File indexing completed on 2025-08-06 08:15:33
0001 #ifndef MACRO_FUN4ALLG4CALO_C
0002 #define MACRO_FUN4ALLG4CALO_C
0003
0004 #include <GlobalVariables.C>
0005 #include <../../pi0Efficiency.h>
0006
0007 #include <DisplayOn.C>
0008 #include <G4Setup_sPHENIX.C>
0009 #include <G4_Bbc.C>
0010 #include <G4_CaloTrigger.C>
0011 #include <G4_DSTReader.C>
0012 #include <G4_Global.C>
0013 #include <G4_HIJetReco.C>
0014 #include <G4_Input.C>
0015 #include <G4_Jets.C>
0016 #include <G4_ParticleFlow.C>
0017 #include <G4_Production.C>
0018 #include <G4_TopoClusterReco.C>
0019 #include <G4_Tracking.C>
0020 #include <G4_User.C>
0021
0022 #include <ffamodules/FlagHandler.h>
0023 #include <ffamodules/XploadInterface.h>
0024
0025 #include <fun4all/Fun4AllDstOutputManager.h>
0026 #include <fun4all/Fun4AllOutputManager.h>
0027 #include <fun4all/Fun4AllServer.h>
0028
0029 #include <phool/PHRandomSeed.h>
0030 #include <phool/recoConsts.h>
0031
0032 R__LOAD_LIBRARY(libffamodules.so)
0033 R__LOAD_LIBRARY(libfun4all.so)
0034 R__LOAD_LIBRARY(libpi0Efficiency.so)
0035
0036
0037
0038
0039 int Fun4All_G4_Calo(
0040 const int nEvents = 1,
0041 const string &inputFile0 = "g4hits.list",
0042
0043 const string &outputFile = "G4sPHENIX_calo.root",
0044 const string &outdir = ".")
0045 {
0046 Fun4AllServer *se = Fun4AllServer::instance();
0047 se->Verbosity(0);
0048
0049
0050 PHRandomSeed::Verbosity(0);
0051
0052
0053 recoConsts *rc = recoConsts::instance();
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 Enable::XPLOAD = true;
0064 rc->set_StringFlag("XPLOAD_TAG",XPLOAD::tag);
0065 rc->set_StringFlag("XPLOAD_CONFIG",XPLOAD::config);
0066 rc->set_uint64Flag("TIMESTAMP",XPLOAD::timestamp);
0067
0068
0069
0070
0071
0072 Input::VERBOSITY = 1;
0073
0074
0075
0076
0077
0078 Input::READHITS = true;
0079 INPUTREADHITS::listfile[0] = inputFile0;
0080
0081
0082
0083
0084
0085
0086
0087 InputInit();
0088
0089
0090 InputRegister();
0091
0092
0093 FlagHandler *flag = new FlagHandler();
0094 se->registerSubsystem(flag);
0095
0096
0097 Enable::PRODUCTION = true;
0098
0099
0100
0101
0102
0103 Enable::DSTOUT = true;
0104 Enable::DSTOUT_COMPRESS = false;
0105 DstOut::OutputDir = outdir;
0106 DstOut::OutputFile = outputFile;
0107
0108
0109
0110
0111
0112 Enable::DISPLAY = false;
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 Enable::CEMC = true;
0123 Enable::CEMC_CELL = Enable::CEMC && true;
0124 Enable::CEMC_TOWER = Enable::CEMC_CELL && true;
0125 Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && true;
0126 Enable::CEMC_EVAL = Enable::CEMC_CLUSTER && true;
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 Enable::GLOBAL_RECO = true;
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 G4Init();
0179
0180
0181
0182
0183 if (!Input::READHITS)
0184 {
0185 G4Setup();
0186 }
0187
0188
0189
0190
0191
0192 if (Enable::BBC || Enable::BBCFAKE) Bbc_Reco();
0193
0194 if (Enable::MVTX_CELL) Mvtx_Cells();
0195 if (Enable::INTT_CELL) Intt_Cells();
0196 if (Enable::TPC_CELL) TPC_Cells();
0197 if (Enable::MICROMEGAS_CELL) Micromegas_Cells();
0198
0199 if (Enable::CEMC_CELL) CEMC_Cells();
0200
0201 if (Enable::HCALIN_CELL) HCALInner_Cells();
0202
0203 if (Enable::HCALOUT_CELL) HCALOuter_Cells();
0204
0205
0206
0207
0208
0209 if (Enable::CEMC_TOWER) CEMC_Towers();
0210 if (Enable::CEMC_CLUSTER) CEMC_Clusters();
0211
0212
0213
0214
0215
0216 if (Enable::HCALIN_TOWER) HCALInner_Towers();
0217 if (Enable::HCALIN_CLUSTER) HCALInner_Clusters();
0218
0219 if (Enable::HCALOUT_TOWER) HCALOuter_Towers();
0220 if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters();
0221
0222
0223 if (Enable::TOPOCLUSTER) TopoClusterReco();
0224
0225 if (Enable::DSTOUT_COMPRESS) ShowerCompress();
0226
0227
0228
0229
0230 if (Enable::MVTX_CLUSTER) Mvtx_Clustering();
0231 if (Enable::INTT_CLUSTER) Intt_Clustering();
0232 if (Enable::TPC_CLUSTER) TPC_Clustering();
0233 if (Enable::MICROMEGAS_CLUSTER) Micromegas_Clustering();
0234
0235 if (Enable::TRACKING_TRACK)
0236 {
0237 TrackingInit();
0238 Tracking_Reco();
0239 }
0240
0241
0242
0243
0244 if (Enable::GLOBAL_RECO && Enable::GLOBAL_FASTSIM)
0245 {
0246 cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not both" << endl;
0247 gSystem->Exit(1);
0248 }
0249 if (Enable::GLOBAL_RECO)
0250 {
0251 Global_Reco();
0252 }
0253 else if (Enable::GLOBAL_FASTSIM)
0254 {
0255 Global_FastSim();
0256 }
0257
0258
0259
0260
0261
0262 if (Enable::CALOTRIGGER)
0263 {
0264 CaloTrigger_Sim();
0265 }
0266
0267
0268
0269
0270
0271 if (Enable::JETS) Jet_Reco();
0272 if (Enable::HIJETS) HIJetReco();
0273
0274 if (Enable::PARTICLEFLOW) ParticleFlow();
0275
0276
0277
0278
0279 string outputroot = outputFile;
0280 string remove_this = ".root";
0281 size_t pos = outputroot.find(remove_this);
0282 if (pos != string::npos)
0283 {
0284 outputroot.erase(pos, remove_this.length());
0285 }
0286
0287
0288
0289
0290
0291 InputManagers();
0292
0293 if (Enable::PRODUCTION)
0294 {
0295 Production_CreateOutputDir();
0296 }
0297
0298 if (Enable::DSTOUT)
0299 {
0300 string FullOutFile = DstOut::OutputFile;
0301 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile);
0302 out->AddNode("Sync");
0303 out->AddNode("EventHeader");
0304 out->AddNode("TOWER_SIM_HCALIN");
0305 out->AddNode("TOWER_RAW_HCALIN");
0306 out->AddNode("TOWER_CALIB_HCALIN");
0307 out->AddNode("CLUSTER_HCALIN");
0308 out->AddNode("TOWER_SIM_HCALOUT");
0309 out->AddNode("TOWER_RAW_HCALOUT");
0310 out->AddNode("TOWER_CALIB_HCALOUT");
0311 out->AddNode("CLUSTER_HCALOUT");
0312 out->AddNode("TOWER_SIM_CEMC");
0313 out->AddNode("TOWER_RAW_CEMC");
0314 out->AddNode("TOWER_CALIB_CEMC");
0315 out->AddNode("CLUSTER_CEMC");
0316 out->AddNode("CLUSTER_POS_COR_CEMC");
0317
0318 out->AddNode("TOPOCLUSTER_ALLCALO");
0319 out->AddNode("TOPOCLUSTER_EMCAL");
0320 out->AddNode("TOPOCLUSTER_HCAL");
0321 out->AddNode("GlobalVertexMap");
0322 if (Enable::DSTOUT_COMPRESS) DstCompress(out);
0323 se->registerOutputManager(out);
0324 }
0325
0326
0327
0328 if (Enable::DISPLAY)
0329 {
0330 DisplayOn();
0331
0332 gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
0333 gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");");
0334
0335 cout << "-------------------------------------------------" << endl;
0336 cout << "You are in event display mode. Run one event with" << endl;
0337 cout << "se->run(1)" << endl;
0338 cout << "Run Geant4 command with following examples" << endl;
0339 gROOT->ProcessLine("displaycmd()");
0340
0341 return 0;
0342 }
0343
0344
0345 if (nEvents < 0)
0346 {
0347 return 0;
0348 }
0349
0350 if (nEvents == 0 && !Input::HEPMC && !Input::READHITS)
0351 {
0352 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0353 cout << "it will run forever, so I just return without running anything" << endl;
0354 return 0;
0355 }
0356 pi0Efficiency *eval = new pi0Efficiency("dummy", outputroot + "_pi0Efficiency.root");
0357 se->registerSubsystem(eval);
0358
0359 se->run(nEvents);
0360
0361
0362
0363
0364
0365
0366 se->End();
0367
0368 std::cout << "All done" << std::endl;
0369 delete se;
0370
0371
0372
0373
0374
0375 gSystem->Exit(0);
0376 return 0;
0377 }
0378 #endif