21 #include "G4SDManager.hh"
22 #include "G4VProcess.hh"
23 #include "G4EventManager.hh"
25 #include "G4VProcess.hh"
31 #include "CLHEP/Units/GlobalSystemOfUnits.h"
39 oldVolume(0), lastId(0), lastTrack(0), eventno(0) {
45 edm::LogInfo(
"Bcm1fSD") <<
"Criteria for Saving Tracker SimTracks: \n "
46 <<
" History: "<<energyHistoryCut<<
" MeV ; Persistency: "<< energyCut<<
" MeV\n"
47 <<
" Constructing a Bcm1fSD with ";
52 std::vector<std::string> lvNames = clg.
logicalNames(name);
54 for (std::vector<std::string>::iterator it = lvNames.begin(); it != lvNames.end(); it++)
56 edm::LogInfo(
"Bcm1fSD")<< name <<
" attaching LV " << *it;
72 LogDebug(
"Bcm1fSD") <<
" Entering a new Step "
73 << aStep->GetTotalEnergyDeposit() <<
" "
74 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName();
76 G4Track * gTrack = aStep->GetTrack();
77 if ((
unsigned int)(gTrack->GetTrackID()) !=
lastTrack) {
79 if (gTrack->GetKineticEnergy() >
energyCut){
89 if (aStep->GetTotalEnergyDeposit()>0.) {
90 if (
newHit(aStep) ==
true) {
103 unsigned int detId = 0;
105 LogDebug(
"Bcm1fSD")<<
" DetID = "<<detId;
108 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
110 if (touch) level = ((touch->GetHistoryDepth())+1);
115 G4String sensorName = touch->GetVolume(0)->GetName();
116 G4String diamondName = touch->GetVolume(1)->GetName();
117 G4String detectorName = touch->GetVolume(2)->GetName();
118 G4String volumeName = touch->GetVolume(3)->GetName();
120 if ( sensorName !=
"BCM1FSensor" )
121 std::cout <<
" Bcm1fSD::setDetUnitId -w- Sensor name not BCM1FSensor " << std::endl;
122 if ( detectorName !=
"BCM1F" )
123 std::cout <<
" Bcm1fSD::setDetUnitId -w- Detector name not BCM1F " << std::endl;
125 int sensorNo = touch->GetReplicaNumber(0);
126 int diamondNo = touch->GetReplicaNumber(1);
128 int volumeNo = touch->GetReplicaNumber(3);
137 detId = 1000*volumeNo + 10*diamondNo + sensorNo;
183 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
189 LogDebug(
"Bcm1fSD") <<
" Updating: new exitpoint " <<
pname <<
" "
190 << theExitPoint <<
" new energy loss " << theEnergyLoss
199 G4Track * theTrack = aStep->GetTrack();
201 unsigned int theTrackID = theTrack->GetTrackID();
204 <<
"), new = (" << theDetUnitId <<
"," << theTrackID <<
") return "
214 const float tolerance = 0.05 * mm;
230 G4Track * theTrack = aStep->GetTrack();
231 G4VPhysicalVolume *
v = aStep->GetPreStepPoint()->GetPhysicalVolume();
236 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
237 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
238 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
244 pname = theTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
246 unsigned int theTrackID = theTrack->GetTrackID();
248 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
250 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()->GetTopTransform().TransformAxis(gmd);
252 float theThetaAtEntry = lnmd.
theta();
253 float thePhiAtEntry = lnmd.
phi();
256 theEnergyLoss,theParticleType,theDetUnitId,
257 theTrackID,theThetaAtEntry,thePhiAtEntry,
274 eventno = (*i)()->GetEventID();
280 const G4Track* gTrack = (*bot)();
281 pname = gTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
289 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
291 edm::LogError(
"Bcm1fSD") <<
" ERROR: no G4VUserTrackInformation available";
296 edm::LogError(
"Bcm1fSD") <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation";
UpdatablePSimHit * mySimHit
Local3DPoint globalExitPoint
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
T getParameter(std::string const &) const
G4TrackToParticleID * myG4TrackToParticleID
G4VPhysicalVolume * oldVolume
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
TrackInformation * getOrCreateTrackInformation(const G4Track *)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
Geom::Phi< T > phi() const
void setExitPoint(const Local3DPoint &exit)
virtual bool closeHit(G4Step *)
Local3DPoint globalEntryPoint
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
virtual void AssignSD(const std::string &vname)
virtual bool newHit(G4Step *)
unsigned int processId(const G4VProcess *p)
Geom::Theta< T > theta() const
void fillHits(edm::PSimHitContainer &, std::string use)
std::vector< PSimHit > & hits()
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
virtual void Initialize()
virtual uint32_t setDetUnitId(G4Step *)
virtual void EndOfEvent(G4HCofThisEvent *)
static int particleID(const G4Track *)
void addEnergyLoss(float eloss)
Bcm1fSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
virtual void updateHit(G4Step *)
unsigned int trackId() const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
virtual void createHit(G4Step *)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
unsigned int detUnitId() const