Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_Year1.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_Year1.C
1 #ifndef FUN4ALL_YEAR1_C
2 #define FUN4ALL_YEAR1_C
3 
4 #include <caloreco/CaloTowerBuilder.h>
5 #include <caloreco/CaloTowerCalib.h>
6 #include <caloreco/CaloTowerStatus.h>
7 #include <caloreco/CaloWaveformProcessing.h>
8 #include <caloreco/DeadHotMapLoader.h>
9 #include <caloreco/RawClusterBuilderTemplate.h>
10 #include <caloreco/RawClusterDeadHotMask.h>
11 #include <caloreco/RawClusterPositionCorrection.h>
12 #include <caloreco/TowerInfoDeadHotMask.h>
13 
14 #include <mbd/MbdReco.h>
15 
17 
19 #include <ffamodules/FlagHandler.h>
20 #include <ffamodules/HeadReco.h>
21 #include <ffamodules/SyncReco.h>
22 
24 
29 #include <fun4all/Fun4AllServer.h>
30 #include <fun4all/Fun4AllUtils.h>
31 #include <fun4all/SubsysReco.h>
32 
33 #include <phool/recoConsts.h>
34 
36 #include <calotrigger/MinimumBiasClassifier.h>
37 
38 #include <calovalid/CaloValid.h>
39 
40 R__LOAD_LIBRARY(libfun4all.so)
41 R__LOAD_LIBRARY(libfun4allraw.so)
42 R__LOAD_LIBRARY(libcalo_reco.so)
43 R__LOAD_LIBRARY(libcalotrigger.so)
44 R__LOAD_LIBRARY(libcentrality.so)
45 R__LOAD_LIBRARY(libffamodules.so)
46 R__LOAD_LIBRARY(libmbd.so)
47 R__LOAD_LIBRARY(libglobalvertex.so)
48 R__LOAD_LIBRARY(libcalovalid.so)
49 
50 void Fun4All_Year1(const std::string &fname = "/sphenix/lustre01/sphnxpro/commissioning/aligned_prdf/beam-00021774-0000.prdf", int nEvents = 10)
51 {
52  bool enableMasking = 0;
53  bool addZeroSupCaloNodes = 1;
54  // v1 uncomment:
55  // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs:::kPRDFTowerv1;
56  // v2 uncomment:
58  // v3 uncomment:
59  // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform;
60 
62  se->Verbosity(0);
63 
65 
66  pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname);
67  int runnumber = runseg.first;
68  int segment = runseg.second;
69  char outfile[100];
70  char outfile_hist[100];
71  sprintf(outfile, "DST_CALOR-%08d-%04d.root", runnumber, segment);
72  sprintf(outfile_hist, "HIST_CALOR-%08d-%04d.root", runnumber, segment);
73  string fulloutfile = string("./") + outfile;
74  string fulloutfile_hist = string("./") + outfile_hist;
75  //===============
76  // conditions DB flags
77  //===============
78  // ENABLE::CDB = true;
79  // global tag
80  rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
81  // // 64 bit timestamp
82  rc->set_uint64Flag("TIMESTAMP", runnumber);
84 
85  // Sync Headers and Flags
86  SyncReco *sync = new SyncReco();
87  se->registerSubsystem(sync);
88 
89  HeadReco *head = new HeadReco();
90  se->registerSubsystem(head);
91 
92  FlagHandler *flag = new FlagHandler();
93  se->registerSubsystem(flag);
94 
95  // MBD/BBC Reconstruction
96  MbdReco *mbdreco = new MbdReco();
97  se->registerSubsystem(mbdreco);
98 
99  // Official vertex storage
100  GlobalVertexReco *gvertex = new GlobalVertexReco();
101  se->registerSubsystem(gvertex);
102 
104  // build towers
105  CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCalBUILDER");
108  ctbEMCal->set_builder_type(buildertype);
109  ctbEMCal->set_nsamples(16);
110  se->registerSubsystem(ctbEMCal);
111 
112  CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
115  ctbIHCal->set_builder_type(buildertype);
116  ctbIHCal->set_nsamples(31);
117  se->registerSubsystem(ctbIHCal);
118 
119  CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
122  ctbOHCal->set_builder_type(buildertype);
123  ctbOHCal->set_nsamples(31);
124  se->registerSubsystem(ctbOHCal);
125 
126  CaloTowerBuilder *ca4 = new CaloTowerBuilder("zdc");
128  ca4->set_nsamples(31);
131  se->registerSubsystem(ca4);
132 
134  // set statuses on raw towers
135  std::cout << "status setters" << std::endl;
136  CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS");
138  statusEMC->set_time_cut(1);
139  se->registerSubsystem(statusEMC);
140 
141  CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
143  statusHCalIn->set_time_cut(2);
144  se->registerSubsystem(statusHCalIn);
145 
146  CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
148  statusHCALOUT->set_time_cut(2);
149  se->registerSubsystem(statusHCALOUT);
150 
152  // Calibrate towers
153  std::cout << "Calibrating EMCal" << std::endl;
154  CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
156  se->registerSubsystem(calibEMC);
157 
158  std::cout << "Calibrating OHcal" << std::endl;
159  CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
161  se->registerSubsystem(calibOHCal);
162 
163  std::cout << "Calibrating IHcal" << std::endl;
164  CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
166  se->registerSubsystem(calibIHCal);
167 
168  std::cout << "Calibrating ZDC" << std::endl;
169  CaloTowerCalib *calibZDC = new CaloTowerCalib("ZDC");
171  se->registerSubsystem(calibZDC);
172 
174  // masking
175  if (enableMasking)
176  {
177  std::cout << "Loading EMCal deadmap" << std::endl;
178  DeadHotMapLoader *towerMapCemc = new DeadHotMapLoader("CEMC");
179  towerMapCemc->detector("CEMC");
180  se->registerSubsystem(towerMapCemc);
181 
182  std::cout << "Loading ihcal deadmap" << std::endl;
183  DeadHotMapLoader *towerMapHCalin = new DeadHotMapLoader("HCALIN");
184  towerMapHCalin->detector("HCALIN");
185  se->registerSubsystem(towerMapHCalin);
186 
187  std::cout << "Loading ohcal deadmap" << std::endl;
188  DeadHotMapLoader *towerMapHCalout = new DeadHotMapLoader("HCALOUT");
189  towerMapHCalout->detector("HCALOUT");
190  se->registerSubsystem(towerMapHCalout);
191 
192  std::cout << "Loading cemc masker" << std::endl;
193  TowerInfoDeadHotMask *towerMaskCemc = new TowerInfoDeadHotMask("CEMC");
194  towerMaskCemc->detector("CEMC");
195  se->registerSubsystem(towerMaskCemc);
196 
197  std::cout << "Loading hcal maskers" << std::endl;
198  TowerInfoDeadHotMask *towerMaskHCalin = new TowerInfoDeadHotMask("HCALIN");
199  towerMaskHCalin->detector("HCALIN");
200  se->registerSubsystem(towerMaskHCalin);
201 
202  TowerInfoDeadHotMask *towerMaskHCalout = new TowerInfoDeadHotMask("HCALOUT");
203  towerMaskHCalout->detector("HCALOUT");
204  se->registerSubsystem(towerMaskHCalout);
205  }
206 
207  std::cout << "Adding Geometry file" << std::endl;
208  Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
209  std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
210  intrue2->AddFile(geoLocation);
211  se->registerInputManager(intrue2);
212 
214  // Clusters
215  std::cout << "Building clusters" << std::endl;
216  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
217  ClusterBuilder->Detector("CEMC");
218  ClusterBuilder->set_threshold_energy(0.030); // for when using basic calibration
219  std::string emc_prof = getenv("CALIBRATIONROOT");
220  emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
221  ClusterBuilder->LoadProfile(emc_prof);
222  ClusterBuilder->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower
223  se->registerSubsystem(ClusterBuilder);
224 
225  if (enableMasking)
226  {
227  std::cout << "Masking clusters" << std::endl;
228  RawClusterDeadHotMask *clusterMask = new RawClusterDeadHotMask("clusterMask");
229  clusterMask->detector("CEMC");
230  se->registerSubsystem(clusterMask);
231  }
232 
233  std::cout << "Applying Position Dependent Correction" << std::endl;
234  RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
235  clusterCorrection->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower
236  se->registerSubsystem(clusterCorrection);
237 
239  // Calo node with software zero supression
240  if (addZeroSupCaloNodes)
241  {
242  CaloTowerBuilder *ctbEMCal_SZ = new CaloTowerBuilder("EMCalBUILDER_ZS");
245  ctbEMCal_SZ->set_nsamples(8);
246  ctbEMCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
247  ctbEMCal_SZ->set_softwarezerosuppression(true, 100000000);
248  se->registerSubsystem(ctbEMCal_SZ);
249 
250  CaloTowerBuilder *ctbIHCal_SZ = new CaloTowerBuilder("HCALINBUILDER_ZS");
253  ctbIHCal_SZ->set_nsamples(8);
254  ctbIHCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
255  ctbIHCal_SZ->set_softwarezerosuppression(true, 100000000);
256  se->registerSubsystem(ctbIHCal_SZ);
257 
258  CaloTowerBuilder *ctbOHCal_SZ = new CaloTowerBuilder("HCALOUTBUILDER_SZ");
261  ctbOHCal_SZ->set_nsamples(8);
262  ctbOHCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
263  ctbOHCal_SZ->set_softwarezerosuppression(true, 100000000);
264  se->registerSubsystem(ctbOHCal_SZ);
265 
266  CaloTowerCalib *calibEMC_SZ = new CaloTowerCalib("CEMCCALIB_SZ");
268  calibEMC_SZ->set_inputNodePrefix("TOWERS_SZ_");
269  calibEMC_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
270  se->registerSubsystem(calibEMC_SZ);
271 
272  CaloTowerCalib *calibIHCal_SZ = new CaloTowerCalib("IHCALCALIB_SZ");
274  calibIHCal_SZ->set_inputNodePrefix("TOWERS_SZ_");
275  calibIHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
276  se->registerSubsystem(calibIHCal_SZ);
277 
278  CaloTowerCalib *calibOHCal_SZ = new CaloTowerCalib("OHCALCALIB_SZ");
280  calibOHCal_SZ->set_inputNodePrefix("TOWERS_SZ_");
281  calibOHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
282  se->registerSubsystem(calibOHCal_SZ);
283  }
284 
285  MinimumBiasClassifier *minimumbiasclassifier = new MinimumBiasClassifier();
286  se->registerSubsystem(minimumbiasclassifier);
287 
288  CentralityReco *centralityreco = new CentralityReco();
289  se->registerSubsystem(centralityreco);
291  // Validation
292  CaloValid *ca = new CaloValid("calomodulename",fulloutfile_hist);
293  ca->set_timing_cut_width(200); //integers for timing width, > 1 : wider cut around max peak time
294  ca->apply_vertex_cut(false);
295  ca->set_vertex_cut(20.);
296  se->registerSubsystem(ca);
297 
298 
300  In->AddFile(fname);
301  se->registerInputManager(In);
302 
303  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fulloutfile);
304  se->registerOutputManager(out);
305 
306  se->run(nEvents);
307  se->End();
308  CDBInterface::instance()->Print(); // print used DB files
309  se->PrintTimer();
310  delete se;
311  std::cout << "All done!" << std::endl;
312  gSystem->Exit(0);
313 }
314 
315 #endif