31 #include "G4SDManager.hh"
32 #include "G4VProcess.hh"
33 #include "G4EventManager.hh"
35 #include "G4ParticleTable.hh"
37 #include "G4PhysicalConstants.hh"
38 #include "G4SystemOfUnits.hh"
52 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
53 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
54 postStepPoint(0), 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;
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;
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 " ;
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++) {
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();
431 G4String particleName;
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 fillHits(edm::PSimHitContainer &, std::string use)
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)
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
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)
virtual void Initialize(G4HCofThisEvent *HCE)
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
virtual unsigned int getUnitID(const G4Step *aStep) const
virtual uint32_t setDetUnitId(G4Step *)
int getTimeSliceID() const
G4VPhysicalVolume * currentPV
void setThetaAtEntry(float t)
void setEntryLocalP(const G4ThreeVector &xyz1)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
void setPhiAtEntry(float f)
G4StepPoint * preStepPoint
std::vector< std::string > getNames()
float getThetaAtEntry() const
void addEnergyDeposit(double em, double hd)
void setTimeSlice(double d)
void setParticleType(short i)
void StoreHit(BscG4Hit *)
G4ThreeVector theEntryPoint
G4StepPoint * postStepPoint
G4ThreeVector hitPointExit
BscNumberingScheme * numberingScheme
G4ThreeVector theExitPoint
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
G4ThreeVector getEntry() const
G4ThreeVector entrancePoint
void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
void setExitLocalP(const G4ThreeVector &xyz1)
G4THitsCollection< BscG4Hit > BscG4HitCollection
void setIncidentEnergy(double e)
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
float getEnergyLoss() const
G4ThreeVector hitPointLocal
void ResetForNewPrimary()