CMS 3D CMS Logo

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

#include <TimingSD.h>

Inheritance diagram for TimingSD:
SensitiveTkDetector Observer< const BeginOfEvent *> SensitiveDetector Bcm1fSD BHMSD BscSD MtdSD PltSD

Public Member Functions

void clearHits () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PSimHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
 TimingSD (const std::string &, const SensitiveDetectorCatalog &, const SimTrackManager *)
 
 ~TimingSD () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (const std::string &iname, const SensitiveDetectorCatalog &clg)
 
- 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)
 
virtual uint32_t setDetUnitId (const G4Step *step)=0
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

virtual bool checkHit (const G4Step *, BscG4Hit *)
 
const G4ThreeVector & getGlobalEntryPoint () const
 
const G4ThreeVector & getLocalEntryPoint () const
 
void setCuts (double eCut, double historyCut)
 
void setTimeFactor (double)
 
void setToLocal (const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
- 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 > &)
 

Private Member Functions

void createNewHit (const G4Step *)
 
void getStepInfo (const G4Step *)
 
bool hitExists (const G4Step *)
 
void storeHit (BscG4Hit *)
 
void updateHit ()
 

Private Attributes

BscG4HitcurrentHit
 
float edeposit
 
float edepositEM
 
float edepositHAD
 
double energyCut
 
double energyHistoryCut
 
int hcID
 
G4ThreeVector hitPoint
 
G4ThreeVector hitPointExit
 
G4ThreeVector hitPointLocal
 
G4ThreeVector hitPointLocalExit
 
double incidentEnergy
 
const G4StepPoint * postStepPoint
 
const G4StepPoint * preStepPoint
 
uint32_t previousUnitID
 
int primaryID
 
int primID
 
TrackingSlaveSDslave
 
G4ProcessTypeEnumeratortheEnumerator
 
BscG4HitCollectiontheHC
 
const SimTrackManagertheManager
 
const G4Track * theTrack
 
double timeFactor
 
float tof
 
int tsID
 
double tSlice
 
int tSliceID
 
uint32_t unitID
 

Additional Inherited Members

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

Detailed Description

Definition at line 29 of file TimingSD.h.

Constructor & Destructor Documentation

◆ TimingSD()

TimingSD::TimingSD ( const std::string &  name,
const SensitiveDetectorCatalog clg,
const SimTrackManager manager 
)

Definition at line 37 of file TimingSD.cc.

References Skims_PA_cff::name, slave, and theEnumerator.

38  : SensitiveTkDetector(name, clg),
39  theManager(manager),
40  theHC(nullptr),
41  currentHit(nullptr),
42  theTrack(nullptr),
43  preStepPoint(nullptr),
44  postStepPoint(nullptr),
45  unitID(0),
46  previousUnitID(0),
47  primID(-2),
48  hcID(-1),
49  tsID(-2),
50  primaryID(0),
51  tSliceID(-1),
52  timeFactor(1.0),
53  energyCut(1.e+9),
54  energyHistoryCut(1.e+9) {
55  slave = new TrackingSlaveSD(name);
57 }
uint32_t previousUnitID
Definition: TimingSD.h:83
double timeFactor
Definition: TimingSD.h:97
int hcID
Definition: TimingSD.h:86
int primID
Definition: TimingSD.h:85
BscG4Hit * currentHit
Definition: TimingSD.h:78
int tsID
Definition: TimingSD.h:87
TrackingSlaveSD * slave
Definition: TimingSD.h:72
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:73
const G4Track * theTrack
Definition: TimingSD.h:79
double energyHistoryCut
Definition: TimingSD.h:100
const G4StepPoint * preStepPoint
Definition: TimingSD.h:80
int tSliceID
Definition: TimingSD.h:89
double energyCut
Definition: TimingSD.h:99
uint32_t unitID
Definition: TimingSD.h:83
const G4StepPoint * postStepPoint
Definition: TimingSD.h:81
BscG4HitCollection * theHC
Definition: TimingSD.h:76
const SimTrackManager * theManager
Definition: TimingSD.h:75
SensitiveTkDetector(const std::string &iname, const SensitiveDetectorCatalog &clg)
int primaryID
Definition: TimingSD.h:88

◆ ~TimingSD()

