CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
CaloSD Class Referenceabstract

#include <CaloSD.h>

Inheritance diagram for CaloSD:
SensitiveCaloDetector Observer< const BeginOfRun *> Observer< const BeginOfEvent *> Observer< const BeginOfTrack *> Observer< const EndOfTrack *> Observer< const EndOfEvent *> SensitiveDetector AHCalSD CastorSD DreamSD ECalSD EcalTBH4BeamSD HCalSD HcalTB02SD HcalTB06BeamSD HFNoseSD HGCalSD HGCalTB16SD01 HGCScintSD HGCSD TotemT2ScintSD ZdcSD

Classes

struct  Detector
 

Public Member Functions

 CaloSD (const std::string &aSDname, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false, const std::string &newcolname="")
 
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
 
bool isItFineCalo (const G4VTouchable *touch)
 
void newCollection (const std::string &name, edm::ParameterSet const &p)
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *) override
 
bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *) override
 
void reset () override
 
uint32_t setDetUnitId (const G4Step *step) override=0
 
 ~CaloSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (const std::string &iname, const SensitiveDetectorCatalog &clg, const std::string &newcollname="")
 
- 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 SensitiveDetectorCatalog &, bool calo, const std::string &newcollname="")
 
 ~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

bool checkHit (int k=0)
 
CaloG4HitcreateNewHit (const G4Step *, const G4Track *, int k)
 
virtual void endEvent ()
 
virtual double EnergyCorrected (const G4Step &step, const G4Track *)
 
virtual bool filterHit (CaloG4Hit *, double)
 
unsigned int findBoundaryCrossingParent (const G4Track *track, bool markParentAsSaveable=true)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual uint16_t getDepth (const G4Step *)
 
virtual double getEnergyDeposit (const G4Step *step)
 
virtual bool getFromLibrary (const G4Step *step)
 
int getNumberOfHits (int k=0)
 
double getResponseWt (const G4Track *, int k=0)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *, int k)
 
void ignoreRejection ()
 
virtual void initEvent (const BeginOfEvent *)
 
virtual void initRun ()
 
void printDetectorLevels (const G4VTouchable *) const
 
void processHit (const G4Step *step)
 
virtual void processSecondHit (const G4Step *, const G4Track *)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val, int k=0)
 
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)
 
std::string shortreprID (const CaloHitID &ID)
 
std::string shortreprID (const CaloG4Hit *hit)
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) 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 update (const ::EndOfEvent *) override
 
void updateHit (CaloG4Hit *, int k)
 
- 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...
 

Static Protected Member Functions

static std::string printableDecayChain (const std::vector< unsigned int > &decayChain)
 

Protected Attributes

std::string collName_ [2]
 
CaloG4HitcurrentHit [2]
 
CaloHitID currentID [2]
 
std::string detName_
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
std::vector< std::string > hcn_
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
int nHC_
 
G4ThreeVector posGlobal
 
CaloHitID previousID [2]
 
bool suppressHeavy
 
double tmaxHit
 
std::vector< int > useResMap_
 

Private Member Functions

void cleanHitCollection ()
 
bool saveHit (CaloG4Hit *, int k=0)
 
void storeHit (CaloG4Hit *, int k=0)
 

Private Attributes

std::unordered_map< unsigned int, unsigned int > boundaryCrossingParentMap_
 
int cleanIndex [2]
 
double correctT
 
bool corrTOFBeam
 
bool doFineCalo_
 
bool doFineCaloThisStep_
 
double eMinFine_
 
double eminHitD
 
std::vector< DetectorfineDetectors_
 
int hcID [2]
 
std::map< CaloHitID, CaloG4Hit * > hitMap [2]
 
bool ignoreReject
 
bool ignoreTrackID
 
bool isParameterized
 
const SimTrackManagerm_trackManager
 
std::unique_ptr< CaloMeanResponsemeanResponse [2]
 
int nCheckedHits [2]
 
int primAncestor
 
int primIDSaved [2]
 
std::vector< std::unique_ptr< CaloG4Hit > > reusehit [2]
 
std::unique_ptr< CaloSlaveSDslave [2]
 
CaloG4HitCollectiontheHC [2]
 
float timeSlice
 
std::map< int, TrackWithHistory * > tkMap
 
int totalHits [2]
 
bool useMap
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Detailed Description

Definition at line 40 of file CaloSD.h.

Constructor & Destructor Documentation

◆ CaloSD()

CaloSD::CaloSD ( const std::string &  aSDname,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager,
float  timeSlice = 1.,
bool  ignoreTkID = false,
const std::string &  newcolname = "" 
)

Definition at line 34 of file CaloSD.cc.

References cleanIndex, collName_, correctT, corrTOFBeam, currentHit, currentID, hgcalTestNeighbor_cfi::detector, detName_, doFineCalo_, edepositEM, edepositHAD, eMinFine_, eminHit, eminHitD, energyCut, entranceLocal, entrancePoint, fineDetectors_, forceSave, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hcID, hcn_, mps_fire::i, ignoreTrackID, incidentEnergy, isParameterized, dqmdumpme::k, kmaxIon, kmaxNeutron, kmaxProton, personalPlayback::level, meanResponse, Skims_PA_cff::name, DD4hep2DDDName::nameMatterLV(), nCheckedHits, nHC_, AlCaHLTBitMon_ParallelJobs::p, posGlobal, previousID, primAncestor, primIDSaved, reset(), slave, suppressHeavy, theHC, timeSlice, tmaxHit, totalHits, useMap, and useResMap_.

41  : SensitiveCaloDetector(name, clg, newcollName),
42  G4VGFlashSensitiveDetector(),
43  eminHit(0.),
44  m_trackManager(manager),
45  ignoreTrackID(ignoreTkID),
46  timeSlice(timeSliceUnit),
47  eminHitD(0.) {
48  //Parameters
49  nHC_ = (newcollName.empty()) ? 1 : 2;
50  for (int k = 0; k < 2; ++k) {
51  currentHit[k] = nullptr;
52  theHC[k] = nullptr;
53  hcID[k] = -1;
54  }
55  bool dd4hep = p.getParameter<bool>("g4GeometryDD4hepSource");
56  int addlevel = dd4hep ? 1 : 0;
57  edm::ParameterSet m_CaloSD = p.getParameter<edm::ParameterSet>("CaloSD");
58  energyCut = m_CaloSD.getParameter<double>("EminTrack") * CLHEP::GeV;
59  tmaxHit = m_CaloSD.getParameter<double>("TmaxHit") * CLHEP::ns;
60  std::vector<double> eminHits = m_CaloSD.getParameter<std::vector<double>>("EminHits");
61  std::vector<double> tmaxHits = m_CaloSD.getParameter<std::vector<double>>("TmaxHits");
62  hcn_ = m_CaloSD.getParameter<std::vector<std::string>>("HCNames");
63  useResMap_ = m_CaloSD.getParameter<std::vector<int>>("UseResponseTables");
64  std::vector<double> eminHitX = m_CaloSD.getParameter<std::vector<double>>("EminHitsDepth");
65  suppressHeavy = m_CaloSD.getParameter<bool>("SuppressHeavy");
66  kmaxIon = m_CaloSD.getParameter<double>("IonThreshold") * CLHEP::MeV;
67  kmaxProton = m_CaloSD.getParameter<double>("ProtonThreshold") * CLHEP::MeV;
68  kmaxNeutron = m_CaloSD.getParameter<double>("NeutronThreshold") * CLHEP::MeV;
69  nCheckedHits[0] = m_CaloSD.getUntrackedParameter<int>("CheckHits", 25);
70  nCheckedHits[1] = nCheckedHits[0];
71  useMap = m_CaloSD.getUntrackedParameter<bool>("UseMap", true);
72  int verbn = m_CaloSD.getUntrackedParameter<int>("Verbosity", 0);
73  corrTOFBeam = m_CaloSD.getParameter<bool>("CorrectTOFBeam");
74  double beamZ = m_CaloSD.getParameter<double>("BeamPosition") * CLHEP::cm;
75  correctT = beamZ / CLHEP::c_light / CLHEP::nanosecond;
76  doFineCalo_ = m_CaloSD.getParameter<bool>("DoFineCalo");
77  eMinFine_ = m_CaloSD.getParameter<double>("EminFineTrack") * CLHEP::MeV;
78  std::vector<std::string> fineNames = m_CaloSD.getParameter<std::vector<std::string>>("FineCaloNames");
79  std::vector<int> fineLevels = m_CaloSD.getParameter<std::vector<int>>("FineCaloLevels");
80  std::vector<int> useFines = m_CaloSD.getParameter<std::vector<int>>("UseFineCalo");
81  for (auto& level : fineLevels)
82  level += addlevel;
83 
84  SetVerboseLevel(verbn);
85  for (int k = 0; k < 2; ++k)
86  meanResponse[k].reset(nullptr);
87  for (unsigned int k = 0; k < hcn_.size(); ++k) {
88  if (name == hcn_[k]) {
89  if (k < eminHits.size())
90  eminHit = eminHits[k] * CLHEP::MeV;
91  if (k < eminHitX.size())
92  eminHitD = eminHitX[k] * CLHEP::MeV;
93  if (k < tmaxHits.size())
94  tmaxHit = tmaxHits[k] * CLHEP::ns;
95  if (k < useResMap_.size() && useResMap_[k] > 0) {
96  meanResponse[0] = std::make_unique<CaloMeanResponse>(p);
97  break;
98  }
99  }
100  }
101  detName_ = name;
102  collName_[0] = name;
103  collName_[1] = newcollName;
104  slave[0] = std::make_unique<CaloSlaveSD>(name);
105  slave[1].reset(nullptr);
106 
107  for (int k = 0; k < 2; ++k) {
110  }
111  isParameterized = false;
112 
113  entrancePoint.set(0., 0., 0.);
114  entranceLocal.set(0., 0., 0.);
115  posGlobal.set(0., 0., 0.);
117 
118  primAncestor = 0;
119  forceSave = false;
120  for (int k = 0; k < 2; ++k) {
121  cleanIndex[k] = primIDSaved[k] = totalHits[k] = 0;
122  }
123 
124  edm::LogVerbatim("CaloSim") << "CaloSD: Minimum energy of track for saving it " << energyCut / CLHEP::GeV
125  << " GeV\n Use of HitID Map " << useMap << "\n Check last "
126  << nCheckedHits[0] << " before saving the hit\n Correct TOF globally by "
127  << correctT << " ns (Flag =" << corrTOFBeam << ")\n Save hits recorded before "
128  << tmaxHit << " ns and if energy is above " << eminHit / CLHEP::MeV
129  << " MeV (for depth 0) or " << eminHitD / CLHEP::MeV
130  << " MeV (for nonzero depths);\n Time Slice Unit " << timeSlice
131  << "\nIgnore TrackID Flag " << ignoreTrackID << " doFineCalo flag " << doFineCalo_
132  << "\nBeam Position " << beamZ / CLHEP::cm << " cm";
133  if (doFineCalo_)
134  edm::LogVerbatim("DoFineCalo") << "Using finecalo v2";
135 
136  // Treat fine calorimeters
137  edm::LogVerbatim("CaloSim") << "CaloSD: Have a possibility of " << fineNames.size() << " fine calorimeters of which "
138  << useFines.size() << " are selected";
139  for (unsigned int k = 0; k < fineNames.size(); ++k)
140  edm::LogVerbatim("CaloSim") << "[" << k << "] " << fineNames[k] << " at " << fineLevels[k];
141  std::ostringstream st1;
142  for (unsigned int k = 0; k < useFines.size(); ++k)
143  st1 << " [" << k << "] " << useFines[k] << ":" << fineNames[useFines[k]];
144  edm::LogVerbatim("CaloSim") << "CaloSD used calorimeters" << st1.str();
145  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
146  std::vector<G4LogicalVolume*>::const_iterator lvcite;
147  for (unsigned int i = 0; i < useFines.size(); i++) {
148  G4LogicalVolume* lv = nullptr;
149  G4String name = static_cast<G4String>(fineNames[useFines[i]]);
150  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
151  G4String namx(static_cast<G4String>(DD4hep2DDDName::nameMatterLV((*lvcite)->GetName(), dd4hep)));
152  if (namx == name) {
153  lv = (*lvcite);
154  break;
155  }
156  }
157  if (lv != nullptr) {
159  detector.name = name;
160  detector.lv = lv;
161  detector.level = fineLevels[useFines[i]];
162  fineDetectors_.emplace_back(detector);
163  }
164  }
165 #ifdef EDM_ML_DEBUG
166  edm::LogVerbatim("CaloSim") << "CaloSD::Loads information for " << fineDetectors_.size() << " fine detectors";
167  unsigned int k(0);
168  for (const auto& detector : fineDetectors_) {
169  edm::LogVerbatim("CaloSim") << "Detector[" << k << "] " << detector.name << " at level " << detector.level
170  << " pointer to LV: " << detector.lv;
171  }
172 #endif
173 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
float edepositEM
Definition: CaloSD.h:144
double energyCut
Definition: CaloSD.h:148
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double kmaxNeutron
Definition: CaloSD.h:155
double eMinFine_
Definition: CaloSD.h:193
bool corrTOFBeam
Definition: CaloSD.h:180
bool useMap
Definition: CaloSD.h:179
double eminHitD
Definition: CaloSD.h:190
int nCheckedHits[2]
Definition: CaloSD.h:187
G4ThreeVector posGlobal
Definition: CaloSD.h:142
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int primAncestor
Definition: CaloSD.h:183
int cleanIndex[2]
Definition: CaloSD.h:184
std::vector< int > useResMap_
Definition: CaloSD.h:150
void reset() override
Definition: CaloSD.cc:862
double kmaxProton
Definition: CaloSD.h:155
std::vector< Detector > fineDetectors_
Definition: CaloSD.h:199
double eminHit
Definition: CaloSD.h:148
SensitiveCaloDetector(const std::string &iname, const SensitiveDetectorCatalog &clg, const std::string &newcollname="")
T getUntrackedParameter(std::string const &, T const &) const
int primIDSaved[2]
Definition: CaloSD.h:186
bool forceSave
Definition: CaloSD.h:157
int nHC_
Definition: CaloSD.h:158
float timeSlice
Definition: CaloSD.h:189
double kmaxIon
Definition: CaloSD.h:155
bool suppressHeavy
Definition: CaloSD.h:154
float edepositHAD
Definition: CaloSD.h:144
bool doFineCalo_
Definition: CaloSD.h:192
std::vector< std::string > hcn_
Definition: CaloSD.h:149
int totalHits[2]
Definition: CaloSD.h:185
CaloHitID previousID[2]
Definition: CaloSD.h:146
double tmaxHit
Definition: CaloSD.h:148
double correctT
Definition: CaloSD.h:191
float incidentEnergy
Definition: CaloSD.h:143
bool isParameterized
Definition: CaloSD.h:177
std::string detName_
Definition: CaloSD.h:159
CaloHitID currentID[2]
Definition: CaloSD.h:146
std::string collName_[2]
Definition: CaloSD.h:159
std::unique_ptr< CaloMeanResponse > meanResponse[2]
Definition: CaloSD.h:172
const SimTrackManager * m_trackManager
Definition: CaloSD.h:169
std::string nameMatterLV(const std::string &name, bool dd4hep)
int hcID[2]
Definition: CaloSD.h:182
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171
G4ThreeVector entrancePoint
Definition: CaloSD.h:140
G4ThreeVector entranceLocal
Definition: CaloSD.h:141
bool ignoreTrackID
Definition: CaloSD.h:176

