CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | 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 ZdcSD

Public Member Functions

 CaloSD (const std::string &aSDname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
 
void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
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 edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, bool calo)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

bool checkHit ()
 
CaloG4HitcreateNewHit (const G4Step *, const G4Track *)
 
virtual void endEvent ()
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual uint16_t getDepth (const G4Step *)
 
virtual double getEnergyDeposit (const G4Step *step)
 
virtual bool getFromLibrary (const G4Step *step)
 
int getNumberOfHits ()
 
double getResponseWt (const G4Track *)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *)
 
virtual void initEvent (const BeginOfEvent *)
 
virtual void initRun ()
 
void processHit (const G4Step *step)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val)
 
void setParameterized (bool val)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *) const
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *) const
 
virtual int setTrackID (const G4Step *)
 
void setUseMap (bool val)
 
void update (const 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 *)
 
- 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...
 

Protected Attributes

CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
G4ThreeVector posGlobal
 
CaloHitID previousID
 
bool suppressHeavy
 
double tmaxHit
 

Private Member Functions

void cleanHitCollection ()
 
bool saveHit (CaloG4Hit *)
 
void storeHit (CaloG4Hit *)
 

Private Attributes

int cleanIndex
 
double correctT
 
bool corrTOFBeam
 
double eminHitD
 
int hcID
 
std::map< CaloHitID, CaloG4Hit * > hitMap
 
bool ignoreTrackID
 
bool isParameterized
 
const SimTrackManagerm_trackManager
 
std::unique_ptr< CaloMeanResponsemeanResponse
 
int nCheckedHits
 
int primAncestor
 
int primIDSaved
 
std::vector< std::unique_ptr< CaloG4Hit > > reusehit
 
std::unique_ptr< CaloSlaveSDslave
 
CaloG4HitCollectiontheHC
 
float timeSlice
 
std::map< int, TrackWithHistory * > tkMap
 
int totalHits
 
bool useMap
 

Additional Inherited Members

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

Detailed Description

Definition at line 38 of file CaloSD.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file CaloSD.cc.

References cleanIndex, correctT, corrTOFBeam, currentID, edepositEM, edepositHAD, eminHit, eminHitD, energyCut, entranceLocal, entrancePoint, forceSave, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), GeV, ignoreTrackID, incidentEnergy, isParameterized, dqmdumpme::k, kmaxIon, kmaxNeutron, kmaxProton, meanResponse, MeV, nCheckedHits, posGlobal, previousID, primAncestor, primIDSaved, slave, suppressHeavy, timeSlice, tmaxHit, totalHits, and useMap.

34  : SensitiveCaloDetector(name, es, clg, p),
35  G4VGFlashSensitiveDetector(),
36  eminHit(0.),
37  currentHit(nullptr),
38  m_trackManager(manager),
39  theHC(nullptr),
40  ignoreTrackID(ignoreTkID),
41  hcID(-1),
42  timeSlice(timeSliceUnit),
43  eminHitD(0.) {
44  //Parameters
45  edm::ParameterSet m_CaloSD = p.getParameter<edm::ParameterSet>("CaloSD");
46  energyCut = m_CaloSD.getParameter<double>("EminTrack") * GeV;
47  tmaxHit = m_CaloSD.getParameter<double>("TmaxHit") * ns;
48  std::vector<double> eminHits = m_CaloSD.getParameter<std::vector<double>>("EminHits");
49  std::vector<double> tmaxHits = m_CaloSD.getParameter<std::vector<double>>("TmaxHits");
50  std::vector<std::string> hcn = m_CaloSD.getParameter<std::vector<std::string>>("HCNames");
51  std::vector<int> useResMap = m_CaloSD.getParameter<std::vector<int>>("UseResponseTables");
52  std::vector<double> eminHitX = m_CaloSD.getParameter<std::vector<double>>("EminHitsDepth");
53  suppressHeavy = m_CaloSD.getParameter<bool>("SuppressHeavy");
54  kmaxIon = m_CaloSD.getParameter<double>("IonThreshold") * MeV;
55  kmaxProton = m_CaloSD.getParameter<double>("ProtonThreshold") * MeV;
56  kmaxNeutron = m_CaloSD.getParameter<double>("NeutronThreshold") * MeV;
57  nCheckedHits = m_CaloSD.getUntrackedParameter<int>("CheckHits", 25);
58  useMap = m_CaloSD.getUntrackedParameter<bool>("UseMap", true);
59  int verbn = m_CaloSD.getUntrackedParameter<int>("Verbosity", 0);
60  corrTOFBeam = m_CaloSD.getParameter<bool>("CorrectTOFBeam");
61  double beamZ = m_CaloSD.getParameter<double>("BeamPosition") * cm;
62  correctT = beamZ / c_light / nanosecond;
63 
64  SetVerboseLevel(verbn);
65  meanResponse.reset(nullptr);
66  for (unsigned int k = 0; k < hcn.size(); ++k) {
67  if (name == hcn[k]) {
68  if (k < eminHits.size())
69  eminHit = eminHits[k] * MeV;
70  if (k < eminHitX.size())
71  eminHitD = eminHitX[k] * MeV;
72  if (k < tmaxHits.size())
73  tmaxHit = tmaxHits[k] * ns;
74  if (k < useResMap.size() && useResMap[k] > 0) {
75  meanResponse.reset(new CaloMeanResponse(p));
76  break;
77  }
78  }
79  }
80  slave.reset(new CaloSlaveSD(name));
81 
84  isParameterized = false;
85 
86  entrancePoint.set(0., 0., 0.);
87  entranceLocal.set(0., 0., 0.);
88  posGlobal.set(0., 0., 0.);
90 
92  forceSave = false;
93 
94  edm::LogVerbatim("CaloSim") << "CaloSD: Minimum energy of track for saving it " << energyCut / GeV << " GeV"
95  << "\n"
96  << " Use of HitID Map " << useMap << "\n"
97  << " Check last " << nCheckedHits << " before saving the hit\n"
98  << " Correct TOF globally by " << correctT << " ns (Flag =" << corrTOFBeam << ")\n"
99  << " Save hits recorded before " << tmaxHit << " ns and if energy is above "
100  << eminHit / MeV << " MeV (for depth 0) or " << eminHitD / MeV
101  << " MeV (for nonzero depths);\n"
102  << " Time Slice Unit " << timeSlice << " Ignore TrackID Flag " << ignoreTrackID;
103 }
float edepositEM
Definition: CaloSD.h:129
double energyCut
Definition: CaloSD.h:133
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const double GeV
Definition: MathUtil.h:16
double kmaxNeutron
Definition: CaloSD.h:138
bool corrTOFBeam
Definition: CaloSD.h:153
int totalHits
Definition: CaloSD.h:158
bool useMap
Definition: CaloSD.h:152
int hcID
Definition: CaloSD.h:155
double eminHitD
Definition: CaloSD.h:163
G4ThreeVector posGlobal
Definition: CaloSD.h:127
int primIDSaved
Definition: CaloSD.h:159
int primAncestor
Definition: CaloSD.h:156
double kmaxProton
Definition: CaloSD.h:138
double eminHit
Definition: CaloSD.h:133
SensitiveCaloDetector(const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
const double MeV
bool forceSave
Definition: CaloSD.h:140
float timeSlice
Definition: CaloSD.h:162
double kmaxIon
Definition: CaloSD.h:138
bool suppressHeavy
Definition: CaloSD.h:137
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:145
float edepositHAD
Definition: CaloSD.h:129
CaloHitID previousID
Definition: CaloSD.h:131
CaloG4Hit * currentHit
Definition: CaloSD.h:135
double tmaxHit
Definition: CaloSD.h:133
std::unique_ptr< CaloMeanResponse > meanResponse
Definition: CaloSD.h:146
CaloHitID currentID
Definition: CaloSD.h:131
double correctT
Definition: CaloSD.h:164
int nCheckedHits
Definition: CaloSD.h:160
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
float incidentEnergy
Definition: CaloSD.h:128
bool isParameterized
Definition: CaloSD.h:151
const SimTrackManager * m_trackManager
Definition: CaloSD.h:143
G4ThreeVector entrancePoint
Definition: CaloSD.h:125
G4ThreeVector entranceLocal
Definition: CaloSD.h:126
int cleanIndex
Definition: CaloSD.h:157
bool ignoreTrackID
Definition: CaloSD.h:150
CaloSD::~CaloSD ( )
override

Definition at line 105 of file CaloSD.cc.

105 {}

Member Function Documentation

bool CaloSD::checkHit ( )
protected

Definition at line 314 of file CaloSD.cc.

References currentHit, currentID, newFWLiteAna::found, hitMap, dqmiolumiharvest::j, nCheckedHits, theHC, updateHit(), and useMap.

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

314  {
315  //look in the HitContainer whether a hit with the same ID already exists:
316  bool found = false;
317  if (useMap) {
318  std::map<CaloHitID, CaloG4Hit*>::const_iterator it = hitMap.find(currentID);
319  if (it != hitMap.end()) {
320  currentHit = it->second;
321  found = true;
322  }
323  } else if (nCheckedHits > 0) {
324  int minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0);
325  int maxhit = theHC->entries() - 1;
326 
327  for (int j = maxhit; j > minhit; --j) {
328  if ((*theHC)[j]->getID() == currentID) {
329  currentHit = (*theHC)[j];
330  found = true;
331  break;
332  }
333  }
334  }
335 
336  if (found) {
338  }
339  return found;
340 }
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:410
bool useMap
Definition: CaloSD.h:152
CaloG4Hit * currentHit
Definition: CaloSD.h:135
CaloHitID currentID
Definition: CaloSD.h:131
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:166
int nCheckedHits
Definition: CaloSD.h:160
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
void CaloSD::cleanHitCollection ( )
private

