21 #include "G4SDManager.hh"
22 #include "G4VProcess.hh"
23 #include "G4EventManager.hh"
25 #include "G4VProcess.hh"
27 #include "G4SystemOfUnits.hh"
40 oldVolume(0), lastId(0), lastTrack(0), eventno(0) {
46 edm::LogInfo(
"PLTSensitiveDetector") <<
"Criteria for Saving Tracker SimTracks: \n "
47 <<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: "<< energyCut<<
" MeV\n"
48 <<
" Constructing a PLTSensitiveDetector with ";
53 std::vector<std::string> lvNames = clg.
logicalNames(name);
55 for (std::vector<std::string>::iterator it = lvNames.begin();
56 it != lvNames.end(); it++) {
57 edm::LogInfo(
"PLTSensitiveDetector")<< name <<
" attaching LV " << *it;
73 LogDebug(
"PLTSensitiveDetector") <<
" Entering a new Step "
74 << aStep->GetTotalEnergyDeposit() <<
" "
75 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
77 G4Track * gTrack = aStep->GetTrack();
78 if ((
unsigned int)(gTrack->GetTrackID()) !=
lastTrack) {
80 if (gTrack->GetKineticEnergy() >
energyCut){
90 if (aStep->GetTotalEnergyDeposit()>0.) {
91 if (
newHit(aStep) ==
true) {
104 unsigned int detId = 0;
106 LogDebug(
"PLTSensitiveDetector")<<
" DetID = "<<detId;
113 LogDebug(
"PLTSensitiveDetector")<<
" Saving the last hit in a ROU " <<
myName;
141 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
147 LogDebug(
"PLTSensitiveDetector") <<
" Updating: new exitpoint " <<
pname <<
" "
148 << theExitPoint <<
" new energy loss " << theEnergyLoss
157 G4Track * theTrack = aStep->GetTrack();
159 unsigned int theTrackID = theTrack->GetTrackID();
162 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
172 const float tolerance = 0.05 * mm;
188 G4Track * theTrack = aStep->GetTrack();
189 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
194 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
195 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
196 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
202 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
204 unsigned int theTrackID = theTrack->GetTrackID();
206 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
208 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
210 float theThetaAtEntry = lnmd.
theta();
211 float thePhiAtEntry = lnmd.
phi();
214 theEnergyLoss,theParticleType,theDetUnitId,
215 theTrackID,theThetaAtEntry,thePhiAtEntry,
218 LogDebug(
"PLTSensitiveDetector") <<
" Created PSimHit: " <<
pname <<
" "
232 eventno = (*i)()->GetEventID();
238 const G4Track* gTrack = (*bot)();
239 pname = gTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
247 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
249 edm::LogError(
"PLTSensitiveDetector") <<
" ERROR: no G4VUserTrackInformation available";
254 edm::LogError(
"PLTSensitiveDetector") <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
T getParameter(std::string const &) const
UpdatablePSimHit * mySimHit
virtual void createHit(G4Step *)
std::vector< std::string > logicalNames(std::string &readoutName)
G4TrackToParticleID * myG4TrackToParticleID
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual ~PLTSensitiveDetector()
Geom::Phi< T > phi() const
TrackInformation * getOrCreateTrackInformation(const G4Track *)
void setExitPoint(const Local3DPoint &exit)
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
G4VPhysicalVolume * oldVolume
type of data representation of DDCompactView
virtual bool newHit(G4Step *)
Geom::Theta< T > theta() const
virtual bool closeHit(G4Step *)
std::vector< PSimHit > & hits()
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
virtual void Initialize()
virtual void updateHit(G4Step *)
void fillHits(edm::PSimHitContainer &, std::string use)
static int particleID(const G4Track *)
virtual uint32_t setDetUnitId(G4Step *)
void addEnergyLoss(float eloss)
unsigned int processId(const G4VProcess *)
Local3DPoint globalEntryPoint
virtual void AssignSD(std::string &vname)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
virtual void EndOfEvent(G4HCofThisEvent *)
unsigned int trackId() const
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
virtual bool processHits(const PSimHit &)
PLTSensitiveDetector(std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
std::vector< PSimHit > PSimHitContainer
Local3DPoint globalExitPoint
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
unsigned int detUnitId() const