TimingSD::~TimingSD ( )
override

Definition at line 59 of file TimingSD.cc.

References slave, and theEnumerator.

59  {
60  delete slave;
61  delete theEnumerator;
62 }
TrackingSlaveSD * slave
Definition: TimingSD.h:72
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:73

Member Function Documentation

◆ checkHit()

bool TimingSD::checkHit ( const G4Step *  ,
BscG4Hit hit 
)
protectedvirtual

Reimplemented in Bcm1fSD, and PltSD.

Definition at line 214 of file TimingSD.cc.

References dqmMemoryStats::float, hitPoint, hitPointLocal, hitPointLocalExit, incidentEnergy, invdeg, invgev, preStepPoint, primaryID, G4ProcessTypeEnumerator::processId(), theEnumerator, theTrack, and tof.

Referenced by hitExists().

214  {
215  // change hit info to fastest primary particle
216  if (tof < hit->getTof()) {
217  hit->setTrackID(primaryID);
218  hit->setIncidentEnergy((float)incidentEnergy);
219  hit->setPabs(float(preStepPoint->GetMomentum().mag()) * invgev);
220  hit->setTof(tof);
221  hit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
222 
223  float ThetaAtEntry = (float)(hitPointLocal.theta() * invdeg);
224  float PhiAtEntry = (float)(hitPointLocal.phi() * invdeg);
225 
226  hit->setThetaAtEntry(ThetaAtEntry);
227  hit->setPhiAtEntry(PhiAtEntry);
228 
229  hit->setEntry(hitPoint);
230  hit->setEntryLocalP(hitPointLocal);
231  hit->setExitLocalP(hitPointLocalExit);
232 
233  hit->setParentId(theTrack->GetParentID());
234  hit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
235 
236  hit->setVertexPosition(theTrack->GetVertexPosition());
237  }
238  return true;
239 }
G4ThreeVector hitPointLocal
Definition: TimingSD.h:93
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:94
static const float invgev
Definition: TimingSD.cc:32
float tof
Definition: TimingSD.h:103
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:73
static const double invdeg
Definition: TimingSD.cc:34
const G4Track * theTrack
Definition: TimingSD.h:79
const G4StepPoint * preStepPoint
Definition: TimingSD.h:80
double incidentEnergy
Definition: TimingSD.h:102
unsigned int processId(const G4VProcess *p) const
G4ThreeVector hitPoint
Definition: TimingSD.h:91
int primaryID
Definition: TimingSD.h:88

◆ clearHits()

void TimingSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 367 of file TimingSD.cc.

References TrackingSlaveSD::Initialize(), and slave.

Referenced by update().

367 { slave->Initialize(); }
virtual void Initialize()
TrackingSlaveSD * slave
Definition: TimingSD.h:72

◆ createNewHit()

void TimingSD::createNewHit ( const G4Step *  aStep)
private

Definition at line 252 of file TimingSD.cc.

References currentHit, hitPoint, hitPointLocal, hitPointLocalExit, incidentEnergy, invdeg, invgev, preStepPoint, primaryID, G4ProcessTypeEnumerator::processId(), BscG4Hit::setEntry(), BscG4Hit::setEntryLocalP(), BscG4Hit::setExitLocalP(), BscG4Hit::setIncidentEnergy(), BscG4Hit::setPabs(), BscG4Hit::setParentId(), BscG4Hit::setParticleType(), BscG4Hit::setPhiAtEntry(), BscG4Hit::setProcessId(), BscG4Hit::setThetaAtEntry(), BscG4Hit::setTimeSlice(), BscG4Hit::setTof(), BscG4Hit::setTrackID(), BscG4Hit::setUnitID(), BscG4Hit::setVertexPosition(), storeHit(), theEnumerator, theTrack, tof, tSlice, tSliceID, unitID, and updateHit().

Referenced by ProcessHits().

