Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::garg4::AuxDetAction Class Reference

list of energy deposits from Geant4 More...

#include <AuxDetAction.h>

Inheritance diagram for gar::garg4::AuxDetAction:

Public Member Functions

 AuxDetAction (CLHEP::HepRandomEngine *engine, fhicl::ParameterSet const &pset)
 
virtual ~AuxDetAction ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void BeginOfEventAction (const G4Event *)
 
void EndOfEventAction (const G4Event *)
 
void PreTrackingAction (const G4Track *)
 
void PostTrackingAction (const G4Track *)
 
void SteppingAction (const G4Step *)
 
std::vector< gar::sdp::LArDeposit > const & LArDeposits () const
 
std::vector< gar::sdp::CaloDeposit > const & CaloDeposits () const
 
std::vector< gar::sdp::CaloDeposit > const & TrackerScDeposits () const
 
std::vector< gar::sdp::CaloDeposit > const & MuIDDeposits () const
 

Private Member Functions

void LArSteppingAction (const G4Step *)
 
void ECALSteppingAction (const G4Step *)
 
void TrackerScSteppingAction (const G4Step *)
 
void MuIDSteppingAction (const G4Step *)
 
void AddHits (const std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_hits, std::vector< gar::sdp::CaloDeposit > &fDeposits)
 
std::string GetVolumeName (const G4Track *track)
 
unsigned int GetDetNumber (std::string volname)
 
unsigned int GetStaveNumber (std::string volname)
 
unsigned int GetModuleNumber (std::string volname)
 
unsigned int GetLayerNumber (std::string volname)
 
unsigned int GetSliceNumber (std::string volname)
 
G4ThreeVector globalToLocal (const G4Step *step, const G4ThreeVector &glob)
 
G4ThreeVector localToGlobal (const G4Step *step, const G4ThreeVector &loc)
 
float GetStepEnergy (const G4Step *step, bool birks)
 
float birksAttenuation (const G4Step *step)
 

Private Attributes

double fLArEnergyCut
 The minimum energy in GeV for a particle to be included in the list. More...
 
std::string fLArMaterial
 Material for the LArTPC. More...
 
std::vector< std::stringfLArVolumeName
 volume we will record energy depositions in More...
 
std::string fECALMaterial
 Material for the ECAL. More...
 
std::vector< std::stringfECALVolumeName
 volume we will record energy depositions in More...
 
std::string fTrackerScMaterial
 Material for the TrackerSc (GArLite) More...
 
std::vector< std::stringfTrackerScVolumeName
 volume we will record energy depositions in More...
 
std::string fMuIDMaterial
 Material for the MuID. More...
 
std::vector< std::stringfMuIDVolumeName
 volume we will record energy depositions in More...
 
bool fApplyBirksLaw
 
std::vector< gar::sdp::LArDepositfLArDeposits
 energy fDeposits for the LArTPC More...
 
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_ECALDeposits
 
std::vector< gar::sdp::CaloDepositfECALDeposits
 energy fDeposits for the ECAL More...
 
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_TrackerScDeposits
 
std::vector< gar::sdp::CaloDepositfTrackerScDeposits
 energy fDeposits for the TrackerSc More...
 
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_MuIDDeposits
 
std::vector< gar::sdp::CaloDepositfMuIDDeposits
 energy fDeposits for the MuID More...
 
const gar::geo::GeometryCorefGeo
 geometry information More...
 
const detinfo::DetectorPropertiesfDetProp
 detector properties More...
 
const gar::geo::seg::MinervaSegmentationAlgfMinervaSegAlg
 

Detailed Description

list of energy deposits from Geant4

Definition at line 39 of file AuxDetAction.h.

Constructor & Destructor Documentation

gar::garg4::AuxDetAction::AuxDetAction ( CLHEP::HepRandomEngine *  engine,
fhicl::ParameterSet const &  pset 
)

Definition at line 45 of file AuxDetAction.cxx.

47  {
48  fGeo = gar::providerFrom<geo::GeometryGAr>();
49  fDetProp = gar::providerFrom<detinfo::DetectorPropertiesService>();
50 
51  this->reconfigure(pset);
52  }
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
const detinfo::DetectorProperties * fDetProp
detector properties
Definition: AuxDetAction.h:113
void reconfigure(fhicl::ParameterSet const &pset)
gar::garg4::AuxDetAction::~AuxDetAction ( )
virtual

Definition at line 56 of file AuxDetAction.cxx.

57  {
58  // Delete anything that we created with "new'.
59  }

Member Function Documentation

void gar::garg4::AuxDetAction::AddHits ( const std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > >  m_hits,
std::vector< gar::sdp::CaloDeposit > &  fDeposits 
)
private

Definition at line 659 of file AuxDetAction.cxx.

660  {
661  //Loop over the hits in the map and add them together
662  for(auto const &it : m_hits) {
663 
664  raw::CellID_t cellID = it.first;
665  std::vector<gar::sdp::CaloDeposit> vechit = it.second;
666  std::sort(vechit.begin(), vechit.end()); //sort per time
667 
668  float esum = 0.;
669  float time = vechit.at(0).Time();
670  int trackID = vechit.at(0).TrackID();
671  double pos[3] = { vechit.at(0).X(), vechit.at(0).Y(), vechit.at(0).Z() };
672 
673  for(auto const &hit : vechit) {
674  esum += hit.Energy();
675  }
676 
677  fDeposits.emplace_back( trackID, time, esum, pos, cellID );
678  }
679  }
long long int CellID_t
Definition: CaloRawDigit.h:24
Detector simulation of raw signals on wires.
void gar::garg4::AuxDetAction::BeginOfEventAction ( const G4Event *  )