Definition at line 696 of file CaloSD.cc.

References cleanIndex, correctT, corrTOFBeam, cond::serialization::equal(), filterHit(), CaloG4Hit::getTimeSlice(), hitMap, mps_fire::i, cuy::ii, dqmiolumiharvest::j, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, reusehit, theHC, ntuplemaker::time, totalHits, and useMap.

Referenced by EndOfEvent(), setNumberCheckedHits(), and update().

696  {
697  std::vector<CaloG4Hit*>* theCollection = theHC->GetVector();
698 
699 #ifdef EDM_ML_DEBUG
700  edm::LogVerbatim("CaloSim") << "CaloSD: collection before merging, size = " << theHC->entries();
701 #endif
702  if (reusehit.empty())
703  reusehit.reserve(theHC->entries() - cleanIndex);
704 
705  // if no map used, merge before hits to have the save situation as a map
706  if (!useMap) {
707  std::vector<CaloG4Hit*> hitvec;
708 
709  hitvec.swap(*theCollection);
710  sort((hitvec.begin() + cleanIndex), hitvec.end(), CaloG4HitLess());
711 #ifdef EDM_ML_DEBUG
712  edm::LogVerbatim("CaloSim") << "CaloSD::cleanHitCollection: sort hits in buffer starting from "
713  << "element = " << cleanIndex;
714  for (unsigned int i = 0; i < hitvec.size(); ++i)
715  edm::LogVerbatim("CaloSim") << i << " " << *hitvec[i];
716 #endif
718  for (unsigned int i = cleanIndex; i < hitvec.size(); ++i) {
719  int jump = 0;
720  for (unsigned int j = i + 1; j < hitvec.size() && equal(hitvec[i], hitvec[j]); ++j) {
721  ++jump;
722  // merge j to i
723  (*hitvec[i]).addEnergyDeposit(*hitvec[j]);
724  (*hitvec[j]).setEM(0.);
725  (*hitvec[j]).setHadr(0.);
726  reusehit.emplace_back(hitvec[j]);
727  hitvec[j] = nullptr;
728  }
729  i += jump;
730  }
731 #ifdef EDM_ML_DEBUG
732  edm::LogVerbatim("CaloSim") << "CaloSD: cleanHitCollection merge the hits in buffer ";
733  for (unsigned int i = 0; i < hitvec.size(); ++i)
734  edm::LogVerbatim("CaloSim") << i << " " << *hitvec[i];
735 #endif
736  //move all nullptr to end of list and then remove them
737  hitvec.erase(
738  std::stable_partition(hitvec.begin() + cleanIndex, hitvec.end(), [](CaloG4Hit* p) { return p != nullptr; }),
739  hitvec.end());
740 #ifdef EDM_ML_DEBUG
741  edm::LogVerbatim("CaloSim") << "CaloSD::cleanHitCollection: remove the merged hits in buffer,"
742  << " new size = " << hitvec.size();
743  for (unsigned int i = 0; i < hitvec.size(); ++i)
744  edm::LogVerbatim("CaloSim") << i << " " << *hitvec[i];
745 #endif
746  hitvec.swap(*theCollection);
747  totalHits = theHC->entries();
748  }
749 
750 #ifdef EDM_ML_DEBUG
751  edm::LogVerbatim("CaloSim") << "CaloSD: collection after merging, size= " << theHC->entries()
752  << " Size of reusehit= " << reusehit.size()
753  << "\n starting hit selection from index = " << cleanIndex;
754 #endif
755 
756  int addhit = 0;
757  for (unsigned int i = cleanIndex; i < theCollection->size(); ++i) {
758  CaloG4Hit* aHit((*theCollection)[i]);
759 
760  // selection
761 
762  double time = aHit->getTimeSlice();
763  if (corrTOFBeam)
764  time += correctT;
765  if (!filterHit(aHit, time)) {
766 #ifdef EDM_ML_DEBUG
767  edm::LogVerbatim("CaloSim") << "CaloSD: dropped CaloG4Hit "
768  << " " << *aHit;
769 #endif
770 
771  // create the list of hits to be reused
772 
773  reusehit.emplace_back((*theCollection)[i]);
774  (*theCollection)[i] = nullptr;
775  ++addhit;
776  }
777  }
778 
779 #ifdef EDM_ML_DEBUG
780  edm::LogVerbatim("CaloSim") << "CaloSD: Size of reusehit after selection = " << reusehit.size()
781  << " Number of added hit = " << addhit;
782 #endif
783  if (useMap) {
784  if (addhit > 0) {
785  int offset = reusehit.size() - addhit;
786  for (int ii = addhit - 1; ii >= 0; --ii) {
787  CaloHitID theID = reusehit[offset + ii]->getID();
788  hitMap.erase(theID);
789  }
790  }
791  }
792 
793  //move all nullptr to end of list and then remove them
794  theCollection->erase(
795  std::stable_partition(
796  theCollection->begin() + cleanIndex, theCollection->end(), [](CaloG4Hit* p) { return p != nullptr; }),
797  theCollection->end());
798 #ifdef EDM_ML_DEBUG
799  edm::LogVerbatim("CaloSim") << "CaloSD: hit collection after selection, size = " << theHC->entries();
800  theHC->PrintAllHits();
801 #endif
802 
803  cleanIndex = theHC->entries();
804 }
bool corrTOFBeam
Definition: CaloSD.h:153
int totalHits
Definition: CaloSD.h:158
bool useMap
Definition: CaloSD.h:152
bool equal(const T &first, const T &second)
Definition: Equal.h:32
virtual bool filterHit(CaloG4Hit *, double)
Definition: CaloSD.cc:609
ii
Definition: cuy.py:590
double correctT
Definition: CaloSD.h:164
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:166
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
std::vector< std::unique_ptr< CaloG4Hit > > reusehit
Definition: CaloSD.h:168
int cleanIndex
Definition: CaloSD.h:157
void CaloSD::clear ( void  )
override

