EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Reco.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Reco.cc
1 #include "PHG4Reco.h"
2 
3 #include "Fun4AllMessenger.h"
5 #include "PHG4DisplayAction.h"
6 #include "PHG4InEvent.h"
7 #include "PHG4PhenixDetector.h"
14 #include "PHG4Subsystem.h"
15 #include "PHG4TrackingAction.h"
16 #include "PHG4UIsession.h"
17 #include "PHG4Utils.h"
18 
19 #include <g4decayer/EDecayType.hh>
21 
22 #include <phgeom/PHGeomUtility.h>
23 
25 
26 #include <phfield/PHFieldConfigv1.h>
27 #include <phfield/PHFieldConfigv2.h>
28 #include <phfield/PHFieldUtility.h>
29 
31 #include <fun4all/Fun4AllServer.h>
32 
33 #include <phool/PHCompositeNode.h>
34 #include <phool/PHDataNode.h> // for PHDataNode
35 #include <phool/PHNode.h> // for PHNode
36 #include <phool/PHNodeIterator.h> // for PHNodeIterator
37 #include <phool/PHObject.h> // for PHObject
38 #include <phool/PHRandomSeed.h>
39 #include <phool/getClass.h>
40 #include <phool/phool.h> // for PHWHERE
41 #include <phool/recoConsts.h>
42 
43 #include <eicphysicslist/EICPhysicsList.hh>
44 
45 #include <TSystem.h> // for TSystem, gSystem
46 
47 #include <CLHEP/Random/Random.h>
48 
49 #include <Geant4/G4Cerenkov.hh>
50 #include <Geant4/G4Scintillation.hh>
51 #include <Geant4/G4Element.hh> // for G4Element
52 #include <Geant4/G4EventManager.hh> // for G4EventManager
53 #include <Geant4/G4HadronicProcessStore.hh>
54 #include <Geant4/G4IonisParamMat.hh> // for G4IonisParamMat
55 #include <Geant4/G4LossTableManager.hh>
56 #include <Geant4/G4Material.hh>
57 #include <Geant4/G4MaterialPropertiesTable.hh> // for G4MaterialProperties...
58 #include <Geant4/G4MaterialPropertyVector.hh> // for G4MaterialPropertyVector
59 #include <Geant4/G4NistManager.hh>
60 #include <Geant4/G4OpAbsorption.hh>
61 #include <Geant4/G4OpBoundaryProcess.hh>
62 #include <Geant4/G4OpMieHG.hh>
63 #include <Geant4/G4OpRayleigh.hh>
64 #include <Geant4/G4OpWLS.hh>
65 #include <Geant4/G4OpticalPhoton.hh>
66 #include <Geant4/G4ParticleDefinition.hh>
67 #include <Geant4/G4ParticleTable.hh>
68 #include <Geant4/G4PhotoElectricEffect.hh> // for G4PhotoElectricEffect
69 #include <Geant4/G4ProcessManager.hh>
70 #include <Geant4/G4ProductionCuts.hh> // for G4ProductionCuts
71 #include <Geant4/G4Region.hh>
72 #include <Geant4/G4RegionStore.hh>
73 #include <Geant4/G4RunManager.hh>
74 #include <Geant4/G4StepLimiterPhysics.hh>
75 #include <Geant4/G4String.hh> // for G4String
76 #include <Geant4/G4SystemOfUnits.hh>
77 #include <Geant4/G4Types.hh> // for G4double, G4int
78 #include <Geant4/G4UIExecutive.hh>
79 #include <Geant4/G4UImanager.hh>
80 #include <Geant4/G4UImessenger.hh> // for G4UImessenger
81 #include <Geant4/G4VModularPhysicsList.hh> // for G4VModularPhysicsList
82 #include <Geant4/G4Version.hh>
83 #include <Geant4/G4VisExecutive.hh>
84 #include <Geant4/G4VisManager.hh> // for G4VisManager
85 
86 // physics lists
87 #include <Geant4/FTFP_BERT.hh>
88 #include <Geant4/FTFP_BERT_HP.hh>
89 #include <Geant4/FTFP_INCLXX.hh>
90 #include <Geant4/FTFP_INCLXX_HP.hh>
91 #include <Geant4/QGSP_BERT.hh>
92 #include <Geant4/QGSP_BERT_HP.hh>
93 #include <Geant4/QGSP_BIC.hh>
94 #include <Geant4/QGSP_BIC_HP.hh>
95 #include <Geant4/QGSP_INCLXX.hh>
96 #include <Geant4/QGSP_INCLXX_HP.hh>
97 
98 #include <boost/filesystem.hpp>
99 
100 #include <cassert>
101 #include <cstdlib>
102 #include <exception> // for exception
103 #include <iostream> // for operator<<, endl
104 #include <memory>
105 #include <set> // for set, _Rb_tree_const_...
106 #include <vector> // for vector, vector<>::it...
107 
108 class G4TrackingManager;
109 class G4VPhysicalVolume;
110 class PHField;
111 class PHG4EventAction;
112 class PHG4StackingAction;
113 class PHG4SteppingAction;
114 
115 using namespace std;
116 
117 //_________________________________________________________________
118 PHG4Reco::PHG4Reco(const string &name)
119  : SubsysReco(name)
120  , m_MagneticFieldRescale(1.0)
121  , m_Field(nullptr)
122  , m_RunManager(nullptr)
123  , m_UISession(nullptr)
124  , m_Detector(nullptr)
125  , m_EventAction(nullptr)
126  , m_SteppingAction(nullptr)
127  , m_TrackingAction(nullptr)
128  , m_DisplayAction(nullptr)
129  , m_GeneratorAction(nullptr)
130  , m_VisManager(nullptr)
131  , m_Fun4AllMessenger(new Fun4AllMessenger(Fun4AllServer::instance()))
132  , m_UImanager(nullptr)
133  , m_EtaCoverage(1.0)
134  , m_FieldConfigType(PHFieldConfig::kFieldUniform)
135  , m_FieldMapFile("NONE")
136  , m_WorldShape("G4Tubs")
137  , m_WorldMaterial("G4_AIR")
138 #if G4VERSION_NUMBER >= 1033
139  , m_PhysicsList("FTFP_BERT")
140 #else
141  , m_PhysicsList("QGSP_BERT")
142 #endif
143  , m_ActiveDecayerFlag(true)
144  , m_ActiveForceDecayFlag(false)
145  , m_ForceDecayType(kAll)
146  , m_SaveDstGeometryFlag(true)
147  , m_disableUserActions(false)
148 {
149  for (int i = 0; i < 3; i++)
150  {
151  m_WorldSize[i] = 1000.;
152  }
153  return;
154 }
155 
156 //_________________________________________________________________
158 {
159  // one can delete null pointer (it results in a nop), so checking if
160  // they are non zero is not needed
161  delete m_Field;
162  delete m_RunManager;
163  delete m_UISession;
164  delete m_VisManager;
165  delete m_Fun4AllMessenger;
166  while (m_SubsystemList.begin() != m_SubsystemList.end())
167  {
168  delete m_SubsystemList.back();
169  m_SubsystemList.pop_back();
170  }
171  delete m_DisplayAction;
172 }
173 
174 //_________________________________________________________________
176 {
177  if (Verbosity() > 0)
178  {
179  cout << "========================= PHG4Reco::Init() ================================" << endl;
180  }
181  unsigned int iseed = PHRandomSeed();
182  G4Seed(iseed); // fixed seed handled in PHRandomSeed()
183 
184  // create GEANT run manager
185  if (Verbosity() > 1) cout << "PHG4Reco::Init - create run manager" << endl;
186 
187  // redirect GEANT verbosity to nowhere
188  // if (Verbosity() < 1)
189  if (0)
190  {
191  G4UImanager *uimanager = G4UImanager::GetUIpointer();
192  m_UISession = new PHG4UIsession();
193  uimanager->SetSession(m_UISession);
194  uimanager->SetCoutDestination(m_UISession);
195  }
196 
197  m_RunManager = new G4RunManager();
198 
199  DefineMaterials();
200  // create physics processes
201  G4VModularPhysicsList *myphysicslist = nullptr;
202  if (m_PhysicsList == "FTFP_BERT")
203  {
204  myphysicslist = new FTFP_BERT(Verbosity());
205  }
206  else if (m_PhysicsList == "FTFP_BERT_HP")
207  {
208  setenv("AllowForHeavyElements", "1", 1);
209  myphysicslist = new FTFP_BERT_HP(Verbosity());
210  }
211  else if (m_PhysicsList == "FTFP_INCLXX")
212  {
213  myphysicslist = new FTFP_INCLXX(Verbosity());
214  }
215  else if (m_PhysicsList == "FTFP_INCLXX_HP")
216  {
217  setenv("AllowForHeavyElements", "1", 1);
218  myphysicslist = new FTFP_INCLXX_HP(Verbosity());
219  }
220  else if (m_PhysicsList == "QGSP_BERT")
221  {
222  myphysicslist = new QGSP_BERT(Verbosity());
223  }
224  else if (m_PhysicsList == "QGSP_BERT_HP")
225  {
226  setenv("AllowForHeavyElements", "1", 1);
227  myphysicslist = new QGSP_BERT_HP(Verbosity());
228  }
229  else if (m_PhysicsList == "QGSP_BIC")
230  {
231  myphysicslist = new QGSP_BIC(Verbosity());
232  }
233  else if (m_PhysicsList == "QGSP_BIC_HP")
234  {
235  setenv("AllowForHeavyElements", "1", 1);
236  myphysicslist = new QGSP_BIC_HP(Verbosity());
237  }
238  else if (m_PhysicsList == "QGSP_INCLXX")
239  {
240  myphysicslist = new QGSP_INCLXX(Verbosity());
241  }
242  else if (m_PhysicsList == "QGSP_INCLXX_HP")
243  {
244  setenv("AllowForHeavyElements", "1", 1);
245  myphysicslist = new QGSP_INCLXX_HP(Verbosity());
246  }
247  else if (m_PhysicsList == "EIC")
248  {
249  myphysicslist = new EICPhysicsList();
250  }
251  else
252  {
253  cout << "Physics List " << m_PhysicsList << " not implemented" << endl;
254  gSystem->Exit(1);
255  exit(1);
256  }
257 
259  {
262  {
264  }
265  myphysicslist->RegisterPhysics(decayer);
266  }
267  myphysicslist->RegisterPhysics(new G4StepLimiterPhysics());
268  // initialize cuts so we can ask the world region for it's default
269  // cuts to propagate them to other regions in DefineRegions()
270  myphysicslist->SetCutsWithDefault();
271  m_RunManager->SetUserInitialization(myphysicslist);
272 
273  DefineRegions();
274 #if G4VERSION_NUMBER >= 1033
275  G4EmSaturation *emSaturation = G4LossTableManager::Instance()->EmSaturation();
276  if (!emSaturation)
277  {
278  cout << PHWHERE << "Could not initialize EmSaturation, Birks constants will fail" << endl;
279  }
280 #endif
281  // initialize registered subsystems
282  for (SubsysReco *reco: m_SubsystemList)
283  {
284  reco->Init(topNode);
285  }
286 
287  if (Verbosity() > 0)
288  {
289  cout << "===========================================================================" << endl;
290  }
291  return 0;
292 }
293 
295 {
296  if (Verbosity() > 1) cout << "PHG4Reco::InitField - create magnetic field setup" << endl;
297 
298  unique_ptr<PHFieldConfig> default_field_cfg(nullptr);
299 
300  if (m_FieldMapFile != "NONE")
301  {
303  }
304  else
305  {
306  default_field_cfg.reset(new PHFieldConfigv2(0, 0, m_MagneticField * m_MagneticFieldRescale));
307  }
308 
309  if (Verbosity() > 1) cout << "PHG4Reco::InitField - create magnetic field setup" << endl;
310 
311  PHField *phfield = PHFieldUtility::GetFieldMapNode(default_field_cfg.get(), topNode, Verbosity() + 1);
312  assert(phfield);
313 
314  m_Field = new G4TBMagneticFieldSetup(phfield);
315 
317 }
318 
320 {
321  // this is a dumb protection against executing this twice.
322  // we have cases (currently detector display or material scan) where
323  // we need the detector but have not run any events (who wants to wait
324  // for processing an event if you just want a detector display?).
325  // Then the InitRun is executed from a macro. But if you decide to run events
326  // afterwards, the InitRun is executed by the framework together with all
327  // other modules. This prevents the PHG4Reco::InitRun() to be executed
328  // again in this case
329  static int InitRunDone = 0;
330  if (InitRunDone)
331  {
333  }
334  InitRunDone = 1;
335  if (Verbosity() > 0)
336  {
337  cout << "========================= PHG4Reco::InitRun() ================================" << endl;
338  }
339 
341 
342  rc->set_StringFlag("WorldMaterial", m_WorldMaterial);
343 // build world material - so in subsequent code we can call
344 // G4Material::GetMaterial(rc->get_StringFlag("WorldMaterial"))
345 // if the world material is not in the nist DB, we need to implement it here
346  G4NistManager::Instance()->FindOrBuildMaterial(m_WorldMaterial);
347  // G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
348  // G4NistManager::Instance()->FindOrBuildMaterial("G4_Be");
349  // G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
350  // G4NistManager::Instance()->FindOrBuildMaterial("G4_STAINLESS-STEEL");
351  rc->set_FloatFlag("WorldSizex", m_WorldSize[0]);
352  rc->set_FloatFlag("WorldSizey", m_WorldSize[1]);
353  rc->set_FloatFlag("WorldSizez", m_WorldSize[2]);
354 
355  //setup the global field
356  const int field_ret = InitField(topNode);
357  if (field_ret != Fun4AllReturnCodes::EVENT_OK)
358  {
359  cout << "PHG4Reco::InitRun- Error - Failed field init with status = " << field_ret << endl;
360  return field_ret;
361  }
362 
363  // initialize registered subsystems
364  for (SubsysReco *reco: m_SubsystemList)
365  {
366  if (Verbosity() >= 1)
367  {
368  cout << "PHG4Reco::InitRun - " << reco->Name() << "->InitRun" << endl;
369  }
370  reco->InitRun(topNode);
371  }
372 
373  // create phenix detector, add subsystems, and register to GEANT
374  // create display settings before detector
376  if (Verbosity() > 1) cout << "PHG4Reco::Init - create detector" << endl;
377  m_Detector = new PHG4PhenixDetector(this);
384 
385  for (PHG4Subsystem *g4sub: m_SubsystemList)
386  {
387  if (g4sub->GetDetector())
388  {
389  m_Detector->AddDetector(g4sub->GetDetector());
390  }
391  }
392  m_RunManager->SetUserInitialization(m_Detector);
393 
395  {
396  cout << "PHG4Reco::InitRun - WARNING - event/track/stepping action disabled! "
397  << "This is aimed to reduce resource consumption for G4 running only. E.g. dose analysis. "
398  << "Meanwhile, it will disable all Geant4 based analysis. Toggle this feature on/off with PHG4Reco::setDisableUserActions()" << endl;
399  }
400 
401  setupInputEventNodeReader(topNode);
402  // create main event action, add subsystemts and register to GEANT
404 
405  for (PHG4Subsystem *g4sub: m_SubsystemList)
406  {
407  PHG4EventAction *evtact = g4sub->GetEventAction();
408  if (evtact)
409  {
410  m_EventAction->AddAction(evtact);
411  }
412  }
413 
414  if (not m_disableUserActions)
415  {
416  m_RunManager->SetUserAction(m_EventAction);
417  }
418 
419  // create main stepping action, add subsystems and register to GEANT
421  for (PHG4Subsystem *g4sub: m_SubsystemList)
422  {
423  PHG4StackingAction *action = g4sub->GetStackingAction();
424  if (action)
425  {
426  if (Verbosity() > 1)
427  {
428  cout << "Adding steppingaction for " << g4sub->Name() << endl;
429  }
430  m_StackingAction->AddAction(g4sub->GetStackingAction());
431  }
432  }
433 
434  if (not m_disableUserActions)
435  {
436  m_RunManager->SetUserAction(m_StackingAction);
437  }
438 
439  // create main stepping action, add subsystems and register to GEANT
441  for (PHG4Subsystem *g4sub: m_SubsystemList)
442  {
443  PHG4SteppingAction *action = g4sub->GetSteppingAction();
444  if (action)
445  {
446  if (Verbosity() > 1)
447  {
448  cout << "Adding steppingaction for " << g4sub->Name() << endl;
449  }
450 
451  m_SteppingAction->AddAction(g4sub->GetSteppingAction());
452  }
453  }
454 
455  if (not m_disableUserActions)
456  {
457  m_RunManager->SetUserAction(m_SteppingAction);
458  }
459 
460  // create main tracking action, add subsystems and register to GEANT
462  for (PHG4Subsystem *g4sub: m_SubsystemList)
463  {
464  m_TrackingAction->AddAction(g4sub->GetTrackingAction());
465 
466  // not all subsystems define a user tracking action
467  if (g4sub->GetTrackingAction())
468  {
469  // make tracking manager accessible within user tracking action if defined
470  if (G4TrackingManager *trackingManager = G4EventManager::GetEventManager()->GetTrackingManager())
471  {
472  g4sub->GetTrackingAction()->SetTrackingManagerPointer(trackingManager);
473  }
474  }
475  }
476 
477  if (not m_disableUserActions)
478  {
479  m_RunManager->SetUserAction(m_TrackingAction);
480  }
481 
482  // initialize
483  m_RunManager->Initialize();
484 
485  // add cerenkov and optical photon processes
486  // cout << endl << "Ignore the next message - we implemented this correctly" << endl;
487  G4Cerenkov *theCerenkovProcess = new G4Cerenkov("Cerenkov");
488  // cout << "End of bogus warning message" << endl << endl;
489  G4Scintillation* theScintillationProcess = new G4Scintillation("Scintillation");
490 
491  /*
492  if (Verbosity() > 0)
493  {
494  // This segfaults
495  theCerenkovProcess->DumpPhysicsTable();
496  }
497  */
498  theCerenkovProcess->SetMaxNumPhotonsPerStep(300);
499  theCerenkovProcess->SetMaxBetaChangePerStep(10.0);
500  theCerenkovProcess->SetTrackSecondariesFirst(false); // current PHG4TruthTrackingAction does not support suspect active track and track secondary first
501 
502  theScintillationProcess->SetScintillationYieldFactor(1.0);
503  theScintillationProcess->SetTrackSecondariesFirst(false);
504  // theScintillationProcess->SetScintillationExcitationRatio(1.0);
505 
506  // Use Birks Correction in the Scintillation process
507 
508  // G4EmSaturation* emSaturation = G4LossTableManager::Instance()->EmSaturation();
509  // theScintillationProcess->AddSaturation(emSaturation);
510 
511  G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
512  G4ParticleTable::G4PTblDicIterator *_theParticleIterator;
513  _theParticleIterator = theParticleTable->GetIterator();
514  _theParticleIterator->reset();
515  while ((*_theParticleIterator)())
516  {
517  G4ParticleDefinition *particle = _theParticleIterator->value();
518  G4String particleName = particle->GetParticleName();
519  G4ProcessManager *pmanager = particle->GetProcessManager();
520  if (theCerenkovProcess->IsApplicable(*particle))
521  {
522  pmanager->AddProcess(theCerenkovProcess);
523  pmanager->SetProcessOrdering(theCerenkovProcess, idxPostStep);
524  }
525  if (theScintillationProcess->IsApplicable(*particle))
526  {
527  pmanager->AddProcess(theScintillationProcess);
528  pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest);
529  pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep);
530  }
531  for (PHG4Subsystem *g4sub: m_SubsystemList)
532  {
533  g4sub->AddProcesses(particle);
534  }
535  }
536  G4ProcessManager *pmanager = G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
537  // std::cout << " AddDiscreteProcess to OpticalPhoton " << std::endl;
538  pmanager->AddDiscreteProcess(new G4OpAbsorption());
539  pmanager->AddDiscreteProcess(new G4OpRayleigh());
540  pmanager->AddDiscreteProcess(new G4OpMieHG());
541  pmanager->AddDiscreteProcess(new G4OpBoundaryProcess());
542  pmanager->AddDiscreteProcess(new G4OpWLS());
543  pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
544  // pmanager->DumpInfo();
545 
546  // needs large amount of memory which kills central hijing events
547  // store generated trajectories
548  //if( G4TrackingManager* trackingManager = G4EventManager::GetEventManager()->GetTrackingManager() ){
549  // trackingManager->SetStoreTrajectory( true );
550  //}
551 
552  // quiet some G4 print-outs (EM and Hadronic settings during first event)
553  G4HadronicProcessStore::Instance()->SetVerbose(0);
554  G4LossTableManager::Instance()->SetVerbose(1);
555 
556  if ((Verbosity() < 1) && (m_UISession))
557  {
558  m_UISession->Verbosity(1); // let messages after setup come through
559  }
560 
561  // Geometry export to DST
563  {
564  const string filename = PHGeomUtility::GenerateGeometryFileName("gdml");
565  cout << "PHG4Reco::InitRun - export geometry to DST via tmp file " << filename << endl;
566 
567  Dump_GDML(filename);
568 
569  PHGeomUtility::ImportGeomFile(topNode, filename);
570 
572  }
573 
574  if (Verbosity() > 0)
575  {
576  cout << "===========================================================================" << endl;
577  }
578 
579  return 0;
580 }
581 
582 //________________________________________________________________
583 //Dump TGeo File
584 void PHG4Reco::Dump_GDML(const std::string &filename)
585 {
587 }
588 
589 //________________________________________________________________
590 //Dump TGeo File using native Geant4 tools
591 void PHG4Reco::Dump_G4_GDML(const std::string &filename)
592 {
594 }
595 
596 //_________________________________________________________________
597 int PHG4Reco::ApplyCommand(const std::string &cmd)
598 {
599  InitUImanager();
600  int iret = m_UImanager->ApplyCommand(cmd.c_str());
601  return iret;
602 }
603 //_________________________________________________________________
604 
606 {
607  // kludge, using boost::dll::program_location().string().c_str() for the
608  // program name and putting it into args lead to invalid reads in G4String
609  char *args[] = {(char *) ("root.exe")};
610  G4UIExecutive *ui = new G4UIExecutive(1, args);
611  InitUImanager();
612  m_UImanager->ApplyCommand("/control/execute init_gui_vis.mac");
613  ui->SessionStart();
614  delete ui;
615  return 0;
616 }
617 
619 {
620  if (!m_UImanager)
621  {
622  // Get the pointer to the User Interface manager
623  // Initialize visualization
624  m_VisManager = new G4VisExecutive;
625  m_VisManager->Initialize();
626  m_UImanager = G4UImanager::GetUIpointer();
627  }
628  return 0;
629 }
630 
631 //_________________________________________________________________
633 {
634  // make sure Actions and subsystems have the relevant pointers set
635  PHG4InEvent *ineve = findNode::getClass<PHG4InEvent>(topNode, "PHG4INEVENT");
637 
638  for (SubsysReco *reco: m_SubsystemList)
639  {
640  if (Verbosity() >= 2)
641  cout << "PHG4Reco::process_event - " << reco->Name() << "->process_event" << endl;
642 
643  try
644  {
645  reco->process_event(topNode);
646  }
647  catch (const exception &e)
648  {
649  cout << PHWHERE << " caught exception thrown during process_event from "
650  << reco->Name() << endl;
651  cout << "error: " << e.what() << endl;
653  }
654  }
655 
656  // run one event
657  if (Verbosity() >= 2)
658  {
659  cout << " PHG4Reco::process_event - "
660  << "run one event :" << endl;
661  ineve->identify();
662  }
663  m_RunManager->BeamOn(1);
664 
665  for (PHG4Subsystem *g4sub: m_SubsystemList)
666  {
667  if (Verbosity() >= 2)
668  cout << " PHG4Reco::process_event - " << g4sub->Name() << "->process_after_geant" << endl;
669  try
670  {
671  g4sub->process_after_geant(topNode);
672  }
673  catch (const exception &e)
674  {
675  cout << PHWHERE << " caught exception thrown during process_after_geant from "
676  << g4sub->Name() << endl;
677  cout << "error: " << e.what() << endl;
679  }
680  }
681  return 0;
682 }
683 
685 {
686  for (SubsysReco *reco: m_SubsystemList)
687  {
688  reco->ResetEvent(topNode);
689  }
690  return 0;
691 }
692 
693 void PHG4Reco::Print(const std::string &what) const
694 {
695  for (SubsysReco *reco: m_SubsystemList)
696  {
697  if (what.empty() || what == "ALL" || (reco->Name()).find(what) != string::npos)
698  {
699  cout << "Printing " << reco->Name() << endl;
700  reco->Print(what);
701  cout << "---------------------------" << endl;
702  }
703  }
704  return;
705 }
706 
708 {
709  PHG4InEvent *ineve = findNode::getClass<PHG4InEvent>(topNode, "PHG4INEVENT");
710  if (!ineve)
711  {
712  PHNodeIterator iter(topNode);
713  PHCompositeNode *dstNode;
714  dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
715 
716  ineve = new PHG4InEvent();
717  PHDataNode<PHObject> *newNode = new PHDataNode<PHObject>(ineve, "PHG4INEVENT", "PHObject");
718  dstNode->addNode(newNode);
719  }
720  // check if we have already registered a generator before creating the default which uses PHG4InEvent Node
721  if (!m_GeneratorAction)
722  {
724  }
725  m_RunManager->SetUserAction(m_GeneratorAction);
726  return 0;
727 }
728 
730 {
731  m_EtaCoverage = eta;
733 }
734 
735 void PHG4Reco::G4Seed(const unsigned int i)
736 {
737  CLHEP::HepRandom::setTheSeed(i);
738  return;
739 }
740 
741 //____________________________________________________________________________
743 {
744  G4String symbol,name; //a=mass of a mole;
745  G4double density; //z=mean number of protons;
746  G4double fractionmass,a;
747  G4int ncomponents, natoms,z;
748  // this is for FTFP_BERT_HP where the neutron code barfs
749  // if the z difference to the last known element (U) is too large
750  // home made compounds
751  // this is a legacy implementation but if they are used in multiple
752  // subsystems put them here
753  // otherwise implement locally used ones now in the DefineMaterials()
754  // method in your subsystem
755 
756  // making quartz
757  G4Material *quartz = new G4Material("Quartz", density = 2.200 * g / cm3, ncomponents = 2);
758  quartz->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 1);
759  quartz->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 2);
760 
761  // making carbon fiber epoxy
762  G4Material *cfrp_intt = new G4Material("CFRP_INTT", density = 1.69 * g / cm3, ncomponents = 3);
763  cfrp_intt->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 10);
764  cfrp_intt->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 6);
765  cfrp_intt->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 1);
766 
767  // water glycol mixture for the INTT endcap rings
768  G4Material *PropyleneGlycol = new G4Material("Propyleneglycol", 1.036 * g / cm3, 3);
769  PropyleneGlycol->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 3);
770  PropyleneGlycol->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 8);
771  PropyleneGlycol->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 2);
772 
773  G4Material *WaterGlycol_INTT = new G4Material("WaterGlycol_INTT", density = (0.997 * 0.7 + 1.036 * 0.3) * g / cm3, ncomponents = 2);
774  WaterGlycol_INTT->AddMaterial(PropyleneGlycol, fractionmass = 0.30811936);
775  WaterGlycol_INTT->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER"), fractionmass = 0.69188064);
776 
777  // making Rohacell foam 110
778  G4Material *rohacell_foam_110 = new G4Material("ROHACELL_FOAM_110", density = 0.110 * g / cm3, ncomponents = 4);
779  rohacell_foam_110->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 8);
780  rohacell_foam_110->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 11);
781  rohacell_foam_110->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 2);
782  rohacell_foam_110->AddElement(G4NistManager::Instance()->FindOrBuildElement("N"), 1);
783 
784  // making Rohacell foam ROHACELL 51 WF
785  // Source of density: https://www.rohacell.com/product/peek-industrial/downloads/rohacell%20wf%20product%20information.pdf
786  G4Material *rohacell_foam_51 = new G4Material("ROHACELL_FOAM_51", density = 0.052 * g / cm3, ncomponents = 4);
787  rohacell_foam_51->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 8);
788  rohacell_foam_51->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 11);
789  rohacell_foam_51->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 2);
790  rohacell_foam_51->AddElement(G4NistManager::Instance()->FindOrBuildElement("N"), 1);
791 
792  // making Carbon PEEK : 30 - 70 Vf.
793  // https://www.quantum-polymers.com/wp-content/uploads/2017/03/QuantaPEEK-CF30.pdf
794  G4Material *peek = new G4Material("PEEK", density = 1.32 * g / cm3, ncomponents = 3);
795  peek->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 19);
796  peek->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 12);
797  peek->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 3);
798 
799  G4Material *cf = new G4Material("CF", density = 1.62 * g / cm3, ncomponents = 1);
800  cf->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 1.);
801 
802  G4Material *cf30_peek70 = new G4Material("CF30_PEEK70", density = (1.32 * 0.7 + 1.62 * 0.3) * g / cm3, ncomponents = 2);
803  cf30_peek70->AddMaterial(cf, fractionmass = 0.34468085);
804  cf30_peek70->AddMaterial(peek, fractionmass = 0.65531915);
805 
806  // gas mixture for the MuID in fsPHENIX. CLS 02-25-14
807  G4Material *IsoButane = new G4Material("Isobutane", 0.00265 * g / cm3, 2);
808  IsoButane->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 4);
809  IsoButane->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 10);
810 
811  G4Material *MuIDgas = new G4Material("MuIDgas", density = (1.977e-3 * 0.92 + 0.00265 * 0.08) * g / cm3, ncomponents = 2);
812  MuIDgas->AddMaterial(IsoButane, fractionmass = 0.08);
813  MuIDgas->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_CARBON_DIOXIDE"), fractionmass = 0.92);
814 
815  // that seems to be the composition of 304 Stainless steel
816  G4Material *StainlessSteel =
817  new G4Material("SS304", density = 7.9 * g / cm3, ncomponents = 8);
818  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.70105);
819  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Cr"), 0.18);
820  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Ni"), 0.09);
821  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.02);
822  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.0007);
823  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("S"), 0.0003);
824  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.0075);
825  StainlessSteel->AddElement(G4NistManager::Instance()->FindOrBuildElement("P"), 0.00045);
826 
827  G4Material *SS310 =
828  new G4Material("SS310", density = 8.0 * g / cm3, ncomponents = 8);
829  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.50455);
830  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("Cr"), 0.25);
831  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("Ni"), 0.20);
832  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.02);
833  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.0025);
834  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("S"), 0.015);
835  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.0075);
836  SS310->AddElement(G4NistManager::Instance()->FindOrBuildElement("P"), 0.00045);
837 
838  // SS316 from https://www.azom.com
839  G4Material *SS316 =
840  new G4Material("SS316", density = 8.0 * g / cm3, ncomponents = 9);
841  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.68095);
842  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Cr"), 0.16);
843  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Ni"), 0.11);
844  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.02);
845  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mo"), 0.02);
846  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.0008);
847  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("S"), 0.0003);
848  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.0075);
849  SS316->AddElement(G4NistManager::Instance()->FindOrBuildElement("P"), 0.00045);
850 
851  G4Material *Steel =
852  new G4Material("Steel", density = 7.86 * g / cm3, ncomponents = 5);
853  Steel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.9834);
854  Steel->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.014);
855  Steel->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.0017);
856  Steel->AddElement(G4NistManager::Instance()->FindOrBuildElement("S"), 0.00045);
857  Steel->AddElement(G4NistManager::Instance()->FindOrBuildElement("P"), 0.00045);
858 
859  // a36 steel from http://www.matweb.com
860  G4Material *a36 = new G4Material("Steel_A36", density = 7.85 * g / cm3, ncomponents = 5);
861  a36->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.9824);
862  a36->AddElement(G4NistManager::Instance()->FindOrBuildElement("Cu"), 0.002);
863  a36->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.0025);
864  a36->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.0103);
865  a36->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.0028);
866 
867  // 1006 steel from http://www.matweb.com
868  G4Material *steel_1006 = new G4Material("Steel_1006", density = 7.872 * g / cm3, ncomponents = 2);
869  steel_1006->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.996);
870  steel_1006->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.004);
871 
872  // from www.aalco.co.uk
873  G4Material *Al5083 = new G4Material("Al5083", density = 2.65 * g / cm3, ncomponents = 3);
874  Al5083->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mn"), 0.004);
875  Al5083->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mg"), 0.04);
876  Al5083->AddElement(G4NistManager::Instance()->FindOrBuildElement("Al"), 0.956);
877 
878  // Al 4046 from http://www.matweb.com
879  G4Material *Al4046 = new G4Material("Al4046", density = 2.66 * g / cm3, ncomponents = 3);
880  Al4046->AddElement(G4NistManager::Instance()->FindOrBuildElement("Al"), 0.897);
881  Al4046->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.1);
882  Al4046->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mg"), 0.003);
883 
884  // Al 6061T6 from http://www.matweb.com
885  G4Material *Al6061T6 = new G4Material("Al6061T6", density = 2.70 * g / cm3, ncomponents = 4);
886  Al6061T6->AddElement(G4NistManager::Instance()->FindOrBuildElement("Al"), 0.975);
887  Al6061T6->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 0.008);
888  Al6061T6->AddElement(G4NistManager::Instance()->FindOrBuildElement("Mg"), 0.01);
889  Al6061T6->AddElement(G4NistManager::Instance()->FindOrBuildElement("Fe"), 0.007);
890 
891  // E864 Pb-Scifi calorimeter
892  // E864 Calorimeter is 99% Pb, 1% Antimony
893  //Nuclear Instruments and Methods in Physics Research A 406 (1998) 227 258
894  G4double density_e864 = (0.99 * 11.34 + 0.01 * 6.697) * g / cm3;
895  G4Material *absorber_e864 = new G4Material("E864_Absorber", density_e864, 2);
896  absorber_e864->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Pb"), 0.99);
897  absorber_e864->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Sb"), 0.01);
898 
899  G4Material *FPC = new G4Material("FPC", 1.542 * g / cm3, 2);
900  FPC->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu"), 0.0162);
901  FPC->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON"), 0.9838);
902 
903  // This is an approximation for the W saturated epoxy of the EMCal.
904  G4Material *W_Epoxy = new G4Material("W_Epoxy", density = 10.2 * g / cm3, ncomponents = 2);
905  W_Epoxy->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_W"), fractionmass = 0.5);
906  W_Epoxy->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_POLYSTYRENE"), fractionmass = 0.5);
907 
908  //from http://www.physi.uni-heidelberg.de/~adler/TRD/TRDunterlagen/RadiatonLength/tgc2.htm
909  //Epoxy (for FR4 )
910  //density = 1.2*g/cm3;
911  G4Material *Epoxy = new G4Material("Epoxy", 1.2 * g / cm3, ncomponents = 2);
912  Epoxy->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), natoms = 2);
913  Epoxy->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 2);
914 
915  //FR4 (Glass + Epoxy)
916  density = 1.86 * g / cm3;
917  G4Material *FR4 = new G4Material("FR4", density, ncomponents = 2);
918  FR4->AddMaterial(quartz, fractionmass = 0.528);
919  FR4->AddMaterial(Epoxy, fractionmass = 0.472);
920  // NOMEX (HoneyComb)
921  // density from http://www.fibreglast.com/product/Nomex_Honeycomb_1562/Vacuum_Bagging_Sandwich_Core
922  // 1562: 29 kg/m^3 <-- I guess it is this one
923  // 2562: 48 kg/m^3
924  // chemical composition http://ww2.unime.it/cdlchimind/adm/inviofile/uploads/HP_Pols2.b.pdf
925  density = 29 * kg / m3;
926  G4Material *NOMEX = new G4Material("NOMEX", density, ncomponents = 4);
927  NOMEX->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 14);
928  NOMEX->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), natoms = 10);
929  NOMEX->AddElement(G4NistManager::Instance()->FindOrBuildElement("N"), natoms = 2);
930  NOMEX->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 2);
931  // spacal material. Source : EICROOT/A. Kiselev
932  /*
933  WEpoxyMix 3 12.011 1.008 183.85 6. 1. 74. 12.18 0.029 0.002 0.969
934  1 1 30. .00001
935  0
936  */
937  G4Material *Spacal_W_Epoxy =
938  new G4Material("Spacal_W_Epoxy", density = 12.18 * g / cm3, ncomponents = 3);
939  Spacal_W_Epoxy->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 0.029);
940  Spacal_W_Epoxy->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 0.002);
941  Spacal_W_Epoxy->AddElement(G4NistManager::Instance()->FindOrBuildElement("W"), 0.969);
942  /*
943 PMMA -3 12.01 1.008 15.99 6. 1. 8. 1.19 3.6 5.7 1.4
944  1 1 20. .00001
945  0
946  */
947  G4Material *PMMA =
948  new G4Material("PMMA", density = 1.19 * g / cm3, ncomponents = 3);
949  PMMA->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), 3.6 / (3.6 + 5.7 + 1.4));
950  PMMA->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), 5.7 / (3.6 + 5.7 + 1.4));
951  PMMA->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 1.4 / (3.6 + 5.7 + 1.4));
952 
953  G4Material *G10 =
954  new G4Material("G10", density = 1.700 * g / cm3, ncomponents = 4);
955  G10->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), natoms = 1);
956  G10->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 2);
957  G10->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 3);
958  G10->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), natoms = 3);
959 
960  G4Material *CsI =
961  new G4Material("CsI", density = 4.534 * g / cm3, ncomponents = 2);
962  CsI->AddElement(G4NistManager::Instance()->FindOrBuildElement("Cs"), natoms = 1);
963  CsI->AddElement(G4NistManager::Instance()->FindOrBuildElement("I"), natoms = 1);
964  CsI->GetIonisation()->SetMeanExcitationEnergy(553.1 * eV);
965 
966  G4Material *C4F10 =
967  new G4Material("C4F10", density = 0.00973 * g / cm3, ncomponents = 2);
968  C4F10->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 4);
969  C4F10->AddElement(G4NistManager::Instance()->FindOrBuildElement("F"), natoms = 10);
970 
971  G4Material *CF4 = new G4Material("CF4", density = 3.72 * mg / cm3, ncomponents = 2, kStateGas, 288.15 * kelvin, 1 * atmosphere);
972  CF4->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 1);
973  CF4->AddElement(G4NistManager::Instance()->FindOrBuildElement("F"), natoms = 4);
974 
975  G4Element* elLu = new G4Element(name="Lutetium", symbol="Lu", z=71., a=174.97*g/mole);
976  G4Material *LSO = new G4Material("LSO", //its name
977  density = 7.4*g/cm3, //its density
978  ncomponents = 3); //number of components
979 
980  LSO->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), natoms = 1);
981  LSO->AddElement(elLu, natoms = 2);
982  LSO->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 5);
983 
984  // Silver epoxy glue LOCTITE ABLESTIK 2902 for the silicon sensors and FPHX chips of INTT
985  G4Material *SilverEpoxyGlue_INTT = new G4Material("SilverEpoxyGlue_INTT", density = 3.2 * g / cm3, ncomponents = 2);
986  SilverEpoxyGlue_INTT->AddMaterial(Epoxy, fractionmass = 0.79);
987  SilverEpoxyGlue_INTT->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Ag"), fractionmass = 0.21);
988 
992 
993  const double den_CF4 = CF4->GetDensity() * .1;
994  const double den_G4_Ar = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ar")->GetDensity() * .8;
995  const double den_G4_CARBON_DIOXIDE = G4NistManager::Instance()->FindOrBuildMaterial("G4_CARBON_DIOXIDE")->GetDensity() * .1;
996  const double den = den_CF4 + den_G4_Ar + den_G4_CARBON_DIOXIDE;
997 
998  G4Material *ePHEINX_TPC_Gas = new G4Material("ePHEINX_TPC_Gas", den,
999  ncomponents = 3, kStateGas);
1000  ePHEINX_TPC_Gas->AddMaterial(CF4, den_CF4 / den);
1001  ePHEINX_TPC_Gas->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Ar"), den_G4_Ar / den);
1002  ePHEINX_TPC_Gas->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_CARBON_DIOXIDE"),
1003  den_G4_CARBON_DIOXIDE / den);
1004  // cross checked with original implementation made up of Ne,C,F
1005  // this here is very close but makes more sense since it uses Ne and CF4
1006  double G4_Ne_frac = 0.5;
1007  double CF4_frac = 0.5;
1008  const double den_G4_Ne = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ne")->GetDensity();
1009  const double den_CF4_2 = CF4->GetDensity();
1010  const double den_sphenix_tpc_gas = den_G4_Ne * G4_Ne_frac + den_CF4_2 * CF4_frac;
1011  G4Material *sPHENIX_tpc_gas = new G4Material("sPHENIX_TPC_Gas", den_sphenix_tpc_gas, ncomponents = 2, kStateGas);
1012  sPHENIX_tpc_gas->AddMaterial(CF4, den_CF4_2 * CF4_frac / den_sphenix_tpc_gas);
1013  sPHENIX_tpc_gas->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("G4_Ne"), den_G4_Ne * G4_Ne_frac / den_sphenix_tpc_gas);
1014 
1015  // LHCb aerogel
1016  // double density = 2.200 * g / cm3;
1017  G4Material *SiO2AerogelQuartz = new G4Material("ePHENIX_AerogelQuartz",
1018  2.200 * g / cm3, 2);
1019  SiO2AerogelQuartz->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), 1);
1020  SiO2AerogelQuartz->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), 2);
1021 
1022  G4Material *AerogTypeA = new G4Material("ePHENIX_AeroGel", 0.200 * g / cm3, 1);
1023  AerogTypeA->AddMaterial(G4NistManager::Instance()->FindOrBuildMaterial("ePHENIX_AerogelQuartz"),
1024  100.0 * perCent);
1025 
1026  //
1027  // CF4
1028  //
1029  const G4int nEntries_CF4 = 50;
1030 
1031  G4double PhotonEnergy_CF4[nEntries_CF4] =
1032  {5.5 * eV, 5.6 * eV, 5.7 * eV, 5.8 * eV, 5.9 * eV,
1033  6.0 * eV, 6.1 * eV, 6.2 * eV, 6.3 * eV, 6.4 * eV,
1034  6.5 * eV, 6.6 * eV, 6.7 * eV, 6.8 * eV, 6.9 * eV,
1035  7.0 * eV, 7.1 * eV, 7.2 * eV, 7.3 * eV, 7.4 * eV,
1036  7.5 * eV, 7.6 * eV, 7.7 * eV, 7.8 * eV, 7.9 * eV,
1037  8.0 * eV, 8.1 * eV, 8.2 * eV, 8.4 * eV, 8.6 * eV,
1038  8.8 * eV, 9.0 * eV, 9.2 * eV, 9.4 * eV, 9.6 * eV,
1039  9.8 * eV, 10.0 * eV, 10.2 * eV, 10.4 * eV, 10.6 * eV,
1040  10.8 * eV, 11.0 * eV, 11.2 * eV, 11.3 * eV, 11.4 * eV,
1041  11.5 * eV, 11.6 * eV, 11.7 * eV, 11.8 * eV, 11.9 * eV};
1042 
1043  G4double RefractiveIndex_CF4[nEntries_CF4] =
1044  {1.000480, 1.000482, 1.000483, 1.000485, 1.000486,
1045  1.000488, 1.000490, 1.000491, 1.000493, 1.000495,
1046  1.000497, 1.000498, 1.000500, 1.000502, 1.000504,
1047  1.000506, 1.000508, 1.000510, 1.000512, 1.000514,
1048  1.000517, 1.000519, 1.000521, 1.000524, 1.000526,
1049  1.000529, 1.000531, 1.000534, 1.000539, 1.000545,
1050  1.000550, 1.000557, 1.000563, 1.000570, 1.000577,
1051  1.000584, 1.000592, 1.000600, 1.000608, 1.000617,
1052  1.000626, 1.000636, 1.000646, 1.000652, 1.000657,
1053  1.000662, 1.000667, 1.000672, 1.000677, 1.000682};
1054 
1055  G4double Absorption_CF4[nEntries_CF4] =
1056  {1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1057  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1058  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1059  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1060  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1061  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1062  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1063  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1064  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1065  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m};
1066 
1067  G4MaterialPropertiesTable *MPT_CF4 = new G4MaterialPropertiesTable();
1068 
1069  MPT_CF4->AddProperty("RINDEX", PhotonEnergy_CF4, RefractiveIndex_CF4, nEntries_CF4)
1070  ->SetSpline(true);
1071  MPT_CF4->AddProperty("ABSLENGTH", PhotonEnergy_CF4, Absorption_CF4, nEntries_CF4)
1072  ->SetSpline(true);
1073 
1074  CF4->SetMaterialPropertiesTable(MPT_CF4);
1075 
1076  //
1077  // LiF
1078  //
1079  G4Material *g4_lif = G4NistManager::Instance()->FindOrBuildMaterial("G4_LITHIUM_FLUORIDE");
1080  G4Material *LiF = new G4Material("LiF", density = 2.635 * g / cm3, ncomponents = 2);
1081  LiF->AddElement(G4NistManager::Instance()->FindOrBuildElement("Li"), natoms = 1);
1082  LiF->AddElement(G4NistManager::Instance()->FindOrBuildElement("F"), natoms = 1);
1083 
1084  if (Verbosity() > 1)
1085  {
1086  cout << "g4_lif: " << g4_lif << endl;
1087  cout << "LiF: " << LiF << endl;
1088  }
1089 
1090  const G4int nEntries_LiF = 50;
1091 
1092  G4double PhotonEnergy_LiF[nEntries_LiF] =
1093  {5.5 * eV, 5.6 * eV, 5.7 * eV, 5.8 * eV, 5.9 * eV,
1094  6.0 * eV, 6.1 * eV, 6.2 * eV, 6.3 * eV, 6.4 * eV,
1095  6.5 * eV, 6.6 * eV, 6.7 * eV, 6.8 * eV, 6.9 * eV,
1096  7.0 * eV, 7.1 * eV, 7.2 * eV, 7.3 * eV, 7.4 * eV,
1097  7.5 * eV, 7.6 * eV, 7.7 * eV, 7.8 * eV, 7.9 * eV,
1098  8.0 * eV, 8.1 * eV, 8.2 * eV, 8.4 * eV, 8.6 * eV,
1099  8.8 * eV, 9.0 * eV, 9.2 * eV, 9.4 * eV, 9.6 * eV,
1100  9.8 * eV, 10.0 * eV, 10.2 * eV, 10.4 * eV, 10.6 * eV,
1101  10.8 * eV, 11.0 * eV, 11.2 * eV, 11.3 * eV, 11.4 * eV,
1102  11.5 * eV, 11.6 * eV, 11.7 * eV, 11.8 * eV, 11.9 * eV};
1103 
1104  G4double RefractiveIndex_LiF[nEntries_LiF] =
1105  {1.42709, 1.42870, 1.42998, 1.43177, 1.43368,
1106  1.43520, 1.43736, 1.43907, 1.44088, 1.44279,
1107  1.44481, 1.44694, 1.44920, 1.45161, 1.45329,
1108  1.45595, 1.45781, 1.46077, 1.46285, 1.46503,
1109  1.46849, 1.47093, 1.47349, 1.47618, 1.47901,
1110  1.48198, 1.48511, 1.48841, 1.49372, 1.50152,
1111  1.50799, 1.51509, 1.52290, 1.53152, 1.54108,
1112  1.54805, 1.55954, 1.56799, 1.58202, 1.59243,
1113  1.60382, 1.61632, 1.63010, 1.63753, 1.64536,
1114  1.65363, 1.66236, 1.67159, 1.68139, 1.69178};
1115 
1116  G4double Absorption_LiF[nEntries_LiF] =
1117  {1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1118  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1119  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1120  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1121  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1122  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1123  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1124  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1125  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m,
1126  1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m, 1.e4 * m};
1127 
1128  G4MaterialPropertiesTable *MPT_LiF = new G4MaterialPropertiesTable();
1129 
1130  MPT_LiF->AddProperty("RINDEX", PhotonEnergy_LiF, RefractiveIndex_LiF, nEntries_LiF)
1131  ->SetSpline(true);
1132  MPT_LiF->AddProperty("ABSLENGTH", PhotonEnergy_LiF, Absorption_LiF, nEntries_LiF)
1133  ->SetSpline(true);
1134 
1135  LiF->SetMaterialPropertiesTable(MPT_LiF);
1136 
1137  //
1138  // CsI
1139  //
1140  const G4int nEntries_CsI = 50;
1141 
1142  G4double PhotonEnergy_CsI[nEntries_CsI] =
1143  {5.5 * eV, 5.6 * eV, 5.7 * eV, 5.8 * eV, 5.9 * eV,
1144  6.0 * eV, 6.1 * eV, 6.2 * eV, 6.3 * eV, 6.4 * eV,
1145  6.5 * eV, 6.6 * eV, 6.7 * eV, 6.8 * eV, 6.9 * eV,
1146  7.0 * eV, 7.1 * eV, 7.2 * eV, 7.3 * eV, 7.4 * eV,
1147  7.5 * eV, 7.6 * eV, 7.7 * eV, 7.8 * eV, 7.9 * eV,
1148  8.0 * eV, 8.1 * eV, 8.2 * eV, 8.4 * eV, 8.6 * eV,
1149  8.8 * eV, 9.0 * eV, 9.2 * eV, 9.4 * eV, 9.6 * eV,
1150  9.8 * eV, 10.0 * eV, 10.2 * eV, 10.4 * eV, 10.6 * eV,
1151  10.8 * eV, 11.0 * eV, 11.2 * eV, 11.3 * eV, 11.4 * eV,
1152  11.5 * eV, 11.6 * eV, 11.7 * eV, 11.8 * eV, 11.9 * eV};
1153 
1154  G4double RefractiveIndex_CsI[nEntries_CsI] =
1155  {1., 1., 1., 1., 1.,
1156  1., 1., 1., 1., 1.,
1157  1., 1., 1., 1., 1.,
1158  1., 1., 1., 1., 1.,
1159  1., 1., 1., 1., 1.,
1160  1., 1., 1., 1., 1.,
1161  1., 1., 1., 1., 1.,
1162  1., 1., 1., 1., 1.,
1163  1., 1., 1., 1., 1.,
1164  1., 1., 1., 1., 1.};
1165 
1166  G4double Absorption_CsI[nEntries_CsI] =
1167  {0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1168  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1169  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1170  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1171  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1172  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1173  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1174  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1175  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m,
1176  0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m, 0.0000001 * m};
1177 
1178  G4MaterialPropertiesTable *MPT_CsI = new G4MaterialPropertiesTable();
1179 
1180  MPT_CsI->AddProperty("RINDEX", PhotonEnergy_CsI, RefractiveIndex_CsI, nEntries_CsI)->SetSpline(true);
1181  MPT_CsI->AddProperty("ABSLENGTH", PhotonEnergy_CsI, Absorption_CsI, nEntries_CsI)->SetSpline(true);
1182 
1183  CsI->SetMaterialPropertiesTable(MPT_CsI);
1184 
1185  // define P10 Gas which will be used for TPC Benchmarking
1186  G4Material *P10 =
1187  new G4Material("P10", density = 1.74 * mg / cm3, ncomponents = 3); // @ 0K, 1atm
1188  P10->AddElement(G4NistManager::Instance()->FindOrBuildElement("Ar"), fractionmass = 0.9222);
1189  P10->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), fractionmass = 0.0623);
1190  P10->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), fractionmass = 0.0155);
1191 
1192  //------------------------------
1193  // for Modular RICH (mRICH)
1194  //------------------------------
1195 
1196  // mRICH_Air_Opt ---------------
1197  const int mRICH_nEntries_Air_Opt = 2;
1198 
1199  G4double mRICH_PhotonEnergy_Air_Opt[mRICH_nEntries_Air_Opt] = {2.034 * eV, 4.136 * eV};
1200  G4double mRICH_RefractiveIndex_Air_Opt[mRICH_nEntries_Air_Opt] = {1.00, 1.00};
1201 
1202  G4MaterialPropertiesTable *mRICH_Air_Opt_MPT = new G4MaterialPropertiesTable();
1203  mRICH_Air_Opt_MPT->AddProperty("RINDEX", mRICH_PhotonEnergy_Air_Opt, mRICH_RefractiveIndex_Air_Opt, mRICH_nEntries_Air_Opt);
1204 
1205  G4Material *mRICH_Air_Opt = new G4Material("mRICH_Air_Opt", density = 1.29 * mg / cm3, ncomponents = 2);
1206  mRICH_Air_Opt->AddElement(G4NistManager::Instance()->FindOrBuildElement("N"), fractionmass = 70. * perCent);
1207  mRICH_Air_Opt->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), fractionmass = 30. * perCent);
1208  mRICH_Air_Opt->SetMaterialPropertiesTable(mRICH_Air_Opt_MPT);
1209 
1210  // mRICH_Acrylic ---------------
1211  const int mRICH_nEntries1 = 32;
1212 
1213  //same photon energy array as aerogel 1
1214  G4double mRICH_PhotonEnergy[mRICH_nEntries1] =
1215  {2.034 * eV, 2.068 * eV, 2.103 * eV, 2.139 * eV, // 610, 600, 590, 580, (nm)
1216  2.177 * eV, 2.216 * eV, 2.256 * eV, 2.298 * eV, // 570, 560, 550, 540,
1217  2.341 * eV, 2.386 * eV, 2.433 * eV, 2.481 * eV, // 530, 520, 510, 500,
1218  2.532 * eV, 2.585 * eV, 2.640 * eV, 2.697 * eV, // 490, 480, 470, 460,
1219  2.757 * eV, 2.820 * eV, 2.885 * eV, 2.954 * eV, // 450, 440, 430, 420,
1220  3.026 * eV, 3.102 * eV, 3.181 * eV, 3.265 * eV, // 410, 400, 390, 380,
1221  3.353 * eV, 3.446 * eV, 3.545 * eV, 3.649 * eV, // 370, 360, 350, 340,
1222  3.760 * eV, 3.877 * eV, 4.002 * eV, 4.136 * eV}; // 330, 320, 310, 300.
1223 
1224  G4double mRICH_AcRefractiveIndex[mRICH_nEntries1] =
1225  {1.4902, 1.4907, 1.4913, 1.4918, 1.4924, // 610, 600, 590, 580, 570,
1226  1.4930, 1.4936, 1.4942, 1.4948, 1.4954, // 560, 550, 540, 530, 520, (this line is interpolated)
1227  1.4960, 1.4965, 1.4971, 1.4977, 1.4983, // 510, 500, 490, 480, 470,
1228  1.4991, 1.5002, 1.5017, 1.5017, 1.5017, // 460, 450, 440, 430, 420,
1229  1.5017, 1.5017, 1.5017, 1.5017, 1.5017, // 410,
1230  1.5017, 1.5017, 1.5017, 1.5017, 1.5017, // 360, look up values below 435
1231  1.5017, 1.5017};
1232 
1233  G4double mRICH_AcAbsorption[mRICH_nEntries1] =
1234  {25.25 * cm, 25.25 * cm, 25.25 * cm, 25.25 * cm,
1235  25.25 * cm, 25.25 * cm, 25.25 * cm, 25.25 * cm,
1236  25.25 * cm, 25.25 * cm, 25.25 * cm, 25.25 * cm,
1237  25.25 * cm, 25.25 * cm, 25.25 * cm, 25.25 * cm,
1238  25.25 * cm, 25.25 * cm, 25.25 * cm, 25.25 * cm,
1239  25.25 * cm, 00.667 * cm, 00.037 * cm, 00.333 * cm,
1240  00.001 * cm, 00.001 * cm, 00.001 * cm, 00.001 * cm,
1241  00.001 * cm, 00.001 * cm, 00.001 * cm, 00.001 * cm};
1242 
1243  G4MaterialPropertiesTable *mRICH_Ac_myMPT = new G4MaterialPropertiesTable();
1244  mRICH_Ac_myMPT->AddProperty("RINDEX", mRICH_PhotonEnergy, mRICH_AcRefractiveIndex, mRICH_nEntries1);
1245  mRICH_Ac_myMPT->AddProperty("ABSLENGTH", mRICH_PhotonEnergy, mRICH_AcAbsorption, mRICH_nEntries1);
1246 
1247  G4Material *mRICH_Acrylic = new G4Material("mRICH_Acrylic", density = 1.19 * g / cm3, ncomponents = 3);
1248  mRICH_Acrylic->AddElement(G4NistManager::Instance()->FindOrBuildElement("C"), natoms = 5);
1249  mRICH_Acrylic->AddElement(G4NistManager::Instance()->FindOrBuildElement("H"), natoms = 8); // molecular ratios
1250  mRICH_Acrylic->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 2);
1251  mRICH_Acrylic->SetMaterialPropertiesTable(mRICH_Ac_myMPT);
1252 
1253  // mRICH_Agel1 -----------------
1254  // using same photon energy array as mRICH_Acrylic
1255 
1256  G4double mRICH_Agel1RefractiveIndex[mRICH_nEntries1] =
1257  {1.02435, 1.0244, 1.02445, 1.0245, 1.02455,
1258  1.0246, 1.02465, 1.0247, 1.02475, 1.0248,
1259  1.02485, 1.02492, 1.025, 1.02505, 1.0251,
1260  1.02518, 1.02522, 1.02530, 1.02535, 1.0254,
1261  1.02545, 1.0255, 1.02555, 1.0256, 1.02568,
1262  1.02572, 1.0258, 1.02585, 1.0259, 1.02595,
1263  1.026, 1.02608};
1264 
1265  G4double mRICH_Agel1Absorption[mRICH_nEntries1] = //from Hubert
1266  {3.448 * m, 4.082 * m, 6.329 * m, 9.174 * m, 12.346 * m, 13.889 * m,
1267  15.152 * m, 17.241 * m, 18.868 * m, 20.000 * m, 26.316 * m, 35.714 * m,
1268  45.455 * m, 47.619 * m, 52.632 * m, 52.632 * m, 55.556 * m, 52.632 * m,
1269  52.632 * m, 47.619 * m, 45.455 * m, 41.667 * m, 37.037 * m, 33.333 * m,
1270  30.000 * m, 28.500 * m, 27.000 * m, 24.500 * m, 22.000 * m, 19.500 * m,
1271  17.500 * m, 14.500 * m};
1272 
1273  G4double mRICH_Agel1Rayleigh[mRICH_nEntries1];
1274  //const G4double AerogelTypeAClarity = 0.00719*micrometer*micrometer*micrometer*micrometer/cm;
1275  const G4double AerogelTypeAClarity = 0.0020 * micrometer * micrometer * micrometer * micrometer / cm;
1276  G4double Cparam = AerogelTypeAClarity * cm / (micrometer * micrometer * micrometer * micrometer);
1277  G4double PhotMomWaveConv = 1239 * eV * nm;
1278 
1279  if (Cparam != 0.0)
1280  {
1281  for (int i = 0; i < mRICH_nEntries1; i++)
1282  {
1283  G4double ephoton = mRICH_PhotonEnergy[i];
1284  //In the following the 1000 is to convert form nm to micrometer
1285  G4double wphoton = (PhotMomWaveConv / ephoton) / (1000.0 * nm);
1286  mRICH_Agel1Rayleigh[i] = (std::pow(wphoton, 4)) / Cparam;
1287  }
1288  }
1289 
1290  G4MaterialPropertiesTable *mRICH_Agel1_myMPT = new G4MaterialPropertiesTable();
1291  mRICH_Agel1_myMPT->AddProperty("RINDEX", mRICH_PhotonEnergy, mRICH_Agel1RefractiveIndex, mRICH_nEntries1);
1292  mRICH_Agel1_myMPT->AddProperty("ABSLENGTH", mRICH_PhotonEnergy, mRICH_Agel1Absorption, mRICH_nEntries1);
1293  mRICH_Agel1_myMPT->AddProperty("RAYLEIGH", mRICH_PhotonEnergy, mRICH_Agel1Rayleigh, mRICH_nEntries1); //Need table of rayleigh Scattering!!!
1294  mRICH_Agel1_myMPT->AddConstProperty("SCINTILLATIONYIELD", 0. / MeV);
1295  mRICH_Agel1_myMPT->AddConstProperty("RESOLUTIONSCALE", 1.0);
1296 
1297  G4Material *mRICH_Aerogel1 = new G4Material("mRICH_Aerogel1", density = 0.02 * g / cm3, ncomponents = 2);
1298  mRICH_Aerogel1->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), natoms = 1);
1299  mRICH_Aerogel1->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 2);
1300  mRICH_Aerogel1->SetMaterialPropertiesTable(mRICH_Agel1_myMPT);
1301 
1302  // mRICH_Agel2 -----------------
1303  const int mRICH_nEntries2 = 50;
1304 
1305  G4double mRICH_Agel2PhotonEnergy[mRICH_nEntries2] =
1306  {1.87855 * eV, 1.96673 * eV, 2.05490 * eV, 2.14308 * eV, 2.23126 * eV,
1307  2.31943 * eV, 2.40761 * eV, 2.49579 * eV, 2.58396 * eV, 2.67214 * eV,
1308  2.76032 * eV, 2.84849 * eV, 2.93667 * eV, 3.02485 * eV, 3.11302 * eV,
1309  3.20120 * eV, 3.28938 * eV, 3.37755 * eV, 3.46573 * eV, 3.55391 * eV,
1310  3.64208 * eV, 3.73026 * eV, 3.81844 * eV, 3.90661 * eV, 3.99479 * eV,
1311  4.08297 * eV, 4.17114 * eV, 4.25932 * eV, 4.34750 * eV, 4.43567 * eV,
1312  4.52385 * eV, 4.61203 * eV, 4.70020 * eV, 4.78838 * eV, 4.87656 * eV,
1313  4.96473 * eV, 5.05291 * eV, 5.14109 * eV, 5.22927 * eV, 5.31744 * eV,
1314  5.40562 * eV, 5.49380 * eV, 5.58197 * eV, 5.67015 * eV, 5.75833 * eV,
1315  5.84650 * eV, 5.93468 * eV, 6.02286 * eV, 6.11103 * eV, 6.19921 * eV};
1316 
1317  G4double mRICH_Agel2RefractiveIndex[mRICH_nEntries2] =
1318  {1.02825, 1.02829, 1.02834, 1.02839, 1.02844,
1319  1.02849, 1.02854, 1.02860, 1.02866, 1.02872,
1320  1.02878, 1.02885, 1.02892, 1.02899, 1.02906,
1321  1.02914, 1.02921, 1.02929, 1.02938, 1.02946,
1322  1.02955, 1.02964, 1.02974, 1.02983, 1.02993,
1323  1.03003, 1.03014, 1.03025, 1.03036, 1.03047,
1324  1.03059, 1.03071, 1.03084, 1.03096, 1.03109,
1325  1.03123, 1.03137, 1.03151, 1.03166, 1.03181,
1326  1.03196, 1.03212, 1.03228, 1.03244, 1.03261,
1327  1.03279, 1.03297, 1.03315, 1.03334, 1.03354};
1328 
1329  G4double mRICH_Agel2Absorption[mRICH_nEntries2] = //from Marco
1330  {17.5000 * cm, 17.7466 * cm, 17.9720 * cm, 18.1789 * cm, 18.3694 * cm,
1331  18.5455 * cm, 18.7086 * cm, 18.8602 * cm, 19.0015 * cm, 19.1334 * cm,
1332  19.2569 * cm, 19.3728 * cm, 19.4817 * cm, 19.5843 * cm, 19.6810 * cm,
1333  19.7725 * cm, 19.8590 * cm, 19.9410 * cm, 20.0188 * cm, 20.0928 * cm,
1334  18.4895 * cm, 16.0174 * cm, 13.9223 * cm, 12.1401 * cm, 10.6185 * cm,
1335  9.3147 * cm, 8.1940 * cm, 7.2274 * cm, 6.3913 * cm, 5.6659 * cm,
1336  5.0347 * cm, 4.4841 * cm, 4.0024 * cm, 3.5801 * cm, 3.2088 * cm,
1337  2.8817 * cm, 2.5928 * cm, 2.3372 * cm, 2.1105 * cm, 1.9090 * cm,
1338  1.7296 * cm, 1.5696 * cm, 1.4266 * cm, 1.2986 * cm, 1.1837 * cm,
1339  1.0806 * cm, 0.9877 * cm, 0.9041 * cm, 0.8286 * cm, 0.7603 * cm};
1340 
1341  G4double mRICH_Agel2Rayleigh[mRICH_nEntries2] = //from Marco
1342  {35.1384 * cm, 29.24805 * cm, 24.5418 * cm, 20.7453 * cm, 17.6553 * cm,
1343  15.1197 * cm, 13.02345 * cm, 11.2782 * cm, 9.81585 * cm, 8.58285 * cm,
1344  7.53765 * cm, 6.6468 * cm, 5.88375 * cm, 5.22705 * cm, 4.6596 * cm,
1345  4.167 * cm, 3.73785 * cm, 3.36255 * cm, 3.03315 * cm, 2.7432 * cm,
1346  2.487 * cm, 2.26005 * cm, 2.05845 * cm, 1.87875 * cm, 1.71825 * cm,
1347  1.57455 * cm, 1.44555 * cm, 1.3296 * cm, 1.2249 * cm, 1.1304 * cm,
1348  1.04475 * cm, 0.9672 * cm, 0.89655 * cm, 0.83235 * cm, 0.77385 * cm,
1349  0.7203 * cm, 0.67125 * cm, 0.6264 * cm, 0.58515 * cm, 0.54735 * cm,
1350  0.51255 * cm, 0.48045 * cm, 0.45075 * cm, 0.4233 * cm, 0.39795 * cm,
1351  0.37455 * cm, 0.3528 * cm, 0.33255 * cm, 0.3138 * cm, 0.29625 * cm};
1352 
1353  G4MaterialPropertiesTable *mRICH_Agel2MPT = new G4MaterialPropertiesTable();
1354  mRICH_Agel2MPT->AddProperty("RINDEX", mRICH_Agel2PhotonEnergy, mRICH_Agel2RefractiveIndex, mRICH_nEntries2);
1355  mRICH_Agel2MPT->AddProperty("ABSLENGTH", mRICH_Agel2PhotonEnergy, mRICH_Agel2Absorption, mRICH_nEntries2);
1356  mRICH_Agel2MPT->AddProperty("RAYLEIGH", mRICH_Agel2PhotonEnergy, mRICH_Agel2Rayleigh, mRICH_nEntries2);
1357  mRICH_Agel2MPT->AddConstProperty("SCINTILLATIONYIELD", 0. / MeV);
1358  mRICH_Agel2MPT->AddConstProperty("RESOLUTIONSCALE", 1.0);
1359 
1360  G4Material *mRICH_Aerogel2 = new G4Material("mRICH_Aerogel2", density = 0.02 * g / cm3, ncomponents = 2);
1361  mRICH_Aerogel2->AddElement(G4NistManager::Instance()->FindOrBuildElement("Si"), natoms = 1);
1362  mRICH_Aerogel2->AddElement(G4NistManager::Instance()->FindOrBuildElement("O"), natoms = 2);
1363  mRICH_Aerogel2->SetMaterialPropertiesTable(mRICH_Agel2MPT);
1364 
1365  // mRICH_Borosilicate ----------
1366  //using the same photon energy array as mRICH_Acrylic
1367 
1368  G4double mRICH_glassRefractiveIndex[mRICH_nEntries1] =
1369  {1.47, 1.47, 1.47, 1.47, 1.47,
1370  1.47, 1.47, 1.47, 1.47, 1.47,
1371  1.47, 1.47, 1.47, 1.47, 1.47,
1372  1.47, 1.47, 1.47, 1.47, 1.47,
1373  1.47, 1.47, 1.47, 1.47, 1.47,
1374  1.47, 1.47, 1.47, 1.47, 1.47,
1375  1.47, 1.47};
1376 
1377  G4double mRICH_glassAbsorption[mRICH_nEntries1] =
1378  {4.25 * cm, 4.25 * cm, 4.25 * cm, 4.25 * cm,
1379  4.25 * cm, 4.25 * cm, 4.25 * cm, 4.25 * cm,
1380  4.25 * cm, 4.25 * cm, 4.25 * cm, 4.25 * cm,
1381  4.25 * cm, 4.25 * cm, 4.25 * cm, 4.25 * cm,
1382  4.25 * cm, 4.25 * cm, 4.25 * cm, 4.25 * cm,
1383  4.25 * cm, 00.667 * cm, 00.037 * cm, 00.333 * cm,
1384  00.001 * cm, 00.001 * cm, 00.001 * cm, 00.001 * cm,
1385  00.001 * cm, 00.001 * cm, 00.001 * cm, 00.001 * cm};
1386 
1387  G4MaterialPropertiesTable *mRICH_glass_myMPT = new G4MaterialPropertiesTable();
1388  //same photon energy array as aerogel 1
1389  mRICH_glass_myMPT->AddProperty("RINDEX", mRICH_PhotonEnergy, mRICH_glassRefractiveIndex, mRICH_nEntries1);
1390  mRICH_glass_myMPT->AddProperty("ABSLENGTH", mRICH_PhotonEnergy, mRICH_glassAbsorption, mRICH_nEntries1);
1391 
1392  const G4Material *G4_Pyrex_Glass = G4NistManager::Instance()->FindOrBuildMaterial("G4_Pyrex_Glass");
1393  G4Material *mRICH_Borosilicate = new G4Material("mRICH_Borosilicate", G4_Pyrex_Glass->GetDensity(), G4_Pyrex_Glass, G4_Pyrex_Glass->GetState(), G4_Pyrex_Glass->GetTemperature(), G4_Pyrex_Glass->GetPressure());
1394  mRICH_Borosilicate->SetMaterialPropertiesTable(mRICH_glass_myMPT);
1395 
1396  // mRICH_Air ------------------
1397  //using same photon energy array as mRICH_Acrylic
1398 
1399  G4double mRICH_AirRefractiveIndex[mRICH_nEntries1] =
1400  {1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1401  1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1402  1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1403  1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1404  1.00, 1.00, 1.00, 1.00};
1405 
1406  G4MaterialPropertiesTable *mRICH_Air_myMPT = new G4MaterialPropertiesTable();
1407  mRICH_Air_myMPT->AddProperty("RINDEX", mRICH_PhotonEnergy, mRICH_AirRefractiveIndex, mRICH_nEntries1);
1408  const G4Material *G4_AIR = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
1409  G4Material *mRICH_Air = new G4Material("mRICH_Air", G4_AIR->GetDensity(), G4_AIR, G4_AIR->GetState(), G4_AIR->GetTemperature(), G4_AIR->GetPressure());
1410  mRICH_Air->SetMaterialPropertiesTable(mRICH_Air_myMPT);
1411 }
1412 
1414 {
1415  // the PAI model does not work anymore in G4 10.06
1416  // const G4RegionStore *theRegionStore = G4RegionStore::GetInstance();
1417  // G4ProductionCuts *gcuts = new G4ProductionCuts(*(theRegionStore->GetRegion("DefaultRegionForTheWorld")->GetProductionCuts()));
1418  // G4Region *tpcregion = new G4Region("REGION_TPCGAS");
1419  // tpcregion->SetProductionCuts(gcuts);
1420  // #if G4VERSION_NUMBER >= 1033
1421  // // Use this from the new G4 version 10.03 on
1422  // // was commented out, crashes in 10.06 I think
1423  // // add the PAI model to the TPCGAS region
1424  // // undocumented, painfully digged out with debugger by tracing what
1425  // // is done for command "/process/em/AddPAIRegion all TPCGAS PAI"
1426  // // G4EmParameters *g4emparams = G4EmParameters::Instance();
1427  // // g4emparams->AddPAIModel("all", "REGION_TPCGAS", "PAI");
1428  // #endif
1429  return;
1430 }
1431 
1432 PHG4Subsystem *
1434 {
1435  for (PHG4Subsystem *subsys: m_SubsystemList)
1436  {
1437  if (subsys->Name() == name)
1438  {
1439  if (Verbosity() > 0)
1440  {
1441  cout << "Found Subsystem " << name << endl;
1442  }
1443  return subsys;
1444  }
1445  }
1446  cout << "Could not find Subsystem " << name << endl;
1447  return nullptr;
1448 }
1449 
1450 void PHG4Reco::G4Verbosity(const int i)
1451 {
1452  if (m_RunManager)
1453  {
1454  m_RunManager->SetVerboseLevel(i);
1455  }
1456 }
1457 
1459 {
1460  if (!m_Detector)
1461  {
1462  return;
1463  }
1464  G4VPhysicalVolume *physworld = m_Detector->GetPhysicalVolume();
1465  m_DisplayAction->ApplyDisplayAction(physworld);
1466  for (PHG4Subsystem *g4sub: m_SubsystemList)
1467  {
1468  PHG4DisplayAction *action = g4sub->GetDisplayAction();
1469  if (action)
1470  {
1471  if (Verbosity() > 1)
1472  {
1473  cout << "Adding steppingaction for " << g4sub->Name() << endl;
1474  }
1475  action->ApplyDisplayAction(physworld);
1476  }
1477  }
1478 }