CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void clear ()
 
virtual void DrawAll ()
 
virtual void EndOfEvent (G4HCofThisEvent *eventHC)
 
void fillHits (edm::PSimHitContainer &, std::string use)
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual void PrintAll ()
 
virtual bool ProcessHits (G4Step *, G4TouchableHistory *)
 
virtual uint32_t setDetUnitId (G4Step *)
 
 TotemSD (std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
virtual ~TotemSD ()
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (const std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point)
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual ~SensitiveDetector ()
 
- 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

virtual void clearHits ()
 
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 *)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *)
 
void UpdateHit ()
 

Private Attributes

TotemG4HitcurrentHit
 
G4VPhysicalVolume * currentPV
 
float edeposit
 
float Eloss
 
G4ThreeVector entrancePoint
 
int eventno
 
G4int hcID
 
G4ThreeVector hitPoint
 
float incidentEnergy
 
std::string name
 
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

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- 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 42 of file TotemSD.h.

Constructor & Destructor Documentation

TotemSD::TotemSD ( 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 SensitiveDetector::AssignSD(), ecaldqm::collectionName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), LogDebug, SensitiveDetectorCatalog::logicalNames(), numberingScheme, SensitiveDetector::Register(), and slave.

50  :
52  hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
54  postStepPoint(0), eventno(0){
55 
56  //Add Totem Sentitive Detector Names
57  collectionName.insert(name);
58 
59  //Parameters
60  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("TotemSD");
61  int verbn = m_p.getUntrackedParameter<int>("Verbosity");
62 
63  SetVerboseLevel(verbn);
64  LogDebug("ForwardSim")
65  << "*******************************************************\n"
66  << "* *\n"
67  << "* Constructing a TotemSD with name " << name << "\n"
68  << "* *\n"
69  << "*******************************************************";
70 
71  slave = new TrackingSlaveSD(name);
72 
73  //
74  // Now attach the right detectors (LogicalVolumes) to me
75  //
76  const std::vector<std::string>& lvNames = clg.logicalNames(name);
77  this->Register();
78  for (std::vector<std::string>::const_iterator it=lvNames.begin();
79  it !=lvNames.end(); it++) {
80  this->AssignSD(*it);
81  edm::LogInfo("ForwardSim") << "TotemSD : Assigns SD to LV " << (*it);
82  }
83 
84  if (name == "TotemHitsT1") {
86  } else if (name == "TotemHitsT2Si") {
88  } else if (name == "TotemHitsT2Gem") {
90  } else if (name == "TotemHitsRP") {
92  } else {
93  edm::LogWarning("ForwardSim") << "TotemSD: ReadoutName not supported\n";
94  }
95 
96  edm::LogInfo("ForwardSim") << "TotemSD: Instantiation completed";
97 }
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
uint32_t unitID
Definition: TotemSD.h:105
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
uint32_t previousUnitID
Definition: TotemSD.h:105
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:85
G4int hcID
Definition: TotemSD.h:97
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
virtual void AssignSD(const std::string &vname)
G4StepPoint * preStepPoint
Definition: TotemSD.h:109
std::string const collectionName[nCollections]
Definition: Collections.h:45
G4StepPoint * postStepPoint
Definition: TotemSD.h:110
TotemG4Hit * currentHit
Definition: TotemSD.h:102
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:104
SensitiveTkDetector(std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
TrackingSlaveSD * slave
Definition: TotemSD.h:84
G4Track * theTrack
Definition: TotemSD.h:103
int eventno
Definition: TotemSD.h:126
const SimTrackManager * theManager
Definition: TotemSD.h:99
std::string name
Definition: TotemSD.h:96
TotemSD::~TotemSD ( )
virtual

Definition at line 99 of file TotemSD.cc.

References numberingScheme, and slave.

99  {
100  if (slave) delete slave;
101  if (numberingScheme) delete numberingScheme;
102 }
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:85
TrackingSlaveSD * slave
Definition: TotemSD.h:84

Member Function Documentation

void TotemSD::clear ( void  )
virtual

Definition at line 168 of file TotemSD.cc.

168  {
169 }
void TotemSD::clearHits ( )
privatevirtual

Implements SensitiveDetector.

Definition at line 193 of file TotemSD.cc.

References TrackingSlaveSD::Initialize(), and slave.

Referenced by update().

193  {
194  slave->Initialize();
195 }
virtual void Initialize()
TrackingSlaveSD * slave
Definition: TotemSD.h:84
void TotemSD::CreateNewHit ( )
private

Definition at line 288 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().

288  {
289 
290 #ifdef debug
291  LogDebug("ForwardSim") << "TotemSD CreateNewHit for"
292  << " PV " << currentPV->GetName()
293  << " PVid = " << currentPV->GetCopyNo()
294  << " MVid = " << currentPV->GetMother()->GetCopyNo()
295  << " Unit " << unitID << "\n"
296  << " primary " << primaryID
297  << " time slice " << tSliceID
298  << " For Track " << theTrack->GetTrackID()
299  << " which is a "
300  << theTrack->GetDefinition()->GetParticleName();
301 
302  if (theTrack->GetTrackID()==1) {
303  LogDebug("ForwardSim") << " of energy " << theTrack->GetTotalEnergy();
304  } else {
305  LogDebug("ForwardSim") << " daughter of part. " << theTrack->GetParentID();
306  }
307 
308  cout << " and created by " ;
309  if (theTrack->GetCreatorProcess()!=NULL)
310  LogDebug("ForwardSim") << theTrack->GetCreatorProcess()->GetProcessName() ;
311  else
312  LogDebug("ForwardSim") << "NO process";
313 #endif
314 
315 
316  currentHit = new TotemG4Hit;
321 
328 
329  currentHit->setEntry(Posizio.x(),Posizio.y(),Posizio.z());
330 
332  currentHit->setVx(Vx);
333  currentHit->setVy(Vy);
334  currentHit->setVz(Vz);
335 
336  UpdateHit();
337 
339 }
#define LogDebug(id)
void setVz(float p)
Definition: TotemG4Hit.cc:183
int ParentId
Definition: TotemSD.h:123
void setPabs(float e)
Definition: TotemG4Hit.cc:153
uint32_t unitID
Definition: TotemSD.h:105
float Pabs
Definition: TotemSD.h:115
G4ThreeVector Posizio
Definition: TotemSD.h:114
float Tof
Definition: TotemSD.h:116
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:107
int primaryID
Definition: TotemSD.h:106
float incidentEnergy
Definition: TotemSD.h:93
#define NULL
Definition: scimark2.h:8
int tSliceID
Definition: TotemSD.h:106
void setVy(float p)
Definition: TotemG4Hit.cc:180
void setTimeSlice(double d)
Definition: TotemG4Hit.cc:141
float Eloss
Definition: TotemSD.h:117
float Vx
Definition: TotemSD.h:124
void setVx(float p)
Definition: TotemG4Hit.cc:177
void setParentId(int p)
Definition: TotemG4Hit.cc:174
TotemG4Hit * currentHit
Definition: TotemSD.h:102
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:104
void setIncidentEnergy(double e)
Definition: TotemG4Hit.cc:132
short ParticleType
Definition: TotemSD.h:118
void setThetaAtEntry(float t)
Definition: TotemG4Hit.cc:161
float PhiAtEntry
Definition: TotemSD.h:121
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:124
void StoreHit(TotemG4Hit *)
Definition: TotemSD.cc:508
G4Track * theTrack
Definition: TotemSD.h:103
void UpdateHit()
Definition: TotemSD.cc:476
tuple cout
Definition: gather_cfg.py:121
float Vy
Definition: TotemSD.h:124
float ThetaAtEntry
Definition: TotemSD.h:120
void TotemSD::CreateNewHitEvo ( )
private

Definition at line 341 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().

341  {
342 
343 // LogDebug("ForwardSim") << "INSIDE CREATE NEW HIT EVO ";
344 
345  currentHit = new TotemG4Hit;
350 
357 
358  // LogDebug("ForwardSim") << Posizio.x() << " " << Posizio.y() << " " << Posizio.z();
359 
361  currentHit->setVx(Vx);
362  currentHit->setVy(Vy);
363  currentHit->setVz(Vz);
364 
365  G4ThreeVector _PosizioEvo;
366  int flagAcc=0;
367  _PosizioEvo=PosizioEvo(Posizio,Vx,Vy,Vz,Pabs,flagAcc);
368 
369  if(flagAcc==1){
370  currentHit->setEntry(_PosizioEvo.x(),_PosizioEvo.y(),_PosizioEvo.z());
371 
372  // if(flagAcc==1)
373  UpdateHit();
374 
376  }
377  // LogDebug("ForwardSim") << "STORED HIT IN: " << unitID;
378 }
void setVz(float p)
Definition: TotemG4Hit.cc:183
int ParentId
Definition: TotemSD.h:123
void setPabs(float e)
Definition: TotemG4Hit.cc:153
uint32_t unitID
Definition: TotemSD.h:105
float Pabs
Definition: TotemSD.h:115
G4ThreeVector Posizio
Definition: TotemSD.h:114
float Tof
Definition: TotemSD.h:116
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:107
int primaryID
Definition: TotemSD.h:106
float incidentEnergy
Definition: TotemSD.h:93
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:380
float Eloss
Definition: TotemSD.h:117
float Vx
Definition: TotemSD.h:124
void setVx(float p)
Definition: TotemG4Hit.cc:177
void setParentId(int p)
Definition: TotemG4Hit.cc:174
TotemG4Hit * currentHit
Definition: TotemSD.h:102
void setIncidentEnergy(double e)
Definition: TotemG4Hit.cc:132
short ParticleType
Definition: TotemSD.h:118
void setThetaAtEntry(float t)
Definition: TotemG4Hit.cc:161
float PhiAtEntry
Definition: TotemSD.h:121
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:124
void StoreHit(TotemG4Hit *)
Definition: TotemSD.cc:508
void UpdateHit()
Definition: TotemSD.cc:476
float Vy
Definition: TotemSD.h:124
float ThetaAtEntry
Definition: TotemSD.h:120
void TotemSD::DrawAll ( )
virtual

Definition at line 171 of file TotemSD.cc.

171  {
172 }
void TotemSD::EndOfEvent ( G4HCofThisEvent *  eventHC)
virtual

Reimplemented from SensitiveDetector.

Definition at line 141 of file TotemSD.cc.

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

141  {
142 
143  // here we loop over transient hits and make them persistent
144  for (int j=0; j<theHC->entries() && j<15000; j++) {
145  TotemG4Hit* aHit = (*theHC)[j];
146 #ifdef ddebug
147  LogDebug("ForwardSim") << "HIT NUMERO " << j << "unit ID = "
148  << aHit->getUnitID() << "\n"
149  << " " << "enrty z "
150  << aHit->getEntry().z() << "\n"
151  << " " << "theta "
152  << aHit->getThetaAtEntry() << "\n";
153 #endif
154  Local3DPoint theExitPoint(0,0,0);
155  Local3DPoint Entrata(aHit->getEntry().x(),
156  aHit->getEntry().y(),
157  aHit->getEntry().z());
158  slave->processHits(PSimHit(Entrata,theExitPoint,
159  aHit->getPabs(), aHit->getTof(),
160  aHit->getEnergyLoss(), aHit->getParticleType(),
161  aHit->getUnitID(), aHit->getTrackID(),
162  aHit->getThetaAtEntry(),aHit->getPhiAtEntry()));
163 
164  }
165  Summarize();
166 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
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 j
Definition: DBlmapReader.cc:9
int getTrackID() const
Definition: TotemG4Hit.cc:134
void Summarize()
Definition: TotemSD.cc:525
uint32_t getUnitID() const
Definition: TotemG4Hit.cc:137
TrackingSlaveSD * slave
Definition: TotemSD.h:84
int getParticleType() const
Definition: TotemG4Hit.cc:151
virtual bool processHits(const PSimHit &)
float getThetaAtEntry() const
Definition: TotemG4Hit.cc:158
void TotemSD::fillHits ( edm::PSimHitContainer c,
std::string  use 
)
virtual

Implements SensitiveTkDetector.

Definition at line 179 of file TotemSD.cc.

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

179  {
180  if (slave->name() == n) c=slave->hits();
181 }
std::string name() const
std::vector< PSimHit > & hits()
TrackingSlaveSD * slave
Definition: TotemSD.h:84
void TotemSD::GetStepInfo ( G4Step *  aStep)
private

Definition at line 205 of file TotemSD.cc.

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

Referenced by ProcessHits().

205  {
206 
207  preStepPoint = aStep->GetPreStepPoint();
208  postStepPoint= aStep->GetPostStepPoint();
209  theTrack = aStep->GetTrack();
210  //Local3DPoint theEntryPoint = SensitiveDetector::InitialStepPosition(aStep,LocalCoordinates);
211  //Local3DPoint theExitPoint = SensitiveDetector::FinalStepPosition(aStep,LocalCoordinates);
212  hitPoint = preStepPoint->GetPosition();
213  currentPV = preStepPoint->GetPhysicalVolume();
214 
215  // double weight = 1;
216  G4String name = currentPV->GetName();
217  name.assign(name,0,4);
218  G4String particleType = theTrack->GetDefinition()->GetParticleName();
219  edeposit = aStep->GetTotalEnergyDeposit();
220 
221  tSlice = (postStepPoint->GetGlobalTime() )/nanosecond;
222  tSliceID = (int) tSlice;
223  unitID = setDetUnitId(aStep);
224 #ifdef debug
225  LogDebug("ForwardSim") << "UNITa " << unitID;
226 #endif
227  primaryID = theTrack->GetTrackID();
228 
229 
230  Posizio = hitPoint;
231  Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
232  Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
233 
234  Eloss = aStep->GetTotalEnergyDeposit()/GeV;
235  ParticleType = theTrack->GetDefinition()->GetPDGEncoding();
236 
237  ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
238  PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
239 
240  ParentId = theTrack->GetParentID();
241  Vx = theTrack->GetVertexPosition().x();
242  Vy = theTrack->GetVertexPosition().y();
243  Vz = theTrack->GetVertexPosition().z();
244 }
#define LogDebug(id)
int ParentId
Definition: TotemSD.h:123
uint32_t unitID
Definition: TotemSD.h:105
const double GeV
Definition: MathUtil.h:16
float Pabs
Definition: TotemSD.h:115
G4ThreeVector Posizio
Definition: TotemSD.h:114
float Tof
Definition: TotemSD.h:116
double tSlice
Definition: TotemSD.h:107
int primaryID
Definition: TotemSD.h:106
virtual uint32_t setDetUnitId(G4Step *)
Definition: TotemSD.cc:123
int tSliceID
Definition: TotemSD.h:106
G4StepPoint * preStepPoint
Definition: TotemSD.h:109
float Eloss
Definition: TotemSD.h:117
float edeposit
Definition: TotemSD.h:111
float Vx
Definition: TotemSD.h:124
G4ThreeVector hitPoint
Definition: TotemSD.h:112
G4StepPoint * postStepPoint
Definition: TotemSD.h:110
G4VPhysicalVolume * currentPV
Definition: TotemSD.h:104
short ParticleType
Definition: TotemSD.h:118
float PhiAtEntry
Definition: TotemSD.h:121
float Vz
Definition: TotemSD.h:124
G4Track * theTrack
Definition: TotemSD.h:103
float Vy
Definition: TotemSD.h:124
float ThetaAtEntry
Definition: TotemSD.h:120
std::string name
Definition: TotemSD.h:96
bool TotemSD::HitExists ( )
private

Definition at line 246 of file TotemSD.cc.

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

Referenced by ProcessHits().

246  {
247 
248  if (primaryID<1) {
249  edm::LogWarning("ForwardSim") << "***** TotemSD error: primaryID = "
250  << primaryID
251  << " maybe detector name changed";
252  }
253 
254  // Update if in the same detector, time-slice and for same track
255  // if (primaryID == primID && tSliceID == tsID && unitID==previousUnitID) {
256  if (tSliceID == tsID && unitID==previousUnitID) {
257  UpdateHit();
258  return true;
259  }
260 
261  // Reset entry point for new primary
262  if (primaryID != primID)
264 
265  //look in the HitContainer whether a hit with the same primID, unitID,
266  //tSliceID already exists:
267 
268  bool found = false;
269 
270  for (int j=0; j<theHC->entries()&&!found; j++) {
271  TotemG4Hit* aPreviousHit = (*theHC)[j];
272  if (aPreviousHit->getTrackID() == primaryID &&
273  aPreviousHit->getTimeSliceID() == tSliceID &&
274  aPreviousHit->getUnitID() == unitID ) {
275  currentHit = aPreviousHit;
276  found = true;
277  }
278  }
279 
280  if (found) {
281  UpdateHit();
282  return true;
283  } else {
284  return false;
285  }
286 }
uint32_t unitID
Definition: TotemSD.h:105
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
int primaryID
Definition: TotemSD.h:106
uint32_t previousUnitID
Definition: TotemSD.h:105
int tSliceID
Definition: TotemSD.h:106
void ResetForNewPrimary()
Definition: TotemSD.cc:519
int j
Definition: DBlmapReader.cc:9
int getTrackID() const
Definition: TotemG4Hit.cc:134
int getTimeSliceID() const
Definition: TotemG4Hit.cc:142
TotemG4Hit * currentHit
Definition: TotemSD.h:102
uint32_t getUnitID() const
Definition: TotemG4Hit.cc:137
G4int primID
Definition: TotemSD.h:94
void UpdateHit()
Definition: TotemSD.cc:476
int tsID
Definition: TotemSD.h:101
void TotemSD::Initialize ( G4HCofThisEvent *  HCE)
virtual

Reimplemented from SensitiveDetector.

Definition at line 128 of file TotemSD.cc.

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

128  {
129 
130  LogDebug("ForwardSim") << "TotemSD : Initialize called for " << name;
131 
133  if (hcID<0)
134  hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
135  HCE->AddHitsCollection(hcID, theHC);
136 
137  tsID = -2;
138  primID = -2;
139 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
G4int hcID
Definition: TotemSD.h:97
std::string const collectionName[nCollections]
Definition: Collections.h:45
G4int primID
Definition: TotemSD.h:94
int tsID
Definition: TotemSD.h:101
G4THitsCollection< TotemG4Hit > TotemG4HitCollection
std::string name
Definition: TotemSD.h:96
G4ThreeVector TotemSD::PosizioEvo ( const G4ThreeVector &  Pos,
double  vx,
double  vy,
double  vz,
double  pabs,
int &  accettanza 
)
private

Definition at line 380 of file TotemSD.cc.

References j, and mathSSE::sqrt().

Referenced by CreateNewHitEvo().

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

Definition at line 174 of file TotemSD.cc.

References LogDebug, and theHC.

174  {
175  LogDebug("ForwardSim") << "TotemSD: Collection " << theHC->GetName();
176  theHC->PrintAllHits();
177 }
#define LogDebug(id)
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
bool TotemSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
virtual

Implements SensitiveDetector.

Definition at line 104 of file TotemSD.cc.

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

104  {
105 
106  if (aStep == NULL) {
107  return true;
108  } else {
109  GetStepInfo(aStep);
110  if (HitExists() == false && edeposit>0.) {
111  CreateNewHit();
112  return true;
113  }
114  if (HitExists() == false && (((unitID==1111 || unitID==2222) &&
115  ParentId==0 && ParticleType==2212))) {
116  CreateNewHitEvo();
117  return true;
118  }
119  }
120  return true;
121 }
int ParentId
Definition: TotemSD.h:123
uint32_t unitID
Definition: TotemSD.h:105
#define NULL
Definition: scimark2.h:8
bool HitExists()
Definition: TotemSD.cc:246
float edeposit
Definition: TotemSD.h:111
short ParticleType
Definition: TotemSD.h:118
void CreateNewHitEvo()
Definition: TotemSD.cc:341
void GetStepInfo(G4Step *aStep)
Definition: TotemSD.cc:205
void CreateNewHit()
Definition: TotemSD.cc:288
void TotemSD::ResetForNewPrimary ( )
private

Definition at line 519 of file TotemSD.cc.

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

Referenced by HitExists().

519  {
520 
522  incidentEnergy = preStepPoint->GetKineticEnergy();
523 }
G4ThreeVector entrancePoint
Definition: TotemSD.h:92
float incidentEnergy
Definition: TotemSD.h:93
G4StepPoint * preStepPoint
Definition: TotemSD.h:109
G4ThreeVector SetToLocal(const G4ThreeVector &globalPoint)
Definition: TotemSD.cc:197
G4ThreeVector hitPoint
Definition: TotemSD.h:112
uint32_t TotemSD::setDetUnitId ( G4Step *  aStep)
virtual

Implements SensitiveDetector.

Definition at line 123 of file TotemSD.cc.

References TotemVDetectorOrganization::GetUnitID(), and numberingScheme.

Referenced by GetStepInfo().

123  {
124 
125  return (numberingScheme == 0 ? 0 : numberingScheme->GetUnitID(aStep));
126 }
virtual uint32_t GetUnitID(const G4Step *aStep) const =0
TotemVDetectorOrganization * numberingScheme
Definition: TotemSD.h:85
G4ThreeVector TotemSD::SetToLocal ( const G4ThreeVector &  globalPoint)
private

Definition at line 197 of file TotemSD.cc.

References preStepPoint.

Referenced by ResetForNewPrimary().

197  {
198 
199  G4ThreeVector localPoint;
200  const G4VTouchable* touch= preStepPoint->GetTouchable();
201  localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
202  return localPoint;
203 }
G4StepPoint * preStepPoint
Definition: TotemSD.h:109
void TotemSD::StoreHit ( TotemG4Hit hit)
private

Definition at line 508 of file TotemSD.cc.

References primID, and theHC.

Referenced by CreateNewHit(), and CreateNewHitEvo().

508  {
509 
510  if (primID<0) return;
511  if (hit == 0 ) {
512  edm::LogWarning("ForwardSim") << "TotemSD: hit to be stored is NULL !!";
513  return;
514  }
515 
516  theHC->insert( hit );
517 }
TotemG4HitCollection * theHC
Definition: TotemSD.h:98
G4int primID
Definition: TotemSD.h:94
void TotemSD::Summarize ( )
private

Definition at line 525 of file TotemSD.cc.

Referenced by EndOfEvent().

525  {
526 }
void TotemSD::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 183 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().

183  {
184  LogDebug("ForwardSim") << " Dispatched BeginOfEvent for " << GetName()
185  << " !" ;
186  clearHits();
187  eventno = (*i)()->GetEventID();
188 }
#define LogDebug(id)
virtual void clearHits()
Definition: TotemSD.cc:193
int eventno
Definition: TotemSD.h:126
void TotemSD::update ( const ::EndOfEvent )
private
void TotemSD::UpdateHit ( )
private

Definition at line 476 of file TotemSD.cc.

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

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

476  {
477  //
478  if (Eloss > 0.) {
479  // currentHit->addEnergyDeposit(edepositEM,edepositHAD);
480 
481 #ifdef debug
482  LogDebug("ForwardSim") << "G4TotemT1SD updateHit: add eloss " << Eloss
483  << "\nCurrentHit=" << currentHit
484  << ", PostStepPoint="
485  << postStepPoint->GetPosition();
486 #endif
487 
489  }
490  // if(PostStepPoint->GetPhysicalVolume() != CurrentPV){
491  // currentHit->setExitPoint(SetToLocal(postStepPoint->GetPosition()));
492  // Local3DPoint exit=currentHit->exitPoint();
493 /*
494 #ifdef debug
495  LogDebug("ForwardSim") << "G4TotemT1SD updateHit: exit point "
496  << exit.x() << " " << exit.y() << " " << exit.z();
497 // LogDebug("ForwardSim") << "Energy deposit in Unit " << unitID << " em " << edepositEM/MeV
498 // << " hadronic " << edepositHAD/MeV << " MeV";
499 #endif
500 */
501 
502  // buffer for next steps:
503  tsID = tSliceID;
504  primID = primaryID;
506 }
#define LogDebug(id)
uint32_t unitID
Definition: TotemSD.h:105
void setEnergyLoss(float e)
Definition: TotemG4Hit.cc:155
int primaryID
Definition: TotemSD.h:106
uint32_t previousUnitID
Definition: TotemSD.h:105
int tSliceID
Definition: TotemSD.h:106
float Eloss
Definition: TotemSD.h:117
G4StepPoint * postStepPoint
Definition: TotemSD.h:110
TotemG4Hit * currentHit
Definition: TotemSD.h:102
G4int primID
Definition: TotemSD.h:94
int tsID
Definition: TotemSD.h:101

Member Data Documentation

TotemG4Hit* TotemSD::currentHit
private

Definition at line 102 of file TotemSD.h.

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

G4VPhysicalVolume* TotemSD::currentPV
private

Definition at line 104 of file TotemSD.h.

Referenced by CreateNewHit(), and GetStepInfo().

float TotemSD::edeposit
private

Definition at line 111 of file TotemSD.h.

Referenced by GetStepInfo(), and ProcessHits().

float TotemSD::Eloss
private

Definition at line 117 of file TotemSD.h.

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

G4ThreeVector TotemSD::entrancePoint
private

Definition at line 92 of file TotemSD.h.

Referenced by ResetForNewPrimary().

int TotemSD::eventno
private

Definition at line 126 of file TotemSD.h.

Referenced by update().

G4int TotemSD::hcID
private

Definition at line 97 of file TotemSD.h.

Referenced by Initialize().

G4ThreeVector TotemSD::hitPoint
private

Definition at line 112 of file TotemSD.h.

Referenced by GetStepInfo(), and ResetForNewPrimary().

float TotemSD::incidentEnergy
private

Definition at line 93 of file TotemSD.h.

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

std::string TotemSD::name
private
TotemVDetectorOrganization* TotemSD::numberingScheme
private

Definition at line 85 of file TotemSD.h.

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

float TotemSD::Pabs
private

Definition at line 115 of file TotemSD.h.

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

int TotemSD::ParentId
private

Definition at line 123 of file TotemSD.h.

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

short TotemSD::ParticleType
private

Definition at line 118 of file TotemSD.h.

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

float TotemSD::PhiAtEntry
private

Definition at line 121 of file TotemSD.h.

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

G4ThreeVector TotemSD::Posizio
private

Definition at line 114 of file TotemSD.h.

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

G4StepPoint* TotemSD::postStepPoint
private

Definition at line 110 of file TotemSD.h.

Referenced by GetStepInfo(), and UpdateHit().

G4StepPoint* TotemSD::preStepPoint
private

Definition at line 109 of file TotemSD.h.

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

uint32_t TotemSD::previousUnitID
private

Definition at line 105 of file TotemSD.h.

Referenced by HitExists(), and UpdateHit().

int TotemSD::primaryID
private

Definition at line 106 of file TotemSD.h.

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

G4int TotemSD::primID
private

Definition at line 94 of file TotemSD.h.

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

TrackingSlaveSD* TotemSD::slave
private

Definition at line 84 of file TotemSD.h.

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

TotemG4HitCollection* TotemSD::theHC
private

Definition at line 98 of file TotemSD.h.

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

const SimTrackManager* TotemSD::theManager
private

Definition at line 99 of file TotemSD.h.

float TotemSD::ThetaAtEntry
private

Definition at line 120 of file TotemSD.h.

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

G4Track* TotemSD::theTrack
private

Definition at line 103 of file TotemSD.h.

Referenced by CreateNewHit(), and GetStepInfo().

float TotemSD::Tof
private

Definition at line 116 of file TotemSD.h.

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

int TotemSD::tsID
private

Definition at line 101 of file TotemSD.h.

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

double TotemSD::tSlice
private

Definition at line 107 of file TotemSD.h.

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

int TotemSD::tSliceID
private

Definition at line 106 of file TotemSD.h.

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

uint32_t TotemSD::unitID
private

Definition at line 105 of file TotemSD.h.

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

float TotemSD::Vx
private

Definition at line 124 of file TotemSD.h.

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

float TotemSD::Vy
private

Definition at line 124 of file TotemSD.h.

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

float TotemSD::Vz
private

Definition at line 124 of file TotemSD.h.

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