Definition at line 273 of file CaloSD.cc.

273 {}
void CaloSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 548 of file CaloSD.cc.

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

Referenced by update().

548  {
549  cleanIndex = 0;
550  previousID.reset();
551  primIDSaved = -99;
552 #ifdef EDM_ML_DEBUG
553  edm::LogVerbatim("CaloSim") << "CaloSD: Clears hit vector for " << GetName()
554  << " and initialise slave: " << slave.get()->name();
555 #endif
556  slave.get()->Initialize();
557 }
int primIDSaved
Definition: CaloSD.h:159
void reset()
Definition: CaloHitID.cc:48
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:145
CaloHitID previousID
Definition: CaloSD.h:131
int cleanIndex
Definition: CaloSD.h:157
CaloG4Hit * CaloSD::createNewHit ( const G4Step *  aStep,
const G4Track *  theTrack 
)
protected

Definition at line 344 of file CaloSD.cc.

References SensitiveDetector::cmsTrackInformation(), currentID, CaloHitID::depth(), edepositEM, edepositHAD, energyCut, entranceLocal, entrancePoint, f, forceSave, getNumberOfHits(), GeV, incidentEnergy, TrackWithHistory::momentum(), posGlobal, primIDSaved, TrackInformation::putInHistory(), reusehit, TrackWithHistory::save(), CaloG4Hit::setEM(), CaloG4Hit::setEntry(), CaloG4Hit::setEntryLocal(), CaloG4Hit::setHadr(), CaloG4Hit::setID(), CaloG4Hit::setIncidentEnergy(), CaloG4Hit::setPosition(), mathSSE::sqrt(), storeHit(), TrackInformation::storeTrack(), CaloHitID::timeSliceID(), tkMap, totalHits, CaloHitID::trackID(), CaloHitID::unitID(), updateHit(), and useMap.

Referenced by processHit(), and ProcessHits().

344  {
345 #ifdef EDM_ML_DEBUG
346  edm::LogVerbatim("CaloSim") << "CaloSD::CreateNewHit " << getNumberOfHits() << " for " << GetName()
347  << " Unit:" << currentID.unitID() << " " << currentID.depth() << " Edep= " << edepositEM
348  << " " << edepositHAD << " primaryID= " << currentID.trackID()
349  << " timeSlice= " << currentID.timeSliceID() << " ID= " << theTrack->GetTrackID() << " "
350  << theTrack->GetDefinition()->GetParticleName()
351  << " E(GeV)= " << theTrack->GetKineticEnergy() / GeV
352  << " parentID= " << theTrack->GetParentID() << "\n Ein= " << incidentEnergy
353  << " entranceGlobal: " << entrancePoint << " entranceLocal: " << entranceLocal
354  << " posGlobal: " << posGlobal;
355 #endif
356 
357  CaloG4Hit* aHit;
358  if (!reusehit.empty()) {
359  aHit = reusehit.back().release();
360  aHit->setEM(0.f);
361  aHit->setHadr(0.f);
362  reusehit.pop_back();
363  } else {
364  aHit = new CaloG4Hit;
365  }
366 
367  aHit->setID(currentID);
368  aHit->setEntry(entrancePoint.x(), entrancePoint.y(), entrancePoint.z());
370  aHit->setPosition(posGlobal.x(), posGlobal.y(), posGlobal.z());
372  updateHit(aHit);
373 
374  storeHit(aHit);
375  double etrack = 0;
376  if (currentID.trackID() == primIDSaved) { // The track is saved; nothing to be done
377  } else if (currentID.trackID() == theTrack->GetTrackID()) {
378  etrack = theTrack->GetKineticEnergy();
379 #ifdef EDM_ML_DEBUG
380  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID.trackID() << " etrack " << etrack
381  << " eCut " << energyCut << " force: " << forceSave
382  << " save: " << (etrack >= energyCut || forceSave);
383 #endif
384  if (etrack >= energyCut || forceSave) {
385  TrackInformation* trkInfo = cmsTrackInformation(theTrack);
386  trkInfo->storeTrack(true);
387  trkInfo->putInHistory();
388  }
389  } else {
391 #ifdef EDM_ML_DEBUG
392  edm::LogVerbatim("CaloSim") << "CaloSD : TrackwithHistory pointer for " << currentID.trackID() << " is " << trkh;
393 #endif
394  if (trkh != nullptr) {
395  etrack = sqrt(trkh->momentum().Mag2());
396  if (etrack >= energyCut) {
397  trkh->save();
398 #ifdef EDM_ML_DEBUG
399  edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID.trackID() << " with Hit";
400 #endif
401  }
402  }
403  }
405  if (useMap)
406  ++totalHits;
407  return aHit;
408 }
float edepositEM
Definition: CaloSD.h:129
double energyCut
Definition: CaloSD.h:133
const double GeV
Definition: MathUtil.h:16
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:410
bool storeTrack() const
int totalHits
Definition: CaloSD.h:158
void setIncidentEnergy(double e)
Definition: CaloG4Hit.h:62
void setEntryLocal(double x, double y, double z)
Definition: CaloG4Hit.h:50
bool useMap
Definition: CaloSD.h:152
G4ThreeVector posGlobal
Definition: CaloSD.h:127
int primIDSaved
Definition: CaloSD.h:159
uint16_t depth() const
Definition: CaloHitID.h:24
bool forceSave
Definition: CaloSD.h:140
int timeSliceID() const
Definition: CaloHitID.h:21
float edepositHAD
Definition: CaloSD.h:129
T sqrt(T t)
Definition: SSEVec.h:19
int trackID() const
Definition: CaloHitID.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:71
double f[11][100]
int getNumberOfHits()
Definition: CaloSD.cc:342
void storeHit(CaloG4Hit *)
Definition: CaloSD.cc:629
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
CaloHitID currentID
Definition: CaloSD.h:131
const math::XYZVectorD & momentum() const
void setHadr(double e)
Definition: CaloG4Hit.h:59
float incidentEnergy
Definition: CaloSD.h:128
void setPosition(double x, double y, double z)
Definition: CaloG4Hit.h:53
void setEntry(double x, double y, double z)
Definition: CaloG4Hit.h:47
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:167
std::vector< std::unique_ptr< CaloG4Hit > > reusehit
Definition: CaloSD.h:168
uint32_t unitID() const
Definition: CaloHitID.h:20
G4ThreeVector entrancePoint
Definition: CaloSD.h:125
G4ThreeVector entranceLocal
Definition: CaloSD.h:126
void CaloSD::DrawAll ( )
override

