CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
CastorSD Class Reference

#include <SimG4CMS/Forward/interface/CastorSD.h>

Inheritance diagram for CastorSD:
CaloSD SensitiveCaloDetector Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

 CastorSD (const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *step) override
 
void setNumberingScheme (CastorNumberingScheme *scheme)
 
 ~CastorSD () override
 
- Public Member Functions inherited from CaloSD
 CaloSD (const std::string &aSDname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
 
void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *) override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *) override
 
void reset () override
 
 ~CaloSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, bool calo)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

double getEnergyDeposit (const G4Step *) override
 
bool getFromLibrary (const G4Step *) override
 
- Protected Member Functions inherited from CaloSD
bool checkHit ()
 
CaloG4HitcreateNewHit (const G4Step *, const G4Track *)
 
virtual void endEvent ()
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual uint16_t getDepth (const G4Step *)
 
int getNumberOfHits ()
 
double getResponseWt (const G4Track *)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *)
 
virtual void initEvent (const BeginOfEvent *)
 
virtual void initRun ()
 
void processHit (const G4Step *step)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val)
 
void setParameterized (bool val)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *) const
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *) const
 
virtual int setTrackID (const G4Step *)
 
void setUseMap (bool val)
 
void update (const ::EndOfEvent *) override
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void updateHit (CaloG4Hit *)
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Private Member Functions

uint32_t rotateUnitID (uint32_t, const G4Track *, const CastorShowerEvent &)
 

Private Attributes

double energyThresholdSL
 
G4LogicalVolume * lvC3EF
 
G4LogicalVolume * lvC3HF
 
G4LogicalVolume * lvC4EF
 
G4LogicalVolume * lvC4HF
 
G4LogicalVolume * lvCAST
 
double non_compensation_factor
 
CastorNumberingSchemenumberingScheme
 
CastorShowerLibraryshowerLibrary
 
bool useShowerLibrary
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Attributes inherited from CaloSD
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
G4ThreeVector posGlobal
 
CaloHitID previousID
 
bool suppressHeavy
 
double tmaxHit
 

Detailed Description

Description: Stores hits of Castor in appropriate container

Usage: Used in sensitive detector builder

Definition at line 30 of file CastorSD.h.

Constructor & Destructor Documentation

◆ CastorSD()

