22 #include "G4StepPoint.hh" 23 #include "G4VProcess.hh" 25 #include "G4SystemOfUnits.hh" 49 rTracker(1200. *
CLHEP::mm),
50 zTracker(3000. *
CLHEP::mm),
66 m_TrackerSD.
getParameter<
double>(
"EnergyThresholdForPersistencyInGeV") * CLHEP::GeV;
68 m_TrackerSD.
getParameter<
double>(
"EnergyThresholdForHistoryInGeV") * CLHEP::GeV;
73 theRotation = std::make_unique<TrackerFrameRotation>();
74 rotType =
"TrackerFrameRotation";
76 #ifdef FAKEFRAMEROTATION 78 rotType =
"FakeFrameRotation";
82 <<
" Criteria for Saving Tracker SimTracks: \n" 85 <<
"\n FrameRotation type " << rotType <<
" rTracker(cm)= " <<
rTracker / CLHEP::cm
86 <<
" zTracker(cm)= " <<
zTracker / CLHEP::cm
93 std::vector<std::string>
temp;
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) {
155 info->storeTrack(
true);
164 info->putInHistory();
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;
244 if (!
temp->storeTrack()) {
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,
283 px = preStepPoint->GetMomentum().x() / CLHEP::GeV;
284 py = preStepPoint->GetMomentum().y() / CLHEP::GeV;
285 pz = preStepPoint->GetMomentum().z() / CLHEP::GeV;
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_
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
unsigned int detUnitId() const
const G4VPhysicalVolume * oldVolume
std::unique_ptr< const G4ProcessTypeEnumerator > theG4ProcTypeEnumerator
Geom::Phi< T > phi() const
Local3DPoint globalExitPoint
void setExitPoint(const Local3DPoint &exit)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
Local3DPoint exitPoint() const
Exit point in the local Det frame.
uint32_t setDetUnitId(const G4Step *) override
bool closeHit(const G4Step *)
std::unique_ptr< TrackingSlaveSD > slaveLowTof
UpdatablePSimHit * mySimHit
void printHitData(const std::string &, float, float, float) const
void fillHits(edm::PSimHitContainer &, const std::string &) override
unsigned int g4ToNumberingScheme(const G4VTouchable *)
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
void updateHit(const G4Step *)
Local3DPoint globalEntryPoint
Abs< T >::type abs(const T &t)
void clearHits() override
Local3DPoint entryPoint() const
Entry point in the local Det frame.
bool newHit(const G4Step *)
unsigned int trackId() const
void printGlobal(const Local3DPoint &, const Local3DPoint &) const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
static int particleID(const G4Track *)
Local3DPoint LocalPreStepPosition(const G4Step *step) const
void addEnergyLoss(float eloss)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
float energyLoss() const
The energy deposit in the PSimHit, in ???.
void setNames(const std::vector< std::string > &)
void printGlobalMomentum(float, float, float) const
~TkAccumulatingSensitiveDetector() override
static TrackerG4SimHitNumberingScheme & numberingScheme(const GeometricDet &det)
float timeOfFlight() const
Local3DPoint LocalPostStepPosition(const G4Step *step) const
std::vector< PSimHit > PSimHitContainer
void EndOfEvent(G4HCofThisEvent *) override
Log< level::Warning, false > LogWarning
TkAccumulatingSensitiveDetector(const std::string &, const GeometricDet *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void printLocal(const Local3DPoint &, const Local3DPoint &) const
Geom::Theta< T > theta() const
TrackerG4SimHitNumberingScheme * theNumberingScheme
void startNewSimHit(const std::string &, const std::string &, int, int, int, int)