File indexing completed on 2024-04-06 12:30:24
0001 #include "SimG4Core/GFlash/interface/ParametrisedPhysics.h"
0002 #include "SimG4Core/PhysicsLists/interface/EmParticleList.h"
0003
0004 #include "G4Electron.hh"
0005 #include "G4ProcessManager.hh"
0006
0007 #include "G4BaryonConstructor.hh"
0008 #include "G4IonConstructor.hh"
0009 #include "G4LeptonConstructor.hh"
0010 #include "G4MesonConstructor.hh"
0011 #include "G4RegionStore.hh"
0012 #include "G4ShortLivedConstructor.hh"
0013
0014 G4ThreadLocal ParametrisedPhysics::ThreadPrivate *ParametrisedPhysics::tpdata = nullptr;
0015
0016 ParametrisedPhysics::ParametrisedPhysics(std::string name, const edm::ParameterSet &p)
0017 : G4VPhysicsConstructor(name), theParSet(p) {}
0018
0019 ParametrisedPhysics::~ParametrisedPhysics() {
0020 if (nullptr != tpdata) {
0021 delete tpdata->theEMShowerModel;
0022 delete tpdata->theHadShowerModel;
0023 delete tpdata->theHadronShowerModel;
0024 delete tpdata->theFastSimulationManagerProcess;
0025 tpdata = nullptr;
0026 }
0027 }
0028
0029 void ParametrisedPhysics::ConstructParticle() {
0030 G4LeptonConstructor pLeptonConstructor;
0031 pLeptonConstructor.ConstructParticle();
0032
0033 G4MesonConstructor pMesonConstructor;
0034 pMesonConstructor.ConstructParticle();
0035
0036 G4BaryonConstructor pBaryonConstructor;
0037 pBaryonConstructor.ConstructParticle();
0038
0039 G4ShortLivedConstructor pShortLivedConstructor;
0040 pShortLivedConstructor.ConstructParticle();
0041
0042 G4IonConstructor pConstructor;
0043 pConstructor.ConstructParticle();
0044 }
0045
0046 void ParametrisedPhysics::ConstructProcess() {
0047 tpdata = new ThreadPrivate;
0048 tpdata->theEMShowerModel = nullptr;
0049 tpdata->theHadShowerModel = nullptr;
0050 tpdata->theHadronShowerModel = nullptr;
0051 tpdata->theFastSimulationManagerProcess = nullptr;
0052
0053 bool gem = theParSet.getParameter<bool>("GflashEcal");
0054 bool ghad = theParSet.getParameter<bool>("GflashHcal");
0055 G4cout << "GFlash Construct: " << gem << " " << ghad << G4endl;
0056
0057 if (gem || ghad) {
0058 tpdata->theFastSimulationManagerProcess = new G4FastSimulationManagerProcess();
0059
0060 G4ParticleTable *table = G4ParticleTable::GetParticleTable();
0061 EmParticleList emList;
0062 for (const auto &particleName : emList.PartNames()) {
0063 G4ParticleDefinition *particle = table->FindParticle(particleName);
0064 G4ProcessManager *pmanager = particle->GetProcessManager();
0065 const G4String &pname = particle->GetParticleName();
0066 if (pname == "e-" || pname == "e+") {
0067 pmanager->AddDiscreteProcess(tpdata->theFastSimulationManagerProcess);
0068 }
0069 }
0070
0071 if (gem) {
0072 G4Region *aRegion = G4RegionStore::GetInstance()->GetRegion("EcalRegion");
0073
0074 if (!aRegion) {
0075 G4cout << "EcalRegion is not defined !!!" << G4endl;
0076 G4cout << "This means that GFlash will not be turned on." << G4endl;
0077
0078 } else {
0079
0080 tpdata->theEMShowerModel = new GflashEMShowerModel("GflashEMShowerModel", aRegion, theParSet);
0081 G4cout << "GFlash is defined for EcalRegion" << G4endl;
0082 }
0083 }
0084 if (ghad) {
0085 G4Region *aRegion = G4RegionStore::GetInstance()->GetRegion("HcalRegion");
0086 if (!aRegion) {
0087 G4cout << "HcalRegion is not defined !!!" << G4endl;
0088 G4cout << "This means that GFlash will not be turned on." << G4endl;
0089
0090 } else {
0091
0092 tpdata->theHadShowerModel = new GflashEMShowerModel("GflashHadShowerModel", aRegion, theParSet);
0093 G4cout << "GFlash is defined for HcalRegion" << G4endl;
0094 }
0095 }
0096 }
0097 }