29 #include "G4SDManager.hh"
30 #include "G4VProcess.hh"
31 #include "G4EventManager.hh"
44 #include "G4VProcess.hh"
66 SensitiveTkDetector(name, cpv, clg, p), myName(name), myRotation(0), mySimHit(0),theManager(manager),
67 oldVolume(0), lastId(0), lastTrack(0), eventno(0) ,rTracker(1200.*mm),zTracker(3000.*mm),
79 edm::LogInfo(
"TrackerSimInfo") <<
"Criteria for Saving Tracker SimTracks: ";
80 edm::LogInfo(
"TrackerSimInfo")<<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: "<< energyCut<<
" MeV ";
81 edm::LogInfo(
"TrackerSimInfo")<<
" Constructing a TkAccumulatingSensitiveDetector with ";
83 #ifndef FAKEFRAMEROTATION
85 if (name.find(
"TrackerHits") != string::npos)
87 edm::LogInfo(
"TrackerSimInfo")<<
" TkAccumulatingSensitiveDetector: using TrackerFrameRotation for "<<
myName;
93 edm::LogInfo(
"TrackerSimInfo")<<
" TkAccumulatingSensitiveDetector: using StandardFrameRotation for "<<
myName;
98 edm::LogWarning(
"TrackerSimInfo")<<
" WARNING - Using FakeFrameRotation in TkAccumulatingSensitiveDetector;";
107 for (vector<string>::iterator it = lvNames.begin(); it != lvNames.end(); it++)
109 edm::LogInfo(
"TrackerSimInfo")<< name <<
" attaching LV " << *it;
129 LogDebug(
"TrackerSimDebug")<<
" Entering a new Step " << aStep->GetTotalEnergyDeposit() <<
" "
130 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
135 if (
newHit(aStep) ==
true)
153 LogDebug(
"TrackerSimDebug")<<
" DetID = "<<detId;
163 if (tof < threshold)
return 1;
175 const G4Track* gTrack = (*bot)();
177 edm::LogInfo(
"TrackerSimInfo") <<
" -> process creator pointer "<<gTrack->GetCreatorProcess();
178 if (gTrack->GetCreatorProcess())
179 edm::LogInfo(
"TrackerSimInfo")<<
" -> PROCESS CREATOR : "<<gTrack->GetCreatorProcess()->GetProcessName();
186 const G4ThreeVector
pos = gTrack->GetPosition();
198 LogDebug(
"TrackerSimDebug")<<
" INSIDE TRACKER";
200 if (gTrack->GetKineticEnergy() >
energyCut){
263 G4Track * theTrack = aStep->GetTrack();
265 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
272 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
273 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
274 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
280 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
282 if (theDetUnitId == 0)
284 edm::LogError(
"TrackerSimInfo") <<
" Error: theDetUnitId is not valid.";
287 unsigned int theTrackID = theTrack->GetTrackID();
292 unsigned int theTrackIDInsideTheSimHit=theTrackID;
295 G4VUserTrackInformation *
info = theTrack->GetUserInformation();
296 if (info == 0)
edm::LogError(
"TrackerSimInfo")<<
" Error: no UserInformation available ";
300 if (temp ==0)
edm::LogError(
"TrackerSimInfo")<<
" Error:G4VUserTrackInformation is not a TrackInformation.";
304 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): setting the TrackID from "
305 << theTrackIDInsideTheSimHit;
306 theTrackIDInsideTheSimHit = theTrack->GetParentID();
307 LogDebug(
"TrackerSimDebug")<<
" to the mother one " << theTrackIDInsideTheSimHit <<
" " << theEnergyLoss;
311 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID "
312 << theTrackIDInsideTheSimHit;
317 px = aStep->GetPreStepPoint()->GetMomentum().x()/GeV;
318 py = aStep->GetPreStepPoint()->GetMomentum().y()/GeV;
319 pz = aStep->GetPreStepPoint()->GetMomentum().z()/GeV;
321 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
323 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
324 ->GetTopTransform().TransformAxis(gmd);
326 float theThetaAtEntry = lnmd.
theta();
327 float thePhiAtEntry = lnmd.
phi();
330 theEnergyLoss,theParticleType,theDetUnitId,
331 theTrackIDInsideTheSimHit,theThetaAtEntry,thePhiAtEntry,
343 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
349 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
355 LogDebug(
"TrackerSimDebug")<<
" Updating: new exitpoint " <<
pname <<
" " << theExitPoint
356 <<
" new energy loss " << theEnergyLoss;
365 G4Track * theTrack = aStep->GetTrack();
367 unsigned int theTrackID = theTrack->GetTrackID();
370 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
380 const float tolerance = 0.05 * mm;
382 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
393 LogDebug(
"TrackerSimDebug")<<
" Saving the last hit in a ROU " <<
myName;
402 eventno = (*i)()->GetEventID();
428 bool sendExc =
false;
430 edm::LogWarning(
"TrackerSimInfo")<<
" ************ Hit outside the detector ; Local z " << z
431 <<
"; skipping event = " << sendExc;
434 G4EventManager::GetEventManager()->AbortCurrentEvent();
435 G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetEventAborted();
440 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
442 edm::LogError(
"TrackerSimInfo") <<
" ERROR: no G4VUserTrackInformation available";
447 edm::LogError(
"TrackerSimInfo")<<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
465 std::vector<string>
temp;
T getParameter(std::string const &) const
TrackInformation * getOrCreateTrackInformation(const G4Track *)
std::vector< std::string > logicalNames(std::string &readoutName)
virtual bool newHit(G4Step *)
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
virtual uint32_t setDetUnitId(G4Step *)
FrameRotation * myRotation
Local3DPoint toOrcaRef(Local3DPoint, G4VPhysicalVolume *)
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
G4TrackToParticleID * myG4TrackToParticleID
Local3DPoint globalExitPoint
Geom::Phi< T > phi() const
void printMomentumOfTrack(float, std::string, int sign) const
void setExitPoint(const Local3DPoint &exit)
TrackingSlaveSD * slaveHighTof
void printHitData(float, float) const
type of data representation of DDCompactView
void printGlobalMomentum(float, float, float) const
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
virtual void EndOfEvent(G4HCofThisEvent *)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
Geom::Theta< T > theta() const
UpdatablePSimHit * mySimHit
std::vector< PSimHit > & hits()
Local3DPoint exitPoint() const
Exit point in the local Det frame.
virtual void updateHit(G4Step *)
void fillHits(edm::PSimHitContainer &, std::string use)
virtual bool closeHit(G4Step *)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float timeOfFlight() const
virtual void Initialize()
virtual ~TkAccumulatingSensitiveDetector()
unsigned int g4ToNumberingScheme(const G4VTouchable *)
void printGlobal(Local3DPoint, Local3DPoint) const
Local3DPoint globalEntryPoint
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
virtual Local3DPoint transformPoint(Local3DPoint &, G4VPhysicalVolume *) const =0
G4VPhysicalVolume * oldVolume
int particleID(const G4Track *)
void addEnergyLoss(float eloss)
unsigned int processId(const G4VProcess *)
virtual void createHit(G4Step *)
TrackerG4SimHitNumberingScheme * numberingScheme_
virtual void AssignSD(std::string &vname)
void startNewSimHit(std::string, std::string, int, int, int)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
void printLocal(Local3DPoint, Local3DPoint) const
void checkExitPoint(Local3DPoint)
unsigned int trackId() const
TkAccumulatingSensitiveDetector(std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
int getPropagationSign(Local3DPoint, Local3DPoint)
TrackingSlaveSD * slaveLowTof
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
unsigned int detUnitId() const
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
std::vector< std::string > getNames()