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