Definition at line 275 of file CaloSD.cc.

275 {}
void CaloSD::endEvent ( )
protectedvirtual

Reimplemented in HGCSD.

Definition at line 569 of file CaloSD.cc.

Referenced by update().

569 {}
void CaloSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 263 of file CaloSD.cc.

References cleanHitCollection(), and theHC.

263  {
264  // clean the hits for the last tracks
265 
267 
268 #ifdef EDM_ML_DEBUG
269  edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC->entries() << " entries";
270 #endif
271 }
void cleanHitCollection()
Definition: CaloSD.cc:696
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
void CaloSD::fillHits ( edm::PCaloHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveCaloDetector.

Definition at line 284 of file CaloSD.cc.

References slave.

284  {
285  if (slave.get()->name() == hname) {
286  cc = slave.get()->hits();
287  }
288  slave.get()->Clean();
289 }
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:145
bool CaloSD::filterHit ( CaloG4Hit hit,
double  time 
)
protectedvirtual

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

Definition at line 609 of file CaloSD.cc.

References eminHit, eminHitD, CaloG4Hit::getDepth(), CaloG4Hit::getEnergyDeposit(), and tmaxHit.

Referenced by cleanHitCollection().

609  {
610  double emin(eminHit);
611  if (hit->getDepth() > 0)
612  emin = eminHitD;
613 #ifdef EDM_ML_DEBUG
614  edm::LogVerbatim("CaloSim") << "CaloSD::filterHit(..) Depth " << hit->getDepth() << " Emin = " << emin << " ("
615  << eminHit << ", " << eminHitD << ")";
616 #endif
617  return ((time <= tmaxHit) && (hit->getEnergyDeposit() > emin));
618 }
uint16_t getDepth() const
Definition: CaloG4Hit.h:68
double eminHitD
Definition: CaloSD.h:163
double eminHit
Definition: CaloSD.h:133
double tmaxHit
Definition: CaloSD.h:133
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
double CaloSD::getAttenuation ( const G4Step *  aStep,
double  birk1,
double  birk2,
double  birk3 
) const
protected

Definition at line 434 of file CaloSD.cc.

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

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

434  {
435  double weight = 1.;
436  double charge = aStep->GetPreStepPoint()->GetCharge();
437  double length = aStep->GetStepLength();
438 
439  if (charge != 0. && length > 0.) {
440  double density = aStep->GetPreStepPoint()->GetMaterial()->GetDensity();
441  double dedx = aStep->GetTotalEnergyDeposit() / length;
442  double rkb = birk1 / density;
443  double c = birk2 * rkb * rkb;
444  if (std::abs(charge) >= 2.)
445  rkb /= birk3; // based on alpha particle data
446  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
447 #ifdef EDM_ML_DEBUG
448  edm::LogVerbatim("CaloSim") << "CaloSD::getAttenuation in " << aStep->GetPreStepPoint()->GetMaterial()->GetName()
449  << " Charge " << charge << " dE/dx " << dedx << " Birk Const " << rkb << ", " << c
450  << " Weight = " << weight << " dE " << aStep->GetTotalEnergyDeposit();
451 #endif
452  }
453  return weight;
454 }
Definition: weight.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint16_t CaloSD::getDepth ( const G4Step *  )
protectedvirtual

Reimplemented in ECalSD.

Definition at line 607 of file CaloSD.cc.

Referenced by ProcessHits().

607 { return 0; }
double CaloSD::getEnergyDeposit ( const G4Step *  step)
protectedvirtual

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

Definition at line 241 of file CaloSD.cc.

Referenced by ProcessHits().

241 { return aStep->GetTotalEnergyDeposit(); }
bool CaloSD::getFromLibrary ( const G4Step *  step)
protectedvirtual

Reimplemented in HCalSD, CastorSD, and ZdcSD.

Definition at line 243 of file CaloSD.cc.

Referenced by ProcessHits().

243 { return false; }
int CaloSD::getNumberOfHits ( )
protected

Definition at line 342 of file CaloSD.cc.

References theHC.

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

342 { return theHC->entries(); }
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
double CaloSD::getResponseWt ( const G4Track *  aTrack)
protected

Definition at line 620 of file CaloSD.cc.

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

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

620  {
621  double wt = 1.0;
622  if (meanResponse.get()) {
623  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
624  wt = meanResponse.get()->getWeight(trkInfo->genParticlePID(), trkInfo->genParticleP());
625  }
626  return wt;
627 }
double genParticleP() const
int genParticlePID() const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
std::unique_ptr< CaloMeanResponse > meanResponse
Definition: CaloSD.h:146
int CaloSD::getTrackID ( const G4Track *  aTrack)
protectedvirtual

Reimplemented in ECalSD.

Definition at line 571 of file CaloSD.cc.

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

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

571  {
572  int primaryID = 0;
573  forceSave = false;
574  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
575  if (trkInfo) {
576  primaryID = trkInfo->getIDonCaloSurface();
577 #ifdef EDM_ML_DEBUG
578  edm::LogVerbatim("CaloSim") << "CaloSD: hit update from track Id on Calo Surface " << trkInfo->getIDonCaloSurface();
579 #endif
580  } else {
581  primaryID = aTrack->GetTrackID();
582 #ifdef EDM_ML_DEBUG
583  edm::LogWarning("CaloSim") << "CaloSD: Problem with primaryID **** set by force to TkID **** " << primaryID;
584 #endif
585  }
586  return primaryID;
587 }
int getIDonCaloSurface() const
bool forceSave
Definition: CaloSD.h:140
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
bool CaloSD::hitExists ( const G4Step *  aStep)
protected

Definition at line 299 of file CaloSD.cc.

References checkHit(), currentHit, currentID, posGlobal, previousID, resetForNewPrimary(), CaloHitID::trackID(), and updateHit().

Referenced by ProcessHits().

299  {
300  // Update if in the same detector, time-slice and for same track
301  if (currentID == previousID) {
303  return true;
304  }
305 
306  // Reset entry point for new primary
307  posGlobal = aStep->GetPreStepPoint()->GetPosition();
308  if (currentID.trackID() != previousID.trackID()) {
309  resetForNewPrimary(aStep);
310  }
311  return checkHit();
312 }
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:410
G4ThreeVector posGlobal
Definition: CaloSD.h:127
bool checkHit()
Definition: CaloSD.cc:314
int trackID() const
Definition: CaloHitID.h:23
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:421
CaloHitID previousID
Definition: CaloSD.h:131
CaloG4Hit * currentHit
Definition: CaloSD.h:135
CaloHitID currentID
Definition: CaloSD.h:131
void CaloSD::initEvent ( const BeginOfEvent )
protectedvirtual

Reimplemented in HGCSD.

Definition at line 567 of file CaloSD.cc.

Referenced by update().

567 {}
void CaloSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 245 of file CaloSD.cc.

References bysipixelclustmulteventfilter_cfi::collectionName, hcID, theHC, and totalHits.

245  {
246  totalHits = 0;
247 
248 #ifdef EDM_ML_DEBUG
249  edm::LogVerbatim("CaloSim") << "CaloSD : Initialize called for " << GetName();
250 #endif
251 
252  //This initialization is performed at the beginning of an event
253  //------------------------------------------------------------
254  theHC = new CaloG4HitCollection(GetName(), collectionName[0]);
255 
256  if (hcID < 0) {
257  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
258  }
259  //theHC ownership is transfered here to HCE
260  HCE->AddHitsCollection(hcID, theHC);
261 }
int totalHits
Definition: CaloSD.h:158
int hcID
Definition: CaloSD.h:155
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
void CaloSD::initRun ( )
protectedvirtual

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

Definition at line 565 of file CaloSD.cc.

Referenced by update().

565 {}
void CaloSD::PrintAll ( )
override

Definition at line 277 of file CaloSD.cc.

References theHC.

277  {
278 #ifdef EDM_ML_DEBUG
279  edm::LogVerbatim("CaloSim") << "CaloSD: Collection " << theHC->GetName();
280 #endif
281  theHC->PrintAllHits();
282 }
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
void CaloSD::processHit ( const G4Step *  step)
inlineprotected

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

103  {
104  // check if it is in the same unit and timeslice as the previous one
105  if (currentID == previousID) {
107  } else if (!checkHit()) {
108  currentHit = createNewHit(step, step->GetTrack());
109  }
110  }
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:410
bool checkHit()
Definition: CaloSD.cc:314
CaloG4Hit * createNewHit(const G4Step *, const G4Track *)
Definition: CaloSD.cc:344
CaloHitID previousID
Definition: CaloSD.h:131
CaloG4Hit * currentHit
Definition: CaloSD.h:135
CaloHitID currentID
Definition: CaloSD.h:131
step
Definition: StallMonitor.cc:94
G4bool CaloSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Definition at line 107 of file CaloSD.cc.

References createNewHit(), currentHit, currentID, TauDecayModes::dec, LEDCalibrationChannels::depth, edepositEM, edepositHAD, HCALHighEnergyHPDFilter_cfi::energy, getDepth(), getEnergyDeposit(), getFromLibrary(), getTrackID(), hitExists(), G4TrackToParticleID::isGammaElectronPositron(), isParameterized, SensitiveDetector::NaNTrap(), previousID, setDetUnitId(), CaloHitID::setID(), ntuplemaker::time, and CaloHitID::unitID().

107  {
108  NaNTrap(aStep);
109 
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " ID= " << aStep->GetTrack()->GetTrackID()
112  << " prID= " << aStep->GetTrack()->GetParentID()
113  << " Eprestep= " << aStep->GetPreStepPoint()->GetKineticEnergy()
114  << " step= " << aStep->GetStepLength() << " Edep= " << aStep->GetTotalEnergyDeposit();
115 #endif
116  // apply shower library or parameterisation
117  if (isParameterized) {
118  if (getFromLibrary(aStep)) {
119  // for parameterized showers the primary track should be killed
120  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
121  auto tv = aStep->GetSecondary();
122  auto vol = aStep->GetPreStepPoint()->GetPhysicalVolume();
123  for (auto& tk : *tv) {
124  if (tk->GetVolume() == vol) {
125  tk->SetTrackStatus(fStopAndKill);
126  }
127  }
128  return true;
129  }
130  }
131 
132  // ignore steps without energy deposit
133  edepositEM = edepositHAD = 0.f;
134  unsigned int unitID = setDetUnitId(aStep);
135  auto const theTrack = aStep->GetTrack();
136  uint16_t depth = getDepth(aStep);
137 
138  double time = theTrack->GetGlobalTime() / nanosecond;
139  int primaryID = getTrackID(theTrack);
140  if (unitID > 0) {
141  currentID.setID(unitID, time, primaryID, depth);
142  } else {
143  if (aStep->GetTotalEnergyDeposit() > 0.0) {
144  const G4TouchableHistory* touch = static_cast<const G4TouchableHistory*>(theTrack->GetTouchable());
145  edm::LogVerbatim("CaloSim") << "CaloSD::ProcessHits: unitID= " << unitID << " currUnit= " << currentID.unitID()
146  << " Detector: " << GetName() << " trackID= " << theTrack->GetTrackID() << " "
147  << theTrack->GetDefinition()->GetParticleName()
148  << "\n Edep= " << aStep->GetTotalEnergyDeposit()
149  << " PV: " << touch->GetVolume(0)->GetName()
150  << " PVid= " << touch->GetReplicaNumber(0) << " MVid= " << touch->GetReplicaNumber(1);
151  }
152  return false;
153  }
154 
155  if (aStep->GetTotalEnergyDeposit() == 0.0) {
156  return false;
157  }
158 
159  double energy = getEnergyDeposit(aStep);
160  if (energy > 0.0) {
162  edepositEM = energy;
163  } else {
165  }
166 #ifdef EDM_ML_DEBUG
167  G4TouchableHistory* touch = (G4TouchableHistory*)(theTrack->GetTouchable());
168  edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " PV:" << touch->GetVolume(0)->GetName()
169  << " PVid=" << touch->GetReplicaNumber(0) << " MVid=" << touch->GetReplicaNumber(1)
170  << " Unit:" << std::hex << unitID << std::dec << " Edep=" << edepositEM << " "
171  << edepositHAD << " ID=" << theTrack->GetTrackID() << " pID=" << theTrack->GetParentID()
172  << " E=" << theTrack->GetKineticEnergy() << " S=" << aStep->GetStepLength() << "\n "
173  << theTrack->GetDefinition()->GetParticleName() << " primaryID= " << primaryID
174  << " currentID= (" << currentID << ") previousID= (" << previousID << ")";
175 #endif
176  if (!hitExists(aStep)) {
177  currentHit = createNewHit(aStep, aStep->GetTrack());
178  }
179  return true;
180  }
181  return false;
182 }
float edepositEM
Definition: CaloSD.h:129
virtual bool getFromLibrary(const G4Step *step)
Definition: CaloSD.cc:243
virtual uint16_t getDepth(const G4Step *)
Definition: CaloSD.cc:607
virtual double getEnergyDeposit(const G4Step *step)
Definition: CaloSD.cc:241
uint32_t setDetUnitId(const G4Step *step) override=0
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:571
float edepositHAD
Definition: CaloSD.h:129
CaloG4Hit * createNewHit(const G4Step *, const G4Track *)
Definition: CaloSD.cc:344
CaloHitID previousID
Definition: CaloSD.h:131
CaloG4Hit * currentHit
Definition: CaloSD.h:135
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
bool hitExists(const G4Step *)
Definition: CaloSD.cc:299
CaloHitID currentID
Definition: CaloSD.h:131
static bool isGammaElectronPositron(int pdgCode)
bool isParameterized
Definition: CaloSD.h:151
uint32_t unitID() const
Definition: CaloHitID.h:20
void NaNTrap(const G4Step *step) const
bool CaloSD::ProcessHits ( G4GFlashSpot *  aSpot,
G4TouchableHistory *   
)
override