CastorSD::CastorSD ( const std::string &  name,
const edm::EventSetup es,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 31 of file CastorSD.cc.

36  : CaloSD(name, es, clg, p, manager),
37  numberingScheme(nullptr),
38  lvC3EF(nullptr),
39  lvC3HF(nullptr),
40  lvC4EF(nullptr),
41  lvC4HF(nullptr),
42  lvCAST(nullptr) {
43  edm::ParameterSet m_CastorSD = p.getParameter<edm::ParameterSet>("CastorSD");
44  useShowerLibrary = m_CastorSD.getParameter<bool>("useShowerLibrary");
45  energyThresholdSL = m_CastorSD.getParameter<double>("minEnergyInGeVforUsingSLibrary");
46  energyThresholdSL = energyThresholdSL * GeV; // Convert GeV => MeV
47 
48  non_compensation_factor = m_CastorSD.getParameter<double>("nonCompensationFactor");
49 
50  if (useShowerLibrary) {
52  setParameterized(true);
53  }
55 
56  edm::LogVerbatim("ForwardSim") << "********************************************************\n"
57  << "* Constructing a CastorSD with name " << GetName() << "\n"
58  << "* Using Castor Shower Library: " << useShowerLibrary << "\n"
59  << "********************************************************";
60 
61  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
62  for (auto lv : *lvs) {
63  if (strcmp((lv->GetName()).c_str(), "C3EF") == 0) {
64  lvC3EF = lv;
65  }
66  if (strcmp((lv->GetName()).c_str(), "C3HF") == 0) {
67  lvC3HF = lv;
68  }
69  if (strcmp((lv->GetName()).c_str(), "C4EF") == 0) {
70  lvC4EF = lv;
71  }
72  if (strcmp((lv->GetName()).c_str(), "C4HF") == 0) {
73  lvC4HF = lv;
74  }
75  if (strcmp((lv->GetName()).c_str(), "CAST") == 0) {
76  lvCAST = lv;
77  }
78  if (lvC3EF != nullptr && lvC3HF != nullptr && lvC4EF != nullptr && lvC4HF != nullptr && lvCAST != nullptr) {
79  break;
80  }
81  }
82  LogDebug("ForwardSim") << "CastorSD:: LogicalVolume pointers\n"
83  << lvC3EF << " for C3EF; " << lvC3HF << " for C3HF; " << lvC4EF << " for C4EF; " << lvC4HF
84  << " for C4HF; " << lvCAST << " for CAST. ";
85 }

References g4SimHits_cfi::CastorShowerLibrary, energyThresholdSL, edm::ParameterSet::getParameter(), GeV, LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAST, Skims_PA_cff::name, non_compensation_factor, AlCaHLTBitMon_ParallelJobs::p, setNumberingScheme(), CaloSD::setParameterized(), showerLibrary, and useShowerLibrary.

◆ ~CastorSD()

CastorSD::~CastorSD ( )
override

Definition at line 89 of file CastorSD.cc.

89 { delete showerLibrary; }

References showerLibrary.

Member Function Documentation

◆ getEnergyDeposit()

double CastorSD::getEnergyDeposit ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 93 of file CastorSD.cc.

93  {
94  double NCherPhot = 0.;
95 
96  // Get theTrack
97  auto const theTrack = aStep->GetTrack();
98 
99  // preStepPoint information *********************************************
100  auto const preStepPoint = aStep->GetPreStepPoint();
101  auto const currentPV = preStepPoint->GetPhysicalVolume();
102  auto const currentLV = currentPV->GetLogicalVolume();
103 
104 #ifdef debugLog
105  edm::LogVerbatim("ForwardSim") << "CastorSD::getEnergyDeposit:"
106  << "\n CurrentStepNumber , TrackID , ParentID, Particle , VertexPosition ,"
107  << " LogicalVolumeAtVertex , PV, Time"
108  << "\n TRACKINFO: " << theTrack->GetCurrentStepNumber() << " , "
109  << theTrack->GetTrackID() << " , " << theTrack->GetParentID() << " , "
110  << theTrack->GetDefinition()->GetParticleName() << " , "
111  << theTrack->GetVertexPosition() << " , "
112  << theTrack->GetLogicalVolumeAtVertex()->GetName() << " , " << currentPV->GetName()
113  << " , " << theTrack->GetGlobalTime();
114 #endif
115 
116  // if particle moves from interaction point or "backwards (halo)
117  const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
118  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
119  double zint = hitPoint.z();
120 
121  // Check if theTrack is a muon (if so, DO NOT use Shower Library)
122  G4int parCode = theTrack->GetDefinition()->GetPDGEncoding();
123  bool isHad = G4TrackToParticleID::isStableHadronIon(theTrack);
124 
125  double meanNCherPhot = 0;
126  G4double charge = preStepPoint->GetCharge();
127  // VI: no Cerenkov light from neutrals
128  if (0.0 == charge) {
129  return meanNCherPhot;
130  }
131 
132  G4double beta = preStepPoint->GetBeta();
133  const double bThreshold = 0.67;
134  // VI: no Cerenkov light from non-relativistic particles
135  if (beta < bThreshold) {
136  return meanNCherPhot;
137  }
138 
139  // remember primary particle hitting the CASTOR detector
140  TrackInformationExtractor TIextractor;
141  TrackInformation& trkInfo = TIextractor(theTrack);
142  if (!trkInfo.hasCastorHit()) {
143  trkInfo.setCastorHitPID(parCode);
144  }
145  G4double stepl = aStep->GetStepLength() / cm;
146 
147  //int castorHitPID = trkInfo.hasCastorHit() ? std::abs(trkInfo.getCastorHitPID())
148  // : std::abs(parCode);
149 
150  // *************************************************
151  // take into account light collection curve for plate
152  // double weight = curve_Castor(nameVolume, preStepPoint);
153  // double edep = aStep->GetTotalEnergyDeposit() * weight;
154  // *************************************************
155 
156  // *************************************************
157  /* comments for sensitive volumes:
158  C001 ...-... CP06,CBU1 ...-...CALM --- > fibres and bundle
159  for first release of CASTOR
160  CASF --- > quartz plate for first and second releases of CASTOR
161  GF2Q, GFNQ, GR2Q, GRNQ
162  for tests with my own test geometry of HF (on ask of Gavrilov)
163  C3TF, C4TF - for third release of CASTOR
164  */
165 #ifdef debugLog
166  edm::LogVerbatim("ForwardSim") << "CastorSD::getEnergyDeposit: for ID=" << theTrack->GetTrackID()
167  << " LV: " << currentLV->GetName() << " isHad:" << isHad << " pdg=" << parCode
168  << " castorPID=" << trkInfo.getCastorHitPID() << " sl= " << stepl
169  << " Edep= " << aStep->GetTotalEnergyDeposit();
170 #endif
171  if (currentLV == lvC3EF || currentLV == lvC4EF || currentLV == lvC3HF || currentLV == lvC4HF) {
172  const double nMedium = 1.4925;
173  // double photEnSpectrDL = (1./400.nm-1./700.nm)*10000000.cm/nm; /* cm-1 */
174  // double photEnSpectrDL = 10714.285714;
175 
176  const double photEnSpectrDE = 1.24; /* see below */
177  /* E = 2pi*(1./137.)*(eV*cm/370.)/lambda = */
178  /* = 12.389184*(eV*cm)/lambda */
179  /* Emax = 12.389184*(eV*cm)/400nm*10-7cm/nm = 3.01 eV */
180  /* Emin = 12.389184*(eV*cm)/700nm*10-7cm/nm = 1.77 eV */
181  /* delE = Emax - Emin = 1.24 eV --> */
182  /* */
183  /* default for Castor nameVolume == "CASF" or (C3TF & C4TF) */
184 
185  const double thFullRefl = 23.; /* 23.dergee */
186  const double thFullReflRad = thFullRefl * pi / 180.;
187 
188  /* default for Castor nameVolume == "CASF" or (C3TF & C4TF) */
189  const double thFibDir = 45.; /* .dergee */
190  /* for test HF geometry volumes:
191  if(nameVolume == "GF2Q" || nameVolume == "GFNQ" ||
192  nameVolume == "GR2Q" || nameVolume == "GRNQ")
193  thFibDir = 0.0; // .dergee
194  */
195  const double thFibDirRad = thFibDir * pi / 180.;
196 
197  // theta of charged particle in LabRF(hit momentum direction):
198  double costh =
199  hit_mom.z() / sqrt(hit_mom.x() * hit_mom.x() + hit_mom.y() * hit_mom.y() + hit_mom.z() * hit_mom.z());
200  if (zint < 0)
201  costh = -costh;
202  double th = acos(std::min(std::max(costh, double(-1.)), double(1.)));
203 
204  // just in case (can do bot use):
205  if (th < 0.)
206  th += twopi;
207 
208  // theta of cone with Cherenkov photons w.r.t.direction of charged part.:
209  double costhcher = 1. / (nMedium * beta);
210  double thcher = acos(std::min(std::max(costhcher, double(-1.)), double(1.)));
211 
212  // diff thetas of charged part. and quartz direction in LabRF:
213  double DelFibPart = std::abs(th - thFibDirRad);
214 
215  // define real distances:
216  double d = std::abs(tan(th) - tan(thFibDirRad));
217 
218  double a = tan(thFibDirRad) + tan(std::abs(thFibDirRad - thFullReflRad));
219  double r = tan(th) + tan(std::abs(th - thcher));
220 
221  // define losses d_qz in cone of full reflection inside quartz direction
222  double d_qz;
223 #ifdef debugLog
224  int variant(0);
225 #endif
226  if (DelFibPart > (thFullReflRad + thcher)) {
227  d_qz = 0.;
228  } else {
229  if ((th + thcher) < (thFibDirRad + thFullReflRad) && (th - thcher) > (thFibDirRad - thFullReflRad)) {
230  d_qz = 1.;
231 #ifdef debugLog
232  variant = 1;
233 #endif
234  } else {
235  if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher)) {
236  d_qz = 0.;
237 #ifdef debugLog
238  variant = 2;
239 #endif
240  } else {
241 #ifdef debugLog
242  variant = 3;
243 #endif
244  // use crossed length of circles(cone projection)
245  // dC1/dC2 :
246  double arg_arcos = 0.;
247  double tan_arcos = 2. * a * d;
248  if (tan_arcos != 0.)
249  arg_arcos = (r * r - a * a - d * d) / tan_arcos;
250  arg_arcos = std::abs(arg_arcos);
251  double th_arcos = acos(std::min(std::max(arg_arcos, -1.), 1.));
252  d_qz = std::abs(th_arcos / CLHEP::twopi);
253  }
254  }
255  }
256 
257  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
258 
259  meanNCherPhot = 370. * charge * charge * (1. - 1. / (nMedium * nMedium * beta * beta)) * photEnSpectrDE * stepl;
260 
261  double scale = isHad ? non_compensation_factor : 1.0;
262 
263  int poissNCherPhot = std::max(0, (int)G4Poisson(meanNCherPhot * scale));
264 
265  const double effPMTandTransport = 0.19;
266  const double ReflPower = 0.1;
267  double proba = d_qz + (1 - d_qz) * ReflPower;
268  NCherPhot = poissNCherPhot * effPMTandTransport * proba * 0.307;
269 #ifdef debugLog
270  edm::LogVerbatim("ForwardSim") << " Nph= " << NCherPhot << " Np= " << poissNCherPhot
271  << " eff= " << effPMTandTransport << " pb= " << proba << " Nmean= " << meanNCherPhot
272  << " q=" << charge << " beta=" << beta << " nMedium= " << nMedium << " sl= " << stepl
273  << " Nde=" << photEnSpectrDE;
274 #endif
275  }
276  return NCherPhot;
277 }

