29 #include "G4SDManager.hh"
30 #include "G4VProcess.hh"
31 #include "G4EventManager.hh"
34 #include "G4SystemOfUnits.hh"
47 #include "G4VProcess.hh"
69 SensitiveTkDetector(name, cpv, clg, p), myName(name), myRotation(0), mySimHit(0),theManager(manager),
70 oldVolume(0), lastId(0), lastTrack(0), eventno(0) ,rTracker(1200.*mm),zTracker(3000.*mm),
82 edm::LogInfo(
"TrackerSimInfo") <<
"Criteria for Saving Tracker SimTracks: ";
83 edm::LogInfo(
"TrackerSimInfo")<<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: "<< energyCut<<
" MeV ";
84 edm::LogInfo(
"TrackerSimInfo")<<
" Constructing a TkAccumulatingSensitiveDetector with ";
86 #ifndef FAKEFRAMEROTATION
88 if (name.find(
"TrackerHits") != string::npos)
90 edm::LogInfo(
"TrackerSimInfo")<<
" TkAccumulatingSensitiveDetector: using TrackerFrameRotation for "<<
myName;
96 edm::LogInfo(
"TrackerSimInfo")<<
" TkAccumulatingSensitiveDetector: using StandardFrameRotation for "<<
myName;
101 edm::LogWarning(
"TrackerSimInfo")<<
" WARNING - Using FakeFrameRotation in TkAccumulatingSensitiveDetector;";
110 for (vector<string>::const_iterator it = lvNames.begin(); it != lvNames.end(); it++)
112 edm::LogInfo(
"TrackerSimInfo")<< name <<
" attaching LV " << *it;
132 LogDebug(
"TrackerSimDebug")<<
" Entering a new Step " << aStep->GetTotalEnergyDeposit() <<
" "
133 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
138 if (
newHit(aStep) ==
true)
156 LogDebug(
"TrackerSimDebug")<<
" DetID = "<<detId;
166 if (tof < threshold)
return 1;
178 const G4Track* gTrack = (*bot)();
180 edm::LogInfo(
"TrackerSimInfo") <<
" -> process creator pointer "<<gTrack->GetCreatorProcess();
181 if (gTrack->GetCreatorProcess())
182 edm::LogInfo(
"TrackerSimInfo")<<
" -> PROCESS CREATOR : "<<gTrack->GetCreatorProcess()->GetProcessName();
189 const G4ThreeVector pos = gTrack->GetPosition();
201 LogDebug(
"TrackerSimDebug")<<
" INSIDE TRACKER";
203 if (gTrack->GetKineticEnergy() >
energyCut){
266 G4Track * theTrack = aStep->GetTrack();
268 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
277 if(0.0 == theTrack->GetDefinition()->GetPDGCharge()) {
278 theEntryPoint = theExitPoint;
287 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
288 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
289 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
300 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
302 if (theDetUnitId == 0)
304 edm::LogError(
"TrackerSimInfo") <<
" Error: theDetUnitId is not valid.";
307 unsigned int theTrackID = theTrack->GetTrackID();
312 unsigned int theTrackIDInsideTheSimHit=theTrackID;
315 G4VUserTrackInformation *
info = theTrack->GetUserInformation();
316 if (info == 0)
edm::LogError(
"TrackerSimInfo")<<
" Error: no UserInformation available ";
320 if (temp ==0)
edm::LogError(
"TrackerSimInfo")<<
" Error:G4VUserTrackInformation is not a TrackInformation.";
324 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): setting the TrackID from "
325 << theTrackIDInsideTheSimHit;
326 theTrackIDInsideTheSimHit = theTrack->GetParentID();
327 LogDebug(
"TrackerSimDebug")<<
" to the mother one " << theTrackIDInsideTheSimHit <<
" " << theEnergyLoss;
330 LogDebug(
"TrackerSimDebug")<<
" TkAccumulatingSensitiveDetector:createHit(): leaving the current TrackID "
331 << theTrackIDInsideTheSimHit;
336 px = aStep->GetPreStepPoint()->GetMomentum().x()/
GeV;
337 py = aStep->GetPreStepPoint()->GetMomentum().y()/
GeV;
338 pz = aStep->GetPreStepPoint()->GetMomentum().z()/
GeV;
340 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
342 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
343 ->GetTopTransform().TransformAxis(gmd);
345 float theThetaAtEntry = lnmd.
theta();
346 float thePhiAtEntry = lnmd.
phi();
349 theEnergyLoss,theParticleType,theDetUnitId,
350 theTrackIDInsideTheSimHit,theThetaAtEntry,thePhiAtEntry,
362 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
368 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
374 LogDebug(
"TrackerSimDebug")<<
" Updating: new exitpoint " <<
pname <<
" " << theExitPoint
375 <<
" new energy loss " << theEnergyLoss;
384 G4Track * theTrack = aStep->GetTrack();
387 if(0.0 == theTrack->GetDefinition()->GetPDGCharge())
return true;
390 unsigned int theTrackID = theTrack->GetTrackID();
393 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
403 const float tolerance = 0.05 * mm;
405 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
416 LogDebug(
"TrackerSimDebug")<<
" Saving the last hit in a ROU " <<
myName;
425 eventno = (*i)()->GetEventID();
451 bool sendExc =
false;
453 edm::LogWarning(
"TrackerSimInfo")<<
" ************ Hit outside the detector ; Local z " << z
454 <<
"; skipping event = " << sendExc;
457 G4EventManager::GetEventManager()->AbortCurrentEvent();
458 G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetEventAborted();
463 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
465 edm::LogError(
"TrackerSimInfo") <<
" ERROR: no G4VUserTrackInformation available";
470 edm::LogError(
"TrackerSimInfo")<<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
488 std::vector<string>
temp;
T getParameter(std::string const &) const
TrackInformation * getOrCreateTrackInformation(const G4Track *)
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())
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
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
void printGlobalMomentum(float, float, float) const
virtual void AssignSD(const std::string &vname)
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.
unsigned int processId(const G4VProcess *p)
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 *)
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
float timeOfFlight() const
virtual void Initialize()
virtual ~TkAccumulatingSensitiveDetector()
unsigned int g4ToNumberingScheme(const G4VTouchable *)
void printGlobal(Local3DPoint, Local3DPoint) const
Local3DPoint globalEntryPoint
Abs< T >::type abs(const T &t)
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
virtual Local3DPoint transformPoint(Local3DPoint &, G4VPhysicalVolume *) const =0
G4VPhysicalVolume * oldVolume
static int particleID(const G4Track *)
void addEnergyLoss(float eloss)
virtual void createHit(G4Step *)
TrackerG4SimHitNumberingScheme * numberingScheme_
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
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)
TkAccumulatingSensitiveDetector(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
unsigned int detUnitId() const
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
std::vector< std::string > getNames()