Definition at line 184 of file CaloSD.cc.

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

184  {
185  edepositEM = edepositHAD = 0.f;
186  const G4Track* track = aSpot->GetOriginatorTrack()->GetPrimaryTrack();
188  return false;
189  }
190  double edep = aSpot->GetEnergySpot()->GetEnergy();
191  if (edep <= 0.0) {
192  return false;
193  }
194  edepositEM = edep;
195  G4Step fFakeStep;
196  G4StepPoint* fFakePreStepPoint = fFakeStep.GetPreStepPoint();
197  G4StepPoint* fFakePostStepPoint = fFakeStep.GetPostStepPoint();
198  fFakePreStepPoint->SetPosition(aSpot->GetPosition());
199  fFakePostStepPoint->SetPosition(aSpot->GetPosition());
200 
201  G4TouchableHandle fTouchableHandle = aSpot->GetTouchableHandle();
202  fFakePreStepPoint->SetTouchableHandle(fTouchableHandle);
203  fFakeStep.SetTotalEnergyDeposit(edep);
204 
205  unsigned int unitID = setDetUnitId(&fFakeStep);
206 
207  if (unitID > 0) {
208  double time = 0;
209  int primaryID = getTrackID(track);
210  uint16_t depth = getDepth(&fFakeStep);
211  currentID.setID(unitID, time, primaryID, depth);
212 #ifdef EDM_ML_DEBUG
213  edm::LogVerbatim("CaloSim") << "CaloSD:: GetSpotInfo for Unit 0x" << std::hex << currentID.unitID() << std::dec
214  << " Edeposit = " << edepositEM << " " << edepositHAD;
215 #endif
216  // Update if in the same detector, time-slice and for same track
217  if (currentID == previousID) {
219  } else {
220  posGlobal = aSpot->GetEnergySpot()->GetPosition();
221  // Reset entry point for new primary
222  if (currentID.trackID() != previousID.trackID()) {
223  entrancePoint = aSpot->GetPosition();
224  entranceLocal = aSpot->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(entrancePoint);
225  incidentEnergy = track->GetKineticEnergy();
226 #ifdef EDM_ML_DEBUG
227  edm::LogVerbatim("CaloSim") << "CaloSD: Incident energy " << incidentEnergy / GeV << " GeV and"
228  << " entrance point " << entrancePoint << " (Global) " << entranceLocal
229  << " (Local)";
230 #endif
231  }
232  if (!checkHit()) {
233  currentHit = createNewHit(&fFakeStep, track);
234  }
235  }
236  return true;
237  }
238  return false;
239 }
float edepositEM
Definition: CaloSD.h:129
const double GeV
Definition: MathUtil.h:16
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:410
virtual uint16_t getDepth(const G4Step *)
Definition: CaloSD.cc:607
uint32_t setDetUnitId(const G4Step *step) override=0
G4ThreeVector posGlobal
Definition: CaloSD.h:127
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:571
bool checkHit()
Definition: CaloSD.cc:314
float edepositHAD
Definition: CaloSD.h:129
int trackID() const
Definition: CaloHitID.h:23
CaloG4Hit * createNewHit(const G4Step *, const G4Track *)
Definition: CaloSD.cc:344
CaloHitID previousID
Definition: CaloSD.h:131
CaloG4Hit * currentHit
Definition: CaloSD.h:135
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
CaloHitID currentID
Definition: CaloSD.h:131
float incidentEnergy
Definition: CaloSD.h:128
static bool isGammaElectronPositron(int pdgCode)
uint32_t unitID() const
Definition: CaloHitID.h:20
G4ThreeVector entrancePoint
Definition: CaloSD.h:125
G4ThreeVector entranceLocal
Definition: CaloSD.h:126
void CaloSD::reset ( void  )
overridevirtual

