Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_Calo.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_Calo.C
1 #pragma once
2 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
3 #include <fun4all/SubsysReco.h>
7 #include <phool/recoConsts.h>
10 
11 #include <caloreco/RawClusterBuilderTemplate.h>
14 
15 #include <caloreco/CaloTowerBuilder.h>
16 #include <caloreco/CaloWaveformProcessing.h>
17 
18 #include <ffamodules/FlagHandler.h>
19 #include <ffamodules/HeadReco.h>
20 #include <ffamodules/SyncReco.h>
22 
23 #include <caloreco/TowerInfoDeadHotMask.h>
24 #include <caloreco/DeadHotMapLoader.h>
25 #include <caloreco/RawClusterDeadHotMask.h>
26 
27 
28 #include <caloana/CaloAna.h>
30 #include <fun4all/Fun4AllUtils.h>
31 R__LOAD_LIBRARY(libfun4all.so)
32 R__LOAD_LIBRARY(libfun4allraw.so)
33 R__LOAD_LIBRARY(libcalo_reco.so)
34 R__LOAD_LIBRARY(libcaloana.so)
35 R__LOAD_LIBRARY(libffamodules.so)
36 #endif
37 
38 void Fun4All_Calo(int nevents = 100,const std::string &fname = "input.txt")
39 {
40 
41  bool enableMasking = 0;
42 
44  int verbosity = 0;
45 
46  se->Verbosity(verbosity);
48 
49  ifstream file(fname);
50  string first_file;
51  getline(file, first_file);
52 
53  //===============
54  // conditions DB flags
55  //===============
56  pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first_file);
57  int runnumber = runseg.first;
58  cout << "run number = " << runnumber << endl;
59 
60  // global tag
61  rc->set_StringFlag("CDB_GLOBALTAG","MDC2");
62  // // 64 bit timestamp
63  rc->set_uint64Flag("TIMESTAMP",runnumber);
64 
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 = "CALOHIST_" + filename;
72 
73 
75  // masking
76  if (enableMasking)
77  {
78  std::cout << "Loading EMCal deadmap" << std::endl;
79  DeadHotMapLoader *towerMapCemc = new DeadHotMapLoader("CEMC");
80  towerMapCemc->detector("CEMC");
81  se->registerSubsystem(towerMapCemc);
82 
83  std::cout << "Loading ihcal deadmap" << std::endl;
84  DeadHotMapLoader *towerMapHCalin = new DeadHotMapLoader("HCALIN");
85  towerMapHCalin->detector("HCALIN");
86  se->registerSubsystem(towerMapHCalin);
87 
88  std::cout << "Loading ohcal deadmap" << std::endl;
89  DeadHotMapLoader *towerMapHCalout = new DeadHotMapLoader("HCALOUT");
90  towerMapHCalout->detector("HCALOUT");
91  se->registerSubsystem(towerMapHCalout);
92 
93  std::cout << "Loading cemc masker" << std::endl;
94  TowerInfoDeadHotMask *towerMaskCemc = new TowerInfoDeadHotMask("CEMC");
95  towerMaskCemc->detector("CEMC");
96  se->registerSubsystem(towerMaskCemc);
97 
98  std::cout << "Loading hcal maskers" << std::endl;
99  TowerInfoDeadHotMask *towerMaskHCalin = new TowerInfoDeadHotMask("HCALIN");
100  towerMaskHCalin->detector("HCALIN");
101  se->registerSubsystem(towerMaskHCalin);
102 
103  TowerInfoDeadHotMask *towerMaskHCalout = new TowerInfoDeadHotMask("HCALOUT");
104  towerMaskHCalout->detector("HCALOUT");
105  se->registerSubsystem(towerMaskHCalout);
106 
108  // Clusters
109  std::cout << "Building clusters" << std::endl;
110  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
111  ClusterBuilder->Detector("CEMC");
112  ClusterBuilder->set_threshold_energy(0.030); // for when using basic calibration
113  std::string emc_prof = getenv("CALIBRATIONROOT");
114  emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
115  ClusterBuilder->LoadProfile(emc_prof);
116  ClusterBuilder->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower
117  se->registerSubsystem(ClusterBuilder);
118 
119 
120  std::cout << "Masking clusters" << std::endl;
121  RawClusterDeadHotMask *clusterMask = new RawClusterDeadHotMask("clusterMask");
122  clusterMask->detector("CEMC");
123  se->registerSubsystem(clusterMask);
124 
125  }
126 
127  CaloAna *ca = new CaloAna("calomodulename",OutFile);
128  ca->set_timing_cut_width(200); //integers for timing width, > 1 : wider cut around max peak time
129  ca->apply_vertex_cut(false);
130  ca->set_vertex_cut(20.);
131  se->registerSubsystem(ca);
132 
133  se->run(nevents); //update number of events as needed
134  se->End();
135 
136 }