252  {
253 #ifdef EDM_ML_DEBUG
254  const G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
255  edm::LogVerbatim("TimingSim") << "TimingSD CreateNewHit for " << GetName() << " PV " << currentPV->GetName()
256  << " PVid = " << currentPV->GetCopyNo() << " Unit " << unitID << "\n primary "
257  << primaryID << " Tof(ns)= " << tof << " time slice " << tSliceID
258  << " E(GeV)= " << incidentEnergy << " trackID " << theTrack->GetTrackID() << " "
259  << theTrack->GetDefinition()->GetParticleName() << " parentID "
260  << theTrack->GetParentID();
261 
262  if (theTrack->GetCreatorProcess() != nullptr) {
263  edm::LogVerbatim("TimingSim") << theTrack->GetCreatorProcess()->GetProcessName();
264  } else {
265  edm::LogVerbatim("TimingSim") << " is primary particle";
266  }
267 #endif
268 
269  currentHit = new BscG4Hit;
274 
275  currentHit->setPabs(float(preStepPoint->GetMomentum().mag() * invgev));
277  currentHit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
278 
279  float ThetaAtEntry = hitPointLocal.theta() * invdeg;
280  float PhiAtEntry = hitPointLocal.phi() * invdeg;
281 
282  currentHit->setThetaAtEntry(ThetaAtEntry);
283  currentHit->setPhiAtEntry(PhiAtEntry);
284 
288 
289  currentHit->setParentId(theTrack->GetParentID());
290  currentHit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
291 
292  currentHit->setVertexPosition(theTrack->GetVertexPosition());
293 
294  updateHit();
296 }
Log< level::Info, true > LogVerbatim
void setTof(float e)
Definition: BscG4Hit.h:73
void setEntryLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:33
void setEntry(const G4ThreeVector &xyz)
Definition: BSCG4Hit.cc:98
void setIncidentEnergy(float e)
Definition: BscG4Hit.h:51
G4ThreeVector hitPointLocal
Definition: TimingSD.h:93
void setTrackID(int id)
Definition: BscG4Hit.h:54
void setParentId(int p)
Definition: BscG4Hit.h:99
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:94
BscG4Hit * currentHit
Definition: TimingSD.h:78
void setParticleType(int i)
Definition: BscG4Hit.h:75
void setThetaAtEntry(float t)
Definition: BscG4Hit.h:80
void storeHit(BscG4Hit *)
Definition: TimingSD.cc:241
void setPabs(float e)
Definition: BscG4Hit.h:72
static const float invgev
Definition: TimingSD.cc:32
void setUnitID(uint32_t id)
Definition: BscG4Hit.h:57
float tof
Definition: TimingSD.h:103
void setPhiAtEntry(float f)
Definition: BscG4Hit.h:81
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:73
static const double invdeg
Definition: TimingSD.cc:34
const G4Track * theTrack
Definition: TimingSD.h:79
const G4StepPoint * preStepPoint
Definition: TimingSD.h:80
int tSliceID
Definition: TimingSD.h:89
void setTimeSlice(double d)
Definition: BscG4Hit.h:60
uint32_t unitID
Definition: TimingSD.h:83
void setExitLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:36
double tSlice
Definition: TimingSD.h:96
void setVertexPosition(const G4ThreeVector &)
Definition: BSCG4Hit.cc:125
void updateHit()
Definition: TimingSD.cc:298
double incidentEnergy
Definition: TimingSD.h:102
unsigned int processId(const G4VProcess *p) const
void setProcessId(int p)
Definition: BscG4Hit.h:100
G4ThreeVector hitPoint
Definition: TimingSD.h:91
int primaryID
Definition: TimingSD.h:88

◆ EndOfEvent()

void TimingSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 317 of file TimingSD.cc.

References SensitiveDetector::ConvertToLocal3DPoint(), BscG4Hit::getEnergyLoss(), BscG4Hit::getEntryLocalP(), BscG4Hit::getExitLocalP(), BscG4Hit::getPabs(), BscG4Hit::getParticleType(), BscG4Hit::getPhiAtEntry(), BscG4Hit::getProcessId(), BscG4Hit::getThetaAtEntry(), BscG4Hit::getTof(), BscG4Hit::getTrackID(), BscG4Hit::getUnitID(), dqmiolumiharvest::j, nhits, TrackingSlaveSD::processHits(), slave, and theHC.