Reimplemented from SensitiveCaloDetector.

Definition at line 559 of file CaloSD.cc.

References fpCaloG4HitAllocator.

559  {
560  if (fpCaloG4HitAllocator) {
561  fpCaloG4HitAllocator->ResetStorage();
562  }
563 }
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:11
void CaloSD::resetForNewPrimary ( const G4Step *  aStep)
protected

Definition at line 421 of file CaloSD.cc.

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

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

421  {
422  auto const preStepPoint = aStep->GetPreStepPoint();
423  entrancePoint = preStepPoint->GetPosition();
424  entranceLocal = setToLocal(entrancePoint, preStepPoint->GetTouchable());
425  incidentEnergy = preStepPoint->GetKineticEnergy();
426 #ifdef EDM_ML_DEBUG
427  edm::LogVerbatim("CaloSim") << "CaloSD::resetForNewPrimary for " << GetName()
428  << " ID= " << aStep->GetTrack()->GetTrackID() << " Ein= " << incidentEnergy / GeV
429  << " GeV and"
430  << " entrance point global: " << entrancePoint << " local: " << entranceLocal;
431 #endif
432 }
const double GeV
Definition: MathUtil.h:16
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:291
float incidentEnergy
Definition: CaloSD.h:128
G4ThreeVector entrancePoint
Definition: CaloSD.h:125
G4ThreeVector entranceLocal
Definition: CaloSD.h:126
bool CaloSD::saveHit ( CaloG4Hit aHit)
private

Definition at line 641 of file CaloSD.cc.

References correctT, corrTOFBeam, TauDecayModes::dec, CaloG4Hit::getDepth(), CaloG4Hit::getEM(), CaloG4Hit::getHadr(), CaloG4Hit::getTimeSlice(), CaloG4Hit::getTrackID(), CaloG4Hit::getUnitID(), GeV, SimTrackManager::giveMotherNeeded(), m_trackManager, convertSQLiteXML::ok, slave, ntuplemaker::time, and SimTrackManager::trackExists().

Referenced by setNumberCheckedHits(), and update().

