26 #include "G4SDManager.hh" 27 #include "G4VProcess.hh" 28 #include "G4EventManager.hh" 30 #include "G4ParticleTable.hh" 45 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
46 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
47 postStepPoint(0), 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);
92 edm::LogInfo(
"FastTimerSim") <<
"FastTimerSD: Instantiation completed for " 93 << name <<
" of type " <<
type_;
102 return aStep->GetTotalEnergyDeposit();
107 std::cout <<
"FastTimerSD : Initialize called for " <<
name << std::endl;
127 std::cout <<
"FastTimerSD : number of hits = " <<
theHC->entries() <<
"\n";
150 G4int particleCode =
theTrack->GetDefinition()->GetPDGEncoding();
152 std::cout <<
"FastTimerSD :particleType = " 153 <<
theTrack->GetDefinition()->GetParticleName() << std::endl;
155 if (particleCode ==
emPDG ||
156 particleCode ==
epPDG ||
162 edeposit = aStep->GetTotalEnergyDeposit();
172 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::nanosecond;
175 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/CLHEP::deg;
176 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/CLHEP::deg;
190 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
191 G4ThreeVector global = aStep->GetPreStepPoint()->GetPosition();
192 G4ThreeVector
local = touch->GetHistory()->GetTopTransform().TransformPoint(global);
193 int iz = (global.z() > 0) ? 1 : -1;
194 std::pair<int,int> izphi = ((
ftcons) ? ((
type_ == 1) ?
197 (std::pair<int,int>(0,0)));
200 std::cout <<
"Volume " << touch->GetVolume(0)->GetName() <<
":" << global.z()
201 <<
" Iz(eta)phi " << izphi.first <<
":" << izphi.second <<
":" 202 << iz <<
" id " << std::hex <<
id <<
std::dec << std::endl;
210 edm::LogWarning(
"FastTimerSim") <<
"***** FastTimerSD error: primaryID = " 212 <<
" maybe detector name changed";
227 G4bool
found =
false;
259 edm::LogWarning(
"FastTimerSim") <<
"FastTimerSD: hit to be stored is NULL !!";
261 theHC->insert( hit );
269 std::cout <<
"FastTimerSD CreateNewHit for" <<
" PV " 271 <<
" Unit " <<
unitID << std::endl;
273 <<
" For Track " <<
theTrack->GetTrackID() <<
" which is a " 274 <<
theTrack->GetDefinition()->GetParticleName();
345 const G4VTouchable* touch=
preStepPoint->GetTouchable();
346 theEntryPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
354 theExitPoint = touch->GetHistory()->GetTopTransform().TransformPoint(globalPoint);
362 for (
int j=0;
j<
theHC->entries();
j++) {
365 std::cout <<
"hit number " <<
j <<
" unit ID = " << std::hex
367 << aHit->
getEntry().z() <<
" entry theta " 395 std::cout <<
"FastTimerSD: Collection " <<
theHC->GetName() << std::endl;
397 theHC->PrintAllHits();
412 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : Cannot find FastTimeDDDConstants";
413 throw cms::Exception(
"Unknown",
"FastTimerSD") <<
"Cannot find FastTimeDDDConstants\n";
416 std::cout <<
"FastTimerSD::Initialized with FastTimeDDDConstants\n";
422 std::cout <<
"Dispatched BeginOfEvent for " << GetName() <<
" !\n" ;
425 eventno = (*i)()->GetEventID();
430 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
432 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
433 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
434 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
445 std::vector<std::string>
temp;
455 const std::vector<double> & fvec = value.
doubles();
456 int nval = fvec.size();
458 edm::LogError(
"FastTimerSim") <<
"FastTimerSD : # of " << str
459 <<
" 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
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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
virtual void update(const BeginOfJob *)
This routine will be called when the appropriate signal arrives.
type of data representation of DDCompactView
unsigned int getUnitID() const
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
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)
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 *)
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
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 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)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
float getEnergyLoss() const
void GetStepInfo(G4Step *aStep)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.