21 #include "G4SDManager.hh" 22 #include "G4VProcess.hh" 23 #include "G4EventManager.hh" 25 #include "G4VProcess.hh" 31 #include "CLHEP/Units/GlobalSystemOfUnits.h" 38 oldVolume(
nullptr), lastId(0), lastTrack(0), eventno(0) {
44 edm::LogInfo(
"Bcm1fSD") <<
" Criteria for Saving Tracker SimTracks: \n " 45 <<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: " 46 << energyCut<<
" MeV\n" <<
" Constructing a Bcm1fSD";
62 LogDebug(
"Bcm1fSD") <<
" Entering a new Step " 63 << aStep->GetTotalEnergyDeposit() <<
" " 64 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
66 G4Track * gTrack = aStep->GetTrack();
67 if ((
unsigned int)(gTrack->GetTrackID()) !=
lastTrack) {
69 if (gTrack->GetKineticEnergy() >
energyCut){
79 if (aStep->GetTotalEnergyDeposit()>0.) {
80 if (
newHit(aStep) ==
true) {
93 unsigned int detId = 0;
95 LogDebug(
"Bcm1fSD")<<
" DetID = "<<detId;
98 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
100 if (touch) level = ((touch->GetHistoryDepth())+1);
105 G4String sensorName = touch->GetVolume(0)->GetName();
106 G4String diamondName = touch->GetVolume(1)->GetName();
107 G4String detectorName = touch->GetVolume(2)->GetName();
108 G4String volumeName = touch->GetVolume(3)->GetName();
110 if ( sensorName !=
"BCM1FSensor" )
111 std::cout <<
" Bcm1fSD::setDetUnitId -w- Sensor name not BCM1FSensor " << std::endl;
112 if ( detectorName !=
"BCM1F" )
113 std::cout <<
" Bcm1fSD::setDetUnitId -w- Detector name not BCM1F " << std::endl;
115 int sensorNo = touch->GetReplicaNumber(0);
116 int diamondNo = touch->GetReplicaNumber(1);
118 int volumeNo = touch->GetReplicaNumber(3);
127 detId = 1000*volumeNo + 10*diamondNo + sensorNo;
145 LogDebug(
"Bcm1fSD")<<
" Saving the last hit in a ROU " << GetName();
173 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
179 LogDebug(
"Bcm1fSD") <<
" Updating: new exitpoint " <<
pname <<
" " 180 << theExitPoint <<
" new energy loss " << theEnergyLoss
189 G4Track * theTrack = aStep->GetTrack();
191 unsigned int theTrackID = theTrack->GetTrackID();
194 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return " 203 if (
mySimHit ==
nullptr)
return false;
220 G4Track * theTrack = aStep->GetTrack();
221 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
226 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
227 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
228 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
234 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
236 unsigned int theTrackID = theTrack->GetTrackID();
238 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
240 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
242 float theThetaAtEntry = lnmd.
theta();
243 float thePhiAtEntry = lnmd.
phi();
246 theEnergyLoss,theParticleType,theDetUnitId,
247 theTrackID,theThetaAtEntry,thePhiAtEntry,
264 eventno = (*i)()->GetEventID();
270 const G4Track* gTrack = (*bot)();
271 pname = gTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
279 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
280 if (temp ==
nullptr){
281 edm::LogError(
"Bcm1fSD") <<
" ERROR: no G4VUserTrackInformation available";
285 if (info ==
nullptr){
286 edm::LogError(
"Bcm1fSD") <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
UpdatablePSimHit * mySimHit
Local3DPoint globalExitPoint
T getParameter(std::string const &) const
bool ProcessHits(G4Step *, G4TouchableHistory *) override
G4TrackToParticleID * myG4TrackToParticleID
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
G4VPhysicalVolume * oldVolume
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
void clearHits() override
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
TrackInformation * getOrCreateTrackInformation(const G4Track *)
Geom::Phi< T > phi() const
void setExitPoint(const Local3DPoint &exit)
virtual bool closeHit(G4Step *)
Local3DPoint globalEntryPoint
type of data representation of DDCompactView
virtual bool newHit(G4Step *)
uint32_t setDetUnitId(const G4Step *) override
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.
void EndOfEvent(G4HCofThisEvent *) override
virtual void Initialize()
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
static int particleID(const G4Track *)
void addEnergyLoss(float eloss)
Bcm1fSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void fillHits(edm::PSimHitContainer &, const std::string &) override
float energyLoss() const
The energy deposit in the PSimHit, in ???.
virtual void updateHit(G4Step *)
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
unsigned int trackId() const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
virtual void createHit(G4Step *)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const