Public Member Functions | Private Attributes | List of all members
larg4::AuxDetSD Class Reference

#include <AuxDetSD.h>

Inheritance diagram for larg4::AuxDetSD:

Public Member Functions

 AuxDetSD (G4String name)
 
virtual ~AuxDetSD ()
 
void Initialize (G4HCofThisEvent *)
 
void EndOfEvent (G4HCofThisEvent *)
 
G4bool ProcessHits (G4Step *, G4TouchableHistory *)
 
const sim::AuxDetHitCollectionGetHits () const
 

Private Attributes

TempHitCollection temphitCollection
 
sim::AuxDetHitCollection hitCollection
 

Detailed Description

Definition at line 24 of file AuxDetSD.h.

Constructor & Destructor Documentation

larg4::AuxDetSD::AuxDetSD ( G4String  name)

Definition at line 33 of file AuxDetSD.cc.

34  : G4VSensitiveDetector(name)
35  {
36  hitCollection.clear();
37  }
static QCString name
Definition: declinfo.cpp:673
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:35
larg4::AuxDetSD::~AuxDetSD ( )
virtual

Definition at line 41 of file AuxDetSD.cc.

41  {
42 
43 }

Member Function Documentation

void larg4::AuxDetSD::EndOfEvent ( G4HCofThisEvent *  )

Definition at line 99 of file AuxDetSD.cc.

99  {
100  if (temphitCollection.size() == 0) return; // No hits so nothing to do
101 #if defined _verbose_
102  std::cout << " EndOfEvent number of temp hits: " << temphitCollection.size() << std::endl;
103  std::cout << " EndOfEvent number of aux hits: " << hitCollection.size() << std::endl;
104 #endif
105  std::sort(temphitCollection.begin(), temphitCollection.end());
106  int geoId = -1;
107  int trackId = -1;
108  unsigned int counter = 0;
109  std::unordered_set<unsigned int> setofIDs;
110 
111  for (auto it = temphitCollection.begin(); it != temphitCollection.end(); it++) {
112 #if defined _verbose_
113  std::cout << "geoID: " << it->GetID() << " track ID: " << it->GetTrackID() << " Edep: " << it->GetEnergyDeposited()
114  << " Parent Id: " << it->GetParentID() << " exit Time: " << it->GetExitT()
115  << " is first: " << it->IsIsfirstinVolume() << " is last: " << it->IsIslastinVolume();
116 #endif
117  if (it->GetID() == geoId && trackId == it->GetTrackID()) // trackid and detector didn't change
118  {
119 #if defined _verbose_
120  std::cout << " A" << std::endl;
121 #endif
122  if (it->GetExitT()) // change exit vector and add to total charge
123  {
124  hitCollection[counter - 1].SetEnergyDeposited(hitCollection[counter - 1].GetEnergyDeposited() + it->GetEnergyDeposited());
125  hitCollection[counter - 1].SetExitX(it->GetExitX());
126  hitCollection[counter - 1].SetExitY(it->GetExitY());
127  hitCollection[counter - 1].SetExitZ(it->GetExitZ());
128  hitCollection[counter - 1].SetExitT(it->GetExitT());
129  } else // just add to total charge
130  {
131  hitCollection[counter - 1].SetEnergyDeposited(hitCollection[counter - 1].GetEnergyDeposited() + it->GetEnergyDeposited());
132  }
133  } else if (setofIDs.find(it->GetParentID()) != setofIDs.end()) {
134  setofIDs.insert(it->GetTrackID());
135 #if defined _verbose_
136  std::cout << " A" << std::endl;
137 #endif
138  hitCollection[counter - 1].SetEnergyDeposited(hitCollection[counter - 1].GetEnergyDeposited() + it->GetEnergyDeposited());
139  } else if (it->GetID() != geoId) // new Detector
140  {
141  geoId = it->GetID();
142  trackId = it->GetTrackID();
143  setofIDs.clear();
144  setofIDs.insert(it->GetTrackID());
145 #if defined _verbose_
146  std::cout << " N" << std::endl;
147 #endif
148  counter++;
149  hitCollection.push_back(sim::AuxDetHit(it->GetID(),
150  it->GetTrackID(),
151  it->GetEnergyDeposited(),
152  it->GetEntryX(),
153  it->GetEntryY(),
154  it->GetEntryZ(),
155  it->GetEntryT(),
156  it->GetExitX(),
157  it->GetExitY(),
158  it->GetExitZ(),
159  it->GetExitT(),
160  it->GetExitMomentumX(),
161  it->GetExitMomentumY(),
162  it->GetExitMomentumZ()
163  ));
164  } else {
165  trackId = it->GetTrackID();
166 #if defined _verbose_
167  std::cout << " N" << std::endl;
168 #endif
169  counter++;
170  setofIDs.clear();
171  setofIDs.insert(it->GetTrackID());
172  hitCollection.push_back(sim::AuxDetHit(it->GetID(),
173  it->GetTrackID(),
174  it->GetEnergyDeposited(),
175  it->GetEntryX(),
176  it->GetEntryY(),
177  it->GetEntryZ(),
178  it->GetEntryT(),
179  it->GetExitX(),
180  it->GetExitY(),
181  it->GetExitZ(),
182  it->GetExitT(),
183  it->GetExitMomentumX(),
184  it->GetExitMomentumY(),
185  it->GetExitMomentumZ()
186  ));
187  }
188  }
189 #if defined _verbose_
190  std::cout << "Number of AuxDetHits: " << counter << std::endl;
191 #endif
192  } // EndOfEvent
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:35
TempHitCollection temphitCollection
Definition: AuxDetSD.h:34
QTextStream & endl(QTextStream &s)
const sim::AuxDetHitCollection& larg4::AuxDetSD::GetHits ( ) const
inline

