CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ParametrisedEMPhysics Class Reference

#include <ParametrisedEMPhysics.h>

Inheritance diagram for ParametrisedEMPhysics:

Classes

struct  TLSmod
 

Public Member Functions

void ConstructParticle () override
 
void ConstructProcess () override
 
 ParametrisedEMPhysics (const std::string &name, const edm::ParameterSet &p)
 
 ~ParametrisedEMPhysics () override
 

Private Member Functions

void ModifyTransportation (const G4ParticleDefinition *, int ntry, double th1, double th2)
 

Private Attributes

edm::ParameterSet theParSet
 

Static Private Attributes

static G4ThreadLocal TLSmodm_tpmod = nullptr
 

Detailed Description

Definition at line 16 of file ParametrisedEMPhysics.h.

Constructor & Destructor Documentation

◆ ParametrisedEMPhysics()

ParametrisedEMPhysics::ParametrisedEMPhysics ( const std::string &  name,
const edm::ParameterSet p 
)

Definition at line 63 of file ParametrisedEMPhysics.cc.

References EgammaValidation_cff::genp, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, NREG, nt, rname, and theParSet.

64  : G4VPhysicsConstructor(name), theParSet(p) {
65  G4EmParameters* param = G4EmParameters::Instance();
66  G4int verb = theParSet.getUntrackedParameter<int>("Verbosity", 0);
67  param->SetVerbose(verb);
68 
69  G4double bremth = theParSet.getParameter<double>("G4BremsstrahlungThreshold") * CLHEP::GeV;
70  param->SetBremsstrahlungTh(bremth);
71  G4double mubrth = theParSet.getParameter<double>("G4MuonBremsstrahlungThreshold") * CLHEP::GeV;
72  param->SetMuHadBremsstrahlungTh(mubrth);
73 
74  bool genp = theParSet.getParameter<bool>("G4GeneralProcess");
75  param->SetGeneralProcessActive(genp);
76 
77  bool mudat = theParSet.getParameter<bool>("ReadMuonData");
78  param->SetRetrieveMuDataFromFile(mudat);
79 
80  bool fluo = theParSet.getParameter<bool>("FlagFluo");
81  param->SetFluo(fluo);
82 
83  bool modifyT = theParSet.getParameter<bool>("ModifyTransportation");
84  double th1 = theParSet.getUntrackedParameter<double>("ThresholdWarningEnergy") * MeV;
85  double th2 = theParSet.getUntrackedParameter<double>("ThresholdImportantEnergy") * MeV;
86  int nt = theParSet.getUntrackedParameter<int>("ThresholdTrials");
87 
88  edm::LogVerbatim("SimG4CoreApplication")
89  << "ParametrisedEMPhysics::ConstructProcess: bremsstrahlung threshold Eth= " << bremth / GeV << " GeV"
90  << "\n verbosity= " << verb << " fluoFlag: " << fluo
91  << " modifyTransport: " << modifyT << " Ntrials= " << nt
92  << "\n ThWarning(MeV)= " << th1 << " ThException(MeV)= " << th2;
93 
94  // Russian roulette and tracking cut for e+-
95  double energyLim = theParSet.getParameter<double>("RusRoElectronEnergyLimit") * MeV;
96  if (energyLim > 0.0) {
97  G4double rrfact[NREG] = {1.0};
98 
99  rrfact[0] = theParSet.getParameter<double>("RusRoEcalElectron");
100  rrfact[1] = theParSet.getParameter<double>("RusRoHcalElectron");
101  rrfact[2] = theParSet.getParameter<double>("RusRoMuonIronElectron");
102  rrfact[3] = theParSet.getParameter<double>("RusRoPreShowerElectron");
103  rrfact[4] = theParSet.getParameter<double>("RusRoCastorElectron");
104  rrfact[5] = theParSet.getParameter<double>("RusRoWorldElectron");
105  for (int i = 0; i < NREG; ++i) {
106  if (rrfact[i] < 1.0) {
107  param->ActivateSecondaryBiasing("eIoni", rname[i], rrfact[i], energyLim);
108  param->ActivateSecondaryBiasing("hIoni", rname[i], rrfact[i], energyLim);
109  edm::LogVerbatim("SimG4CoreApplication")
110  << "ParametrisedEMPhysics: Russian Roulette"
111  << " for e- Prob= " << rrfact[i] << " Elimit(MeV)= " << energyLim / CLHEP::MeV << " inside " << rname[i];
112  }
113  }
114  }
115 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
genp
produce generated paricles in acceptance #
edm::ParameterSet theParSet
T getUntrackedParameter(std::string const &, T const &) const
int nt
Definition: AMPTWrapper.h:42
const G4String rname[NREG]
const G4int NREG

◆ ~ParametrisedEMPhysics()

ParametrisedEMPhysics::~ParametrisedEMPhysics ( )
override

Definition at line 117 of file ParametrisedEMPhysics.cc.

References m_tpmod.

117  {
118  delete m_tpmod;
119  m_tpmod = nullptr;
120 }
static G4ThreadLocal TLSmod * m_tpmod

Member Function Documentation

◆ ConstructParticle()

void ParametrisedEMPhysics::ConstructParticle ( )
override

Definition at line 122 of file ParametrisedEMPhysics.cc.

122  {
123  // minimal set of particles for EM physics
124  G4EmBuilder::ConstructMinimalEmSet();
125 }

◆ ConstructProcess()

void ParametrisedEMPhysics::ConstructProcess ( )
override

Definition at line 127 of file ParametrisedEMPhysics.cc.

References nanoDQM_cff::Electron, mixOne_premix_on_sim_cfi::gem, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, m_tpmod, ModifyTransportation(), nt, alignCSCRings::r, ElectronLimiter::SetFieldCheckFlag(), ElectronLimiter::SetRangeCheckFlag(), ElectronLimiter::SetTrackingCutPerRegion(), ParametrisedEMPhysics::TLSmod::theEcalEMShowerModel, ParametrisedEMPhysics::TLSmod::theEcalHadShowerModel, ParametrisedEMPhysics::TLSmod::theFastSimulationManagerProcess, ParametrisedEMPhysics::TLSmod::theHcalEMShowerModel, ParametrisedEMPhysics::TLSmod::theHcalHadShowerModel, ParametrisedEMPhysics::TLSmod::theLowEnergyFastSimModel, and theParSet.

127  {
128  edm::LogVerbatim("SimG4CoreApplication") << "ParametrisedEMPhysics::ConstructProcess() started";
129 
130  // GFlash part
131  bool gem = theParSet.getParameter<bool>("GflashEcal");
132  bool lowEnergyGem = theParSet.getParameter<bool>("LowEnergyGflashEcal");
133  bool ghad = theParSet.getParameter<bool>("GflashHcal");
134  bool gemHad = theParSet.getParameter<bool>("GflashEcalHad");
135  bool ghadHad = theParSet.getParameter<bool>("GflashHcalHad");
136 
137  if (gem || ghad || lowEnergyGem || gemHad || ghadHad) {
138  if (!m_tpmod) {
139  m_tpmod = new TLSmod;
140  }
141  edm::LogVerbatim("SimG4CoreApplication")
142  << "ParametrisedEMPhysics: GFlash Construct for e+-: " << gem << " " << ghad << " " << lowEnergyGem
143  << " for hadrons: " << gemHad << " " << ghadHad;
144 
145  m_tpmod->theFastSimulationManagerProcess = std::make_unique<G4FastSimulationManagerProcess>();
146 
147  if (gem || ghad) {
148  G4Electron::Electron()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
149  G4Positron::Positron()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
150  } else if (lowEnergyGem) {
151  G4Electron::Electron()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
152  G4Positron::Positron()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
153  }
154 
155  if (gemHad || ghadHad) {
156  G4Proton::Proton()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
157  G4AntiProton::AntiProton()->GetProcessManager()->AddDiscreteProcess(
159  G4PionPlus::PionPlus()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
160  G4PionMinus::PionMinus()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
161  G4KaonPlus::KaonPlus()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
162  G4KaonMinus::KaonMinus()->GetProcessManager()->AddDiscreteProcess(m_tpmod->theFastSimulationManagerProcess.get());
163  }
164 
165  if (gem || gemHad || lowEnergyGem) {
166  G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion("EcalRegion", false);
167 
168  if (!aRegion) {
169  edm::LogWarning("SimG4CoreApplication") << "ParametrisedEMPhysics::ConstructProcess: "
170  << "EcalRegion is not defined, GFlash will not be enabled for ECAL!";
171 
172  } else {
173  if (gem) {
174  //Electromagnetic Shower Model for ECAL
176  std::make_unique<GFlashEMShowerModel>("GflashEcalEMShowerModel", aRegion, theParSet);
177  } else if (lowEnergyGem) {
178  //Low energy electromagnetic Shower Model for ECAL
180  std::make_unique<LowEnergyFastSimModel>("LowEnergyFastSimModel", aRegion, theParSet);
181  }
182 
183  if (gemHad) {
184  //Electromagnetic Shower Model for ECAL
186  std::make_unique<GFlashHadronShowerModel>("GflashEcalHadShowerModel", aRegion, theParSet);
187  }
188  }
189  }
190  if (ghad || ghadHad) {
191  G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion("HcalRegion", false);
192  if (!aRegion) {
193  edm::LogWarning("SimG4CoreApplication") << "ParametrisedEMPhysics::ConstructProcess: "
194  << "HcalRegion is not defined, GFlash will not be enabled for HCAL!";
195 
196  } else {
197  if (ghad) {
198  //Electromagnetic Shower Model for HCAL
200  std::make_unique<GFlashEMShowerModel>("GflashHcalEMShowerModel", aRegion, theParSet);
201  }
202  if (ghadHad) {
203  //Electromagnetic Shower Model for ECAL
205  std::make_unique<GFlashHadronShowerModel>("GflashHcalHadShowerModel", aRegion, theParSet);
206  }
207  }
208  }
209  }
210 
211  G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
212 
213  // Step limiters for e+-
214  bool eLimiter = theParSet.getParameter<bool>("ElectronStepLimit");
215  bool rLimiter = theParSet.getParameter<bool>("ElectronRangeTest");
216  bool pLimiter = theParSet.getParameter<bool>("PositronStepLimit");
217  // Step limiters for hadrons
218  bool pTCut = theParSet.getParameter<bool>("ProtonRegionLimit");
219  bool piTCut = theParSet.getParameter<bool>("PionRegionLimit");
220 
221  std::vector<std::string> regnames = theParSet.getParameter<std::vector<std::string> >("LimitsPerRegion");
222  std::vector<double> limitsE = theParSet.getParameter<std::vector<double> >("EnergyLimitsE");
223  std::vector<double> limitsH = theParSet.getParameter<std::vector<double> >("EnergyLimitsH");
224  std::vector<double> facE = theParSet.getParameter<std::vector<double> >("EnergyFactorsE");
225  std::vector<double> rmsE = theParSet.getParameter<std::vector<double> >("EnergyRMSE");
226  int nlimits = regnames.size();
227  int nlimitsH = 0;
228  std::vector<const G4Region*> reg;
229  std::vector<G4double> rlimE;
230  std::vector<G4double> rlimH;
231  std::vector<G4double> factE;
232  std::vector<G4double> rmsvE;
233  if (0 < nlimits) {
234  G4RegionStore* store = G4RegionStore::GetInstance();
235  for (int i = 0; i < nlimits; ++i) {
236  // apply limiter for whole CMS
237  if (regnames[i] == "all") {
238  reg.clear();
239  rlimE.clear();
240  rlimH.clear();
241  factE.clear();
242  rmsvE.clear();
243  reg.emplace_back(nullptr);
244  rlimE.emplace_back(limitsE[i] * CLHEP::MeV);
245  rlimH.emplace_back(limitsH[i] * CLHEP::MeV);
246  factE.emplace_back(facE[i]);
247  rmsvE.emplace_back(rmsE[i]);
248  nlimitsH = (limitsH[i] > 0) ? 1 : 0;
249  break;
250  }
251  const G4Region* r = store->GetRegion(regnames[i], false);
252  // apply for concrete G4Region
253  if (r && (limitsE[i] > 0.0 || limitsH[i] > 0.0)) {
254  reg.emplace_back(r);
255  rlimE.emplace_back(limitsE[i] * CLHEP::MeV);
256  rlimH.emplace_back(limitsH[i] * CLHEP::MeV);
257  factE.emplace_back(facE[i]);
258  rmsvE.emplace_back(rmsE[i]);
259  if (limitsH[i] > 0) {
260  ++nlimitsH;
261  }
262  }
263  }
264  nlimits = reg.size();
265  }
266 
267  if (eLimiter || rLimiter || 0 < nlimits) {
269  elim->SetRangeCheckFlag(rLimiter);
270  elim->SetFieldCheckFlag(eLimiter);
271  elim->SetTrackingCutPerRegion(reg, rlimE, factE, rmsvE);
272  ph->RegisterProcess(elim, G4Electron::Electron());
273  }
274 
275  if (pLimiter || 0 < nlimits) {
276  ElectronLimiter* plim = new ElectronLimiter(theParSet, G4Positron::Positron());
277  plim->SetFieldCheckFlag(pLimiter);
278  plim->SetTrackingCutPerRegion(reg, rlimE, factE, rmsvE);
279  ph->RegisterProcess(plim, G4Positron::Positron());
280  }
281  if (0 < nlimits && 0 < nlimitsH) {
282  if (pTCut) {
283  ElectronLimiter* plim = new ElectronLimiter(theParSet, G4Proton::Proton());
284  plim->SetFieldCheckFlag(pLimiter);
285  plim->SetTrackingCutPerRegion(reg, rlimH, factE, rmsvE);
286  ph->RegisterProcess(plim, G4Proton::Proton());
287  }
288  if (piTCut) {
289  ElectronLimiter* plim = new ElectronLimiter(theParSet, G4PionPlus::PionPlus());
290  plim->SetFieldCheckFlag(pLimiter);
291  plim->SetTrackingCutPerRegion(reg, rlimH, factE, rmsvE);
292  ph->RegisterProcess(plim, G4PionPlus::PionPlus());
293  plim = new ElectronLimiter(theParSet, G4PionMinus::PionMinus());
294  plim->SetFieldCheckFlag(pLimiter);
295  plim->SetTrackingCutPerRegion(reg, rlimH, factE, rmsvE);
296  ph->RegisterProcess(plim, G4PionMinus::PionMinus());
297  }
298  }
299  // enable fluorescence
300  bool fluo = theParSet.getParameter<bool>("FlagFluo");
301  if (fluo && !G4LossTableManager::Instance()->AtomDeexcitation()) {
302  G4VAtomDeexcitation* de = new G4UAtomicDeexcitation();
303  G4LossTableManager::Instance()->SetAtomDeexcitation(de);
304  }
305  // change parameters of transportation
306  bool modifyT = theParSet.getParameter<bool>("ModifyTransportation");
307  if (modifyT) {
308  double th1 = theParSet.getUntrackedParameter<double>("ThresholdWarningEnergy") * MeV;
309  double th2 = theParSet.getUntrackedParameter<double>("ThresholdImportantEnergy") * MeV;
310  int nt = theParSet.getUntrackedParameter<int>("ThresholdTrials");
312  }
313  edm::LogVerbatim("SimG4CoreApplication") << "ParametrisedEMPhysics::ConstructProcess() is done";
314 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void SetRangeCheckFlag(G4bool)
edm::ParameterSet theParSet
void SetTrackingCutPerRegion(std::vector< const G4Region *> &, std::vector< G4double > &, std::vector< G4double > &, std::vector< G4double > &)
static G4ThreadLocal TLSmod * m_tpmod
void ModifyTransportation(const G4ParticleDefinition *, int ntry, double th1, double th2)
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< G4FastSimulationManagerProcess > theFastSimulationManagerProcess
std::unique_ptr< GFlashEMShowerModel > theEcalEMShowerModel
void SetFieldCheckFlag(G4bool)
std::unique_ptr< LowEnergyFastSimModel > theLowEnergyFastSimModel
int nt
Definition: AMPTWrapper.h:42
std::unique_ptr< GFlashEMShowerModel > theHcalEMShowerModel
std::unique_ptr< GFlashHadronShowerModel > theHcalHadShowerModel
std::unique_ptr< GFlashHadronShowerModel > theEcalHadShowerModel
Log< level::Warning, false > LogWarning

◆ ModifyTransportation()

void ParametrisedEMPhysics::ModifyTransportation ( const G4ParticleDefinition *  part,
int  ntry,
double  th1,
double  th2 
)
private

Definition at line 316 of file ParametrisedEMPhysics.cc.

Referenced by ConstructProcess().

316  {
317  G4ProcessManager* man = part->GetProcessManager();
318  G4Transportation* trans = (G4Transportation*)((*(man->GetProcessList()))[0]);
319  if (trans) {
320  trans->SetThresholdWarningEnergy(th1);
321  trans->SetThresholdImportantEnergy(th2);
322  trans->SetThresholdTrials(ntry);
323  edm::LogVerbatim("SimG4CoreApplication")
324  << "ParametrisedEMPhysics: printout level changed for " << part->GetParticleName();
325  }
326 }
Log< level::Info, true > LogVerbatim
part
Definition: HCALResponse.h:20

Member Data Documentation

◆ m_tpmod

G4ThreadLocal ParametrisedEMPhysics::TLSmod * ParametrisedEMPhysics::m_tpmod = nullptr
staticprivate

Definition at line 29 of file ParametrisedEMPhysics.h.

Referenced by ConstructProcess(), and ~ParametrisedEMPhysics().

◆ theParSet

edm::ParameterSet ParametrisedEMPhysics::theParSet
private

Definition at line 27 of file ParametrisedEMPhysics.h.

Referenced by ConstructProcess(), and ParametrisedEMPhysics().