CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TotemSD Class Reference

#include <SimG4CMS/Forward/interface/TotemSD.h>

Inheritance diagram for TotemSD:
SensitiveTkDetector Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PSimHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
uint32_t setDetUnitId (const G4Step *) override
 
 TotemSD (const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
 ~TotemSD () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Private Member Functions

void CreateNewHit ()
 
void CreateNewHitEvo ()
 
void GetStepInfo (G4Step *aStep)
 
bool HitExists ()
 
G4ThreeVector PosizioEvo (const G4ThreeVector &, double, double, double, double, int &)
 
void ResetForNewPrimary ()
 
G4ThreeVector SetToLocal (const G4ThreeVector &globalPoint)
 
void StoreHit (TotemG4Hit *)
 
void Summarize ()
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *) override
 
void UpdateHit ()
 

Private Attributes

TotemG4HitcurrentHit
 
G4VPhysicalVolume * currentPV
 
float edeposit
 
float Eloss
 
G4ThreeVector entrancePoint
 
int eventno
 
G4int hcID
 
G4ThreeVector hitPoint
 
float incidentEnergy
 
TotemVDetectorOrganizationnumberingScheme
 
float Pabs
 
int ParentId
 
short ParticleType
 
float PhiAtEntry
 
G4ThreeVector Posizio
 
G4StepPoint * postStepPoint
 
G4StepPoint * preStepPoint
 
uint32_t previousUnitID
 
int primaryID
 
G4int primID
 
TrackingSlaveSDslave
 
TotemG4HitCollectiontheHC
 
const SimTrackManagertheManager
 
float ThetaAtEntry
 
G4Track * theTrack
 
float Tof
 
int tsID
 
double tSlice
 
int tSliceID
 
uint32_t unitID
 
float Vx
 
float Vy
 
float Vz
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Member Functions inherited from SensitiveDetector
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Detailed Description

Description: Stores hits of Totem in appropriate container

Usage: Used in sensitive detector builder

Definition at line 43 of file TotemSD.h.

Constructor & Destructor Documentation

TotemSD::TotemSD ( const std::string &  name,
const DDCompactView cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 48 of file TotemSD.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), numberingScheme, and slave.

