21 #include "G4StepPoint.hh" 23 #include "G4VPhysicalVolume.hh" 24 #include "G4SDManager.hh" 25 #include "G4VProcess.hh" 27 #include "G4PhysicalConstants.hh" 28 #include "G4SystemOfUnits.hh" 36 static const double invns = 1.0/CLHEP::nanosecond;
37 static const double invdeg= 1.0/CLHEP::deg;
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) {
62 <<
"TimingSD : Initialize called for " << GetName()
79 if(val <= 0.0) {
return; }
83 <<
"TimingSD : for " << GetName()
84 <<
" time slice factor is set to " <<
timeFactor;
94 <<
"TimingSD : for " << GetName()
102 edeposit = aStep->GetTotalEnergyDeposit();
118 const G4Track* newTrack = aStep->GetTrack();
122 if(newTrack->GetDefinition()->GetPDGCharge() == 0.0) {
139 LogDebug(
"TimingSim") <<
"TimingSD:" 140 <<
"\n Global entry point: " <<
hitPoint 142 <<
"\n Global step length: " << distGlobal
145 <<
"\n Local step length: " << distLocal;
146 if ( std::fabs(distGlobal - distLocal) > 1.
e-6 ) {
LogDebug(
"TimingSim") <<
"DIFFERENCE IN DISTANCE \n"; }
194 for (
int j=0; j<
theHC->entries(); ++j) {
211 if(tof < hit->getTof()) {
239 if (hit ==
nullptr ) {
244 theHC->insert( hit );
250 const G4VPhysicalVolume* currentPV =
preStepPoint->GetPhysicalVolume();
252 <<
"TimingSD CreateNewHit for " << GetName()
253 <<
" PV " << currentPV->GetName()
254 <<
" PVid = " << currentPV->GetCopyNo()
257 <<
" Tof(ns)= " <<
tof 260 <<
" trackID " <<
theTrack->GetTrackID()
261 <<
" " <<
theTrack->GetDefinition()->GetParticleName()
262 <<
" parentID " <<
theTrack->GetParentID();
264 if (
theTrack->GetCreatorProcess()!=
nullptr) {
266 <<
theTrack->GetCreatorProcess()->GetProcessName();
307 <<
"updateHit: " << GetName() <<
" add eloss(GeV) " <<
edeposit 319 const G4ThreeVector& globalPoint,
320 G4ThreeVector& localPoint) {
322 const G4VTouchable* touch= stepPoint->GetTouchable();
324 touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
330 if(0 == nhits) {
return; }
332 for (
int j=0; j<
nhits; ++j) {
339 edm::LogInfo(
"TimingSim") <<
"TimingSD: Hit for storage \n" << *aHit
340 <<
"\n Entry point: " << locEntryPoint
341 <<
"\n Exit point: " << locExitPoint <<
"\n";
359 LogDebug(
"TimingSim") <<
"TimingSD: Collection " <<
theHC->GetName() <<
"\n";
360 theHC->PrintAllHits();
368 LogDebug(
"TimingSim") <<
" Dispatched BeginOfEvent for " << GetName();
void setEntryLocalP(const G4ThreeVector &xyz)
void setEntry(const G4ThreeVector &xyz)
void setTimeFactor(double)
float getPhiAtEntry() const
int getParticleType() const
void EndOfEvent(G4HCofThisEvent *eventHC) override
void clearHits() override
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
void setIncidentEnergy(float e)
G4ThreeVector hitPointLocal
void fillHits(edm::PSimHitContainer &, const std::string &) override
virtual uint32_t setDetUnitId(const G4Step *step)=0
virtual bool checkHit(const G4Step *, BscG4Hit *)
G4ThreeVector hitPointLocalExit
void createNewHit(const G4Step *)
void setCuts(double eCut, double historyCut)
Compact representation of the geometrical detector hierarchy.
void setParticleType(int i)
int getTimeSliceID() const
void setToLocal(const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
void setThetaAtEntry(float t)
void storeHit(BscG4Hit *)
std::vector< PSimHit > & hits()
void getStepInfo(const G4Step *)
unsigned int processId(const G4VProcess *p) const
static const float invgev
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
void setUnitID(uint32_t id)
std::string const collectionName[nCollections]
virtual void Initialize()
bool ProcessHits(G4Step *, G4TouchableHistory *) override
void setPhiAtEntry(float f)
G4ProcessTypeEnumerator * theEnumerator
const G4ThreeVector & getExitLocalP() const
static const double invdeg
bool hitExists(const G4Step *)
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const G4StepPoint * preStepPoint
float getThetaAtEntry() const
void setTimeSlice(double d)
void addEnergyDeposit(float em, float hd)
void setExitLocalP(const G4ThreeVector &xyz)
void setVertexPosition(const G4ThreeVector &)
const G4ThreeVector & getEntryLocalP() const
static const double invns
TimingSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, const edm::ParameterSet &, const SimTrackManager *)
const G4StepPoint * postStepPoint
BscG4HitCollection * theHC
static bool isGammaElectronPositron(int pdgCode)
virtual bool processHits(const PSimHit &)
uint32_t getUnitID() const
std::vector< PSimHit > PSimHitContainer
G4THitsCollection< BscG4Hit > BscG4HitCollection
void Initialize(G4HCofThisEvent *HCE) override
Power< A, B >::type pow(const A &a, const B &b)
float getEnergyLoss() const
G4ThreeVector hitPointExit