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 edm::EventSetup &, const SensitiveDetectorCatalog &, const edm::ParameterSet &, const SimTrackManager *)
 
 ~TimingSD () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (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)
 
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 edm::EventSetup ,
const SensitiveDetectorCatalog ,
const edm::ParameterSet ,
const SimTrackManager  
)

Definition at line 40 of file TimingSD.cc.

References slave, and theEnumerator.

45  : SensitiveTkDetector(name, es, clg, p),
46  theManager(manager),
47  theHC(nullptr),
48  currentHit(nullptr),
49  theTrack(nullptr),
50  preStepPoint(nullptr),
51  postStepPoint(nullptr),
52  unitID(0),
53  previousUnitID(0),
54  primID(-2),
55  hcID(-1),
56  tsID(-2),
57  primaryID(0),
58  tSliceID(-1),
59  timeFactor(1.0),
60  energyCut(1.e+9),
61  energyHistoryCut(1.e+9) {
62  slave = new TrackingSlaveSD(name);
64 }
uint32_t previousUnitID
Definition: TimingSD.h:87
SensitiveTkDetector(const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
double timeFactor
Definition: TimingSD.h:101
int hcID
Definition: TimingSD.h:90
int primID
Definition: TimingSD.h:89
BscG4Hit * currentHit
Definition: TimingSD.h:82
int tsID
Definition: TimingSD.h:91
TrackingSlaveSD * slave
Definition: TimingSD.h:76
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:77
const G4Track * theTrack
Definition: TimingSD.h:83
double energyHistoryCut
Definition: TimingSD.h:104
const G4StepPoint * preStepPoint
Definition: TimingSD.h:84
int tSliceID
Definition: TimingSD.h:93
double energyCut
Definition: TimingSD.h:103
uint32_t unitID
Definition: TimingSD.h:87
const G4StepPoint * postStepPoint
Definition: TimingSD.h:85
BscG4HitCollection * theHC
Definition: TimingSD.h:80
const SimTrackManager * theManager
Definition: TimingSD.h:79
int primaryID
Definition: TimingSD.h:92
TimingSD::~TimingSD ( )
override

Definition at line 66 of file TimingSD.cc.

References slave, and theEnumerator.

66  {
67  delete slave;
68  delete theEnumerator;
69 }
TrackingSlaveSD * slave
Definition: TimingSD.h:76
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:77

Member Function Documentation

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

Reimplemented in Bcm1fSD, and PltSD.

Definition at line 220 of file TimingSD.cc.

References dqmMemoryStats::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().

220  {
221  // change hit info to fastest primary particle
222  if (tof < hit->getTof()) {
223  hit->setTrackID(primaryID);
224  hit->setIncidentEnergy((float)incidentEnergy);
225  hit->setPabs(float(preStepPoint->GetMomentum().mag()) * invgev);
226  hit->setTof(tof);
227  hit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
228 
229  float ThetaAtEntry = (float)(hitPointLocal.theta() * invdeg);
230  float PhiAtEntry = (float)(hitPointLocal.phi() * invdeg);
231 
232  hit->setThetaAtEntry(ThetaAtEntry);
233  hit->setPhiAtEntry(PhiAtEntry);
234 
235  hit->setEntry(hitPoint);
238 
239  hit->setParentId(theTrack->GetParentID());
240  hit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
241 
242  hit->setVertexPosition(theTrack->GetVertexPosition());
243  }
244  return true;
245 }
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:97
void setIncidentEnergy(float e)
Definition: BscG4Hit.h:51
G4ThreeVector hitPointLocal
Definition: TimingSD.h:97
void setTrackID(int id)
Definition: BscG4Hit.h:54
void setParentId(int p)
Definition: BscG4Hit.h:99
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:98
void setParticleType(int i)
Definition: BscG4Hit.h:75
void setThetaAtEntry(float t)
Definition: BscG4Hit.h:80
void setPabs(float e)
Definition: BscG4Hit.h:72
unsigned int processId(const G4VProcess *p) const
static const float invgev
Definition: TimingSD.cc:35
float tof
Definition: TimingSD.h:107
void setPhiAtEntry(float f)
Definition: BscG4Hit.h:81
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:77
static const double invdeg
Definition: TimingSD.cc:37
const G4Track * theTrack
Definition: TimingSD.h:83
const G4StepPoint * preStepPoint
Definition: TimingSD.h:84
void setExitLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:36
void setVertexPosition(const G4ThreeVector &)
Definition: BSCG4Hit.cc:124
double incidentEnergy
Definition: TimingSD.h:106
void setProcessId(int p)
Definition: BscG4Hit.h:100
G4ThreeVector hitPoint
Definition: TimingSD.h:95
int primaryID
Definition: TimingSD.h:92
void TimingSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 370 of file TimingSD.cc.

References TrackingSlaveSD::Initialize(), and slave.

Referenced by update().

370 { slave->Initialize(); }
virtual void Initialize()
TrackingSlaveSD * slave
Definition: TimingSD.h:76
void TimingSD::createNewHit ( const G4Step *  aStep)
private

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

258  {
259 #ifdef debug
260  const G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
261  edm::LogVerbatim("TimingSim") << "TimingSD CreateNewHit for " << GetName() << " PV " << currentPV->GetName()
262  << " PVid = " << currentPV->GetCopyNo() << " Unit " << unitID << "\n primary "
263  << primaryID << " Tof(ns)= " << tof << " time slice " << tSliceID
264  << " E(GeV)= " << incidentEnergy << " trackID " << theTrack->GetTrackID() << " "
265  << theTrack->GetDefinition()->GetParticleName() << " parentID "
266  << theTrack->GetParentID();
267 
268  if (theTrack->GetCreatorProcess() != nullptr) {
269  edm::LogVerbatim("TimingSim") << theTrack->GetCreatorProcess()->GetProcessName();
270  } else {
271  edm::LogVerbatim("TimingSim") << " is primary particle";
272  }
273 #endif
274 
275  currentHit = new BscG4Hit;
280 
281  currentHit->setPabs(float(preStepPoint->GetMomentum().mag() * invgev));
283  currentHit->setParticleType(theTrack->GetDefinition()->GetPDGEncoding());
284 
285  float ThetaAtEntry = hitPointLocal.theta() * invdeg;
286  float PhiAtEntry = hitPointLocal.phi() * invdeg;
287 
288  currentHit->setThetaAtEntry(ThetaAtEntry);
289  currentHit->setPhiAtEntry(PhiAtEntry);
290 
294 
295  currentHit->setParentId(theTrack->GetParentID());
296  currentHit->setProcessId(theEnumerator->processId(theTrack->GetCreatorProcess()));
297 
298  currentHit->setVertexPosition(theTrack->GetVertexPosition());
299 
300  updateHit();
302 }
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:97
void setIncidentEnergy(float e)
Definition: BscG4Hit.h:51
G4ThreeVector hitPointLocal
Definition: TimingSD.h:97
void setTrackID(int id)
Definition: BscG4Hit.h:54
void setParentId(int p)
Definition: BscG4Hit.h:99
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:98
BscG4Hit * currentHit
Definition: TimingSD.h:82
void setParticleType(int i)
Definition: BscG4Hit.h:75
void setThetaAtEntry(float t)
Definition: BscG4Hit.h:80
void storeHit(BscG4Hit *)
Definition: TimingSD.cc:247
void setPabs(float e)
Definition: BscG4Hit.h:72
unsigned int processId(const G4VProcess *p) const
static const float invgev
Definition: TimingSD.cc:35
void setUnitID(uint32_t id)
Definition: BscG4Hit.h:57
float tof
Definition: TimingSD.h:107
void setPhiAtEntry(float f)
Definition: BscG4Hit.h:81
G4ProcessTypeEnumerator * theEnumerator
Definition: TimingSD.h:77
static const double invdeg
Definition: TimingSD.cc:37
const G4Track * theTrack
Definition: TimingSD.h:83
const G4StepPoint * preStepPoint
Definition: TimingSD.h:84
int tSliceID
Definition: TimingSD.h:93
void setTimeSlice(double d)
Definition: BscG4Hit.h:60
uint32_t unitID
Definition: TimingSD.h:87
void setExitLocalP(const G4ThreeVector &xyz)
Definition: BscG4Hit.h:36
double tSlice
Definition: TimingSD.h:100
void setVertexPosition(const G4ThreeVector &)
Definition: BSCG4Hit.cc:124
void updateHit()
Definition: TimingSD.cc:304
double incidentEnergy
Definition: TimingSD.h:106
void setProcessId(int p)
Definition: BscG4Hit.h:100
G4ThreeVector hitPoint
Definition: TimingSD.h:95
int primaryID
Definition: TimingSD.h:92
void TimingSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 323 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.

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

Implements SensitiveTkDetector.

Definition at line 359 of file TimingSD.cc.

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

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

Definition at line 67 of file TimingSD.h.

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

Referenced by FastTimerSD::setDetUnitId().

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

Definition at line 66 of file TimingSD.h.

References hitPointLocal.

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

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

Definition at line 120 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, TrackInformation::putInHistory(), SensitiveDetector::setDetUnitId(), setToLocal(), mathSSE::sqrt(), TrackInformation::storeTrack(), theTrack, timeFactor, tof, tSlice, tSliceID, and unitID.

Referenced by getGlobalEntryPoint(), and ProcessHits().

120  {
121  preStepPoint = aStep->GetPreStepPoint();
122  postStepPoint = aStep->GetPostStepPoint();
123  hitPointExit = postStepPoint->GetPosition();
125  const G4Track* newTrack = aStep->GetTrack();
126 
127  // neutral particles deliver energy post step
128  // charged particle start deliver energy pre step
129  if (newTrack->GetDefinition()->GetPDGCharge() == 0.0) {
132  tof = (float)(postStepPoint->GetGlobalTime() * invns);
133  } else {
134  hitPoint = preStepPoint->GetPosition();
136  tof = (float)(preStepPoint->GetGlobalTime() * invns);
137  }
138 
139 #ifdef debug
140  double distGlobal =
141  std::sqrt(std::pow(hitPoint.x() - hitPointExit.x(), 2) + std::pow(hitPoint.y() - hitPointExit.y(), 2) +
142  std::pow(hitPoint.z() - hitPointExit.z(), 2));
143  double distLocal = std::sqrt(std::pow(hitPointLocal.x() - hitPointLocalExit.x(), 2) +
146  LogDebug("TimingSim") << "TimingSD:"
147  << "\n Global entry point: " << hitPoint << "\n Global exit point: " << hitPointExit
148  << "\n Global step length: " << distGlobal << "\n Local entry point: " << hitPointLocal
149  << "\n Local exit point: " << hitPointLocalExit << "\n Local step length: " << distLocal;
150  if (std::fabs(distGlobal - distLocal) > 1.e-6) {
151  LogDebug("TimingSim") << "DIFFERENCE IN DISTANCE \n";
152  }
153 #endif
154 
155  incidentEnergy = preStepPoint->GetKineticEnergy();
156 
157  // should MC truth be saved
158  if (newTrack != theTrack) {
159  theTrack = newTrack;
160  TrackInformation* info = nullptr;
161  if (incidentEnergy > energyCut) {
163  info->storeTrack(true);
164  }
166  if (!info) {
168  }
169  info->putInHistory();
170  }
171  }
172 
173  edeposit *= invgev;
176  edepositHAD = 0.f;
177  } else {
178  edepositEM = 0.f;
180  }
181  // time slice is defined for the entry point
182  tSlice = timeFactor * preStepPoint->GetGlobalTime() * invns;
183  tSliceID = (int)tSlice;
184 
185  unitID = setDetUnitId(aStep);
186  primaryID = theTrack->GetTrackID();
187 }
#define LogDebug(id)
static const TGPicture * info(bool iBackgroundIsBlack)
bool storeTrack() const
double timeFactor
Definition: TimingSD.h:101
float edepositHAD
Definition: TimingSD.h:109
G4ThreeVector hitPointLocal
Definition: TimingSD.h:97
virtual uint32_t setDetUnitId(const G4Step *step)=0
G4ThreeVector hitPointLocalExit
Definition: TimingSD.h:98
float edepositEM
Definition: TimingSD.h:109
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:107
T sqrt(T t)
Definition: SSEVec.h:19
float edeposit
Definition: TimingSD.h:108
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const G4Track * theTrack
Definition: TimingSD.h:83
double energyHistoryCut
Definition: TimingSD.h:104
const G4StepPoint * preStepPoint
Definition: TimingSD.h:84
int tSliceID
Definition: TimingSD.h:93
double energyCut
Definition: TimingSD.h:103
uint32_t unitID
Definition: TimingSD.h:87
double tSlice
Definition: TimingSD.h:100
static const double invns
Definition: TimingSD.cc:36
const G4StepPoint * postStepPoint
Definition: TimingSD.h:85
static bool isGammaElectronPositron(int pdgCode)
double incidentEnergy
Definition: TimingSD.h:106
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
G4ThreeVector hitPointExit
Definition: TimingSD.h:96
G4ThreeVector hitPoint
Definition: TimingSD.h:95
int primaryID
Definition: TimingSD.h:92
bool TimingSD::hitExists ( const G4Step *  aStep)
private

Definition at line 189 of file TimingSD.cc.

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

Referenced by getGlobalEntryPoint(), and ProcessHits().

189  {
190  if (!currentHit) {
191  return false;
192  }
193 
194  // Update if in the same detector and time-slice
195  if (tSliceID == tsID && unitID == previousUnitID) {
196  updateHit();
197  return true;
198  }
199 
200  //look in the HitContainer whether a hit with the same primID, unitID,
201  //tSliceID already exists:
202 
203  bool found = false;
204  for (int j = 0; j < theHC->entries(); ++j) {
205  BscG4Hit* aHit = (*theHC)[j];
206  if (aHit->getTimeSliceID() == tSliceID && aHit->getUnitID() == unitID) {
207  if (checkHit(aStep, aHit)) {
208  currentHit = aHit;
209  found = true;
210  break;
211  }
212  }
213  }
214  if (found) {
215  updateHit();
216  }
217  return found;
218 }
uint32_t previousUnitID
Definition: TimingSD.h:87
virtual bool checkHit(const G4Step *, BscG4Hit *)
Definition: TimingSD.cc:220
BscG4Hit * currentHit
Definition: TimingSD.h:82
int getTimeSliceID() const
Definition: BscG4Hit.h:61
int tsID
Definition: TimingSD.h:91
int tSliceID
Definition: TimingSD.h:93
uint32_t unitID
Definition: TimingSD.h:87
void updateHit()
Definition: TimingSD.cc:304
BscG4HitCollection * theHC
Definition: TimingSD.h:80
uint32_t getUnitID() const
Definition: BscG4Hit.h:56
void TimingSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 71 of file TimingSD.cc.

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