317  {
318  int nhits = theHC->entries();
319  if (0 == nhits) {
320  return;
321  }
322  // here we loop over transient hits and make them persistent
323  for (int j = 0; j < nhits; ++j) {
324  BscG4Hit* aHit = (*theHC)[j];
325  Local3DPoint locEntryPoint = ConvertToLocal3DPoint(aHit->getEntryLocalP());
326  Local3DPoint locExitPoint = ConvertToLocal3DPoint(aHit->getExitLocalP());
327 
328 #ifdef EDM_ML_DEBUG
329  edm::LogVerbatim("TimingSim") << "TimingSD: Hit for storage \n"
330  << *aHit << "\n Entry point: " << locEntryPoint << "\n Exit point: " << locExitPoint;
331 #endif
332 
333  slave->processHits(PSimHit(locEntryPoint,
334  locExitPoint,
335  aHit->getPabs(),
336  aHit->getTof(),
337  aHit->getEnergyLoss(),
338  aHit->getParticleType(),
339  aHit->getUnitID(),
340  aHit->getTrackID(),
341  aHit->getThetaAtEntry(),
342  aHit->getPhiAtEntry(),
343  aHit->getProcessId()));
344  }
345 }
Log< level::Info, true > LogVerbatim
uint32_t getUnitID() const
Definition: BscG4Hit.h:56
int getParticleType() const
Definition: BscG4Hit.h:70
int getProcessId() const
Definition: BscG4Hit.h:94
float getPhiAtEntry() const
Definition: BscG4Hit.h:78
float getTof() const
Definition: BscG4Hit.h:68
float getPabs() const
Definition: BscG4Hit.h:67
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
int getTrackID() const
Definition: BscG4Hit.h:53
TrackingSlaveSD * slave
Definition: TimingSD.h:72
float getThetaAtEntry() const
Definition: BscG4Hit.h:77
float getEnergyLoss() const
Definition: BscG4Hit.h:69
BscG4HitCollection * theHC
Definition: TimingSD.h:76
const G4ThreeVector & getExitLocalP() const
Definition: BscG4Hit.h:35
virtual bool processHits(const PSimHit &)
const G4ThreeVector & getEntryLocalP() const
Definition: BscG4Hit.h:32

◆ fillHits()