References a, funct::abs(), zMuMuMuonUserData::beta, ALCARECOTkAlJpsiMuMu_cff::charge, ztail::d, TrackInformation::getCastorHitPID(), TrackInformation::hasCastorHit(), G4TrackToParticleID::isStableHadronIon(), lvC3EF, lvC3HF, lvC4EF, lvC4HF, SiStripPI::max, min(), non_compensation_factor, pi, alignCSCRings::r, Scenarios_cff::scale, TrackInformation::setCastorHitPID(), mathSSE::sqrt(), and funct::tan().

◆ getFromLibrary()

bool CastorSD::getFromLibrary ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 359 of file CastorSD.cc.

359  {
361  //
362  // Method to get hits from the Shower Library
363  //
364  // "updateHit" save the Hits to a CaloG4Hit container
365  //
367 
368  auto const theTrack = aStep->GetTrack();
369  auto parCode = theTrack->GetDefinition()->GetPDGEncoding();
370 
371  // remember primary particle hitting the CASTOR detector
372  TrackInformationExtractor TIextractor;
373  TrackInformation& trkInfo = TIextractor(theTrack);
374  if (!trkInfo.hasCastorHit()) {
375  trkInfo.setCastorHitPID(parCode);
376  }
377 
378  if (!useShowerLibrary) {
379  return false;
380  }
381 
382  // preStepPoint information *********************************************
383 
384  auto const preStepPoint = aStep->GetPreStepPoint();
385  auto const currentPV = preStepPoint->GetPhysicalVolume();
386  auto const currentLV = currentPV->GetLogicalVolume();
387 
388 #ifdef debugLog
389  edm::LogVerbatim("ForwardSim") << "CastorSD::getFromLibrary: for ID=" << theTrack->GetTrackID()
390  << " parentID= " << theTrack->GetParentID() << " "
391  << theTrack->GetDefinition()->GetParticleName() << " LV: " << currentLV->GetName()
392  << " PV: " << currentPV->GetName() << "\n eta= " << theTrack->GetPosition().eta()
393  << " phi= " << theTrack->GetPosition().phi()
394  << " z(cm)= " << theTrack->GetPosition().z() / cm
395  << " time(ns)= " << theTrack->GetGlobalTime()
396  << " E(GeV)= " << theTrack->GetTotalEnergy() / GeV;
397 
398 #endif
399 
400  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
401  const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
402  double zint = hitPoint.z();
403  double pz = hit_mom.z();
404 
405  // Check if theTrack moves backward
406  bool backward = (pz * zint < 0.) ? true : false;
407 
408  // Check that theTrack is above the energy threshold to use Shower Library
409  bool aboveThreshold = (theTrack->GetKineticEnergy() > energyThresholdSL) ? true : false;
410 
411  // Check if theTrack is a muon (if so, DO NOT use Shower Library)
413  bool isHad = G4TrackToParticleID::isStableHadronIon(theTrack);
414 
415  // angle condition
416  double theta_max = M_PI - 3.1305; // angle in radians corresponding to -5.2 eta
417  double R_mom = sqrt(hit_mom.x() * hit_mom.x() + hit_mom.y() * hit_mom.y());
418  double theta = atan2(R_mom, std::abs(pz));
419  bool angleok = (theta < theta_max) ? true : false;
420 
421  // OkToUse
422  double R = sqrt(hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y());
423  bool dot = (zint < -14450. && R < 45.) ? true : false;
424  bool inRange = (zint < -14700. || R > 193.) ? false : true;
425  //bool OkToUse = (inRange && !dot) ? true : false;
426 
427  bool particleWithinShowerLibrary =
428  aboveThreshold && (isEM || isHad) && (!backward) && inRange && !dot && angleok && currentLV == lvCAST;
429 
430 #ifdef debugLog
431  edm::LogVerbatim("ForwardSim") << "CastorSD::getFromLibrary: ID= " << theTrack->GetTrackID() << " E>E0 "
432  << aboveThreshold << " isEM " << isEM << " isHad " << isHad << " backword " << backward
433  << " Ok " << (inRange && !dot) << " angle " << angleok
434  << " LV: " << currentLV->GetName() << " " << (currentLV == lvCAST) << " "
435  << particleWithinShowerLibrary << " Edep= " << aStep->GetTotalEnergyDeposit();
436 #endif
437 
438  // Use Castor shower library if energy is above threshold, is not a muon
439  // and is not moving backward
440  if (!particleWithinShowerLibrary) {
441  return false;
442  }
443 
444  // **** Call method to retrieve hits from the ShowerLibrary ****
445  // always kill primary
446  bool isKilled(true);
448 
449  int primaryID = setTrackID(aStep);
450 
451  // Reset entry point for new primary
452  resetForNewPrimary(aStep);
453 
454 #ifdef debugLog
455  edm::LogVerbatim("ForwardSim") << "CastorSD::getFromLibrary: " << hits.getNhit() << " hits for " << GetName()
456  << " from " << theTrack->GetDefinition()->GetParticleName() << " of "
457  << preStepPoint->GetKineticEnergy() / GeV << " GeV and trackID "
458  << theTrack->GetTrackID() << " isHad: " << isHad;
459 #endif
460 
461  // Scale to correct energy
462  double E_track = preStepPoint->GetTotalEnergy();
463  double E_SLhit = hits.getPrimE() * CLHEP::GeV;
464  double scale = E_track / E_SLhit;
465 
466  //Non compensation
467  if (isHad) {
468  scale *= non_compensation_factor; // if hadronic extend the scale with the non-compensation factor
469  }
470  // Loop over hits retrieved from the library
471  for (unsigned int i = 0; i < hits.getNhit(); ++i) {
472  // Get nPhotoElectrons and set edepositEM / edepositHAD accordingly
473  double nPhotoElectrons = hits.getNphotons(i) * scale;
474 
475  if (isEM) {
476  edepositEM = nPhotoElectrons;
477  edepositHAD = 0.;
478  } else {
479  edepositEM = 0.;
480  edepositHAD = nPhotoElectrons;
481  }
482 
483  // Get hit position and time
484  double time = hits.getTime(i);
485 
486  // Get hit detID
487  unsigned int unitID = hits.getDetID(i);
488 
489  // Make the detID "rotation" from one sector to another taking into account the
490  // sectors of the impinging particle (theTrack) and of the particle that produced
491  // the 'hits' retrieved from shower library
492  unsigned int rotatedUnitID = rotateUnitID(unitID, theTrack, hits);
493  currentID.setID(rotatedUnitID, time, primaryID, 0);
494  processHit(aStep);
495  } // End of loop over hits
496  return isKilled;
497 }

