File indexing completed on 2025-08-05 08:11:58
0001
0002 int Fun4All_G4_EICIR(
0003 const int nEvents = 1,
0004 const char * inputFile = "/gpfs02/phenix/prod/sPHENIX/preCDR/pro.1-beta.5/single_particle/spacal1d/fieldmap/G4Hits_sPHENIX_e-_eta0_16GeV.root",
0005 const char * outputFile = "G4EICIR.root"
0006 )
0007 {
0008
0009
0010
0011
0012
0013 const bool pgun = true;
0014
0015
0016
0017
0018
0019 bool do_pipe = false;
0020
0021 bool do_magnet = true;
0022
0023
0024 bool do_ExtendedIR = true;
0025
0026
0027
0028
0029
0030 gSystem->Load("libfun4all.so");
0031 gSystem->Load("libg4detectors.so");
0032 gSystem->Load("libphhepmc.so");
0033 gSystem->Load("libg4testbench.so");
0034 gSystem->Load("libg4hough.so");
0035 gSystem->Load("libg4eval.so");
0036
0037
0038 gROOT->LoadMacro("G4Setup_EICIR.C");
0039 G4Init(do_magnet,do_pipe,do_ExtendedIR);
0040
0041 int absorberactive = 0;
0042
0043 const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root";
0044 const float magfield_rescale = 1.4/1.5;
0045
0046
0047
0048
0049
0050 Fun4AllServer *se = Fun4AllServer::instance();
0051
0052 se->Verbosity(Fun4AllServer::VERBOSITY_SOME);
0053
0054 recoConsts *rc = recoConsts::instance();
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 if (pgun)
0070 {
0071
0072
0073
0074 double psi_mrad = 0;
0075
0076 double ptot = 250*1;
0077
0078 double vx = 0;
0079 double vy = 0;
0080 double vz = 0;
0081
0082 double px = ptot * sin(psi_mrad / 1000.);
0083 double py = 0;
0084 double pz = ptot * cos(psi_mrad / 1000.);
0085
0086 PHG4ParticleGun*gun = new PHG4ParticleGun();
0087 gun->set_name("proton");
0088 gun->set_vtx(vx,vy,vz);
0089 gun->set_mom(px,py,pz);
0090 se->registerSubsystem(gun);
0091 }
0092 else
0093 {
0094 cout << "WARNING: No events being generated!" << endl;
0095 }
0096
0097
0098
0099
0100
0101 G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,do_magnet,do_pipe,do_ExtendedIR,magfield_rescale);
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 Fun4AllInputManager *in = new Fun4AllDummyInputManager( "JADE");
0112 se->registerInputManager( in );
0113
0114
0115 gROOT->LoadMacro("G4_DSTReader_EICIR.C");
0116
0117 G4DSTreader_EICIR( outputFile,
0118 absorberactive );
0119
0120 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outputFile);
0121
0122 se->registerOutputManager(out);
0123
0124 if (nEvents == 0 && !readhits && !readhepmc)
0125 {
0126 cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0127 cout << "it will run forever, so I just return without running anything" << endl;
0128 return;
0129 }
0130
0131 if (nEvents < 0)
0132 {
0133 PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
0134 g4->ApplyCommand("/control/execute vis.mac");
0135
0136 se->run(1);
0137
0138 se->End();
0139 std::cout << "All done" << std::endl;
0140
0141 std::cout << "==== Useful display commands ==" << std::endl;
0142 cout << "draw axis: " << endl;
0143 cout << " G4Cmd(\"/vis/scene/add/axes 0 0 0 50 cm\")" << endl;
0144 cout << "zoom" << endl;
0145 cout << " G4Cmd(\"/vis/viewer/zoom 1\")" << endl;
0146 cout << "viewpoint:" << endl;
0147 cout << " G4Cmd(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << endl;
0148 cout << "panTo:" << endl;
0149 cout << " G4Cmd(\"/vis/viewer/panTo 0 0 cm\")" << endl;
0150 cout << "print to eps:" << endl;
0151 cout << " G4Cmd(\"/vis/ogl/printEPS\")" << endl;
0152 cout << "set background color:" << endl;
0153 cout << " G4Cmd(\"/vis/viewer/set/background white\")" << endl;
0154 std::cout << "===============================" << std::endl;
0155 }
0156 else
0157 {
0158 se->run(nEvents);
0159
0160 se->End();
0161 std::cout << "All done" << std::endl;
0162 delete se;
0163 gSystem->Exit(0);
0164 }
0165
0166 }
0167
0168
0169 void
0170 G4Cmd(const char * cmd)
0171 {
0172 Fun4AllServer *se = Fun4AllServer::instance();
0173 PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
0174 g4->ApplyCommand(cmd);
0175 }