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) {
57 SetVerboseLevel(verbn);
59 std::cout <<
"*******************************************************\n" 61 <<
"* Constructing a FastTimerSD with name " << name <<
"\n" 63 <<
"*******************************************************\n";
71 std::vector<std::string> lvNames = clg.
logicalNames(name);
75 for (std::vector<std::string>::iterator it=lvNames.begin();
76 it !=lvNames.end(); it++) {
78 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD : Assigns SD to LV " << (*it);
89 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD: Instantiation completed for " 90 << name <<
" of type " <<
type_;
99 return aStep->GetTotalEnergyDeposit();
104 std::cout <<
"FastTimerSD : Initialize called for " <<
name << std::endl;
119 if (aStep ==
nullptr) {
124 std::cout <<
"FastTimerSD : number of hits = " <<
theHC->entries() <<
"\n";
147 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
149 std::cout <<
"FastTimerSD :particleType = " 150 <<
theTrack->GetDefinition()->GetParticleName() << std::endl;
152 if (particleCode ==
emPDG ||
153 particleCode ==
epPDG ||
159 edeposit = aStep->GetTotalEnergyDeposit();
169 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::nanosecond;
172 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/CLHEP::deg;
173 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/CLHEP::deg;
187 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
188 G4ThreeVector global = aStep->GetPreStepPoint()->GetPosition();
189 G4ThreeVector
local = touch->GetHistory()->GetTopTransform().TransformPoint(global);
190 int iz = (global.z() > 0) ? 1 : -1;
191 std::pair<int,int> izphi = ((
ftcons) ? ((
type_ == 1) ?
194 (std::pair<int,int>(0,0)));
197 std::cout <<
"Volume " << touch->GetVolume(0)->GetName() <<
":" << global.z()
198 <<
" Iz(eta)phi " << izphi.first <<
":" << izphi.second <<
":" 199 << iz <<
" id " << std::hex <<
id <<
std::dec << std::endl;
207 edm::LogWarning(
"FastTimerSim") <<
"***** FastTimerSD error: primaryID = " 209 <<
" maybe detector name changed";
224 G4bool
found =
false;
226 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
227 BscG4Hit* aPreviousHit = (*theHC)[j];
255 if (hit ==
nullptr) {
256 edm::LogWarning(
"FastTimerSim") <<
"FastTimerSD: hit to be stored is NULL !!";
258 theHC->insert( hit );
266 std::cout <<
"FastTimerSD CreateNewHit for" <<
" PV " 268 <<
" Unit " <<
unitID << std::endl;
270 <<
" For Track " <<
theTrack->GetTrackID() <<
" which is a " 271 <<
theTrack->GetDefinition()->GetParticleName();
342 const G4VTouchable* touch=
preStepPoint->GetTouchable();
343 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
351 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
359 for (
int j=0; j<
theHC->entries(); j++) {
362 std::cout <<
"hit number " << j <<
" unit ID = " << std::hex
364 << aHit->
getEntry().z() <<
" entry theta " 392 std::cout <<
"FastTimerSD: Collection " <<
theHC->GetName() << std::endl;
394 theHC->PrintAllHits();
409 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : Cannot find FastTimeDDDConstants";
410 throw cms::Exception(
"Unknown",
"FastTimerSD") <<
"Cannot find FastTimeDDDConstants\n";
413 std::cout <<
"FastTimerSD::Initialized with FastTimeDDDConstants\n";
419 std::cout <<
"Dispatched BeginOfEvent for " << GetName() <<
" !\n" ;
422 eventno = (*i)()->GetEventID();
427 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
429 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
430 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
431 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
442 std::vector<std::string>
temp;
452 const std::vector<double> & fvec = value.
doubles();
453 int nval = fvec.size();
455 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : # of " << str
456 <<
" 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
G4ThreeVector SetToLocalExit(const G4ThreeVector &globalPoint)
int getParticleType() const
std::pair< int, int > getEtaPhi(double r, double phi) const
G4ThreeVector theEntryPoint
virtual double getEnergyDeposit(G4Step *step)
void setEnergyLoss(float e)
uint32_t setDetUnitId(G4Step *) override
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
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.
virtual void AssignSD(const std::string &vname)
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()
FastTimerSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
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 *)
std::vector< std::string > getNames() 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
void fillHits(edm::PSimHitContainer &, std::string use) override
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)