71  {
72  edm::LogVerbatim("TimingSim") << "TimingSD : Initialize called for " << GetName() << " time slice factor "
73  << timeFactor << "\n MC truth cuts in are " << energyCut / CLHEP::GeV << " GeV and "
74  << energyHistoryCut / CLHEP::GeV << " GeV";
75 
76  theHC = new BscG4HitCollection(GetName(), collectionName[0]);
77  if (hcID < 0) {
78  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
79  }
80  HCE->AddHitsCollection(hcID, theHC);
81 
82  tsID = -2;
83  primID = -2;
84 }
const double GeV
Definition: MathUtil.h:16
double timeFactor
Definition: TimingSD.h:101
int hcID
Definition: TimingSD.h:90
int primID
Definition: TimingSD.h:89
int tsID
Definition: TimingSD.h:91
double energyHistoryCut
Definition: TimingSD.h:104
double energyCut
Definition: TimingSD.h:103
BscG4HitCollection * theHC
Definition: TimingSD.h:80
G4THitsCollection< BscG4Hit > BscG4HitCollection
void TimingSD::PrintAll ( )
override

Definition at line 354 of file TimingSD.cc.

References LogDebug, and theHC.

354  {
355  LogDebug("TimingSim") << "TimingSD: Collection " << theHC->GetName() << "\n";
356  theHC->PrintAllHits();
357 }
#define LogDebug(id)
BscG4HitCollection * theHC
Definition: TimingSD.h:80
bool TimingSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Definition at line 109 of file TimingSD.cc.

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

