31 #include "G4SDManager.hh"
32 #include "G4VProcess.hh"
33 #include "G4EventManager.hh"
35 #include "G4ParticleTable.hh"
49 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
50 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
51 postStepPoint(0), eventno(0){
62 SetVerboseLevel(verbn);
64 <<
"*******************************************************\n"
66 <<
"* Constructing a BscSD with name " << name <<
"\n"
68 <<
"*******************************************************";
76 std::vector<std::string> lvNames = clg.
logicalNames(name);
80 for (std::vector<std::string>::iterator it=lvNames.begin();
81 it !=lvNames.end(); it++) {
83 edm::LogInfo(
"BscSim") <<
"BscSD : Assigns SD to LV " << (*it);
86 if (name ==
"BSCHits") {
88 edm::LogInfo(
"BscSim") <<
"name = BSCHits and new BscNumberingSchem";
92 edm::LogWarning(
"BscSim") <<
"BscSD: ReadoutName "<<name<<
" not supported";
95 edm::LogInfo(
"BscSim") <<
"BscSD: Instantiation completed";
111 return aStep->GetTotalEnergyDeposit();
116 LogDebug(
"BscSim") <<
"BscSD : Initialize called for " <<
name << std::endl;
141 LogDebug(
"BscSim") <<
"BscSD : number of hits = " <<
theHC->entries() << std::endl;
165 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
166 LogDebug(
"BscSim") <<
" BscSD :particleType = " <<
theTrack->GetDefinition()->GetParticleName() <<std::endl;
167 if (particleCode ==
emPDG ||
168 particleCode ==
epPDG ||
174 edeposit = aStep->GetTotalEnergyDeposit();
183 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
184 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
185 Eloss = aStep->GetTotalEnergyDeposit()/GeV;
187 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
188 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
209 <<
" maybe detector name changed";
226 G4bool
found =
false;
268 theHC->insert( hit );
275 LogDebug(
"BscSim") <<
"BscSD CreateNewHit for"
278 <<
" Unit " <<
unitID <<std::endl;
281 <<
" For Track " <<
theTrack->GetTrackID()
282 <<
" which is a " <<
theTrack->GetDefinition()->GetParticleName();
290 LogDebug(
"BscSim") <<
" and created by " ;
337 LogDebug(
"BscSim") <<
"updateHit: add eloss " <<
Eloss <<std::endl;
354 const G4VTouchable* touch=
preStepPoint->GetTouchable();
355 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
363 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
371 for (
int j=0;
j<
theHC->entries();
j++) {
409 LogDebug(
"BscSim") <<
"BscSD: Collection " <<
theHC->GetName() <<
"\n";
410 theHC->PrintAllHits();
419 LogDebug(
"BscSim") <<
" Dispatched BeginOfEvent for " << GetName()
422 eventno = (*i)()->GetEventID();
427 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
428 G4String particleName;
429 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
430 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
431 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
444 std::vector<std::string>
temp;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4ThreeVector SetToLocal(G4ThreeVector global)
void fillHits(edm::PSimHitContainer &, std::string use)
std::vector< std::string > logicalNames(std::string &readoutName)
float getPhiAtEntry() const
int getParticleType() const
void setEntry(G4ThreeVector xyz)
virtual double getEnergyDeposit(G4Step *step)
void setEnergyLoss(float e)
void GetStepInfo(G4Step *aStep)
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
void setUnitID(unsigned int i)
BscG4HitCollection * theHC
G4ThreeVector hitPointLocalExit
type of data representation of DDCompactView
unsigned int getUnitID() const
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)
std::vector< PSimHit > & hits()
void setEntryLocalP(G4ThreeVector xyz1)
std::string const collectionName[nCollections]
virtual void Initialize()
void setPhiAtEntry(float f)
G4ThreeVector SetToLocalExit(G4ThreeVector globalPoint)
G4StepPoint * preStepPoint
std::vector< std::string > getNames()
float getThetaAtEntry() const
BscSD(std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
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
virtual void AssignSD(std::string &vname)
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
G4THitsCollection< BscG4Hit > BscG4HitCollection
void setIncidentEnergy(double e)
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
float getEnergyLoss() const
G4ThreeVector hitPointLocal
void ResetForNewPrimary()
void setExitLocalP(G4ThreeVector xyz1)