CMS 3D CMS Logo

ParametrisedEMPhysics.cc
Go to the documentation of this file.
1 //
2 // Joanna Weng 08.2005
3 // Physics process for Gflash parameterisation
4 // modified by Soon Yung Jun, Dongwook Jang
5 // V.Ivanchenko rename the class, cleanup, and move
6 // to SimG4Core/Application - 2012/08/14
7 
13 
14 #include "G4FastSimulationManagerProcess.hh"
15 #include "G4ProcessManager.hh"
16 
17 #include "G4LeptonConstructor.hh"
18 #include "G4MesonConstructor.hh"
19 #include "G4BaryonConstructor.hh"
20 #include "G4ShortLivedConstructor.hh"
21 #include "G4IonConstructor.hh"
22 #include "G4RegionStore.hh"
23 #include "G4Electron.hh"
24 #include "G4Positron.hh"
25 #include "G4MuonMinus.hh"
26 #include "G4MuonPlus.hh"
27 #include "G4PionMinus.hh"
28 #include "G4PionPlus.hh"
29 #include "G4KaonMinus.hh"
30 #include "G4KaonPlus.hh"
31 #include "G4Proton.hh"
32 #include "G4AntiProton.hh"
33 
34 #include "G4EmParameters.hh"
35 #include "G4PhysicsListHelper.hh"
36 #include "G4SystemOfUnits.hh"
37 #include "G4UAtomicDeexcitation.hh"
38 #include "G4LossTableManager.hh"
39 #include "G4ProcessManager.hh"
40 #include "G4Transportation.hh"
41 
43  std::unique_ptr<GFlashEMShowerModel> theEcalEMShowerModel;
44  std::unique_ptr<GFlashEMShowerModel> theHcalEMShowerModel;
45  std::unique_ptr<GFlashHadronShowerModel> theEcalHadShowerModel;
46  std::unique_ptr<GFlashHadronShowerModel> theHcalHadShowerModel;
47  std::unique_ptr<ElectronLimiter> theElectronLimiter;
48  std::unique_ptr<ElectronLimiter> thePositronLimiter;
49  std::unique_ptr<G4FastSimulationManagerProcess> theFastSimulationManagerProcess;
50 };
51 
53 
55  const edm::ParameterSet & p)
56  : G4VPhysicsConstructor(name), theParSet(p)
57 {
58  // bremsstrahlung threshold and EM verbosity
59  G4EmParameters* param = G4EmParameters::Instance();
60  G4int verb = theParSet.getUntrackedParameter<int>("Verbosity",0);
61  param->SetVerbose(verb);
62 
63  G4double bremth = theParSet.getParameter<double>("G4BremsstrahlungThreshold")*GeV;
64  param->SetBremsstrahlungTh(bremth);
65 
66  bool fluo = theParSet.getParameter<bool>("FlagFluo");
67  param->SetFluo(fluo);
68 
69  bool modifyT = theParSet.getParameter<bool>("ModifyTransportation");
70  double th1 = theParSet.getUntrackedParameter<double>("ThresholdWarningEnergy")*MeV;
71  double th2 = theParSet.getUntrackedParameter<double>("ThresholdImportantEnergy")*MeV;
72  int nt = theParSet.getUntrackedParameter<int>("ThresholdTrials");
73 
74  edm::LogVerbatim("SimG4CoreApplication")
75  << "ParametrisedEMPhysics::ConstructProcess: bremsstrahlung threshold Eth= "
76  << bremth/GeV << " GeV"
77  << "\n verbosity= " << verb
78  << " fluoFlag: " << fluo << " modifyTransport: " << modifyT
79  << " Ntrials= " << nt
80  << "\n ThWarning(MeV)= " << th1
81  << " ThException(MeV)= " << th2;
82 
83  // Russian roulette and tracking cut for e+-
84  double energyLim =
85  theParSet.getParameter<double>("RusRoElectronEnergyLimit")*MeV;
86  if(energyLim > 0.0) {
87  const G4int NREG = 6;
88  const G4String rname[NREG] = {"EcalRegion", "HcalRegion", "MuonIron",
89  "PreshowerRegion","CastorRegion",
90  "DefaultRegionForTheWorld"};
91  G4double rrfact[NREG] = { 1.0 };
92 
93  rrfact[0] = theParSet.getParameter<double>("RusRoEcalElectron");
94  rrfact[1] = theParSet.getParameter<double>("RusRoHcalElectron");
95  rrfact[2] = theParSet.getParameter<double>("RusRoMuonIronElectron");
96  rrfact[3] = theParSet.getParameter<double>("RusRoPreShowerElectron");
97  rrfact[4] = theParSet.getParameter<double>("RusRoCastorElectron");
98  rrfact[5] = theParSet.getParameter<double>("RusRoWorldElectron");
99  for(int i=0; i<NREG; ++i) {
100  if(rrfact[i] < 1.0) {
101  param->ActivateSecondaryBiasing("eIoni",rname[i],rrfact[i],energyLim);
102  param->ActivateSecondaryBiasing("hIoni",rname[i],rrfact[i],energyLim);
103  edm::LogVerbatim("SimG4CoreApplication")
104  << "ParametrisedEMPhysics: Russian Roulette"
105  << " for e- Prob= " << rrfact[i]
106  << " Elimit(MeV)= " << energyLim/CLHEP::MeV
107  << " inside " << rname[i];
108  }
109  }
110  }
111 }
112 
114  if(m_tpmod) {
115  delete m_tpmod;
116  m_tpmod = nullptr;
117  }
118 }
119 
121 {
122  G4LeptonConstructor pLeptonConstructor;
123  pLeptonConstructor.ConstructParticle();
124 
125  G4MesonConstructor pMesonConstructor;
126  pMesonConstructor.ConstructParticle();
127 
128  G4BaryonConstructor pBaryonConstructor;
129  pBaryonConstructor.ConstructParticle();
130 
131  G4ShortLivedConstructor pShortLivedConstructor;
132  pShortLivedConstructor.ConstructParticle();
133 
134  G4IonConstructor pConstructor;
135  pConstructor.ConstructParticle();
136 }
137 
139 
140  // GFlash part
141  bool gem = theParSet.getParameter<bool>("GflashEcal");
142  bool ghad = theParSet.getParameter<bool>("GflashHcal");
143  bool gemHad = theParSet.getParameter<bool>("GflashEcalHad");
144  bool ghadHad = theParSet.getParameter<bool>("GflashHcalHad");
145 
146  G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
147  if(gem || ghad || gemHad || ghadHad) {
148  if(!m_tpmod) { m_tpmod = new TLSmod; }
149  edm::LogVerbatim("SimG4CoreApplication")
150  << "ParametrisedEMPhysics: GFlash Construct for e+-: "
151  << gem << " " << ghad << " for hadrons: " << gemHad << " " << ghadHad;
152 
153  m_tpmod->theFastSimulationManagerProcess.reset(new G4FastSimulationManagerProcess());
154 
155  if(gem || ghad) {
156  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4Electron::Electron());
157  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4Positron::Positron());
158  }
159  if(gemHad || ghadHad) {
160  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4Proton::Proton());
161  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4AntiProton::AntiProton());
162  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4PionPlus::PionPlus());
163  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4PionMinus::PionMinus());
164  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4KaonPlus::KaonPlus());
165  ph->RegisterProcess(m_tpmod->theFastSimulationManagerProcess.get(), G4KaonMinus::KaonMinus());
166  }
167 
168  if(gem || gemHad) {
169  G4Region* aRegion =
170  G4RegionStore::GetInstance()->GetRegion("EcalRegion");
171 
172  if(!aRegion){
173  edm::LogVerbatim("SimG4CoreApplication")
174  << "ParametrisedEMPhysics::ConstructProcess: "
175  << "EcalRegion is not defined, GFlash will not be enabled for ECAL!";
176 
177  } else {
178  if(gem) {
179 
180  //Electromagnetic Shower Model for ECAL
181  m_tpmod->theEcalEMShowerModel.reset(new GFlashEMShowerModel("GflashEcalEMShowerModel",
182  aRegion,theParSet));
183  }
184  if(gemHad) {
185 
186  //Electromagnetic Shower Model for ECAL
187  m_tpmod->theEcalHadShowerModel.reset(new GFlashHadronShowerModel("GflashEcalHadShowerModel",
188  aRegion,theParSet));
189  }
190  }
191  }
192  if(ghad || ghadHad) {
193  G4Region* aRegion =
194  G4RegionStore::GetInstance()->GetRegion("HcalRegion");
195  if(!aRegion) {
196  edm::LogVerbatim("SimG4CoreApplication")
197  << "ParametrisedEMPhysics::ConstructProcess: "
198  << "HcalRegion is not defined, GFlash will not be enabled for HCAL!";
199 
200  } else {
201  if(ghad) {
202 
203  //Electromagnetic Shower Model for HCAL
204  m_tpmod->theHcalEMShowerModel.reset(new GFlashEMShowerModel("GflashHcalEMShowerModel",
205  aRegion,theParSet));
206  }
207  if(ghadHad) {
208 
209  //Electromagnetic Shower Model for ECAL
210  m_tpmod->theHcalHadShowerModel.reset(new GFlashHadronShowerModel("GflashHcalHadShowerModel",
211  aRegion,theParSet));
212  }
213  }
214  }
215  }
216 
217  // Step limiters for e+-
218  bool eLimiter = theParSet.getParameter<bool>("ElectronStepLimit");
219  bool rLimiter = theParSet.getParameter<bool>("ElectronRangeTest");
220  bool pLimiter = theParSet.getParameter<bool>("PositronStepLimit");
221 
222  if(eLimiter || rLimiter) {
223  if(!m_tpmod) { m_tpmod = new TLSmod; }
225  m_tpmod->theElectronLimiter.get()->SetRangeCheckFlag(rLimiter);
226  m_tpmod->theElectronLimiter.get()->SetFieldCheckFlag(eLimiter);
227  ph->RegisterProcess(m_tpmod->theElectronLimiter.get(), G4Electron::Electron());
228  }
229 
230  if(pLimiter){
231  if(!m_tpmod) { m_tpmod = new TLSmod; }
233  m_tpmod->thePositronLimiter.get()->SetFieldCheckFlag(pLimiter);
234  ph->RegisterProcess(m_tpmod->theElectronLimiter.get(), G4Positron::Positron());
235  }
236  // enable fluorescence
237  bool fluo = theParSet.getParameter<bool>("FlagFluo");
238  if(fluo && !G4LossTableManager::Instance()->AtomDeexcitation()) {
239  G4VAtomDeexcitation* de = new G4UAtomicDeexcitation();
240  G4LossTableManager::Instance()->SetAtomDeexcitation(de);
241  }
242  // change parameters of transportation
243  bool modifyT = theParSet.getParameter<bool>("ModifyTransportation");
244  if(modifyT) {
245  double th1 = theParSet.getUntrackedParameter<double>("ThresholdWarningEnergy")*MeV;
246  double th2 = theParSet.getUntrackedParameter<double>("ThresholdImportantEnergy")*MeV;
247  int nt = theParSet.getUntrackedParameter<int>("ThresholdTrials");
249  ModifyTransportation(G4Positron::Positron(), nt, th1, th2);
250  ModifyTransportation(G4Proton::Proton(), nt, th1, th2);
251  }
252 }
253 
254 void ParametrisedEMPhysics::ModifyTransportation(const G4ParticleDefinition* part,
255  int ntry, double th1, double th2)
256 {
257  G4ProcessManager* man = part->GetProcessManager();
258  G4Transportation* trans = (G4Transportation*)((*(man->GetProcessList()))[0]);
259  if(trans) {
260  trans->SetThresholdWarningEnergy(th1);
261  trans->SetThresholdImportantEnergy(th2);
262  trans->SetThresholdTrials(ntry);
263  edm::LogVerbatim("SimG4CoreApplication")
264  << "ParametrisedEMPhysics: printout level changed for " << part->GetParticleName();
265 
266  }
267 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const double GeV
Definition: MathUtil.h:16
edm::ParameterSet theParSet
static G4ThreadLocal TLSmod * m_tpmod
void ModifyTransportation(const G4ParticleDefinition *, int ntry, double th1, double th2)
std::unique_ptr< ElectronLimiter > thePositronLimiter
Definition: AMC13Event.h:6
const double MeV
std::unique_ptr< G4FastSimulationManagerProcess > theFastSimulationManagerProcess
std::unique_ptr< GFlashEMShowerModel > theEcalEMShowerModel
int nt
Definition: AMPTWrapper.h:32
std::unique_ptr< GFlashEMShowerModel > theHcalEMShowerModel
std::unique_ptr< GFlashHadronShowerModel > theHcalHadShowerModel
part
Definition: HCALResponse.h:20
ParametrisedEMPhysics(const std::string &name, const edm::ParameterSet &p)
std::unique_ptr< GFlashHadronShowerModel > theEcalHadShowerModel
std::unique_ptr< ElectronLimiter > theElectronLimiter