◆ ~CaloSD()

CaloSD::~CaloSD ( )
override

Definition at line 175 of file CaloSD.cc.

175 {}

Member Function Documentation

◆ checkHit()

bool CaloSD::checkHit ( int  k = 0)
protected

Definition at line 489 of file CaloSD.cc.

References currentHit, currentID, mps_fire::end, newFWLiteAna::found, hitMap, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, dqmdumpme::k, SiStripPI::max, nCheckedHits, TrackingDataMCValidation_Standalone_cff::nhits, theHC, updateHit(), and useMap.

Referenced by hitExists(), processHit(), and ProcessHits().

489  {
490 #ifdef EDM_ML_DEBUG
491  edm::LogVerbatim("CaloSim") << "CaloSD: checkHit for " << k << " for map " << useMap << ":" << &hitMap[k] << " Nhits "
492  << nCheckedHits[k] << " HC " << theHC[k] << " ID " << currentID[k];
493 #endif
494  //look in the HitContainer whether a hit with the same ID already exists:
495  bool found = false;
496  if (useMap) {
497  std::map<CaloHitID, CaloG4Hit*>::const_iterator it = hitMap[k].find(currentID[k]);
498  if (it != hitMap[k].end()) {
499  currentHit[k] = it->second;
500  found = true;
501  }
502  } else if (nCheckedHits[k] > 0) {
503  int nhits = theHC[k]->entries();
504  int minhit = std::max(nhits - nCheckedHits[k], 0);
505  int maxhit = nhits - 1;
506 
507  for (int j = maxhit; j > minhit; --j) {
508  if ((*theHC[k])[j]->getID() == currentID[k]) {
509  currentHit[k] = (*theHC[k])[j];
510  found = true;
511  break;
512  }
513  }
514  }
515 
516  if (found) {
517  updateHit(currentHit[k], k);
518  }
519  return found;
520 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
Log< level::Info, true > LogVerbatim
std::map< CaloHitID, CaloG4Hit * > hitMap[2]
Definition: CaloSD.h:195
bool useMap
Definition: CaloSD.h:179
int nCheckedHits[2]
Definition: CaloSD.h:187
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:704
CaloHitID currentID[2]
Definition: CaloSD.h:146

◆ cleanHitCollection()

void CaloSD::cleanHitCollection ( )
private

Definition at line 1041 of file CaloSD.cc.

References cleanIndex, correctT, corrTOFBeam, relativeConstraints::empty, cond::serialization::equal(), filterHit(), CaloG4Hit::getTimeSlice(), hitMap, mps_fire::i, cuy::ii, dqmiolumiharvest::j, dqmdumpme::k, nHC_, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, reusehit, jetUpdater_cfi::sort, theHC, hcalRecHitTable_cff::time, totalHits, and useMap.

Referenced by EndOfEvent(), and update().

1041  {
1042  for (int k = 0; k < nHC_; ++k) {
1043  std::vector<CaloG4Hit*>* theCollection = theHC[k]->GetVector();
1044 
1045 #ifdef EDM_ML_DEBUG
1046  edm::LogVerbatim("CaloSim") << "CaloSD: collection before merging, size = " << theHC[k]->entries();
1047 #endif
1048  if (reusehit[k].empty())
1049  reusehit[k].reserve(theHC[k]->entries() - cleanIndex[k]);
1050 
1051  // if no map used, merge before hits to have the save situation as a map
1052  if (!useMap) {
1053  std::vector<CaloG4Hit*> hitvec;
1054 
1055  hitvec.swap(*theCollection);
1056  sort((hitvec.begin() + cleanIndex[k]), hitvec.end(), CaloG4HitLess());
1057 #ifdef EDM_ML_DEBUG
1058  edm::LogVerbatim("CaloSim") << "CaloSD::cleanHitCollection: sort hits in buffer starting from "
1059  << "element = " << cleanIndex[k];
1060  for (unsigned int i = 0; i < hitvec.size(); ++i) {
1061  if (hitvec[i] == nullptr)
1062  edm::LogVerbatim("CaloSim") << i << " has a null pointer";
1063  else
1064  edm::LogVerbatim("CaloSim") << i << " " << *hitvec[i];
1065  }
1066 #endif
1068  for (unsigned int i = cleanIndex[k]; i < hitvec.size(); ++i) {
1069  int jump = 0;
1070  for (unsigned int j = i + 1; j < hitvec.size() && equal(hitvec[i], hitvec[j]); ++j) {
1071  ++jump;
1072  // merge j to i
1073  (*hitvec[i]).addEnergyDeposit(*hitvec[j]);
1074  (*hitvec[j]).setEM(0.);
1075  (*hitvec[j]).setHadr(0.);
1076  reusehit[k].emplace_back(hitvec[j]);
1077  hitvec[j] = nullptr;
1078  }
1079  i += jump;
1080  }
1081 #ifdef EDM_ML_DEBUG
1082  edm::LogVerbatim("CaloSim") << "CaloSD: cleanHitCollection merge the hits in buffer ";
1083  for (unsigned int i = 0; i < hitvec.size(); ++i) {
1084  if (hitvec[i] == nullptr)
1085  edm::LogVerbatim("CaloSim") << i << " has a null pointer";
1086  else
1087  edm::LogVerbatim("CaloSim") << i << " " << *hitvec[i];
1088  }
1089 #endif
1090  //move all nullptr to end of list and then remove them
1091  hitvec.erase(std::stable_partition(
1092  hitvec.begin() + cleanIndex[k], hitvec.end(), [](CaloG4Hit* p) { return p != nullptr; }),
1093  hitvec.end());
1094 #ifdef EDM_ML_DEBUG
1095  edm::LogVerbatim("CaloSim") << "CaloSD::cleanHitCollection: remove the merged hits in buffer, new size = "
1096  << hitvec.size();
1097 #endif
1098  hitvec.swap(*theCollection);
1099  totalHits[k] = theHC[k]->entries();
1100  }
1101 
1102 #ifdef EDM_ML_DEBUG
1103  edm::LogVerbatim("CaloSim") << "CaloSD: collection after merging, size= " << theHC[k]->entries()
1104  << " Size of reusehit= " << reusehit[k].size()
1105  << "\n starting hit selection from index = " << cleanIndex[k];
1106 #endif
1107 
1108  int addhit = 0;
1109  for (unsigned int i = cleanIndex[k]; i < theCollection->size(); ++i) {
1110  CaloG4Hit* aHit((*theCollection)[i]);
1111 
1112  // selection
1113 
1114  double time = aHit->getTimeSlice();
1115  if (corrTOFBeam)
1116  time += correctT;
1117  if (!filterHit(aHit, time)) {
1118 #ifdef EDM_ML_DEBUG
1119  edm::LogVerbatim("CaloSim") << "CaloSD: dropped CaloG4Hit "
1120  << " " << *aHit;
1121 #endif
1122 
1123  // create the list of hits to be reused
1124 
1125  reusehit[k].emplace_back((*theCollection)[i]);
1126  (*theCollection)[i] = nullptr;
1127  ++addhit;
1128  }
1129  }
1130 
1131 #ifdef EDM_ML_DEBUG
1132  edm::LogVerbatim("CaloSim") << "CaloSD: Size of reusehit after selection = " << reusehit[k].size()
1133  << " Number of added hit = " << addhit;
1134 #endif
1135  if (useMap) {
1136  if (addhit > 0) {
1137  int offset = reusehit[k].size() - addhit;
1138  for (int ii = addhit - 1; ii >= 0; --ii) {
1139  CaloHitID theID = reusehit[k][offset + ii]->getID();
1140  hitMap[k].erase(theID);
1141  }
1142  }
1143  }
1144 
1145  //move all nullptr to end of list and then remove them
1146  theCollection->erase(
1147  std::stable_partition(
1148  theCollection->begin() + cleanIndex[k], theCollection->end(), [](CaloG4Hit* p) { return p != nullptr; }),
1149  theCollection->end());
1150 #ifdef EDM_ML_DEBUG
1151  edm::LogVerbatim("CaloSim") << "CaloSD: hit collection after selection, size = " << theHC[k]->entries();
1152  theHC[k]->PrintAllHits();
1153 #endif
1154 
1155  cleanIndex[k] = theHC[k]->entries();
1156  }
1157 }
Log< level::Info, true > LogVerbatim
std::map< CaloHitID, CaloG4Hit * > hitMap[2]
Definition: CaloSD.h:195
bool corrTOFBeam
Definition: CaloSD.h:180
bool useMap
Definition: CaloSD.h:179
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int cleanIndex[2]
Definition: CaloSD.h:184
bool equal(const T &first, const T &second)
Definition: Equal.h:32
int nHC_
Definition: CaloSD.h:158
std::vector< std::unique_ptr< CaloG4Hit > > reusehit[2]
Definition: CaloSD.h:198
int totalHits[2]
Definition: CaloSD.h:185
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:918
ii
Definition: cuy.py:589
double correctT
Definition: CaloSD.h:191

◆ clear()

void CaloSD::clear ( void  )
override

Definition at line 429 of file CaloSD.cc.

429 {}

◆ clearHits()

void CaloSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 849 of file CaloSD.cc.

References cleanIndex, dqmdumpme::k, nHC_, previousID, primIDSaved, CaloHitID::reset(), and slave.

Referenced by update().

849  {
850  for (int k = 0; k < nHC_; ++k) {
851  previousID[k].reset();
852  primIDSaved[k] = -99;
853  cleanIndex[k] = 0;
854 #ifdef EDM_ML_DEBUG
855  edm::LogVerbatim("CaloSim") << "CaloSD: Clears hit vector for " << GetName()
856  << " and initialise slave: " << slave[k].get()->name();
857 #endif
858  slave[k].get()->Initialize();
859  }
860 }
Log< level::Info, true > LogVerbatim
int cleanIndex[2]
Definition: CaloSD.h:184
void reset()
Definition: CaloHitID.cc:49
int primIDSaved[2]
Definition: CaloSD.h:186
int nHC_
Definition: CaloSD.h:158
CaloHitID previousID[2]
Definition: CaloSD.h:146
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ createNewHit()

CaloG4Hit * CaloSD::createNewHit ( const G4Step *  aStep,
const G4Track *  theTrack,
int  k 
)
protected

Definition at line 625 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), currentID, CaloHitID::depth(), doFineCaloThisStep_, edepositEM, edepositHAD, relativeConstraints::empty, energyCut, entranceLocal, entrancePoint, f, forceSave, getNumberOfHits(), incidentEnergy, isItFineCalo(), dqmdumpme::k, TrackWithHistory::momentum(), posGlobal, primIDSaved, reusehit, CaloG4Hit::setEM(), CaloG4Hit::setEntry(), CaloG4Hit::setEntryLocal(), CaloG4Hit::setHadr(), CaloG4Hit::setID(), CaloG4Hit::setIncidentEnergy(), CaloG4Hit::setPosition(), TrackInformation::setStoreTrack(), TrackWithHistory::setToBeSaved(), shortreprID(), mathSSE::sqrt(), storeHit(), CaloHitID::timeSliceID(), tkMap, totalHits, CaloHitID::trackID(), CaloHitID::unitID(), updateHit(), and useMap.