References funct::abs(), CaloSD::currentID, dot(), CaloSD::edepositEM, CaloSD::edepositHAD, energyThresholdSL, funct::false, CastorShowerLibrary::getShowerHits(), GeV, TrackInformation::hasCastorHit(), hfClusterShapes_cfi::hits, mps_fire::i, G4TrackToParticleID::isGammaElectronPositron(), G4TrackToParticleID::isStableHadronIon(), lvCAST, M_PI, non_compensation_factor, CaloSD::processHit(), dttmaxenums::R, CaloSD::resetForNewPrimary(), rotateUnitID(), Scenarios_cff::scale, TrackInformation::setCastorHitPID(), CaloHitID::setID(), CaloSD::setTrackID(), showerLibrary, mathSSE::sqrt(), theta(), ntuplemaker::time, funct::true, and useShowerLibrary.

◆ rotateUnitID()

uint32_t CastorSD::rotateUnitID ( uint32_t  unitID,
const G4Track *  track,
const CastorShowerEvent shower 
)
private

Definition at line 297 of file CastorSD.cc.

297  {
298  // ==============================================================
299  //
300  // o Exploit Castor phi symmetry to return newUnitID for
301  // shower hits based on track phi coordinate
302  //
303  // ==============================================================
304 
305  // Get 'track' phi:
306  double trackPhi = track->GetPosition().phi();
307  if (trackPhi < 0)
308  trackPhi += 2 * M_PI;
309  // Get phi from primary that gave rise to SL 'shower':
310  double showerPhi = shower.getPrimPhi();
311  if (showerPhi < 0)
312  showerPhi += 2 * M_PI;
313  // Delta phi:
314 
315  // Find the OctSector for which 'track' and 'shower' belong
316  int trackOctSector = (int)(trackPhi / (M_PI / 4));
317  int showerOctSector = (int)(showerPhi / (M_PI / 4));
318 
319  uint32_t newUnitID;
320  uint32_t sec = ((unitID >> 4) & 0xF);
321  uint32_t complement = (unitID & 0xFFFFFF0F);
322 
323  // Get 'track' z:
324  double trackZ = track->GetPosition().z();
325 
326  int aux;
327  int dSec = 2 * (trackOctSector - showerOctSector);
328  if (trackZ > 0) // Good for revision 1.9 of CastorNumberingScheme
329  {
330  int sec1 = sec - dSec;
331  // sec -= dSec ;
332  if (sec1 < 0)
333  sec1 += 16;
334  if (sec1 > 15)
335  sec1 -= 16;
336  sec = (uint32_t)(sec1);
337  } else {
338  if (dSec < 0)
339  sec += 16;
340  sec += dSec;
341  aux = (int)(sec / 16);
342  sec -= aux * 16;
343  }
344  sec = sec << 4;
345  newUnitID = complement | sec;
346 
347 #ifdef debugLog
348  if (newUnitID != unitID) {
349  LogDebug("ForwardSim") << "\n CastorSD::rotateUnitID: "
350  << "\n unitID = " << unitID << "\n newUnitID = " << newUnitID;
351  }
352 #endif
353 
354  return newUnitID;
355 }

