File indexing completed on 2025-08-05 08:14:31
0001 #ifndef MACRO_FUN4ALLG4SPHENIX_C
0002 #define MACRO_FUN4ALLG4SPHENIX_C
0003
0004 #include <../src/pi0ClusterAna.h>
0005 #include <GlobalVariables.C>
0006
0007 #include <DisplayOn.C>
0008 #include <G4Setup_sPHENIX.C>
0009 #include <G4_Bbc.C>
0010 #include <G4_CaloTrigger.C>
0011 #include <G4_Centrality.C>
0012 #include <G4_DSTReader.C>
0013 #include <G4_Global.C>
0014 #include <G4_HIJetReco.C>
0015 #include <G4_Input.C>
0016 #include <G4_Jets.C>
0017 #include <G4_KFParticle.C>
0018 #include <G4_ParticleFlow.C>
0019 #include <G4_Production.C>
0020 #include <G4_TopoClusterReco.C>
0021 #include <G4_Tracking.C>
0022 #include <G4_User.C>
0023 #include <QA.C>
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(libfun4all.so)
0033 R__LOAD_LIBRARY(libpi0ClusterAna.so)
0034
0035
0036
0037 int Fun4All_Pi0Gen_sPHENIX(
0038 const int nEvents = 1,
0039 const int pid = 111,
0040 const string &outputFile = "G4sPHENIX.root",
0041 const string &inputFile = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
0042 const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
0043 const int skip = 0,
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
0064
0065
0066
0067
0068 rc->set_StringFlag("XPLOAD_TAG","sPHENIX_ExampleGT_1");
0069
0070 rc->set_StringFlag("XPLOAD_CONFIG","sPHENIX_cdb");
0071
0072 rc->set_uint64Flag("TIMESTAMP",12345678912345);
0073
0074
0075
0076
0077
0078
0079 Input::VERBOSITY = 0;
0080
0081
0082
0083
0084
0085
0086 INPUTREADHITS::filename[0] = inputFile;
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 INPUTEMBED::filename[0] = embed_input_file;
0097
0098
0099
0100 Input::SIMPLE = true;
0101
0102 Input::SIMPLE_VERBOSITY = 0;
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 INPUTHEPMC::filename = inputFile;
0125
0126
0127
0128
0129
0130
0131
0132
0133 InputInit();
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 if (Input::SIMPLE)
0144 {
0145 INPUTGENERATOR::SimpleEventGenerator[0]->add_particles(pid, 1);
0146
0147 if (Input::HEPMC || Input::EMBED)
0148 {
0149 INPUTGENERATOR::SimpleEventGenerator[0]->set_reuse_existing_vertex(true);
0150 INPUTGENERATOR::SimpleEventGenerator[0]->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0151 }
0152 else
0153 {
0154 INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Gaus,
0155 PHG4SimpleEventGenerator::Gaus,
0156 PHG4SimpleEventGenerator::Gaus);
0157 INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0., 0.);
0158 INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0.01, 0.01, 5.);
0159 }
0160 INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-1.2, 1.2);
0161 INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI);
0162 INPUTGENERATOR::SimpleEventGenerator[0]->set_pt_range(2, 20.);
0163 }
0164
0165
0166
0167 if (Input::UPSILON)
0168 {
0169 INPUTGENERATOR::VectorMesonGenerator[0]->add_decay_particles("e", 0);
0170 INPUTGENERATOR::VectorMesonGenerator[0]->set_rapidity_range(-1, 1);
0171 INPUTGENERATOR::VectorMesonGenerator[0]->set_pt_range(0., 10.);
0172
0173 INPUTGENERATOR::VectorMesonGenerator[0]->set_upsilon_1s();
0174 if (Input::HEPMC || Input::EMBED)
0175 {
0176 INPUTGENERATOR::VectorMesonGenerator[0]->set_reuse_existing_vertex(true);
0177 INPUTGENERATOR::VectorMesonGenerator[0]->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0178 }
0179 }
0180
0181
0182
0183 if (Input::GUN)
0184 {
0185 INPUTGENERATOR::Gun[0]->AddParticle("pi-", 0, 1, 0);
0186 INPUTGENERATOR::Gun[0]->set_vtx(0, 0, 0);
0187 }
0188
0189
0190 if (Input::PYTHIA6)
0191 {
0192
0193 Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia6);
0194 }
0195
0196 if (Input::PYTHIA8)
0197 {
0198
0199 Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8);
0200 }
0201
0202
0203
0204
0205
0206
0207 if (Input::HEPMC)
0208 {
0209
0210 Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCInputManager);
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222 if (Input::PILEUPRATE > 0)
0223 {
0224
0225 INPUTMANAGER::HepMCPileupInputManager->CopyHelperSettings(INPUTMANAGER::HepMCInputManager);
0226
0227
0228 }
0229 }
0230 if (Input::PILEUPRATE > 0)
0231 {
0232
0233 Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCPileupInputManager);
0234 }
0235
0236 InputRegister();
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246 Enable::DSTOUT_COMPRESS = false;
0247 DstOut::OutputDir = outdir;
0248 DstOut::OutputFile = outputFile;
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261 Enable::QA = false;
0262
0263
0264
0265
0266
0267
0268
0269
0270 Enable::BBCFAKE = true;
0271
0272 Enable::PIPE = true;
0273
0274
0275
0276 Enable::MVTX = true;
0277
0278 Enable::MVTX_CLUSTER = Enable::MVTX_CELL && true;
0279 Enable::MVTX_QA = Enable::MVTX_CLUSTER && Enable::QA && true;
0280 Enable::TrackingService = false;
0281
0282 Enable::INTT = true;
0283
0284
0285
0286 Enable::INTT_CLUSTER = Enable::INTT_CELL && true;
0287 Enable::INTT_QA = Enable::INTT_CLUSTER && Enable::QA && true;
0288
0289 Enable::TPC = true;
0290
0291
0292 Enable::TPC_CLUSTER = Enable::TPC_CELL && true;
0293 Enable::TPC_QA = Enable::TPC_CLUSTER && Enable::QA && true;
0294
0295 Enable::MICROMEGAS = true;
0296
0297 Enable::MICROMEGAS_CLUSTER = Enable::MICROMEGAS_CELL && true;
0298 Enable::MICROMEGAS_QA = Enable::MICROMEGAS_CLUSTER && Enable::QA && true;
0299
0300
0301 Enable::TRACKING_EVAL = false;
0302 Enable::TRACKING_QA = false;
0303
0304
0305
0306
0307
0308 Enable::CEMC = true;
0309 Enable::CEMC_ABSORBER = true;
0310 Enable::CEMC_CELL = Enable::CEMC && true;
0311 Enable::CEMC_TOWER = Enable::CEMC_CELL && true;
0312 Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && true;
0313 Enable::CEMC_EVAL = false;
0314 Enable::CEMC_QA = false;
0315
0316 Enable::HCALIN =false;
0317 Enable::HCALIN_ABSORBER = true;
0318 Enable::HCALIN_CELL = Enable::HCALIN && true;
0319 Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true;
0320 Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true;
0321 Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true;
0322 Enable::HCALIN_QA = Enable::HCALIN_CLUSTER && Enable::QA && true;
0323
0324 Enable::MAGNET = false;
0325 Enable::MAGNET_ABSORBER = false;
0326
0327 Enable::HCALOUT = false;
0328 Enable::HCALOUT_ABSORBER = true;
0329 Enable::HCALOUT_CELL = Enable::HCALOUT && true;
0330 Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true;
0331 Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true;
0332 Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true;
0333 Enable::HCALOUT_QA = Enable::HCALOUT_CLUSTER && Enable::QA && true;
0334
0335 Enable::EPD = false;
0336
0337
0338
0339
0340 G4BEAMLINE::skin_thickness = 0.5;
0341
0342 Enable::ZDC = false;
0343
0344
0345 Enable::ZDC_TOWER = Enable::ZDC && true;
0346 Enable::ZDC_EVAL = Enable::ZDC_TOWER && true;
0347
0348
0349
0350
0351 Enable::PLUGDOOR_BLACKHOLE = true;
0352
0353 Enable::GLOBAL_RECO = true;
0354
0355
0356
0357
0358
0359
0360
0361 Enable::CALOTRIGGER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER && false;
0362
0363 Enable::JETS = false;
0364 Enable::JETS_EVAL = Enable::JETS && true;
0365 Enable::JETS_QA = Enable::JETS && Enable::QA && true;
0366
0367
0368
0369
0370 Enable::HIJETS = false && Enable::JETS && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER;
0371
0372
0373 Enable::TOPOCLUSTER = false && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER;
0374
0375 Enable::PARTICLEFLOW = true && Enable::TOPOCLUSTER;
0376
0377 Enable::CENTRALITY = true;
0378
0379
0380 Enable::BLACKHOLE = true;
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410 G4Init();
0411
0412
0413
0414
0415 if (!Input::READHITS)
0416 {
0417 G4Setup();
0418 }
0419
0420
0421
0422
0423
0424 if (Enable::BBC || Enable::BBCFAKE) Bbc_Reco();
0425
0426 if (Enable::MVTX_CELL) Mvtx_Cells();
0427 if (Enable::INTT_CELL) Intt_Cells();
0428 if (Enable::TPC_CELL) TPC_Cells();
0429 if (Enable::MICROMEGAS_CELL) Micromegas_Cells();
0430
0431 if (Enable::CEMC_CELL) CEMC_Cells();
0432
0433 if (Enable::HCALIN_CELL) HCALInner_Cells();
0434
0435 if (Enable::HCALOUT_CELL) HCALOuter_Cells();
0436
0437
0438
0439
0440
0441 if (Enable::CEMC_TOWER) CEMC_Towers();
0442 if (Enable::CEMC_CLUSTER) CEMC_Clusters();
0443
0444
0445
0446
0447
0448 if (Enable::HCALIN_TOWER) HCALInner_Towers();
0449 if (Enable::HCALIN_CLUSTER) HCALInner_Clusters();
0450
0451 if (Enable::HCALOUT_TOWER) HCALOuter_Towers();
0452 if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters();
0453
0454
0455 if (Enable::TOPOCLUSTER) TopoClusterReco();
0456
0457
0458
0459
0460 if(Enable::TRACKING_TRACK)
0461 {
0462 TrackingInit();
0463 }
0464 if (Enable::MVTX_CLUSTER) Mvtx_Clustering();
0465 if (Enable::INTT_CLUSTER) Intt_Clustering();
0466 if (Enable::TPC_CLUSTER) TPC_Clustering();
0467 if (Enable::MICROMEGAS_CLUSTER) Micromegas_Clustering();
0468
0469 if (Enable::TRACKING_TRACK)
0470 {
0471 Tracking_Reco();
0472 }
0473
0474
0475
0476
0477 if (Enable::GLOBAL_RECO && Enable::GLOBAL_FASTSIM)
0478 {
0479 cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not both" << endl;
0480 gSystem->Exit(1);
0481 }
0482 if (Enable::GLOBAL_RECO)
0483 {
0484 Global_Reco();
0485 }
0486 else if (Enable::GLOBAL_FASTSIM)
0487 {
0488 Global_FastSim();
0489 }
0490
0491
0492
0493
0494
0495 if (Enable::CENTRALITY)
0496 {
0497 Centrality();
0498 }
0499
0500
0501
0502
0503
0504 if (Enable::CALOTRIGGER)
0505 {
0506 CaloTrigger_Sim();
0507 }
0508
0509
0510
0511
0512
0513 if (Enable::JETS) Jet_Reco();
0514 if (Enable::HIJETS) HIJetReco();
0515
0516 if (Enable::PARTICLEFLOW) ParticleFlow();
0517
0518
0519
0520
0521 string outputroot = outputFile;
0522 string remove_this = ".root";
0523 size_t pos = outputroot.find(remove_this);
0524 if (pos != string::npos)
0525 {
0526 outputroot.erase(pos, remove_this.length());
0527 }
0528
0529 if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + "_g4svtx_eval.root");
0530
0531 if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + "_g4cemc_eval.root");
0532
0533 if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + "_g4hcalin_eval.root");
0534
0535 if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + "_g4hcalout_eval.root");
0536
0537 if (Enable::JETS_EVAL) Jet_Eval(outputroot + "_g4jet_eval.root");
0538
0539 if (Enable::DSTREADER) G4DSTreader(outputroot + "_DSTReader.root");
0540
0541 if (Enable::USER) UserAnalysisInit();
0542
0543
0544
0545
0546
0547 pi0ClusterAna *eval = new pi0ClusterAna("dummy", outputroot + "_pi0ClusterAna.root");
0548 se->registerSubsystem(eval);
0549
0550
0551
0552
0553
0554 if (Enable::KFPARTICLE && Input::UPSILON) KFParticle_Upsilon_Reco();
0555 if (Enable::KFPARTICLE && Input::DZERO) KFParticle_D0_Reco();
0556
0557
0558
0559
0560
0561 if (Enable::CEMC_QA) CEMC_QA();
0562 if (Enable::HCALIN_QA) HCALInner_QA();
0563 if (Enable::HCALOUT_QA) HCALOuter_QA();
0564
0565 if (Enable::JETS_QA) Jet_QA();
0566
0567 if (Enable::MVTX_QA) Mvtx_QA();
0568 if (Enable::INTT_QA) Intt_QA();
0569 if (Enable::TPC_QA) TPC_QA();
0570 if (Enable::MICROMEGAS_QA) Micromegas_QA();
0571 if (Enable::TRACKING_QA) Tracking_QA();
0572
0573 if (Enable::TRACKING_QA && Enable::CEMC_QA && Enable::HCALIN_QA && Enable::HCALOUT_QA) QA_G4CaloTracking();
0574
0575
0576
0577
0578
0579 InputManagers();
0580
0581 if (Enable::PRODUCTION)
0582 {
0583 Production_CreateOutputDir();
0584 }
0585
0586 if (Enable::DSTOUT)
0587 {
0588 string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile;
0589 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile);
0590 if (Enable::DSTOUT_COMPRESS)
0591 {
0592 ShowerCompress();
0593 DstCompress(out);
0594 }
0595 se->registerOutputManager(out);
0596 }
0597
0598
0599
0600 if (Enable::DISPLAY)
0601 {
0602 DisplayOn();
0603
0604 gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
0605 gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");");
0606
0607 cout << "-------------------------------------------------" << endl;
0608 cout << "You are in event display mode. Run one event with" << endl;
0609 cout << "se->run(1)" << endl;
0610 cout << "Run Geant4 command with following examples" << endl;
0611 gROOT->ProcessLine("displaycmd()");
0612
0613 return 0;
0614 }
0615
0616
0617 if (nEvents < 0)
0618 {
0619 return 0;
0620 }
0621
0622
0623 if (nEvents == 0 && !Input::HEPMC && !Input::READHITS && INPUTEMBED::REPEAT)
0624 {
0625 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0626 cout << "it will run forever, so I just return without running anything" << endl;
0627 return 0;
0628 }
0629
0630 se->skip(skip);
0631 se->run(nEvents);
0632
0633
0634
0635
0636
0637 if (Enable::QA) QA_Output(outputroot + "_qa.root");
0638
0639
0640
0641
0642
0643 se->End();
0644 std::cout << "All done" << std::endl;
0645 delete se;
0646 if (Enable::PRODUCTION)
0647 {
0648 Production_MoveOutput();
0649 }
0650
0651 gSystem->Exit(0);
0652 return 0;
0653 }
0654 #endif