Definition at line 31 of file AuxDetSD.h.

31 { return hitCollection; }
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:35
void larg4::AuxDetSD::Initialize ( G4HCofThisEvent *  )

Definition at line 45 of file AuxDetSD.cc.

45  {
46  hitCollection.clear();
47  temphitCollection.clear();
48 }
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:35
TempHitCollection temphitCollection
Definition: AuxDetSD.h:34
G4bool larg4::AuxDetSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *   
)

Definition at line 50 of file AuxDetSD.cc.

50  {
51  G4double edep = step->GetTotalEnergyDeposit() / CLHEP::MeV;
52  if (edep == 0.) return false;
53  G4Track * track = step->GetTrack();
54  const unsigned int trackID = track->GetTrackID();
55  unsigned int ID = step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo();
56  TempHit tmpHit = TempHit(
57  ID,
58  trackID,
59  track->GetParentID(),
60  step->IsFirstStepInVolume(),
61  step->IsLastStepInVolume(),
62  edep,
63  step->GetPreStepPoint()->GetPosition().getX() / CLHEP::cm,
64  step->GetPreStepPoint()->GetPosition().getY() / CLHEP::cm,
65  step->GetPreStepPoint()->GetPosition().getZ() / CLHEP::cm,
66  step->GetPreStepPoint()->GetGlobalTime() / CLHEP::ns,
67  step->GetPostStepPoint()->GetPosition().getX() / CLHEP::cm,
68  step->GetPostStepPoint()->GetPosition().getY() / CLHEP::cm,
69  step->GetPostStepPoint()->GetPosition().getZ() / CLHEP::cm,
70  step->GetPostStepPoint()->GetGlobalTime() / CLHEP::ns,
71  step->GetPostStepPoint()->GetMomentum().getX() / CLHEP::GeV,
72  step->GetPostStepPoint()->GetMomentum().getY() / CLHEP::GeV,
73  step->GetPostStepPoint()->GetMomentum().getZ() / CLHEP::GeV
74  );
75  temphitCollection.push_back(tmpHit);
76 
77  /*
78  sim::AuxDetHit newHit = sim::AuxDetHit(ID,
79  trackID,
80  edep,
81  step->GetPreStepPoint()->GetPosition().getX()/CLHEP::cm,
82  step->GetPreStepPoint()->GetPosition().getY()/CLHEP::cm,
83  step->GetPreStepPoint()->GetPosition().getZ()/CLHEP::cm,
84  step->GetPreStepPoint()->GetGlobalTime()/CLHEP::ns,
85  step->GetPostStepPoint()->GetPosition().getX()/CLHEP::cm,
86  step->GetPostStepPoint()->GetPosition().getY()/CLHEP::cm,
87  step->GetPostStepPoint()->GetPosition().getZ()/CLHEP::cm,
88  step->GetPostStepPoint()->GetGlobalTime()/CLHEP::ns,
89  step->GetPostStepPoint()->GetMomentum().getX()/CLHEP::GeV,
90  step->GetPostStepPoint()->GetMomentum().getY()/CLHEP::GeV,
91  step->GetPostStepPoint()->GetMomentum().getZ()/CLHEP::GeV
92  );
93  hitCollection.push_back(newHit);
94  */
95  return true;
96 }
static constexpr double cm
Definition: Units.h:68
unsigned int ID
static constexpr double MeV
Definition: Units.h:129
TempHitCollection temphitCollection
Definition: AuxDetSD.h:34
static constexpr double GeV
Definition: Units.h:28
QAsciiDict< Entry > ns

Member Data Documentation

sim::AuxDetHitCollection larg4::AuxDetSD::hitCollection
private

Definition at line 35 of file AuxDetSD.h.

TempHitCollection larg4::AuxDetSD::temphitCollection
private

Definition at line 34 of file AuxDetSD.h.


The documentation for this class was generated from the following files: