File indexing completed on 2025-08-06 08:16:18
0001 int Fun4All_single_particle (
0002 const int nEvents = 10,
0003 const char * inputFile = NULL,
0004 const char * outputFile = "SvtxClusters.root",
0005 const char * embed_input_file = NULL,
0006 const int which_tracking = 15,
0007 const bool do_embedding = false,
0008 const int particle_pid = 211
0009 )
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 runpythia8 = false;
0029 const bool runpythia6 = false;
0030
0031
0032
0033 const bool usegun = false;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 bool do_bbc = true;
0045
0046 bool do_pipe = true;
0047
0048 bool do_svtx = true;
0049 bool do_svtx_cell = true;
0050 bool do_svtx_cluster = true;
0051 bool do_svtx_track = false;
0052 bool do_svtx_eval = false;
0053
0054
0055
0056
0057
0058
0059 bool do_preshower = false;
0060
0061 bool do_cemc = false;
0062 bool do_cemc_cell = do_cemc && true;
0063 bool do_cemc_twr = do_cemc_cell && true;
0064 bool do_cemc_cluster = do_cemc_twr && true;
0065 bool do_cemc_eval = do_cemc_cluster && true;
0066
0067 bool do_hcalin = false;
0068 bool do_hcalin_cell = do_hcalin && true;
0069 bool do_hcalin_twr = do_hcalin_cell && true;
0070 bool do_hcalin_cluster = do_hcalin_twr && true;
0071 bool do_hcalin_eval = do_hcalin_cluster && true;
0072
0073 bool do_magnet = false;
0074
0075 bool do_hcalout = false;
0076 bool do_hcalout_cell = do_hcalout && true;
0077 bool do_hcalout_twr = do_hcalout_cell && true;
0078 bool do_hcalout_cluster = do_hcalout_twr && true;
0079 bool do_hcalout_eval = do_hcalout_cluster && true;
0080
0081 bool do_global = false;
0082 bool do_global_fastsim = false;
0083
0084 bool do_jet_reco = false;
0085 bool do_jet_eval = false;
0086
0087 bool do_dst_compress = false;
0088
0089
0090 bool do_DSTReader = false;
0091
0092
0093
0094
0095 gSystem->Load("libfun4all.so");
0096 gSystem->Load("libg4detectors.so");
0097 gSystem->Load("libphhepmc.so");
0098 gSystem->Load("libg4testbench.so");
0099 gSystem->Load("libg4hough.so");
0100 gSystem->Load("libg4calo.so");
0101 gSystem->Load("libg4eval.so");
0102
0103
0104 gROOT->LoadMacro("G4Setup_sPHENIX.C");
0105 G4Init(do_svtx,do_preshower,do_cemc,do_hcalin,do_magnet,do_hcalout,do_pipe,which_tracking);
0106
0107 int absorberactive = 1;
0108
0109 const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root";
0110 const float magfield_rescale = 1.4/1.5;
0111
0112
0113
0114
0115
0116 Fun4AllServer *se = Fun4AllServer::instance();
0117
0118
0119 recoConsts *rc = recoConsts::instance();
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 if (readhits)
0135 {
0136
0137
0138
0139 if (do_embedding)
0140 {
0141 cout <<"Do not support read hits and embed background at the same time."<<endl;
0142 exit(1);
0143 }
0144
0145 }
0146 else if (readhepmc)
0147 {
0148
0149
0150 HepMCNodeReader *hr = new HepMCNodeReader();
0151 se->registerSubsystem(hr);
0152 }
0153 else if (runpythia8)
0154 {
0155 gSystem->Load("libPHPythia8.so");
0156
0157 PHPy8JetTrigger *theTrigger = new PHPy8JetTrigger();
0158
0159 theTrigger->SetEtaHighLow(-0.6, 0.6);
0160 theTrigger->SetJetR(.4);
0161 theTrigger->SetMinJetPt(20);
0162
0163 PHPythia8* pythia8 = new PHPythia8();
0164
0165 pythia8->set_config_file("phpythia8.cfg");
0166 pythia8->register_trigger(theTrigger);
0167 se->registerSubsystem(pythia8);
0168
0169 HepMCNodeReader *hr = new HepMCNodeReader();
0170 hr->Embed(10);
0171 se->registerSubsystem(hr);
0172 }
0173 else if (runpythia6)
0174 {
0175 gSystem->Load("libPHPythia6.so");
0176
0177 PHPythia6 *pythia6 = new PHPythia6();
0178 pythia6->set_config_file("phpythia6.cfg");
0179 se->registerSubsystem(pythia6);
0180
0181 HepMCNodeReader *hr = new HepMCNodeReader();
0182 se->registerSubsystem(hr);
0183 }
0184 else
0185 {
0186
0187 PHG4SimpleEventGenerator *gen = new PHG4SimpleEventGenerator();
0188
0189
0190 gen->add_particles(particle_pid,1);
0191
0192
0193 if (readhepmc || do_embedding)
0194 {
0195 gen->set_reuse_existing_vertex(true);
0196 gen->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0197 }
0198 else
0199 {
0200 gen->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
0201 PHG4SimpleEventGenerator::Uniform,
0202 PHG4SimpleEventGenerator::Uniform);
0203 gen->set_vertex_distribution_mean(0.0, 0.0, 0.0);
0204 gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
0205 }
0206 gen->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform);
0207 gen->set_vertex_size_parameters(0.0, 0.0);
0208 gen->set_eta_range(0,0);
0209 gen->set_phi_range(-1 * TMath::Pi(), 1 * TMath::Pi());
0210
0211
0212 gen->set_pt_range(0.1, 5);
0213 gen->Embed(10);
0214 gen->Verbosity(0);
0215 if (! usegun)
0216 {
0217 se->registerSubsystem(gen);
0218 }
0219 else
0220 {
0221 PHG4ParticleGun *gun = new PHG4ParticleGun();
0222
0223 gun->set_name("geantino");
0224 gun->set_vtx(0, 0, 0);
0225 gun->set_mom(10, 0, 0.01);
0226
0227
0228
0229
0230
0231 PHG4ParticleGenerator *pgen = new PHG4ParticleGenerator();
0232 pgen->set_name("geantino");
0233 pgen->set_z_range(0,0);
0234 pgen->set_eta_range(0.01,0.01);
0235 pgen->set_mom_range(10,10);
0236 pgen->set_phi_range(5.3/180.*TMath::Pi(),5.3/180.*TMath::Pi());
0237 se->registerSubsystem(pgen);
0238 pgen = new PHG4ParticleGenerator();
0239 pgen->set_name("geantino");
0240 pgen->set_z_range(0,0);
0241 pgen->set_eta_range(0.01,0.01);
0242 pgen->set_mom_range(10,10);
0243 pgen->set_phi_range(-0.2/180.*TMath::Pi(),0.2/180.*TMath::Pi());
0244 se->registerSubsystem(pgen);
0245 }
0246 }
0247
0248 if (!readhits)
0249 {
0250
0251
0252
0253
0254 G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,
0255 do_svtx, do_preshower, do_cemc, do_hcalin, do_magnet, do_hcalout, do_pipe, magfield_rescale);
0256 }
0257
0258
0259
0260
0261
0262 if (do_bbc)
0263 {
0264 gROOT->LoadMacro("G4_Bbc.C");
0265 BbcInit();
0266 Bbc_Reco();
0267 }
0268
0269
0270
0271
0272 if (do_svtx_cell) Svtx_Cells();
0273
0274 if (do_cemc_cell) CEMC_Cells();
0275
0276 if (do_hcalin_cell) HCALInner_Cells();
0277
0278 if (do_hcalout_cell) HCALOuter_Cells();
0279
0280
0281
0282
0283
0284 if (do_cemc_twr) CEMC_Towers();
0285 if (do_cemc_cluster) CEMC_Clusters();
0286
0287
0288
0289
0290
0291 if (do_hcalin_twr) HCALInner_Towers();
0292 if (do_hcalin_cluster) HCALInner_Clusters();
0293
0294 if (do_hcalout_twr) HCALOuter_Towers();
0295 if (do_hcalout_cluster) HCALOuter_Clusters();
0296
0297 if (do_dst_compress) ShowerCompress();
0298
0299
0300
0301
0302
0303 if(which_tracking == 14 || which_tracking == 15) {
0304 if (do_svtx_cluster) Svtx_Clustering();
0305 if (do_svtx_track) Svtx_Tracking();
0306 } else {
0307 if (do_svtx_cluster || do_svtx_track) Svtx_Reco();
0308 }
0309
0310
0311
0312
0313
0314 if (do_global)
0315 {
0316 gROOT->LoadMacro("G4_Global.C");
0317 Global_Reco();
0318 }
0319
0320 else if (do_global_fastsim)
0321 {
0322 gROOT->LoadMacro("G4_Global.C");
0323 Global_FastSim();
0324 }
0325
0326
0327
0328
0329
0330 if (do_jet_reco)
0331 {
0332 gROOT->LoadMacro("G4_Jets.C");
0333 Jet_Reco();
0334 }
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353 if (do_svtx_eval) Svtx_Eval("g4svtx_eval.root");
0354
0355 if (do_cemc_eval) CEMC_Eval("g4cemc_eval.root");
0356
0357 if (do_hcalin_eval) HCALInner_Eval("g4hcalin_eval.root");
0358
0359 if (do_hcalout_eval) HCALOuter_Eval("g4hcalout_eval.root");
0360
0361 if (do_jet_eval) Jet_Eval("g4jet_eval.root");
0362
0363
0364
0365
0366
0367 if (readhits)
0368 {
0369
0370 Fun4AllInputManager *hitsin = new Fun4AllDstInputManager("DSTin");
0371 hitsin->fileopen(inputFile);
0372 se->registerInputManager(hitsin);
0373 }
0374 if (do_embedding)
0375 {
0376 if (embed_input_file == NULL)
0377 {
0378 cout << "Missing embed_input_file! Exit";
0379 exit(3);
0380 }
0381
0382 Fun4AllDstInputManager *in1 = new Fun4AllNoSyncDstInputManager("DSTinEmbed");
0383 in1->AddFile(embed_input_file);
0384
0385 se->registerInputManager(in1);
0386 }
0387 if (readhepmc)
0388 {
0389 Fun4AllInputManager *in = new Fun4AllHepMCInputManager( "DSTIN");
0390 se->registerInputManager( in );
0391 se->fileopen( in->Name().c_str(), inputFile );
0392 }
0393 else
0394 {
0395
0396
0397 Fun4AllInputManager *in = new Fun4AllDummyInputManager( "JADE");
0398 se->registerInputManager( in );
0399 }
0400
0401 if (do_DSTReader)
0402 {
0403
0404 gROOT->LoadMacro("G4_DSTReader.C");
0405
0406 G4DSTreader( outputFile,
0407 absorberactive ,
0408 do_svtx ,
0409 do_preshower ,
0410 do_cemc ,
0411 do_hcalin ,
0412 do_magnet ,
0413 do_hcalout ,
0414 do_cemc_twr ,
0415 do_hcalin_twr ,
0416 do_magnet ,
0417 do_hcalout_twr
0418 );
0419 }
0420
0421 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outputFile);
0422 if (do_dst_compress) DstCompress(out);
0423 se->registerOutputManager(out);
0424
0425
0426
0427
0428 if (nEvents < 0)
0429 {
0430 return;
0431 }
0432
0433 if (nEvents == 0 && !readhits && !readhepmc)
0434 {
0435 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0436 cout << "it will run forever, so I just return without running anything" << endl;
0437 return;
0438 }
0439
0440 se->run(nEvents);
0441
0442
0443
0444
0445
0446 se->End();
0447
0448
0449
0450 std::cout << "All done" << std::endl;
0451
0452
0453 }