CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ParametrisedPhysics.cc
Go to the documentation of this file.
3 
4 #include "G4Electron.hh"
5 #include "G4ProcessManager.hh"
6 
7 #include "G4BaryonConstructor.hh"
8 #include "G4IonConstructor.hh"
9 #include "G4LeptonConstructor.hh"
10 #include "G4MesonConstructor.hh"
11 #include "G4RegionStore.hh"
12 #include "G4ShortLivedConstructor.hh"
13 
15 
17  : G4VPhysicsConstructor(name), theParSet(p) {}
18 
20  if (nullptr != tpdata) {
21  delete tpdata->theEMShowerModel;
22  delete tpdata->theHadShowerModel;
25  tpdata = nullptr;
26  }
27 }
28 
30  G4LeptonConstructor pLeptonConstructor;
31  pLeptonConstructor.ConstructParticle();
32 
33  G4MesonConstructor pMesonConstructor;
34  pMesonConstructor.ConstructParticle();
35 
36  G4BaryonConstructor pBaryonConstructor;
37  pBaryonConstructor.ConstructParticle();
38 
39  G4ShortLivedConstructor pShortLivedConstructor;
40  pShortLivedConstructor.ConstructParticle();
41 
42  G4IonConstructor pConstructor;
43  pConstructor.ConstructParticle();
44 }
45 
47  tpdata = new ThreadPrivate;
48  tpdata->theEMShowerModel = nullptr;
49  tpdata->theHadShowerModel = nullptr;
50  tpdata->theHadronShowerModel = nullptr;
52 
53  bool gem = theParSet.getParameter<bool>("GflashEcal");
54  bool ghad = theParSet.getParameter<bool>("GflashHcal");
55  G4cout << "GFlash Construct: " << gem << " " << ghad << G4endl;
56 
57  if (gem || ghad) {
58  tpdata->theFastSimulationManagerProcess = new G4FastSimulationManagerProcess();
59 
60  G4ParticleTable *table = G4ParticleTable::GetParticleTable();
61  EmParticleList emList;
62  for (const auto &particleName : emList.PartNames()) {
63  G4ParticleDefinition *particle = table->FindParticle(particleName);
64  G4ProcessManager *pmanager = particle->GetProcessManager();
65  const G4String &pname = particle->GetParticleName();
66  if (pname == "e-" || pname == "e+") {
67  pmanager->AddDiscreteProcess(tpdata->theFastSimulationManagerProcess);
68  }
69  }
70 
71  if (gem) {
72  G4Region *aRegion = G4RegionStore::GetInstance()->GetRegion("EcalRegion");
73 
74  if (!aRegion) {
75  G4cout << "EcalRegion is not defined !!!" << G4endl;
76  G4cout << "This means that GFlash will not be turned on." << G4endl;
77 
78  } else {
79  // Electromagnetic Shower Model for ECAL
80  tpdata->theEMShowerModel = new GflashEMShowerModel("GflashEMShowerModel", aRegion, theParSet);
81  G4cout << "GFlash is defined for EcalRegion" << G4endl;
82  }
83  }
84  if (ghad) {
85  G4Region *aRegion = G4RegionStore::GetInstance()->GetRegion("HcalRegion");
86  if (!aRegion) {
87  G4cout << "HcalRegion is not defined !!!" << G4endl;
88  G4cout << "This means that GFlash will not be turned on." << G4endl;
89 
90  } else {
91  // Electromagnetic Shower Model for HCAL
92  tpdata->theHadShowerModel = new GflashEMShowerModel("GflashHadShowerModel", aRegion, theParSet);
93  G4cout << "GFlash is defined for HcalRegion" << G4endl;
94  }
95  }
96  }
97 }
const std::vector< G4String > & PartNames() const
void ConstructParticle() override
void ConstructProcess() override
ParametrisedPhysics(std::string name, const edm::ParameterSet &p)
edm::ParameterSet theParSet
G4FastSimulationManagerProcess * theFastSimulationManagerProcess
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GflashHadronShowerModel * theHadronShowerModel
static G4ThreadLocal ThreadPrivate * tpdata