Referenced by processHit(), ZdcSD::ProcessHits(), ProcessHits(), and HGCalSD::processSecondHit().

625  {
626 #ifdef EDM_ML_DEBUG
627  edm::LogVerbatim("CaloSim") << "CaloSD::CreateNewHit " << getNumberOfHits() << " for " << GetName()
628  << " Unit:" << currentID[k].unitID() << " " << currentID[k].depth()
629  << " Edep= " << edepositEM << " " << edepositHAD
630  << " primaryID= " << currentID[k].trackID()
631  << " timeSlice= " << currentID[k].timeSliceID() << " ID= " << theTrack->GetTrackID()
632  << " " << theTrack->GetDefinition()->GetParticleName()
633  << " E(GeV)= " << theTrack->GetKineticEnergy() / CLHEP::GeV
634  << " parentID= " << theTrack->GetParentID() << "\n Ein= " << incidentEnergy
635  << " entranceGlobal: " << entrancePoint << " entranceLocal: " << entranceLocal
636  << " posGlobal: " << posGlobal;
637 #endif
638 
639  CaloG4Hit* aHit;
640  if (!reusehit[k].empty()) {
641  aHit = reusehit[k].back().release();
642  aHit->setEM(0.f);
643  aHit->setHadr(0.f);
644  reusehit[k].pop_back();
645  } else {
646  aHit = new CaloG4Hit;
647  }
648 
649  aHit->setID(currentID[k]);
650  aHit->setEntry(entrancePoint.x(), entrancePoint.y(), entrancePoint.z());
652  aHit->setPosition(posGlobal.x(), posGlobal.y(), posGlobal.z());
654  updateHit(aHit, k);
655 
656  storeHit(aHit, k);
657  TrackInformation* trkInfo = cmsTrackInformation(theTrack);
658 
659 #ifdef EDM_ML_DEBUG
661  edm::LogVerbatim("DoFineCalo") << "New hit " << shortreprID(aHit) << " using finecalo;"
662  << " isItFineCalo(post)=" << isItFineCalo(aStep->GetPostStepPoint()->GetTouchable())
663  << " isItFineCalo(pre)=" << isItFineCalo(aStep->GetPreStepPoint()->GetTouchable());
664 #endif
665 
666  // 'Traditional', non-fine history bookkeeping
667  if (!doFineCaloThisStep_) {
668  double etrack = 0;
669  if (currentID[k].trackID() == primIDSaved[k]) { // The track is saved; nothing to be done
670  } else if (currentID[k].trackID() == theTrack->GetTrackID()) {
671  etrack = theTrack->GetKineticEnergy();
672 #ifdef EDM_ML_DEBUG
673  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID[k].trackID() << " etrack " << etrack
674  << " eCut " << energyCut << " force: " << forceSave
675  << " save: " << (etrack >= energyCut || forceSave);
676 #endif
677  if (etrack >= energyCut || forceSave) {
678  trkInfo->setStoreTrack();
679  }
680  } else {
682 #ifdef EDM_ML_DEBUG
683  edm::LogVerbatim("CaloSim") << "CaloSD : TrackWithHistory pointer for " << currentID[k].trackID() << " is "
684  << trkh;
685 #endif
686  if (trkh != nullptr) {
687  etrack = sqrt(trkh->momentum().Mag2());
688  if (etrack >= energyCut) {
689  trkh->setToBeSaved();
690 #ifdef EDM_ML_DEBUG
691  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID[k].trackID() << " with Hit";
692 #endif
693  }
694  }
695  }
697  }
698 
699  if (useMap)
700  ++totalHits[k];
701  return aHit;
702 }
float edepositEM
Definition: CaloSD.h:144
int getNumberOfHits(int k=0)
Definition: CaloSD.cc:522
double energyCut
Definition: CaloSD.h:148
Log< level::Info, true > LogVerbatim
void setStoreTrack()
can only be set to true, cannot be reset to false!
bool doFineCaloThisStep_
Definition: CaloSD.h:200
void setIncidentEnergy(double e)
Definition: CaloG4Hit.h:62
const math::XYZVectorD & momentum() const
void setEntryLocal(double x, double y, double z)
Definition: CaloG4Hit.h:50
bool useMap
Definition: CaloSD.h:179
G4ThreeVector posGlobal
Definition: CaloSD.h:142
int primIDSaved[2]
Definition: CaloSD.h:186
bool forceSave
Definition: CaloSD.h:157
int timeSliceID() const
Definition: CaloHitID.h:21
bool isItFineCalo(const G4VTouchable *touch)
Definition: CaloSD.cc:369
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:704
float edepositHAD
Definition: CaloSD.h:144
T sqrt(T t)
Definition: SSEVec.h:23
void setEM(double e)
Definition: CaloG4Hit.h:56
void setID(uint32_t i, double d, int j, uint16_t k=0)
Definition: CaloG4Hit.h:73
double f[11][100]
std::vector< std::unique_ptr< CaloG4Hit > > reusehit[2]
Definition: CaloSD.h:198
uint32_t unitID() const
Definition: CaloHitID.h:20
int totalHits[2]
Definition: CaloSD.h:185
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
void storeHit(CaloG4Hit *, int k=0)
Definition: CaloSD.cc:938
void setHadr(double e)
Definition: CaloG4Hit.h:59
float incidentEnergy
Definition: CaloSD.h:143
void setPosition(double x, double y, double z)
Definition: CaloG4Hit.h:53
void setEntry(double x, double y, double z)
Definition: CaloG4Hit.h:47
CaloHitID currentID[2]
Definition: CaloSD.h:146
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:196
std::string shortreprID(const CaloHitID &ID)
Definition: CaloSD.cc:539
int trackID() const
Definition: CaloHitID.h:23
G4ThreeVector entrancePoint
Definition: CaloSD.h:140
G4ThreeVector entranceLocal
Definition: CaloSD.h:141
uint16_t depth() const
Definition: CaloHitID.h:24

◆ DrawAll()

void CaloSD::DrawAll ( )
override

Definition at line 431 of file CaloSD.cc.

431 {}

◆ endEvent()

void CaloSD::endEvent ( )
protectedvirtual

Reimplemented in HCalSD, and HGCSD.

Definition at line 872 of file CaloSD.cc.

Referenced by update().

872 {}

◆ EndOfEvent()

void CaloSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 413 of file CaloSD.cc.

References cleanHitCollection(), dqmdumpme::k, nHC_, and theHC.

413  {
414  // clean the hits for the last tracks
415 
417 
418 #ifdef EDM_ML_DEBUG
419  for (int k = 0; k < nHC_; ++k) {
420  if (theHC[k] == nullptr)
421  edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered for container " << k << " with no entries";
422  else
423  edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered for container " << k << " with " << theHC[k]->entries()
424  << " entries";
425  }
426 #endif
427 }
Log< level::Info, true > LogVerbatim
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
void cleanHitCollection()
Definition: CaloSD.cc:1041
int nHC_
Definition: CaloSD.h:158

◆ EnergyCorrected()

double CaloSD::EnergyCorrected ( const G4Step &  step,
const G4Track *   
)
protectedvirtual

Reimplemented in ECalSD.

Definition at line 365 of file CaloSD.cc.

Referenced by ProcessHits().

365 { return aStep.GetTotalEnergyDeposit(); }

◆ fillHits()

