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 FastTimerSD 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 DDCompactView &, const SensitiveDetectorCatalog &, const edm::ParameterSet &, const SimTrackManager *)
 
 ~TimingSD () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (const std::string &iname, const DDCompactView &cpv, 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
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
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 ( const std::string &  ,
const DDCompactView ,
const SensitiveDetectorCatalog ,
const edm::ParameterSet ,
const SimTrackManager  
)

Definition at line 40 of file TimingSD.cc.

References slave, and theEnumerator.

42  :
43  SensitiveTkDetector(name, cpv, clg, p),
44  theManager(manager), theHC(nullptr), currentHit(nullptr), theTrack(nullptr),
45  preStepPoint(nullptr),postStepPoint(nullptr),
46  unitID(0), previousUnitID(0), primID(-2), hcID(-1), tsID(-2),
47  primaryID(0), tSliceID(-1),
48  timeFactor(1.0), energyCut(1.e+9), energyHistoryCut(1.e+9) {
49 
50  slave = new TrackingSlaveSD(name);
52 }
uint32_t previousUnitID
Definition: TimingSD.h:90
double timeFactor
Definition: TimingSD.h:104
int hcID
Definition: TimingSD.h:93
int primID
Definition: TimingSD.h:92
BscG4Hit * currentHit
Definition: TimingSD.h:85
int tsID
Definition: TimingSD.h:94
TrackingSlaveSD * slave
Definition: TimingSD.h:79
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:80
const G4Track * theTrack
Definition: TimingSD.h:86
double energyHistoryCut
Definition: TimingSD.h:107
const G4StepPoint * preStepPoint
Definition: TimingSD.h:87
int tSliceID
Definition: TimingSD.h:96
double energyCut
Definition: TimingSD.h:106
uint32_t unitID
Definition: TimingSD.h:90
const G4StepPoint * postStepPoint
Definition: TimingSD.h:88
BscG4HitCollection * theHC
Definition: TimingSD.h:83
const SimTrackManager * theManager
Definition: TimingSD.h:82
SensitiveTkDetector(const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
int primaryID
Definition: TimingSD.h:95
TimingSD::~TimingSD ( )
override

Definition at line 54 of file TimingSD.cc.

References slave, and theEnumerator.

54  {
55  delete slave;
56  delete theEnumerator;
57 }
TrackingSlaveSD * slave
Definition: TimingSD.h:79
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:80

Member Function Documentation

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

Reimplemented in Bcm1fSD, and PltSD.

Definition at line 208 of file TimingSD.cc.

References objects.autophobj::float, 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::setTof(), BscG4Hit::setTrackID(), BscG4Hit::setVertexPosition(), theEnumerator, theTrack, and tof.

Referenced by hitExists().

208  {
209 
210  // change hit info to fastest primary particle
211  if(tof < hit->getTof()) {
212  hit->setTrackID(primaryID);
213  hit->setIncidentEnergy((float)incidentEnergy);
214  hit->setPabs(float(preStepPoint->GetMomentum().mag())*invgev);
215  hit->setTof(tof);
216  hit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
217 
218  float ThetaAtEntry = (float)(hitPointLocal.theta()*invdeg);
219  float PhiAtEntry = (float)(hitPointLocal.phi()*invdeg);
220 
221  hit->setThetaAtEntry(ThetaAtEntry);
222  hit->setPhiAtEntry(PhiAtEntry);
223 
224  hit->setEntry(hitPoint);
227 
228  hit->setParentId(theTrack->GetParentID());
229  hit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
230 
231  hit->setVertexPosition(theTrack->GetVertexPosition());
232  }
233  return true;
234 }
void setTof(float e)
Definition: BscG4Hit.h:70
void setEntryLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:36
void setEntry(const G4ThreeVector &xyz)
Definition: BSCG4Hit.cc:97
void setIncidentEnergy(float e)
Definition: BscG4Hit.h:48
G4ThreeVector hitPointLocal
Definition: TimingSD.h:100
void setTrackID(int id)
Definition: BscG4Hit.h:51
void setParentId(int p)
Definition: BscG4Hit.h:96
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:101
void setParticleType(int i)
Definition: BscG4Hit.h:72
void setThetaAtEntry(float t)
Definition: BscG4Hit.h:77
void setPabs(float e)
Definition: BscG4Hit.h:69
unsigned int processId(const G4VProcess *p) const
static const float invgev
Definition: TimingSD.cc:35
float tof
Definition: TimingSD.h:110
void setPhiAtEntry(float f)
Definition: BscG4Hit.h:78
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:80
static const double invdeg
Definition: TimingSD.cc:37
const G4Track * theTrack
Definition: TimingSD.h:86
const G4StepPoint * preStepPoint
Definition: TimingSD.h:87
void setExitLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:39
void setVertexPosition(const G4ThreeVector &)
Definition: BSCG4Hit.cc:122
double incidentEnergy
Definition: TimingSD.h:109
void setProcessId(int p)
Definition: BscG4Hit.h:97
G4ThreeVector hitPoint
Definition: TimingSD.h:98
int primaryID
Definition: TimingSD.h:95
void TimingSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 372 of file TimingSD.cc.

References TrackingSlaveSD::Initialize(), and slave.

Referenced by update().

372  {
373  slave->Initialize();
374 }
virtual void Initialize()
TrackingSlaveSD * slave
Definition: TimingSD.h:79
void TimingSD::createNewHit ( const G4Step *  aStep)
private

Definition at line 247 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 getGlobalEntryPoint(), and ProcessHits().

247  {
248 
249 #ifdef debug
250  const G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
251  edm::LogVerbatim("TimingSim")
252  << "TimingSD CreateNewHit for " << GetName()
253  << " PV " << currentPV->GetName()
254  << " PVid = " << currentPV->GetCopyNo()
255  << " Unit " << unitID
256  << "\n primary " << primaryID
257  << " Tof(ns)= " << tof
258  << " time slice " << tSliceID
259  << " E(GeV)= " << incidentEnergy
260  << " trackID " << theTrack->GetTrackID()
261  << " " << theTrack->GetDefinition()->GetParticleName()
262  << " parentID " << theTrack->GetParentID();
263 
264  if (theTrack->GetCreatorProcess()!=nullptr) {
265  edm::LogVerbatim("TimingSim")
266  << theTrack->GetCreatorProcess()->GetProcessName();
267  } else {
268  edm::LogVerbatim("TimingSim") << " is primary particle";
269  }
270 #endif
271 
272  currentHit = new BscG4Hit;
277 
278  currentHit->setPabs(float(preStepPoint->GetMomentum().mag()*invgev));
280  currentHit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
281 
282  float ThetaAtEntry = hitPointLocal.theta()*invdeg;
283  float PhiAtEntry = hitPointLocal.phi()*invdeg;
284 
285  currentHit->setThetaAtEntry(ThetaAtEntry);
286  currentHit->setPhiAtEntry(PhiAtEntry);
287 
291 
292  currentHit->setParentId(theTrack->GetParentID());
293  currentHit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
294 
295  currentHit->setVertexPosition(theTrack->GetVertexPosition());
296 
297  updateHit();
299 }
void setTof(float e)
Definition: BscG4Hit.h:70
void setEntryLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:36
void setEntry(const G4ThreeVector &xyz)
Definition: BSCG4Hit.cc:97
void setIncidentEnergy(float e)
Definition: BscG4Hit.h:48
G4ThreeVector hitPointLocal
Definition: TimingSD.h:100
void setTrackID(int id)
Definition: BscG4Hit.h:51
void setParentId(int p)
Definition: BscG4Hit.h:96
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:101
BscG4Hit * currentHit
Definition: TimingSD.h:85
void setParticleType(int i)
Definition: BscG4Hit.h:72
void setThetaAtEntry(float t)
Definition: BscG4Hit.h:77
void storeHit(BscG4Hit *)
Definition: TimingSD.cc:236
void setPabs(float e)
Definition: BscG4Hit.h:69
unsigned int processId(const G4VProcess *p) const
static const float invgev
Definition: TimingSD.cc:35
void setUnitID(uint32_t id)
Definition: BscG4Hit.h:54
float tof
Definition: TimingSD.h:110
void setPhiAtEntry(float f)
Definition: BscG4Hit.h:78
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:80
static const double invdeg
Definition: TimingSD.cc:37
const G4Track * theTrack
Definition: TimingSD.h:86
const G4StepPoint * preStepPoint
Definition: TimingSD.h:87
int tSliceID
Definition: TimingSD.h:96
void setTimeSlice(double d)
Definition: BscG4Hit.h:57
uint32_t unitID
Definition: TimingSD.h:90
void setExitLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:39
double tSlice
Definition: TimingSD.h:103
void setVertexPosition(const G4ThreeVector &)
Definition: BSCG4Hit.cc:122
void updateHit()
Definition: TimingSD.cc:301
double incidentEnergy
Definition: TimingSD.h:109
void setProcessId(int p)
Definition: BscG4Hit.h:97
G4ThreeVector hitPoint
Definition: TimingSD.h:98
int primaryID
Definition: TimingSD.h:95
void TimingSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 327 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(), nhits, TrackingSlaveSD::processHits(), slave, and theHC.

327  {
328 
329  int nhits = theHC->entries();
330  if(0 == nhits) { return; }
331  // here we loop over transient hits and make them persistent
332  for (int j=0; j<nhits; ++j) {
333 
334  BscG4Hit* aHit = (*theHC)[j];
335  Local3DPoint locEntryPoint= ConvertToLocal3DPoint(aHit->getEntryLocalP());
336  Local3DPoint locExitPoint = ConvertToLocal3DPoint(aHit->getExitLocalP());
337 
338 #ifdef debug
339  edm::LogInfo("TimingSim") << "TimingSD: Hit for storage \n" << *aHit
340  << "\n Entry point: " << locEntryPoint
341  << "\n Exit point: " << locExitPoint << "\n";
342 #endif
343 
344 
345  slave->processHits(PSimHit(locEntryPoint,locExitPoint,
346  aHit->getPabs(),
347  aHit->getTof(),
348  aHit->getEnergyLoss(),
349  aHit->getParticleType(),
350  aHit->getUnitID(),
351  aHit->getTrackID(),
352  aHit->getThetaAtEntry(),
353  aHit->getPhiAtEntry(),
354  aHit->getProcessId()));
355  }
356 }
float getPhiAtEntry() const
Definition: BscG4Hit.h:75
int getParticleType() const
Definition: BscG4Hit.h:67
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
int getProcessId() const
Definition: BscG4Hit.h:91
float getTof() const
Definition: BscG4Hit.h:65
float getPabs() const
Definition: BscG4Hit.h:64
int getTrackID() const
Definition: BscG4Hit.h:50
TrackingSlaveSD * slave
Definition: TimingSD.h:79
const G4ThreeVector & getExitLocalP() const
Definition: BscG4Hit.h:38
float getThetaAtEntry() const
Definition: BscG4Hit.h:74
const G4ThreeVector & getEntryLocalP() const
Definition: BscG4Hit.h:35
BscG4HitCollection * theHC
Definition: TimingSD.h:83
virtual bool processHits(const PSimHit &)
uint32_t getUnitID() const
Definition: BscG4Hit.h:53
float getEnergyLoss() const
Definition: BscG4Hit.h:66
void TimingSD::fillHits ( edm::PSimHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveTkDetector.

Definition at line 363 of file TimingSD.cc.

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

363  {
364  if (slave->name() == hname) { cc=slave->hits(); }
365 }
std::string name() const
std::vector< PSimHit > & hits()
TrackingSlaveSD * slave
Definition: TimingSD.h:79
const G4ThreeVector& TimingSD::getGlobalEntryPoint ( ) const
inlineprotected

Definition at line 70 of file TimingSD.h.

References createNewHit(), getStepInfo(), hitExists(), hitPoint, storeHit(), and updateHit().

Referenced by FastTimerSD::setDetUnitId().

70 { return hitPoint; };
G4ThreeVector hitPoint
Definition: TimingSD.h:98
const G4ThreeVector& TimingSD::getLocalEntryPoint ( ) const
inlineprotected

Definition at line 69 of file TimingSD.h.

References hitPointLocal.

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

69 { return hitPointLocal; };
G4ThreeVector hitPointLocal
Definition: TimingSD.h:100
void TimingSD::getStepInfo ( const G4Step *  aStep)
private

Definition at line 112 of file TimingSD.cc.

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

Referenced by getGlobalEntryPoint(), and ProcessHits().

112  {
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 debug
133  double distGlobal = std::sqrt(std::pow(hitPoint.x()-hitPointExit.x(),2)+
134  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
141  << "\n Global exit point: " << hitPointExit
142  << "\n Global step length: " << distGlobal
143  << "\n Local entry point: " << hitPointLocal
144  << "\n Local exit point: " << hitPointLocalExit
145  << "\n Local step length: " << distLocal;
146  if ( std::fabs(distGlobal - distLocal) > 1.e-6 ) { LogDebug("TimingSim") << "DIFFERENCE IN DISTANCE \n"; }
147 #endif
148 
149 
150  incidentEnergy = preStepPoint->GetKineticEnergy();
151 
152  // should MC truth be saved
153  if (newTrack != theTrack) {
154  theTrack = newTrack;
155  TrackInformation* info = nullptr;
156  if (incidentEnergy > energyCut) {
158  info->storeTrack(true);
159  }
161  if(!info) { info = cmsTrackInformation(theTrack); }
162  info->putInHistory();
163  }
164  }
165 
166  edeposit *= invgev;
169  } else {
171  }
172  // time slice is defined for the entry point
173  tSlice = timeFactor*preStepPoint->GetGlobalTime()*invns;
174  tSliceID = (int) tSlice;
175 
176  unitID = setDetUnitId(aStep);
177  primaryID = theTrack->GetTrackID();
178 }
#define LogDebug(id)
static const TGPicture * info(bool iBackgroundIsBlack)
bool storeTrack() const
double timeFactor
Definition: TimingSD.h:104
float edepositHAD
Definition: TimingSD.h:112
G4ThreeVector hitPointLocal
Definition: TimingSD.h:100
virtual uint32_t setDetUnitId(const G4Step *step)=0
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:101
float edepositEM
Definition: TimingSD.h:112
void setToLocal(const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
Definition: TimingSD.cc:318
static const float invgev
Definition: TimingSD.cc:35
float tof
Definition: TimingSD.h:110
T sqrt(T t)
Definition: SSEVec.h:18
float edeposit
Definition: TimingSD.h:111
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const G4Track * theTrack
Definition: TimingSD.h:86
double energyHistoryCut
Definition: TimingSD.h:107
const G4StepPoint * preStepPoint
Definition: TimingSD.h:87
int tSliceID
Definition: TimingSD.h:96
double energyCut
Definition: TimingSD.h:106
uint32_t unitID
Definition: TimingSD.h:90
double tSlice
Definition: TimingSD.h:103
static const double invns
Definition: TimingSD.cc:36
const G4StepPoint * postStepPoint
Definition: TimingSD.h:88
static bool isGammaElectronPositron(int pdgCode)
double incidentEnergy
Definition: TimingSD.h:109
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
G4ThreeVector hitPointExit
Definition: TimingSD.h:99
G4ThreeVector hitPoint
Definition: TimingSD.h:98
int primaryID
Definition: TimingSD.h:95
bool TimingSD::hitExists ( const G4Step *  aStep)
private

Definition at line 180 of file TimingSD.cc.

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

Referenced by getGlobalEntryPoint(), and ProcessHits().

180  {
181 
182  if(!currentHit) { return false; }
183 
184  // Update if in the same detector and time-slice
185  if (tSliceID == tsID && unitID == previousUnitID) {
186  updateHit();
187  return true;
188  }
189 
190  //look in the HitContainer whether a hit with the same primID, unitID,
191  //tSliceID already exists:
192 
193  bool found = false;
194  for (int j=0; j<theHC->entries(); ++j) {
195  BscG4Hit* aHit = (*theHC)[j];
196  if (aHit->getTimeSliceID() == tSliceID && aHit->getUnitID() == unitID) {
197  if(checkHit(aStep, aHit)) {
198  currentHit = aHit;
199  found = true;
200  break;
201  }
202  }
203  }
204  if (found) { updateHit(); }
205  return found;
206 }
uint32_t previousUnitID
Definition: TimingSD.h:90
virtual bool checkHit(const G4Step *, BscG4Hit *)
Definition: TimingSD.cc:208
BscG4Hit * currentHit
Definition: TimingSD.h:85
int getTimeSliceID() const
Definition: BscG4Hit.h:58
int tsID
Definition: TimingSD.h:94
int tSliceID
Definition: TimingSD.h:96
uint32_t unitID
Definition: TimingSD.h:90
void updateHit()
Definition: TimingSD.cc:301
BscG4HitCollection * theHC
Definition: TimingSD.h:83
uint32_t getUnitID() const
Definition: BscG4Hit.h:53
void TimingSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 59 of file TimingSD.cc.

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

59  {
60 
61  edm::LogVerbatim("TimingSim")
62  << "TimingSD : Initialize called for " << GetName()
63  << " time slice factor " << timeFactor
64  << "\n MC truth cuts in are " << energyCut/CLHEP::GeV
65  << " GeV and " << energyHistoryCut/CLHEP::GeV << " GeV";
66 
67  theHC = new BscG4HitCollection(GetName(), collectionName[0]);
68  if (hcID<0) {
69  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
70  }
71  HCE->AddHitsCollection(hcID, theHC);
72 
73  tsID = -2;
74  primID = -2;
75 }
const double GeV
Definition: MathUtil.h:16
double timeFactor
Definition: TimingSD.h:104
int hcID
Definition: TimingSD.h:93
int primID
Definition: TimingSD.h:92
std::string const collectionName[nCollections]
Definition: Collections.h:47
int tsID
Definition: TimingSD.h:94
double energyHistoryCut
Definition: TimingSD.h:107
double energyCut
Definition: TimingSD.h:106
BscG4HitCollection * theHC
Definition: TimingSD.h:83
G4THitsCollection< BscG4Hit > BscG4HitCollection
void TimingSD::PrintAll ( )
override

Definition at line 358 of file TimingSD.cc.

References LogDebug, and theHC.

358  {
359  LogDebug("TimingSim") << "TimingSD: Collection " << theHC->GetName() << "\n";
360  theHC->PrintAllHits();
361 }
#define LogDebug(id)
BscG4HitCollection * theHC
Definition: TimingSD.h:83
bool TimingSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Definition at line 100 of file TimingSD.cc.

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

100  {
101 
102  edeposit = aStep->GetTotalEnergyDeposit();
103  if (edeposit>0.f){
104  getStepInfo(aStep);
105  if (!hitExists(aStep)){
106  createNewHit(aStep);
107  }
108  }
109  return true;
110 }
void createNewHit(const G4Step *)
Definition: TimingSD.cc:247
void getStepInfo(const G4Step *)
Definition: TimingSD.cc:112
float edeposit
Definition: TimingSD.h:111
double f[11][100]
bool hitExists(const G4Step *)
Definition: TimingSD.cc:180
void TimingSD::setCuts ( double  eCut,
double  historyCut 
)
protected

Definition at line 88 of file TimingSD.cc.

References energyCut, energyHistoryCut, and GeV.

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

89 {
90  if(eCut > 0.) { energyCut = eCut; }
91  if(historyCut > 0.) { energyHistoryCut = historyCut; }
92 #ifdef debug
93  edm::LogVerbatim("TimingSim")
94  << "TimingSD : for " << GetName()
95  << " MC truth cuts in are " << energyCut/CLHEP::GeV
96  << " GeV and " << energyHistoryCut/CLHEP::GeV << " GeV";
97 #endif
98 }
const double GeV
Definition: MathUtil.h:16
double energyHistoryCut
Definition: TimingSD.h:107
double energyCut
Definition: TimingSD.h:106
void TimingSD::setTimeFactor ( double  val)
protected

Definition at line 77 of file TimingSD.cc.

References timeFactor, and heppy_batch::val.

Referenced by FastTimerSD::FastTimerSD(), and MtdSD::MtdSD().

78 {
79  if(val <= 0.0) { return; }
80  timeFactor = val;
81 #ifdef debug
82  edm::LogVerbatim("TimingSim")
83  << "TimingSD : for " << GetName()
84  << " time slice factor is set to " << timeFactor;
85 #endif
86 }
double timeFactor
Definition: TimingSD.h:104
void TimingSD::setToLocal ( const G4StepPoint *  stepPoint,
const G4ThreeVector &  globalPoint,
G4ThreeVector &  localPoint 
)
protected

Definition at line 318 of file TimingSD.cc.

Referenced by getStepInfo().

320  {
321 
322  const G4VTouchable* touch= stepPoint->GetTouchable();
323  localPoint =
324  touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
325 }
void TimingSD::storeHit ( BscG4Hit hit)
private

Definition at line 236 of file TimingSD.cc.

References primID, and theHC.

Referenced by createNewHit(), and getGlobalEntryPoint().

236  {
237 
238  if (primID<0) return;
239  if (hit == nullptr ) {
240  edm::LogWarning("BscSim") << "BscSD: hit to be stored is NULL !!";
241  return;
242  }
243 
244  theHC->insert( hit );
245 }
int primID
Definition: TimingSD.h:92
BscG4HitCollection * theHC
Definition: TimingSD.h:83
void TimingSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 367 of file TimingSD.cc.

References clearHits(), and LogDebug.

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

367  {
368  LogDebug("TimingSim") << " Dispatched BeginOfEvent for " << GetName();
369  clearHits();
370 }
#define LogDebug(id)
void clearHits() override
Definition: TimingSD.cc:372
void TimingSD::updateHit ( )
private

Definition at line 301 of file TimingSD.cc.

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

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

301  {
302 
304 
305 #ifdef debug
306  edm::LogVerbatim("TimingSim")
307  << "updateHit: " << GetName() << " add eloss(GeV) " << edeposit
308  << "CurrentHit=" << currentHit
309  << ", PostStepPoint= " << postStepPoint->GetPosition();
310 #endif
311 
312  // buffer for next steps:
313  tsID = tSliceID;
314  primID = primaryID;
316 }
uint32_t previousUnitID
Definition: TimingSD.h:90
float edepositHAD
Definition: TimingSD.h:112
int primID
Definition: TimingSD.h:92
BscG4Hit * currentHit
Definition: TimingSD.h:85
float edepositEM
Definition: TimingSD.h:112
int tsID
Definition: TimingSD.h:94
float edeposit
Definition: TimingSD.h:111
int tSliceID
Definition: TimingSD.h:96
void addEnergyDeposit(float em, float hd)
Definition: BSCG4Hit.cc:112
uint32_t unitID
Definition: TimingSD.h:90
const G4StepPoint * postStepPoint
Definition: TimingSD.h:88
int primaryID
Definition: TimingSD.h:95

Member Data Documentation

BscG4Hit* TimingSD::currentHit
private

Definition at line 85 of file TimingSD.h.

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

float TimingSD::edeposit
private

Definition at line 111 of file TimingSD.h.

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

float TimingSD::edepositEM
private

Definition at line 112 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

float TimingSD::edepositHAD
private

Definition at line 112 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

double TimingSD::energyCut
private

Definition at line 106 of file TimingSD.h.

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

double TimingSD::energyHistoryCut
private

Definition at line 107 of file TimingSD.h.

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

int TimingSD::hcID
private

Definition at line 93 of file TimingSD.h.

Referenced by Initialize().

G4ThreeVector TimingSD::hitPoint
private

Definition at line 98 of file TimingSD.h.

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

G4ThreeVector TimingSD::hitPointExit
private

Definition at line 99 of file TimingSD.h.

Referenced by getStepInfo().

G4ThreeVector TimingSD::hitPointLocal
private

Definition at line 100 of file TimingSD.h.

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

G4ThreeVector TimingSD::hitPointLocalExit
private

Definition at line 101 of file TimingSD.h.

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

double TimingSD::incidentEnergy
private

Definition at line 109 of file TimingSD.h.

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

const G4StepPoint* TimingSD::postStepPoint
private

Definition at line 88 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

const G4StepPoint* TimingSD::preStepPoint
private

Definition at line 87 of file TimingSD.h.

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

uint32_t TimingSD::previousUnitID
private

Definition at line 90 of file TimingSD.h.

Referenced by hitExists(), and updateHit().

int TimingSD::primaryID
private

Definition at line 95 of file TimingSD.h.

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

int TimingSD::primID
private

Definition at line 92 of file TimingSD.h.

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

TrackingSlaveSD* TimingSD::slave
private

Definition at line 79 of file TimingSD.h.

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

G4ProcessTypeEnumerator* TimingSD::theEnumerator
private

Definition at line 80 of file TimingSD.h.

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

BscG4HitCollection* TimingSD::theHC
private

Definition at line 83 of file TimingSD.h.

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

const SimTrackManager* TimingSD::theManager
private

Definition at line 82 of file TimingSD.h.

const G4Track* TimingSD::theTrack
private

Definition at line 86 of file TimingSD.h.

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

double TimingSD::timeFactor
private

Definition at line 104 of file TimingSD.h.

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

float TimingSD::tof
private

Definition at line 110 of file TimingSD.h.

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

int TimingSD::tsID
private

Definition at line 94 of file TimingSD.h.

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

double TimingSD::tSlice
private

Definition at line 103 of file TimingSD.h.

Referenced by createNewHit(), and getStepInfo().

int TimingSD::tSliceID
private

Definition at line 96 of file TimingSD.h.

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

uint32_t TimingSD::unitID
private

Definition at line 90 of file TimingSD.h.

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