void TimingSD::fillHits ( edm::PSimHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveTkDetector.

Definition at line 354 of file TimingSD.cc.

References gpuPixelDoublets::cc, TrackingSlaveSD::hits(), TrackingSlaveSD::name(), and slave.

354  {
355  if (slave->name() == hname) {
356  cc = slave->hits();
357  }
358 }
std::string name() const
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::vector< PSimHit > & hits()
TrackingSlaveSD * slave
Definition: TimingSD.h:72

◆ getGlobalEntryPoint()

const G4ThreeVector& TimingSD::getGlobalEntryPoint ( ) const
inlineprotected

Definition at line 63 of file TimingSD.h.

References hitPoint.

63 { return hitPoint; };
G4ThreeVector hitPoint
Definition: TimingSD.h:91

◆ getLocalEntryPoint()

const G4ThreeVector& TimingSD::getLocalEntryPoint ( ) const
inlineprotected

Definition at line 62 of file TimingSD.h.

References hitPointLocal.

Referenced by Bcm1fSD::checkHit(), and PltSD::checkHit().

62 { return hitPointLocal; };
G4ThreeVector hitPointLocal
Definition: TimingSD.h:93

◆ getStepInfo()

void TimingSD::getStepInfo ( const G4Step *  aStep)
private

Definition at line 113 of file TimingSD.cc.

References SensitiveDetector::cmsTrackInformation(), MillePedeFileConverter_cfg::e, edeposit, edepositEM, edepositHAD, energyCut, energyHistoryCut, dqmMemoryStats::float, hitPoint, hitPointExit, hitPointLocal, hitPointLocalExit, incidentEnergy, info(), createfilelist::int, invgev, invns, G4TrackToParticleID::isGammaElectronPositron(), LogDebug, postStepPoint, funct::pow(), preStepPoint, primaryID, SensitiveDetector::setDetUnitId(), setToLocal(), mathSSE::sqrt(), theTrack, timeFactor, tof, tSlice, tSliceID, and unitID.

Referenced by ProcessHits().

113  {
114  preStepPoint = aStep->GetPreStepPoint();
115  postStepPoint = aStep->GetPostStepPoint();
116  hitPointExit = postStepPoint->GetPosition();
118  const G4Track* newTrack = aStep->GetTrack();
119 
120  // neutral particles deliver energy post step
121  // charged particle start deliver energy pre step
122  if (newTrack->GetDefinition()->GetPDGCharge() == 0.0) {
125  tof = (float)(postStepPoint->GetGlobalTime() * invns);
126  } else {
127  hitPoint = preStepPoint->GetPosition();
129  tof = (float)(preStepPoint->GetGlobalTime() * invns);
130  }
131 
132 #ifdef EDM_ML_DEBUG
133  double distGlobal =
134  std::sqrt(std::pow(hitPoint.x() - hitPointExit.x(), 2) + std::pow(hitPoint.y() - hitPointExit.y(), 2) +
135  std::pow(hitPoint.z() - hitPointExit.z(), 2));
136  double distLocal = std::sqrt(std::pow(hitPointLocal.x() - hitPointLocalExit.x(), 2) +
139  LogDebug("TimingSim") << "TimingSD:"
140  << "\n Global entry point: " << hitPoint << "\n Global exit point: " << hitPointExit
141  << "\n Global step length: " << distGlobal << "\n Local entry point: " << hitPointLocal
142  << "\n Local exit point: " << hitPointLocalExit << "\n Local step length: " << distLocal;
143  if (std::fabs(distGlobal - distLocal) > 1.e-6) {
144  LogDebug("TimingSim") << "DIFFERENCE IN DISTANCE \n";
145  }
146 #endif
147 
148  incidentEnergy = preStepPoint->GetKineticEnergy();
149 
150  // should MC truth be saved
151  if (newTrack != theTrack) {
152  theTrack = newTrack;
153  TrackInformation* info = nullptr;
154  if (incidentEnergy > energyCut) {
156  info->storeTrack(true);
157  }
159  if (!info) {
161  }
162  info->putInHistory();
163  }
164  }
165 
166  edeposit *= invgev;
169  edepositHAD = 0.f;
170  } else {
171  edepositEM = 0.f;
173  }
174  // time slice is defined for the entry point
175  tSlice = timeFactor * preStepPoint->GetGlobalTime() * invns;
176  tSliceID = (int)tSlice;
177 
178  unitID = setDetUnitId(aStep);
179  primaryID = theTrack->GetTrackID();
180 }
static const TGPicture * info(bool iBackgroundIsBlack)
double timeFactor
Definition: TimingSD.h:97
float edepositHAD
Definition: TimingSD.h:105
G4ThreeVector hitPointLocal
Definition: TimingSD.h:93
virtual uint32_t setDetUnitId(const G4Step *step)=0
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:94
float edepositEM
Definition: TimingSD.h:105
void setToLocal(const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
Definition: TimingSD.cc:312
static const float invgev
Definition: TimingSD.cc:32
float tof
Definition: TimingSD.h:103
T sqrt(T t)
Definition: SSEVec.h:19
float edeposit
Definition: TimingSD.h:104
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const G4Track * theTrack
Definition: TimingSD.h:79
double energyHistoryCut
Definition: TimingSD.h:100
const G4StepPoint * preStepPoint
Definition: TimingSD.h:80
int tSliceID
Definition: TimingSD.h:89
double energyCut
Definition: TimingSD.h:99
uint32_t unitID
Definition: TimingSD.h:83
double tSlice
Definition: TimingSD.h:96
static const double invns
Definition: TimingSD.cc:33
const G4StepPoint * postStepPoint
Definition: TimingSD.h:81
static bool isGammaElectronPositron(int pdgCode)
double incidentEnergy
Definition: TimingSD.h:102
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
G4ThreeVector hitPointExit
Definition: TimingSD.h:92
G4ThreeVector hitPoint
Definition: TimingSD.h:91
int primaryID
Definition: TimingSD.h:88
#define LogDebug(id)

◆ hitExists()

bool TimingSD::hitExists ( const G4Step *  aStep)
private

Definition at line 182 of file TimingSD.cc.

References checkHit(), currentHit, newFWLiteAna::found, BscG4Hit::getTimeSliceID(), BscG4Hit::getUnitID(), dqmiolumiharvest::j, previousUnitID, theHC, tsID, tSliceID, unitID, and updateHit().

Referenced by ProcessHits().

182  {
183  if (!currentHit) {
184  return false;
185  }
186 
187  // Update if in the same detector and time-slice
188  if (tSliceID == tsID && unitID == previousUnitID) {
189  updateHit();
190  return true;
191  }
192 
193  //look in the HitContainer whether a hit with the same primID, unitID,
194  //tSliceID already exists:
195 
196  bool found = false;
197  int thehc_entries = theHC->entries();
198  for (int j = 0; j < thehc_entries; ++j) {
199  BscG4Hit* aHit = (*theHC)[j];
200  if (aHit->getTimeSliceID() == tSliceID && aHit->getUnitID() == unitID) {
201  if (checkHit(aStep, aHit)) {
202  currentHit = aHit;
203  found = true;
204  break;
205  }
206  }
207  }
208  if (found) {
209  updateHit();
210  }
211  return found;
212 }
uint32_t previousUnitID
Definition: TimingSD.h:83
uint32_t getUnitID() const
Definition: BscG4Hit.h:56
virtual bool checkHit(const G4Step *, BscG4Hit *)
Definition: TimingSD.cc:214
BscG4Hit * currentHit
Definition: TimingSD.h:78
int tsID
Definition: TimingSD.h:87
int tSliceID
Definition: TimingSD.h:89
uint32_t unitID
Definition: TimingSD.h:83
void updateHit()
Definition: TimingSD.cc:298
int getTimeSliceID() const
Definition: BscG4Hit.h:61
BscG4HitCollection * theHC
Definition: TimingSD.h:76

◆ Initialize()

void TimingSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 64 of file TimingSD.cc.

References bysipixelclustmulteventfilter_cfi::collectionName, energyCut, energyHistoryCut, hcID, primID, theHC, timeFactor, and tsID.

64  {
65  edm::LogVerbatim("TimingSim") << "TimingSD : Initialize called for " << GetName() << " time slice factor "
66  << timeFactor << "\n MC truth cuts in are " << energyCut / CLHEP::GeV << " GeV and "
67  << energyHistoryCut / CLHEP::GeV << " GeV";
68 
69  theHC = new BscG4HitCollection(GetName(), collectionName[0]);
70  if (hcID < 0) {
71  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
72  }
73  HCE->AddHitsCollection(hcID, theHC);
74 
75  tsID = -2;
76  primID = -2;
77 }
Log< level::Info, true > LogVerbatim
double timeFactor
Definition: TimingSD.h:97
int hcID
Definition: TimingSD.h:86
int primID
Definition: TimingSD.h:85
int tsID
Definition: TimingSD.h:87
double energyHistoryCut
Definition: TimingSD.h:100
double energyCut
Definition: TimingSD.h:99
BscG4HitCollection * theHC
Definition: TimingSD.h:76
G4THitsCollection< BscG4Hit > BscG4HitCollection

◆ PrintAll()

void TimingSD::PrintAll ( )
override

Definition at line 347 of file TimingSD.cc.

References theHC.

347  {
348 #ifdef EDM_ML_DEBUG
349  edm::LogVerbatim("TimingSim") << "TimingSD: Collection " << theHC->GetName();
350 #endif
351  theHC->PrintAllHits();
352 }
Log< level::Info, true > LogVerbatim
BscG4HitCollection * theHC
Definition: TimingSD.h:76

◆ ProcessHits()

bool TimingSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Definition at line 102 of file TimingSD.cc.

References createNewHit(), edeposit, f, getStepInfo(), and hitExists().

102  {
103  edeposit = aStep->GetTotalEnergyDeposit();
104  if (edeposit > 0.f) {
105  getStepInfo(aStep);
106  if (!hitExists(aStep)) {
107  createNewHit(aStep);
108  }
109  }
110  return true;
111 }
void createNewHit(const G4Step *)
Definition: TimingSD.cc:252
void getStepInfo(const G4Step *)
Definition: TimingSD.cc:113
float edeposit
Definition: TimingSD.h:104
double f[11][100]
bool hitExists(const G4Step *)
Definition: TimingSD.cc:182

◆ setCuts()

void TimingSD::setCuts ( double  eCut,
double  historyCut 
)
protected

Definition at line 89 of file TimingSD.cc.

References energyCut, and energyHistoryCut.

Referenced by Bcm1fSD::Bcm1fSD(), and PltSD::PltSD().

89  {
90  if (eCut > 0.) {
91  energyCut = eCut;
92  }
93  if (historyCut > 0.) {
94  energyHistoryCut = historyCut;
95  }
96 #ifdef EDM_ML_DEBUG
97  edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " MC truth cuts in are " << energyCut / CLHEP::GeV
98  << " GeV and " << energyHistoryCut / CLHEP::GeV << " GeV";
99 #endif
100 }
Log< level::Info, true > LogVerbatim
double energyHistoryCut
Definition: TimingSD.h:100
double energyCut
Definition: TimingSD.h:99

◆ setTimeFactor()

void TimingSD::setTimeFactor ( double  val)
protected

Definition at line 79 of file TimingSD.cc.

References timeFactor, and heppy_batch::val.

Referenced by MtdSD::MtdSD().

79  {
80  if (val <= 0.0) {
81  return;
82  }
83  timeFactor = val;
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " time slice factor is set to " << timeFactor;
86 #endif
87 }
Log< level::Info, true > LogVerbatim
double timeFactor
Definition: TimingSD.h:97

◆ setToLocal()

void TimingSD::setToLocal ( const G4StepPoint *  stepPoint,
const G4ThreeVector &  globalPoint,
G4ThreeVector &  localPoint 
)
protected

Definition at line 312 of file TimingSD.cc.

Referenced by getStepInfo().

312  {
313  const G4VTouchable* touch = stepPoint->GetTouchable();
314  localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
315 }

◆ storeHit()

void TimingSD::storeHit ( BscG4Hit hit)
private

Definition at line 241 of file TimingSD.cc.

References primID, and theHC.

Referenced by createNewHit().

241  {
242  if (primID < 0)
243  return;
244  if (hit == nullptr) {
245  edm::LogWarning("BscSim") << "BscSD: hit to be stored is NULL !!";
246  return;
247  }
248 
249  theHC->insert(hit);
250 }
int primID
Definition: TimingSD.h:85
BscG4HitCollection * theHC
Definition: TimingSD.h:76
Log< level::Warning, false > LogWarning

◆ update()

void TimingSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 360 of file TimingSD.cc.

References clearHits().

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

360  {
361 #ifdef EDM_ML_DEBUG
362  edm::LogVerbatim("TimingSim") << " Dispatched BeginOfEvent for " << GetName();
363 #endif
364  clearHits();
365 }
Log< level::Info, true > LogVerbatim
void clearHits() override
Definition: TimingSD.cc:367

◆ updateHit()

void TimingSD::updateHit ( )
private

Definition at line 298 of file TimingSD.cc.

References BscG4Hit::addEnergyDeposit(), currentHit, edeposit, edepositEM, edepositHAD, postStepPoint, previousUnitID, primaryID, primID, tsID, tSliceID, and unitID.

Referenced by createNewHit(), and hitExists().

298  {
300 
301 #ifdef EDM_ML_DEBUG
302  edm::LogVerbatim("TimingSim") << "updateHit: " << GetName() << " add eloss(GeV) " << edeposit
303  << "CurrentHit=" << currentHit << ", PostStepPoint= " << postStepPoint->GetPosition();
304 #endif
305 
306  // buffer for next steps:
307  tsID = tSliceID;
308  primID = primaryID;
310 }
uint32_t previousUnitID
Definition: TimingSD.h:83
Log< level::Info, true > LogVerbatim
float edepositHAD
Definition: TimingSD.h:105
int primID
Definition: TimingSD.h:85
BscG4Hit * currentHit
Definition: TimingSD.h:78
float edepositEM
Definition: TimingSD.h:105
int tsID
Definition: TimingSD.h:87
float edeposit
Definition: TimingSD.h:104
int tSliceID
Definition: TimingSD.h:89
void addEnergyDeposit(float em, float hd)
Definition: BSCG4Hit.cc:113
uint32_t unitID
Definition: TimingSD.h:83
const G4StepPoint * postStepPoint
Definition: TimingSD.h:81
int primaryID
Definition: TimingSD.h:88

Member Data Documentation

◆ currentHit

BscG4Hit* TimingSD::currentHit
private

Definition at line 78 of file TimingSD.h.

Referenced by createNewHit(), hitExists(), and updateHit().

◆ edeposit

float TimingSD::edeposit
private

Definition at line 104 of file TimingSD.h.

Referenced by getStepInfo(), ProcessHits(), and updateHit().

◆ edepositEM

float TimingSD::edepositEM
private

Definition at line 105 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

◆ edepositHAD

float TimingSD::edepositHAD
private

Definition at line 105 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

◆ energyCut

double TimingSD::energyCut
private

Definition at line 99 of file TimingSD.h.

Referenced by getStepInfo(), Initialize(), and setCuts().

◆ energyHistoryCut

double TimingSD::energyHistoryCut
private

Definition at line 100 of file TimingSD.h.

Referenced by getStepInfo(), Initialize(), and setCuts().

◆ hcID

int TimingSD::hcID
private

Definition at line 86 of file TimingSD.h.

Referenced by Initialize().

◆ hitPoint

G4ThreeVector TimingSD::hitPoint
private

Definition at line 91 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), getGlobalEntryPoint(), and getStepInfo().

