22 #include "G4StepPoint.hh"
23 #include "G4VProcess.hh"
25 #include "G4SystemOfUnits.hh"
49 rTracker(1200. * CLHEP::mm),
50 zTracker(3000. * CLHEP::mm),
73 theRotation = std::make_unique<TrackerFrameRotation>();
74 rotType =
"TrackerFrameRotation";
76 #ifdef FAKEFRAMEROTATION
78 rotType =
"FakeFrameRotation";
82 <<
" Criteria for Saving Tracker SimTracks: \n"
83 <<
" History: " << energyHistoryCut <<
" MeV; Persistency: " << energyCut
84 <<
" MeV; TofLimit: " << theTofLimit <<
" ns"
85 <<
"\n FrameRotation type " << rotType <<
" rTracker(cm)= " << rTracker / CLHEP::cm
86 <<
" zTracker(cm)= " <<
zTracker / CLHEP::cm
87 <<
" allowZeroEnergyLoss: " << allowZeroEnergyLoss
88 <<
" neverAccumulate: " << neverAccumulate <<
" printHits: " <<
printHits;
90 slaveLowTof = std::make_unique<TrackingSlaveSD>(name +
"LowTof");
91 slaveHighTof = std::make_unique<TrackingSlaveSD>(name +
"HighTof");
93 std::vector<std::string>
temp;
95 temp.push_back(slaveHighTof.get()->name());
105 LogDebug(
"TrackerSimDebug") <<
" Entering a new Step " << aStep->GetTotalEnergyDeposit() <<
" "
106 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
127 const G4Track* gTrack = (*bot)();
130 if (gTrack->GetCreatorProcess()) {
131 edm::LogVerbatim(
"TrackerSim") <<
" -> PROCESS CREATOR : " << gTrack->GetCreatorProcess()->GetProcessName();
140 const G4ThreeVector& pos = gTrack->GetPosition();
141 LogDebug(
"TrackerSimDebug") <<
" update(..) of " << gTrack->GetDefinition()->GetParticleName()
142 <<
" trackID= " << gTrack->GetTrackID() <<
" E(MeV)= " << gTrack->GetKineticEnergy()
143 <<
" Ecut= " <<
energyCut <<
" R(mm)= " << pos.perp() <<
" Z(mm)= " << pos.z();
153 if (gTrack->GetKineticEnergy() >
energyCut) {
165 LogDebug(
"TrackerSimDebug") <<
" Track inside the tracker selected for HISTORY"
166 <<
" Track ID= " << gTrack->GetTrackID();
177 oldVolume->GetLogicalVolume()->GetName(),
209 const G4Track* theTrack = aStep->GetTrack();
216 if (0.0 == theTrack->GetDefinition()->GetPDGCharge()) {
217 theEntryPoint = theExitPoint;
225 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
226 float thePabs = preStepPoint->GetMomentum().mag() /
GeV;
227 float theTof = preStepPoint->GetGlobalTime() / nanosecond;
228 float theEnergyLoss = aStep->GetTotalEnergyDeposit() /
GeV;
231 int theTrackID = theTrack->GetTrackID();
232 if (theDetUnitId == 0) {
233 edm::LogWarning(
"TkAccumulatingSensitiveDetector::createHit") <<
" theDetUnitId is not valid for " << GetName();
234 throw cms::Exception(
"TkAccumulatingSensitiveDetector::createHit")
235 <<
"cannot get theDetUnitId for G4Track " << theTrackID;
241 unsigned int theTrackIDInsideTheSimHit = theTrackID;
246 theTrackIDInsideTheSimHit = theTrack->GetParentID();
247 LogDebug(
"TrackerSimDebug") <<
" TkAccumulatingSensitiveDetector::createHit(): setting the TrackID from "
248 << theTrackIDInsideTheSimHit <<
" to the mother one " << theTrackIDInsideTheSimHit
249 <<
" " << theEnergyLoss;
251 LogDebug(
"TrackerSimDebug") <<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID "
252 << theTrackIDInsideTheSimHit;
255 const G4ThreeVector& gmd = preStepPoint->GetMomentumDirection();
258 ((G4TouchableHistory*)(preStepPoint->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
260 float theThetaAtEntry = lnmd.
theta();
261 float thePhiAtEntry = lnmd.
phi();
270 theTrackIDInsideTheSimHit,
286 oldVolume = preStepPoint->GetPhysicalVolume();
287 pname = theTrack->GetDefinition()->GetParticleName();
290 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag() <<
" "
301 float theEnergyLoss = aStep->GetTotalEnergyDeposit() /
GeV;
306 LogDebug(
"TrackerSimDebug") <<
" updateHit: for " << aStep->GetTrack()->GetDefinition()->GetParticleName()
307 <<
" trackID= " << aStep->GetTrack()->GetTrackID() <<
" deltaEloss= " << theEnergyLoss
315 const G4Track* theTrack = aStep->GetTrack();
318 if (0.0 == theTrack->GetDefinition()->GetPDGCharge())
322 int theTrackID = theTrack->GetTrackID();
325 << theDetUnitId <<
"," << theTrackID <<
") Step length(mm)= " << aStep->GetStepLength()
326 <<
" Edep= " << aStep->GetTotalEnergyDeposit()
327 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag();
332 const float tolerance2 = 0.0025f;
340 LogDebug(
"TrackerSimDebug") <<
" Saving the last hit in a ROU " << GetName();
347 eventno = (*i)()->GetEventID();
void createHit(const G4Step *)
Log< level::Info, true > LogVerbatim
const GeometricDet * pDD_
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
std::unique_ptr< TrackingSlaveSD > slaveHighTof
std::unique_ptr< FrameRotation > theRotation
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const G4VPhysicalVolume * oldVolume
std::unique_ptr< const G4ProcessTypeEnumerator > theG4ProcTypeEnumerator
void printHitData(const std::string &, float, float, float) const
Local3DPoint globalExitPoint
Geom::Phi< T > phi() const
void setExitPoint(const Local3DPoint &exit)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
uint32_t setDetUnitId(const G4Step *) override
void printGlobalMomentum(float, float, float) const
bool closeHit(const G4Step *)
std::unique_ptr< TrackingSlaveSD > slaveLowTof
Geom::Theta< T > theta() const
UpdatablePSimHit * mySimHit
void fillHits(edm::PSimHitContainer &, const std::string &) override
Local3DPoint exitPoint() const
Exit point in the local Det frame.
float timeOfFlight() const
unsigned int g4ToNumberingScheme(const G4VTouchable *)
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
void updateHit(const G4Step *)
Local3DPoint globalEntryPoint
Abs< T >::type abs(const T &t)
void clearHits() override
bool newHit(const G4Step *)
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
static int particleID(const G4Track *)
void addEnergyLoss(float eloss)
Local3DPoint LocalPostStepPosition(const G4Step *step) const
T getParameter(std::string const &) const
void printGlobal(const Local3DPoint &, const Local3DPoint &) const
void setNames(const std::vector< std::string > &)
~TkAccumulatingSensitiveDetector() override
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Local3DPoint LocalPreStepPosition(const G4Step *step) const
static TrackerG4SimHitNumberingScheme & numberingScheme(const GeometricDet &det)
unsigned int trackId() const
std::vector< PSimHit > PSimHitContainer
void EndOfEvent(G4HCofThisEvent *) override
Log< level::Warning, false > LogWarning
void printLocal(const Local3DPoint &, const Local3DPoint &) const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
TkAccumulatingSensitiveDetector(const std::string &, const GeometricDet *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
unsigned int detUnitId() const
TrackerG4SimHitNumberingScheme * theNumberingScheme
void startNewSimHit(const std::string &, const std::string &, int, int, int, int)