References printConversionInfo::aux, CastorShowerEvent::getPrimPhi(), createfilelist::int, LogDebug, M_PI, fileinputsource_cfi::sec, HLT_2018_cff::track, and reco::btau::trackPhi.

Referenced by getFromLibrary().

◆ setDetUnitId()

uint32_t CastorSD::setDetUnitId ( const G4Step *  step)
overridevirtual

Implements CaloSD.

Definition at line 281 of file CastorSD.cc.

281  {
282  return (numberingScheme == nullptr ? 0 : numberingScheme->getUnitID(aStep));
283 }

References CastorNumberingScheme::getUnitID(), and numberingScheme.

◆ setNumberingScheme()

void CastorSD::setNumberingScheme ( CastorNumberingScheme scheme)

Definition at line 287 of file CastorSD.cc.

287  {
288  if (scheme != nullptr) {
289  edm::LogVerbatim("ForwardSim") << "CastorSD: updates numbering scheme for " << GetName();
290  delete numberingScheme;
292  }
293 }

References numberingScheme, and generator_cfi::scheme.

Referenced by CastorSD().

Member Data Documentation

◆ energyThresholdSL

double CastorSD::energyThresholdSL
private

Definition at line 53 of file CastorSD.h.

Referenced by CastorSD(), and getFromLibrary().

