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;
105 LogDebug(
"TrackerSimDebug")<<
" Entering a new Step " << aStep->GetTotalEnergyDeposit() <<
" " 106 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
130 return theNumberingScheme.get()->g4ToNumberingScheme(step->GetPreStepPoint()->GetTouchable());
134 const G4Track* gTrack = (*bot)();
137 if (gTrack->GetCreatorProcess()) {
138 edm::LogInfo(
"TrackerSimInfo")<<
" -> PROCESS CREATOR : " 139 <<gTrack->GetCreatorProcess()->GetProcessName();
141 edm::LogInfo(
"TrackerSimInfo") <<
" -> No Creator process";
148 const G4ThreeVector&
pos = gTrack->GetPosition();
150 <<
" update(..) of " << gTrack->GetDefinition()->GetParticleName()
151 <<
" trackID= " << gTrack->GetTrackID()
152 <<
" E(MeV)= "<<gTrack->GetKineticEnergy() <<
" Ecut= " <<
energyCut 153 <<
" R(mm)= " << pos.perp() <<
" Z(mm)= " << pos.z();
162 if (gTrack->GetKineticEnergy() >
energyCut){
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;
251 G4VUserTrackInformation *
info = theTrack->GetUserInformation();
252 if (info ==
nullptr) {
254 <<
" no UserTrackInformation available for trackID= " << theTrackID;
255 throw cms::Exception(
"TkAccumulatingSensitiveDetector::createHit")
256 <<
" cannot handle hits for tracking in " << GetName();
259 if (temp ==
nullptr) {
261 <<
" G4VUserTrackInformation is not a TrackInformation for trackID= " 263 throw cms::Exception(
"TkAccumulatingSensitiveDetector::createHit")
264 <<
" cannot handle hits for tracking in " << GetName();
268 theTrackIDInsideTheSimHit = theTrack->GetParentID();
270 <<
" TkAccumulatingSensitiveDetector::createHit(): setting the TrackID from " 271 << theTrackIDInsideTheSimHit
272 <<
" to the mother one " << theTrackIDInsideTheSimHit <<
" " << theEnergyLoss;
275 <<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID " 276 << theTrackIDInsideTheSimHit;
281 const G4ThreeVector& gmd = preStepPoint->GetMomentumDirection();
283 G4ThreeVector lmd = ((G4TouchableHistory *)(preStepPoint->GetTouchable()))->GetHistory()
284 ->GetTopTransform().TransformAxis(gmd);
286 float theThetaAtEntry = lnmd.
theta();
287 float thePhiAtEntry = lnmd.
phi();
290 theEnergyLoss,theParticleType,theDetUnitId,
291 theTrackIDInsideTheSimHit,theThetaAtEntry,thePhiAtEntry,
302 px = preStepPoint->GetMomentum().x()/
GeV;
303 py = preStepPoint->GetMomentum().y()/
GeV;
304 pz = preStepPoint->GetMomentum().z()/
GeV;
305 oldVolume = preStepPoint->GetPhysicalVolume();
306 pname = theTrack->GetDefinition()->GetParticleName();
310 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag()
322 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
329 <<
" updateHit: for " << aStep->GetTrack()->GetDefinition()->GetParticleName()
330 <<
" trackID= " << aStep->GetTrack()->GetTrackID() <<
" deltaEloss= " << theEnergyLoss
338 const G4Track * theTrack = aStep->GetTrack();
341 if(0.0 == theTrack->GetDefinition()->GetPDGCharge())
return true;
344 int theTrackID = theTrack->GetTrackID();
347 <<
"), NEW = (" << theDetUnitId <<
"," << theTrackID
348 <<
") Step length(mm)= " << aStep->GetStepLength()
349 <<
" Edep= " << aStep->GetTotalEnergyDeposit()
350 <<
" p= " << aStep->GetPreStepPoint()->GetMomentum().mag();
357 const float tolerance2 = 0.0025f;
359 LogDebug(
"TrackerSimDebug")<<
" closeHit: distance = " 367 LogDebug(
"TrackerSimDebug")<<
" Saving the last hit in a ROU " << GetName();
374 eventno = (*i)()->GetEventID();
399 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
400 if (temp ==
nullptr){
401 edm::LogWarning(
"TkAccumulatingSensitiveDetector::getTrackInformation")
402 <<
" ERROR: no G4VUserTrackInformation available for track " 403 << gTrack->GetTrackID() <<
" Ekin(MeV)= " << gTrack->GetKineticEnergy()
404 <<
" " << gTrack->GetDefinition()->GetParticleName();
405 throw cms::Exception(
"TkAccumulatingSensitiveDetector::getTrackInformation")
406 <<
" cannot handle hits for tracking in " << GetName();
409 if (info ==
nullptr){
410 edm::LogWarning(
"TkAccumulatingSensitiveDetector::getTrackInformation")
411 <<
" G4VUserTrackInformation is not a TrackInformation for " 412 <<
"TrackID= " << gTrack->GetTrackID() <<
" Ekin(MeV)= " << gTrack->GetKineticEnergy()
413 <<
" " << gTrack->GetDefinition()->GetParticleName();
414 throw cms::Exception(
"TkAccumulatingSensitiveDetector::getTrackInformation")
415 <<
" cannot handle hits for tracking in " << GetName();
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
TrackInformation * getTrackInformation(const G4Track *)
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 *)
std::unique_ptr< const G4TrackToParticleID > theG4TrackToParticleID
void setExitPoint(const Local3DPoint &exit)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
uint32_t setDetUnitId(const G4Step *) override
type of data representation of DDCompactView
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()
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)