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 33 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_.

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

174 {}

Member Function Documentation

◆ checkHit()

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

Definition at line 488 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, nhits, theHC, updateHit(), and useMap.

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

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

◆ cleanHitCollection()

void CaloSD::cleanHitCollection ( )
private

Definition at line 1040 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().

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

◆ clear()

void CaloSD::clear ( void  )
override

Definition at line 428 of file CaloSD.cc.

428 {}

◆ clearHits()

void CaloSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 848 of file CaloSD.cc.

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

Referenced by update().

848  {
849  for (int k = 0; k < nHC_; ++k) {
850  previousID[k].reset();
851  primIDSaved[k] = -99;
852  cleanIndex[k] = 0;
853 #ifdef EDM_ML_DEBUG
854  edm::LogVerbatim("CaloSim") << "CaloSD: Clears hit vector for " << GetName()
855  << " and initialise slave: " << slave[k].get()->name();
856 #endif
857  slave[k].get()->Initialize();
858  }
859 }
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 624 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().

624  {
625 #ifdef EDM_ML_DEBUG
626  edm::LogVerbatim("CaloSim") << "CaloSD::CreateNewHit " << getNumberOfHits() << " for " << GetName()
627  << " Unit:" << currentID[k].unitID() << " " << currentID[k].depth()
628  << " Edep= " << edepositEM << " " << edepositHAD
629  << " primaryID= " << currentID[k].trackID()
630  << " timeSlice= " << currentID[k].timeSliceID() << " ID= " << theTrack->GetTrackID()
631  << " " << theTrack->GetDefinition()->GetParticleName()
632  << " E(GeV)= " << theTrack->GetKineticEnergy() / CLHEP::GeV
633  << " parentID= " << theTrack->GetParentID() << "\n Ein= " << incidentEnergy
634  << " entranceGlobal: " << entrancePoint << " entranceLocal: " << entranceLocal
635  << " posGlobal: " << posGlobal;
636 #endif
637 
638  CaloG4Hit* aHit;
639  if (!reusehit[k].empty()) {
640  aHit = reusehit[k].back().release();
641  aHit->setEM(0.f);
642  aHit->setHadr(0.f);
643  reusehit[k].pop_back();
644  } else {
645  aHit = new CaloG4Hit;
646  }
647 
648  aHit->setID(currentID[k]);
649  aHit->setEntry(entrancePoint.x(), entrancePoint.y(), entrancePoint.z());
651  aHit->setPosition(posGlobal.x(), posGlobal.y(), posGlobal.z());
653  updateHit(aHit, k);
654 
655  storeHit(aHit, k);
656  TrackInformation* trkInfo = cmsTrackInformation(theTrack);
657 
658 #ifdef EDM_ML_DEBUG
660  edm::LogVerbatim("DoFineCalo") << "New hit " << shortreprID(aHit) << " using finecalo;"
661  << " isItFineCalo(post)=" << isItFineCalo(aStep->GetPostStepPoint()->GetTouchable())
662  << " isItFineCalo(pre)=" << isItFineCalo(aStep->GetPreStepPoint()->GetTouchable());
663 #endif
664 
665  // 'Traditional', non-fine history bookkeeping
666  if (!doFineCaloThisStep_) {
667  double etrack = 0;
668  if (currentID[k].trackID() == primIDSaved[k]) { // The track is saved; nothing to be done
669  } else if (currentID[k].trackID() == theTrack->GetTrackID()) {
670  etrack = theTrack->GetKineticEnergy();
671 #ifdef EDM_ML_DEBUG
672  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID[k].trackID() << " etrack " << etrack
673  << " eCut " << energyCut << " force: " << forceSave
674  << " save: " << (etrack >= energyCut || forceSave);
675 #endif
676  if (etrack >= energyCut || forceSave) {
677  trkInfo->setStoreTrack();
678  }
679  } else {
681 #ifdef EDM_ML_DEBUG
682  edm::LogVerbatim("CaloSim") << "CaloSD : TrackWithHistory pointer for " << currentID[k].trackID() << " is "
683  << trkh;
684 #endif
685  if (trkh != nullptr) {
686  etrack = sqrt(trkh->momentum().Mag2());
687  if (etrack >= energyCut) {
688  trkh->setToBeSaved();
689 #ifdef EDM_ML_DEBUG
690  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID[k].trackID() << " with Hit";
691 #endif
692  }
693  }
694  }
696  }
697 
698  if (useMap)
699  ++totalHits[k];
700  return aHit;
701 }
float edepositEM
Definition: CaloSD.h:144
int getNumberOfHits(int k=0)
Definition: CaloSD.cc:521
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:368
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:703
float edepositHAD
Definition: CaloSD.h:144
T sqrt(T t)
Definition: SSEVec.h:19
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:937
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:538
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 430 of file CaloSD.cc.

