Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_EMCal_Hist.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_EMCal_Hist.C
1 
2 #include <caloreco/CaloTowerCalib.h>
3 #include <caloreco/RawClusterBuilderTemplate.h>
4 #include <caloreco/RawClusterDeadHotMask.h>
5 #include <caloreco/RawClusterPositionCorrection.h>
6 
8 #include <ffamodules/HeadReco.h>
9 #include <ffamodules/SyncReco.h>
10 
12 
17 #include <fun4all/Fun4AllServer.h>
18 #include <fun4all/Fun4AllUtils.h>
19 #include <fun4all/SubsysReco.h>
20 
21 #include <phool/recoConsts.h>
22 
24 #include <GlobalVariables.C>
25 
26 #include <litecaloeval/LiteCaloEval.h>
27 
28 R__LOAD_LIBRARY(libcdbobjects)
29 
30 R__LOAD_LIBRARY(libfun4all.so)
31 R__LOAD_LIBRARY(libfun4allraw.so)
32 R__LOAD_LIBRARY(libcalo_reco.so)
33 R__LOAD_LIBRARY(libffamodules.so)
34 R__LOAD_LIBRARY(libmbd.so)
35 R__LOAD_LIBRARY(libglobalvertex.so)
36 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
37 
38 #include <caloana/CaloAna.h>
39 R__LOAD_LIBRARY(libcaloana.so)
40 
41 void Fun4All_EMCal_Hist(int nevents = 0, const std::string &fname = "inputdata.txt")
42 {
43 
45  se->Verbosity(0);
46 
47  // se->Verbosity(verbosity);
49 
50  ifstream file(fname);
51  string first_file;
52  getline(file, first_file);
53 
54  //===============
55  // conditions DB flags
56  //===============
57  pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first_file);
58  int runnumber = runseg.first;
59  cout << "run number = " << runnumber << endl;
60 
61  // global tag
62  rc->set_StringFlag("CDB_GLOBALTAG", "MDC2");
63  // // 64 bit timestamp
64  rc->set_uint64Flag("TIMESTAMP", runnumber);
65 
66  Fun4AllInputManager *in = new Fun4AllDstInputManager("DST_TOWERS");
67  in->AddListFile(fname);
68  se->registerInputManager(in);
69 
70  std::string filename = first_file.substr(first_file.find_last_of("/\\") + 1);
71  std::string OutFile = Form("OUTHIST_iter_%s",filename.c_str());
72 
74  // Calibrate towers
75  std::cout << "Calibrating EMCal" << std::endl;
76  CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
78  se->registerSubsystem(calibEMC);
79 
80 
82  // Clusters
83  std::cout << "Building clusters" << std::endl;
84  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
85  ClusterBuilder->Detector("CEMC");
86  ClusterBuilder->set_threshold_energy(0.20); // for when using basic calibration
87  std::string emc_prof = getenv("CALIBRATIONROOT");
88  emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
89  ClusterBuilder->LoadProfile(emc_prof);
90  ClusterBuilder->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower
91  ClusterBuilder->setOutputClusterNodeName("CLUSTERINFO_CEMC2");
92  se->registerSubsystem(ClusterBuilder);
93 
94 /*
95  std::cout << "Applying Position Dependent Correction" << std::endl;
96  RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
97  clusterCorrection->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower
98  se->registerSubsystem(clusterCorrection);
99 */
100 
102  // analysis modules
103  CaloAna *ca = new CaloAna("calomodulename", OutFile);
104  ca->set_timing_cut_width(16);
105  ca->apply_vertex_cut(false);
106  ca->set_vertex_cut(20.);
107  se->registerSubsystem(ca);
108 
109  se->run(nevents);
110  se->End();
111  se->PrintTimer();
112  delete se;
113 
114  TFile* f_done_signal = new TFile("DONE.root","recreate");
115  std::cout << "All done!" << std::endl;
116  gSystem->Exit(0);
117 
118 }
119