21 #include "G4SDManager.hh" 22 #include "G4VProcess.hh" 23 #include "G4EventManager.hh" 25 #include "G4VProcess.hh" 27 #include "CLHEP/Units/GlobalSystemOfUnits.h" 28 #include "CLHEP/Units/GlobalPhysicalConstants.h" 41 oldVolume(
nullptr), lastId(0), lastTrack(0), eventno(0) {
47 edm::LogInfo(
"PltSD") <<
"Criteria for Saving Tracker SimTracks: \n " 48 <<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: "<< energyCut<<
" MeV\n" 49 <<
" Constructing a PltSD";
65 LogDebug(
"PltSD") <<
" Entering a new Step " 66 << aStep->GetTotalEnergyDeposit() <<
" " 67 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
69 G4Track * gTrack = aStep->GetTrack();
70 if ((
unsigned int)(gTrack->GetTrackID()) !=
lastTrack) {
72 if (gTrack->GetKineticEnergy() >
energyCut){
82 if (aStep->GetTotalEnergyDeposit()>0.) {
83 if (
newHit(aStep) ==
true) {
96 unsigned int detId = 0;
98 LogDebug(
"PltSD")<<
" DetID = "<<detId;
101 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
103 if (touch) level = ((touch->GetHistoryDepth())+1);
108 G4String sensorName = touch->GetVolume(2)->GetName();
109 G4String telName = touch->GetVolume(3)->GetName();
110 G4String volumeName = touch->GetVolume(4)->GetName();
111 if ( sensorName !=
"PLTSensorPlane" )
112 std::cout <<
" PltSD::setDetUnitId -w- Sensor name not PLTSensorPlane " << std::endl;
113 if ( telName !=
"Telescope" )
114 std::cout <<
" PltSD::setDetUnitId -w- Telescope name not Telescope " << std::endl;
115 if ( volumeName !=
"PLT" )
116 std::cout <<
" PltSD::setDetUnitId -w- Volume name not PLT " << std::endl;
119 int columnNum = touch->GetReplicaNumber(0);
120 int rowNum = touch->GetReplicaNumber(1);
121 int sensorNum = touch->GetReplicaNumber(2);
122 int telNum = touch->GetReplicaNumber(3);
124 int temp = touch->GetReplicaNumber(5);
127 if (temp == 2) pltNum = 0;
135 else if (telNum == 1){
138 else if (telNum == 2){
141 else if (telNum == 3){
144 else if (telNum == 4){
147 else if (telNum == 5){
150 else if (telNum == 6){
153 else if (telNum == 7){
158 int halfCarriageNum = -1;
161 if(telNum == 0 || telNum == 1 || telNum == 2 || telNum == 3)
166 if(halfCarriageNum == 1){
170 else if (telNum == 5){
173 else if (telNum == 6){
176 else if (telNum == 7){
181 detId = 10000000*pltNum+1000000*halfCarriageNum+100000*telNum+10000*sensorNum+100*rowNum+columnNum;
190 LogDebug(
"PltSD")<<
" Saving the last hit in a ROU " << GetName();
218 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
224 LogDebug(
"PltSD") <<
" Updating: new exitpoint " <<
pname <<
" " 225 << theExitPoint <<
" new energy loss " << theEnergyLoss
234 G4Track * theTrack = aStep->GetTrack();
236 unsigned int theTrackID = theTrack->GetTrackID();
239 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return " 248 if (
mySimHit ==
nullptr)
return false;
265 G4Track * theTrack = aStep->GetTrack();
266 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
271 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
272 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
273 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
279 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
281 unsigned int theTrackID = theTrack->GetTrackID();
283 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
285 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
287 float theThetaAtEntry = lnmd.
theta();
288 float thePhiAtEntry = lnmd.
phi();
291 theEnergyLoss,theParticleType,theDetUnitId,
292 theTrackID,theThetaAtEntry,thePhiAtEntry,
309 eventno = (*i)()->GetEventID();
315 const G4Track* gTrack = (*bot)();
316 pname = gTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
324 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
325 if (temp ==
nullptr){
326 edm::LogError(
"PltSD") <<
" ERROR: no G4VUserTrackInformation available";
330 if (info ==
nullptr){
331 edm::LogError(
"PltSD") <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
T getParameter(std::string const &) const
UpdatablePSimHit * mySimHit
virtual bool newHit(G4Step *)
PltSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
G4TrackToParticleID * myG4TrackToParticleID
Geom::Phi< T > phi() const
void setExitPoint(const Local3DPoint &exit)
virtual void updateHit(G4Step *)
type of data representation of DDCompactView
Geom::Theta< T > theta() const
std::vector< PSimHit > & hits()
unsigned int processId(const G4VProcess *p) const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
virtual void Initialize()
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
static int particleID(const G4Track *)
Local3DPoint globalExitPoint
void addEnergyLoss(float eloss)
virtual void createHit(G4Step *)
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
float energyLoss() const
The energy deposit in the PSimHit, in ???.
G4VPhysicalVolume * oldVolume
virtual bool closeHit(G4Step *)
unsigned int trackId() const
void clearHits() override
void EndOfEvent(G4HCofThisEvent *) override
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
TrackInformation * getOrCreateTrackInformation(const G4Track *)
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
bool ProcessHits(G4Step *, G4TouchableHistory *) override
Local3DPoint entryPoint() const
Entry point in the local Det frame.
void fillHits(edm::PSimHitContainer &, const std::string &) override
uint32_t setDetUnitId(const G4Step *) override
unsigned int detUnitId() const
Local3DPoint globalEntryPoint
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const