430 {}

◆ endEvent()

void CaloSD::endEvent ( )
protectedvirtual

Reimplemented in HCalSD, and HGCSD.

Definition at line 871 of file CaloSD.cc.

Referenced by update().

871 {}

◆ EndOfEvent()

void CaloSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 412 of file CaloSD.cc.

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

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

◆ EnergyCorrected()

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

Reimplemented in ECalSD.

Definition at line 364 of file CaloSD.cc.

Referenced by ProcessHits().

364 { return aStep.GetTotalEnergyDeposit(); }

◆ fillHits()

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

Implements SensitiveCaloDetector.

Definition at line 441 of file CaloSD.cc.

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

441  {
442  for (int k = 0; k < nHC_; ++k) {
443 #ifdef EDM_ML_DEBUG
444  edm::LogVerbatim("CaloSim") << "CaloSD: Tries to transfer " << slave[k].get()->hits().size() << " hits for "
445  << slave[k].get()->name() << " " << hname;
446 #endif
447  if (slave[k].get()->name() == hname) {
448  cc = slave[k].get()->hits();
449  slave[k].get()->Clean();
450  }
451  }
452 }
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 917 of file CaloSD.cc.

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

Referenced by cleanHitCollection().

917  {
918  double emin(eminHit);
919  if (hit->getDepth() > 0)
920  emin = eminHitD;
921 #ifdef EDM_ML_DEBUG
922  edm::LogVerbatim("CaloSim") << "CaloSD::filterHit(..) Depth " << hit->getDepth() << " Emin = " << emin << " ("
923  << eminHit << ", " << eminHitD << ")";
924 #endif
925  return ((time <= tmaxHit) && (hit->getEnergyDeposit() > emin));
926 }
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 552 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_2023v12_cff::track.

Referenced by ProcessHits().

552  {
554  unsigned int id = track->GetTrackID();
555  // First see if this track is already in the map
556  auto it = boundaryCrossingParentMap_.find(id);
557  if (it != boundaryCrossingParentMap_.end()) {
558 #ifdef EDM_ML_DEBUG
559  edm::LogVerbatim("DoFineCalo") << "Track " << id << " parent already cached: " << it->second;
560 #endif
561  return it->second;
562  }
563  // Then see if the track itself crosses the boundary
564  else if (trkInfo->crossedBoundary()) {
565 #ifdef EDM_ML_DEBUG
566  edm::LogVerbatim("DoFineCalo") << "Track " << id << " crosses boundary itself";
567 #endif
569  trkInfo->setStoreTrack();
570  return id;
571  }
572  // Else, traverse the history of the track
573  std::vector<unsigned int> decayChain{id};
574 #ifdef EDM_ML_DEBUG
575  edm::LogVerbatim("DoFineCalo") << "Track " << id << ": Traversing history to find boundary-crossing parent";
576 #endif
577  unsigned int parentID = track->GetParentID();
578  while (true) {
579  if (parentID == 0)
580  throw cms::Exception("Unknown", "CaloSD")
581  << "Hit end of parentage for track " << id << " without finding a boundary-crossing parent";
582  // First check if this ancestor is already in the map
583  auto it = boundaryCrossingParentMap_.find(parentID);
584  if (it != boundaryCrossingParentMap_.end()) {
585 #ifdef EDM_ML_DEBUG
586  edm::LogVerbatim("DoFineCalo") << " Track " << parentID
587  << " boundary-crossing parent already cached: " << it->second;
588 #endif
589  // Store this parent also for the rest of the traversed decay chain
590  for (auto ancestorID : decayChain)
591  boundaryCrossingParentMap_[ancestorID] = it->second;
592 #ifdef EDM_ML_DEBUG
593  // In debug mode, still build the rest of the decay chain for debugging
594  decayChain.push_back(parentID);
595  while (parentID != it->second) {
596  parentID = m_trackManager->getTrackByID(parentID, true)->parentID();
597  decayChain.push_back(parentID);
598  }
599  edm::LogVerbatim("DoFineCalo") << " Full decay chain: " << printableDecayChain(decayChain);
600 #endif
601  return it->second;
602  }
603  // If not, get this parent from the track manager (expensive)
605  if (parentTrack->crossedBoundary()) {
606  if (markAsSaveable)
607  parentTrack->setToBeSaved();
608  decayChain.push_back(parentID);
609  // Record this boundary crossing parent for all traversed ancestors
610  for (auto ancestorID : decayChain)
611  boundaryCrossingParentMap_[ancestorID] = parentID;
612 #ifdef EDM_ML_DEBUG
613  edm::LogVerbatim("DoFineCalo") << " Found boundary-crossing ancestor " << parentID << " for track " << id
614  << "; decay chain: " << printableDecayChain(decayChain);
615 #endif
616  return parentID;
617  }
618  // Next iteration
619  decayChain.push_back(parentID);
620  parentID = parentTrack->parentID();
621  }
622 }
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:527
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 727 of file CaloSD.cc.

References funct::abs(), HltBtagPostValidation_cff::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().

727  {
728  double weight = 1.;
729  double charge = aStep->GetPreStepPoint()->GetCharge();
730  double length = aStep->GetStepLength();
731 
732  if (charge != 0. && length > 0.) {
733  double density = aStep->GetPreStepPoint()->GetMaterial()->GetDensity();
734  double dedx = aStep->GetTotalEnergyDeposit() / length;
735  double rkb = birk1 / density;
736  double c = birk2 * rkb * rkb;
737  if (std::abs(charge) >= 2.)
738  rkb /= birk3; // based on alpha particle data
739  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
740 #ifdef EDM_ML_DEBUG
741  edm::LogVerbatim("CaloSim") << "CaloSD::getAttenuation in " << aStep->GetPreStepPoint()->GetMaterial()->GetName()
742  << " Charge " << charge << " dE/dx " << dedx << " Birk Const " << rkb << ", " << c
743  << " Weight = " << weight << " dE " << aStep->GetTotalEnergyDeposit();
744 #endif
745  }
746  return weight;
747 }
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 913 of file CaloSD.cc.

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

913 { 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 362 of file CaloSD.cc.

Referenced by ProcessHits().

362 { return aStep->GetTotalEnergyDeposit(); }

◆ getFromLibrary()

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

Reimplemented in HCalSD, CastorSD, and ZdcSD.

Definition at line 366 of file CaloSD.cc.

Referenced by ProcessHits().

366 { return false; }

◆ getNumberOfHits()

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

Definition at line 521 of file CaloSD.cc.

References dqmdumpme::k, and theHC.

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

521 { 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 928 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().

928  {
929  double wt = 1.0;
930  if (meanResponse[k].get()) {
931  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
932  wt = meanResponse[k].get()->getWeight(trkInfo->genParticlePID(), trkInfo->genParticleP());
933  }
934  return wt;
935 }
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 873 of file CaloSD.cc.

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

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

873  {
874  int primaryID = 0;
875  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
876  if (trkInfo) {
877  primaryID = trkInfo->getIDonCaloSurface();
878 #ifdef EDM_ML_DEBUG
879  edm::LogVerbatim("CaloSim") << "Track ID: " << trkInfo->getIDonCaloSurface() << ":" << aTrack->GetTrackID() << ":"
880  << primaryID;
881 #endif
882  } else {
883  primaryID = aTrack->GetTrackID();
884 #ifdef EDM_ML_DEBUG
885  edm::LogWarning("CaloSim") << "CaloSD: Problem with primaryID **** set by force to TkID **** " << primaryID;
886 #endif
887  }
888  return primaryID;
889 }
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 462 of file CaloSD.cc.

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

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

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

Referenced by update().

869 {}

◆ Initialize()

void CaloSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 388 of file CaloSD.cc.

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

388  {
389 #ifdef EDM_ML_DEBUG
390  edm::LogVerbatim("CaloSim") << "CaloSD : Initialize called for " << detName_;
391 #endif
392 
393  for (int k = 0; k < nHC_; ++k) {
394  totalHits[k] = 0;
395 
396  //This initialization is performed at the beginning of an event
397  //------------------------------------------------------------
399 
400  if (hcID[k] < 0) {
401  hcID[k] = G4SDManager::GetSDMpointer()->GetCollectionID(collName_[k]);
402  }
403  //theHC ownership is transfered here to HCE
404  HCE->AddHitsCollection(hcID[k], theHC[k]);
405 #ifdef EDM_ML_DEBUG
406  edm::LogVerbatim("CaloSim") << "CaloSD : Add hits collection for " << hcID[k] << " for " << k << ":" << detName_
407  << ":" << collName_[k];
408 #endif
409  }
410 }
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 867 of file CaloSD.cc.

Referenced by update().

867 {}

◆ isItFineCalo()

bool CaloSD::isItFineCalo ( const G4VTouchable *  touch)

Definition at line 368 of file CaloSD.cc.

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

Referenced by createNewHit(), and ProcessHits().

368  {
369  bool ok(false);
370  int level = ((touch->GetHistoryDepth()) + 1);
371  for (const auto& detector : fineDetectors_) {
372  if (level > 0 && level >= detector.level) {
373  int ii = level - detector.level;
374  G4LogicalVolume* lv = touch->GetVolume(ii)->GetLogicalVolume();
375  ok = (lv == detector.lv);
376 #ifdef EDM_ML_DEBUG
377  std::string name1 = (lv == nullptr) ? "Unknown" : lv->GetName();
378  edm::LogVerbatim("CaloSim") << "CaloSD: volume " << name1 << ":" << detector.name << " at Level "
379  << detector.level << " Flag " << ok;
380 #endif
381  if (ok)
382  break;
383  }
384  }
385  return ok;
386 }
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 176 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().

176  {
177  for (unsigned int k = 0; k < hcn_.size(); ++k) {
178  if (name == hcn_[k]) {
179  if (k < useResMap_.size() && useResMap_[k] > 0) {
180  meanResponse[1] = std::make_unique<CaloMeanResponse>(p);
181  break;
182  }
183  }
184  }
185  slave[1] = std::make_unique<CaloSlaveSD>(name);
186 #ifdef EDM_ML_DEBUG
187  edm::LogVerbatim("CaloSim") << "CaloSD:: Initialise a second collection for " << name;
188  for (int k = 0; k < nHC_; ++k)
189  edm::LogVerbatim("CaloSim") << "Detector[" << k << "]" << detName_ << " collection " << collName_[k];
190 
191 #endif
192 }
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 527 of file CaloSD.cc.

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

Referenced by findBoundaryCrossingParent().

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

◆ PrintAll()

void CaloSD::PrintAll ( )
override

Definition at line 432 of file CaloSD.cc.

References dqmdumpme::k, nHC_, and theHC.

432  {
433  for (int k = 0; k < nHC_; ++k) {
434 #ifdef EDM_ML_DEBUG
435  edm::LogVerbatim("CaloSim") << "CaloSD: Collection " << theHC[k]->GetName();
436 #endif
437  theHC[k]->PrintAllHits();
438  }
439 }
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 1158 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().

1158  {
1159  //Print name and copy numbers
1160  int level = ((touch->GetHistoryDepth()) + 1);
1161  std::ostringstream st1;
1162  st1 << level << " Levels:";
1163  if (level > 0) {
1164  for (int ii = 0; ii < level; ii++) {
1165  int i = level - ii - 1;
1166  G4VPhysicalVolume* pv = touch->GetVolume(i);
1167  std::string name = (pv != nullptr) ? pv->GetName() : "Unknown";
1168  st1 << " " << name << ":" << touch->GetReplicaNumber(i);
1169  }
1170  }
1171  edm::LogVerbatim("CaloSim") << st1.str();
1172 }
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:488
void updateHit(CaloG4Hit *, int k)
Definition: CaloSD.cc:703
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
Definition: CaloSD.cc:624
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 194 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().

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

◆ ProcessHits() [2/2]

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

Definition at line 294 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_2023v12_cff::track, CaloHitID::unitID(), and updateHit().

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

Referenced by ProcessHits().

915 {}

◆ reset()

void CaloSD::reset ( void  )
overridevirtual

Reimplemented from SensitiveCaloDetector.

Definition at line 861 of file CaloSD.cc.

References fpCaloG4HitAllocator.

Referenced by CaloSD().

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

◆ resetForNewPrimary()

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

Definition at line 714 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().

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

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

References DTRecHitClients_cfi::local.

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

◆ setToLocal()

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

Definition at line 454 of file CaloSD.cc.

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

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

◆ setTrackID()

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

Reimplemented in ZdcSD.

Definition at line 891 of file CaloSD.cc.

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

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

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

References contentValuesCheck::ss.

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

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

◆ shortreprID() [2/2]

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

Definition at line 547 of file CaloSD.cc.

References shortreprID().

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

◆ storeHit()

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

Definition at line 937 of file CaloSD.cc.

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

Referenced by createNewHit().

937  {
938  if (hit == nullptr || previousID[k].trackID() < 0) {
939  edm::LogWarning("CaloSim") << "CaloSD: hit to be stored is nullptr !!"
940  << " previousID.trackID()= " << previousID[k].trackID();
941  return;
942  }
943 
944  theHC[k]->insert(hit);
945  if (useMap)
946  hitMap[k].insert(std::pair<CaloHitID, CaloG4Hit*>(previousID[k], hit));
947 }
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 749 of file CaloSD.cc.

References initRun().

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

749 { initRun(); }
virtual void initRun()
Definition: CaloSD.cc:867

◆ 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 751 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().

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

◆ 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 1013 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().

1013  {
1014  int primary = -1;
1015  TrackInformation* trkInfo = cmsTrackInformation((*trk)());
1016  if (trkInfo->isPrimary())
1017  primary = (*trk)()->GetTrackID();
1018 
1019 #ifdef EDM_ML_DEBUG
1020  edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary
1021  << " primary ancestor ID " << primAncestor;
1022 #endif
1023 
1024  // update the information if a different primary track ID
1025 
1026  if (primary > 0 && primary != primAncestor) {
1027  primAncestor = primary;
1028 
1029  // clean the hits information
1030 
1031  bool clean(false);
1032  for (int k = 0; k < nHC_; ++k)
1033  if (theHC[k]->entries() > 0)
1034  clean = true;
1035  if (clean)
1037  }
1038 }
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:1040
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 759 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().

759  {
760  int id = (*trk)()->GetTrackID();
761  TrackInformation* trkI = cmsTrackInformation((*trk)());
762  int lastTrackID = -1;
763  if (trkI)
764  lastTrackID = trkI->getIDonCaloSurface();
765  if (id == lastTrackID) {
766  auto trksForThisEvent = m_trackManager->trackContainer();
767  if (!trksForThisEvent->empty()) {
768  TrackWithHistory* trkH = trksForThisEvent->back();
769  if (trkH->trackID() == id) {
770  tkMap[id] = trkH;
771 #ifdef EDM_ML_DEBUG
772  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << id << " from Container of size "
773  << trksForThisEvent->size() << " with ID " << trkH->trackID();
774 #endif
775  }
776  }
777  }
778 }
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 780 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().

780  {
781  endEvent();
782  for (int k = 0; k < nHC_; ++k) {
783  slave[k].get()->ReserveMemory(theHC[k]->entries());
784 
785  int count(0);
786  double eEM(0.0);
787  double eHAD(0.0);
788  double eEM2(0.0);
789  double eHAD2(0.0);
790 #ifdef EDM_ML_DEBUG
791  int wrong(0);
792  double tt(0.0);
793  double zloc(0.0);
794  double zglob(0.0);
795  double ee(0.0);
796 #endif
797  int hc_entries = theHC[k]->entries();
798  for (int i = 0; i < hc_entries; ++i) {
799 #ifdef EDM_ML_DEBUG
800  if (!saveHit((*theHC[k])[i], k)) {
801  ++wrong;
802  }
803 #else
804  saveHit((*theHC[k])[i], k);
805 #endif
806 
807  ++count;
808  double x = (*theHC[k])[i]->getEM();
809  eEM += x;
810  eEM2 += x * x;
811  x = (*theHC[k])[i]->getHadr();
812  eHAD += x;
813  eHAD2 += x * x;
814 #ifdef EDM_ML_DEBUG
815  tt += (*theHC[k])[i]->getTimeSlice();
816  ee += (*theHC[k])[i]->getIncidentEnergy();
817  zglob += std::abs((*theHC[k])[i]->getEntry().z());
818  zloc += std::abs((*theHC[k])[i]->getEntryLocal().z());
819 #endif
820  }
821 
822  double norm = (count > 0) ? 1.0 / count : 0.0;
823  eEM *= norm;
824  eEM2 *= norm;
825  eHAD *= norm;
826  eHAD2 *= norm;
827  eEM2 = std::sqrt(eEM2 - eEM * eEM);
828  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
829 #ifdef EDM_ML_DEBUG
830  tt *= norm;
831  ee *= norm;
832  zglob *= norm;
833  zloc *= norm;
834  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
835  << " track IDs not given properly and " << totalHits - count
836  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
837  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
838  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
839 #endif
840  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit[k]);
841  if (useMap)
842  hitMap[k].erase(hitMap[k].begin(), hitMap[k].end());
843  }
844  tkMap.erase(tkMap.begin(), tkMap.end());
846 }
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:949
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:19
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:871
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 703 of file CaloSD.cc.

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

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

703  {
705 #ifdef EDM_ML_DEBUG
706  edm::LogVerbatim("CaloSim") << "CaloSD:" << GetName() << " Add energy deposit in " << currentID[k]
707  << " Edep_em(MeV)= " << edepositEM << " Edep_had(MeV)= " << edepositHAD;
708 #endif
709 
710  // buffer for next steps:
711  previousID[k] = currentID[k];
712 }
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().