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();
274 if(0.0 == theTrack->GetDefinition()->GetPDGCharge()) {
275 theEntryPoint = theExitPoint;
284 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
285 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
286 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
297 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
299 if (theDetUnitId == 0)
301 edm::LogError(
"TrackerSimInfo") <<
" Error: theDetUnitId is not valid.";
304 unsigned int theTrackID = theTrack->GetTrackID();
309 unsigned int theTrackIDInsideTheSimHit=theTrackID;
312 G4VUserTrackInformation *
info = theTrack->GetUserInformation();
313 if (info == 0)
edm::LogError(
"TrackerSimInfo")<<
" Error: no UserInformation available ";
317 if (temp ==0)
edm::LogError(
"TrackerSimInfo")<<
" Error:G4VUserTrackInformation is not a TrackInformation.";
321 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): setting the TrackID from "
322 << theTrackIDInsideTheSimHit;
323 theTrackIDInsideTheSimHit = theTrack->GetParentID();
324 LogDebug(
"TrackerSimDebug")<<
" to the mother one " << theTrackIDInsideTheSimHit <<
" " << theEnergyLoss;
328 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID "
329 << theTrackIDInsideTheSimHit;
333 px = aStep->GetPreStepPoint()->GetMomentum().x()/GeV;
334 py = aStep->GetPreStepPoint()->GetMomentum().y()/GeV;
335 pz = aStep->GetPreStepPoint()->GetMomentum().z()/GeV;
337 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
339 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
340 ->GetTopTransform().TransformAxis(gmd);
342 float theThetaAtEntry = lnmd.
theta();
343 float thePhiAtEntry = lnmd.
phi();
346 theEnergyLoss,theParticleType,theDetUnitId,
347 theTrackIDInsideTheSimHit,theThetaAtEntry,thePhiAtEntry,
359 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
365 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
371 LogDebug(
"TrackerSimDebug")<<
" Updating: new exitpoint " <<
pname <<
" " << theExitPoint
372 <<
" new energy loss " << theEnergyLoss;
381 G4Track * theTrack = aStep->GetTrack();
384 if(0.0 == theTrack->GetDefinition()->GetPDGCharge())
return true;
387 unsigned int theTrackID = theTrack->GetTrackID();
390 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
400 const float tolerance = 0.05 * mm;
402 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
413 LogDebug(
"TrackerSimDebug")<<
" Saving the last hit in a ROU " <<
myName;
422 eventno = (*i)()->GetEventID();
448 bool sendExc =
false;
450 edm::LogWarning(
"TrackerSimInfo")<<
" ************ Hit outside the detector ; Local z " << z
451 <<
"; skipping event = " << sendExc;
454 G4EventManager::GetEventManager()->AbortCurrentEvent();
455 G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetEventAborted();
460 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
462 edm::LogError(
"TrackerSimInfo") <<
" ERROR: no G4VUserTrackInformation available";
467 edm::LogError(
"TrackerSimInfo")<<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
485 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 *)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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 *)
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()