CMS 3D CMS Logo

GflashHadronShowerModel.cc
Go to the documentation of this file.
2 
4 
14 
15 #include "G4EventManager.hh"
16 #include "G4FastSimulationManager.hh"
17 #include "G4TouchableHandle.hh"
18 #include "G4TransportationManager.hh"
19 #include "G4VPhysicalVolume.hh"
20 #include "G4VSensitiveDetector.hh"
21 
22 #include "G4AntiProton.hh"
23 #include "G4KaonMinus.hh"
24 #include "G4KaonPlus.hh"
25 #include "G4PionMinus.hh"
26 #include "G4PionPlus.hh"
27 #include "G4Proton.hh"
28 #include "G4VProcess.hh"
29 
30 #include <vector>
31 
32 using namespace CLHEP;
33 
35  G4Region *envelope,
36  const edm::ParameterSet &parSet)
37  : G4VFastSimulationModel(modelName, envelope), theParSet(parSet) {
38  theWatcherOn = parSet.getParameter<bool>("watcherOn");
39 
47 
48  theGflashStep = new G4Step();
49  theGflashTouchableHandle = new G4TouchableHistory();
50  theGflashNavigator = new G4Navigator();
51 }
52 
54  if (theProfile)
55  delete theProfile;
56  if (theGflashStep)
57  delete theGflashStep;
58 }
59 
60 G4bool GflashHadronShowerModel::IsApplicable(const G4ParticleDefinition &particleType) {
61  return &particleType == G4PionMinus::PionMinusDefinition() || &particleType == G4PionPlus::PionPlusDefinition() ||
62  &particleType == G4KaonMinus::KaonMinusDefinition() || &particleType == G4KaonPlus::KaonPlusDefinition() ||
63  &particleType == G4AntiProton::AntiProtonDefinition() || &particleType == G4Proton::ProtonDefinition();
64 }
65 
66 G4bool GflashHadronShowerModel::ModelTrigger(const G4FastTrack &fastTrack) {
67  // ModelTrigger returns false for Gflash Hadronic Shower Model if it is not
68  // tested from the corresponding wrapper process, GflashHadronWrapperProcess.
69  // Temporarily the track status is set to fPostponeToNextEvent at the wrapper
70  // process before ModelTrigger is really tested for the second time through
71  // PostStepGPIL of enviaged parameterization processes. The better
72  // implmentation may be using via G4VUserTrackInformation of each track, which
73  // requires to modify a geant source code of stepping (G4SteppingManager2)
74 
75  G4bool trigger = false;
76 
77  // mininum energy cutoff to parameterize
78  if (fastTrack.GetPrimaryTrack()->GetKineticEnergy() / GeV < Gflash::energyCutOff)
79  return trigger;
80 
81  // check whether this is called from the normal GPIL or the wrapper process
82  // GPIL
83  if (fastTrack.GetPrimaryTrack()->GetTrackStatus() == fPostponeToNextEvent) {
84  // Shower pameterization start at the first inelastic interaction point
85  G4bool isInelastic = isFirstInelasticInteraction(fastTrack);
86 
87  // Other conditions
88  if (isInelastic) {
89  trigger = (!excludeDetectorRegion(fastTrack));
90  }
91  }
92 
93  return trigger;
94 }
95 
96 void GflashHadronShowerModel::DoIt(const G4FastTrack &fastTrack, G4FastStep &fastStep) {
97  // kill the particle
98  fastStep.KillPrimaryTrack();
99  fastStep.ProposePrimaryTrackPathLength(0.0);
100 
101  // parameterize energy depostion by the particle type
102  G4ParticleDefinition *particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
103 
105  if (particleType == G4KaonMinus::KaonMinusDefinition())
107  else if (particleType == G4KaonPlus::KaonPlusDefinition())
109  else if (particleType == G4AntiProton::AntiProtonDefinition())
111  else if (particleType == G4Proton::ProtonDefinition())
113 
114  // input variables for GflashHadronShowerProfile
115  G4double energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy() / GeV;
116  G4double globalTime = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetGlobalTime();
117  G4double charge = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint()->GetCharge();
118  G4ThreeVector position = fastTrack.GetPrimaryTrack()->GetPosition() / cm;
119  G4ThreeVector momentum = fastTrack.GetPrimaryTrack()->GetMomentum() / GeV;
120  G4int showerType = Gflash::findShowerType(position);
121 
122  theProfile->initialize(showerType, energy, globalTime, charge, position, momentum);
125 
126  // make hits
127  makeHits(fastTrack);
128 }
129 
130 void GflashHadronShowerModel::makeHits(const G4FastTrack &fastTrack) {
131  std::vector<GflashHit> &gflashHitList = theProfile->getGflashHitList();
132 
133  theGflashStep->SetTrack(const_cast<G4Track *>(fastTrack.GetPrimaryTrack()));
134  theGflashStep->GetPostStepPoint()->SetProcessDefinedStep(
135  const_cast<G4VProcess *>(fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()));
136  theGflashNavigator->SetWorldVolume(
137  G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume());
138 
139  std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
140  std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
141 
142  for (; spotIter != spotIterEnd; spotIter++) {
143  theGflashNavigator->LocateGlobalPointAndUpdateTouchableHandle(
144  spotIter->getPosition(), G4ThreeVector(0, 0, 0), theGflashTouchableHandle, false);
145  updateGflashStep(spotIter->getPosition(), spotIter->getTime());
146 
147  G4VPhysicalVolume *aCurrentVolume = theGflashStep->GetPreStepPoint()->GetPhysicalVolume();
148  if (aCurrentVolume == nullptr)
149  continue;
150 
151  G4LogicalVolume *lv = aCurrentVolume->GetLogicalVolume();
152  if (lv->GetRegion()->GetName() != "CaloRegion")
153  continue;
154 
155  theGflashStep->GetPreStepPoint()->SetSensitiveDetector(aCurrentVolume->GetLogicalVolume()->GetSensitiveDetector());
156  G4VSensitiveDetector *aSensitive = theGflashStep->GetPreStepPoint()->GetSensitiveDetector();
157 
158  if (aSensitive == nullptr)
159  continue;
160 
161  G4String nameCalor = aCurrentVolume->GetName();
162  nameCalor.assign(nameCalor, 0, 2);
163  G4double samplingWeight = 1.0;
164  if (nameCalor == "HB") {
165  samplingWeight = Gflash::scaleSensitiveHB;
166  } else if (nameCalor == "HE" || nameCalor == "HT") {
167  samplingWeight = Gflash::scaleSensitiveHE;
168  }
169  theGflashStep->SetTotalEnergyDeposit(spotIter->getEnergy() * samplingWeight);
170 
171  aSensitive->Hit(theGflashStep);
172  }
173 }
174 
175 void GflashHadronShowerModel::updateGflashStep(const G4ThreeVector &spotPosition, G4double timeGlobal) {
176  theGflashStep->GetPostStepPoint()->SetGlobalTime(timeGlobal);
177  theGflashStep->GetPreStepPoint()->SetPosition(spotPosition);
178  theGflashStep->GetPostStepPoint()->SetPosition(spotPosition);
179  theGflashStep->GetPreStepPoint()->SetTouchableHandle(theGflashTouchableHandle);
180 }
181 
182 G4bool GflashHadronShowerModel::isFirstInelasticInteraction(const G4FastTrack &fastTrack) {
183  G4bool isFirst = false;
184 
185  G4StepPoint *preStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint();
186  G4StepPoint *postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
187 
188  G4String procName = postStep->GetProcessDefinedStep()->GetProcessName();
189  G4ParticleDefinition *particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
190 
191  //@@@ this part is still temporary and the cut for the variable ratio should
192  // be optimized later
193 
194  if ((particleType == G4PionPlus::PionPlusDefinition() && procName == "WrappedPionPlusInelastic") ||
195  (particleType == G4PionMinus::PionMinusDefinition() && procName == "WrappedPionMinusInelastic") ||
196  (particleType == G4KaonPlus::KaonPlusDefinition() && procName == "WrappedKaonPlusInelastic") ||
197  (particleType == G4KaonMinus::KaonMinusDefinition() && procName == "WrappedKaonMinusInelastic") ||
198  (particleType == G4AntiProton::AntiProtonDefinition() && procName == "WrappedAntiProtonInelastic") ||
199  (particleType == G4Proton::ProtonDefinition() && procName == "WrappedProtonInelastic")) {
200  // skip to the second interaction if the first inelastic is a quasi-elastic
201  // like interaction
202  //@@@ the cut may be optimized later
203 
204  const G4TrackVector *fSecondaryVector = fastTrack.GetPrimaryTrack()->GetStep()->GetSecondary();
205  G4double leadingEnergy = 0.0;
206 
207  // loop over 'all' secondaries including those produced by continuous
208  // processes.
209  //@@@may require an additional condition only for hadron interaction with
210  // the process name, but it will not change the result anyway
211 
212  for (unsigned int isec = 0; isec < fSecondaryVector->size(); isec++) {
213  G4Track *fSecondaryTrack = (*fSecondaryVector)[isec];
214  G4double secondaryEnergy = fSecondaryTrack->GetKineticEnergy();
215 
216  if (secondaryEnergy > leadingEnergy) {
217  leadingEnergy = secondaryEnergy;
218  }
219  }
220 
221  if ((preStep->GetTotalEnergy() != 0) && (leadingEnergy / preStep->GetTotalEnergy() < Gflash::QuasiElasticLike))
222  isFirst = true;
223 
224  // Fill debugging histograms and check information on secondaries -
225  // remove after final implimentation
226 
227  if (theHisto->getStoreFlag()) {
228  theHisto->preStepPosition->Fill(preStep->GetPosition().getRho() / cm);
229  theHisto->postStepPosition->Fill(postStep->GetPosition().getRho() / cm);
230  theHisto->deltaStep->Fill((postStep->GetPosition() - preStep->GetPosition()).getRho() / cm);
231  theHisto->kineticEnergy->Fill(fastTrack.GetPrimaryTrack()->GetKineticEnergy() / GeV);
232  theHisto->energyLoss->Fill(fabs(fastTrack.GetPrimaryTrack()->GetStep()->GetDeltaEnergy() / GeV));
233  theHisto->energyRatio->Fill(leadingEnergy / preStep->GetTotalEnergy());
234  }
235  }
236  return isFirst;
237 }
238 
239 G4bool GflashHadronShowerModel::excludeDetectorRegion(const G4FastTrack &fastTrack) {
240  G4bool isExcluded = false;
241  int verbosity = theParSet.getUntrackedParameter<int>("Verbosity");
242 
243  // exclude regions where geometry are complicated
244  //+- one supermodule around the EB/EE boundary: 1.479 +- 0.0174*5
245  G4double eta = fastTrack.GetPrimaryTrack()->GetPosition().pseudoRapidity();
246  if (std::fabs(eta) > 1.392 && std::fabs(eta) < 1.566) {
247  if (verbosity > 0) {
248  edm::LogInfo("SimGeneralGFlash") << "GflashHadronShowerModel: excluding region of eta = " << eta;
249  }
250  return true;
251  } else {
252  G4StepPoint *postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
253 
254  Gflash::CalorimeterNumber kCalor = Gflash::getCalorimeterNumber(postStep->GetPosition() / cm);
255  G4double distOut = 9999.0;
256 
257  // exclude the region where the shower starting point is inside the
258  // preshower
259  if (std::fabs(eta) > Gflash::EtaMin[Gflash::kENCA] &&
260  std::fabs((postStep->GetPosition()).getZ() / cm) < Gflash::Zmin[Gflash::kENCA]) {
261  return true;
262  }
263 
264  //<---the shower starting point is always inside envelopes
265  //@@@exclude the region where the shower starting point is too close to the
266  // end of the hadronic envelopes (may need to be optimized further!)
267  //@@@if we extend parameterization including Magnet/HO, we need to change
268  // this strategy
269  if (kCalor == Gflash::kHB) {
270  distOut = Gflash::Rmax[Gflash::kHB] - postStep->GetPosition().getRho() / cm;
271  if (distOut < Gflash::MinDistanceToOut)
272  isExcluded = true;
273  } else if (kCalor == Gflash::kHE) {
274  distOut = Gflash::Zmax[Gflash::kHE] - std::fabs(postStep->GetPosition().getZ() / cm);
275  if (distOut < Gflash::MinDistanceToOut)
276  isExcluded = true;
277  }
278 
279  //@@@remove this print statement later
280  if (isExcluded && verbosity > 0) {
281  std::cout << "GflashHadronShowerModel: skipping kCalor = " << kCalor << " DistanceToOut " << distOut << " from ("
282  << (postStep->GetPosition()).getRho() / cm << ":" << (postStep->GetPosition()).getZ() / cm
283  << ") of KE = " << fastTrack.GetPrimaryTrack()->GetKineticEnergy() / GeV << std::endl;
284  }
285  }
286 
287  return isExcluded;
288 }
GflashKaonPlusShowerProfile.h
GflashHit.h
ctppsCommonDQMSource_cfi.verbosity
verbosity
Definition: ctppsCommonDQMSource_cfi.py:14
GflashHistogram::getStoreFlag
bool getStoreFlag()
Definition: GflashHistogram.h:25
MessageLogger.h
GflashHistogram::postStepPosition
TH1F * postStepPosition
Definition: GflashHistogram.h:50
GflashHadronShowerModel::makeHits
void makeHits(const G4FastTrack &fastTrack)
Definition: GflashHadronShowerModel.cc:130
GflashNameSpace.h
Gflash::MinDistanceToOut
const double MinDistanceToOut
Definition: GflashNameSpace.h:51
GflashHadronShowerModel::theGflashNavigator
G4Navigator * theGflashNavigator
Definition: GflashHadronShowerModel.h:52
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GflashHadronShowerModel::theAntiProtonProfile
GflashAntiProtonShowerProfile * theAntiProtonProfile
Definition: GflashHadronShowerModel.h:49
Gflash::scaleSensitiveHB
const double scaleSensitiveHB
Definition: GflashNameSpace.h:75
Gflash::Rmax
const double Rmax[kNumberCalorimeter]
Definition: GflashNameSpace.h:31
GflashHistogram::kineticEnergy
TH1F * kineticEnergy
Definition: GflashHistogram.h:52
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
GflashHadronShowerModel::GflashHadronShowerModel
GflashHadronShowerModel(G4String modelName, G4Region *envelope, const edm::ParameterSet &parSet)
Definition: GflashHadronShowerModel.cc:34
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
GflashHadronShowerModel::theGflashStep
G4Step * theGflashStep
Definition: GflashHadronShowerModel.h:51
GflashHadronShowerModel::updateGflashStep
void updateGflashStep(const G4ThreeVector &position, G4double time)
Definition: GflashHadronShowerModel.cc:175
cuy.isFirst
isFirst
Definition: cuy.py:418
Gflash::findShowerType
int findShowerType(const Gflash3Vector &position)
Definition: GflashNameSpace.cc:41
GflashHistogram::deltaStep
TH1F * deltaStep
Definition: GflashHistogram.h:51
GflashKaonPlusShowerProfile
Definition: GflashKaonPlusShowerProfile.h:6
GflashHadronShowerModel::DoIt
void DoIt(const G4FastTrack &, G4FastStep &) override
Definition: GflashHadronShowerModel.cc:96
GflashKaonMinusShowerProfile
Definition: GflashKaonMinusShowerProfile.h:6
Gflash::kHB
Definition: GflashNameSpace.h:13
HLTEgPhaseIITestSequence_cff.modelName
modelName
Definition: HLTEgPhaseIITestSequence_cff.py:16
Gflash::kHE
Definition: GflashNameSpace.h:15
Gflash::kENCA
Definition: GflashNameSpace.h:14
Gflash::Zmax
const double Zmax[kNumberCalorimeter]
Definition: GflashNameSpace.h:29
GflashProtonShowerProfile
Definition: GflashProtonShowerProfile.h:6
PVValHelper::eta
Definition: PVValidationHelpers.h:70
Gflash::EtaMin
const double EtaMin[kNumberCalorimeter]
Definition: GflashNameSpace.h:33
Gflash::energyCutOff
const double energyCutOff
Definition: GflashNameSpace.h:44
GflashHadronShowerModel.h
Gflash::QuasiElasticLike
const double QuasiElasticLike
Definition: GflashNameSpace.h:48
GflashHadronShowerModel::excludeDetectorRegion
G4bool excludeDetectorRegion(const G4FastTrack &fastTrack)
Definition: GflashHadronShowerModel.cc:239
GflashHadronShowerModel::~GflashHadronShowerModel
~GflashHadronShowerModel() override
Definition: GflashHadronShowerModel.cc:53
GflashHadronShowerModel::isFirstInelasticInteraction
G4bool isFirstInelasticInteraction(const G4FastTrack &fastTrack)
Definition: GflashHadronShowerModel.cc:182
GflashHadronShowerModel::theWatcherOn
G4bool theWatcherOn
Definition: GflashHadronShowerModel.h:42
GflashHadronShowerProfile::initialize
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum)
Definition: GflashHadronShowerProfile.cc:30
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
GflashHistogram.h
CLHEP
Definition: CocoaGlobals.h:27
GflashHadronShowerProfile::getGflashHitList
std::vector< GflashHit > & getGflashHitList()
Definition: GflashHadronShowerProfile.h:33
GflashHadronShowerModel::theProfile
GflashHadronShowerProfile * theProfile
Definition: GflashHadronShowerModel.h:44
GflashHadronShowerProfile::loadParameters
virtual void loadParameters()
Definition: GflashHadronShowerProfile.cc:247
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
Gflash::getCalorimeterNumber
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector &position)
Definition: GflashNameSpace.cc:7
edm::ParameterSet
Definition: ParameterSet.h:47
GflashHadronShowerModel::theKaonPlusProfile
GflashKaonPlusShowerProfile * theKaonPlusProfile
Definition: GflashHadronShowerModel.h:46
GflashHadronShowerModel::theHisto
GflashHistogram * theHisto
Definition: GflashHadronShowerModel.h:56
GeV
const double GeV
Definition: MathUtil.h:16
GflashHadronShowerModel::theGflashTouchableHandle
G4TouchableHandle theGflashTouchableHandle
Definition: GflashHadronShowerModel.h:53
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
Gflash::CalorimeterNumber
CalorimeterNumber
Definition: GflashNameSpace.h:10
GflashProtonShowerProfile.h
Gflash::Zmin
const double Zmin[kNumberCalorimeter]
Definition: GflashNameSpace.h:28
Gflash::scaleSensitiveHE
const double scaleSensitiveHE
Definition: GflashNameSpace.h:77
GflashAntiProtonShowerProfile
Definition: GflashAntiProtonShowerProfile.h:6
GflashKaonMinusShowerProfile.h
GflashHistogram::instance
static GflashHistogram * instance()
Definition: GflashHistogram.cc:5
GflashHadronShowerModel::theParSet
edm::ParameterSet theParSet
Definition: GflashHadronShowerModel.h:43
GflashHistogram::energyRatio
TH1F * energyRatio
Definition: GflashHistogram.h:54
GflashPiKShowerProfile.h
GflashHadronShowerModel::thePiKProfile
GflashPiKShowerProfile * thePiKProfile
Definition: GflashHadronShowerModel.h:45
GflashHadronShowerModel::theProtonProfile
GflashProtonShowerProfile * theProtonProfile
Definition: GflashHadronShowerModel.h:48
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
trigger
Definition: HLTPrescaleTableCond.h:8
GflashHadronShowerProfile.h
GflashHadronShowerProfile
Definition: GflashHadronShowerProfile.h:15
PbPb_ZMuSkimMuonDPG_cff.particleType
particleType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:27
GflashHistogram::energyLoss
TH1F * energyLoss
Definition: GflashHistogram.h:53
GflashHadronShowerModel::theKaonMinusProfile
GflashKaonMinusShowerProfile * theKaonMinusProfile
Definition: GflashHadronShowerModel.h:47
GflashAntiProtonShowerProfile.h
GflashHadronShowerModel::ModelTrigger
G4bool ModelTrigger(const G4FastTrack &) override
Definition: GflashHadronShowerModel.cc:66
GflashHadronShowerModel::IsApplicable
G4bool IsApplicable(const G4ParticleDefinition &) override
Definition: GflashHadronShowerModel.cc:60
GflashHadronShowerProfile::hadronicParameterization
void hadronicParameterization()
Definition: GflashHadronShowerProfile.cc:36
GflashHistogram::preStepPosition
TH1F * preStepPosition
Definition: GflashHistogram.h:49
GflashPiKShowerProfile
Definition: GflashPiKShowerProfile.h:6