CMS 3D CMS Logo

LowEnergyFastSimModel.cc
Go to the documentation of this file.
3 
6 
7 #include "G4VFastSimulationModel.hh"
8 #include "G4EventManager.hh"
9 #include "G4Electron.hh"
10 #include "GFlashHitMaker.hh"
11 #include "G4Region.hh"
12 #include "G4PhysicalConstants.hh"
13 
14 constexpr double twomass = 2 * CLHEP::electron_mass_c2;
15 
17  : G4VFastSimulationModel(name, region), fRegion(region), fTrackingAction(nullptr) {
18  fEmax = parSet.getParameter<double>("LowEnergyGflashEcalEmax") * CLHEP::GeV;
19 }
20 
21 G4bool LowEnergyFastSimModel::IsApplicable(const G4ParticleDefinition& particle) {
22  return (11 == std::abs(particle.GetPDGEncoding()));
23 }
24 
25 G4bool LowEnergyFastSimModel::ModelTrigger(const G4FastTrack& fastTrack) {
26  const G4Track* track = fastTrack.GetPrimaryTrack();
27  if (nullptr == fTrackingAction) {
28  fTrackingAction = static_cast<const TrackingAction*>(G4EventManager::GetEventManager()->GetUserTrackingAction());
29  }
30  int pdgMother = std::abs(fTrackingAction->geant4Track()->GetDefinition()->GetPDGEncoding());
31  if (pdgMother == 11 || pdgMother == 22)
32  return false;
33  G4double energy = track->GetKineticEnergy();
34  return energy < fEmax && fRegion == fastTrack.GetEnvelope();
35 }
36 
37 void LowEnergyFastSimModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) {
38  fastStep.KillPrimaryTrack();
39  fastStep.SetPrimaryTrackPathLength(0.0);
40  double energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
41 
42  const G4ThreeVector& pos = fastTrack.GetPrimaryTrack()->GetPosition();
43 
44  G4double inPointEnergy = param.GetInPointEnergyFraction(energy) * energy;
45 
46  // take into account positron annihilation (not included in in-point)
47  if (-11 == fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGEncoding())
48  energy += twomass;
49 
50  const G4ThreeVector& momDir = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
51  const G4ThreeVector& ortho = momDir.orthogonal();
52  const G4ThreeVector& cross = momDir.cross(ortho);
53 
54  // in point energy deposition
55  GFlashEnergySpot spot;
56  spot.SetEnergy(inPointEnergy);
57  spot.SetPosition(pos);
58  fHitMaker.make(&spot, &fastTrack);
59 
60  // tail energy deposition
61  G4double etail = energy - inPointEnergy;
62  const G4int nspots = int(etail) + 1;
63  const G4double tailEnergy = etail / (G4double)nspots;
64  for (G4int i = 0; i < nspots; ++i) {
65  const G4double radius = param.GetRadius(energy);
66  const G4double z = param.GetZ();
67 
68  const G4double phi = CLHEP::twopi * G4UniformRand();
69  const G4ThreeVector tailPos = pos + z * momDir + radius * std::cos(phi) * ortho + radius * std::sin(phi) * cross;
70 
71  spot.SetEnergy(tailEnergy);
72  spot.SetPosition(tailPos);
73  fHitMaker.make(&spot, &fastTrack);
74  }
75 }
mps_fire.i
i
Definition: mps_fire.py:428
TrackingAction.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
twomass
constexpr double twomass
Definition: LowEnergyFastSimModel.cc:14
MessageLogger.h
pos
Definition: PixelAliasList.h:18
LowEnergyFastSimModel.h
TrackingAction::geant4Track
const G4Track * geant4Track() const
Definition: TrackingAction.h:25
LowEnergyFastSimParam::GetInPointEnergyFraction
G4double GetInPointEnergyFraction(G4double energy) const
Definition: LowEnergyFastSimParam.h:9
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Basic3DVector::cross
Basic3DVector cross(const Basic3DVector &lh) const
Vector product, or "cross" product, with a vector of same type.
Definition: extBasic3DVector.h:203
DDAxes::z
LowEnergyFastSimParam::GetRadius
G4double GetRadius(G4double energy) const
Definition: LowEnergyFastSimParam.h:15
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
cross
Basic3DVector cross(const Basic3DVector &v) const
Vector product, or "cross" product, with a vector of same type.
Definition: Basic3DVectorLD.h:225
LowEnergyFastSimModel::DoIt
void DoIt(const G4FastTrack &fastTrack, G4FastStep &fastStep) override
Definition: LowEnergyFastSimModel.cc:37
edm::ParameterSet
Definition: ParameterSet.h:47
LowEnergyFastSimModel::fEmax
G4double fEmax
Definition: LowEnergyFastSimModel.h:24
GeV
const double GeV
Definition: MathUtil.h:16
LowEnergyFastSimModel::param
LowEnergyFastSimParam param
Definition: LowEnergyFastSimModel.h:28
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
createfilelist.int
int
Definition: createfilelist.py:10
LowEnergyFastSimParam::GetZ
G4double GetZ() const
Definition: LowEnergyFastSimParam.h:24
LowEnergyFastSimModel::fRegion
const G4Envelope * fRegion
Definition: LowEnergyFastSimModel.h:25
DDAxes::phi
LowEnergyFastSimModel::fHitMaker
GFlashHitMaker fHitMaker
Definition: LowEnergyFastSimModel.h:27
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LowEnergyFastSimModel::ModelTrigger
G4bool ModelTrigger(const G4FastTrack &fastTrack) override
Definition: LowEnergyFastSimModel.cc:25
LowEnergyFastSimModel::IsApplicable
G4bool IsApplicable(const G4ParticleDefinition &particle) override
Definition: LowEnergyFastSimModel.cc:21
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LowEnergyFastSimModel::fTrackingAction
const TrackingAction * fTrackingAction
Definition: LowEnergyFastSimModel.h:26
ParameterSet.h
LowEnergyFastSimModel::LowEnergyFastSimModel
LowEnergyFastSimModel(const G4String &name, G4Region *region, const edm::ParameterSet &parSet)
Definition: LowEnergyFastSimModel.cc:16