Definition at line 89 of file AuxDetAction.cxx.

90  {
91  // Clear any previous information.
92  m_ECALDeposits.clear();
93  fECALDeposits.clear();
94 
95  m_TrackerScDeposits.clear();
96  fTrackerScDeposits.clear();
97 
98  m_MuIDDeposits.clear();
99  fMuIDDeposits.clear();
100 
101  fLArDeposits.clear();
102  }
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_ECALDeposits
Definition: AuxDetAction.h:103
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_TrackerScDeposits
Definition: AuxDetAction.h:106
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_MuIDDeposits
Definition: AuxDetAction.h:109
std::vector< gar::sdp::CaloDeposit > fMuIDDeposits
energy fDeposits for the MuID
Definition: AuxDetAction.h:110
std::vector< gar::sdp::LArDeposit > fLArDeposits
energy fDeposits for the LArTPC
Definition: AuxDetAction.h:101
std::vector< gar::sdp::CaloDeposit > fTrackerScDeposits
energy fDeposits for the TrackerSc
Definition: AuxDetAction.h:107
std::vector< gar::sdp::CaloDeposit > fECALDeposits
energy fDeposits for the ECAL
Definition: AuxDetAction.h:104
float gar::garg4::AuxDetAction::birksAttenuation ( const G4Step *  step)
private

Definition at line 627 of file AuxDetAction.cxx.

628  {
629  #if G4VERSION_NUMBER >= 1001
630  static G4EmSaturation s_emSaturation(1);
631  #else
632  static G4EmSaturation s_emSaturation();
633  s_emSaturation.SetVerbose(1);
634  #endif
635 
636  #if G4VERSION_NUMBER >= 1030
637  static bool s_initialised = false;
638  if(not s_initialised) {
639  s_emSaturation.InitialiseG4Saturation();
640  s_initialised = true;
641  }
642  #endif
643 
644  double energyDeposition = step->GetTotalEnergyDeposit();
645  double length = step->GetStepLength();
646  double niel = step->GetNonIonizingEnergyDeposit();
647  const G4Track* trk = step->GetTrack();
648  const G4ParticleDefinition* particle = trk->GetDefinition();
649  const G4MaterialCutsCouple* couple = trk->GetMaterialCutsCouple();
650  double engyVis = s_emSaturation.VisibleEnergyDeposition(particle,
651  couple,
652  length,
653  energyDeposition,
654  niel);
655  return engyVis;
656  }
std::vector<gar::sdp::CaloDeposit> const& gar::garg4::AuxDetAction::CaloDeposits ( ) const
inline

Definition at line 60 of file AuxDetAction.h.

60 { return fECALDeposits; }
std::vector< gar::sdp::CaloDeposit > fECALDeposits
energy fDeposits for the ECAL
Definition: AuxDetAction.h:104
void gar::garg4::AuxDetAction::ECALSteppingAction ( const G4Step *  step)
private

Definition at line 233 of file AuxDetAction.cxx.