void CaloSD::fillHits ( edm::PCaloHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveCaloDetector.

Definition at line 442 of file CaloSD.cc.

References gpuPixelDoublets::cc, dqmdumpme::k, Skims_PA_cff::name, nHC_, and slave.

442  {
443  for (int k = 0; k < nHC_; ++k) {
444 #ifdef EDM_ML_DEBUG
445  edm::LogVerbatim("CaloSim") << "CaloSD: Tries to transfer " << slave[k].get()->hits().size() << " hits for "
446  << slave[k].get()->name() << " " << hname;
447 #endif
448  if (slave[k].get()->name() == hname) {
449  cc = slave[k].get()->hits();
450  slave[k].get()->Clean();
451  }
452  }
453 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
int nHC_
Definition: CaloSD.h:158
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ filterHit()

bool CaloSD::filterHit ( CaloG4Hit hit,
double  time 
)
protectedvirtual

Reimplemented in HCalSD, HGCSD, HGCalSD, HFNoseSD, HGCScintSD, and AHCalSD.

Definition at line 918 of file CaloSD.cc.

References eminHit, eminHitD, hcalRecHitTable_cff::time, and tmaxHit.

Referenced by cleanHitCollection().

918  {
919  double emin(eminHit);
920  if (hit->getDepth() > 0)
921  emin = eminHitD;
922 #ifdef EDM_ML_DEBUG
923  edm::LogVerbatim("CaloSim") << "CaloSD::filterHit(..) Depth " << hit->getDepth() << " Emin = " << emin << " ("
924  << eminHit << ", " << eminHitD << ")";
925 #endif
926  return ((time <= tmaxHit) && (hit->getEnergyDeposit() > emin));
927 }
Log< level::Info, true > LogVerbatim
double eminHitD
Definition: CaloSD.h:190
double eminHit
Definition: CaloSD.h:148
double tmaxHit
Definition: CaloSD.h:148

◆ findBoundaryCrossingParent()

unsigned int CaloSD::findBoundaryCrossingParent ( const G4Track *  track,
bool  markParentAsSaveable = true 
)
protected

Definition at line 553 of file CaloSD.cc.

References boundaryCrossingParentMap_, SensitiveDetector::cmsTrackInformation(), TrackInformation::crossedBoundary(), Exception, SimTrackManager::getTrackByID(), l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_trackManager, TrackWithHistory::parentID(), cosmicMuonLinks_cfi::parentTrack, printableDecayChain(), TrackInformation::setStoreTrack(), and HLT_2024v14_cff::track.

Referenced by ProcessHits().

553  {
555  unsigned int id = track->GetTrackID();
556  // First see if this track is already in the map
557  auto it = boundaryCrossingParentMap_.find(id);
558  if (it != boundaryCrossingParentMap_.end()) {
559 #ifdef EDM_ML_DEBUG
560  edm::LogVerbatim("DoFineCalo") << "Track " << id << " parent already cached: " << it->second;
561 #endif
562  return it->second;
563  }
564  // Then see if the track itself crosses the boundary
565  else if (trkInfo->crossedBoundary()) {
566 #ifdef EDM_ML_DEBUG
567  edm::LogVerbatim("DoFineCalo") << "Track " << id << " crosses boundary itself";
568 #endif
570  trkInfo->setStoreTrack();
571  return id;
572  }
573  // Else, traverse the history of the track
574  std::vector<unsigned int> decayChain{id};
575 #ifdef EDM_ML_DEBUG
576  edm::LogVerbatim("DoFineCalo") << "Track " << id << ": Traversing history to find boundary-crossing parent";
577 #endif
578  unsigned int parentID = track->GetParentID();
579  while (true) {
580  if (parentID == 0)
581  throw cms::Exception("Unknown", "CaloSD")
582  << "Hit end of parentage for track " << id << " without finding a boundary-crossing parent";
583  // First check if this ancestor is already in the map
584  auto it = boundaryCrossingParentMap_.find(parentID);
585  if (it != boundaryCrossingParentMap_.end()) {
586 #ifdef EDM_ML_DEBUG
587  edm::LogVerbatim("DoFineCalo") << " Track " << parentID
588  << " boundary-crossing parent already cached: " << it->second;
589 #endif
590  // Store this parent also for the rest of the traversed decay chain
591  for (auto ancestorID : decayChain)
592  boundaryCrossingParentMap_[ancestorID] = it->second;
593 #ifdef EDM_ML_DEBUG
594  // In debug mode, still build the rest of the decay chain for debugging
595  decayChain.push_back(parentID);
596  while (parentID != it->second) {
597  parentID = m_trackManager->getTrackByID(parentID, true)->parentID();
598  decayChain.push_back(parentID);
599  }
600  edm::LogVerbatim("DoFineCalo") << " Full decay chain: " << printableDecayChain(decayChain);
601 #endif
602  return it->second;
603  }
604  // If not, get this parent from the track manager (expensive)
606  if (parentTrack->crossedBoundary()) {
607  if (markAsSaveable)
608  parentTrack->setToBeSaved();
609  decayChain.push_back(parentID);
610  // Record this boundary crossing parent for all traversed ancestors
611  for (auto ancestorID : decayChain)
612  boundaryCrossingParentMap_[ancestorID] = parentID;
613 #ifdef EDM_ML_DEBUG
614  edm::LogVerbatim("DoFineCalo") << " Found boundary-crossing ancestor " << parentID << " for track " << id
615  << "; decay chain: " << printableDecayChain(decayChain);
616 #endif
617  return parentID;
618  }
619  // Next iteration
620  decayChain.push_back(parentID);
621  parentID = parentTrack->parentID();
622  }
623 }
Log< level::Info, true > LogVerbatim
void setStoreTrack()
can only be set to true, cannot be reset to false!
bool crossedBoundary() const
int parentID() const
TrackWithHistory * getTrackByID(int trackID, bool strict=false) const
std::unordered_map< unsigned int, unsigned int > boundaryCrossingParentMap_
Definition: CaloSD.h:197
static std::string printableDecayChain(const std::vector< unsigned int > &decayChain)
Definition: CaloSD.cc:528
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const SimTrackManager * m_trackManager
Definition: CaloSD.h:169

◆ getAttenuation()

double CaloSD::getAttenuation ( const G4Step *  aStep,
double  birk1,
double  birk2,
double  birk3 
) const
protected

Definition at line 728 of file CaloSD.cc.

References funct::abs(), DummyCfis::c, ALCARECOTkAlJpsiMuMu_cff::charge, fastSimProducer_cff::density, and mps_merge::weight.

Referenced by TotemT2ScintSD::getEnergyDeposit(), AHCalSD::getEnergyDeposit(), HGCalTB16SD01::getEnergyDeposit(), HcalTB06BeamSD::getEnergyDeposit(), HGCScintSD::getEnergyDeposit(), EcalTBH4BeamSD::getEnergyDeposit(), DreamSD::getEnergyDeposit(), ECalSD::getEnergyDeposit(), HcalTB02SD::getEnergyDeposit(), and HCalSD::getEnergyDeposit().

728  {
729  double weight = 1.;
730  double charge = aStep->GetPreStepPoint()->GetCharge();
731  double length = aStep->GetStepLength();
732 
733  if (charge != 0. && length > 0.) {
734  double density = aStep->GetPreStepPoint()->GetMaterial()->GetDensity();
735  double dedx = aStep->GetTotalEnergyDeposit() / length;
736  double rkb = birk1 / density;
737  double c = birk2 * rkb * rkb;
738  if (std::abs(charge) >= 2.)
739  rkb /= birk3; // based on alpha particle data
740  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
741 #ifdef EDM_ML_DEBUG
742  edm::LogVerbatim("CaloSim") << "CaloSD::getAttenuation in " << aStep->GetPreStepPoint()->GetMaterial()->GetName()
743  << " Charge " << charge << " dE/dx " << dedx << " Birk Const " << rkb << ", " << c
744  << " Weight = " << weight << " dE " << aStep->GetTotalEnergyDeposit();
745 #endif
746  }
747  return weight;
748 }
Log< level::Info, true > LogVerbatim
Definition: weight.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getDepth()

uint16_t CaloSD::getDepth ( const G4Step *  )
protectedvirtual

Reimplemented in ECalSD.

Definition at line 914 of file CaloSD.cc.

Referenced by ZdcSD::ProcessHits(), and ProcessHits().

914 { return 0; }

◆ getEnergyDeposit()

double CaloSD::getEnergyDeposit ( const G4Step *  step)
protectedvirtual

Reimplemented in HCalSD, ECalSD, HcalTB02SD, CastorSD, HGCSD, HGCalSD, HFNoseSD, DreamSD, EcalTBH4BeamSD, HGCScintSD, HcalTB06BeamSD, ZdcSD, HGCalTB16SD01, AHCalSD, and TotemT2ScintSD.

Definition at line 363 of file CaloSD.cc.

Referenced by ProcessHits().

363 { return aStep->GetTotalEnergyDeposit(); }

◆ getFromLibrary()

bool CaloSD::getFromLibrary ( const G4Step *  step)
protectedvirtual

Reimplemented in HCalSD, CastorSD, and ZdcSD.

Definition at line 367 of file CaloSD.cc.

Referenced by ProcessHits().

367 { return false; }

◆ getNumberOfHits()

int CaloSD::getNumberOfHits ( int  k = 0)
protected

Definition at line 522 of file CaloSD.cc.

References dqmdumpme::k, and theHC.

Referenced by createNewHit(), and HCalSD::getFromLibrary().

522 { return theHC[k]->entries(); }
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174

◆ getResponseWt()

double CaloSD::getResponseWt ( const G4Track *  aTrack,
int  k = 0 
)
protected

Definition at line 929 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), TrackInformation::genParticleP(), TrackInformation::genParticlePID(), dqmdumpme::k, and meanResponse.

Referenced by ECalSD::EnergyCorrected(), HGCScintSD::getEnergyDeposit(), HFNoseSD::getEnergyDeposit(), HGCalSD::getEnergyDeposit(), HGCSD::getEnergyDeposit(), ECalSD::getEnergyDeposit(), and HCalSD::getEnergyDeposit().

929  {
930  double wt = 1.0;
931  if (meanResponse[k].get()) {
932  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
933  wt = meanResponse[k].get()->getWeight(trkInfo->genParticlePID(), trkInfo->genParticleP());
934  }
935  return wt;
936 }
double genParticleP() const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int genParticlePID() const
std::unique_ptr< CaloMeanResponse > meanResponse[2]
Definition: CaloSD.h:172

◆ getTrackID()

int CaloSD::getTrackID ( const G4Track *  aTrack)
protectedvirtual

Reimplemented in ECalSD.

Definition at line 874 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), and TrackInformation::getIDonCaloSurface().

Referenced by ECalSD::getTrackID(), ZdcSD::ProcessHits(), and ProcessHits().

874  {
875  int primaryID = 0;
876  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
877  if (trkInfo) {
878  primaryID = trkInfo->getIDonCaloSurface();
879 #ifdef EDM_ML_DEBUG
880  edm::LogVerbatim("CaloSim") << "Track ID: " << trkInfo->getIDonCaloSurface() << ":" << aTrack->GetTrackID() << ":"
881  << primaryID;
882 #endif
883  } else {
884  primaryID = aTrack->GetTrackID();
885 #ifdef EDM_ML_DEBUG
886  edm::LogWarning("CaloSim") << "CaloSD: Problem with primaryID **** set by force to TkID **** " << primaryID;
887 #endif
888  }
889  return primaryID;
890 }
Log< level::Info, true > LogVerbatim
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
Log< level::Warning, false > LogWarning

◆ hitExists()

bool CaloSD::hitExists ( const G4Step *  aStep,
int  k 
)
protected

Definition at line 463 of file CaloSD.cc.

References checkHit(), currentHit, currentID, dqmdumpme::k, posGlobal, previousID, resetForNewPrimary(), and updateHit().

Referenced by ZdcSD::ProcessHits(), ProcessHits(), and HGCalSD::processSecondHit().