641  {
642  int tkID;
643  bool ok = true;
644  if (m_trackManager) {
645  tkID = m_trackManager->giveMotherNeeded(aHit->getTrackID());
646  if (tkID == 0) {
647  if (m_trackManager->trackExists(aHit->getTrackID()))
648  tkID = (aHit->getTrackID());
649  else {
650  ok = false;
651  }
652  }
653  } else {
654  tkID = aHit->getTrackID();
655  ok = false;
656  }
657 #ifdef EDM_ML_DEBUG
658  edm::LogVerbatim("CaloSim") << "CalosD: Track ID " << aHit->getTrackID() << " changed to " << tkID
659  << " by SimTrackManager Status " << ok;
660 #endif
661  double time = aHit->getTimeSlice();
662  if (corrTOFBeam)
663  time += correctT;
664  slave.get()->processHits(aHit->getUnitID(), aHit->getEM() / GeV, aHit->getHadr() / GeV, time, tkID, aHit->getDepth());
665 #ifdef EDM_ML_DEBUG
666  edm::LogVerbatim("CaloSim") << "CaloSD: Store Hit at " << std::hex << aHit->getUnitID() << std::dec << " "
667  << aHit->getDepth() << " due to " << tkID << " in time " << time << " of energy "
668  << aHit->getEM() / GeV << " GeV (EM) and " << aHit->getHadr() / GeV << " GeV (Hadr)";
669 #endif
670  return ok;
671 }
const double GeV
Definition: MathUtil.h:16
bool corrTOFBeam
Definition: CaloSD.h:153
uint16_t getDepth() const
Definition: CaloG4Hit.h:68
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:145
bool trackExists(unsigned int i) const
int giveMotherNeeded(int i) const
int getTrackID() const
Definition: CaloG4Hit.h:64
double correctT
Definition: CaloSD.h:164
double getEM() const
Definition: CaloG4Hit.h:55
double getTimeSlice() const
Definition: CaloG4Hit.h:66
const SimTrackManager * m_trackManager
Definition: CaloSD.h:143
uint32_t getUnitID() const
Definition: CaloG4Hit.h:65
double getHadr() const
Definition: CaloG4Hit.h:58
uint32_t CaloSD::setDetUnitId ( const G4Step *  step)
overridepure virtual
void CaloSD::setNumberCheckedHits ( int  val)
inlineprotected
void CaloSD::setParameterized ( bool  val)
inlineprotected

Definition at line 100 of file CaloSD.h.

References isParameterized, and heppy_batch::val.

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

100 { isParameterized = val; }
bool isParameterized
Definition: CaloSD.h:151
G4ThreeVector CaloSD::setToGlobal ( const G4ThreeVector &  local,
const G4VTouchable *  touch 
) const
protected

Definition at line 295 of file CaloSD.cc.

295  {
296  return touch->GetHistory()->GetTopTransform().Inverse().TransformPoint(local);
297 }
G4ThreeVector CaloSD::setToLocal ( const G4ThreeVector &  global,
const G4VTouchable *  touch 
) const
protected

Definition at line 291 of file CaloSD.cc.

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

291  {
292  return touch->GetHistory()->GetTopTransform().TransformPoint(global);
293 }
int CaloSD::setTrackID ( const G4Step *  aStep)
protectedvirtual

Definition at line 589 of file CaloSD.cc.

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

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

589  {
590  auto const theTrack = aStep->GetTrack();
591  TrackInformation* trkInfo = cmsTrackInformation(theTrack);
592  int primaryID = trkInfo->getIDonCaloSurface();
593  if (primaryID == 0) {
594  primaryID = theTrack->GetTrackID();
595  }
596 
597  if (primaryID != previousID.trackID()) {
598  resetForNewPrimary(aStep);
599  }
600 #ifdef EDM_ML_DEBUG
601  edm::LogVerbatim("CaloSim") << "CaloSD::setTrackID for " << GetName()
602  << " trackID= " << aStep->GetTrack()->GetTrackID() << " primaryID= " << primaryID;
603 #endif
604  return primaryID;
605 }
int getIDonCaloSurface() const
int trackID() const
Definition: CaloHitID.h:23
void resetForNewPrimary(const G4Step *)
Definition: CaloSD.cc:421
CaloHitID previousID
Definition: CaloSD.h:131
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
void CaloSD::setUseMap ( bool  val)
inlineprotected

Definition at line 101 of file CaloSD.h.

References useMap, and heppy_batch::val.

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

101 { useMap = val; }
bool useMap
Definition: CaloSD.h:152
void CaloSD::storeHit ( CaloG4Hit hit)
private

Definition at line 629 of file CaloSD.cc.

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

Referenced by createNewHit(), and setNumberCheckedHits().

629  {
630  if (hit == nullptr || previousID.trackID() < 0) {
631  edm::LogWarning("CaloSim") << "CaloSD: hit to be stored is nullptr !!"
632  << " previousID.trackID()= " << previousID.trackID();
633  return;
634  }
635 
636  theHC->insert(hit);
637  if (useMap)
638  hitMap.insert(std::pair<CaloHitID, CaloG4Hit*>(previousID, hit));
639 }
bool useMap
Definition: CaloSD.h:152
int trackID() const
Definition: CaloHitID.h:23
CaloHitID previousID
Definition: CaloSD.h:131
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:166
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
void CaloSD::update ( const BeginOfRun )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 456 of file CaloSD.cc.

References initRun().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

456 { initRun(); }
virtual void initRun()
Definition: CaloSD.cc:565
void CaloSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 458 of file CaloSD.cc.

References clearHits(), and initEvent().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

458  {
459 #ifdef EDM_ML_DEBUG
460  edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !";
461 #endif
462  clearHits();
463  initEvent(g4Event);
464 }
virtual void initEvent(const BeginOfEvent *)
Definition: CaloSD.cc:567
void clearHits() override
Definition: CaloSD.cc:548
void CaloSD::update ( const BeginOfTrack )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 673 of file CaloSD.cc.

References cleanHitCollection(), SensitiveDetector::cmsTrackInformation(), TrackInformation::isPrimary(), primAncestor, and theHC.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

673  {
674  int primary = -1;
675  TrackInformation* trkInfo = cmsTrackInformation((*trk)());
676  if (trkInfo->isPrimary())
677  primary = (*trk)()->GetTrackID();
678 
679 #ifdef EDM_ML_DEBUG
680  edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary
681  << " primary ancestor ID " << primAncestor;
682 #endif
683 
684  // update the information if a different primary track ID
685 
686  if (primary > 0 && primary != primAncestor) {
687  primAncestor = primary;
688 
689  // clean the hits information
690 
691  if (theHC->entries() > 0)
693  }
694 }
int primAncestor
Definition: CaloSD.h:156
void cleanHitCollection()
Definition: CaloSD.cc:696
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
bool isPrimary() const
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
void CaloSD::update ( const EndOfTrack )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 466 of file CaloSD.cc.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

466  {
467  int id = (*trk)()->GetTrackID();
468  TrackInformation* trkI = cmsTrackInformation((*trk)());
469  int lastTrackID = -1;
470  if (trkI)
471  lastTrackID = trkI->getIDonCaloSurface();
472  if (id == lastTrackID) {
473  const TrackContainer* trksForThisEvent = m_trackManager->trackContainer();
474  if (trksForThisEvent != nullptr) {
475  int it = (int)(trksForThisEvent->size()) - 1;
476  if (it >= 0) {
477  TrackWithHistory* trkH = (*trksForThisEvent)[it];
478  if (trkH->trackID() == (unsigned int)(id))
479  tkMap[id] = trkH;
480 #ifdef EDM_ML_DEBUG
481  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size "
482  << trksForThisEvent->size() << " with ID " << trkH->trackID();
483  } else {
484  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size "
485  << trksForThisEvent->size() << " with no ID";
486 #endif
487  }
488  }
489  }
490 }
int getIDonCaloSurface() const
const TrackContainer * trackContainer() const
std::vector< TrackWithHistory * > TrackContainer
Definition: TrackContainer.h:8
unsigned int trackID() const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:167
const SimTrackManager * m_trackManager
Definition: CaloSD.h:143
void CaloSD::update ( const ::EndOfEvent )
overrideprotected

