CMS 3D CMS Logo

CMSEmStandardPhysics.cc
Go to the documentation of this file.
4 
5 #include "G4SystemOfUnits.hh"
6 #include "G4ParticleDefinition.hh"
7 #include "G4EmParameters.hh"
8 #include "G4EmBuilder.hh"
9 
10 #include "G4ComptonScattering.hh"
11 #include "G4GammaConversion.hh"
12 #include "G4PhotoElectricEffect.hh"
13 #include "G4LivermorePhotoElectricModel.hh"
14 
15 #include "G4MscStepLimitType.hh"
16 
17 #include "G4eMultipleScattering.hh"
18 #include "G4hMultipleScattering.hh"
19 #include "G4eCoulombScatteringModel.hh"
20 #include "G4CoulombScattering.hh"
21 #include "G4WentzelVIModel.hh"
22 #include "G4UrbanMscModel.hh"
23 
24 #include "G4eIonisation.hh"
25 #include "G4eBremsstrahlung.hh"
26 #include "G4eplusAnnihilation.hh"
27 
28 #include "G4hIonisation.hh"
29 #include "G4ionIonisation.hh"
30 
31 #include "G4ParticleTable.hh"
32 #include "G4Gamma.hh"
33 #include "G4Electron.hh"
34 #include "G4Positron.hh"
35 #include "G4GenericIon.hh"
36 
37 #include "G4PhysicsListHelper.hh"
38 #include "G4BuilderType.hh"
39 #include "G4GammaGeneralProcess.hh"
40 #include "G4LossTableManager.hh"
41 
42 #include "G4Version.hh"
43 #if G4VERSION_NUMBER >= 1110
44 #include "G4ProcessManager.hh"
45 #include "G4TransportationWithMsc.hh"
46 #endif
47 
48 #include "G4RegionStore.hh"
49 #include "G4Region.hh"
50 #include <string>
51 
53  : G4VPhysicsConstructor("CMSEmStandard_emm") {
54  SetVerboseLevel(ver);
55  // EM parameters specific for this EM physics configuration
56  G4EmParameters* param = G4EmParameters::Instance();
57  param->SetDefaults();
58  param->SetVerbose(ver);
59  param->SetApplyCuts(true);
60  param->SetStepFunction(0.8, 1 * CLHEP::mm);
61  param->SetMscRangeFactor(0.2);
62  param->SetMscStepLimitType(fMinimal);
63  param->SetFluo(false);
64  SetPhysicsType(bElectromagnetic);
65  fRangeFactor = p.getParameter<double>("G4MscRangeFactor");
66  fGeomFactor = p.getParameter<double>("G4MscGeomFactor");
67  fSafetyFactor = p.getParameter<double>("G4MscSafetyFactor");
68  fLambdaLimit = p.getParameter<double>("G4MscLambdaLimit") * CLHEP::mm;
69  std::string msc = p.getParameter<std::string>("G4MscStepLimit");
70  fStepLimitType = fUseSafety;
71  if (msc == "UseSafetyPlus") {
72  fStepLimitType = fUseSafetyPlus;
73  }
74  if (msc == "Minimal") {
75  fStepLimitType = fMinimal;
76  }
77  double tcut = p.getParameter<double>("G4TrackingCut") * CLHEP::MeV;
78  param->SetLowestElectronEnergy(tcut);
79  param->SetLowestMuHadEnergy(tcut);
80  fG4HepEmActive = p.getParameter<bool>("G4HepEmActive");
81 }
82 
84  // minimal set of particles for EM physics
85  G4EmBuilder::ConstructMinimalEmSet();
86 }
87 
89  if (verboseLevel > 0) {
90  edm::LogVerbatim("PhysicsList") << "### " << GetPhysicsName() << " Construct EM Processes";
91  }
92 
93  // This EM builder takes default models of Geant4 10 EMV.
94  // Multiple scattering by WentzelVI for all particles except:
95  // a) e+e- below 100 MeV for which the Urban model is used
96  // b) ions for which Urban model is used
97  G4EmBuilder::PrepareEMPhysics();
98 
99  G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
100  // processes used by several particles
101  G4hMultipleScattering* hmsc = new G4hMultipleScattering("ionmsc");
102  G4NuclearStopping* pnuc(nullptr);
103 
104  // high energy limit for e+- scattering models
105  auto param = G4EmParameters::Instance();
106  G4double highEnergyLimit = param->MscEnergyLimit();
107 
108  const G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion("HcalRegion", false);
109  const G4Region* bRegion = G4RegionStore::GetInstance()->GetRegion("HGCalRegion", false);
110 
111  // Add gamma EM Processes
112  G4ParticleDefinition* particle = G4Gamma::Gamma();
113 
114  G4PhotoElectricEffect* pee = new G4PhotoElectricEffect();
115 
116  if (param->GeneralProcessActive()) {
118  sp->AddEmProcess(pee);
119  sp->AddEmProcess(new G4ComptonScattering());
120  sp->AddEmProcess(new G4GammaConversion());
121  G4LossTableManager::Instance()->SetGammaGeneralProcess(sp);
122  ph->RegisterProcess(sp, particle);
123 
124  } else {
125  ph->RegisterProcess(pee, particle);
126  ph->RegisterProcess(new G4ComptonScattering(), particle);
127  ph->RegisterProcess(new G4GammaConversion(), particle);
128  }
129 
130  // e-
131  particle = G4Electron::Electron();
132 
133  G4eIonisation* eioni = new G4eIonisation();
134 
135  G4UrbanMscModel* msc1 = new G4UrbanMscModel();
136  G4WentzelVIModel* msc2 = new G4WentzelVIModel();
137  msc1->SetHighEnergyLimit(highEnergyLimit);
138  msc2->SetLowEnergyLimit(highEnergyLimit);
139 
140  // e-/e+ msc for HCAL and HGCAL using the Urban model
141  G4UrbanMscModel* msc3 = nullptr;
142  if (nullptr != aRegion || nullptr != bRegion) {
143  msc3 = new G4UrbanMscModel();
144  msc3->SetHighEnergyLimit(highEnergyLimit);
145  msc3->SetRangeFactor(fRangeFactor);
146  msc3->SetGeomFactor(fGeomFactor);
147  msc3->SetSafetyFactor(fSafetyFactor);
148  msc3->SetLambdaLimit(fLambdaLimit);
149  msc3->SetStepLimitType(fStepLimitType);
150  msc3->SetLocked(true);
151  }
152 
153 #if G4VERSION_NUMBER >= 1110
154  G4TransportationWithMscType transportationWithMsc = param->TransportationWithMsc();
155  if (transportationWithMsc != G4TransportationWithMscType::fDisabled) {
156  // Remove default G4Transportation and replace with G4TransportationWithMsc.
157  G4ProcessManager* procManager = particle->GetProcessManager();
158  G4VProcess* removed = procManager->RemoveProcess(0);
159  if (removed->GetProcessName() != "Transportation") {
160  G4Exception("CMSEmStandardPhysics::ConstructProcess",
161  "em0050",
162  FatalException,
163  "replaced process is not G4Transportation!");
164  }
165  G4TransportationWithMsc* transportWithMsc =
167  if (transportationWithMsc == G4TransportationWithMscType::fMultipleSteps) {
168  transportWithMsc->SetMultipleSteps(true);
169  }
170  transportWithMsc->AddMscModel(msc1);
171  transportWithMsc->AddMscModel(msc2);
172  if (nullptr != aRegion) {
173  transportWithMsc->AddMscModel(msc3, -1, aRegion);
174  }
175  if (nullptr != bRegion) {
176  transportWithMsc->AddMscModel(msc3, -1, bRegion);
177  }
178  procManager->AddProcess(transportWithMsc, -1, 0, 0);
179  } else
180 #endif
181  {
182  // Multiple scattering is registered as a separate process
183  G4eMultipleScattering* msc = new G4eMultipleScattering;
184  msc->SetEmModel(msc1);
185  msc->SetEmModel(msc2);
186  if (nullptr != aRegion) {
187  msc->AddEmModel(-1, msc3, aRegion);
188  }
189  if (nullptr != bRegion) {
190  msc->AddEmModel(-1, msc3, bRegion);
191  }
192  ph->RegisterProcess(msc, particle);
193  }
194 
195  // single scattering
196  G4eCoulombScatteringModel* ssm = new G4eCoulombScatteringModel();
197  G4CoulombScattering* ss = new G4CoulombScattering();
198  ss->SetEmModel(ssm);
199  ss->SetMinKinEnergy(highEnergyLimit);
200  ssm->SetLowEnergyLimit(highEnergyLimit);
201  ssm->SetActivationLowEnergyLimit(highEnergyLimit);
202 
203  ph->RegisterProcess(eioni, particle);
204  ph->RegisterProcess(new G4eBremsstrahlung(), particle);
205  ph->RegisterProcess(ss, particle);
206 
207  // e+
208  particle = G4Positron::Positron();
209  eioni = new G4eIonisation();
210 
211  msc1 = new G4UrbanMscModel();
212  msc2 = new G4WentzelVIModel();
213  msc1->SetHighEnergyLimit(highEnergyLimit);
214  msc2->SetLowEnergyLimit(highEnergyLimit);
215 
216  // e-/e+ msc for HCAL and HGCAL using the Urban model
217  if (nullptr != aRegion || nullptr != bRegion) {
218  msc3 = new G4UrbanMscModel();
219  msc3->SetHighEnergyLimit(highEnergyLimit);
220  msc3->SetRangeFactor(fRangeFactor);
221  msc3->SetGeomFactor(fGeomFactor);
222  msc3->SetSafetyFactor(fSafetyFactor);
223  msc3->SetLambdaLimit(fLambdaLimit);
224  msc3->SetStepLimitType(fStepLimitType);
225  msc3->SetLocked(true);
226  }
227 
228 #if G4VERSION_NUMBER >= 1110
229  if (transportationWithMsc != G4TransportationWithMscType::fDisabled) {
230  G4ProcessManager* procManager = particle->GetProcessManager();
231  // Remove default G4Transportation and replace with G4TransportationWithMsc.
232  G4VProcess* removed = procManager->RemoveProcess(0);
233  if (removed->GetProcessName() != "Transportation") {
234  G4Exception("CMSEmStandardPhysics::ConstructProcess",
235  "em0050",
236  FatalException,
237  "replaced process is not G4Transportation!");
238  }
239  G4TransportationWithMsc* transportWithMsc =
241  if (transportationWithMsc == G4TransportationWithMscType::fMultipleSteps) {
242  transportWithMsc->SetMultipleSteps(true);
243  }
244  transportWithMsc->AddMscModel(msc1);
245  transportWithMsc->AddMscModel(msc2);
246  if (nullptr != aRegion) {
247  transportWithMsc->AddMscModel(msc3, -1, aRegion);
248  }
249  if (nullptr != bRegion) {
250  transportWithMsc->AddMscModel(msc3, -1, bRegion);
251  }
252  procManager->AddProcess(transportWithMsc, -1, 0, 0);
253  } else
254 #endif
255  {
256  // Register as a separate process.
257  G4eMultipleScattering* msc = new G4eMultipleScattering;
258  msc->SetEmModel(msc1);
259  msc->SetEmModel(msc2);
260  if (nullptr != aRegion) {
261  msc->AddEmModel(-1, msc3, aRegion);
262  }
263  if (nullptr != bRegion) {
264  msc->AddEmModel(-1, msc3, bRegion);
265  }
266  ph->RegisterProcess(msc, particle);
267  }
268 
269  // single scattering
270  ssm = new G4eCoulombScatteringModel();
271  ss = new G4CoulombScattering();
272  ss->SetEmModel(ssm);
273  ss->SetMinKinEnergy(highEnergyLimit);
274  ssm->SetLowEnergyLimit(highEnergyLimit);
275  ssm->SetActivationLowEnergyLimit(highEnergyLimit);
276 
277  ph->RegisterProcess(eioni, particle);
278  ph->RegisterProcess(new G4eBremsstrahlung(), particle);
279  ph->RegisterProcess(new G4eplusAnnihilation(), particle);
280  ph->RegisterProcess(ss, particle);
281 
282 #if G4VERSION_NUMBER >= 1110
283  if (fG4HepEmActive) {
284  auto* hepEmTM = new CMSHepEmTrackingManager(highEnergyLimit);
285  G4Electron::Electron()->SetTrackingManager(hepEmTM);
286  G4Positron::Positron()->SetTrackingManager(hepEmTM);
287  }
288 #endif
289 
290  // generic ion
291  particle = G4GenericIon::GenericIon();
292  G4ionIonisation* ionIoni = new G4ionIonisation();
293  ph->RegisterProcess(hmsc, particle);
294  ph->RegisterProcess(ionIoni, particle);
295 
296  // muons, hadrons ions
297  G4EmBuilder::ConstructCharged(hmsc, pnuc);
298 }
Log< level::Info, true > LogVerbatim
void ConstructParticle() override
void ConstructProcess() override
G4MscStepLimitType fStepLimitType
CMSEmStandardPhysics(G4int ver, const edm::ParameterSet &p)