50  :
51  SensitiveTkDetector(name, cpv, clg, p), numberingScheme(nullptr),
52  hcID(-1), theHC(nullptr), theManager(manager), currentHit(nullptr), theTrack(nullptr),
53  currentPV(nullptr), unitID(0), previousUnitID(0), preStepPoint(nullptr),
54  postStepPoint(nullptr), eventno(0){
55 
56  //Parameters
57  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("TotemSD");
58  int verbn = m_p.getUntrackedParameter<int>("Verbosity");
59 
60  SetVerboseLevel(verbn);
61 
62  slave = new TrackingSlaveSD(name);
63 
64  if (name == "TotemHitsT1") {
66  } else if (name == "TotemHitsT2Si") {
68  } else if (name == "TotemHitsT2Gem") {
70  } else if (name == "TotemHitsRP") {
72  } else {
73  edm::LogWarning("ForwardSim") << "TotemSD: ReadoutName not supported\n";
74  }
75 }
T getUntrackedParameter(std::string const &, T const &) const
uint32_t unitID
Definition: TotemSD.h:103
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
uint32_t previousUnitID
Definition: TotemSD.h:103
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:84
G4int hcID
Definition: TotemSD.h:95
G4StepPoint * preStepPoint
Definition: TotemSD.h:107
G4StepPoint * postStepPoint
Definition: TotemSD.h:108
TotemG4Hit * currentHit
Definition: TotemSD.h:100
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:102
TrackingSlaveSD * slave
Definition: TotemSD.h:83
G4Track * theTrack
Definition: TotemSD.h:101
int eventno
Definition: TotemSD.h:124
const SimTrackManager * theManager
Definition: TotemSD.h:97
SensitiveTkDetector(const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
TotemSD::~TotemSD ( )
override

Definition at line 77 of file TotemSD.cc.

References numberingScheme, and slave.

77  {
78  delete slave;
79  delete numberingScheme;
80 }
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:84
TrackingSlaveSD * slave
Definition: TotemSD.h:83

Member Function Documentation

void TotemSD::clear ( void  )
override

Definition at line 146 of file TotemSD.cc.

146  {
147 }
void TotemSD::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 171 of file TotemSD.cc.

References TrackingSlaveSD::Initialize(), and slave.

Referenced by update().

171  {
172  slave->Initialize();
173 }
virtual void Initialize()
TrackingSlaveSD * slave
Definition: TotemSD.h:83
void TotemSD::CreateNewHit ( )
private

Definition at line 266 of file TotemSD.cc.

References gather_cfg::cout, currentHit, currentPV, Eloss, incidentEnergy, LogDebug, NULL, Pabs, ParentId, ParticleType, PhiAtEntry, Posizio, primaryID, TotemG4Hit::setEnergyLoss(), TotemG4Hit::setEntry(), TotemG4Hit::setIncidentEnergy(), TotemG4Hit::setPabs(), TotemG4Hit::setParentId(), TotemG4Hit::setParticleType(), TotemG4Hit::setPhiAtEntry(), TotemG4Hit::setThetaAtEntry(), TotemG4Hit::setTimeSlice(), TotemG4Hit::setTof(), TotemG4Hit::setTrackID(), TotemG4Hit::setUnitID(), TotemG4Hit::setVx(), TotemG4Hit::setVy(), TotemG4Hit::setVz(), StoreHit(), ThetaAtEntry, theTrack, Tof, tSlice, tSliceID, unitID, UpdateHit(), Vx, Vy, and Vz.

Referenced by ProcessHits().

266  {
267 
268 #ifdef debug
269  LogDebug("ForwardSim") << "TotemSD CreateNewHit for"
270  << " PV " << currentPV->GetName()
271  << " PVid = " << currentPV->GetCopyNo()
272  << " MVid = " << currentPV->GetMother()->GetCopyNo()
273  << " Unit " << unitID << "\n"
274  << " primary " << primaryID
275  << " time slice " << tSliceID
276  << " For Track " << theTrack->GetTrackID()
277  << " which is a "
278  << theTrack->GetDefinition()->GetParticleName();
279 
280  if (theTrack->GetTrackID()==1) {
281  LogDebug("ForwardSim") << " of energy " << theTrack->GetTotalEnergy();
282  } else {
283  LogDebug("ForwardSim") << " daughter of part. " << theTrack->GetParentID();
284  }
285 
286  cout << " and created by " ;
287  if (theTrack->GetCreatorProcess()!=NULL)
288  LogDebug("ForwardSim") << theTrack->GetCreatorProcess()->GetProcessName() ;
289  else
290  LogDebug("ForwardSim") << "NO process";
291 #endif
292 
293 
294  currentHit = new TotemG4Hit;
299 
306 
307  currentHit->setEntry(Posizio.x(),Posizio.y(),Posizio.z());
308 
310  currentHit->setVx(Vx);
311  currentHit->setVy(Vy);
312  currentHit->setVz(Vz);
313 
314  UpdateHit();
315 
317 }
#define LogDebug(id)
void setVz(float p)
Definition: TotemG4Hit.cc:183
int ParentId
Definition: TotemSD.h:121
void setPabs(float e)
Definition: TotemG4Hit.cc:153
uint32_t unitID
Definition: TotemSD.h:103
float Pabs
Definition: TotemSD.h:113
G4ThreeVector Posizio
Definition: TotemSD.h:112
float Tof
Definition: TotemSD.h:114
void setEnergyLoss(float e)
Definition: TotemG4Hit.cc:155
void setEntry(double x, double y, double z)
Definition: TotemG4Hit.h:57
double tSlice
Definition: TotemSD.h:105
int primaryID
Definition: TotemSD.h:104
float incidentEnergy
Definition: TotemSD.h:92
#define NULL
Definition: scimark2.h:8
int tSliceID
Definition: TotemSD.h:104
void setVy(float p)
Definition: TotemG4Hit.cc:180
void setTimeSlice(double d)
Definition: TotemG4Hit.cc:141
float Eloss
Definition: TotemSD.h:115
float Vx
Definition: TotemSD.h:122
void setVx(float p)
Definition: TotemG4Hit.cc:177
void setParentId(int p)
Definition: TotemG4Hit.cc:174
TotemG4Hit * currentHit
Definition: TotemSD.h:100
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:102
void setIncidentEnergy(double e)
Definition: TotemG4Hit.cc:132
short ParticleType
Definition: TotemSD.h:116
void setThetaAtEntry(float t)
Definition: TotemG4Hit.cc:161
float PhiAtEntry
Definition: TotemSD.h:119
void setUnitID(uint32_t i)
Definition: TotemG4Hit.cc:138
void setTrackID(int i)
Definition: TotemG4Hit.cc:135
void setPhiAtEntry(float f)
Definition: TotemG4Hit.cc:162
void setParticleType(short i)
Definition: TotemG4Hit.cc:156
void setTof(float e)
Definition: TotemG4Hit.cc:154
float Vz
Definition: TotemSD.h:122
void StoreHit(TotemG4Hit *)
Definition: TotemSD.cc:486
G4Track * theTrack
Definition: TotemSD.h:101
void UpdateHit()
Definition: TotemSD.cc:454
float Vy
Definition: TotemSD.h:122
float ThetaAtEntry
Definition: TotemSD.h:118
void TotemSD::CreateNewHitEvo ( )
private

Definition at line 319 of file TotemSD.cc.

References currentHit, Eloss, incidentEnergy, Pabs, ParentId, ParticleType, PhiAtEntry, Posizio, PosizioEvo(), primaryID, TotemG4Hit::setEnergyLoss(), TotemG4Hit::setEntry(), TotemG4Hit::setIncidentEnergy(), TotemG4Hit::setPabs(), TotemG4Hit::setParentId(), TotemG4Hit::setParticleType(), TotemG4Hit::setPhiAtEntry(), TotemG4Hit::setThetaAtEntry(), TotemG4Hit::setTimeSlice(), TotemG4Hit::setTof(), TotemG4Hit::setTrackID(), TotemG4Hit::setUnitID(), TotemG4Hit::setVx(), TotemG4Hit::setVy(), TotemG4Hit::setVz(), StoreHit(), ThetaAtEntry, Tof, tSlice, unitID, UpdateHit(), Vx, Vy, and Vz.

Referenced by ProcessHits().

319  {
320 
321 // LogDebug("ForwardSim") << "INSIDE CREATE NEW HIT EVO ";
322 
323  currentHit = new TotemG4Hit;
328 
335 
336  // LogDebug("ForwardSim") << Posizio.x() << " " << Posizio.y() << " " << Posizio.z();
337 
339  currentHit->setVx(Vx);
340  currentHit->setVy(Vy);
341  currentHit->setVz(Vz);
342 
343  G4ThreeVector _PosizioEvo;
344  int flagAcc=0;
345  _PosizioEvo=PosizioEvo(Posizio,Vx,Vy,Vz,Pabs,flagAcc);
346 
347  if(flagAcc==1){
348  currentHit->setEntry(_PosizioEvo.x(),_PosizioEvo.y(),_PosizioEvo.z());
349 
350  // if(flagAcc==1)
351  UpdateHit();
352 
354  }
355  // LogDebug("ForwardSim") << "STORED HIT IN: " << unitID;
356 }
void setVz(float p)
Definition: TotemG4Hit.cc:183
int ParentId
Definition: TotemSD.h:121
void setPabs(float e)
Definition: TotemG4Hit.cc:153
uint32_t unitID
Definition: TotemSD.h:103
float Pabs
Definition: TotemSD.h:113
G4ThreeVector Posizio
Definition: TotemSD.h:112
float Tof
Definition: TotemSD.h:114
void setEnergyLoss(float e)
Definition: TotemG4Hit.cc:155
void setEntry(double x, double y, double z)
Definition: TotemG4Hit.h:57
double tSlice
Definition: TotemSD.h:105
int primaryID
Definition: TotemSD.h:104
float incidentEnergy
Definition: TotemSD.h:92
void setVy(float p)
Definition: TotemG4Hit.cc:180
void setTimeSlice(double d)
Definition: TotemG4Hit.cc:141
G4ThreeVector PosizioEvo(const G4ThreeVector &, double, double, double, double, int &)
Definition: TotemSD.cc:358
float Eloss
Definition: TotemSD.h:115
float Vx
Definition: TotemSD.h:122
void setVx(float p)
Definition: TotemG4Hit.cc:177
void setParentId(int p)
Definition: TotemG4Hit.cc:174
TotemG4Hit * currentHit
Definition: TotemSD.h:100
void setIncidentEnergy(double e)
Definition: TotemG4Hit.cc:132
short ParticleType
Definition: TotemSD.h:116
void setThetaAtEntry(float t)
Definition: TotemG4Hit.cc:161
float PhiAtEntry
Definition: TotemSD.h:119
void setUnitID(uint32_t i)
Definition: TotemG4Hit.cc:138
void setTrackID(int i)
Definition: TotemG4Hit.cc:135
void setPhiAtEntry(float f)
Definition: TotemG4Hit.cc:162
void setParticleType(short i)
Definition: TotemG4Hit.cc:156
void setTof(float e)
Definition: TotemG4Hit.cc:154
float Vz
Definition: TotemSD.h:122
void StoreHit(TotemG4Hit *)
Definition: TotemSD.cc:486
void UpdateHit()
Definition: TotemSD.cc:454
float Vy
Definition: TotemSD.h:122
float ThetaAtEntry
Definition: TotemSD.h:118
void TotemSD::DrawAll ( )
override

Definition at line 149 of file TotemSD.cc.

149  {
150 }
void TotemSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 119 of file TotemSD.cc.

References TotemG4Hit::getEnergyLoss(), TotemG4Hit::getEntry(), TotemG4Hit::getPabs(), TotemG4Hit::getParticleType(), TotemG4Hit::getPhiAtEntry(), TotemG4Hit::getThetaAtEntry(), TotemG4Hit::getTof(), TotemG4Hit::getTrackID(), TotemG4Hit::getUnitID(), LogDebug, TrackingSlaveSD::processHits(), slave, Summarize(), and theHC.

119  {
120 
121  // here we loop over transient hits and make them persistent
122  for (int j=0; j<theHC->entries() && j<15000; j++) {
123  TotemG4Hit* aHit = (*theHC)[j];
124 #ifdef ddebug
125  LogDebug("ForwardSim") << "HIT NUMERO " << j << "unit ID = "
126  << aHit->getUnitID() << "\n"
127  << " " << "enrty z "
128  << aHit->getEntry().z() << "\n"
129  << " " << "theta "
130  << aHit->getThetaAtEntry() << "\n";
131 #endif
132  Local3DPoint theExitPoint(0,0,0);
133  Local3DPoint Entrata(aHit->getEntry().x(),
134  aHit->getEntry().y(),
135  aHit->getEntry().z());
136  slave->processHits(PSimHit(Entrata,theExitPoint,
137  aHit->getPabs(), aHit->getTof(),
138  aHit->getEnergyLoss(), aHit->getParticleType(),
139  aHit->getUnitID(), aHit->getTrackID(),
140  aHit->getThetaAtEntry(),aHit->getPhiAtEntry()));
141 
142  }
143  Summarize();
144 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
float getTof() const
Definition: TotemG4Hit.cc:149
float getEnergyLoss() const
Definition: TotemG4Hit.cc:150
math::XYZPoint getEntry() const
Definition: TotemG4Hit.cc:123
float getPabs() const
Definition: TotemG4Hit.cc:148
float getPhiAtEntry() const
Definition: TotemG4Hit.cc:159
int getTrackID() const
Definition: TotemG4Hit.cc:134
void Summarize()
Definition: TotemSD.cc:503
uint32_t getUnitID() const
Definition: TotemG4Hit.cc:137
TrackingSlaveSD * slave
Definition: TotemSD.h:83
int getParticleType() const
Definition: TotemG4Hit.cc:151
virtual bool processHits(const PSimHit &)
float getThetaAtEntry() const
Definition: TotemG4Hit.cc:158
void TotemSD::fillHits ( edm::PSimHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveTkDetector.

Definition at line 157 of file TotemSD.cc.

References TrackingSlaveSD::hits(), TrackingSlaveSD::name(), and slave.

157  {
158  if (slave->name() == hname) { cc=slave->hits(); }
159 }
std::string name() const
std::vector< PSimHit > & hits()
TrackingSlaveSD * slave
Definition: TotemSD.h:83
void TotemSD::GetStepInfo ( G4Step *  aStep)
private

Definition at line 183 of file TotemSD.cc.

References currentPV, edeposit, Eloss, GeV, hitPoint, createfilelist::int, LogDebug, dataset::name, Pabs, ParentId, objects.autophobj::particleType, ParticleType, PhiAtEntry, Posizio, postStepPoint, preStepPoint, primaryID, setDetUnitId(), ThetaAtEntry, theTrack, Tof, tSlice, tSliceID, unitID, Vx, Vy, and Vz.

Referenced by ProcessHits().

183  {
184 
185  preStepPoint = aStep->GetPreStepPoint();
186  postStepPoint= aStep->GetPostStepPoint();
187  theTrack = aStep->GetTrack();
188  //Local3DPoint theEntryPoint = SensitiveDetector::InitialStepPosition(aStep,LocalCoordinates);
189  //Local3DPoint theExitPoint = SensitiveDetector::FinalStepPosition(aStep,LocalCoordinates);
190  hitPoint = preStepPoint->GetPosition();
191  currentPV = preStepPoint->GetPhysicalVolume();
192 
193  // double weight = 1;
194  G4String name = currentPV->GetName();
195  name.assign(name,0,4);
196  G4String particleType = theTrack->GetDefinition()->GetParticleName();
197  edeposit = aStep->GetTotalEnergyDeposit();
198 
199  tSlice = (postStepPoint->GetGlobalTime() )/nanosecond;
200  tSliceID = (int) tSlice;
201  unitID = setDetUnitId(aStep);
202 #ifdef debug
203  LogDebug("ForwardSim") << "UNITa " << unitID;
204 #endif
205  primaryID = theTrack->GetTrackID();
206 
207 
208  Posizio = hitPoint;
209  Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
210  Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
211 
212  Eloss = aStep->GetTotalEnergyDeposit()/GeV;
213  ParticleType = theTrack->GetDefinition()->GetPDGEncoding();
214 
215  ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
216  PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
217 
218  ParentId = theTrack->GetParentID();
219  Vx = theTrack->GetVertexPosition().x();
220  Vy = theTrack->GetVertexPosition().y();
221  Vz = theTrack->GetVertexPosition().z();
222 }
#define LogDebug(id)
int ParentId
Definition: TotemSD.h:121
uint32_t unitID
Definition: TotemSD.h:103
const double GeV
Definition: MathUtil.h:16
float Pabs
Definition: TotemSD.h:113
G4ThreeVector Posizio
Definition: TotemSD.h:112
float Tof
Definition: TotemSD.h:114
double tSlice
Definition: TotemSD.h:105
int primaryID
Definition: TotemSD.h:104
int tSliceID
Definition: TotemSD.h:104
G4StepPoint * preStepPoint
Definition: TotemSD.h:107
float Eloss
Definition: TotemSD.h:115
float edeposit
Definition: TotemSD.h:109
float Vx
Definition: TotemSD.h:122
G4ThreeVector hitPoint
Definition: TotemSD.h:110
G4StepPoint * postStepPoint
Definition: TotemSD.h:108
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:102
uint32_t setDetUnitId(const G4Step *) override
Definition: TotemSD.cc:101
short ParticleType
Definition: TotemSD.h:116
float PhiAtEntry
Definition: TotemSD.h:119
float Vz
Definition: TotemSD.h:122
G4Track * theTrack
Definition: TotemSD.h:101
float Vy
Definition: TotemSD.h:122
float ThetaAtEntry
Definition: TotemSD.h:118
bool TotemSD::HitExists ( )
private

Definition at line 224 of file TotemSD.cc.

References currentHit, runEdmFileComparison::found, TotemG4Hit::getTimeSliceID(), TotemG4Hit::getTrackID(), TotemG4Hit::getUnitID(), previousUnitID, primaryID, primID, ResetForNewPrimary(), theHC, tsID, tSliceID, unitID, and UpdateHit().

Referenced by ProcessHits().

224  {
225 
226  if (primaryID<1) {
227  edm::LogWarning("ForwardSim") << "***** TotemSD error: primaryID = "
228  << primaryID
229  << " maybe detector name changed";
230  }
231 
232  // Update if in the same detector, time-slice and for same track
233  // if (primaryID == primID && tSliceID == tsID && unitID==previousUnitID) {
234  if (tSliceID == tsID && unitID==previousUnitID) {
235  UpdateHit();
236  return true;
237  }
238 
239  // Reset entry point for new primary
240  if (primaryID != primID)
242 
243  //look in the HitContainer whether a hit with the same primID, unitID,
244  //tSliceID already exists:
245 
246  bool found = false;
247 
248  for (int j=0; j<theHC->entries()&&!found; j++) {
249  TotemG4Hit* aPreviousHit = (*theHC)[j];
250  if (aPreviousHit->getTrackID() == primaryID &&
251  aPreviousHit->getTimeSliceID() == tSliceID &&
252  aPreviousHit->getUnitID() == unitID ) {
253  currentHit = aPreviousHit;
254  found = true;
255  }
256  }
257 
258  if (found) {
259  UpdateHit();
260  return true;
261  } else {
262  return false;
263  }
264 }
uint32_t unitID
Definition: TotemSD.h:103
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
int primaryID
Definition: TotemSD.h:104
uint32_t previousUnitID
Definition: TotemSD.h:103
int tSliceID
Definition: TotemSD.h:104
void ResetForNewPrimary()
Definition: TotemSD.cc:497
int getTrackID() const
Definition: TotemG4Hit.cc:134
int getTimeSliceID() const
Definition: TotemG4Hit.cc:142
TotemG4Hit * currentHit
Definition: TotemSD.h:100
uint32_t getUnitID() const
Definition: TotemG4Hit.cc:137
G4int primID
Definition: TotemSD.h:93
void UpdateHit()
Definition: TotemSD.cc:454
int tsID
Definition: TotemSD.h:99
void TotemSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 106 of file TotemSD.cc.

References ecaldqm::collectionName, hcID, LogDebug, primID, theHC, and tsID.

106  {
107 
108  LogDebug("ForwardSim") << "TotemSD : Initialize called for " << GetName();
109 
110  theHC = new TotemG4HitCollection(GetName(), collectionName[0]);
111  if (hcID<0)
112  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
113  HCE->AddHitsCollection(hcID, theHC);
114 
115  tsID = -2;
116  primID = -2;
117 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
G4int hcID
Definition: TotemSD.h:95
std::string const collectionName[nCollections]
Definition: Collections.h:47
G4int primID
Definition: TotemSD.h:93
int tsID
Definition: TotemSD.h:99
G4THitsCollection< TotemG4Hit > TotemG4HitCollection
G4ThreeVector TotemSD::PosizioEvo ( const G4ThreeVector &  Pos,
double  vx,
double  vy,
double  vz,
double  pabs,
int &  accettanza 
)
private

Definition at line 358 of file TotemSD.cc.

References mathSSE::sqrt().

Referenced by CreateNewHitEvo().

359  {
360  accettanza=0;
361  //Pos.xyz() in mm
362  G4ThreeVector PosEvo;
363  double ThetaX=atan((Pos.x()-vx)/(Pos.z()-vz));
364  double ThetaY=atan((Pos.y()-vy)/(Pos.z()-vz));
365  double X_at_0 =(vx-((Pos.x()-vx)/(Pos.z()-vz))*vz)/1000.;
366  double Y_at_0 =(vy-((Pos.y()-vy)/(Pos.z()-vz))*vz)/1000.;
367 
368  // double temp_evo_X;
369  // double temp_evo_Y;
370  // double temp_evo_Z;
371  // temp_evo_Z = fabs(Pos.z())/Pos.z()*220000.;
372 
373  //csi=-dp/d
374  double csi = fabs((7000.-pabs)/7000.);
375 
376  // all in m
377  const int no_rp=4;
378  double x_par[no_rp+1];
379  double y_par[no_rp+1];
380  //rp z position
381  double rp[no_rp]={141.,149.,198.,220.};
382  //{lx0,mlx} for each rp; Lx=lx0+mlx*csi
383  double leffx[][2]={{122.5429,-46.9312},{125.4194,-49.1849},{152.6,-81.157},{98.8914,-131.8390}};
384  //{ly0,mly} for each rp; Ly=ly0+mly*csi
385  double leffy[][2]={{124.2314,-55.4852},{127.7825,-57.4503},{179.455,-76.274},{273.0931,-40.4626}};
386  //{vx0,mvx0} for each rp; vx=vx0+mvx*csi
387  double avx[][2]={{0.515483,-1.0123},{0.494122,-1.0534},{0.2217,-1.483},{0.004633,-1.0719}};
388  //{vy0,mvy0} for each rp; vy=vy0+mvy*csi
389  double avy[][2]={{0.371418,-1.6327},{0.349035,-1.6955},{0.0815,-2.59},{0.007592,-4.0841}};
390  //{D0,md,a,b} for each rp; D=D0+(md+a*thetax)*csi+b*thetax
391  double ddx[][4]= {{-0.082336,-0.092513,112.3436,-82.5029},{-0.086927,-0.097670,114.9513,-82.9835},
392  {-0.092117,-0.0915,180.6236,-82.443},{-0.050470,0.058837,208.1106,20.8198}};
393  // {10sigma_x+0.5mm,10sigma_y+0.5mm}
394  double detlim[][2]={{0,0},{0.0028,0.0021},{0,0},{0.0008,0.0013}};
395  //{rmax,dmax}
396  double pipelim[][2]={{0.026,0.026},{0.04,0.04},{0.0226,0.0177},{0.04,0.04}};
397 
398 
399  for(int j=0; j<no_rp ; j++) {
400  //y=Ly*thetay+vy*y0
401  //x=Lx*thetax+vx*x0-csi*D
402  y_par[j]=ThetaY*(leffy[j][0]+leffy[j][1]*csi)+(avy[j][0]+avy[j][1]*csi)*Y_at_0;
403  x_par[j]=ThetaX*(leffx[j][0]+leffx[j][1]*csi)+(avx[j][0]+avx[j][1]*csi)*X_at_0-
404  csi*(ddx[j][0]+(ddx[j][1]+ddx[j][2]*ThetaX)*csi+ddx[j][3]*ThetaX);
405  }
406 
407 
408  //pass TAN@141
409  if (fabs(y_par[0])<pipelim[0][1] && sqrt((y_par[0]*y_par[0])+(x_par[0]*x_par[0]))<pipelim[0][0]) {
410  //pass 149
411  if ((sqrt((y_par[1]*y_par[1])+(x_par[1]*x_par[1]))<pipelim[1][0]) &&
412  (fabs(y_par[1])>detlim[1][1] || x_par[1]>detlim[1][0])) {
413  accettanza = 1;
414  }
415  }
416 
417 
418  //pass TAN@141
419  if (fabs(y_par[0])<pipelim[0][1] && sqrt((y_par[0])*(y_par[0])+(x_par[0])*(x_par[0]))<pipelim[0][0]) {
420  //pass Q5@198
421  if (fabs(y_par[2])<pipelim[2][1] && sqrt((y_par[2]*y_par[2])+(x_par[2]*x_par[2]))<pipelim[2][0]) {
422  //pass 220
423  if ((sqrt((y_par[3]*y_par[3])+(x_par[3]*x_par[3]))<pipelim[3][0]) &&
424  (fabs(y_par[3])>detlim[3][1] || x_par[3]>detlim[3][0])) {
425  accettanza = 1;
426 
427  PosEvo.setX(1000*x_par[3]);
428  PosEvo.setY(1000*y_par[3]);
429  PosEvo.setZ(1000*rp[3]);
430  if(Pos.z()<vz)PosEvo.setZ(-1000*rp[3]);
431  }
432  }
433 
434  }
435 /*
436  LogDebug("ForwardSim") << "\n"
437  << "ACCETTANZA: "<<accettanza << "\n"
438  << "CSI: "<< csi << "\n"
439  << "Theta_X: " << ThetaX << "\n"
440  << "Theta_Y: " << ThetaY << "\n"
441  << "X_at_0: "<< X_at_0 << "\n"
442  << "Y_at_0: "<< Y_at_0 << "\n"
443  << "x_par[3]: "<< x_par[3] << "\n"
444  << "y_par[3]: "<< y_par[3] << "\n"
445  << "pos " << Pos.x() << " " << Pos.y() << " "
446  << Pos.z() << "\n" << "V "<< vx << " " << vy << " "
447  << vz << "\n"
448 */
449 // --------------
450  return PosEvo;
451 }
T sqrt(T t)
Definition: SSEVec.h:18
void TotemSD::PrintAll ( )
override

Definition at line 152 of file TotemSD.cc.

References LogDebug, and theHC.

152  {
153  LogDebug("ForwardSim") << "TotemSD: Collection " << theHC->GetName();
154  theHC->PrintAllHits();
155 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
bool TotemSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Implements SensitiveDetector.

Definition at line 82 of file TotemSD.cc.

References CreateNewHit(), CreateNewHitEvo(), edeposit, GetStepInfo(), HitExists(), ParentId, ParticleType, and unitID.

82  {
83 
84  if (aStep == nullptr) {
85  return true;
86  } else {
87  GetStepInfo(aStep);
88  if (HitExists() == false && edeposit>0.) {
89  CreateNewHit();
90  return true;
91  }
92  if (HitExists() == false && (((unitID==1111 || unitID==2222) &&
93  ParentId==0 && ParticleType==2212))) {
95  return true;
96  }
97  }
98  return true;
99 }
int ParentId
Definition: TotemSD.h:121
uint32_t unitID
Definition: TotemSD.h:103
bool HitExists()
Definition: TotemSD.cc:224
float edeposit
Definition: TotemSD.h:109
short ParticleType
Definition: TotemSD.h:116
void CreateNewHitEvo()
Definition: TotemSD.cc:319
void GetStepInfo(G4Step *aStep)
Definition: TotemSD.cc:183
void CreateNewHit()
Definition: TotemSD.cc:266
void TotemSD::ResetForNewPrimary ( )
private

Definition at line 497 of file TotemSD.cc.

References entrancePoint, hitPoint, incidentEnergy, preStepPoint, and SetToLocal().

Referenced by HitExists().

497  {
498 
500  incidentEnergy = preStepPoint->GetKineticEnergy();
501 }
G4ThreeVector entrancePoint
Definition: TotemSD.h:91
float incidentEnergy
Definition: TotemSD.h:92
G4StepPoint * preStepPoint
Definition: TotemSD.h:107
G4ThreeVector SetToLocal(const G4ThreeVector &globalPoint)
Definition: TotemSD.cc:175
G4ThreeVector hitPoint
Definition: TotemSD.h:110
uint32_t TotemSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements SensitiveDetector.

Definition at line 101 of file TotemSD.cc.

References TotemVDetectorOrganization::GetUnitID(), and numberingScheme.

Referenced by GetStepInfo().

101  {
102 
103  return (numberingScheme == nullptr ? 0 : numberingScheme->GetUnitID(aStep));
104 }
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:84
virtual uint32_t GetUnitID(const G4Step *aStep) const =0
G4ThreeVector TotemSD::SetToLocal ( const G4ThreeVector &  globalPoint)
private

Definition at line 175 of file TotemSD.cc.

References preStepPoint.

Referenced by ResetForNewPrimary().

175  {
176 
177  G4ThreeVector localPoint;
178  const G4VTouchable* touch= preStepPoint->GetTouchable();
179  localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
180  return localPoint;
181 }
G4StepPoint * preStepPoint
Definition: TotemSD.h:107
void TotemSD::StoreHit ( TotemG4Hit hit)
private

Definition at line 486 of file TotemSD.cc.

References primID, and theHC.

Referenced by CreateNewHit(), and CreateNewHitEvo().

486  {
487 
488  if (primID<0) return;
489  if (hit == nullptr ) {
490  edm::LogWarning("ForwardSim") << "TotemSD: hit to be stored is NULL !!";
491  return;
492  }
493 
494  theHC->insert( hit );
495 }
TotemG4HitCollection * theHC
Definition: TotemSD.h:96
G4int primID
Definition: TotemSD.h:93
void TotemSD::Summarize ( )
private

Definition at line 503 of file TotemSD.cc.

Referenced by EndOfEvent().

503  {
504 }
void TotemSD::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 161 of file TotemSD.cc.

References clearHits(), eventno, and LogDebug.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

161  {
162  LogDebug("ForwardSim") << " Dispatched BeginOfEvent for " << GetName()
163  << " !" ;
164  clearHits();
165  eventno = (*i)()->GetEventID();
166 }
#define LogDebug(id)
void clearHits() override
Definition: TotemSD.cc:171
int eventno
Definition: TotemSD.h:124
void TotemSD::update ( const ::EndOfEvent )
overrideprivate
void TotemSD::UpdateHit ( )
private

Definition at line 454 of file TotemSD.cc.

References currentHit, Eloss, LogDebug, postStepPoint, previousUnitID, primaryID, primID, TotemG4Hit::setEnergyLoss(), tsID, tSliceID, and unitID.

Referenced by CreateNewHit(), CreateNewHitEvo(), and HitExists().

454  {
455  //
456  if (Eloss > 0.) {
457  // currentHit->addEnergyDeposit(edepositEM,edepositHAD);
458 
459 #ifdef debug
460  LogDebug("ForwardSim") << "G4TotemT1SD updateHit: add eloss " << Eloss
461  << "\nCurrentHit=" << currentHit
462  << ", PostStepPoint="
463  << postStepPoint->GetPosition();
464 #endif
465 
467  }
468  // if(PostStepPoint->GetPhysicalVolume() != CurrentPV){
469  // currentHit->setExitPoint(SetToLocal(postStepPoint->GetPosition()));
470  // Local3DPoint exit=currentHit->exitPoint();
471 /*
472 #ifdef debug
473  LogDebug("ForwardSim") << "G4TotemT1SD updateHit: exit point "
474  << exit.x() << " " << exit.y() << " " << exit.z();
475 // LogDebug("ForwardSim") << "Energy deposit in Unit " << unitID << " em " << edepositEM/MeV
476 // << " hadronic " << edepositHAD/MeV << " MeV";
477 #endif
478 */
479 
480  // buffer for next steps:
481  tsID = tSliceID;
482  primID = primaryID;
484 }
#define LogDebug(id)
uint32_t unitID
Definition: TotemSD.h:103
void setEnergyLoss(float e)
Definition: TotemG4Hit.cc:155
int primaryID
Definition: TotemSD.h:104
uint32_t previousUnitID
Definition: TotemSD.h:103
int tSliceID
Definition: TotemSD.h:104
float Eloss
Definition: TotemSD.h:115
G4StepPoint * postStepPoint
Definition: TotemSD.h:108
TotemG4Hit * currentHit
Definition: TotemSD.h:100
G4int primID
Definition: TotemSD.h:93
int tsID
Definition: TotemSD.h:99

Member Data Documentation

TotemG4Hit* TotemSD::currentHit
private

Definition at line 100 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), HitExists(), and UpdateHit().

G4VPhysicalVolume* TotemSD::currentPV
private

Definition at line 102 of file TotemSD.h.

Referenced by CreateNewHit(), and GetStepInfo().

float TotemSD::edeposit
private

Definition at line 109 of file TotemSD.h.

Referenced by GetStepInfo(), and ProcessHits().

float TotemSD::Eloss
private

Definition at line 115 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), GetStepInfo(), and UpdateHit().

G4ThreeVector TotemSD::entrancePoint
private

Definition at line 91 of file TotemSD.h.

Referenced by ResetForNewPrimary().

int TotemSD::eventno
private

Definition at line 124 of file TotemSD.h.

Referenced by update().

G4int TotemSD::hcID
private

Definition at line 95 of file TotemSD.h.

Referenced by Initialize().

G4ThreeVector TotemSD::hitPoint
private

Definition at line 110 of file TotemSD.h.

Referenced by GetStepInfo(), and ResetForNewPrimary().

float TotemSD::incidentEnergy
private

Definition at line 92 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and ResetForNewPrimary().

TotemVDetectorOrganization* TotemSD::numberingScheme
private

Definition at line 84 of file TotemSD.h.

Referenced by setDetUnitId(), TotemSD(), and ~TotemSD().

float TotemSD::Pabs
private

Definition at line 113 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

int TotemSD::ParentId
private

Definition at line 121 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), GetStepInfo(), and ProcessHits().

short TotemSD::ParticleType
private

Definition at line 116 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), GetStepInfo(), and ProcessHits().

float TotemSD::PhiAtEntry
private

Definition at line 119 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

G4ThreeVector TotemSD::Posizio
private

Definition at line 112 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

G4StepPoint* TotemSD::postStepPoint
private

Definition at line 108 of file TotemSD.h.

Referenced by GetStepInfo(), and UpdateHit().

G4StepPoint* TotemSD::preStepPoint
private

Definition at line 107 of file TotemSD.h.

Referenced by GetStepInfo(), ResetForNewPrimary(), and SetToLocal().

uint32_t TotemSD::previousUnitID
private

Definition at line 103 of file TotemSD.h.

Referenced by HitExists(), and UpdateHit().

int TotemSD::primaryID
private

Definition at line 104 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), GetStepInfo(), HitExists(), and UpdateHit().