◆ lvC3EF

G4LogicalVolume* CastorSD::lvC3EF
private

Definition at line 49 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

◆ lvC3HF

G4LogicalVolume * CastorSD::lvC3HF
private

Definition at line 49 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

◆ lvC4EF

G4LogicalVolume * CastorSD::lvC4EF
private

Definition at line 49 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

◆ lvC4HF

G4LogicalVolume * CastorSD::lvC4HF
private

Definition at line 49 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

◆ lvCAST

G4LogicalVolume* CastorSD::lvCAST
private

Definition at line 50 of file CastorSD.h.

Referenced by CastorSD(), and getFromLibrary().

◆ non_compensation_factor

double CastorSD::non_compensation_factor
private

Definition at line 54 of file CastorSD.h.

Referenced by CastorSD(), getEnergyDeposit(), and getFromLibrary().

◆ numberingScheme

CastorNumberingScheme* CastorSD::numberingScheme
private

Definition at line 47 of file CastorSD.h.

Referenced by setDetUnitId(), and setNumberingScheme().

◆ showerLibrary

CastorShowerLibrary* CastorSD::showerLibrary
private

Definition at line 48 of file CastorSD.h.

Referenced by CastorSD(), getFromLibrary(), and ~CastorSD().

◆ useShowerLibrary

