File indexing completed on 2025-08-05 08:12:04
0001 int Fun4All_EICAnalysis_DVCS(
0002 const int nEvents = 10,
0003 const char * inputFile = "example_tesst.dat",
0004 const char * outputFile = "G4sPHENIXCells.root",
0005 const char * embed_input_file = "/sphenix/sim/sim01/production/2016-07-12/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm.list"
0006 )
0007 {
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 const bool readhits = false;
0020
0021
0022 const bool readhepmc = false;
0023
0024
0025 const bool runpythia8 = false;
0026 const bool runpythia6 = false;
0027 const bool runhepgen = true;
0028
0029
0030
0031 const bool usegun = false;
0032
0033 const bool readeictree = false;
0034
0035 gSystem->Load("libfun4all.so");
0036
0037 gSystem->Load("libphhepmc.so");
0038 gSystem->Load("libg4testbench.so");
0039 gSystem->Load("libg4hough.so");
0040
0041 gSystem->Load("libeicana.so");
0042
0043
0044
0045
0046
0047
0048
0049 const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root";
0050 const float magfield_rescale = 1.4/1.5;
0051
0052
0053
0054
0055
0056 Fun4AllServer *se = Fun4AllServer::instance();
0057 se->Verbosity(0);
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 if (readhits)
0075 {
0076
0077
0078 }
0079 else if (readhepmc)
0080 {
0081
0082
0083 HepMCNodeReader *hr = new HepMCNodeReader();
0084 se->registerSubsystem(hr);
0085 }
0086
0087 else if (readeictree)
0088 {
0089
0090 ReadEICFiles *eicr = new ReadEICFiles();
0091 eicr->OpenInputFile(inputFile);
0092
0093 se->registerSubsystem(eicr);
0094
0095 HepMCNodeReader *hr = new HepMCNodeReader();
0096 se->registerSubsystem(hr);
0097
0098 }
0099 else if (runpythia8)
0100 {
0101 gSystem->Load("libPHPythia8.so");
0102
0103 PHPythia8* pythia8 = new PHPythia8();
0104
0105 pythia8->set_config_file("phpythia8.cfg");
0106 se->registerSubsystem(pythia8);
0107
0108 HepMCNodeReader *hr = new HepMCNodeReader();
0109 se->registerSubsystem(hr);
0110 }
0111 else if (runpythia6)
0112 {
0113 gSystem->Load("libPHPythia6.so");
0114
0115 PHPythia6 *pythia6 = new PHPythia6();
0116 pythia6->set_config_file("phpythia6.cfg");
0117 se->registerSubsystem(pythia6);
0118
0119 HepMCNodeReader *hr = new HepMCNodeReader();
0120 se->registerSubsystem(hr);
0121 }
0122 else if (runhepgen)
0123 {
0124 gSystem->Load("libsHEPGen.so");
0125
0126 sHEPGen *hepgen = new sHEPGen();
0127 hepgen->set_datacard_file("hepgen_dvcs.data");
0128 hepgen->set_momentum_electron(20);
0129 hepgen->set_momentum_hadron(250);
0130 se->registerSubsystem(hepgen);
0131
0132
0133
0134 }
0135 else
0136 {
0137
0138 PHG4SimpleEventGenerator *gen = new PHG4SimpleEventGenerator();
0139 gen->add_particles("e-",1);
0140
0141 if (readhepmc)
0142 {
0143 gen->set_reuse_existing_vertex(true);
0144 gen->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0145 }
0146 else
0147 {
0148 gen->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
0149 PHG4SimpleEventGenerator::Uniform,
0150 PHG4SimpleEventGenerator::Uniform);
0151 gen->set_vertex_distribution_mean(0.0, 0.0, 0.0);
0152 gen->set_vertex_distribution_width(0.0, 0.0, 5.0);
0153 }
0154 gen->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform);
0155 gen->set_vertex_size_parameters(0.0, 0.0);
0156 gen->set_eta_range(-0.5, 0.5);
0157 gen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
0158 gen->set_pt_range(0.1, 10.0);
0159 gen->Embed(1);
0160 gen->Verbosity(0);
0161 if (! usegun)
0162 {
0163 se->registerSubsystem(gen);
0164 }
0165 else
0166 {
0167 PHG4ParticleGun *gun = new PHG4ParticleGun();
0168
0169 gun->set_name("geantino");
0170 gun->set_vtx(0, 0, 0);
0171 gun->set_mom(10, 0, 0.01);
0172
0173
0174
0175
0176
0177 PHG4ParticleGenerator *pgen = new PHG4ParticleGenerator();
0178 pgen->set_name("geantino");
0179 pgen->set_z_range(0,0);
0180 pgen->set_eta_range(0.01,0.01);
0181 pgen->set_mom_range(10,10);
0182 pgen->set_phi_range(5.3./180.*TMath::Pi(),5.7./180.*TMath::Pi());
0183 se->registerSubsystem(pgen);
0184 pgen = new PHG4ParticleGenerator();
0185 pgen->set_name("geantino");
0186 pgen->set_z_range(0,0);
0187 pgen->set_eta_range(0.01,0.01);
0188 pgen->set_mom_range(10,10);
0189 pgen->set_phi_range(-0.2./180.*TMath::Pi(),0.2./180.*TMath::Pi());
0190 se->registerSubsystem(pgen);
0191 }
0192 }
0193
0194
0195 if (readhits)
0196 {
0197
0198 Fun4AllInputManager *hitsin = new Fun4AllDstInputManager("DSTin");
0199 hitsin->fileopen(inputFile);
0200 se->registerInputManager(hitsin);
0201 }
0202 if (readhepmc)
0203 {
0204 Fun4AllInputManager *in = new Fun4AllHepMCInputManager( "DSTIN");
0205 se->registerInputManager( in );
0206 se->fileopen( in->Name().c_str(), inputFile );
0207 }
0208 else
0209 {
0210
0211
0212
0213
0214 }
0215
0216
0217
0218
0219
0220 DISKinematics *mcana = new DISKinematics(outputFile);
0221 se->registerSubsystem( mcana );
0222
0223
0224
0225
0226
0227 if (nEvents < 0)
0228 {
0229 return;
0230 }
0231
0232 if (nEvents == 0 && !readhits && !readhepmc)
0233 {
0234 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0235 cout << "it will run forever, so I just return without running anything" << endl;
0236 return;
0237 }
0238
0239 se->run(nEvents);
0240
0241
0242
0243
0244
0245 se->End();
0246 std::cout << "All done" << std::endl;
0247 delete se;
0248 gSystem->Exit(0);
0249 }