463  {
464 #ifdef EDM_ML_DEBUG
465  edm::LogVerbatim("CaloSim") << "CaloSD: hitExists for " << k;
466 #endif
467  // Update if in the same detector, time-slice and for same track
468  if (currentID[k] == previousID[k]) {
469  updateHit(currentHit[k], k);
470  return true;
471  }
472 
473  // Note T. Klijnsma:
474  // This is a rather strange place to set these class variables.
475  // The code would be much more readable if all logic for determining
476  // whether to update a hit or create a new hit is done in one place,
477  // and only then perform the actual updating or creating of the hit.
478 
479  // Reset entry point for new primary (only for the primary hit)
480  if (k == 0) {
481  posGlobal = aStep->GetPreStepPoint()->GetPosition();
482  if (currentID[k].trackID() != previousID[k].trackID()) {
483  resetForNewPrimary(aStep);
484  }
485  }
486  return checkHit(k);
487 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
Log< level::Info, true > LogVerbatim
G4ThreeVector posGlobal
Definition: CaloSD.h:142
bool checkHit(int k=0)
Definition: CaloSD.cc:489
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:704
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:715
CaloHitID previousID[2]
Definition: CaloSD.h:146
CaloHitID currentID[2]
Definition: CaloSD.h:146

◆ ignoreRejection()

void CaloSD::ignoreRejection ( )
inlineprotected

Definition at line 112 of file CaloSD.h.

References ignoreReject.

Referenced by HGCalSD::setDetUnitId().

112 { ignoreReject = true; }
bool ignoreReject
Definition: CaloSD.h:178

◆ initEvent()

void CaloSD::initEvent ( const BeginOfEvent )
protectedvirtual

Reimplemented in HCalSD, and HGCSD.

Definition at line 870 of file CaloSD.cc.

Referenced by update().

870 {}

◆ Initialize()

void CaloSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 389 of file CaloSD.cc.

References collName_, detName_, hcID, dqmdumpme::k, nHC_, theHC, and totalHits.

389  {
390 #ifdef EDM_ML_DEBUG
391  edm::LogVerbatim("CaloSim") << "CaloSD : Initialize called for " << detName_;
392 #endif
393 
394  for (int k = 0; k < nHC_; ++k) {
395  totalHits[k] = 0;
396 
397  //This initialization is performed at the beginning of an event
398  //------------------------------------------------------------
400 
401  if (hcID[k] < 0) {
402  hcID[k] = G4SDManager::GetSDMpointer()->GetCollectionID(collName_[k]);
403  }
404  //theHC ownership is transfered here to HCE
405  HCE->AddHitsCollection(hcID[k], theHC[k]);
406 #ifdef EDM_ML_DEBUG
407  edm::LogVerbatim("CaloSim") << "CaloSD : Add hits collection for " << hcID[k] << " for " << k << ":" << detName_
408  << ":" << collName_[k];
409 #endif
410  }
411 }
Log< level::Info, true > LogVerbatim
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int nHC_
Definition: CaloSD.h:158
int totalHits[2]
Definition: CaloSD.h:185
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
std::string detName_
Definition: CaloSD.h:159
std::string collName_[2]
Definition: CaloSD.h:159
int hcID[2]
Definition: CaloSD.h:182

◆ initRun()

void CaloSD::initRun ( )
protectedvirtual

Reimplemented in HCalSD, HGCSD, HGCalSD, HFNoseSD, HGCScintSD, DreamSD, and ZdcSD.

Definition at line 868 of file CaloSD.cc.

Referenced by update().

868 {}

◆ isItFineCalo()

bool CaloSD::isItFineCalo ( const G4VTouchable *  touch)

Definition at line 369 of file CaloSD.cc.

References hgcalTestNeighbor_cfi::detector, fineDetectors_, cuy::ii, personalPlayback::level, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createNewHit(), and ProcessHits().

369  {
370  bool ok(false);
371  int level = ((touch->GetHistoryDepth()) + 1);
372  for (const auto& detector : fineDetectors_) {
373  if (level > 0 && level >= detector.level) {
374  int ii = level - detector.level;
375  G4LogicalVolume* lv = touch->GetVolume(ii)->GetLogicalVolume();
376  ok = (lv == detector.lv);
377 #ifdef EDM_ML_DEBUG
378  std::string name1 = (lv == nullptr) ? "Unknown" : lv->GetName();
379  edm::LogVerbatim("CaloSim") << "CaloSD: volume " << name1 << ":" << detector.name << " at Level "
380  << detector.level << " Flag " << ok;
381 #endif
382  if (ok)
383  break;
384  }
385  }
386  return ok;
387 }
Log< level::Info, true > LogVerbatim
std::vector< Detector > fineDetectors_
Definition: CaloSD.h:199
ii
Definition: cuy.py:589

◆ newCollection()

void CaloSD::newCollection ( const std::string &  name,
edm::ParameterSet const &  p 
)

Definition at line 177 of file CaloSD.cc.

References collName_, detName_, hcn_, dqmdumpme::k, meanResponse, Skims_PA_cff::name, nHC_, AlCaHLTBitMon_ParallelJobs::p, slave, and useResMap_.

Referenced by HGCalSD::update().

177  {
178  for (unsigned int k = 0; k < hcn_.size(); ++k) {
179  if (name == hcn_[k]) {
180  if (k < useResMap_.size() && useResMap_[k] > 0) {
181  meanResponse[1] = std::make_unique<CaloMeanResponse>(p);
182  break;
183  }
184  }
185  }
186  slave[1] = std::make_unique<CaloSlaveSD>(name);
187 #ifdef EDM_ML_DEBUG
188  edm::LogVerbatim("CaloSim") << "CaloSD:: Initialise a second collection for " << name;
189  for (int k = 0; k < nHC_; ++k)
190  edm::LogVerbatim("CaloSim") << "Detector[" << k << "]" << detName_ << " collection " << collName_[k];
191 
192 #endif
193 }
Log< level::Info, true > LogVerbatim
std::vector< int > useResMap_
Definition: CaloSD.h:150
int nHC_
Definition: CaloSD.h:158
std::vector< std::string > hcn_
Definition: CaloSD.h:149
std::string detName_
Definition: CaloSD.h:159
std::string collName_[2]
Definition: CaloSD.h:159
std::unique_ptr< CaloMeanResponse > meanResponse[2]
Definition: CaloSD.h:172
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ printableDecayChain()

std::string CaloSD::printableDecayChain ( const std::vector< unsigned int > &  decayChain)
staticprotected

Definition at line 528 of file CaloSD.cc.

References mps_fire::i, and contentValuesCheck::ss.

Referenced by findBoundaryCrossingParent().

528  {
529  std::stringstream ss;
530  for (long unsigned int i = 0; i < decayChain.size(); i++) {
531  if (i > 0)
532  ss << " <- ";
533  ss << decayChain[i];
534  }
535  return ss.str();
536 }

◆ PrintAll()

void CaloSD::PrintAll ( )
override

Definition at line 433 of file CaloSD.cc.

References dqmdumpme::k, nHC_, and theHC.

433  {
434  for (int k = 0; k < nHC_; ++k) {
435 #ifdef EDM_ML_DEBUG
436  edm::LogVerbatim("CaloSim") << "CaloSD: Collection " << theHC[k]->GetName();
437 #endif
438  theHC[k]->PrintAllHits();
439  }
440 }
Log< level::Info, true > LogVerbatim
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int nHC_
Definition: CaloSD.h:158

◆ printDetectorLevels()

void CaloSD::printDetectorLevels ( const G4VTouchable *  touch) const
protected

Definition at line 1159 of file CaloSD.cc.

References mps_fire::i, cuy::ii, personalPlayback::level, Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HGCScintSD::setDetUnitId(), and HGCalSD::setDetUnitId().

1159  {
1160  //Print name and copy numbers
1161  int level = ((touch->GetHistoryDepth()) + 1);
1162  std::ostringstream st1;
1163  st1 << level << " Levels:";
1164  if (level > 0) {
1165  for (int ii = 0; ii < level; ii++) {
1166  int i = level - ii - 1;
1167  G4VPhysicalVolume* pv = touch->GetVolume(i);
1168  std::string name = (pv != nullptr) ? pv->GetName() : "Unknown";
1169  st1 << " " << name << ":" << touch->GetReplicaNumber(i);
1170  }
1171  }
1172  edm::LogVerbatim("CaloSim") << st1.str();
1173 }
Log< level::Info, true > LogVerbatim
ii
Definition: cuy.py:589

◆ processHit()

void CaloSD::processHit ( const G4Step *  step)
inlineprotected

Definition at line 117 of file CaloSD.h.

References checkHit(), createNewHit(), currentHit, currentID, previousID, and updateHit().

Referenced by HCalSD::getFromHFLibrary(), ZdcSD::getFromLibrary(), CastorSD::getFromLibrary(), HCalSD::getFromParam(), HCalSD::getHitFibreBundle(), HCalSD::getHitPMT(), and HCalSD::hitForFibre().

117  {
118  // check if it is in the same unit and timeslice as the previous one
119  if (currentID[0] == previousID[0]) {
120  updateHit(currentHit[0], 0);
121  } else if (!checkHit()) {
122  currentHit[0] = createNewHit(step, step->GetTrack(), 0);
123  }
124  }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
bool checkHit(int k=0)
Definition: CaloSD.cc:489
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:704
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
Definition: CaloSD.cc:625
CaloHitID previousID[2]
Definition: CaloSD.h:146
CaloHitID currentID[2]
Definition: CaloSD.h:146
step
Definition: StallMonitor.cc:83

◆ ProcessHits() [1/2]

G4bool CaloSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Reimplemented in ZdcSD.

Definition at line 195 of file CaloSD.cc.

References createNewHit(), currentHit, currentID, TauDecayModes::dec, hcalRecHitTable_cff::depth, doFineCalo_, doFineCaloThisStep_, edepositEM, edepositHAD, hcalRecHitTable_cff::energy, findBoundaryCrossingParent(), getDepth(), getEnergyDeposit(), getFromLibrary(), getTrackID(), hitExists(), ignoreReject, G4TrackToParticleID::isGammaElectronPositron(), isItFineCalo(), isParameterized, CaloHitID::markAsFinecaloTrackID(), SensitiveDetector::NaNTrap(), previousID, processSecondHit(), setDetUnitId(), CaloHitID::setID(), shortreprID(), hcalRecHitTable_cff::time, and CaloHitID::unitID().

195  {
196  NaNTrap(aStep);
197  ignoreReject = false;
198 
199 #ifdef EDM_ML_DEBUG
200  edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " ID= " << aStep->GetTrack()->GetTrackID()
201  << " prID= " << aStep->GetTrack()->GetParentID()
202  << " Eprestep= " << aStep->GetPreStepPoint()->GetKineticEnergy()
203  << " step= " << aStep->GetStepLength() << " Edep= " << aStep->GetTotalEnergyDeposit();
204 #endif
205 
206  // Class variable to determine whether finecalo rules should apply for this step
207  doFineCaloThisStep_ = (doFineCalo_ && isItFineCalo(aStep->GetPreStepPoint()->GetTouchable()));
208 
209  // apply shower library or parameterisation
210  // independent on energy deposition at a step
211  if (isParameterized) {
212  if (getFromLibrary(aStep)) {
213  // for parameterized showers the primary track should be killed
214  // secondary tracks should be killed if they are in the same volume
215  (aStep->GetTrack())->SetTrackStatus(fStopAndKill);
216  if (0 < aStep->GetNumberOfSecondariesInCurrentStep()) {
217  auto tv = aStep->GetSecondaryInCurrentStep();
218  auto vol = aStep->GetPreStepPoint()->GetPhysicalVolume();
219  for (auto& tk : *tv) {
220  if (tk->GetVolume() == vol) {
221  const_cast<G4Track*>(tk)->SetTrackStatus(fStopAndKill);
222  }
223  }
224  }
225  return true;
226  }
227  }
228 
229  // ignore steps without energy deposit
230  edepositEM = edepositHAD = 0.f;
231  if (aStep->GetTotalEnergyDeposit() <= 0.0) {
232  return false;
233  }
234 
235  // check unitID
236  unsigned int unitID = setDetUnitId(aStep);
237  auto const theTrack = aStep->GetTrack();
238  uint16_t depth = getDepth(aStep);
239 
240  double time = theTrack->GetGlobalTime() / CLHEP::nanosecond;
241  int primaryID = getTrackID(theTrack);
242  if (unitID > 0) {
243  currentID[0].setID(unitID, time, primaryID, depth);
244  } else {
245  if (!ignoreReject) {
246  const G4TouchableHistory* touch = static_cast<const G4TouchableHistory*>(theTrack->GetTouchable());
247  edm::LogVerbatim("CaloSim") << "CaloSD::ProcessHits: unitID= " << unitID
248  << " currUnit= " << currentID[0].unitID() << " Detector: " << GetName()
249  << " trackID= " << theTrack->GetTrackID() << " "
250  << theTrack->GetDefinition()->GetParticleName()
251  << "\n Edep= " << aStep->GetTotalEnergyDeposit()
252  << " PV: " << touch->GetVolume(0)->GetName()
253  << " PVid= " << touch->GetReplicaNumber(0) << " MVid= " << touch->GetReplicaNumber(1);
254  }
255  return false;
256  }
257  double energy = getEnergyDeposit(aStep);
258  if (energy <= 0.0) {
259  return false;
260  }
261 
262  if (doFineCaloThisStep_) {
263  currentID[0].setID(unitID, time, findBoundaryCrossingParent(theTrack), depth);
265  }
266 
268  edepositEM = energy;
269  } else {
271  }
272 #ifdef EDM_ML_DEBUG
273  const G4TouchableHistory* touch = static_cast<const G4TouchableHistory*>(theTrack->GetTouchable());
274  edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " PV:" << touch->GetVolume(0)->GetName()
275  << " PVid=" << touch->GetReplicaNumber(0) << " MVid=" << touch->GetReplicaNumber(1)
276  << " Unit:" << std::hex << unitID << std::dec << " Edep=" << edepositEM << " "
277  << edepositHAD << " ID=" << theTrack->GetTrackID() << " pID=" << theTrack->GetParentID()
278  << " E=" << theTrack->GetKineticEnergy() << " S=" << aStep->GetStepLength() << "\n "
279  << theTrack->GetDefinition()->GetParticleName() << " primaryID= " << primaryID
280  << " currentID= (" << currentID[0] << ") previousID= (" << previousID[0] << ")";
281 #endif
282  if (!hitExists(aStep, 0)) {
283  currentHit[0] = createNewHit(aStep, theTrack, 0);
284  } else {
285 #ifdef EDM_ML_DEBUG
286  edm::LogVerbatim("DoFineCalo") << "Not creating new hit, only updating " << shortreprID(currentHit[0]);
287 #endif
288  }
289 
290  processSecondHit(aStep, theTrack);
291 
292  return true;
293 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
float edepositEM
Definition: CaloSD.h:144
virtual void processSecondHit(const G4Step *, const G4Track *)
Definition: CaloSD.cc:916
Log< level::Info, true > LogVerbatim
bool ignoreReject
Definition: CaloSD.h:178
virtual bool getFromLibrary(const G4Step *step)
Definition: CaloSD.cc:367
bool doFineCaloThisStep_
Definition: CaloSD.h:200
virtual uint16_t getDepth(const G4Step *)
Definition: CaloSD.cc:914
virtual double getEnergyDeposit(const G4Step *step)
Definition: CaloSD.cc:363
unsigned int findBoundaryCrossingParent(const G4Track *track, bool markParentAsSaveable=true)
Definition: CaloSD.cc:553
uint32_t setDetUnitId(const G4Step *step) override=0
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:874
bool isItFineCalo(const G4VTouchable *touch)
Definition: CaloSD.cc:369
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
Definition: CaloSD.cc:625
float edepositHAD
Definition: CaloSD.h:144
bool doFineCalo_
Definition: CaloSD.h:192
uint32_t unitID() const
Definition: CaloHitID.h:20
CaloHitID previousID[2]
Definition: CaloSD.h:146
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:41
bool hitExists(const G4Step *, int k)
Definition: CaloSD.cc:463
void markAsFinecaloTrackID(bool flag=true)
Definition: CaloHitID.h:29
static bool isGammaElectronPositron(int pdgCode)
bool isParameterized
Definition: CaloSD.h:177
CaloHitID currentID[2]
Definition: CaloSD.h:146
std::string shortreprID(const CaloHitID &ID)
Definition: CaloSD.cc:539
void NaNTrap(const G4Step *step) const

◆ ProcessHits() [2/2]

bool CaloSD::ProcessHits ( G4GFlashSpot *  aSpot,
G4TouchableHistory *   
)
override

Definition at line 295 of file CaloSD.cc.

References checkHit(), createNewHit(), currentHit, currentID, TauDecayModes::dec, hcalRecHitTable_cff::depth, edepositEM, edepositHAD, EnergyCorrected(), entranceLocal, entrancePoint, getDepth(), getTrackID(), incidentEnergy, G4TrackToParticleID::isGammaElectronPositron(), posGlobal, previousID, setDetUnitId(), CaloHitID::setID(), hcalRecHitTable_cff::time, HLT_2024v14_cff::track, CaloHitID::unitID(), and updateHit().

295  {
296  edepositEM = edepositHAD = 0.f;
297  const G4Track* track = aSpot->GetOriginatorTrack()->GetPrimaryTrack();
298 
299  double edep = aSpot->GetEnergySpot()->GetEnergy();
300  if (edep <= 0.0) {
301  return false;
302  }
303 
304  G4Step fFakeStep;
305  G4StepPoint* fFakePreStepPoint = fFakeStep.GetPreStepPoint();
306  G4StepPoint* fFakePostStepPoint = fFakeStep.GetPostStepPoint();
307  fFakePreStepPoint->SetPosition(aSpot->GetPosition());
308  fFakePostStepPoint->SetPosition(aSpot->GetPosition());
309 
310  G4TouchableHandle fTouchableHandle = aSpot->GetTouchableHandle();
311  fFakePreStepPoint->SetTouchableHandle(fTouchableHandle);
312  fFakeStep.SetTotalEnergyDeposit(edep);
313  edep = EnergyCorrected(fFakeStep, track);
314 
315  // zero edep means hit outside the calorimeter
316  if (edep <= 0.0) {
317  return false;
318  }
319 
321  edepositEM = edep;
322  } else {
323  edepositHAD = edep;
324  }
325 
326  unsigned int unitID = setDetUnitId(&fFakeStep);
327 
328  if (unitID > 0) {
329  // time of initial track
330  double time = track->GetGlobalTime() / CLHEP::nanosecond;
331  int primaryID = getTrackID(track);
332  uint16_t depth = getDepth(&fFakeStep);
333  currentID[0].setID(unitID, time, primaryID, depth);
334 #ifdef EDM_ML_DEBUG
335  edm::LogVerbatim("CaloSim") << "CaloSD:: GetSpotInfo for Unit 0x" << std::hex << currentID[0].unitID() << std::dec
336  << " Edeposit = " << edepositEM << " " << edepositHAD;
337 #endif
338  // Update if in the same detector, time-slice and for same track
339  if (currentID[0] == previousID[0]) {
340  updateHit(currentHit[0], 0);
341  } else {
342  posGlobal = aSpot->GetEnergySpot()->GetPosition();
343  // Reset entry point for new primary
344  if (currentID[0].trackID() != previousID[0].trackID()) {
345  entrancePoint = aSpot->GetPosition();
346  entranceLocal = aSpot->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(entrancePoint);
347  incidentEnergy = track->GetKineticEnergy();
348 #ifdef EDM_ML_DEBUG
349  edm::LogVerbatim("CaloSim") << "CaloSD: Incident energy " << incidentEnergy / CLHEP::GeV << " GeV and"
350  << " entrance point " << entrancePoint << " (Global) " << entranceLocal
351  << " (Local)";
352 #endif
353  }
354  if (!checkHit()) {
355  currentHit[0] = createNewHit(&fFakeStep, track, 0);
356  }
357  }
358  return true;
359  }
360  return false;
361 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
float edepositEM
Definition: CaloSD.h:144
Log< level::Info, true > LogVerbatim
virtual uint16_t getDepth(const G4Step *)
Definition: CaloSD.cc:914
virtual double EnergyCorrected(const G4Step &step, const G4Track *)
Definition: CaloSD.cc:365
uint32_t setDetUnitId(const G4Step *step) override=0
G4ThreeVector posGlobal
Definition: CaloSD.h:142
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:874
bool checkHit(int k=0)
Definition: CaloSD.cc:489
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:704
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
Definition: CaloSD.cc:625
float edepositHAD
Definition: CaloSD.h:144
uint32_t unitID() const
Definition: CaloHitID.h:20
CaloHitID previousID[2]
Definition: CaloSD.h:146
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:41
float incidentEnergy
Definition: CaloSD.h:143
static bool isGammaElectronPositron(int pdgCode)
CaloHitID currentID[2]
Definition: CaloSD.h:146
G4ThreeVector entrancePoint
Definition: CaloSD.h:140
G4ThreeVector entranceLocal
Definition: CaloSD.h:141

◆ processSecondHit()

void CaloSD::processSecondHit ( const G4Step *  ,
const G4Track *   
)
protectedvirtual

Reimplemented in HGCalSD.

Definition at line 916 of file CaloSD.cc.

Referenced by ProcessHits().

916 {}

◆ reset()

void CaloSD::reset ( void  )
overridevirtual

Reimplemented from SensitiveCaloDetector.

Definition at line 862 of file CaloSD.cc.

References fpCaloG4HitAllocator.

Referenced by CaloSD().

862  {
863  if (fpCaloG4HitAllocator) {
864  fpCaloG4HitAllocator->ResetStorage();
865  }
866 }
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:11

◆ resetForNewPrimary()

void CaloSD::resetForNewPrimary ( const G4Step *  aStep)
protected

Definition at line 715 of file CaloSD.cc.

References entranceLocal, entrancePoint, incidentEnergy, and setToLocal().

Referenced by HCalSD::getFromHFLibrary(), ZdcSD::getFromLibrary(), CastorSD::getFromLibrary(), HCalSD::getHitFibreBundle(), HCalSD::getHitPMT(), hitExists(), ZdcSD::setTrackID(), and setTrackID().

715  {
716  auto const preStepPoint = aStep->GetPreStepPoint();
717  entrancePoint = preStepPoint->GetPosition();
718  entranceLocal = setToLocal(entrancePoint, preStepPoint->GetTouchable());
719  incidentEnergy = preStepPoint->GetKineticEnergy();
720 #ifdef EDM_ML_DEBUG
721  edm::LogVerbatim("CaloSim") << "CaloSD::resetForNewPrimary for " << GetName()
722  << " ID= " << aStep->GetTrack()->GetTrackID() << " Ein= " << incidentEnergy / CLHEP::GeV
723  << " GeV and"
724  << " entrance point global: " << entrancePoint << " local: " << entranceLocal;
725 #endif
726 }
Log< level::Info, true > LogVerbatim
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:455
float incidentEnergy
Definition: CaloSD.h:143
G4ThreeVector entrancePoint
Definition: CaloSD.h:140
G4ThreeVector entranceLocal
Definition: CaloSD.h:141

◆ saveHit()

bool CaloSD::saveHit ( CaloG4Hit aHit,
int  k = 0 
)
private

Definition at line 950 of file CaloSD.cc.

References correctT, corrTOFBeam, TauDecayModes::dec, doFineCalo_, Exception, CaloG4Hit::getDepth(), CaloG4Hit::getEM(), CaloG4Hit::getHadr(), CaloG4Hit::getTimeSlice(), CaloG4Hit::getTrackID(), CaloG4Hit::getUnitID(), SimTrackManager::giveMotherNeeded(), CaloG4Hit::isFinecaloTrackID(), dqmdumpme::k, m_trackManager, convertSQLiteXML::ok, shortreprID(), slave, hcalRecHitTable_cff::time, and SimTrackManager::trackExists().

Referenced by update().

950  {
951  int tkID;
952  bool ok = true;
953 
954  double time = aHit->getTimeSlice();
955  if (corrTOFBeam)
956  time += correctT;
957 
958  // More strict bookkeeping for finecalo
959  if (doFineCalo_ && aHit->isFinecaloTrackID()) {
960 #ifdef EDM_ML_DEBUG
961  edm::LogVerbatim("DoFineCalo") << "Saving hit " << shortreprID(aHit);
962 #endif
963  if (!m_trackManager)
964  throw cms::Exception("Unknown", "CaloSD") << "m_trackManager not set, needed for finecalo!";
965  if (!m_trackManager->trackExists(aHit->getTrackID()))
966  throw cms::Exception("Unknown", "CaloSD")
967  << "Error on hit " << shortreprID(aHit) << ": Parent track not in track manager";
968  slave[k].get()->processHits(aHit->getUnitID(),
969  aHit->getEM() / CLHEP::GeV,
970  aHit->getHadr() / CLHEP::GeV,
971  time,
972  aHit->getTrackID(),
973  aHit->getDepth());
974  }
975  // Regular, not-fine way:
976  else {
977  if (m_trackManager) {
978  tkID = m_trackManager->giveMotherNeeded(aHit->getTrackID());
979  if (tkID == 0) {
980  if (m_trackManager->trackExists(aHit->getTrackID()))
981  tkID = (aHit->getTrackID());
982  else {
983  ok = false;
984  }
985  }
986  } else {
987  tkID = aHit->getTrackID();
988  ok = false;
989  }
990 #ifdef EDM_ML_DEBUG
991  edm::LogVerbatim("DoFineCalo") << "Saving hit " << shortreprID(aHit) << " with trackID=" << tkID;
992 #endif
993 
994  slave[k].get()->processHits(
995  aHit->getUnitID(), aHit->getEM() / CLHEP::GeV, aHit->getHadr() / CLHEP::GeV, time, tkID, aHit->getDepth());
996  }
997 
998 #ifdef EDM_ML_DEBUG
999  if (!ok)
1000  edm::LogWarning("CaloSim") << "CaloSD:Cannot find track ID for " << aHit->getTrackID();
1001  edm::LogVerbatim("CaloSim") << "CalosD: Track ID " << aHit->getTrackID() << " changed to " << tkID
1002  << " by SimTrackManager Status " << ok;
1003 #endif
1004 
1005 #ifdef EDM_ML_DEBUG
1006  edm::LogVerbatim("CaloSim") << "CaloSD: Store Hit at " << std::hex << aHit->getUnitID() << std::dec << " "
1007  << aHit->getDepth() << " due to " << tkID << " in time " << time << " of energy "
1008  << aHit->getEM() / CLHEP::GeV << " GeV (EM) and " << aHit->getHadr() / CLHEP::GeV
1009  << " GeV (Hadr)";
1010 #endif
1011  return ok;
1012 }
Log< level::Info, true > LogVerbatim
int getTrackID() const
Definition: CaloG4Hit.h:64
bool corrTOFBeam
Definition: CaloSD.h:180
double getEM() const
Definition: CaloG4Hit.h:55
uint16_t getDepth() const
Definition: CaloG4Hit.h:69
double getHadr() const
Definition: CaloG4Hit.h:58
bool isFinecaloTrackID() const
Definition: CaloG4Hit.h:70
bool doFineCalo_
Definition: CaloSD.h:192
double correctT
Definition: CaloSD.h:191
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
bool trackExists(int i) const
double getTimeSlice() const
Definition: CaloG4Hit.h:67
int giveMotherNeeded(int i) const
const SimTrackManager * m_trackManager
Definition: CaloSD.h:169
std::string shortreprID(const CaloHitID &ID)
Definition: CaloSD.cc:539
Log< level::Warning, false > LogWarning
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ setDetUnitId()

uint32_t CaloSD::setDetUnitId ( const G4Step *  step)
overridepure virtual

◆ setNumberCheckedHits()

void CaloSD::setNumberCheckedHits ( int  val,
int  k = 0 
)
inlineprotected

◆ setParameterized()

void CaloSD::setParameterized ( bool  val)
inlineprotected

Definition at line 114 of file CaloSD.h.

References isParameterized, and heppy_batch::val.

Referenced by CastorSD::CastorSD(), HCalSD::HCalSD(), and ZdcSD::ZdcSD().

114 { isParameterized = val; }
bool isParameterized
Definition: CaloSD.h:177

◆ setToGlobal()

G4ThreeVector CaloSD::setToGlobal ( const G4ThreeVector &  local,
const G4VTouchable *  touch 
) const
protected

Definition at line 459 of file CaloSD.cc.

References DTRecHitClients_cfi::local.

459  {
460  return touch->GetHistory()->GetTopTransform().Inverse().TransformPoint(local);
461 }

◆ setToLocal()

G4ThreeVector CaloSD::setToLocal ( const G4ThreeVector &  global,
const G4VTouchable *  touch 
) const
protected

Definition at line 455 of file CaloSD.cc.

Referenced by ZdcSD::calculateCherenkovDeposit(), DreamSD::curve_LY(), HcalTB02SD::curve_LY(), ECalSD::EnergyCorrected(), ECalSD::getDepth(), ECalSD::getRadiationLength(), resetForNewPrimary(), and HcalTB06BeamSD::setDetUnitId().

455  {
456  return touch->GetHistory()->GetTopTransform().TransformPoint(global);
457 }

◆ setTrackID()

int CaloSD::setTrackID ( const G4Step *  aStep)
protectedvirtual

Reimplemented in ZdcSD.

Definition at line 892 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), TrackInformation::getIDonCaloSurface(), previousID, and resetForNewPrimary().