Definition at line 492 of file CaloSD.cc.

References funct::abs(), KineDebug3::count(), endEvent(), edm::roottree::getEntry(), hitMap, mps_fire::i, 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__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

492  {
493  endEvent();
494  slave.get()->ReserveMemory(theHC->entries());
495 
496  int count(0);
497  int wrong(0);
498  double eEM(0.0);
499  double eHAD(0.0);
500  double eEM2(0.0);
501  double eHAD2(0.0);
502  double tt(0.0);
503  double zloc(0.0);
504  double zglob(0.0);
505  double ee(0.0);
506 
507  for (int i = 0; i < theHC->entries(); ++i) {
508  if (!saveHit((*theHC)[i])) {
509  ++wrong;
510  }
511  ++count;
512  double x = (*theHC)[i]->getEM();
513  eEM += x;
514  eEM2 += x * x;
515  x = (*theHC)[i]->getHadr();
516  eHAD += x;
517  eHAD2 += x * x;
518  tt += (*theHC)[i]->getTimeSlice();
519  ee += (*theHC)[i]->getIncidentEnergy();
520  zglob += std::abs((*theHC)[i]->getEntry().z());
521  zloc += std::abs((*theHC)[i]->getEntryLocal().z());
522  }
523 
524  double norm = (count > 0) ? 1.0 / count : 0.0;
525  eEM *= norm;
526  eEM2 *= norm;
527  eHAD *= norm;
528  eHAD2 *= norm;
529  eEM2 = std::sqrt(eEM2 - eEM * eEM);
530  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
531  tt *= norm;
532  ee *= norm;
533  zglob *= norm;
534  zloc *= norm;
535 
536  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
537  << " track IDs not given properly and " << totalHits - count
538  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
539  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
540  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
541 
542  tkMap.erase(tkMap.begin(), tkMap.end());
543  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit);
544  if (useMap)
545  hitMap.erase(hitMap.begin(), hitMap.end());
546 }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:496
int totalHits
Definition: CaloSD.h:158
bool useMap
Definition: CaloSD.h:152
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:145
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:166
virtual void endEvent()
Definition: CaloSD.cc:569
CaloG4HitCollection * theHC
Definition: CaloSD.h:148
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:167
std::vector< std::unique_ptr< CaloG4Hit > > reusehit
Definition: CaloSD.h:168
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:641
void CaloSD::updateHit ( CaloG4Hit aHit)
protected

Definition at line 410 of file CaloSD.cc.

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

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

410  {
412 #ifdef EDM_ML_DEBUG
413  edm::LogVerbatim("CaloSim") << "CaloSD:" << GetName() << " Add energy deposit in " << currentID
414  << " Edep_em(MeV)= " << edepositEM << " Edep_had(MeV)= " << edepositHAD;
415 #endif
416 
417  // buffer for next steps:
419 }
float edepositEM
Definition: CaloSD.h:129
void addEnergyDeposit(double em, double hd)
Definition: CaloG4Hit.cc:45
float edepositHAD
Definition: CaloSD.h:129
CaloHitID previousID
Definition: CaloSD.h:131
CaloHitID currentID
Definition: CaloSD.h:131

Member Data Documentation

int CaloSD::cleanIndex
private

Definition at line 157 of file CaloSD.h.

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

double CaloSD::correctT
private

Definition at line 164 of file CaloSD.h.

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

bool CaloSD::corrTOFBeam
private

Definition at line 153 of file CaloSD.h.

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

CaloG4Hit* CaloSD::currentHit
protected

Definition at line 135 of file CaloSD.h.

Referenced by checkHit(), ZdcSD::getFromLibrary(), hitExists(), processHit(), and ProcessHits().

CaloHitID CaloSD::currentID
protected
float CaloSD::edepositEM
protected
float CaloSD::edepositHAD
protected
double CaloSD::eminHit
protected

Definition at line 133 of file CaloSD.h.

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

double CaloSD::eminHitD
private

Definition at line 163 of file CaloSD.h.

Referenced by CaloSD(), and filterHit().

double CaloSD::energyCut
protected

Definition at line 133 of file CaloSD.h.

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

G4ThreeVector CaloSD::entranceLocal
protected
G4ThreeVector CaloSD::entrancePoint
protected
bool CaloSD::forceSave
protected

Definition at line 140 of file CaloSD.h.

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

int CaloSD::hcID
private

Definition at line 155 of file CaloSD.h.

Referenced by Initialize().

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

Definition at line 166 of file CaloSD.h.

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

bool CaloSD::ignoreTrackID
private

Definition at line 150 of file CaloSD.h.

Referenced by CaloSD().

float CaloSD::incidentEnergy
protected
bool CaloSD::isParameterized
private

Definition at line 151 of file CaloSD.h.

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

double CaloSD::kmaxIon
protected
double CaloSD::kmaxNeutron
protected
double CaloSD::kmaxProton
protected
const SimTrackManager* CaloSD::m_trackManager
private

Definition at line 143 of file CaloSD.h.

Referenced by saveHit(), and update().

std::unique_ptr<CaloMeanResponse> CaloSD::meanResponse
private

Definition at line 146 of file CaloSD.h.

Referenced by CaloSD(), and getResponseWt().

int CaloSD::nCheckedHits
private

Definition at line 160 of file CaloSD.h.

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

G4ThreeVector CaloSD::posGlobal
protected

Definition at line 127 of file CaloSD.h.

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

CaloHitID CaloSD::previousID
protected
int CaloSD::primAncestor
private

Definition at line 156 of file CaloSD.h.

Referenced by CaloSD(), and update().

int CaloSD::primIDSaved
private

Definition at line 159 of file CaloSD.h.

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

std::vector<std::unique_ptr<CaloG4Hit> > CaloSD::reusehit
private

Definition at line 168 of file CaloSD.h.

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

std::unique_ptr<CaloSlaveSD> CaloSD::slave
private

Definition at line 145 of file CaloSD.h.

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

bool CaloSD::suppressHeavy
protected
CaloG4HitCollection* CaloSD::theHC
private
float CaloSD::timeSlice
private

Definition at line 162 of file CaloSD.h.

Referenced by CaloSD().

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

Definition at line 167 of file CaloSD.h.

Referenced by createNewHit(), and update().

double CaloSD::tmaxHit
protected
int CaloSD::totalHits
private

Definition at line 158 of file CaloSD.h.

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

bool CaloSD::useMap
private

Definition at line 152 of file CaloSD.h.

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