◆ hitPointExit

G4ThreeVector TimingSD::hitPointExit
private

Definition at line 92 of file TimingSD.h.

Referenced by getStepInfo().

◆ hitPointLocal

G4ThreeVector TimingSD::hitPointLocal
private

Definition at line 93 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), getLocalEntryPoint(), and getStepInfo().

◆ hitPointLocalExit

G4ThreeVector TimingSD::hitPointLocalExit
private

Definition at line 94 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), and getStepInfo().

◆ incidentEnergy

double TimingSD::incidentEnergy
private

Definition at line 102 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), and getStepInfo().

◆ postStepPoint

const G4StepPoint* TimingSD::postStepPoint
private

Definition at line 81 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

◆ preStepPoint

const G4StepPoint* TimingSD::preStepPoint
private

Definition at line 80 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), and getStepInfo().

◆ previousUnitID

uint32_t TimingSD::previousUnitID
private

Definition at line 83 of file TimingSD.h.

Referenced by hitExists(), and updateHit().

◆ primaryID

int TimingSD::primaryID
private

Definition at line 88 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), getStepInfo(), and updateHit().

◆ primID

int TimingSD::primID
private

Definition at line 85 of file TimingSD.h.

Referenced by Initialize(), storeHit(), and updateHit().

◆ slave