Referenced by HCalSD::getFromHFLibrary(), CastorSD::getFromLibrary(), HCalSD::getFromParam(), and HCalSD::hitForFibre().

892  {
893  auto const theTrack = aStep->GetTrack();
894  TrackInformation* trkInfo = cmsTrackInformation(theTrack);
895  int primaryID = trkInfo->getIDonCaloSurface();
896  if (primaryID <= 0) {
897  primaryID = theTrack->GetTrackID();
898  }
899 #ifdef EDM_ML_DEBUG
900  edm::LogVerbatim("CaloSim") << "Track ID: " << trkInfo->getIDonCaloSurface() << ":" << theTrack->GetTrackID() << ":"
901  << primaryID;
902 #endif
903 
904  if (primaryID != previousID[0].trackID()) {
905  resetForNewPrimary(aStep);
906  }
907 #ifdef EDM_ML_DEBUG
908  edm::LogVerbatim("CaloSim") << "CaloSD::setTrackID for " << GetName()
909  << " trackID= " << aStep->GetTrack()->GetTrackID() << " primaryID= " << primaryID;
910 #endif
911  return primaryID;
912 }
Log< level::Info, true > LogVerbatim
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:715
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
CaloHitID previousID[2]
Definition: CaloSD.h:146

◆ setUseMap()