bool CastorSD::useShowerLibrary
private

Definition at line 52 of file CastorSD.h.

Referenced by CastorSD(), and getFromLibrary().

dot
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
Definition: Basic3DVectorLD.h:212
CastorSD::non_compensation_factor
double non_compensation_factor
Definition: CastorSD.h:54
CaloSD::edepositHAD
float edepositHAD
Definition: CaloSD.h:129
mps_fire.i
i
Definition: mps_fire.py:355
funct::false
false
Definition: Factorize.h:34
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
min
T min(T a, T b)
Definition: MathUtil.h:58
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CastorNumberingScheme::getUnitID
virtual uint32_t getUnitID(const G4Step *aStep) const
Definition: CastorNumberingScheme.cc:86
CastorSD::useShowerLibrary
bool useShowerLibrary
Definition: CastorSD.h:52
CaloSD::edepositEM
float edepositEM
Definition: CaloSD.h:129
CastorShowerLibrary::getShowerHits
CastorShowerEvent getShowerHits(const G4Step *, bool &)
Definition: CastorShowerLibrary.cc:190
G4TrackToParticleID::isGammaElectronPositron
static bool isGammaElectronPositron(int pdgCode)
Definition: G4TrackToParticleID.cc:17
CaloSD::setTrackID
virtual int setTrackID(const G4Step *)
Definition: CaloSD.cc:592
CastorSD::numberingScheme
CastorNumberingScheme * numberingScheme
Definition: CastorSD.h:47
CaloHitID::setID
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
TrackInformationExtractor
Definition: TrackInformationExtractor.h:20
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CastorSD::lvC4HF
G4LogicalVolume * lvC4HF
Definition: CastorSD.h:49
CastorSD::lvC3HF
G4LogicalVolume * lvC3HF
Definition: CastorSD.h:49
CaloSD::processHit
void processHit(const G4Step *step)
Definition: CaloSD.h:103
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
CastorShowerEvent::getPrimPhi
float getPrimPhi() const
Definition: CastorShowerEvent.h:57
CaloSD::currentID
CaloHitID currentID
Definition: CaloSD.h:131
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
funct::true
true
Definition: Factorize.h:173
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
CastorSD::rotateUnitID
uint32_t rotateUnitID(uint32_t, const G4Track *, const CastorShowerEvent &)
Definition: CastorSD.cc:297
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
a
double a
Definition: hdecay.h:119
CastorNumberingScheme
Definition: CastorNumberingScheme.h:30
CastorSD::lvC3EF
G4LogicalVolume * lvC3EF
Definition: CastorSD.h:49
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
CastorShowerEvent
Definition: CastorShowerEvent.h:15
GeV
const double GeV
Definition: MathUtil.h:16
TrackInformation::getCastorHitPID
int getCastorHitPID() const
Definition: TrackInformation.h:71
reco::btau::trackPhi
Definition: TaggingVariable.h:43
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
TrackInformation
Definition: TrackInformation.h:8
createfilelist.int
int
Definition: createfilelist.py:10
CaloSD::CaloSD
CaloSD(const std::string &aSDname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:27
CastorSD::energyThresholdSL
double energyThresholdSL
Definition: CastorSD.h:53
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
edm::LogVerbatim
Definition: MessageLogger.h:297
CaloSD::resetForNewPrimary
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:422
CastorSD::showerLibrary
CastorShowerLibrary * showerLibrary
Definition: CastorSD.h:48
TrackInformation::hasCastorHit
bool hasCastorHit() const
Definition: TrackInformation.h:66
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
generator_cfi.scheme
scheme
Definition: generator_cfi.py:22
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CastorSD::lvC4EF
G4LogicalVolume * lvC4EF
Definition: CastorSD.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
G4TrackToParticleID::isStableHadronIon
static bool isStableHadronIon(const G4Track *)
Definition: G4TrackToParticleID.cc:40
CaloSD::setParameterized
void setParameterized(bool val)
Definition: CaloSD.h:100
CastorSD::lvCAST
G4LogicalVolume * lvCAST
Definition: CastorSD.h:50
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
g4SimHits_cfi.CastorShowerLibrary
CastorShowerLibrary
Definition: g4SimHits_cfi.py:432
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
CastorSD::setNumberingScheme
void setNumberingScheme(CastorNumberingScheme *scheme)
Definition: CastorSD.cc:287
ztail.d
d
Definition: ztail.py:151
pi
const Double_t pi
Definition: trackSplitPlot.h:36
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ntuplemaker.time
time
Definition: ntuplemaker.py:310
TrackInformation::setCastorHitPID
void setCastorHitPID(const int pid)
Definition: TrackInformation.h:67
dttmaxenums::R
Definition: DTTMax.h:29