TrackingSlaveSD* TimingSD::slave
private

Definition at line 72 of file TimingSD.h.

Referenced by clearHits(), EndOfEvent(), fillHits(), TimingSD(), and ~TimingSD().

◆ theEnumerator

G4ProcessTypeEnumerator* TimingSD::theEnumerator
private

Definition at line 73 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), TimingSD(), and ~TimingSD().

◆ theHC

BscG4HitCollection* TimingSD::theHC
private

Definition at line 76 of file TimingSD.h.

Referenced by EndOfEvent(), hitExists(), Initialize(), PrintAll(), and storeHit().

◆ theManager

const SimTrackManager* TimingSD::theManager
private

Definition at line 75 of file TimingSD.h.

◆ theTrack

const G4Track* TimingSD::theTrack
private

Definition at line 79 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), and getStepInfo().

◆ timeFactor

double TimingSD::timeFactor
private

Definition at line 97 of file TimingSD.h.

Referenced by getStepInfo(), Initialize(), and setTimeFactor().

◆ tof

float TimingSD::tof
private

Definition at line 103 of file TimingSD.h.

Referenced by checkHit(), createNewHit(), and getStepInfo().

◆ tsID

int TimingSD::tsID
private

Definition at line 87 of file TimingSD.h.

Referenced by hitExists(), Initialize(), and updateHit().

◆ tSlice

double TimingSD::tSlice
private

Definition at line 96 of file TimingSD.h.

Referenced by createNewHit(), and getStepInfo().

◆ tSliceID

int TimingSD::tSliceID
private

Definition at line 89 of file TimingSD.h.

Referenced by createNewHit(), getStepInfo(), hitExists(), and updateHit().

◆ unitID

uint32_t TimingSD::unitID
private

Definition at line 83 of file TimingSD.h.

Referenced by createNewHit(), getStepInfo(), hitExists(), and updateHit().