void CaloSD::setUseMap ( bool  val)
inlineprotected

Definition at line 115 of file CaloSD.h.

References useMap, and heppy_batch::val.

Referenced by HFNoseSD::HFNoseSD(), HGCalSD::HGCalSD(), HGCScintSD::HGCScintSD(), and HGCSD::HGCSD().

115 { useMap = val; }
bool useMap
Definition: CaloSD.h:179

◆ shortreprID() [1/2]

std::string CaloSD::shortreprID ( const CaloHitID ID)
protected

Definition at line 539 of file CaloSD.cc.

References contentValuesCheck::ss.

Referenced by createNewHit(), ProcessHits(), saveHit(), and shortreprID().

539  {
540  std::stringstream ss;
541  ss << GetName() << "/" << ID.unitID() << "/trk" << ID.trackID() << "/d" << ID.depth() << "/time" << ID.timeSliceID();
542  if (ID.isFinecaloTrackID())
543  ss << "/FC";
544  return ss.str();
545 }
uint32_t ID
Definition: Definitions.h:24

◆ shortreprID() [2/2]

std::string CaloSD::shortreprID ( const CaloG4Hit hit)
protected

Definition at line 548 of file CaloSD.cc.

References shortreprID().

548 { return shortreprID(hit->getID()); }
std::string shortreprID(const CaloHitID &ID)
Definition: CaloSD.cc:539

◆ storeHit()

void CaloSD::storeHit ( CaloG4Hit hit,
int  k = 0 
)
private

Definition at line 938 of file CaloSD.cc.

References hitMap, dqmdumpme::k, previousID, theHC, CaloHitID::trackID(), and useMap.

Referenced by createNewHit().

938  {
939  if (hit == nullptr || previousID[k].trackID() < 0) {
940  edm::LogWarning("CaloSim") << "CaloSD: hit to be stored is nullptr !!"
941  << " previousID.trackID()= " << previousID[k].trackID();
942  return;
943  }
944 
945  theHC[k]->insert(hit);
946  if (useMap)
947  hitMap[k].insert(std::pair<CaloHitID, CaloG4Hit*>(previousID[k], hit));
948 }
std::map< CaloHitID, CaloG4Hit * > hitMap[2]
Definition: CaloSD.h:195
bool useMap
Definition: CaloSD.h:179
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
CaloHitID previousID[2]
Definition: CaloSD.h:146
Log< level::Warning, false > LogWarning
int trackID() const
Definition: CaloHitID.h:23

◆ update() [1/5]

void CaloSD::update ( const BeginOfRun )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 750 of file CaloSD.cc.

References initRun().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

750 { initRun(); }
virtual void initRun()
Definition: CaloSD.cc:868

◆ update() [2/5]

void CaloSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 752 of file CaloSD.cc.

References clearHits(), and initEvent().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

752  {
753 #ifdef EDM_ML_DEBUG
754  edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !";
755 #endif
756  clearHits();
757  initEvent(g4Event);
758 }
Log< level::Info, true > LogVerbatim
virtual void initEvent(const BeginOfEvent *)
Definition: CaloSD.cc:870
void clearHits() override
Definition: CaloSD.cc:849

◆ update() [3/5]

void CaloSD::update ( const BeginOfTrack )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack *>.

Definition at line 1014 of file CaloSD.cc.

References clean(), cleanHitCollection(), SensitiveDetector::cmsTrackInformation(), TrackInformation::isPrimary(), dqmdumpme::k, nHC_, primAncestor, and theHC.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

1014  {
1015  int primary = -1;
1016  TrackInformation* trkInfo = cmsTrackInformation((*trk)());
1017  if (trkInfo->isPrimary())
1018  primary = (*trk)()->GetTrackID();
1019 
1020 #ifdef EDM_ML_DEBUG
1021  edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary
1022  << " primary ancestor ID " << primAncestor;
1023 #endif
1024 
1025  // update the information if a different primary track ID
1026 
1027  if (primary > 0 && primary != primAncestor) {
1028  primAncestor = primary;
1029 
1030  // clean the hits information
1031 
1032  bool clean(false);
1033  for (int k = 0; k < nHC_; ++k)
1034  if (theHC[k]->entries() > 0)
1035  clean = true;
1036  if (clean)
1038  }
1039 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int primAncestor
Definition: CaloSD.h:183
void cleanHitCollection()
Definition: CaloSD.cc:1041
static void clean(char *s)
int nHC_
Definition: CaloSD.h:158
TrackInformation * cmsTrackInformation(const G4Track *aTrack)

◆ update() [4/5]

void CaloSD::update ( const EndOfTrack )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack *>.

Definition at line 760 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), TrackInformation::getIDonCaloSurface(), l1ctLayer2EG_cff::id, m_trackManager, tkMap, SimTrackManager::trackContainer(), and TrackWithHistory::trackID().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

760  {
761  int id = (*trk)()->GetTrackID();
762  TrackInformation* trkI = cmsTrackInformation((*trk)());
763  int lastTrackID = -1;
764  if (trkI)
765  lastTrackID = trkI->getIDonCaloSurface();
766  if (id == lastTrackID) {
767  auto trksForThisEvent = m_trackManager->trackContainer();
768  if (!trksForThisEvent->empty()) {
769  TrackWithHistory* trkH = trksForThisEvent->back();
770  if (trkH->trackID() == id) {
771  tkMap[id] = trkH;
772 #ifdef EDM_ML_DEBUG
773  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << id << " from Container of size "
774  << trksForThisEvent->size() << " with ID " << trkH->trackID();
775 #endif
776  }
777  }
778  }
779 }
Log< level::Info, true > LogVerbatim
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
const std::vector< TrackWithHistory * > * trackContainer() const
int trackID() const
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:196
const SimTrackManager * m_trackManager
Definition: CaloSD.h:169

◆ update() [5/5]

void CaloSD::update ( const ::EndOfEvent )
overrideprotected

Definition at line 781 of file CaloSD.cc.

