17 #include "G4SDManager.hh"
18 #include "G4VProcess.hh"
19 #include "G4EventManager.hh"
21 #include "G4ParticleTable.hh"
36 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
37 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
38 postStepPoint(0), eventno(0){
49 SetVerboseLevel(verbn);
52 <<
"*******************************************************\n"
54 <<
"* Constructing a FastTimerSD with name " << name <<
"\n"
56 <<
"*******************************************************";
64 std::vector<std::string> lvNames = clg.
logicalNames(name);
68 for (std::vector<std::string>::iterator it=lvNames.begin();
69 it !=lvNames.end(); it++) {
71 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD : Assigns SD to LV " << (*it);
77 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD: Instantiation completed";
88 return aStep->GetTotalEnergyDeposit();
93 LogDebug(
"FastTimerSim") <<
"FastTimerSD : Initialize called for " <<
name;
113 LogDebug(
"FastTimerSim") <<
"FastTimerSD : number of hits = "
137 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
139 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD :particleType = "
140 <<
theTrack->GetDefinition()->GetParticleName();
142 if (particleCode ==
emPDG ||
143 particleCode ==
epPDG ||
149 edeposit = aStep->GetTotalEnergyDeposit();
154 LogDebug(
"FastTimerSim") <<
"FastTimerSD:unitID = " << std::hex <<
unitID
160 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::nanosecond;
163 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/CLHEP::deg;
164 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/CLHEP::deg;
178 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
179 float globalZ = aStep->GetPreStepPoint()->GetPosition().z();
180 int iz = (globalZ > 0) ? 1 : -1;
181 std::pair<int,int> ixy;
189 edm::LogInfo(
"FastTimerSim") <<
"Levels " << touch->GetReplicaNumber(0) <<
":"
190 << globalZ <<
" Ixyz " << ixy.first <<
":"
191 << ixy.second <<
":" << iz <<
" id "
200 edm::LogWarning(
"FastTimerSim") <<
"***** FastTimerSD error: primaryID = "
202 <<
" maybe detector name changed";
217 G4bool
found =
false;
250 edm::LogWarning(
"FastTimerSim") <<
"FastTimerSD: hit to be stored is NULL !!";
252 theHC->insert( hit );
260 LogDebug(
"FastTimerSim") <<
"FastTimerSD CreateNewHit for"
263 <<
" Unit " <<
unitID <<std::endl;
266 <<
" For Track " <<
theTrack->GetTrackID()
267 <<
" which is a " <<
theTrack->GetDefinition()->GetParticleName();
272 LogDebug(
"FastTimerSim") <<
" daughter of part. " <<
theTrack->GetParentID();
275 LogDebug(
"FastTimerSim") <<
" and created by " ;
277 LogDebug(
"FastTimerSim") <<
theTrack->GetCreatorProcess()->GetProcessName() ;
279 LogDebug(
"FastTimerSim") <<
"NO process";
280 LogDebug(
"FastTimerSim") << std::endl;
322 LogDebug(
"FastTimerSim") <<
"updateHit: add eloss " <<
Eloss <<std::endl;
338 const G4VTouchable* touch=
preStepPoint->GetTouchable();
339 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
347 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
355 for (
int j=0;
j<
theHC->entries();
j++) {
358 edm::LogInfo(
"FastTimerSim") <<
"hit number " <<
j <<
" unit ID = "
360 <<
" entry z " << aHit->
getEntry().z()
390 theHC->PrintAllHits();
399 edm::LogInfo(
"FastTimerSim") <<
"Dispatched BeginOfEvent for " << GetName()
403 eventno = (*i)()->GetEventID();
408 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
409 G4String particleName;
410 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
411 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
412 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
423 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)
float getPhiAtEntry() const
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
int getParticleType() const
void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
G4ThreeVector theEntryPoint
virtual void Initialize(G4HCofThisEvent *HCE)
virtual double getEnergyDeposit(G4Step *step)
void setEnergyLoss(float e)
void setUnitID(unsigned int i)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
unsigned int getUnitID() const
virtual void AssignSD(const std::string &vname)
int getTimeSliceID() const
uint32_t rawId() const
get the raw id
void setThetaAtEntry(float t)
G4ThreeVector SetToLocal(const G4ThreeVector &global)
void setEntryLocalP(const G4ThreeVector &xyz1)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
FastTimerSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void setPhiAtEntry(float f)
G4StepPoint * postStepPoint
G4ThreeVector hitPointLocalExit
G4VPhysicalVolume * currentPV
void ResetForNewPrimary()
void StoreHit(BscG4Hit *)
FastTimeDDDConstants * ftcons
G4ThreeVector hitPointLocal
float getThetaAtEntry() const
BscG4HitCollection * theHC
void addEnergyDeposit(double em, double hd)
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
std::vector< std::string > getNames()
G4StepPoint * preStepPoint
void setTimeSlice(double d)
void setParticleType(short i)
void fillHits(edm::PSimHitContainer &, std::string use)
G4ThreeVector entrancePoint
G4ThreeVector theExitPoint
G4ThreeVector getEntry() const
virtual uint32_t setDetUnitId(G4Step *)
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)
std::pair< int, int > getXY(int copy) const
float getEnergyLoss() const
void GetStepInfo(G4Step *aStep)