20 #include "G4StepPoint.hh" 22 #include "G4VPhysicalVolume.hh" 23 #include "G4SDManager.hh" 24 #include "G4VProcess.hh" 26 #include "G4PhysicalConstants.hh" 27 #include "G4SystemOfUnits.hh" 32 static const float invgev = 1.0 / CLHEP::GeV;
33 static const double invns = 1.0 / CLHEP::nanosecond;
34 static const double invdeg = 1.0 / CLHEP::deg;
43 preStepPoint(nullptr),
44 postStepPoint(nullptr),
54 energyHistoryCut(1.
e+9) {
65 edm::LogVerbatim(
"TimingSim") <<
"TimingSD : Initialize called for " << GetName() <<
" time slice factor " 93 if (historyCut > 0.) {
103 edeposit = aStep->GetTotalEnergyDeposit();
118 const G4Track* newTrack = aStep->GetTrack();
122 if (newTrack->GetDefinition()->GetPDGCharge() == 0.0) {
139 LogDebug(
"TimingSim") <<
"TimingSD:" 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";
156 info->setStoreTrack();
159 if (
nullptr ==
info) {
162 info->putInHistory();
165 if (
info !=
nullptr) {
166 LogDebug(
"TimingSim") <<
"TrackInformation for ID = " <<
theTrack->GetTrackID();
203 int thehc_entries =
theHC->entries();
204 for (
int j = 0;
j < thehc_entries; ++
j) {
222 if (tof < hit->getTof()) {
227 hit->setParticleType(
theTrack->GetDefinition()->GetPDGEncoding());
232 hit->setThetaAtEntry(ThetaAtEntry);
233 hit->setPhiAtEntry(PhiAtEntry);
242 hit->setVertexPosition(
theTrack->GetVertexPosition());
250 if (
hit ==
nullptr) {
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 " 265 <<
theTrack->GetDefinition()->GetParticleName() <<
" parentID " 268 if (
theTrack->GetCreatorProcess() !=
nullptr) {
318 void TimingSD::setToLocal(
const G4StepPoint* stepPoint,
const G4ThreeVector& globalPoint, G4ThreeVector& localPoint) {
319 const G4VTouchable* touch = stepPoint->GetTouchable();
320 localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
336 << *aHit <<
"\n Entry point: " << locEntryPoint <<
"\n Exit point: " << locExitPoint;
357 theHC->PrintAllHits();
368 edm::LogVerbatim(
"TimingSim") <<
" Dispatched BeginOfEvent for " << GetName();
376 LogDebug(
"TimingSim") <<
"primary ID: " << aTrack->GetTrackID();
377 return aTrack->GetTrackID();
Log< level::Info, true > LogVerbatim
void setEntryLocalP(const G4ThreeVector &xyz)
void setEntry(const G4ThreeVector &xyz)
void setTimeFactor(double)
void EndOfEvent(G4HCofThisEvent *eventHC) override
void clearHits() override
void setIncidentEnergy(float e)
uint32_t getUnitID() const
uint32_t cc[maxCellsPerHit]
G4ThreeVector hitPointLocal
void fillHits(edm::PSimHitContainer &, const std::string &) override
int getParticleType() const
virtual uint32_t setDetUnitId(const G4Step *step)=0
virtual bool checkHit(const G4Step *, BscG4Hit *)
G4ThreeVector hitPointLocalExit
void createNewHit(const G4Step *)
float getPhiAtEntry() const
void setCuts(double eCut, double historyCut)
void setParticleType(int i)
void setToLocal(const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
void setThetaAtEntry(float t)
TimingSD(const std::string &, const SensitiveDetectorCatalog &, const SimTrackManager *)
void storeHit(BscG4Hit *)
std::vector< PSimHit > & hits()
void getStepInfo(const G4Step *)
static const float invgev
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
void setUnitID(uint32_t id)
virtual void Initialize()
bool ProcessHits(G4Step *, G4TouchableHistory *) override
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
void setPhiAtEntry(float f)
G4ProcessTypeEnumerator * theEnumerator
static const double invdeg
bool hitExists(const G4Step *)
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
const G4StepPoint * preStepPoint
void setTimeSlice(double d)
void addEnergyDeposit(float em, float hd)
float getThetaAtEntry() const
void setExitLocalP(const G4ThreeVector &xyz)
void setVertexPosition(const G4ThreeVector &)
static const double invns
float getEnergyLoss() const
int getTimeSliceID() const
const G4StepPoint * postStepPoint
BscG4HitCollection * theHC
static bool isGammaElectronPositron(int pdgCode)
const G4ThreeVector & getExitLocalP() const
virtual int getTrackID(const G4Track *)
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
unsigned int processId(const G4VProcess *p) const
G4THitsCollection< BscG4Hit > BscG4HitCollection
Log< level::Warning, false > LogWarning
const G4ThreeVector & getEntryLocalP() const
void Initialize(G4HCofThisEvent *HCE) override
Power< A, B >::type pow(const A &a, const B &b)
G4ThreeVector hitPointExit