References funct::abs(), boundaryCrossingParentMap_, submitPVResolutionJobs::count, mps_fire::end, endEvent(), edm::roottree::getEntry(), hitMap, mps_fire::i, dqmdumpme::k, nHC_, reusehit, saveHit(), slave, mathSSE::sqrt(), edm::swap(), theHC, tkMap, totalHits, groupFilesInBlocks::tt, useMap, x, and z.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

781  {
782  endEvent();
783  for (int k = 0; k < nHC_; ++k) {
784  slave[k].get()->ReserveMemory(theHC[k]->entries());
785 
786  int count(0);
787  double eEM(0.0);
788  double eHAD(0.0);
789  double eEM2(0.0);
790  double eHAD2(0.0);
791 #ifdef EDM_ML_DEBUG
792  int wrong(0);
793  double tt(0.0);
794  double zloc(0.0);
795  double zglob(0.0);
796  double ee(0.0);
797 #endif
798  int hc_entries = theHC[k]->entries();
799  for (int i = 0; i < hc_entries; ++i) {
800 #ifdef EDM_ML_DEBUG
801  if (!saveHit((*theHC[k])[i], k)) {
802  ++wrong;
803  }
804 #else
805  saveHit((*theHC[k])[i], k);
806 #endif
807 
808  ++count;
809  double x = (*theHC[k])[i]->getEM();
810  eEM += x;
811  eEM2 += x * x;
812  x = (*theHC[k])[i]->getHadr();
813  eHAD += x;
814  eHAD2 += x * x;
815 #ifdef EDM_ML_DEBUG
816  tt += (*theHC[k])[i]->getTimeSlice();
817  ee += (*theHC[k])[i]->getIncidentEnergy();
818  zglob += std::abs((*theHC[k])[i]->getEntry().z());
819  zloc += std::abs((*theHC[k])[i]->getEntryLocal().z());
820 #endif
821  }
822 
823  double norm = (count > 0) ? 1.0 / count : 0.0;
824  eEM *= norm;
825  eEM2 *= norm;
826  eHAD *= norm;
827  eHAD2 *= norm;
828  eEM2 = std::sqrt(eEM2 - eEM * eEM);
829  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
830 #ifdef EDM_ML_DEBUG
831  tt *= norm;
832  ee *= norm;
833  zglob *= norm;
834  zloc *= norm;
835  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
836  << " track IDs not given properly and " << totalHits - count
837  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
838  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
839  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
840 #endif
841  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit[k]);
842  if (useMap)
843  hitMap[k].erase(hitMap[k].begin(), hitMap[k].end());
844  }
845  tkMap.erase(tkMap.begin(), tkMap.end());
847 }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:527
Log< level::Info, true > LogVerbatim
std::map< CaloHitID, CaloG4Hit * > hitMap[2]
Definition: CaloSD.h:195
bool useMap
Definition: CaloSD.h:179
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
bool saveHit(CaloG4Hit *, int k=0)
Definition: CaloSD.cc:950
std::unordered_map< unsigned int, unsigned int > boundaryCrossingParentMap_
Definition: CaloSD.h:197
int nHC_
Definition: CaloSD.h:158
Definition: TTTypes.h:54
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::unique_ptr< CaloG4Hit > > reusehit[2]
Definition: CaloSD.h:198
int totalHits[2]
Definition: CaloSD.h:185
virtual void endEvent()
Definition: CaloSD.cc:872
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:196
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ updateHit()

void CaloSD::updateHit ( CaloG4Hit aHit,
int  k 
)
protected

Definition at line 704 of file CaloSD.cc.

References CaloG4Hit::addEnergyDeposit(), currentID, edepositEM, edepositHAD, dqmdumpme::k, and previousID.

Referenced by checkHit(), createNewHit(), hitExists(), processHit(), and ProcessHits().

704  {
706 #ifdef EDM_ML_DEBUG
707  edm::LogVerbatim("CaloSim") << "CaloSD:" << GetName() << " Add energy deposit in " << currentID[k]
708  << " Edep_em(MeV)= " << edepositEM << " Edep_had(MeV)= " << edepositHAD;
709 #endif
710 
711  // buffer for next steps:
712  previousID[k] = currentID[k];
713 }
float edepositEM
Definition: CaloSD.h:144
Log< level::Info, true > LogVerbatim
void addEnergyDeposit(double em, double hd)
Definition: CaloG4Hit.cc:45
float edepositHAD
Definition: CaloSD.h:144
CaloHitID previousID[2]
Definition: CaloSD.h:146
CaloHitID currentID[2]
Definition: CaloSD.h:146

Member Data Documentation

◆ boundaryCrossingParentMap_

std::unordered_map<unsigned int, unsigned int> CaloSD::boundaryCrossingParentMap_
private

Definition at line 197 of file CaloSD.h.

Referenced by findBoundaryCrossingParent(), and update().

◆ cleanIndex

int CaloSD::cleanIndex[2]
private

Definition at line 184 of file CaloSD.h.

Referenced by CaloSD(), cleanHitCollection(), and clearHits().

◆ collName_

std::string CaloSD::collName_[2]
protected

Definition at line 159 of file CaloSD.h.

Referenced by CaloSD(), Initialize(), newCollection(), and HGCalSD::update().

◆ correctT

double CaloSD::correctT
private

Definition at line 191 of file CaloSD.h.

Referenced by CaloSD(), cleanHitCollection(), and saveHit().

◆ corrTOFBeam

bool CaloSD::corrTOFBeam
private

Definition at line 180 of file CaloSD.h.

Referenced by CaloSD(), cleanHitCollection(), and saveHit().

◆ currentHit

CaloG4Hit* CaloSD::currentHit[2]
protected

◆ currentID

CaloHitID CaloSD::currentID[2]
protected

◆ detName_

std::string CaloSD::detName_
protected

Definition at line 159 of file CaloSD.h.

Referenced by CaloSD(), Initialize(), and newCollection().

◆ doFineCalo_

bool CaloSD::doFineCalo_
private

Definition at line 192 of file CaloSD.h.

Referenced by CaloSD(), ProcessHits(), and saveHit().

◆ doFineCaloThisStep_

bool CaloSD::doFineCaloThisStep_
private

Definition at line 200 of file CaloSD.h.

Referenced by createNewHit(), and ProcessHits().

◆ edepositEM

float CaloSD::edepositEM
protected

◆ edepositHAD

float CaloSD::edepositHAD
protected

◆ eMinFine_

double CaloSD::eMinFine_
private

Definition at line 193 of file CaloSD.h.

Referenced by CaloSD().

◆ eminHit

double CaloSD::eminHit
protected

Definition at line 148 of file CaloSD.h.

Referenced by CaloSD(), filterHit(), and HGCSD::HGCSD().

◆ eminHitD

double CaloSD::eminHitD
private

Definition at line 190 of file CaloSD.h.

Referenced by CaloSD(), and filterHit().

◆ energyCut

double CaloSD::energyCut
protected

Definition at line 148 of file CaloSD.h.

Referenced by CaloSD(), createNewHit(), HCalSD::getHitFibreBundle(), and HCalSD::getHitPMT().

◆ entranceLocal

G4ThreeVector CaloSD::entranceLocal
protected

◆ entrancePoint

G4ThreeVector CaloSD::entrancePoint
protected

◆ fineDetectors_

std::vector<Detector> CaloSD::fineDetectors_
private

Definition at line 199 of file CaloSD.h.

Referenced by CaloSD(), and isItFineCalo().

◆ forceSave

bool CaloSD::forceSave
protected

Definition at line 157 of file CaloSD.h.

Referenced by CaloSD(), createNewHit(), and ECalSD::getTrackID().

◆ hcID

int CaloSD::hcID[2]
private

Definition at line 182 of file CaloSD.h.

Referenced by CaloSD(), and Initialize().

◆ hcn_

std::vector<std::string> CaloSD::hcn_
protected

Definition at line 149 of file CaloSD.h.

Referenced by CaloSD(), and newCollection().

◆ hitMap

std::map<CaloHitID, CaloG4Hit*> CaloSD::hitMap[2]
private

Definition at line 195 of file CaloSD.h.

Referenced by checkHit(), cleanHitCollection(), storeHit(), and update().

◆ ignoreReject

bool CaloSD::ignoreReject
private

Definition at line 178 of file CaloSD.h.

Referenced by ignoreRejection(), and ProcessHits().

◆ ignoreTrackID

bool CaloSD::ignoreTrackID
private

Definition at line 176 of file CaloSD.h.

Referenced by CaloSD().

◆ incidentEnergy

float CaloSD::incidentEnergy
protected

◆ isParameterized

bool CaloSD::isParameterized
private

Definition at line 177 of file CaloSD.h.

Referenced by CaloSD(), ProcessHits(), and setParameterized().

◆ kmaxIon

double CaloSD::kmaxIon
protected

◆ kmaxNeutron

double CaloSD::kmaxNeutron
protected

◆ kmaxProton

double CaloSD::kmaxProton
protected

◆ m_trackManager

const SimTrackManager* CaloSD::m_trackManager
private

Definition at line 169 of file CaloSD.h.

Referenced by findBoundaryCrossingParent(), saveHit(), and update().

◆ meanResponse

std::unique_ptr<CaloMeanResponse> CaloSD::meanResponse[2]
private

Definition at line 172 of file CaloSD.h.

Referenced by CaloSD(), getResponseWt(), and newCollection().

◆ nCheckedHits

int CaloSD::nCheckedHits[2]
private

Definition at line 187 of file CaloSD.h.

Referenced by CaloSD(), checkHit(), and setNumberCheckedHits().

◆ nHC_

int CaloSD::nHC_
protected

◆ posGlobal

G4ThreeVector CaloSD::posGlobal
protected

Definition at line 142 of file CaloSD.h.

Referenced by CaloSD(), createNewHit(), ZdcSD::getFromLibrary(), hitExists(), and ProcessHits().

◆ previousID

CaloHitID CaloSD::previousID[2]
protected

◆ primAncestor

int CaloSD::primAncestor
private

Definition at line 183 of file CaloSD.h.

Referenced by CaloSD(), and update().

◆ primIDSaved

int CaloSD::primIDSaved[2]
private

Definition at line 186 of file CaloSD.h.

Referenced by CaloSD(), clearHits(), and createNewHit().

◆ reusehit

std::vector<std::unique_ptr<CaloG4Hit> > CaloSD::reusehit[2]
private

Definition at line 198 of file CaloSD.h.

Referenced by cleanHitCollection(), createNewHit(), and update().

◆ slave

std::unique_ptr<CaloSlaveSD> CaloSD::slave[2]
private

Definition at line 171 of file CaloSD.h.

Referenced by CaloSD(), clearHits(), fillHits(), newCollection(), saveHit(), and update().

◆ suppressHeavy

bool CaloSD::suppressHeavy
protected

◆ theHC

CaloG4HitCollection* CaloSD::theHC[2]
private

◆ timeSlice

float CaloSD::timeSlice
private

Definition at line 189 of file CaloSD.h.

Referenced by CaloSD().

◆ tkMap

std::map<int, TrackWithHistory*> CaloSD::tkMap
private

Definition at line 196 of file CaloSD.h.

Referenced by createNewHit(), and update().

◆ tmaxHit

double CaloSD::tmaxHit
protected

◆ totalHits

int CaloSD::totalHits[2]
private

Definition at line 185 of file CaloSD.h.

Referenced by CaloSD(), cleanHitCollection(), createNewHit(), Initialize(), and update().

◆ useMap

bool CaloSD::useMap
private

Definition at line 179 of file CaloSD.h.

Referenced by CaloSD(), checkHit(), cleanHitCollection(), createNewHit(), setUseMap(), storeHit(), and update().

◆ useResMap_

std::vector<int> CaloSD::useResMap_
protected

Definition at line 150 of file CaloSD.h.

Referenced by CaloSD(), and newCollection().