109  {
110  edeposit = aStep->GetTotalEnergyDeposit();
111  if (edeposit > 0.f) {
112  getStepInfo(aStep);
113  if (!hitExists(aStep)) {
114  createNewHit(aStep);
115  }
116  }
117  return true;
118 }
void createNewHit(const G4Step *)
Definition: TimingSD.cc:258
void getStepInfo(const G4Step *)
Definition: TimingSD.cc:120
float edeposit
Definition: TimingSD.h:108
double f[11][100]
bool hitExists(const G4Step *)
Definition: TimingSD.cc:189
void TimingSD::setCuts ( double  eCut,
double  historyCut 
)
protected

Definition at line 96 of file TimingSD.cc.

References energyCut, energyHistoryCut, and GeV.

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

96  {
97  if (eCut > 0.) {
98  energyCut = eCut;
99  }
100  if (historyCut > 0.) {
101  energyHistoryCut = historyCut;
102  }
103 #ifdef debug
104  edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " MC truth cuts in are " << energyCut / CLHEP::GeV
105  << " GeV and " << energyHistoryCut / CLHEP::GeV << " GeV";
106 #endif
107 }
const double GeV
Definition: MathUtil.h:16
double energyHistoryCut
Definition: TimingSD.h:104
double energyCut
Definition: TimingSD.h:103
void TimingSD::setTimeFactor ( double  val)
protected

