File indexing completed on 2025-08-06 08:12:53
0001 int Fun4All_G4_EICDetector_LQ_reference(
0002 string n="1093",
0003 string ebeam="20",
0004 string pbeam="250",
0005
0006 string inputFile="/direct/phenix+u/spjeffas/LQGENEP/TestOut.1093event.root",
0007 string output="",
0008 const char * outputFile = "G4EICDetector.root"
0009 )
0010 {
0011
0012 const int n_TPC_layers = 40;
0013
0014
0015
0016 int nEvents;
0017 stringstream geek(n);
0018 geek>>nEvents;
0019
0020
0021
0022 string directory = "/direct/phenix+u/spjeffas/leptoquark/output/"+output+"/";
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 const bool readhits = false;
0036
0037
0038 const bool readhepmc = false;
0039
0040
0041 const bool readeictree = true;
0042
0043
0044 const bool runpythia8 = false;
0045
0046
0047 const bool runpythia6 = false;
0048
0049
0050 const bool runhepgen = false;
0051
0052
0053 const bool runsartre = false;
0054
0055
0056
0057
0058
0059 const bool particles = false && !readhits;
0060
0061 const bool usegun = false && !readhits;
0062
0063 const bool upsilons = false && !readhits;
0064
0065
0066
0067
0068
0069
0070 bool do_bbc = true;
0071
0072 bool do_pipe = true;
0073
0074 bool do_svtx = true;
0075 bool do_svtx_cell = do_svtx && true;
0076 bool do_svtx_track = do_svtx_cell && true;
0077 bool do_svtx_eval = do_svtx_track && true;
0078
0079 bool do_pstof = false;
0080
0081 bool do_cemc = true;
0082
0083 bool do_cemc_cell = true;
0084 bool do_cemc_twr = true;
0085 bool do_cemc_cluster = true;
0086 bool do_cemc_eval = true;
0087
0088 bool do_hcalin = true;
0089 bool do_hcalin_cell = true;
0090 bool do_hcalin_twr = true;
0091 bool do_hcalin_cluster = true;
0092 bool do_hcalin_eval = true;
0093
0094 bool do_cemc_cell = do_cemc && true;
0095 bool do_cemc_twr = do_cemc_cell && true;
0096 bool do_cemc_cluster = do_cemc_twr && true;
0097 bool do_cemc_eval = do_cemc_cluster && true;
0098
0099 bool do_hcalin = true;
0100 bool do_hcalin_cell = do_hcalin && true;
0101 bool do_hcalin_twr = do_hcalin_cell && true;
0102 bool do_hcalin_cluster = do_hcalin_twr && true;
0103 bool do_hcalin_eval = do_hcalin_cluster && true;
0104
0105
0106 bool do_magnet = true;
0107
0108 bool do_hcalout = true;
0109
0110 bool do_hcalout_cell = true;
0111 bool do_hcalout_twr = true;
0112 bool do_hcalout_cluster = true;
0113 bool do_hcalout_eval = true;
0114
0115 bool do_global = true;
0116 bool do_global_fastsim = false;
0117
0118 bool do_jet_reco = true;
0119 bool do_jet_eval = true;
0120
0121 bool do_fwd_jet_reco = true;
0122 bool do_fwd_jet_eval = false;
0123
0124 bool do_hcalout_cell = do_hcalout && true;
0125 bool do_hcalout_twr = do_hcalout_cell && true;
0126 bool do_hcalout_cluster = do_hcalout_twr && true;
0127 bool do_hcalout_eval = do_hcalout_cluster && true;
0128
0129
0130
0131 bool do_DIRC = true;
0132
0133
0134 bool do_FGEM = true;
0135 bool do_FGEM_track = do_FGEM && false;
0136
0137 bool do_RICH = true;
0138 bool do_Aerogel = true;
0139
0140 bool do_FEMC = true;
0141 bool do_FEMC_cell = do_FEMC && true;
0142 bool do_FEMC_twr = do_FEMC_cell && true;
0143 bool do_FEMC_cluster = do_FEMC_twr && true;
0144 bool do_FEMC_eval = do_FEMC_cluster && true;
0145
0146 bool do_FHCAL = true;
0147 bool do_FHCAL_cell = do_FHCAL && true;
0148 bool do_FHCAL_twr = do_FHCAL_cell && true;
0149 bool do_FHCAL_cluster = do_FHCAL_twr && true;
0150 bool do_FHCAL_eval = do_FHCAL_cluster && true;
0151
0152
0153 bool do_EGEM = true;
0154 bool do_EGEM_track = do_EGEM && false;
0155
0156 bool do_EEMC = true;
0157 bool do_EEMC_cell = do_EEMC && true;
0158 bool do_EEMC_twr = do_EEMC_cell && true;
0159 bool do_EEMC_cluster = do_EEMC_twr && true;
0160 bool do_EEMC_eval = do_EEMC_cluster && true;
0161
0162
0163 bool do_lepto_analysis = true;
0164
0165
0166 bool do_global = true;
0167 bool do_global_fastsim = false;
0168
0169 bool do_calotrigger = false && do_cemc_twr && do_hcalin_twr && do_hcalout_twr;
0170
0171 bool do_jet_reco = true;
0172 bool do_jet_eval = do_jet_reco && true;
0173
0174 bool do_fwd_jet_reco = true;
0175 bool do_fwd_jet_eval = do_fwd_jet_reco && true;
0176
0177
0178
0179
0180 bool do_HIjetreco = false && do_jet_reco && do_cemc_twr && do_hcalin_twr && do_hcalout_twr;
0181
0182
0183 bool do_dst_compress = false;
0184
0185
0186 bool do_DSTReader = false;
0187
0188
0189
0190
0191
0192 gSystem->Load("libfun4all.so");
0193 gSystem->Load("libg4detectors.so");
0194 gSystem->Load("libphhepmc.so");
0195 gSystem->Load("libg4testbench.so");
0196 gSystem->Load("libg4hough.so");
0197 gSystem->Load("libg4calo.so");
0198 gSystem->Load("libg4eval.so");
0199 gSystem->Load("libeicana.so");
0200
0201
0202 gROOT->LoadMacro("G4Setup_EICDetector.C");
0203 G4Init(do_svtx,do_cemc,do_hcalin,do_magnet,do_hcalout,do_pipe,do_FGEM,do_EGEM,do_FEMC,do_FHCAL,do_EEMC,do_DIRC,do_RICH,do_Aerogel,n_TPC_layers);
0204
0205 int absorberactive = 0;
0206
0207 const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root";
0208 const float magfield_rescale = 1.4/1.5;
0209
0210
0211
0212
0213
0214 Fun4AllServer *se = Fun4AllServer::instance();
0215 se->Verbosity(0);
0216
0217
0218
0219 recoConsts *rc = recoConsts::instance();
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234 if (readhits)
0235 {
0236
0237
0238 }
0239 else if (readhepmc)
0240 {
0241
0242
0243 HepMCNodeReader *hr = new HepMCNodeReader();
0244 se->registerSubsystem(hr);
0245 }
0246 else if (readeictree)
0247 {
0248
0249 ReadEICFiles *eicr = new ReadEICFiles();
0250 eicr->OpenInputFile(inputFile);
0251
0252 se->registerSubsystem(eicr);
0253 }
0254 else if (runpythia8)
0255 {
0256 gSystem->Load("libPHPythia8.so");
0257
0258 PHPythia8* pythia8 = new PHPythia8();
0259
0260 pythia8->set_config_file("/direct/phenix+u/spjeffas/coresoftware/generators/PHPythia8/phpythia8.cfg");
0261 se->registerSubsystem(pythia8);
0262
0263 HepMCNodeReader *hr = new HepMCNodeReader();
0264 se->registerSubsystem(hr);
0265 }
0266 else if (runpythia6)
0267 {
0268 gSystem->Load("libPHPythia6.so");
0269
0270 PHPythia6 *pythia6 = new PHPythia6();
0271
0272 pythia6->set_config_file("/direct/phenix+u/spjeffas/coresoftware/generators/PHPythia6/phpythia6_ep.cfg");
0273 se->registerSubsystem(pythia6);
0274
0275 HepMCNodeReader *hr = new HepMCNodeReader();
0276 se->registerSubsystem(hr);
0277 }
0278 else if (runhepgen)
0279 {
0280 gSystem->Load("libsHEPGen.so");
0281
0282 sHEPGen *hepgen = new sHEPGen();
0283
0284
0285 hepgen->set_datacard_file("hepgen_dvcs.data");
0286 hepgen->set_momentum_electron(-20);
0287 hepgen->set_momentum_hadron(250);
0288 se->registerSubsystem(hepgen);
0289
0290 HepMCNodeReader *hr = new HepMCNodeReader();
0291 se->registerSubsystem(hr);
0292 }
0293 else if (runsartre)
0294 {
0295
0296
0297
0298 gSystem->Load("libPHSartre.so");
0299
0300 PHSartre* mysartre = new PHSartre();
0301
0302 mysartre->set_config_file("sartre.cfg");
0303
0304
0305 PHSartreParticleTrigger* pTrig = new PHSartreParticleTrigger("MySartreTrigger");
0306 pTrig->AddParticles(-11);
0307
0308 pTrig->SetEtaHighLow(1.0,-1.1);
0309 pTrig->PrintConfig();
0310 mysartre->register_trigger((PHSartreGenTrigger *)pTrig);
0311 se->registerSubsystem(mysartre);
0312
0313 HepMCNodeReader *hr = new HepMCNodeReader();
0314 se->registerSubsystem(hr);
0315 }
0316
0317
0318 if(particles)
0319 {
0320
0321 PHG4SimpleEventGenerator *gen = new PHG4SimpleEventGenerator();
0322
0323
0324
0325 gen->add_particles("tau-",1);
0326 if (readhepmc) {
0327 gen->set_reuse_existing_vertex(true);
0328 gen->set_existing_vertex_offset_vector(0.0,0.0,0.0);
0329 } else {
0330 gen->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
0331 PHG4SimpleEventGenerator::Uniform,
0332 PHG4SimpleEventGenerator::Uniform);
0333 gen->set_vertex_distribution_mean(0.0,0.0,0.0);
0334 gen->set_vertex_distribution_width(0.0,0.0,5.0);
0335 }
0336 gen->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform);
0337 gen->set_vertex_size_parameters(0.0,0.0);
0338 gen->set_eta_range(0.1, 0.1);
0339
0340 gen->set_phi_range(TMath::Pi()/2-0.1, TMath::Pi()/2-0.1);
0341
0342 gen->set_p_range(30.0, 30.0);
0343
0344
0345
0346 if (readhepmc)
0347 {
0348 gen->set_reuse_existing_vertex(true);
0349 gen->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0350 }
0351 else
0352 {
0353 gen->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
0354 PHG4SimpleEventGenerator::Uniform,
0355 PHG4SimpleEventGenerator::Uniform);
0356 gen->set_vertex_distribution_mean(0.0, 0.0, 0.0);
0357 gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
0358 }
0359 gen->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform);
0360 gen->set_vertex_size_parameters(0.0, 0.0);
0361 gen->set_eta_range(-1.0, 1.0);
0362 gen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
0363
0364 gen->set_pt_range(0.1, 20.0);
0365
0366 gen->Embed(1);
0367 gen->Verbosity(0);
0368
0369 se->registerSubsystem(gen);
0370 }
0371 if (usegun)
0372 {
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383 PHG4ParticleGenerator *pgen = new PHG4ParticleGenerator();
0384 pgen->set_name("e-");
0385 pgen->set_z_range(0,0);
0386 pgen->set_eta_range(0.01,0.01);
0387 pgen->set_mom_range(10,10);
0388 pgen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
0389 se->registerSubsystem(pgen);
0390 }
0391
0392
0393 if(upsilons)
0394 {
0395
0396
0397 PHG4ParticleGeneratorVectorMeson *vgen = new PHG4ParticleGeneratorVectorMeson();
0398 vgen->add_decay_particles("e+","e-",0);
0399
0400 if (readhepmc || particles)
0401 {
0402 vgen->set_reuse_existing_vertex(true);
0403 }
0404 else
0405 {
0406 vgen->set_vtx_zrange(-10.0, +10.0);
0407 }
0408
0409
0410 vgen->set_rapidity_range(-1.0, +1.0);
0411 vgen->set_pt_range(0.0, 10.0);
0412
0413 int istate = 1;
0414
0415 if(istate == 1)
0416 {
0417
0418 vgen->set_mass(9.46);
0419 vgen->set_width(54.02e-6);
0420 }
0421 else if (istate == 2)
0422 {
0423
0424 vgen->set_mass(10.0233);
0425 vgen->set_width(31.98e-6);
0426 }
0427 else
0428 {
0429
0430 vgen->set_mass(10.3552);
0431 vgen->set_width(20.32e-6);
0432 }
0433
0434 vgen->Verbosity(0);
0435 vgen->Embed(2);
0436 se->registerSubsystem(vgen);
0437
0438 cout << "Upsilon generator for istate = " << istate << " created and registered " << endl;
0439 }
0440
0441 if (!readhits)
0442 {
0443
0444
0445
0446
0447 G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,
0448 do_svtx,do_cemc,do_hcalin,do_magnet,do_hcalout,do_pipe,
0449 do_FGEM,do_EGEM,do_FEMC,do_FHCAL,do_EEMC,do_DIRC,do_RICH,do_Aerogel,
0450 magfield_rescale);
0451
0452 }
0453
0454
0455
0456
0457
0458 if (do_bbc)
0459 {
0460 gROOT->LoadMacro("G4_Bbc.C");
0461 BbcInit();
0462 Bbc_Reco();
0463 }
0464
0465
0466
0467
0468
0469 if (do_svtx_cell) Svtx_Cells();
0470
0471 if (do_cemc_cell) CEMC_Cells();
0472
0473 if (do_hcalin_cell) HCALInner_Cells();
0474
0475 if (do_hcalout_cell) HCALOuter_Cells();
0476
0477 if (do_FEMC_cell) FEMC_Cells();
0478
0479 if (do_FHCAL_cell) FHCAL_Cells();
0480
0481 if (do_EEMC_cell) EEMC_Cells();
0482
0483
0484
0485
0486
0487 if (do_cemc_twr) CEMC_Towers();
0488 if (do_cemc_cluster) CEMC_Clusters();
0489
0490
0491
0492
0493
0494 if (do_hcalin_twr) HCALInner_Towers();
0495 if (do_hcalin_cluster) HCALInner_Clusters();
0496
0497 if (do_hcalout_twr) HCALOuter_Towers();
0498 if (do_hcalout_cluster) HCALOuter_Clusters();
0499
0500
0501
0502
0503
0504 if (do_FEMC_twr) FEMC_Towers();
0505 if (do_FEMC_cluster) FEMC_Clusters();
0506
0507 if (do_FHCAL_twr) FHCAL_Towers();
0508 if (do_FHCAL_cluster) FHCAL_Clusters();
0509
0510 if (do_EEMC_twr) EEMC_Towers();
0511 if (do_EEMC_cluster) EEMC_Clusters();
0512
0513 if (do_dst_compress) ShowerCompress();
0514
0515
0516
0517
0518
0519 if (do_svtx_track) Svtx_Reco();
0520
0521
0522
0523
0524
0525 if(do_FGEM_track) FGEM_FastSim_Reco();
0526
0527
0528
0529
0530
0531 if(do_EGEM_track) EGEM_FastSim_Reco();
0532
0533
0534
0535
0536
0537 if (do_global)
0538 {
0539 gROOT->LoadMacro("G4_Global.C");
0540 Global_Reco();
0541 }
0542
0543 else if (do_global_fastsim)
0544 {
0545 gROOT->LoadMacro("G4_Global.C");
0546 Global_FastSim();
0547 }
0548
0549
0550
0551
0552
0553 if (do_calotrigger)
0554 {
0555 gROOT->LoadMacro("G4_CaloTrigger.C");
0556 CaloTrigger_Sim();
0557 }
0558
0559
0560
0561
0562
0563 if (do_jet_reco)
0564 {
0565 gROOT->LoadMacro("G4_Jets.C");
0566 Jet_Reco();
0567 }
0568
0569 if (do_HIjetreco) {
0570 gROOT->LoadMacro("G4_HIJetReco.C");
0571 HIJetReco();
0572 }
0573
0574 if (do_fwd_jet_reco)
0575 {
0576 gROOT->LoadMacro("G4_FwdJets.C");
0577 Jet_FwdReco();
0578 }
0579
0580
0581
0582
0583
0584
0585 if (do_svtx_eval) Svtx_Eval(directory+"g4svtx_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0586
0587 if (do_cemc_eval) CEMC_Eval(directory+"g4cemc_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0588
0589 if (do_hcalin_eval) HCALInner_Eval(directory+"g4hcalin_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0590
0591 if (do_hcalout_eval) HCALOuter_Eval(directory+"g4hcalout_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0592
0593 if (do_jet_eval) Jet_Eval(directory+"g4jet_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0594
0595 if (do_fwd_jet_eval) Jet_FwdEval(directory+"g4fwdjet_p"+pbeam+"_e"+ebeam+"_"+n+"events_eval.root");
0596
0597 if(do_lepto_analysis){
0598 gROOT->LoadMacro("G4_Lepto.C");
0599 G4_Lepto(directory+"LeptoAna_p"+pbeam+"_e"+ebeam+"_"+n+"events");
0600 }
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610 if (readhits)
0611 {
0612
0613 Fun4AllInputManager *hitsin = new Fun4AllDstInputManager("DSTin");
0614 hitsin->fileopen(inputFile);
0615 se->registerInputManager(hitsin);
0616 }
0617 if (readhepmc)
0618 {
0619 Fun4AllInputManager *in = new Fun4AllHepMCInputManager( "DSTIN");
0620 se->registerInputManager( in );
0621 se->fileopen( in->Name().c_str(), inputFile );
0622 }
0623 else
0624 {
0625
0626
0627 Fun4AllInputManager *in = new Fun4AllDummyInputManager( "JADE");
0628 se->registerInputManager( in );
0629 }
0630
0631 if (do_DSTReader)
0632 {
0633
0634 gROOT->LoadMacro("G4_DSTReader_EICDetector.C");
0635
0636 G4DSTreader_EICDetector( outputFile,
0637 absorberactive ,
0638 do_svtx ,
0639 do_cemc ,
0640 do_hcalin ,
0641 do_magnet ,
0642 do_hcalout ,
0643 do_cemc_twr ,
0644 do_hcalin_twr ,
0645 do_magnet ,
0646 do_hcalout_twr,
0647 do_FGEM,
0648 do_EGEM,
0649 do_FHCAL,
0650 do_FHCAL_twr,
0651 do_FEMC,
0652 do_FEMC_twr,
0653 do_EEMC,
0654 do_EEMC_twr
0655 );
0656 }
0657
0658 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outputFile);
0659 if (do_dst_compress) DstCompress(out);
0660 se->registerOutputManager(out);
0661
0662
0663
0664
0665 if (nEvents < 0)
0666 {
0667 return;
0668 }
0669
0670 if (nEvents == 0 && !readhits && !readhepmc)
0671 {
0672 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0673 cout << "it will run forever, so I just return without running anything" << endl;
0674 return;
0675 }
0676
0677 se->run(nEvents);
0678
0679
0680
0681
0682
0683 se->End();
0684 std::cout << "All done" << std::endl;
0685 delete se;
0686 gSystem->Exit(0);
0687 }