31 #include "G4SDManager.hh" 32 #include "G4VProcess.hh" 33 #include "G4EventManager.hh" 35 #include "G4ParticleTable.hh" 37 #include "G4PhysicalConstants.hh" 38 #include "G4SystemOfUnits.hh" 53 currentPV(
nullptr), unitID(0), previousUnitID(0), preStepPoint(
nullptr),
54 postStepPoint(
nullptr), eventno(0){
65 SetVerboseLevel(verbn);
67 <<
"*******************************************************\n" 69 <<
"* Constructing a BscSD with name " << name <<
"\n" 71 <<
"*******************************************************";
79 const std::vector<std::string>& lvNames = clg.
logicalNames(name);
83 for (std::vector<std::string>::const_iterator it=lvNames.begin();
84 it !=lvNames.end(); it++) {
86 edm::LogInfo(
"BscSim") <<
"BscSD : Assigns SD to LV " << (*it);
89 if (name ==
"BSCHits") {
91 edm::LogInfo(
"BscSim") <<
"name = BSCHits and new BscNumberingSchem";
95 edm::LogWarning(
"BscSim") <<
"BscSD: ReadoutName "<<name<<
" not supported";
98 edm::LogInfo(
"BscSim") <<
"BscSD: Instantiation completed";
114 return aStep->GetTotalEnergyDeposit();
119 LogDebug(
"BscSim") <<
"BscSD : Initialize called for " <<
name << std::endl;
136 if (aStep ==
nullptr) {
144 LogDebug(
"BscSim") <<
"BscSD : number of hits = " <<
theHC->entries() << std::endl;
168 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
169 LogDebug(
"BscSim") <<
" BscSD :particleType = " <<
theTrack->GetDefinition()->GetParticleName() <<std::endl;
170 if (particleCode ==
emPDG ||
171 particleCode ==
epPDG ||
177 edeposit = aStep->GetTotalEnergyDeposit();
186 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
187 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
188 Eloss = aStep->GetTotalEnergyDeposit()/
GeV;
190 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
191 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
212 <<
" maybe detector name changed";
229 G4bool
found =
false;
233 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
234 BscG4Hit* aPreviousHit = (*theHC)[j];
266 if (hit ==
nullptr ) {
271 theHC->insert( hit );
278 LogDebug(
"BscSim") <<
"BscSD CreateNewHit for" 281 <<
" Unit " <<
unitID <<std::endl;
284 <<
" For Track " <<
theTrack->GetTrackID()
285 <<
" which is a " <<
theTrack->GetDefinition()->GetParticleName();
293 LogDebug(
"BscSim") <<
" and created by " ;
294 if (
theTrack->GetCreatorProcess()!=
nullptr)
340 LogDebug(
"BscSim") <<
"updateHit: add eloss " <<
Eloss <<std::endl;
357 const G4VTouchable* touch=
preStepPoint->GetTouchable();
358 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
366 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
374 for (
int j=0; j<
theHC->entries(); j++) {
377 LogDebug(
"BscSim") <<
"hit number" << j <<
"unit ID = "<<aHit->
getUnitID()<<
"\n";
412 LogDebug(
"BscSim") <<
"BscSD: Collection " <<
theHC->GetName() <<
"\n";
413 theHC->PrintAllHits();
422 LogDebug(
"BscSim") <<
" Dispatched BeginOfEvent for " << GetName()
425 eventno = (*i)()->GetEventID();
430 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
432 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
433 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
434 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
447 std::vector<std::string>
temp;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setEntry(const G4ThreeVector &xyz)
float getPhiAtEntry() const
G4ThreeVector SetToLocal(const G4ThreeVector &global)
int getParticleType() const
BscSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
virtual double getEnergyDeposit(G4Step *step)
void setEnergyLoss(float e)
void GetStepInfo(G4Step *aStep)
void setUnitID(unsigned int i)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
BscG4HitCollection * theHC
G4ThreeVector hitPointLocalExit
type of data representation of DDCompactView
unsigned int getUnitID() const
virtual void AssignSD(const std::string &vname)
std::vector< std::string > getNames() override
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
virtual unsigned int getUnitID(const G4Step *aStep) const
int getTimeSliceID() const
G4VPhysicalVolume * currentPV
void setThetaAtEntry(float t)
void setEntryLocalP(const G4ThreeVector &xyz1)
std::vector< PSimHit > & hits()
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
std::string const collectionName[nCollections]
virtual void Initialize()
void setPhiAtEntry(float f)
G4StepPoint * preStepPoint
void fillHits(edm::PSimHitContainer &, std::string use) override
bool ProcessHits(G4Step *, G4TouchableHistory *) override
float getThetaAtEntry() const
void addEnergyDeposit(double em, double hd)
void setTimeSlice(double d)
void setParticleType(short i)
uint32_t setDetUnitId(G4Step *) override
void StoreHit(BscG4Hit *)
G4ThreeVector theEntryPoint
void clearHits() override
G4StepPoint * postStepPoint
G4ThreeVector hitPointExit
BscNumberingScheme * numberingScheme
G4ThreeVector theExitPoint
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
void EndOfEvent(G4HCofThisEvent *eventHC) override
G4ThreeVector getEntry() const
G4ThreeVector entrancePoint
void Initialize(G4HCofThisEvent *HCE) override
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
void setExitLocalP(const G4ThreeVector &xyz1)
G4THitsCollection< BscG4Hit > BscG4HitCollection
void setIncidentEnergy(double e)
float getEnergyLoss() const
G4ThreeVector hitPointLocal
void ResetForNewPrimary()