16 #include "G4SDManager.hh" 17 #include "G4VProcess.hh" 18 #include "G4EventManager.hh" 20 #include "G4ParticleTable.hh" 35 currentPV(
nullptr), unitID(0), previousUnitID(0), preStepPoint(
nullptr),
36 postStepPoint(
nullptr), eventno(0){
47 SetVerboseLevel(verbn);
49 <<
"*******************************************************\n" 51 <<
"* Constructing a BHMSD with name " << name <<
"\n" 53 <<
"*******************************************************";
61 std::vector<std::string> lvNames = clg.
logicalNames(name);
65 for (std::vector<std::string>::iterator it=lvNames.begin();
66 it !=lvNames.end(); it++) {
68 edm::LogInfo(
"BHMSim") <<
"BHMSD : Assigns SD to LV " << (*it);
72 edm::LogInfo(
"BHMSim") <<
"name = " <<name <<
" and new BHMNumberingScheme";
76 edm::LogInfo(
"BHMSim") <<
"BHMSD: Instantiation completed";
87 return aStep->GetTotalEnergyDeposit();
92 LogDebug(
"BHMSim") <<
"BHMSD : Initialize called for " <<
name << std::endl;
107 if (aStep ==
nullptr) {
112 LogDebug(
"BHMSim") <<
"BHMSD : number of hits = " <<
theHC->entries() << std::endl;
135 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
136 LogDebug(
"BHMSim") <<
" BHMSD :particleType = " <<
theTrack->GetDefinition()->GetParticleName() <<std::endl;
137 if (particleCode ==
emPDG ||
138 particleCode ==
epPDG ||
144 edeposit = aStep->GetTotalEnergyDeposit();
154 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::nanosecond;
157 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/CLHEP::deg;
158 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/CLHEP::deg;
178 <<
" maybe detector name changed";
193 G4bool
found =
false;
195 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
196 BscG4Hit* aPreviousHit = (*theHC)[j];
225 if (hit ==
nullptr ) {
230 theHC->insert( hit );
237 LogDebug(
"BHMSim") <<
"BHMSD CreateNewHit for" 240 <<
" Unit " <<
unitID <<std::endl;
243 <<
" For Track " <<
theTrack->GetTrackID()
244 <<
" which is a " <<
theTrack->GetDefinition()->GetParticleName();
252 LogDebug(
"BHMSim") <<
" and created by " ;
253 if (
theTrack->GetCreatorProcess()!=
nullptr)
299 LogDebug(
"BHMSim") <<
"updateHit: add eloss " <<
Eloss <<std::endl;
315 const G4VTouchable* touch=
preStepPoint->GetTouchable();
316 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
324 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
332 for (
int j=0; j<
theHC->entries(); j++) {
334 LogDebug(
"BHMSim") <<
"hit number" << j <<
"unit ID = "<<aHit->
getUnitID()<<
"\n";
369 LogDebug(
"BHMSim") <<
"BHMSD: Collection " <<
theHC->GetName() <<
"\n";
370 theHC->PrintAllHits();
379 LogDebug(
"BHMSim") <<
" Dispatched BeginOfEvent for " << GetName()
382 eventno = (*i)()->GetEventID();
387 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
389 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
390 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
391 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
403 std::vector<std::string>
temp;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4ThreeVector hitPointExit
void setEntry(const G4ThreeVector &xyz)
void ResetForNewPrimary()
float getPhiAtEntry() const
int getParticleType() const
void Initialize(G4HCofThisEvent *HCE) override
G4ThreeVector theEntryPoint
void setEnergyLoss(float e)
BHMNumberingScheme * numberingScheme
G4StepPoint * preStepPoint
void setUnitID(unsigned int i)
BHMSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
G4ThreeVector hitPointLocal
type of data representation of DDCompactView
unsigned int getUnitID() const
virtual void AssignSD(const std::string &vname)
virtual double getEnergyDeposit(G4Step *step)
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
void EndOfEvent(G4HCofThisEvent *eventHC) override
int getTimeSliceID() const
void setThetaAtEntry(float t)
void setEntryLocalP(const G4ThreeVector &xyz1)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
virtual void Initialize()
void setPhiAtEntry(float f)
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
G4ThreeVector theExitPoint
virtual unsigned int getUnitID(const G4Step *aStep) const
float getThetaAtEntry() const
void addEnergyDeposit(double em, double hd)
void setTimeSlice(double d)
G4ThreeVector entrancePoint
void setParticleType(short i)
void clearHits() override
G4StepPoint * postStepPoint
BscG4HitCollection * theHC
void fillHits(edm::PSimHitContainer &, std::string use) override
G4ThreeVector SetToLocal(const G4ThreeVector &global)
G4ThreeVector getEntry() const
void GetStepInfo(G4Step *aStep)
std::vector< std::string > getNames() override
virtual bool processHits(const PSimHit &)
G4ThreeVector hitPointLocalExit
std::vector< PSimHit > PSimHitContainer
G4VPhysicalVolume * currentPV
void setExitLocalP(const G4ThreeVector &xyz1)
uint32_t setDetUnitId(G4Step *) override
G4THitsCollection< BscG4Hit > BscG4HitCollection
void setIncidentEnergy(double e)
void StoreHit(BscG4Hit *)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
float getEnergyLoss() const