234  {
235  MF_LOG_DEBUG("AuxDetAction")
236  << "AuxDetAction::ECALSteppingAction";
237 
238  // Get the pointer to the track
239  G4Track *track = step->GetTrack();
240 
241  const CLHEP::Hep3Vector &start = step->GetPreStepPoint()->GetPosition();
242  const CLHEP::Hep3Vector &stop = track->GetPosition();
243 
244  // If it's a null step, don't use it.
245  if(start == stop) return;
246  if(step->GetTotalEnergyDeposit() == 0) return;
247 
248  // check that we are in the correct material to record a hit
249  const std::string VolumeName = this->GetVolumeName(track);
250 
251  if (std::find_if(fECALVolumeName.begin(), fECALVolumeName.end(), [&VolumeName](std::string s) { return VolumeName.find(s) != std::string::npos; }) == fECALVolumeName.end())
252  return;
253 
254  // check the material
255  auto pos = 0.5 * (start + stop);
256  TGeoNode *node = fGeo->FindNode(pos.x()/CLHEP::cm, pos.y()/CLHEP::cm, pos.z()/CLHEP::cm);//Node in cm...
257 
258  if(nullptr == node){
259  MF_LOG_DEBUG("AuxDetAction::ECALSteppingAction")
260  << "Node not found in "
261  << pos.x() << " mm "
262  << pos.y() << " mm "
263  << pos.z() << " mm";
264  return;
265  }
266 
267  std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
268  if ( ! std::regex_match(volmaterial, std::regex(fECALMaterial)) ) return;
269 
270  // only worry about energy depositions larger than the minimum required
271  MF_LOG_DEBUG("AuxDetAction::ECALSteppingAction")
272  << "In volume "
273  << VolumeName
274  << " Material is "
275  << volmaterial
276  << " step size is "
277  << step->GetStepLength() / CLHEP::cm
278  << " cm and deposited "
279  << step->GetTotalEnergyDeposit()
280  << " MeV of energy";
281 
282  // the step mid point is used for the position of the deposit
283  G4ThreeVector G4Global = 0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition() );
284 
285  //get layer and slice number from the volume name (easier for segmentation later)
286  unsigned int layer = this->GetLayerNumber(VolumeName); //get layer number
287  unsigned int slice = this->GetSliceNumber(VolumeName); // get slice number
288  unsigned int det_id = this->GetDetNumber(VolumeName); // 1 == Barrel, 2 = Endcap
289  unsigned int stave = this->GetStaveNumber(VolumeName); //get the stave number
290  unsigned int module = this->GetModuleNumber(VolumeName); //get the module number
291 
292  MF_LOG_DEBUG("AuxDetAction::ECALSteppingAction")
293  << "det_id " << det_id
294  << " stave " << stave
295  << " module " << module
296  << " layer " << layer
297  << " slice " << slice;
298 
299  //Transform from global coordinates to local coordinates in mm
300  G4ThreeVector G4Local = this->globalToLocal(step, G4Global);
301  //Transform in cm
302  std::array<double, 3> G4Localcm = {G4Local.x() / CLHEP::cm, G4Local.y() / CLHEP::cm, G4Local.z() / CLHEP::cm};
303  //Get cellID
304  raw::CellID_t cellID = fGeo->GetCellID(node, det_id, stave, module, layer, slice, G4Localcm);//encoding the cellID on 64 bits
305 
306  //Don't correct for the strip or tile position yet
307  double G4Pos[3] = {0., 0., 0.}; // in cm
308  G4Pos[0] = G4Global.x() / CLHEP::cm;
309  G4Pos[1] = G4Global.y() / CLHEP::cm;
310  G4Pos[2] = G4Global.z() / CLHEP::cm;
311 
312  // get the track id for this step
313  auto trackID = ParticleListAction::GetCurrentTrackID();
314  float time = step->GetPreStepPoint()->GetGlobalTime();
315 
316  float edep = this->GetStepEnergy(step, true) * CLHEP::MeV / CLHEP::GeV;
317 
318  MF_LOG_DEBUG("AuxDetAction::ECALSteppingAction")
319  << "Energy deposited "
320  << step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV
321  << " GeV in cellID "
322  << cellID
323  << " after Birks "
324  << edep
325  << " GeV";
326 
327  //Create a map of cellID to SimHit
328  gar::sdp::CaloDeposit hit( trackID, time, edep, G4Pos, cellID );
329  if(m_ECALDeposits.find(cellID) != m_ECALDeposits.end())
330  m_ECALDeposits[cellID].push_back(hit);
331  else {
332  std::vector<gar::sdp::CaloDeposit> vechit;
333  vechit.push_back(hit);
334  m_ECALDeposits.emplace(cellID, vechit);
335  }
336  }
static constexpr double cm
Definition: Units.h:68
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
float GetStepEnergy(const G4Step *step, bool birks)
unsigned int GetDetNumber(std::string volname)
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
std::vector< std::string > fECALVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:92
std::string string
Definition: nybbler.cc:12
gar::raw::CellID_t GetCellID(const TGeoNode *node, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const
static constexpr double MeV
Definition: Units.h:129
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_ECALDeposits
Definition: AuxDetAction.h:103
unsigned int GetSliceNumber(std::string volname)
G4ThreeVector globalToLocal(const G4Step *step, const G4ThreeVector &glob)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
unsigned int GetModuleNumber(std::string volname)
static constexpr double GeV
Definition: Units.h:28
unsigned int GetLayerNumber(std::string volname)
std::string GetVolumeName(const G4Track *track)
long long int CellID_t
Definition: CaloRawDigit.h:24
Detector simulation of raw signals on wires.
std::string fECALMaterial
Material for the ECAL.
Definition: AuxDetAction.h:91
#define MF_LOG_DEBUG(id)
unsigned int GetStaveNumber(std::string volname)
static QCString * s
Definition: config.cpp:1042
void gar::garg4::AuxDetAction::EndOfEventAction ( const G4Event *  )

Definition at line 136 of file AuxDetAction.cxx.

137  {
138  //sort per time the hits
139  if (fGeo->HasLArTPCDetector()) {
140  std::sort(fLArDeposits.begin(), fLArDeposits.end());
141  }
142 
143  if(fGeo->HasECALDetector()) {
145  std::sort(fECALDeposits.begin(), fECALDeposits.end());
146  }
147 
148  if(fGeo->HasTrackerScDetector() && nullptr != fMinervaSegAlg) {
150  std::sort(fTrackerScDeposits.begin(), fTrackerScDeposits.end());
151  }
152 
153  if(fGeo->HasMuonDetector()) {
155  std::sort(fMuIDDeposits.begin(), fMuIDDeposits.end());
156  }
157  }
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
bool HasLArTPCDetector() const
Definition: GeometryCore.h:987
void AddHitsMinerva(std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > &m_Deposits, std::vector< gar::sdp::CaloDeposit > &fDeposits) const
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_ECALDeposits
Definition: AuxDetAction.h:103
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_TrackerScDeposits
Definition: AuxDetAction.h:106
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_MuIDDeposits
Definition: AuxDetAction.h:109
bool HasTrackerScDetector() const
Definition: GeometryCore.h:996
const gar::geo::seg::MinervaSegmentationAlg * fMinervaSegAlg
Definition: AuxDetAction.h:114
std::vector< gar::sdp::CaloDeposit > fMuIDDeposits
energy fDeposits for the MuID
Definition: AuxDetAction.h:110
std::vector< gar::sdp::LArDeposit > fLArDeposits
energy fDeposits for the LArTPC
Definition: AuxDetAction.h:101
void AddHits(const std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_hits, std::vector< gar::sdp::CaloDeposit > &fDeposits)
bool HasECALDetector() const
Definition: GeometryCore.h:993
bool HasMuonDetector() const
Definition: GeometryCore.h:999
std::vector< gar::sdp::CaloDeposit > fTrackerScDeposits
energy fDeposits for the TrackerSc
Definition: AuxDetAction.h:107
std::vector< gar::sdp::CaloDeposit > fECALDeposits
energy fDeposits for the ECAL
Definition: AuxDetAction.h:104
unsigned int gar::garg4::AuxDetAction::GetDetNumber ( std::string  volname)
private

Definition at line 568 of file AuxDetAction.cxx.

569  {
570  unsigned int det_id = 0;
571 
572  if( volname.find("ECal") != std::string::npos )
573  {
574  if( volname.find("Barrel") != std::string::npos )
575  det_id = 1;
576  if( volname.find("Endcap") != std::string::npos )
577  det_id = 2;
578  }
579 
580  if( volname.find("Yoke") != std::string::npos )
581  {
582  if( volname.find("Barrel") != std::string::npos )
583  det_id = 4;
584  if( volname.find("Endcap") != std::string::npos )
585  det_id = 4;
586  }
587 
588  return det_id;
589  }
unsigned int gar::garg4::AuxDetAction::GetLayerNumber ( std::string  volname)
private

Definition at line 556 of file AuxDetAction.cxx.

557  {
558  return std::atoi( (volname.substr( volname.find("layer_") + 6, 2)).c_str() );
559  }
unsigned int gar::garg4::AuxDetAction::GetModuleNumber ( std::string  volname)
private

Definition at line 598 of file AuxDetAction.cxx.

599  {
600  return std::atoi( (volname.substr( volname.find("_module") + 7, 2)).c_str() );
601  }
unsigned int gar::garg4::AuxDetAction::GetSliceNumber ( std::string  volname)
private

Definition at line 562 of file AuxDetAction.cxx.

563  {
564  return std::atoi( (volname.substr( volname.find("slice") + 5, 1)).c_str() );
565  }
unsigned int gar::garg4::AuxDetAction::GetStaveNumber ( std::string  volname)
private

Definition at line 592 of file AuxDetAction.cxx.

593  {
594  return std::atoi( (volname.substr( volname.find("_stave") + 6, 2)).c_str() );
595  }
float gar::garg4::AuxDetAction::GetStepEnergy ( const G4Step *  step,
bool  birks 
)
private

Definition at line 616 of file AuxDetAction.cxx.

617  {
618  if(birks){
619  return this->birksAttenuation(step);
620  }
621  else{
622  return step->GetTotalEnergyDeposit();
623  }
624  }
float birksAttenuation(const G4Step *step)
std::string gar::garg4::AuxDetAction::GetVolumeName ( const G4Track *  track)
private

Definition at line 548 of file AuxDetAction.cxx.

549  {
550  std::string VolName = track->GetVolume()->GetName();
551  VolName.erase(VolName.length()-3, 3);
552  return VolName;
553  }
std::string string
Definition: nybbler.cc:12
G4ThreeVector gar::garg4::AuxDetAction::globalToLocal ( const G4Step *  step,
const G4ThreeVector &  glob 
)
private

Definition at line 604 of file AuxDetAction.cxx.

605  {
606  return step->GetPreStepPoint()->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(glob);
607  }
std::vector<gar::sdp::LArDeposit> const& gar::garg4::AuxDetAction::LArDeposits ( ) const
inline

Definition at line 58 of file AuxDetAction.h.

58 { return fLArDeposits; }
std::vector< gar::sdp::LArDeposit > fLArDeposits
energy fDeposits for the LArTPC
Definition: AuxDetAction.h:101
void gar::garg4::AuxDetAction::LArSteppingAction ( const G4Step *  step)
private

Definition at line 160 of file AuxDetAction.cxx.

161  {
162  MF_LOG_DEBUG("AuxDetAction")
163  << "AuxDetAction::LArSteppingAction";
164 
165  // Get the pointer to the track
166  G4Track *track = step->GetTrack();
167 
168  const CLHEP::Hep3Vector &start = step->GetPreStepPoint()->GetPosition();
169  const CLHEP::Hep3Vector &stop = track->GetPosition();
170 
171  // If it's a null step, don't use it.
172  if(start == stop) return;
173  if(step->GetTotalEnergyDeposit() == 0) return;
174 
175  // check that we are in the correct material to record a hit
176  const std::string VolumeName = this->GetVolumeName(track);
177  if( std::find_if( fLArVolumeName.begin(), fLArVolumeName.end(), [&VolumeName](std::string s) { return VolumeName.find(s) != std::string::npos; } ) == fLArVolumeName.end() )
178  return;
179 
180  // check the material
181  auto pos = 0.5 * (start + stop);
182  TGeoNode *node = fGeo->FindNode(pos.x()/CLHEP::cm, pos.y()/CLHEP::cm, pos.z()/CLHEP::cm);//Node in cm...
183 
184  if(nullptr == node){
185  MF_LOG_DEBUG("AuxDetAction::LArSteppingAction")
186  << "Node not found in "
187  << pos.x() << " mm "
188  << pos.y() << " mm "
189  << pos.z() << " mm";
190  return;
191  }
192 
193  std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
194  if ( ! std::regex_match(volmaterial, std::regex(fLArMaterial)) ) return;
195 
196  // only worry about energy depositions larger than the minimum required
197  if(step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV > fLArEnergyCut){
198 
199  MF_LOG_DEBUG("AuxDetAction::LArSteppingAction")
200  << "In volume "
201  << VolumeName
202  << " Material is "
203  << volmaterial
204  << " step size is "
205  << step->GetStepLength() / CLHEP::cm
206  << " cm and deposited "
207  << step->GetTotalEnergyDeposit()
208  << " MeV of energy with a minimum of "
209  << fLArEnergyCut
210  << " required.";
211 
212  // the step mid point is used for the position of the deposit
213  auto midPoint = 0.5 * (step->GetPreStepPoint()->GetPosition() +
214  step->GetPostStepPoint()->GetPosition() );
215 
216  // get the track id for this step
217  auto trackID = ParticleListAction::GetCurrentTrackID();
218  float time = step->GetPreStepPoint()->GetGlobalTime();
219 
220  fLArDeposits.emplace_back(trackID,
221  time,//get the time of the first subhit
222  step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV,
223  midPoint.x() / CLHEP::cm,
224  midPoint.y() / CLHEP::cm,
225  midPoint.z() / CLHEP::cm,
226  step->GetStepLength() / CLHEP::cm,
227  (trackID > 0));
228 
229  } // end if enough energy to worry about this step
230  }
static constexpr double cm
Definition: Units.h:68
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
std::string fLArMaterial
Material for the LArTPC.
Definition: AuxDetAction.h:88
std::string string
Definition: nybbler.cc:12
static constexpr double MeV
Definition: Units.h:129
double fLArEnergyCut
The minimum energy in GeV for a particle to be included in the list.
Definition: AuxDetAction.h:87
static constexpr double GeV
Definition: Units.h:28
std::string GetVolumeName(const G4Track *track)
std::vector< gar::sdp::LArDeposit > fLArDeposits
energy fDeposits for the LArTPC
Definition: AuxDetAction.h:101
#define MF_LOG_DEBUG(id)
std::vector< std::string > fLArVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:89
static QCString * s
Definition: config.cpp:1042
G4ThreeVector gar::garg4::AuxDetAction::localToGlobal ( const G4Step *  step,
const G4ThreeVector &  loc 
)
private

Definition at line 610 of file AuxDetAction.cxx.

611  {
612  return step->GetPreStepPoint()->GetTouchable()->GetHistory()->GetTopTransform().Inverse().TransformPoint(loc);
613  }
std::vector<gar::sdp::CaloDeposit> const& gar::garg4::AuxDetAction::MuIDDeposits ( ) const
inline

Definition at line 64 of file AuxDetAction.h.

64 { return fMuIDDeposits; }
std::vector< gar::sdp::CaloDeposit > fMuIDDeposits
energy fDeposits for the MuID
Definition: AuxDetAction.h:110
void gar::garg4::AuxDetAction::MuIDSteppingAction ( const G4Step *  step)
private

Definition at line 441 of file AuxDetAction.cxx.

442  {
443  MF_LOG_DEBUG("AuxDetAction")
444  << "AuxDetAction::MuIDSteppingAction";
445 
446  // Get the pointer to the track
447  G4Track *track = step->GetTrack();
448 
449  const CLHEP::Hep3Vector &start = step->GetPreStepPoint()->GetPosition();
450  const CLHEP::Hep3Vector &stop = track->GetPosition();
451 
452  // If it's a null step, don't use it.
453  if(start == stop) return;
454  if(step->GetTotalEnergyDeposit() == 0) return;
455 
456  // check that we are in the correct material to record a hit
457  const std::string VolumeName = this->GetVolumeName(track);
458 
459  if (std::find_if(fMuIDVolumeName.begin(), fMuIDVolumeName.end(), [&VolumeName](std::string s) { return VolumeName.find(s) != std::string::npos; }) == fMuIDVolumeName.end())
460  return;
461 
462  // check the material
463  auto pos = 0.5 * (start + stop);
464  TGeoNode *node = fGeo->FindNode(pos.x()/CLHEP::cm, pos.y()/CLHEP::cm, pos.z()/CLHEP::cm);//Node in cm...
465 
466  if (nullptr == node)
467  {
468  MF_LOG_DEBUG("AuxDetAction::MuIDSteppingAction")
469  << "Node not found in "
470  << pos.x() << " mm "
471  << pos.y() << " mm "
472  << pos.z() << " mm";
473  return;
474  }
475 
476  std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
477  if ( ! std::regex_match(volmaterial, std::regex(fMuIDMaterial)) ) return;
478 
479  // only worry about energy depositions larger than the minimum required
480  MF_LOG_DEBUG("AuxDetAction::MuIDSteppingAction")
481  << "In volume "
482  << VolumeName
483  << " Material is "
484  << volmaterial
485  << " step size is "
486  << step->GetStepLength() / CLHEP::cm
487  << " cm and deposited "
488  << step->GetTotalEnergyDeposit()
489  << " MeV of energy";
490 
491  // the step mid point is used for the position of the deposit
492  G4ThreeVector G4Global = 0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition() );
493 
494  //get layer and slice number from the volume name (easier for segmentation later)
495  unsigned int layer = this->GetLayerNumber(VolumeName); //get layer number
496  unsigned int slice = this->GetSliceNumber(VolumeName); // get slice number
497  unsigned int det_id = this->GetDetNumber(VolumeName); // 1 == Barrel, 2 = Endcap
498  unsigned int stave = this->GetStaveNumber(VolumeName); //get the stave number
499  unsigned int module = this->GetModuleNumber(VolumeName); //get the module number
500 
501  MF_LOG_DEBUG("AuxDetAction::MuIDSteppingAction")
502  << "det_id " << det_id
503  << " stave " << stave
504  << " module " << module
505  << " layer " << layer
506  << " slice " << slice;
507 
508  //Transform from global coordinates to local coordinates in mm
509  G4ThreeVector G4Local = this->globalToLocal(step, G4Global);
510  //Transform in cm
511  std::array<double, 3> G4Localcm = {G4Local.x() / CLHEP::cm, G4Local.y() / CLHEP::cm, G4Local.z() / CLHEP::cm};
512  //Get cellID
513  raw::CellID_t cellID = fGeo->GetCellID(node, det_id, stave, module, layer, slice, G4Localcm);//encoding the cellID on 64 bits
514 
515  //Don't correct for the strip or tile position yet
516  double G4Pos[3] = {0., 0., 0.}; // in cm
517  G4Pos[0] = G4Global.x() / CLHEP::cm;
518  G4Pos[1] = G4Global.y() / CLHEP::cm;
519  G4Pos[2] = G4Global.z() / CLHEP::cm;
520 
521  // get the track id for this step
522  auto trackID = ParticleListAction::GetCurrentTrackID();
523  float time = step->GetPreStepPoint()->GetGlobalTime();
524 
525  float edep = this->GetStepEnergy(step, true) * CLHEP::MeV / CLHEP::GeV;
526 
527  MF_LOG_DEBUG("AuxDetAction::MuIDSteppingAction")
528  << "Energy deposited "
529  << step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV
530  << " GeV in cellID "
531  << cellID
532  << " after Birks "
533  << edep
534  << " GeV";
535 
536  //Create a map of cellID to SimHit
537  gar::sdp::CaloDeposit hit( trackID, time, edep, G4Pos, cellID );
538  if(m_MuIDDeposits.find(cellID) != m_MuIDDeposits.end())
539  m_MuIDDeposits[cellID].push_back(hit);
540  else {
541  std::vector<gar::sdp::CaloDeposit> vechit;
542  vechit.push_back(hit);
543  m_MuIDDeposits.emplace(cellID, vechit);
544  }
545  }
static constexpr double cm
Definition: Units.h:68
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
float GetStepEnergy(const G4Step *step, bool birks)
unsigned int GetDetNumber(std::string volname)
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
std::string string
Definition: nybbler.cc:12
std::vector< std::string > fMuIDVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:98
gar::raw::CellID_t GetCellID(const TGeoNode *node, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const
static constexpr double MeV
Definition: Units.h:129
unsigned int GetSliceNumber(std::string volname)
G4ThreeVector globalToLocal(const G4Step *step, const G4ThreeVector &glob)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_MuIDDeposits
Definition: AuxDetAction.h:109
unsigned int GetModuleNumber(std::string volname)
std::string fMuIDMaterial
Material for the MuID.
Definition: AuxDetAction.h:97
static constexpr double GeV
Definition: Units.h:28
unsigned int GetLayerNumber(std::string volname)
std::string GetVolumeName(const G4Track *track)
long long int CellID_t
Definition: CaloRawDigit.h:24
Detector simulation of raw signals on wires.
#define MF_LOG_DEBUG(id)
unsigned int GetStaveNumber(std::string volname)
static QCString * s
Definition: config.cpp:1042
void gar::garg4::AuxDetAction::PostTrackingAction ( const G4Track *  )

Definition at line 111 of file AuxDetAction.cxx.

112  {
113  }
void gar::garg4::AuxDetAction::PreTrackingAction ( const G4Track *  )

Definition at line 105 of file AuxDetAction.cxx.

106  {
107 
108  }
void gar::garg4::AuxDetAction::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 62 of file AuxDetAction.cxx.

63  {
64  fLArEnergyCut = pset.get<double>("LArEnergyCut", 0.);
65  fLArVolumeName = pset.get<std::vector<std::string>>("LArVolumeName");
66  fLArMaterial = pset.get<std::string>("LArMaterial", "LAr");
67 
68  fECALMaterial = pset.get<std::string>("ECALMaterial", "Scintillator");
69  fECALVolumeName = pset.get<std::vector<std::string>>("ECALVolumeName");
70 
71  fTrackerScMaterial = pset.get<std::string>("TrackerScMaterial", "Scintillator");
72  fTrackerScVolumeName = pset.get<std::vector<std::string>>("TrackerScVolumeName");
73 
74  fMuIDMaterial = pset.get<std::string>("MuIDMaterial", "Scintillator");
75  fMuIDVolumeName = pset.get<std::vector<std::string>>("MuIDVolumeName");
76 
77  fApplyBirksLaw = pset.get<bool>("ApplyBirksLaw", true);
78 
79  // std::cout << "AuxDetAction: Name of the Volumes to track for the LArTPC" << std::endl;
80  // for(unsigned int i = 0; i < fLArVolumeName.size(); i++) std::cout << fLArVolumeName.at(i) << " ";
81  // std::cout << std::endl;
82 
84 
85  return;
86  }
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
std::string fLArMaterial
Material for the LArTPC.
Definition: AuxDetAction.h:88
std::vector< std::string > fECALVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:92
std::string string
Definition: nybbler.cc:12
std::vector< std::string > fMuIDVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:98
std::string fTrackerScMaterial
Material for the TrackerSc (GArLite)
Definition: AuxDetAction.h:94
double fLArEnergyCut
The minimum energy in GeV for a particle to be included in the list.
Definition: AuxDetAction.h:87
std::string fMuIDMaterial
Material for the MuID.
Definition: AuxDetAction.h:97
const gar::geo::seg::MinervaSegmentationAlg * fMinervaSegAlg
Definition: AuxDetAction.h:114
gar::geo::seg::SegmentationAlg const * MinervaSegmentationAlg() const
Returns the object handling the Sc Tracker segmentation.
Definition: GeometryCore.h:936
std::string fECALMaterial
Material for the ECAL.
Definition: AuxDetAction.h:91
std::vector< std::string > fTrackerScVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:95
std::vector< std::string > fLArVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:89
void gar::garg4::AuxDetAction::SteppingAction ( const G4Step *  step)

Definition at line 117 of file AuxDetAction.cxx.

118  {
119  MF_LOG_DEBUG("AuxDetAction")
120  << "AuxDetAction::SteppingAction";
121 
122  if(fGeo->HasLArTPCDetector())
123  this->LArSteppingAction(step);
124 
125  if(fGeo->HasECALDetector())
126  this->ECALSteppingAction(step);
127 
130 
131  if(fGeo->HasMuonDetector())
132  this->MuIDSteppingAction(step);
133  }// end of AuxDetAction::SteppingAction
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
bool HasLArTPCDetector() const
Definition: GeometryCore.h:987
void LArSteppingAction(const G4Step *)
bool HasTrackerScDetector() const
Definition: GeometryCore.h:996
bool HasECALDetector() const
Definition: GeometryCore.h:993
bool HasMuonDetector() const
Definition: GeometryCore.h:999
void ECALSteppingAction(const G4Step *)
#define MF_LOG_DEBUG(id)
void MuIDSteppingAction(const G4Step *)
void TrackerScSteppingAction(const G4Step *)
std::vector<gar::sdp::CaloDeposit> const& gar::garg4::AuxDetAction::TrackerScDeposits ( ) const
inline

Definition at line 62 of file AuxDetAction.h.

62 { return fTrackerScDeposits; }
std::vector< gar::sdp::CaloDeposit > fTrackerScDeposits
energy fDeposits for the TrackerSc
Definition: AuxDetAction.h:107
void gar::garg4::AuxDetAction::TrackerScSteppingAction ( const G4Step *  step)
private

Definition at line 339 of file AuxDetAction.cxx.

340  {
341  MF_LOG_DEBUG("AuxDetAction")
342  << "AuxDetAction::TrackerScSteppingAction";
343 
344  // Get the pointer to the track
345  G4Track *track = step->GetTrack();
346 
347  const CLHEP::Hep3Vector &start = step->GetPreStepPoint()->GetPosition();
348  const CLHEP::Hep3Vector &stop = track->GetPosition();
349 
350  // If it's a null step, don't use it.
351  if(start == stop) return;
352  if(step->GetTotalEnergyDeposit() == 0) return;
353 
354  // check that we are in the correct material to record a hit
355  const std::string VolumeName = this->GetVolumeName(track);
356  if( std::find_if( fTrackerScVolumeName.begin(), fTrackerScVolumeName.end(), [&VolumeName](std::string s) { return VolumeName.find(s) != std::string::npos; } ) == fTrackerScVolumeName.end() )
357  return;
358 
359  // check the material
360  auto pos = 0.5 * (start + stop);
361  TGeoNode *node = fGeo->FindNode(pos.x()/CLHEP::cm, pos.y()/CLHEP::cm, pos.z()/CLHEP::cm);//Node in cm...
362 
363  if (nullptr == node)
364  {
365  MF_LOG_DEBUG("AuxDetAction::TrackerScSteppingAction")
366  << "Node not found in "
367  << pos.x()/CLHEP::cm << " cm "
368  << pos.y()/CLHEP::cm << " cm "
369  << pos.z()/CLHEP::cm << " cm in volume "
370  << VolumeName;
371  return;
372  }
373 
374  std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
375  if ( ! std::regex_match(volmaterial, std::regex(fTrackerScMaterial)) ) return;
376 
377  // only worry about energy depositions larger than the minimum required
378  MF_LOG_DEBUG("AuxDetAction::TrackerScSteppingAction")
379  << "In volume "
380  << VolumeName
381  << " Material is "
382  << volmaterial
383  << " step size is "
384  << step->GetStepLength() / CLHEP::cm
385  << " cm and deposited "
386  << step->GetTotalEnergyDeposit()
387  << " MeV of energy";
388 
389  // the step mid point is used for the position of the deposit
390  G4ThreeVector G4Global = 0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition() );
391 
392  //get layer and slice number from the volume name (easier for segmentation later)
393  unsigned int layer = this->GetLayerNumber(VolumeName); //get layer number
394  unsigned int slice = this->GetSliceNumber(VolumeName); // get slice number
395  unsigned int det_id = 3;
396 
397  MF_LOG_DEBUG("AuxDetAction::TrackerScSteppingAction")
398  << "det_id " << det_id
399  << " layer " << layer
400  << " slice " << slice;
401 
402  //Transform from global coordinates to local coordinates in mm
403  G4ThreeVector G4Local = this->globalToLocal(step, G4Global);
404  //Transform in cm
405  std::array<double, 3> G4Localcm = {G4Local.x() / CLHEP::cm, G4Local.y() / CLHEP::cm, G4Local.z() / CLHEP::cm};
406  //Get cellID
407  raw::CellID_t cellID = fGeo->GetCellID(node, det_id, 0, 0, layer, slice, G4Localcm);//encoding the cellID on 64 bits
408 
409  //Don't correct for the strip or tile position yet
410  double G4Pos[3] = {0., 0., 0.}; // in cm
411  G4Pos[0] = G4Global.x() / CLHEP::cm;
412  G4Pos[1] = G4Global.y() / CLHEP::cm;
413  G4Pos[2] = G4Global.z() / CLHEP::cm;
414 
415  // get the track id for this step
416  auto trackID = ParticleListAction::GetCurrentTrackID();
417  float time = step->GetPreStepPoint()->GetGlobalTime();
418  float edep = this->GetStepEnergy(step, true) * CLHEP::MeV / CLHEP::GeV;
419 
420  MF_LOG_DEBUG("AuxDetAction::TrackerScSteppingAction")
421  << "Energy deposited "
422  << step->GetTotalEnergyDeposit() * CLHEP::MeV / CLHEP::GeV
423  << " GeV in cellID "
424  << cellID
425  << " after Birks "
426  << edep
427  << " GeV";
428 
429  //Create a map of cellID to SimHit
430  gar::sdp::CaloDeposit hit( trackID, time, edep, G4Pos, cellID );
431  if(m_TrackerScDeposits.find(cellID) != m_TrackerScDeposits.end())
433  else {
434  std::vector<gar::sdp::CaloDeposit> vechit;
435  vechit.push_back(hit);
436  m_TrackerScDeposits.emplace(cellID, vechit);
437  }
438  }
static constexpr double cm
Definition: Units.h:68
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
float GetStepEnergy(const G4Step *step, bool birks)
const gar::geo::GeometryCore * fGeo
geometry information
Definition: AuxDetAction.h:112
std::string string
Definition: nybbler.cc:12
std::string fTrackerScMaterial
Material for the TrackerSc (GArLite)
Definition: AuxDetAction.h:94
gar::raw::CellID_t GetCellID(const TGeoNode *node, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const
static constexpr double MeV
Definition: Units.h:129
unsigned int GetSliceNumber(std::string volname)
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_TrackerScDeposits
Definition: AuxDetAction.h:106
G4ThreeVector globalToLocal(const G4Step *step, const G4ThreeVector &glob)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
static constexpr double GeV
Definition: Units.h:28
unsigned int GetLayerNumber(std::string volname)
std::string GetVolumeName(const G4Track *track)
long long int CellID_t
Definition: CaloRawDigit.h:24
Detector simulation of raw signals on wires.
std::vector< std::string > fTrackerScVolumeName
volume we will record energy depositions in
Definition: AuxDetAction.h:95
#define MF_LOG_DEBUG(id)
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

bool gar::garg4::AuxDetAction::fApplyBirksLaw
private

Definition at line 99 of file AuxDetAction.h.

const detinfo::DetectorProperties* gar::garg4::AuxDetAction::fDetProp
private

detector properties

Definition at line 113 of file AuxDetAction.h.

std::vector<gar::sdp::CaloDeposit> gar::garg4::AuxDetAction::fECALDeposits
private

energy fDeposits for the ECAL

Definition at line 104 of file AuxDetAction.h.

std::string gar::garg4::AuxDetAction::fECALMaterial
private

Material for the ECAL.

Definition at line 91 of file AuxDetAction.h.

std::vector<std::string> gar::garg4::AuxDetAction::fECALVolumeName
private

volume we will record energy depositions in

Definition at line 92 of file AuxDetAction.h.

const gar::geo::GeometryCore* gar::garg4::AuxDetAction::fGeo
private

geometry information

Definition at line 112 of file AuxDetAction.h.

std::vector<gar::sdp::LArDeposit> gar::garg4::AuxDetAction::fLArDeposits
private

energy fDeposits for the LArTPC

Definition at line 101 of file AuxDetAction.h.

double gar::garg4::AuxDetAction::fLArEnergyCut
private

The minimum energy in GeV for a particle to be included in the list.

Definition at line 87 of file AuxDetAction.h.

std::string gar::garg4::AuxDetAction::fLArMaterial
private

Material for the LArTPC.

Definition at line 88 of file AuxDetAction.h.

std::vector<std::string> gar::garg4::AuxDetAction::fLArVolumeName
private

volume we will record energy depositions in

Definition at line 89 of file AuxDetAction.h.

const gar::geo::seg::MinervaSegmentationAlg* gar::garg4::AuxDetAction::fMinervaSegAlg
private

Definition at line 114 of file AuxDetAction.h.

std::vector<gar::sdp::CaloDeposit> gar::garg4::AuxDetAction::fMuIDDeposits
private

energy fDeposits for the MuID

Definition at line 110 of file AuxDetAction.h.

std::string gar::garg4::AuxDetAction::fMuIDMaterial
private

Material for the MuID.

Definition at line 97 of file AuxDetAction.h.

std::vector<std::string> gar::garg4::AuxDetAction::fMuIDVolumeName
private

volume we will record energy depositions in

Definition at line 98 of file AuxDetAction.h.

std::vector<gar::sdp::CaloDeposit> gar::garg4::AuxDetAction::fTrackerScDeposits
private

energy fDeposits for the TrackerSc

Definition at line 107 of file AuxDetAction.h.

std::string gar::garg4::AuxDetAction::fTrackerScMaterial
private

Material for the TrackerSc (GArLite)

Definition at line 94 of file AuxDetAction.h.

std::vector<std::string> gar::garg4::AuxDetAction::fTrackerScVolumeName
private

volume we will record energy depositions in

Definition at line 95 of file AuxDetAction.h.

std::map< gar::raw::CellID_t, std::vector<gar::sdp::CaloDeposit> > gar::garg4::AuxDetAction::m_ECALDeposits
private

Definition at line 103 of file AuxDetAction.h.

std::map< gar::raw::CellID_t, std::vector<gar::sdp::CaloDeposit> > gar::garg4::AuxDetAction::m_MuIDDeposits
private

Definition at line 109 of file AuxDetAction.h.

std::map< gar::raw::CellID_t, std::vector<gar::sdp::CaloDeposit> > gar::garg4::AuxDetAction::m_TrackerScDeposits
private

Definition at line 106 of file AuxDetAction.h.


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