26 #include "G4SDManager.hh" 27 #include "G4VProcess.hh" 28 #include "G4EventManager.hh" 30 #include "G4ParticleTable.hh" 46 currentPV(
nullptr), unitID(0), previousUnitID(0), preStepPoint(
nullptr),
47 postStepPoint(
nullptr), eventno(0) {
53 SetVerboseLevel(verbn);
65 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD: Instantiation completed for " 66 << name <<
" of type " <<
type_;
74 return aStep->GetTotalEnergyDeposit();
79 std::cout <<
"FastTimerSD : Initialize called for " <<
name << std::endl;
93 if (aStep ==
nullptr) {
98 std::cout <<
"FastTimerSD : number of hits = " <<
theHC->entries() <<
"\n";
121 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
123 std::cout <<
"FastTimerSD :particleType = " 124 <<
theTrack->GetDefinition()->GetParticleName() << std::endl;
126 if (particleCode ==
emPDG ||
127 particleCode ==
epPDG ||
133 edeposit = aStep->GetTotalEnergyDeposit();
143 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::nanosecond;
146 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/CLHEP::deg;
147 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/CLHEP::deg;
161 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
162 G4ThreeVector global = aStep->GetPreStepPoint()->GetPosition();
163 G4ThreeVector
local = touch->GetHistory()->GetTopTransform().TransformPoint(global);
164 int iz = (global.z() > 0) ? 1 : -1;
165 std::pair<int,int> izphi = ((
ftcons) ? ((
type_ == 1) ?
168 (std::pair<int,int>(0,0)));
171 std::cout <<
"Volume " << touch->GetVolume(0)->GetName() <<
":" << global.z()
172 <<
" Iz(eta)phi " << izphi.first <<
":" << izphi.second <<
":" 173 << iz <<
" id " << std::hex <<
id <<
std::dec << std::endl;
181 edm::LogWarning(
"FastTimerSim") <<
"***** FastTimerSD error: primaryID = " 183 <<
" maybe detector name changed";
198 G4bool
found =
false;
200 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
201 BscG4Hit* aPreviousHit = (*theHC)[j];
229 if (hit ==
nullptr) {
230 edm::LogWarning(
"FastTimerSim") <<
"FastTimerSD: hit to be stored is NULL !!";
232 theHC->insert( hit );
240 std::cout <<
"FastTimerSD CreateNewHit for" <<
" PV " 242 <<
" Unit " <<
unitID << std::endl;
244 <<
" For Track " <<
theTrack->GetTrackID() <<
" which is a " 245 <<
theTrack->GetDefinition()->GetParticleName();
316 const G4VTouchable* touch=
preStepPoint->GetTouchable();
317 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
325 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
333 for (
int j=0; j<
theHC->entries(); j++) {
336 std::cout <<
"hit number " << j <<
" unit ID = " << std::hex
338 << aHit->
getEntry().z() <<
" entry theta " 366 std::cout <<
"FastTimerSD: Collection " <<
theHC->GetName() << std::endl;
368 theHC->PrintAllHits();
383 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : Cannot find FastTimeDDDConstants";
384 throw cms::Exception(
"Unknown",
"FastTimerSD") <<
"Cannot find FastTimeDDDConstants\n";
387 std::cout <<
"FastTimerSD::Initialized with FastTimeDDDConstants\n";
393 std::cout <<
"Dispatched BeginOfEvent for " << GetName() <<
" !\n" ;
396 eventno = (*i)()->GetEventID();
401 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
403 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
404 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
405 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
420 const std::vector<double> & fvec = value.
doubles();
421 int nval = fvec.size();
423 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : # of " << str
424 <<
" bins " << nval <<
" < 1 ==> illegal";
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4ThreeVector hitPointExit
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
void setEntry(const G4ThreeVector &xyz)
float getPhiAtEntry() const
FastTimerSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
int getParticleType() const
double getEnergyDeposit(const G4Step *step)
std::pair< int, int > getEtaPhi(double r, double phi) const
G4ThreeVector theEntryPoint
void setEnergyLoss(float e)
void setUnitID(unsigned int i)
type of data representation of DDCompactView
unsigned int getUnitID() const
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
int getTimeSliceID() const
uint32_t rawId() const
get the raw id
const FastTimeDDDConstants * ftcons
void setThetaAtEntry(float t)
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
G4ThreeVector SetToLocal(const G4ThreeVector &global)
std::pair< int, int > getZPhi(double z, double phi) const
void setEntryLocalP(const G4ThreeVector &xyz1)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
void setPhiAtEntry(float f)
void clearHits() override
G4StepPoint * postStepPoint
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Abs< T >::type abs(const T &t)
G4ThreeVector hitPointLocalExit
G4VPhysicalVolume * currentPV
void ResetForNewPrimary()
void StoreHit(BscG4Hit *)
void fillHits(edm::PSimHitContainer &, const std::string &) override
uint32_t setDetUnitId(const G4Step *) override
G4ThreeVector hitPointLocal
float getThetaAtEntry() const
BscG4HitCollection * theHC
void addEnergyDeposit(double em, double hd)
G4StepPoint * preStepPoint
void setTimeSlice(double d)
void setParticleType(short i)
void EndOfEvent(G4HCofThisEvent *eventHC) override
G4ThreeVector entrancePoint
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
DDsvalues_type mergedSpecifics() const
G4ThreeVector theExitPoint
G4ThreeVector getEntry() const
bool firstChild()
set the current node to the first child ...
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
void setExitLocalP(const G4ThreeVector &xyz1)
G4THitsCollection< BscG4Hit > BscG4HitCollection
void setIncidentEnergy(double e)
void Initialize(G4HCofThisEvent *HCE) override
float getEnergyLoss() const
bool ProcessHits(G4Step *, G4TouchableHistory *) override
void GetStepInfo(G4Step *aStep)