LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 26 of file AuxDetSD.h.

Constructor & Destructor Documentation

larg4::AuxDetSD::AuxDetSD ( G4String  name)

Definition at line 33 of file AuxDetSD.cc.

References hitCollection.

33  : G4VSensitiveDetector(name)
34  {
35  hitCollection.clear();
36  }
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:37
larg4::AuxDetSD::~AuxDetSD ( )
virtual

Definition at line 40 of file AuxDetSD.cc.

40 {}

Member Function Documentation

void larg4::AuxDetSD::EndOfEvent ( G4HCofThisEvent )

Definition at line 95 of file AuxDetSD.cc.

References util::counter(), hitCollection, and temphitCollection.

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

Definition at line 33 of file AuxDetSD.h.

References hitCollection.

Referenced by larg4::LArG4DetectorService::doFillEventWithArtHits().

33 { return hitCollection; }
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:37
void larg4::AuxDetSD::Initialize ( G4HCofThisEvent )

Definition at line 42 of file AuxDetSD.cc.

References hitCollection, and temphitCollection.

43  {
44  hitCollection.clear();
45  temphitCollection.clear();
46  }
sim::AuxDetHitCollection hitCollection
Definition: AuxDetSD.h:37
TempHitCollection temphitCollection
Definition: AuxDetSD.h:36
G4bool larg4::AuxDetSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *   
)

Definition at line 48 of file AuxDetSD.cc.

References edep, temphitCollection, and track.

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

Member Data Documentation

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

Definition at line 37 of file AuxDetSD.h.

Referenced by AuxDetSD(), EndOfEvent(), GetHits(), and Initialize().

TempHitCollection larg4::AuxDetSD::temphitCollection
private

Definition at line 36 of file AuxDetSD.h.

Referenced by EndOfEvent(), Initialize(), and ProcessHits().


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