Definition at line 86 of file TimingSD.cc.

References timeFactor, and heppy_batch::val.

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

86  {
87  if (val <= 0.0) {
88  return;
89  }
90  timeFactor = val;
91 #ifdef debug
92  edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " time slice factor is set to " << timeFactor;
93 #endif
94 }
double timeFactor
Definition: TimingSD.h:101
void TimingSD::setToLocal ( const G4StepPoint *  stepPoint,
const G4ThreeVector &  globalPoint,
G4ThreeVector &  localPoint 
)
protected

Definition at line 318 of file TimingSD.cc.

Referenced by getStepInfo().

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

Definition at line 247 of file TimingSD.cc.

References primID, and theHC.

Referenced by createNewHit(), and getGlobalEntryPoint().

247  {
248  if (primID < 0)
249  return;
250  if (hit == nullptr) {
251  edm::LogWarning("BscSim") << "BscSD: hit to be stored is NULL !!";
252  return;
253  }
254 
255  theHC->insert(hit);
256 }
int primID
Definition: TimingSD.h:89
BscG4HitCollection * theHC
Definition: TimingSD.h:80
void TimingSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

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

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

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

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

Member Data Documentation

BscG4Hit* TimingSD::currentHit
private

Definition at line 82 of file TimingSD.h.

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

float TimingSD::edeposit
private

Definition at line 108 of file TimingSD.h.

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

float TimingSD::edepositEM
private

Definition at line 109 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

float TimingSD::edepositHAD
private

Definition at line 109 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

double TimingSD::energyCut
private

Definition at line 103 of file TimingSD.h.

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

double TimingSD::energyHistoryCut
private

Definition at line 104 of file TimingSD.h.

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

int TimingSD::hcID
private

Definition at line 90 of file TimingSD.h.

Referenced by Initialize().

G4ThreeVector TimingSD::hitPoint
private

Definition at line 95 of file TimingSD.h.

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

G4ThreeVector TimingSD::hitPointExit
private

Definition at line 96 of file TimingSD.h.

Referenced by getStepInfo().

G4ThreeVector TimingSD::hitPointLocal
private

Definition at line 97 of file TimingSD.h.

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

G4ThreeVector TimingSD::hitPointLocalExit
private

Definition at line 98 of file TimingSD.h.

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

double TimingSD::incidentEnergy
private

Definition at line 106 of file TimingSD.h.

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

const G4StepPoint* TimingSD::postStepPoint
private

Definition at line 85 of file TimingSD.h.

Referenced by getStepInfo(), and updateHit().

const G4StepPoint* TimingSD::preStepPoint
private

Definition at line 84 of file TimingSD.h.

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

uint32_t TimingSD::previousUnitID
private

Definition at line 87 of file TimingSD.h.

Referenced by hitExists(), and updateHit().

int TimingSD::primaryID
private

Definition at line 92 of file TimingSD.h.

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

int TimingSD::primID
private

Definition at line 89 of file TimingSD.h.

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

TrackingSlaveSD* TimingSD::slave
private

Definition at line 76 of file TimingSD.h.

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

G4ProcessTypeEnumerator* TimingSD::theEnumerator
private

Definition at line 77 of file TimingSD.h.

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

BscG4HitCollection* TimingSD::theHC
private

Definition at line 80 of file TimingSD.h.

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

const SimTrackManager* TimingSD::theManager
private

Definition at line 79 of file TimingSD.h.

const G4Track* TimingSD::theTrack
private

Definition at line 83 of file TimingSD.h.

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

double TimingSD::timeFactor
private

Definition at line 101 of file TimingSD.h.

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

float TimingSD::tof
private

Definition at line 107 of file TimingSD.h.

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

int TimingSD::tsID
private

Definition at line 91 of file TimingSD.h.

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

double TimingSD::tSlice
private

Definition at line 100 of file TimingSD.h.

Referenced by createNewHit(), and getStepInfo().

int TimingSD::tSliceID
private

Definition at line 93 of file TimingSD.h.

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

uint32_t TimingSD::unitID
private

Definition at line 87 of file TimingSD.h.

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