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(0), 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 with ";
54 const std::vector<std::string>& lvNames = clg.
logicalNames(name);
56 for (std::vector<std::string>::const_iterator it = lvNames.begin();
57 it != lvNames.end(); it++) {
74 LogDebug(
"PltSD") <<
" Entering a new Step "
75 << aStep->GetTotalEnergyDeposit() <<
" "
76 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
78 G4Track * gTrack = aStep->GetTrack();
79 if ((
unsigned int)(gTrack->GetTrackID()) !=
lastTrack) {
81 if (gTrack->GetKineticEnergy() >
energyCut){
91 if (aStep->GetTotalEnergyDeposit()>0.) {
92 if (
newHit(aStep) ==
true) {
105 unsigned int detId = 0;
107 LogDebug(
"PltSD")<<
" DetID = "<<detId;
110 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
112 if (touch) level = ((touch->GetHistoryDepth())+1);
117 G4String sensorName = touch->GetVolume(2)->GetName();
118 G4String telName = touch->GetVolume(3)->GetName();
119 G4String volumeName = touch->GetVolume(4)->GetName();
120 if ( sensorName !=
"PLTSensorPlane" )
121 std::cout <<
" PltSD::setDetUnitId -w- Sensor name not PLTSensorPlane " << std::endl;
122 if ( telName !=
"Telescope" )
123 std::cout <<
" PltSD::setDetUnitId -w- Telescope name not Telescope " << std::endl;
124 if ( volumeName !=
"PLT" )
125 std::cout <<
" PltSD::setDetUnitId -w- Volume name not PLT " << std::endl;
128 int columnNum = touch->GetReplicaNumber(0);
129 int rowNum = touch->GetReplicaNumber(1);
130 int sensorNum = touch->GetReplicaNumber(2);
131 int telNum = touch->GetReplicaNumber(3);
133 int temp = touch->GetReplicaNumber(5);
136 if (temp == 2) pltNum = 0;
144 else if (telNum == 1){
147 else if (telNum == 2){
150 else if (telNum == 3){
153 else if (telNum == 4){
156 else if (telNum == 5){
159 else if (telNum == 6){
162 else if (telNum == 7){
167 int halfCarriageNum = -1;
170 if(telNum == 0 || telNum == 1 || telNum == 2 || telNum == 3)
175 if(halfCarriageNum == 1){
179 else if (telNum == 5){
182 else if (telNum == 6){
185 else if (telNum == 7){
190 detId = 10000000*pltNum+1000000*halfCarriageNum+100000*telNum+10000*sensorNum+100*rowNum+columnNum;
227 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
233 LogDebug(
"PltSD") <<
" Updating: new exitpoint " <<
pname <<
" "
234 << theExitPoint <<
" new energy loss " << theEnergyLoss
243 G4Track * theTrack = aStep->GetTrack();
245 unsigned int theTrackID = theTrack->GetTrackID();
248 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
258 const float tolerance = 0.05 * mm;
274 G4Track * theTrack = aStep->GetTrack();
275 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
280 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
281 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
282 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
288 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
290 unsigned int theTrackID = theTrack->GetTrackID();
292 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
294 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
296 float theThetaAtEntry = lnmd.
theta();
297 float thePhiAtEntry = lnmd.
phi();
300 theEnergyLoss,theParticleType,theDetUnitId,
301 theTrackID,theThetaAtEntry,thePhiAtEntry,
318 eventno = (*i)()->GetEventID();
324 const G4Track* gTrack = (*bot)();
325 pname = gTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
333 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
335 edm::LogError(
"PltSD") <<
" ERROR: no G4VUserTrackInformation available";
340 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 *)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
G4TrackToParticleID * myG4TrackToParticleID
Geom::Phi< T > phi() const
void setExitPoint(const Local3DPoint &exit)
PltSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
virtual void updateHit(G4Step *)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
virtual void AssignSD(const std::string &vname)
unsigned int processId(const G4VProcess *p)
Geom::Theta< T > theta() const
std::vector< PSimHit > & hits()
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
virtual void Initialize()
static int particleID(const G4Track *)
Local3DPoint globalExitPoint
virtual uint32_t setDetUnitId(G4Step *)
void addEnergyLoss(float eloss)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
virtual void EndOfEvent(G4HCofThisEvent *)
virtual void createHit(G4Step *)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
G4VPhysicalVolume * oldVolume
virtual bool closeHit(G4Step *)
unsigned int trackId() const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
void fillHits(edm::PSimHitContainer &, std::string use)
TrackInformation * getOrCreateTrackInformation(const G4Track *)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
unsigned int detUnitId() const
Local3DPoint globalEntryPoint