EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_G4_FullDetectorModular.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_G4_FullDetectorModular.C
1 #ifndef MACRO_FUN4ALLG4EICDETECTOR_C
2 #define MACRO_FUN4ALLG4EICDETECTOR_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <DisplayOn.C>
8 #include <G4_Bbc.C>
9 #include <G4_CaloTrigger.C>
11 #include <G4_FwdJets.C>
12 #include <G4_Global.C>
13 #include <G4_HIJetReco.C>
14 #include <G4_Input.C>
15 #include <G4_Jets.C>
16 #include <G4_Production.C>
17 #include <G4_User.C>
18 #include <QA.C>
19 
20 #include <TROOT.h>
23 #include <fun4all/Fun4AllServer.h>
24 #include <PHPy6GenTrigger.h>
25 #include <PHPy6ParticleTrigger.h>
26 #include <PHPy6JetTrigger.h>
27 #include <phool/recoConsts.h>
28 
29 #include <eiceval/EventEvaluatorEIC.h>
30 
31 R__LOAD_LIBRARY(libfun4all.so)
32 R__LOAD_LIBRARY(libeiceval.so)
33 
34 void ParseTString(TString &specialSetting);
35 
37  const int nEvents = 1,
38  const double particlemomMin = -1,
39  const double particlemomMax = -1,
40  TString specialSetting = "ALLSILICON-TTLEM",
41  TString generatorSettings = "e10p250MB",
42  const string &inputFile = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
43  const string &outputFile = "G4EICDetector.root",
44  const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
45  const int skip = 0,
46  const string &outdir = ".")
47 {
48  //---------------
49  // Fun4All server
50  //---------------
52  se->Verbosity(0);
53  //Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints.
54  //PHRandomSeed::Verbosity(1);
55 
56  // just if we set some flags somewhere in this macro
58  // By default every random number generator uses
59  // PHRandomSeed() which reads /dev/urandom to get its seed
60  // if the RANDOMSEED flag is set its value is taken as initial seed
61  // which will produce identical results so you can debug your code
62  //rc->set_IntFlag("RANDOMSEED", 12345);
63 
64  // switching IPs by comment/uncommenting the following lines
65  // used for both beamline setting and for the event generator crossing boost
66  Enable::IP6 = true;
67  // Enable::IP8 = true;
68 
69  //===============
70  // Input options
71  //===============
72 
73  // pythia6
74  // Use Pythia 6
75  if(particlemomMin==-1 && particlemomMax==-1){
76  Input::PYTHIA6 = true;
77  }
78  // Simple multi particle generator in eta/phi/pt ranges
79  Input::SIMPLE = false;
80  if (particlemomMin>-1 && particlemomMax>-1){
81  Input::SIMPLE = true;
83  }
84  // Input::SIMPLE_NUMBER = 2; // if you need 2 of them
85 
86  Input::VERBOSITY = 0;
87  INPUTHEPMC::filename = inputFile;
88 
89 
90  Enable::QA = false;
91 
92  //-----------------
93  // Initialize the selected Input/Event generation
94  //-----------------
95  InputInit();
96  //--------------
97  // Set generator specific options
98  //--------------
99  // can only be set after InputInit() is called
100 
101  // Simple Input generator:
102  // if you run more than one of these Input::SIMPLE_NUMBER > 1
103  // add the settings for other with [1], next with [2]...
104  if (Input::SIMPLE){
105  if (generatorSettings.Contains("SimplePion"))
106  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("pi-", 1);
107  else if (generatorSettings.Contains("SimpleKaon"))
108  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("kaon-", 1);
109  else if (generatorSettings.Contains("SimpleProton"))
110  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("proton", 1);
111  else if (generatorSettings.Contains("SimplePhoton"))
112  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("gamma", 1);
113  else if (generatorSettings.Contains("SimpleNeutron"))
114  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("neutron", 1);
115  else if (generatorSettings.Contains("SimpleElectron"))
116  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("e-", 1);
117  else if (generatorSettings.Contains("SimplePiZero"))
118  INPUTGENERATOR::SimpleEventGenerator[0]->add_particles("pi0", 1);
119  else {
120  std::cout << "You didn't specify which particle you wanted to generate, exiting" << std::endl;
121  return 0;
122  }
123  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
126  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0., 0.);
127  INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0., 0., 5.);
128  if (generatorSettings.Contains("central"))
129  INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-1.8, 1.2);
130  else if (generatorSettings.Contains("bck"))
131  INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-4, -1.7);
132  else if (generatorSettings.Contains("fwd"))
133  INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(1.1, 4.0);
134  else
135  INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-4.0, 4.0);
136  INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI);
137  INPUTGENERATOR::SimpleEventGenerator[0]->set_p_range(particlemomMin, particlemomMax);
138  }
139  if(particlemomMin>-1 && particlemomMax == -1){
140  PHG4ParticleGenerator *gen = new PHG4ParticleGenerator("PGENERATOR");
141  gen->set_name("pi-");
142  // gen->set_name("pi0");
143  gen->set_vtx(0, 0, 0);
144  gen->set_eta_range(-4.0, 4.0); // around midrapidity
145  if(particlemomMin > -1)
146  gen->set_mom_range(particlemomMin, particlemomMin); // fixed 4 GeV/c
147  else
148  gen->set_mom_range(1, 60); // fixed 4 GeV/c
149  gen->set_phi_range(0., 2* M_PI); // 0-90 deg
150  // gen->Verbosity(1); // 0-90 deg
151  se->registerSubsystem(gen);
152  }
153  // pythia6
154  if (Input::PYTHIA6){
155  if (generatorSettings.Contains("e10p250MB") )
156  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep.cfg");
157  else if (generatorSettings.Contains("e10p250pTHard5") )
158  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep_MinPartonP5GeV.cfg");
159  else if (generatorSettings.Contains("e10p250pTQ210"))
160  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep_QSquare10GeV.cfg");
161  else if (generatorSettings.Contains("e10p250pTHard10"))
162  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep_MinPartonP10GeV.cfg");
163  else if (generatorSettings.Contains("e10p250pTHard20"))
164  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_ep_MinPartonP20GeV.cfg");
165  else if (generatorSettings.Contains("e5p100MB") )
166  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e5p100.cfg");
167  else if (generatorSettings.Contains("e5p100pTHard5") )
168  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e5p100_MinPartonP5GeV.cfg");
169  else if (generatorSettings.Contains("e10p275MB") )
170  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e10p275.cfg");
171  else if (generatorSettings.Contains("e10p275pTHard5") )
172  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e10p275_MinPartonP5GeV.cfg");
173  else if (generatorSettings.Contains("e10p275pTHard10") )
174  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e10p275_MinPartonP10GeV.cfg");
175  else if (generatorSettings.Contains("e18p275MB") )
176  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e18p275.cfg");
177  else if (generatorSettings.Contains("e18p275pTHard5") )
178  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e18p275_MinPartonP5GeV.cfg");
179  else if (generatorSettings.Contains("e18p275pTHard10") )
180  INPUTGENERATOR::Pythia6->set_config_file(string(getenv("CALIBRATIONROOT")) + "/Generators/phpythia6_e18p275_MinPartonP10GeV.cfg");
181  else
182  INPUTGENERATOR::Pythia6->set_config_file(generatorSettings.Data());
183 
184  if (generatorSettings.Contains("FPartTrigg")){
186  ptrig->SetPtLow(1);
187  ptrig->SetEtaHighLow(1,5);
189  }
190  if (generatorSettings.Contains("FJetTrigg")){
191  PHPy6JetTrigger *trig = new PHPy6JetTrigger();
192  trig->SetEtaHighLow(1,5);
193  if (generatorSettings.Contains("pTHard5"))
194  trig->SetMinJetPt(5);
195  else if (generatorSettings.Contains("pTHard10"))
196  trig->SetMinJetPt(10);
197  else if (generatorSettings.Contains("pTHard20"))
198  trig->SetMinJetPt(20);
199  else
200  trig->SetMinJetPt(1);
201  trig->SetJetR(0.7);
203  }
206 
207 
208  }
209 
210  // register all input generators with Fun4All
211  InputRegister();
212 
213 
214  //======================
215  // Write the DST
216  //======================
217 
218  Enable::DSTOUT = false;
219  DstOut::OutputDir = outdir;
220  DstOut::OutputFile = outputFile;
221  Enable::DSTOUT_COMPRESS = false; // Compress DST files
222 
223  //Option to convert DST to human command readable TTree for quick poke around the outputs
224  Enable::DSTREADER = false;
225 
226  // turn the display on (default off)
227  if(specialSetting.Contains("display"))
228  Enable::DISPLAY = true;
229 
230  bool enableCentral = true;
231  bool enableForwardTracking = true;
232  bool enableElectronSide = true;
233 
234  //======================
235  // What to run
236  //======================
237  // Global options (enabled for all subsystems - if implemented)
238  // Enable::ABSORBER = true;
239 // Enable::OVERLAPCHECK = true;
240  // Enable::VERBOSITY = 1;
241 
242  // Enable::BBC = true;
243  Enable::BBCFAKE = true; // Smeared vtx and t0, use if you don't want real BBC in simulation
244 
245  // whether to simulate the Be section of the beam pipe
246  Enable::PIPE = true;
247  // EIC beam pipe extension beyond the Be-section:
249  //EIC hadron far forward magnets and detectors. IP6 and IP8 are incompatible (pick either or);
250  Enable::HFARFWD_MAGNETS = false;
252  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
253  // geometry - tracking
254  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
255 
256  // backward GEM
257  if (specialSetting.Contains("EGEM")){
258  Enable::EGEM = true;
259  if (specialSetting.Contains("EGEMOO")) // only last 2 EGEM layers
260  Enable::EGEM_FULL = false;
261  else
262  Enable::EGEM_FULL = true;
263  }
264  //Forward GEM
265  if (specialSetting.Contains("FGEM")){
266  Enable::FGEM = true;
267  // FGEM settings
268  if (specialSetting.Contains("FGEMOrg")){
269  Enable::FGEM_ORIG = true;
270  } else {
271  Enable::FGEM_ORIG = false;
272  }
273  }
274 
275  // barrel tracker (LANL)
276  if (specialSetting.Contains("BARREL"))
277  Enable::BARREL = true;
278  if(specialSetting.Contains("FST"))
279  Enable::FST = true;
280 
281  // all silicon tracker version (LBL)
282  if(specialSetting.Contains("ALLSILICON")){
283  Enable::ALLSILICON = true;
285  }
286 
287  // LGAD layers
288  if(specialSetting.Contains("TTL")){
289  Enable::FTTL = true;
290  Enable::ETTL = true;
291  Enable::CTTL = true;
293  }
294  // mvtx/tpc tracker
295  if(specialSetting.Contains("MVTX")){
296  Enable::MVTX = true;
297  Enable::TPC = true;
298  }
299 
300  if(specialSetting.Contains("ENDCAPTPC"))
301  Enable::TPC_ENDCAP = true;
302 
303  Enable::TRACKING = true;
305  if (specialSetting.Contains("INNERTRACKING")) {
306  Enable::TRACKING_INNER = true;
307  }
308  if (specialSetting.Contains("TREXTOUT"))
310 
311  G4TRACKING::DISPLACED_VERTEX = true; // this option exclude vertex in the track fitting and use RAVE to reconstruct primary and 2ndary vertexes
312 
313  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
314  // geometry - barrel
315  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
316  // PID detectors
317  Enable::DIRC = true;
319 
320  // sPHENIX SPACAL reuse
321  Enable::CEMC = true;
322  // Enable::CEMC_ABSORBER = true;
323 
324  // sPHENIX HCal inner reuse
325  Enable::HCALIN = true;
327  // Enable::HCALIN_ABSORBER = true;
328 
329  if (specialSetting.Contains("BECAL") ){
330  Enable::BECAL = true;
331  // need to switch of CEMC & HCALin
332  Enable::CEMC = false;
333  Enable::HCALIN = true; // for now deactivated due to crash
334  }
335  Enable::MAGNET = true;
336 
337  // sPHENIX HCal outer reuse
338  Enable::HCALOUT = true;
339  // Enable::HCALOUT_ABSORBER = true;
340 
341 
342  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
343  // geometry - 'hadron' direction
344  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
345  // PID detectors - RICH's
346  Enable::RICH = true;
347 // Enable::AEROGEL = true;
348 
349  // PHENIX EMCal shashlik reuse
350  Enable::FEMC = true;
351  // Enable::FEMC_ABSORBER = true;
352 
353  // STAR forward HCal
354  Enable::FHCAL = true;
355  if(specialSetting.Contains("FEMCSTANDALONE") || specialSetting.Contains("LFHCAL"))
356  Enable::FHCAL = false;
358  // Enable::FHCAL_ABSORBER = true;
359  // Enable::FHCAL_SUPPORT = true; // make support active volume
360 
361 
362  Enable::DRCALO = false;
363  if(specialSetting.Contains("DRCALO")){
364  Enable::DRCALO = true;
366  if(!specialSetting.Contains("FwdConfig") && !specialSetting.Contains("FwdSquare")){
367  Enable::FEMC = false;
368  Enable::FHCAL = false;
369  }
370  }
372  // Enable::DRCALO_ABSORBER = true;
373 
374  // PSD like HCal
375  if ( specialSetting.Contains("LFHCAL")){
376  Enable::LFHCAL = true;
377  Enable::LFHCAL_ABSORBER = false;
378  }
379 
380 
381  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
382  // EICDetector geometry - 'electron' direction
383  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
384  // PID detectors - RICH's
385  Enable::mRICH = false;
386 
387  Enable::EEMC = true;
388  Enable::EEMCH = false;
389  if (specialSetting.Contains("EEMCH")){
390  Enable::EEMCH = true;
391  Enable::EEMC = false;
393  }
394  Enable::EHCAL = true;
395  if(specialSetting.Contains("noEHCAL"))
396  Enable::EHCAL = false;
398  // Enable::EHCAL_ABSORBER = true;
399 
400  Enable::PLUGDOOR = false;
401 
402 
403  // projections to calorimeters
404  if (specialSetting.Contains("TRACKEVALHITS")){
411  } else {
418  }
419 
420 
421  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
422  // special settings for Calo standalone studies
423  // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
424  // deactivate all respective detector systems for standalone studies
425  if(specialSetting.Contains("STANDALONE") ){
426  Enable::PIPE = false;
428  Enable::HFARFWD_MAGNETS = false;
430  Enable::TPC_ENDCAP = false;
437  Enable::MAGNET = false;
438  Enable::DIRC = false;
439  Enable::RICH = false;
440  Enable::mRICH = false;
441  Enable::AEROGEL = false;
442  Enable::CEMC = false;
443  Enable::HCALOUT = false;
444  Enable::HCALIN = false;
445  Enable::EHCAL = false;
446  Enable::EEMC = false;
447  Enable::EEMCH = false;
448  Enable::FEMC = false;
449  Enable::FHCAL = false;
450  Enable::LFHCAL = false;
451  Enable::BECAL = false;
452  Enable::FTTL = false;
453  Enable::CTTL = false;
454  Enable::ETTL = false;
455  if(specialSetting.Contains("PIPE")){
456  Enable::PIPE = true;
458  }
459  if(specialSetting.Contains("Magnet"))
460  Enable::MAGNET = true;
461  if(specialSetting.Contains("ALLSILICON"))
462  Enable::ALLSILICON = true;
463  if(specialSetting.Contains("CEMC"))
464  Enable::CEMC = true;
465  if(specialSetting.Contains("DR"))
466  Enable::DRCALO = true;
467  if(specialSetting.Contains("FEMC"))
468  Enable::FEMC = true;
469  if(specialSetting.Contains("FHCAL") && !specialSetting.Contains("LFHCAL"))
470  Enable::FHCAL = true;
471  if(specialSetting.Contains("LFHCAL"))
472  Enable::LFHCAL = true;
473  if(specialSetting.Contains("BECAL"))
474  Enable::BECAL = true;
475  if(specialSetting.Contains("EHCAL"))
476  Enable::EHCAL = true;
477  if(specialSetting.Contains("EEMCH"))
478  Enable::EEMCH = true;
479  if(specialSetting.Contains("CHCAL")){
480  Enable::HCALIN = true;
481  Enable::HCALOUT = true;
482  }
483  if(specialSetting.Contains("DIRC"))
484  Enable::DIRC = true;
485 
486  if(specialSetting.Contains("FWDCALO")){
487  Enable::FEMC = true;
488  Enable::FHCAL = true;
489  }
490  if(specialSetting.Contains("FWDLCALO")){
491  Enable::FEMC = true;
492  Enable::LFHCAL = true;
493  }
494  if(specialSetting.Contains("BARCALO")){
495  Enable::BECAL = true;
496  Enable::HCALIN = true;
497  Enable::HCALOUT = true;
498  Enable::MAGNET = true;
499  }
500  if(specialSetting.Contains("BCKCALO")){
501  Enable::EHCAL = true;
502  Enable::EEMCH = true;
503  }
504  if(specialSetting.Contains("TTL")){
505  // Enable::PIPE = true;
506  // G4PIPE::use_forward_pipes = true;
507  // LGAD layers
508  if(specialSetting.Contains("FTTL"))
509  Enable::FTTL = true;
510  if(specialSetting.Contains("ETTL")){
511  Enable::ETTL = true;
514  }
515  if(specialSetting.Contains("CTTL")){
516  Enable::CTTL = true;
517  // Enable::DIRC = true;
518  // Enable::CEMC = true;
519  // Enable::BECAL = true;
520  // Enable::ALLSILICON = true;
523  }
524  }
525  }
526 
527  // Automatic settings based on previous selections:
532 
537 
542 
547 
552 
557 
562 
567 
572 
577 
582 
583 
586 
587  // Other options
588  Enable::GLOBAL_RECO = true;
589  Enable::GLOBAL_FASTSIM = true;
590 
592 
593  // Select only one jet reconstruction- they currently use the same
594  // output collections on the node tree!
595  Enable::JETS = false;
597 
598  Enable::FWDJETS = false;
600 
601  // HI Jet Reco for jet simulations in Au+Au (default is false for
602  // single particle / p+p simulations, or for Au+Au simulations which
603  // don't care about jets)
605 
606  // new settings using Enable namespace in GlobalVariables.C
607  Enable::BLACKHOLE = true;
608  //Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits
609  //BlackHoleGeometry::visible = true;
610 
611  //Enable::USER = true;
612 
613  //---------------
614  // World Settings
615  //---------------
616  // G4WORLD::PhysicsList = "QGSP_BERT"; //FTFP_BERT_HP best for calo
617  // G4WORLD::WorldMaterial = "G4_AIR"; // set to G4_GALACTIC for material scans
618 
619  //---------------
620  // Magnet Settings
621  //---------------
622  if(specialSetting.Contains("3T")){
623  const string magfield = "3.0"; // alternatively to specify a constant magnetic field, give a float number, which will be translated to solenoidal field in T, if string use as fieldmap name (including path)
625  // G4MAGNET::magfield = string(getenv("CALIBRATIONROOT")) + string("/Field/Map/sPHENIX.2d.root"); // default map from the calibration database
626  } else {
627  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos)
628  {
629  G4MAGNET::magfield_rescale = 1.; // 3d fieldmap uses 1.4T
630  }
631  else
632  {
633  G4MAGNET::magfield_rescale = -1.4 / 1.5; // make consistent with expected Babar field strength of 1.4T
634  }
635  }
636  //---------------
637  // Pythia Decayer
638  //---------------
639  // list of decay types in
640  // $OFFLINE_MAIN/include/g4decayer/EDecayType.hh
641  // default is All:
642  // G4P6DECAYER::decayType = EDecayType::kAll;
643 
644  // translate the option TString into subsystem namespace options
645  ParseTString(specialSetting);
646 
647  // Initialize the selected subsystems
648  G4Init();
649 
650  //---------------------
651  // GEANT4 Detector description
652  //---------------------
653 
654  // If "readhepMC" is also set, the Upsilons will be embedded in Hijing events, if 'particles" is set, the Upsilons will be embedded in whatever particles are thrown
655  if (!Input::READHITS) G4Setup(specialSetting);
656 
657  //------------------
658  // Detector Division
659  //------------------
666 
667  //-----------------------------
668  // CEMC towering and clustering
669  //-----------------------------
672 
673  //-----------------------------
674  // HCAL towering and clustering
675  //-----------------------------
678 
679  if (Enable::HCALOUT_TOWER) HCALOuter_Towers();
681 
682  //-----------------------------
683  // e, h direction Calorimeter towering and clustering
684  //-----------------------------
687 
690 
693 
696 
699 
702 
705 
708 
711 
713 
714  //--------------
715  // SVTX tracking
716  //--------------
717  if (Enable::TRACKING) Tracking_Reco(specialSetting);
718 
719  //-----------------
720  // Global Vertexing
721  //-----------------
724 
725  //-----------------
726  // Calo Trigger Simulation
727  //-----------------
729 
730  //---------
731  // Jet reco
732  //---------
733  if (Enable::JETS) Jet_Reco();
734  if (Enable::HIJETS) HIJetReco();
736 
737  string outputroot = outdir + "/" + outputFile;
738  string remove_this = ".root";
739  size_t pos = outputroot.find(remove_this);
740  if (pos != string::npos){
741  outputroot.erase(pos, remove_this.length());
742  }
743 
744  if (Enable::DSTREADER) G4DSTreader_EICDetector(outputroot + "_DSTReader.root");
745 
746  //----------------------
747  // Simulation evaluation
748  //----------------------
749  bool doFullEventTree = true;
750  if(doFullEventTree){
751  EventEvaluatorEIC *eval = new EventEvaluatorEIC("EVENTEVALUATOR", outputroot + "_eventtree.root");
752  eval->Verbosity(0);
753  if(specialSetting.Contains("GEOMETRYTREE"))
754  eval->set_do_GEOMETRY(true);
755  if (Enable::FHCAL)
756  eval->set_do_FHCAL(true);
757  if (Enable::FEMC)
758  eval->set_do_FEMC(true);
759  if (Enable::DRCALO)
760  eval->set_do_DRCALO(true);
761  if (Enable::LFHCAL)
762  eval->set_do_LFHCAL(true);
763  if (Enable::EHCAL)
764  eval->set_do_EHCAL(true);
766  eval->set_do_EEMC(true);
768  eval->set_do_EEMCG(true);
769  if (Enable::CEMC)
770  eval->set_do_CEMC(true);
771  if (Enable::HCALIN)
772  eval->set_do_HCALIN(true);
773  if (Enable::BECAL)
774  eval->set_do_BECAL(true);
775  if (Enable::HCALOUT)
776  eval->set_do_HCALOUT(true);
778  eval->set_do_CLUSTERS(true);
779  if (Enable::TRACKING){
780  eval->set_do_TRACKS(true);
781  eval->set_do_HITS(true);
782  eval->set_do_PROJECTIONS(true);
784  }
785  if (Input::PYTHIA6){
786  eval->set_do_HEPMC(true);
787  eval->set_do_store_event_level_info(true);
788  }
789  eval->set_do_MCPARTICLES(true);
790  se->registerSubsystem(eval);
791  }
792 
793  if (specialSetting.Contains("TRACKEVALHITS")) Tracking_Eval(outputroot + "_g4tracking_eval.root", specialSetting);
794  //--------------
795  // Set up Input Managers
796  //--------------
797 
798  InputManagers();
799 
800  //--------------
801  // Set up Output Manager
802  //--------------
803  if (Enable::PRODUCTION){
805  }
806 
807  if (Enable::DSTOUT){
808  string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile;
809  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile);
811  se->registerOutputManager(out);
812  }
813 
814  //-----------------
815  // Event processing
816  //-----------------
817  if (Enable::DISPLAY){
818  if (specialSetting.Contains("viewer")){
819  gROOT->ProcessLine("PHG4Reco *g4 = QTGui();"); // alternative to DisplayOn
820  } else {
821  DisplayOn();
822  gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
823  gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");");
824  }
825  cout << "-------------------------------------------------" << endl;
826  cout << "You are in event display mode. Run one event with" << endl;
827  cout << "se->run(1)" << endl;
828  cout << "Run Geant4 command with following examples" << endl;
829  gROOT->ProcessLine("displaycmd()");
830 
831  return 0;
832  }
833  // if we use a negative number of events we go back to the command line here
834  if (nEvents < 0){
835  return 0;
836  }
837  // if we run any of the particle generators and use 0 it'll run forever
838  if (nEvents == 0 && !Input::READHITS && !Input::HEPMC && !Input::READEIC){
839  cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
840  cout << "it will run forever, so I just return without running anything" << endl;
841  return 0;
842  }
843 
844  se->skip(skip);
845  se->run(nEvents);
846 
847  if (Enable::QA) QA_Output(outputroot + "_qa.root");
848 
849  //-----
850  // Exit
851  //-----
852 
853  se->End();
854  std::cout << "All done" << std::endl;
855  delete se;
856  if (Enable::PRODUCTION){
858  }
859  gSystem->Exit(0);
860  return 0;
861 }
862 
863 void ParseTString(TString &specialSetting)
864 {
865 // Barrel settings
866  if (specialSetting.Contains("BARRELV1"))
867  {
869  }
870  else if (specialSetting.Contains("BARRELV2"))
871  {
873  }
874  else if (specialSetting.Contains("BARRELV3"))
875  {
877  }
878  else if (specialSetting.Contains("BARRELV4"))
879  {
881  }
882  else if (specialSetting.Contains("BARREL"))
883  {
885  }
886 
887 // FST settings
888  if (specialSetting.Contains("FSTV1"))
889  {
890  G4FST::SETTING::FSTV1 = true;
891  }
892  else if (specialSetting.Contains("FSTV2"))
893  {
894  G4FST::SETTING::FSTV2 = true;
895  }
896  else if (specialSetting.Contains("FSTV3"))
897  {
898  G4FST::SETTING::FSTV3 = true;
899  }
900  else if (specialSetting.Contains("FSTV4"))
901  {
902  G4FST::SETTING::FSTV4 = true;
903  }
904  else if (specialSetting.Contains("FSTV41"))
905  {
906  G4FST::SETTING::FSTV41 = true;
907  }
908  else if (specialSetting.Contains("FSTV42"))
909  {
910  G4FST::SETTING::FSTV42 = true;
911  }
912  else if (specialSetting.Contains("FSTVTPC"))
913  {
915  }
916  else if (specialSetting.Contains("FST"))
917  {
918  G4FST::SETTING::FSTV0 = true;
919  }
920 
921  // FHCAL/FEMC settings
922  if (specialSetting.Contains("fsPHENIX"))
923  {
925  }
926  else if (specialSetting.Contains("EC2x"))
927  {
929  }
930  else if (specialSetting.Contains("ROS"))
931  {
933  }
934 
935  if (specialSetting.Contains("FullEtaAcc")) // common for FHCAL and FEMC
936  {
939  }
940  if (specialSetting.Contains("ASYM")) // common for FHCAL and FEMC
941  {
945  }
946  if (specialSetting.Contains("XDEPTH")) // common for FHCAL and FEMC
947  {
950  }
951  if (specialSetting.Contains("wDR")) // common for FHCAL and FEMC
952  {
956  }
957 
958  if (specialSetting.Contains("FwdConfig")) // common for FHCAL and FEMC
959  {
965  }
966  if (specialSetting.Contains("FwdSquare")) // common for FHCAL and FEMC
967  {
973  }
974 
975  if (specialSetting.Contains("HC2x"))
976  {
977  G4FHCAL::SETTING::HC2x = true;
979  }
980  if (specialSetting.Contains("FHCFeTungsten"))
981  {
983  }
984  if (specialSetting.Contains("FHCFeTungsten"))
985  {
987  }
988  else if (specialSetting.Contains("HC4x"))
989  {
991  }
992 
993  if (specialSetting.Contains("towercalib1"))
994  {
996  }
997  else if (specialSetting.Contains("towercalibSiPM"))
998  {
1000  }
1001  else if (specialSetting.Contains("towercalibHCALIN"))
1002  {
1004  }
1005  else if (specialSetting.Contains("towercalib3"))
1006  {
1008  }
1009  // DRCALO settings
1010  if (specialSetting.Contains("DRTungsten"))
1011  {
1013  }
1014  if (specialSetting.Contains("DRQuartz"))
1015  {
1017  }
1018  if (specialSetting.Contains("DRPMMA"))
1019  {
1021  }
1022  if (specialSetting.Contains("DRTUBES"))
1023  {
1025  }
1026 
1027  // EEMCH setting
1028  if (specialSetting.Contains("purePbWO4"))
1030  else
1032 
1033  if (specialSetting.Contains("BECAL")){
1038  }
1039  if (specialSetting.Contains("EEMCH"))
1041  else
1043 
1044  if (specialSetting.Contains("TTLEMd"))
1046  else if (specialSetting.Contains("TTLEMl"))
1048  else if (specialSetting.Contains("TTLEMs"))
1050  else if (specialSetting.Contains("TTLF"))
1052 
1053  if (specialSetting.Contains("LYSO")){
1056  }
1057  if (specialSetting.Contains("TTLBasicGeo")){
1059  } else {
1060  // deactivate DIRC basic supports in case the updated TTL is used -> already contains supports
1062  }
1063 
1064  if (specialSetting.Contains("ACLGAD"))
1066  else if (specialSetting.Contains("LGLGAD"))
1068 
1069  if (specialSetting.Contains("ALLSILICONV3"))
1071 
1072 
1073  if (specialSetting.Contains("OIRC"))
1074  G4DIRC::SETTING::NEWDIRC = false;
1075 
1076 
1077  if (specialSetting.Contains("FWDDETS")){
1078  Enable::HFARFWD_MAGNETS = true;
1080  }
1081 
1082 }
1083 
1084 #endif