G4int TotemSD::primID
private

Definition at line 93 of file TotemSD.h.

Referenced by HitExists(), Initialize(), StoreHit(), and UpdateHit().

TrackingSlaveSD* TotemSD::slave
private

Definition at line 83 of file TotemSD.h.

Referenced by clearHits(), EndOfEvent(), fillHits(), TotemSD(), and ~TotemSD().

TotemG4HitCollection* TotemSD::theHC
private

Definition at line 96 of file TotemSD.h.

Referenced by EndOfEvent(), HitExists(), Initialize(), PrintAll(), and StoreHit().

const SimTrackManager* TotemSD::theManager
private

Definition at line 97 of file TotemSD.h.

float TotemSD::ThetaAtEntry
private

Definition at line 118 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

G4Track* TotemSD::theTrack
private

Definition at line 101 of file TotemSD.h.

Referenced by CreateNewHit(), and GetStepInfo().

float TotemSD::Tof
private

Definition at line 114 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

int TotemSD::tsID
private

Definition at line 99 of file TotemSD.h.

Referenced by HitExists(), Initialize(), and UpdateHit().

double TotemSD::tSlice
private

Definition at line 105 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

int TotemSD::tSliceID
private

Definition at line 104 of file TotemSD.h.

Referenced by CreateNewHit(), GetStepInfo(), HitExists(), and UpdateHit().

uint32_t TotemSD::unitID
private

Definition at line 103 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), GetStepInfo(), HitExists(), ProcessHits(), and UpdateHit().

float TotemSD::Vx
private

Definition at line 122 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

float TotemSD::Vy
private

Definition at line 122 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().

float TotemSD::Vz
private

Definition at line 122 of file TotemSD.h.

Referenced by CreateNewHit(), CreateNewHitEvo(), and GetStepInfo().