28 #include "G4StepPoint.hh" 29 #include "G4VProcess.hh" 31 #include "G4SystemOfUnits.hh" 55 lastId(0),lastTrack(0),oldVolume(
nullptr),px(0.0
f),py(0.0
f),pz(0.0
f),eventno(0),
pname(
"")
69 rotType =
"TrackerFrameRotation";
71 #ifdef FAKEFRAMEROTATION 73 rotType =
"FakeFrameRotation";
76 edm::LogInfo(
"TrackerSimInfo")<<
" TkAccumulatingSensitiveDetector: " 77 <<
" Criteria for Saving Tracker SimTracks: \n" 78 <<
" History: "<<energyHistoryCut<<
" MeV; Persistency: " 79 << energyCut<<
" MeV; TofLimit: " << theTofLimit <<
" ns" 80 <<
"\n FrameRotation type " << rotType
81 <<
" rTracker(cm)= " << rTracker/CLHEP::cm
82 <<
" zTracker(cm)= " <<
zTracker/CLHEP::cm
83 <<
" allowZeroEnergyLoss: " << allowZeroEnergyLoss
84 <<
" neverAccumulate: " << neverAccumulate
90 std::vector<std::string>
temp;
104 LogDebug(
"TrackerSimDebug")<<
" Entering a new Step " << aStep->GetTotalEnergyDeposit() <<
" " 105 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
129 return theNumberingScheme.get()->g4ToNumberingScheme(step->GetPreStepPoint()->GetTouchable());
133 const G4Track* gTrack = (*bot)();
136 if (gTrack->GetCreatorProcess()) {
138 <<gTrack->GetCreatorProcess()->GetProcessName();
147 const G4ThreeVector&
pos = gTrack->GetPosition();
149 <<
" update(..) of " << gTrack->GetDefinition()->GetParticleName()
150 <<
" trackID= " << gTrack->GetTrackID()
151 <<
" E(MeV)= "<<gTrack->GetKineticEnergy() <<
" Ecut= " <<
energyCut 152 <<
" R(mm)= " << pos.perp() <<
" Z(mm)= " << pos.z();
157 if (pos.x()*pos.x() + pos.y()*pos.y() <
rTracker2 163 if (gTrack->GetKineticEnergy() >
energyCut){
173 LogDebug(
"TrackerSimDebug")<<
" Track inside the tracker selected for HISTORY" 174 <<
" Track ID= "<<gTrack->GetTrackID();
215 const G4Track * theTrack = aStep->GetTrack();
222 if(0.0 == theTrack->GetDefinition()->GetPDGCharge()) {
223 theEntryPoint = theExitPoint;
231 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
232 float thePabs = preStepPoint->GetMomentum().mag()/
GeV;
233 float theTof = preStepPoint->GetGlobalTime()/nanosecond;
234 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
237 int theTrackID = theTrack->GetTrackID();
238 if (theDetUnitId == 0)
241 <<
" theDetUnitId is not valid for " << GetName();
242 throw cms::Exception(
"TkAccumulatingSensitiveDetector::createHit")
243 <<
"cannot get theDetUnitId for G4Track " << theTrackID;
249 unsigned int theTrackIDInsideTheSimHit=theTrackID;
254 theTrackIDInsideTheSimHit = theTrack->GetParentID();
256 <<
" TkAccumulatingSensitiveDetector::createHit(): setting the TrackID from " 257 << theTrackIDInsideTheSimHit
258 <<
" to the mother one " << theTrackIDInsideTheSimHit <<
" " << theEnergyLoss;
261 <<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID " 262 << theTrackIDInsideTheSimHit;
265 const G4ThreeVector& gmd = preStepPoint->GetMomentumDirection();
267 G4ThreeVector lmd = ((G4TouchableHistory *)(preStepPoint->GetTouchable()))->GetHistory()
268 ->GetTopTransform().TransformAxis(gmd);
270 float theThetaAtEntry = lnmd.
theta();
271 float thePhiAtEntry = lnmd.
phi();
274 theEnergyLoss,theParticleType,theDetUnitId,
275 theTrackIDInsideTheSimHit,theThetaAtEntry,thePhiAtEntry,
289 oldVolume = preStepPoint->GetPhysicalVolume();
290 pname = theTrack->GetDefinition()->GetParticleName();
294 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag()
306 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
312 <<
" updateHit: for " << aStep->GetTrack()->GetDefinition()->GetParticleName()
313 <<
" trackID= " << aStep->GetTrack()->GetTrackID() <<
" deltaEloss= " << theEnergyLoss
322 const G4Track * theTrack = aStep->GetTrack();
325 if(0.0 == theTrack->GetDefinition()->GetPDGCharge())
return true;
328 int theTrackID = theTrack->GetTrackID();
331 <<
"), NEW = (" << theDetUnitId <<
"," << theTrackID
332 <<
") Step length(mm)= " << aStep->GetStepLength()
333 <<
" Edep= " << aStep->GetTotalEnergyDeposit()
334 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag();
341 const float tolerance2 = 0.0025f;
343 LogDebug(
"TrackerSimDebug")<<
" closeHit: distance = " 351 LogDebug(
"TrackerSimDebug")<<
" Saving the last hit in a ROU " << GetName();
358 eventno = (*i)()->GetEventID();
void createHit(const G4Step *)
T getParameter(std::string const &) const
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
TkAccumulatingSensitiveDetector(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void setExitPoint(const Local3DPoint &exit)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
uint32_t setDetUnitId(const G4Step *) override
Compact representation of the geometrical detector hierarchy.
void printGlobalMomentum(float, float, float) const
bool closeHit(const G4Step *)
std::unique_ptr< TrackingSlaveSD > slaveLowTof
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
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
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 *)
std::unique_ptr< TrackerG4SimHitNumberingScheme > theNumberingScheme
void addEnergyLoss(float eloss)
Local3DPoint LocalPostStepPosition(const G4Step *step) 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
unsigned int trackId() const
std::vector< PSimHit > PSimHitContainer
void EndOfEvent(G4HCofThisEvent *) override
void printLocal(const Local3DPoint &, const Local3DPoint &) const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const
void startNewSimHit(const std::string &, const std::string &, int, int, int, int)