LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cheat::BackTracker Class Reference

#include "BackTracker.h"

Inheritance diagram for cheat::BackTracker:
cheat::BackTrackerService

Classes

struct  fhiclConfig
 

Public Member Functions

 BackTracker (const fhiclConfig &config, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom, const detinfo::DetectorClocks *detClock)
 
 BackTracker (const fhicl::ParameterSet &pSet, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom, const detinfo::DetectorClocks *detClock)
 
 BackTracker (BackTracker const &)=delete
 
template<typename Evt >
void PrepEvent (const Evt &evt)
 
template<typename Evt >
void PrepSimChannels (const Evt &evt)
 
template<typename Evt >
bool CanRun (const Evt &evt)
 
template<typename Evt >
const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps (art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
 
template<typename Evt >
const std::vector< double > SpacePointToXYZ (art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
 
void ClearEvent ()
 
bool SimChannelsReady () const
 
const std::vector< art::Ptr< sim::SimChannel > > & SimChannels () const
 
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps (int const &id) const
 
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps (int const &id, const geo::View_t view) const
 
art::Ptr< sim::SimChannelFindSimChannel (raw::ChannelID_t channel) const
 
const std::vector< sim::TrackIDEChannelToTrackIDEs (raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
 
const std::vector< sim::TrackIDEHitToTrackIDEs (recob::Hit const &hit) const
 
const std::vector< sim::TrackIDEHitToTrackIDEs (art::Ptr< recob::Hit > const &hit) const
 
const std::vector< int > HitToTrackIds (recob::Hit const &hit) const
 
const std::vector< sim::TrackIDEHitToEveTrackIDEs (recob::Hit const &hit) const
 
const std::vector< sim::TrackIDEHitToEveTrackIDEs (art::Ptr< recob::Hit > const &hit) const
 
std::vector< art::Ptr< recob::Hit > > TrackIdToHits_Ps (const int &tkId, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
 
std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps (std::vector< int > const &tkIds, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
 
const std::vector< sim::IDEHitToAvgSimIDEs (recob::Hit const &hit) const
 
const std::vector< sim::IDEHitToAvgSimIDEs (art::Ptr< recob::Hit > hit) const
 
const std::vector< const sim::IDE * > HitToSimIDEs_Ps (recob::Hit const &hit) const
 
const std::vector< const sim::IDE * > HitToSimIDEs_Ps (art::Ptr< recob::Hit > const &hit) const
 
const std::vector< double > SimIDEsToXYZ (std::vector< sim::IDE > const &ides) const
 
const std::vector< double > SimIDEsToXYZ (std::vector< const sim::IDE * > const &ide_Ps) const
 
const std::vector< double > HitToXYZ (const recob::Hit &hit) const
 
const std::vector< double > HitToXYZ (art::Ptr< recob::Hit > const &hit) const
 
const double HitCollectionPurity (std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
 
const double HitChargeCollectionPurity (std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
 
const double HitCollectionEfficiency (std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const &view) const
 
const double HitChargeCollectionEfficiency (std::set< int > trackIds, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const &view) const
 
const std::set< int > GetSetOfTrackIds () const
 
const std::set< int > GetSetOfEveIds () const
 
const std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::Hit > > const &hits) const
 
const std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::Hit > > const &hits) const
 
const std::vector< double > SpacePointHitsToWeightedXYZ (std::vector< art::Ptr< recob::Hit >> const &hits) const
 

Private Attributes

const cheat::ParticleInventoryfPartInv
 
const geo::GeometryCorefGeom
 
const detinfo::DetectorClocksfDetClocks
 
const art::InputTag fG4ModuleLabel
 
const art::InputTag fHitLabel
 
const double fMinHitEnergyFraction
 
const bool fOverrideRealData
 
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
 

Detailed Description

Definition at line 38 of file BackTracker.h.

Constructor & Destructor Documentation

cheat::BackTracker::BackTracker ( const fhiclConfig config,
const cheat::ParticleInventory partInv,
const geo::GeometryCore geom,
const detinfo::DetectorClocks detClock 
)

Definition at line 29 of file BackTracker.cc.

30  :fPartInv (partInv),
31  fGeom (geom),
32  fDetClocks(detClock),
33  fG4ModuleLabel(config.G4ModuleLabel()),
34  fHitLabel(config.DefaultHitModuleLabel()),
35  fMinHitEnergyFraction(config.MinHitEnergyFraction()),
36  fOverrideRealData(config.OverrideRealData())
37  {
38  }
const art::InputTag fHitLabel
Definition: BackTracker.h:161
const geo::GeometryCore * fGeom
Definition: BackTracker.h:158
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:159
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:157
const bool fOverrideRealData
Definition: BackTracker.h:163
const art::InputTag fG4ModuleLabel
Definition: BackTracker.h:160
cheat::BackTracker::BackTracker ( const fhicl::ParameterSet pSet,
const cheat::ParticleInventory partInv,
const geo::GeometryCore geom,
const detinfo::DetectorClocks detClock 
)

Definition at line 41 of file BackTracker.cc.

42  :fPartInv (partInv),
43  fGeom (geom),
44  fDetClocks(detClock),
45  fG4ModuleLabel (pSet.get<art::InputTag>("G4ModuleLabel", "largeant")),
46  fHitLabel (pSet.get<art::InputTag>("DefaultHitModuleLabel", "hitfd")),
47  fMinHitEnergyFraction(pSet.get<double> ("MinHitEnergyFraction", 0.010)),
48  fOverrideRealData (pSet.get<bool> ("OverrideRealData",false))
49  {
50  }
const art::InputTag fHitLabel
Definition: BackTracker.h:161
const geo::GeometryCore * fGeom
Definition: BackTracker.h:158
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:159
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
T get(std::string const &key) const
Definition: ParameterSet.h:231
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:157
const bool fOverrideRealData
Definition: BackTracker.h:163
const art::InputTag fG4ModuleLabel
Definition: BackTracker.h:160
cheat::BackTracker::BackTracker ( BackTracker const &  )
delete

Member Function Documentation

template<typename Evt >
bool cheat::BackTracker::CanRun ( const Evt &  evt)
inline

Definition at line 72 of file BackTracker.h.

References ClearEvent(), fOverrideRealData, SpacePointToHits_Ps(), and SpacePointToXYZ().

Referenced by cheat::BackTrackerService::priv_CanRun().

72 { return ( !(evt.isRealData()) || fOverrideRealData);}
const bool fOverrideRealData
Definition: BackTracker.h:163
TCEvent evt
Definition: DataStructs.cxx:5
const std::vector< sim::TrackIDE > cheat::BackTracker::ChannelToTrackIDEs ( raw::ChannelID_t  channel,
const double  hit_start_time,
const double  hit_end_time 
) const

Definition at line 114 of file BackTracker.cc.

References e, energy, sim::TrackIDE::energy, sim::TrackIDE::energyFrac, fDetClocks, FindSimChannel(), sim::NoParticleId, sim::TrackIDE::numElectrons, detinfo::DetectorClocks::TPCTick2TDC(), sim::TrackIDE::trackID, and sim::SimChannel::TrackIDsAndEnergies().

Referenced by cheat::BackTrackerService::ChannelToTrackIDEs(), GetSetOfTrackIds(), HitToTrackIDEs(), SimChannels(), TrackIdsToHits_Ps(), and TrackIdToHits_Ps().

114  {
115  std::vector< sim::TrackIDE > trackIDEs;
116  double totalE=0.;
117  try{
118  art::Ptr<sim::SimChannel> schannel = this->FindSimChannel(channel);
119 
120  // loop over the electrons in the channel and grab those that are in time
121  // with the identified hit start and stop times
122  int start_tdc = fDetClocks->TPCTick2TDC( hit_start_time );
123  int end_tdc = fDetClocks->TPCTick2TDC( hit_end_time );
124  if(start_tdc<0) start_tdc = 0;
125  if(end_tdc<0) end_tdc = 0;
126  std::vector<sim::IDE> simides = schannel->TrackIDsAndEnergies(start_tdc, end_tdc);
127 
128  // first get the total energy represented by all track ids for
129  // this channel and range of tdc values
130  for(size_t e = 0; e < simides.size(); ++e)
131  totalE += simides[e].energy;
132 
133 
134  // protect against a divide by zero below
135  if(totalE < 1.e-5) totalE = 1.;
136 
137  // loop over the entries in the map and fill the input vectors
138 
139  for(size_t e = 0; e < simides.size(); ++e){
140 
141  if(simides[e].trackID == sim::NoParticleId) continue;
142 
143  sim::TrackIDE info;
144  info.trackID = simides[e].trackID;
145  info.energyFrac = simides[e].energy/totalE;
146  info.energy = simides[e].energy;
147  info.numElectrons = simides[e].numElectrons;
148 
149  trackIDEs.push_back(info);
150 
151  }
152  }// end try
153  catch(cet::exception e){
154  mf::LogWarning("BackTracker") << "caught exception \n"
155  << e;
156  }
157 
158  return trackIDEs;
159 
160  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:159
float numElectrons
number of electrons from the particle detected on the wires
Definition: SimChannel.h:32
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:31
static const int NoParticleId
Definition: sim.h:28
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:101
double energy
Definition: plottest35.C:25
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:29
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
std::vector< sim::IDE > TrackIDsAndEnergies(TDC_t startTDC, TDC_t endTDC) const
Return all the recorded energy deposition within a time interval.
Definition: SimChannel.cxx:178
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::BackTracker::ClearEvent ( )

Definition at line 53 of file BackTracker.cc.

References fSimChannels.

Referenced by CanRun(), and cheat::BackTrackerService::priv_PrepEvent().

53  {
54  fSimChannels.clear();
55 // fAllHitList.clear();
56  }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
art::Ptr< sim::SimChannel > cheat::BackTracker::FindSimChannel ( raw::ChannelID_t  channel) const

Definition at line 101 of file BackTracker.cc.

References fSimChannels.

Referenced by ChannelToTrackIDEs(), cheat::BackTrackerService::FindSimChannel(), HitToAvgSimIDEs(), HitToSimIDEs_Ps(), and SimChannels().

101  {
103  auto ilb = std::lower_bound(fSimChannels.begin(),fSimChannels.end(),channel,[](art::Ptr<sim::SimChannel> a, raw:: ChannelID_t channel) {return(a->Channel()<channel);});
104  if (ilb != fSimChannels.end())
105  if ( (*ilb)->Channel() == channel) {chan = *ilb;}
106  if(!chan)
107  throw cet::exception("BackTracker") << "No sim::SimChannel corresponding "
108  << "to channel: " << channel << "\n";
109  return chan;
110  }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::set<int> cheat::BackTracker::GetSetOfEveIds ( ) const
inline
const std::set< int > cheat::BackTracker::GetSetOfEveIds ( std::vector< art::Ptr< recob::Hit > > const &  hits) const

Definition at line 501 of file BackTracker.cc.

References hits(), and HitToEveTrackIDEs().

501  {
502  std::set<int> eveIds;
503  for(const auto& hit : hits){
504  const std::vector<sim::TrackIDE> ides = this->HitToEveTrackIDEs(hit);
505  for(const auto& ide : ides){eveIds.insert(ide.trackID);}//end ides
506  }//End for hits
507  return eveIds;
508  }
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:184
Detector simulation of raw signals on wires.
const std::set<int> cheat::BackTracker::GetSetOfTrackIds ( ) const
inline

Definition at line 148 of file BackTracker.h.

References fPartInv, and cheat::ParticleInventory::GetSetOfTrackIds().

Referenced by GetSetOfEveIds(), and cheat::BackTrackerService::GetSetOfTrackIds().

148 { return fPartInv->GetSetOfTrackIds();}
std::set< int > GetSetOfTrackIds() const
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:157
const std::set< int > cheat::BackTracker::GetSetOfTrackIds ( std::vector< art::Ptr< recob::Hit > > const &  hits) const

Definition at line 487 of file BackTracker.cc.

References ChannelToTrackIDEs(), evd::details::end(), and hits().

487  {
488  std::set<int> tids;
489  for( const auto& hit : hits){
490  const double start = hit->PeakTimeMinusRMS();
491  const double end = hit->PeakTimePlusRMS();
492  std::vector<sim::TrackIDE> trackIDEs = this->ChannelToTrackIDEs(hit->Channel(), start, end);
493  for(const auto& ide : trackIDEs) {
494  tids.insert(ide.trackID);
495  }//End for TrackIDEs
496  }//End for hits
497  return tids;
498  }//End GetSetOfTrackIds
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:114
Detector simulation of raw signals on wires.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
const double cheat::BackTracker::HitChargeCollectionEfficiency ( std::set< int >  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits,
std::vector< art::Ptr< recob::Hit > > const &  allhits,
geo::View_t const &  view 
) const

Definition at line 454 of file BackTracker.cc.

References fMinHitEnergyFraction, hits(), HitToTrackIDEs(), and geo::k3D.

Referenced by cheat::BackTrackerService::HitChargeCollectionEfficiency(), and HitToXYZ().

457  {
458  double desired=0.,total=0.;
459  for( const auto& hit : hits){
460  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
461  for(const auto& hitIDE : hitTrackIDEs){
462  if(trackIds.find(hitIDE.trackID) != trackIds.end() && hitIDE.energyFrac >= fMinHitEnergyFraction){
463  desired+=hit->Integral();
464  break;
465  }//end if hit id matches and energy sufficient.
466  }//End for IDE in HitTrackIDEs.
467  }//End for hit in hits.
468 
469  for( const auto& hit : allHits ){
470  if(hit->View() != view && view != geo::k3D){ continue; }
471  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
472  for( const auto& hitIDE : hitTrackIDEs ){
473  if(trackIds.find(hitIDE.trackID) != trackIds.end() && hitIDE.energyFrac >= fMinHitEnergyFraction){
474  total += hit->Integral();
475  break;
476  }//end if hit matches
477  }//end for ide in ides
478  }//End for hit in allHits
479 
480  if(total>0.) {return desired/total;}
481  return 0.;
482 
483  }
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:82
Detector simulation of raw signals on wires.
const double cheat::BackTracker::HitChargeCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const

Definition at line 405 of file BackTracker.cc.

References hits(), and HitToTrackIDEs().

Referenced by cheat::BackTrackerService::HitChargeCollectionPurity(), and HitToXYZ().

405  {
406  double totalCharge=0.,desired=0.;
407  for(const auto& hit : hits){
408  totalCharge+=hit->Integral();
409  std::vector<sim::TrackIDE> trackIDEs= this->HitToTrackIDEs(hit);
410  for(const auto& trackIDE : trackIDEs){
411  if(trackIds.find(trackIDE.trackID)!=trackIds.end()){
412  desired+=hit->Integral();
413  break;
414  }//End if trackId in trackIds.
415  }//End for trackIDE in trackIDEs
416  }//End for Hit in Hits
417  if(totalCharge>0.0){return (desired/totalCharge);}
418  return 0.0;
419  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
Detector simulation of raw signals on wires.
const double cheat::BackTracker::HitCollectionEfficiency ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits,
std::vector< art::Ptr< recob::Hit > > const &  allhits,
geo::View_t const &  view 
) const

Definition at line 422 of file BackTracker.cc.

References fMinHitEnergyFraction, hits(), HitToTrackIDEs(), and geo::k3D.

Referenced by cheat::BackTrackerService::HitCollectionEfficiency(), and HitToXYZ().

425  {
426 
427  int desired=0,total=0;
428 
429  for( const auto& hit : hits){
430  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
431  for( const auto& trackIDE : hitTrackIDEs){
432  if( trackIds.find(trackIDE.trackID)!=trackIds.end() && trackIDE.energyFrac >= fMinHitEnergyFraction){
433  ++desired;
434  break;
435  }//End if trackID in trackIds.
436  }//end for trackIDE in TrackIDEs
437  }//end for hit in hits
438 
439  for( const auto& hit : allHits){
440  if(hit->View()!=view && view != geo::k3D) {continue;}//End if hit.view = view or view = geo::k3D
441  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
442  for( const auto& hitIDE : hitTrackIDEs){
443  if(trackIds.find(hitIDE.trackID)!=trackIds.end() && hitIDE.energyFrac>=fMinHitEnergyFraction){
444  ++total;
445  break;
446  }
447  }//END for all IDEs in HitTrackIDEs.
448  }//end for hit in allHits.
449  if(total >= 0){ return double(double(desired)/double(total));}
450  return 0.;
451  }
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:82
Detector simulation of raw signals on wires.
const double cheat::BackTracker::HitCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const

Definition at line 389 of file BackTracker.cc.

References hits(), and HitToTrackIDEs().

Referenced by cheat::BackTrackerService::HitCollectionPurity(), and HitToXYZ().

389  {
390  int desired =0;
391  for( const auto& hit : hits ){
392  std::vector<sim::TrackIDE> hitTrackIDEs=this->HitToTrackIDEs(hit);
393  for(const auto& tIDE : hitTrackIDEs){
394  if(trackIds.find(tIDE.trackID)!=trackIds.end()){
395  ++desired;
396  break;
397  }//End if TID Found
398  }//END for trackIDE in TrackIDEs
399  }//End for hit in hits
400  if(hits.size()>0){return double(double(desired)/double(hits.size()));}
401  return 0;
402  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
Detector simulation of raw signals on wires.
const std::vector< sim::IDE > cheat::BackTracker::HitToAvgSimIDEs ( recob::Hit const &  hit) const

Definition at line 279 of file BackTracker.cc.

References recob::Hit::Channel(), fDetClocks, FindSimChannel(), recob::Hit::PeakTimeMinusRMS(), recob::Hit::PeakTimePlusRMS(), and detinfo::DetectorClocks::TPCTick2TDC().

Referenced by cheat::BackTrackerService::HitToAvgSimIDEs(), and HitToEveTrackIDEs().

279  {
280  // Get services.
281 
282  int start_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimeMinusRMS() );
283  int end_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimePlusRMS() );
284  if(start_tdc<0) start_tdc = 0;
285  if(end_tdc<0) end_tdc = 0;
286 
287  return (this->FindSimChannel(hit.Channel()))->TrackIDsAndEnergies(start_tdc, end_tdc);
288  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:159
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:101
Detector simulation of raw signals on wires.
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
const std::vector< sim::IDE > cheat::BackTracker::HitToAvgSimIDEs ( art::Ptr< recob::Hit hit) const
inline

Definition at line 124 of file BackTracker.h.

References HitToAvgSimIDEs(), and HitToSimIDEs_Ps().

Referenced by HitToAvgSimIDEs().

124 { return this->HitToAvgSimIDEs(*hit);}
const std::vector< sim::IDE > HitToAvgSimIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:279
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToEveTrackIDEs ( recob::Hit const &  hit) const

Definition at line 184 of file BackTracker.cc.

References sim::TrackIDE::energy, sim::TrackIDE::energyFrac, fPartInv, HitToTrackIDEs(), sim::TrackIDE::numElectrons, sim::TrackIDE::trackID, and cheat::ParticleInventory::TrackIdToEveTrackId().

Referenced by GetSetOfEveIds(), cheat::BackTrackerService::HitToEveTrackIDEs(), and HitToTrackIDEs().

185  {
186  std::vector<sim::TrackIDE> eveIDEs;
187  std::vector<sim::TrackIDE> trackIDEs = this->HitToTrackIDEs(hit);
188  std::map<int, std::pair<double,double>> eveToEMap;
189  double totalE=0.0;
190  for (const auto& trackIDE : trackIDEs){
191  auto check = eveToEMap.emplace(
192  fPartInv->TrackIdToEveTrackId(trackIDE.trackID),
193  std::make_pair(trackIDE.energy,trackIDE.numElectrons));
194  if(check.second==false)
195  {
196  check.first->second.first +=trackIDE.energy;
197  check.first->second.second +=trackIDE.numElectrons;
198  }
199  // eveToEMap[fPartInv->TrackIdToEveTrackId(trackIDE.trackID)].first
200  // += trackIDE.energy;
201  totalE+=trackIDE.energy;
202  }//End for trackIDEs
203  eveIDEs.reserve(eveToEMap.size());
204  for(const auto& eveToE : eveToEMap){
205  sim::TrackIDE eveTrackIDE_tmp;
206 
207  eveTrackIDE_tmp.trackID = eveToE.first;
208  eveTrackIDE_tmp.energy = eveToE.second.first;
209  eveTrackIDE_tmp.energyFrac = (eveTrackIDE_tmp.energy)/(totalE);
210  eveTrackIDE_tmp.numElectrons = eveToE.second.second;
211 
212  eveIDEs.push_back(eveTrackIDE_tmp);
213  }//END eveToEMap loop
214  return eveIDEs;
215  }
float numElectrons
number of electrons from the particle detected on the wires
Definition: SimChannel.h:32
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:31
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:157
Detector simulation of raw signals on wires.
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:29
int TrackIdToEveTrackId(const int &tid) const
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
const std::vector<sim::TrackIDE> cheat::BackTracker::HitToEveTrackIDEs ( art::Ptr< recob::Hit > const &  hit) const
inline

Definition at line 111 of file BackTracker.h.

References HitToAvgSimIDEs(), HitToEveTrackIDEs(), TrackIdsToHits_Ps(), TrackIdToHits_Ps(), and lar::dump::vector().

Referenced by HitToEveTrackIDEs().

111 { return this->HitToEveTrackIDEs(*hit);}
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:184
const std::vector< const sim::IDE * > cheat::BackTracker::HitToSimIDEs_Ps ( recob::Hit const &  hit) const

Definition at line 291 of file BackTracker.cc.

References recob::Hit::Channel(), fDetClocks, FindSimChannel(), recob::Hit::PeakTimeMinusRMS(), recob::Hit::PeakTimePlusRMS(), and detinfo::DetectorClocks::TPCTick2TDC().

Referenced by HitToAvgSimIDEs(), cheat::BackTrackerService::HitToSimIDEs_Ps(), and HitToXYZ().

291  {
292  std::vector< const sim::IDE* > retVec;
293  // const auto start_tdc = hit.PeakTimeMinusRMS();
294  // const auto end_tdc = hit.PeakTimePlusRMS();
295  int start_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimeMinusRMS() );
296  int end_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimePlusRMS() );
297  if(start_tdc<0) start_tdc = 0;
298  if(end_tdc<0) end_tdc = 0;
299 
300  if(start_tdc > end_tdc){throw;}
301 
302  /* auto sc = this->FindSimChannel(hit.Channel());
303  auto tdcidemap = sc->TDCIDEMap();
304  auto& tdcidemapref = sc->TDCIDEMap();*/
305 
306  const std::vector< std::pair<unsigned short, std::vector<sim::IDE>> >& tdcIDEMap = (this->FindSimChannel(hit.Channel()))->TDCIDEMap(); //This in fact does not return a map. It returns a vector... with no guarantee that it is sorted...
307  std::vector<const std::pair<unsigned short, std::vector<sim::IDE>>*> tdcIDEMap_SortedPointers;
308  for ( auto& pair : tdcIDEMap ){
309  tdcIDEMap_SortedPointers.push_back(&pair);
310  }
311 
312  //Sort a vector of pointers to the TDCIDEs
313  /*
314  auto pairSort = [](auto& a, auto& b) { return a.first < b.first ; } ;
315  if( !std::is_sorted( tdcIDEMap.begin(), tdcIDEMap.end(), pairSort)) {
316  std::cout<<"AlreadySorted\n";
317  // std::sort (tdcIDEMap.begin(), tdcIDEMap.end(), pairSort);
318  }else{
319  throw;
320  }*/
321 
322  //This is a bunch of extra steps, due to needing a vector we can sort, and needing those items in the sorted vector to be the items from the sim channels (so a pointer to the IDEs inside the sim channels can be made). The work around is to make a vector of pointers to IDEs inside the TDCIDEMap (which is a constant reference to the fTDCIDEs in the SimChannel.)
323  auto pairSort = [](auto& a, auto& b) { return a->first < b->first ; } ;
324  if( !std::is_sorted( tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), pairSort)) {
325  std::sort (tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), pairSort);
326  }
327 
328 
329  std::vector<sim::IDE> dummyVec; //I need something to stick in a pair to compare pair<tdcVal, IDE>. This is an otherwise useless "hack".
330  std::pair<double, std::vector<sim::IDE>> start_tdcPair = std::make_pair(start_tdc,dummyVec); //This pair is a "hack" to make my comparison work for lower and upper bound.
331  std::pair<double, std::vector<sim::IDE>> end_tdcPair = std::make_pair(end_tdc,dummyVec);
332  //const std::vector<std::pair<unsigned short, std::vector<sim::IDE> > >::iterator //iterator to the first interesting IDE
333  auto start_tdcPair_P = &start_tdcPair;
334  auto end_tdcPair_P = &end_tdcPair;
335  auto
336  mapFirst = std::lower_bound(tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), start_tdcPair_P, pairSort);
337  //mapFirst = std::lower_bound(tdcIDEMap.begin(), tdcIDEMap.end(), start_tdcPair, pairSort);
338  //const std::vector<std::pair<unsigned short, std::vector<sim::IDE> > >::iterator //iterator to just after the last interesting IDE
339  auto
340  mapLast = std::upper_bound(tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), end_tdcPair_P, pairSort);
341  for( auto& mapitr = mapFirst; mapitr != mapLast; ++mapitr ){
342  for( auto& ide : (*mapitr)->second){
343  retVec.push_back(&ide);
344  //std::cout<<"Dumping Selected IDEs from tdcIDEMap:\nTrackID: "<<ide.trackID<<"\nnumElectrons: "<<ide.numElectrons<<"\nenergy: "<<ide.energy<<"\nXYZ: "<<ide.x<<" "<<ide.y<<" "<<ide.z<<"\n";
345  } //Add all interesting IDEs to the retVec
346  }
347  /* for( auto ide : retVec){
348  std::cout<<"Dumping Selected IDEs from retVec:\nTrackID: "<<ide->trackID<<"\nnumElectrons: "<<ide->numElectrons<<"\nenergy: "<<ide->energy<<"\nXYZ: "<<ide->x<<" "<<ide->y<<" "<<ide->z<<"\n";
349  }*/
350  return retVec;
351  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:159
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:101
Detector simulation of raw signals on wires.
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
const std::vector< const sim::IDE* > cheat::BackTracker::HitToSimIDEs_Ps ( art::Ptr< recob::Hit > const &  hit) const
inline

Definition at line 127 of file BackTracker.h.

References HitToSimIDEs_Ps(), HitToXYZ(), and SimIDEsToXYZ().

Referenced by HitToSimIDEs_Ps().

127 { return this->HitToSimIDEs_Ps (*hit); }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:291
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToTrackIDEs ( recob::Hit const &  hit) const

Definition at line 164 of file BackTracker.cc.

References recob::Hit::Channel(), ChannelToTrackIDEs(), evd::details::end(), recob::Hit::PeakTimeMinusRMS(), and recob::Hit::PeakTimePlusRMS().

Referenced by HitChargeCollectionEfficiency(), HitChargeCollectionPurity(), HitCollectionEfficiency(), HitCollectionPurity(), HitToEveTrackIDEs(), cheat::BackTrackerService::HitToTrackIDEs(), HitToTrackIds(), and SimChannels().

164  {
165  std::vector< sim::TrackIDE > trackIDEs;
166  const double start = hit.PeakTimeMinusRMS();
167  const double end = hit.PeakTimePlusRMS();
168  trackIDEs = this->ChannelToTrackIDEs(hit.Channel(), start, end);
169  return trackIDEs;
170  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:114
Detector simulation of raw signals on wires.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
const std::vector< sim::TrackIDE> cheat::BackTracker::HitToTrackIDEs ( art::Ptr< recob::Hit > const &  hit) const
inline

Definition at line 105 of file BackTracker.h.

References HitToEveTrackIDEs(), HitToTrackIDEs(), and HitToTrackIds().

Referenced by HitToTrackIDEs().

105 { return this->HitToTrackIDEs(*hit);}
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
const std::vector< int > cheat::BackTracker::HitToTrackIds ( recob::Hit const &  hit) const

Definition at line 174 of file BackTracker.cc.

References HitToTrackIDEs().

Referenced by HitToTrackIDEs(), and cheat::BackTrackerService::HitToTrackIds().

174  {
175  std::vector< int > retVec;
176  for(auto const trackIDE : this->HitToTrackIDEs( hit ) ){
177  retVec.push_back( trackIDE.trackID );
178  }
179  return retVec;
180  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
Detector simulation of raw signals on wires.
const std::vector< double > cheat::BackTracker::HitToXYZ ( const recob::Hit hit) const

Definition at line 383 of file BackTracker.cc.

References HitToSimIDEs_Ps(), and SimIDEsToXYZ().

Referenced by HitToSimIDEs_Ps(), cheat::BackTrackerService::HitToXYZ(), and SpacePointHitsToWeightedXYZ().

383  {
384  std::vector<const sim::IDE*> ide_Ps = this->HitToSimIDEs_Ps(hit);
385  return this->SimIDEsToXYZ(ide_Ps);
386  }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:291
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:354
const std::vector<double> cheat::BackTracker::HitToXYZ ( art::Ptr< recob::Hit > const &  hit) const
inline

Definition at line 136 of file BackTracker.h.

References HitChargeCollectionEfficiency(), HitChargeCollectionPurity(), HitCollectionEfficiency(), HitCollectionPurity(), hits(), HitToXYZ(), and lar::dump::vector().

Referenced by HitToXYZ().

136 { return this->HitToXYZ(*hit);}
const std::vector< double > HitToXYZ(const recob::Hit &hit) const
Definition: BackTracker.cc:383
template<typename Evt >
void cheat::BackTracker::PrepEvent ( const Evt &  evt)
template<typename Evt >
void cheat::BackTracker::PrepSimChannels ( const Evt &  evt)
const std::vector<art::Ptr<sim::SimChannel> >& cheat::BackTracker::SimChannels ( ) const
inline

Definition at line 90 of file BackTracker.h.

References ChannelToTrackIDEs(), FindSimChannel(), fSimChannels, HitToTrackIDEs(), and TrackIdToSimIDEs_Ps().

Referenced by cheat::BackTrackerService::SimChannels().

90 { return fSimChannels; }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
bool cheat::BackTracker::SimChannelsReady ( ) const
inline

Definition at line 87 of file BackTracker.h.

References fSimChannels.

Referenced by cheat::BackTrackerService::priv_SimChannelsReady().

87 { return !( fSimChannels.empty() ); }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
const std::vector< double > cheat::BackTracker::SimIDEsToXYZ ( std::vector< sim::IDE > const &  ides) const

Definition at line 354 of file BackTracker.cc.

References e, w, and weight.

Referenced by HitToSimIDEs_Ps(), HitToXYZ(), cheat::BackTrackerService::SimIDEsToXYZ(), and SimIDEsToXYZ().

355  {
356  std::vector<double> xyz(3,0.0);
357  double w = 0.0;
358  for( auto const& ide : ides){
359  double weight=ide.numElectrons;
360  w += weight;
361  xyz[0] += (weight*ide.x);
362  xyz[1] += (weight*ide.y);
363  xyz[2] += (weight*ide.z);
364  }
365  if(w<1.e-5)
366  throw cet::exception("BackTracker")<<"No sim::IDEs providing non-zero number of electrons"
367  << " can't determine originating location from truth\n";
368  xyz[0] = xyz[0]/w;
369  xyz[1] = xyz[1]/w;
370  xyz[2] = xyz[2]/w;
371  return xyz;
372  }
double weight
Definition: plottest35.C:25
Float_t e
Definition: plot.C:34
Float_t w
Definition: plot.C:23
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< double > cheat::BackTracker::SimIDEsToXYZ ( std::vector< const sim::IDE * > const &  ide_Ps) const

Definition at line 375 of file BackTracker.cc.

References SimIDEsToXYZ().

375  {
376  std::vector<sim::IDE> ides;
377  for(auto ide_P : ide_Ps ){ ides.push_back(*ide_P);}
378  return this->SimIDEsToXYZ(ides);
379  }
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:354
const std::vector< double > cheat::BackTracker::SpacePointHitsToWeightedXYZ ( std::vector< art::Ptr< recob::Hit >> const &  hits) const

Definition at line 512 of file BackTracker.cc.

References geo::CryostatID::Cryostat, fGeom, hits(), HitToXYZ(), recob::Hit::Integral(), geo::GeometryCore::Ncryostats(), geo::GeometryCore::Nplanes(), geo::GeometryCore::NTPC(), geo::PlaneID::Plane, geo::GeometryCore::PositionToTPC(), geo::TPCID::TPC, and recob::Hit::WireID().

Referenced by GetSetOfEveIds(), and cheat::BackTrackerService::SpacePointHitsToWeightedXYZ().

512  {
513  std::vector<double> xyz(3,-99999.9);
514  std::vector< std::vector<std::vector<int>>> numHits (fGeom->Ncryostats());
515  std::vector< std::vector<std::vector<double>>> hitWeight (fGeom->Ncryostats());
516  std::vector< std::vector<std::vector<std::vector<double>>>> hitPos (fGeom->Ncryostats());
517  //Do we need to resize everything...
518  for(size_t c = 0; c < numHits.size(); ++c){
519  numHits[c].resize( fGeom->NTPC(c) );
520  hitWeight[c].resize( fGeom->NTPC(c) );
521  hitPos[c].resize( fGeom->NTPC(c) );
522  for(size_t t = 0; t < numHits[c].size(); ++t){
523  numHits[c][t].resize( fGeom->Nplanes(t, c) );
524  hitWeight[c][t].resize( fGeom->Nplanes(t, c) );
525  hitPos[c][t].resize( fGeom->Nplanes(t, c) );
526  }
527  }
528 
529  for(art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit) {
530 
531  const recob::Hit& hit = **ihit;
532 
533  // use the HitToXYZ and Geometry::PositionToTPC
534  // to figure out which drift volume the hit originates from
535  std::vector<double> hitOrigin = this->HitToXYZ(*ihit);
536  unsigned int cstat = 0;
537  unsigned int tpc = 0;
538  const double worldLoc[3] = {hitOrigin[0], hitOrigin[1], hitOrigin[2]};
539  fGeom->PositionToTPC(worldLoc, tpc, cstat);
540 
541  if(hit.WireID().Cryostat == cstat && hit.WireID().TPC == tpc){
542  ++numHits[cstat][tpc][hit.WireID().Plane];
543  hitWeight[cstat][tpc][hit.WireID().Plane] = hit.Integral();
544  hitPos[cstat][tpc][hit.WireID().Plane] = hitOrigin;
545  }
546 
547  }
548 
549  // loop over the vectors we made and find the average position for the hits
550  // in the future we might take a weighted average
551  int nhits = 0;
552  xyz[0] = 0.;
553  xyz[1] = 0.;
554  xyz[2] = 0.;
555  for(size_t c = 0; c < numHits.size(); ++c){
556  for(size_t t = 0; t < numHits[c].size(); ++t){
557  for(size_t p = 0; p < numHits[c][t].size(); ++p){
558 
559  if(numHits[c][t][p] == 1) {
560  ++nhits;
561  xyz[0] += hitPos[c][t][p][0];
562  xyz[1] += hitPos[c][t][p][1];
563  xyz[2] += hitPos[c][t][p][2];
564  }
565 
566  } // end loop over planes
567  } // end loop over tpcs
568  } // end loop over cryostats
569 
570  // get the average position
571  if(nhits < 1)
572  throw cet::exception("BackTracker") << "No hits to determine originating location from truth\n";
573 
574 
575  xyz[0] /= nhits;
576  xyz[1] /= nhits;
577  xyz[2] /= nhits;
578 
579  // Done.
580  return xyz;
581 
582  }
const geo::GeometryCore * fGeom
Definition: BackTracker.h:158
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:225
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
const std::vector< double > HitToXYZ(const recob::Hit &hit) const
Definition: BackTracker.cc:383
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
data_t::const_iterator const_iterator
Definition: PtrVector.h:61
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename Evt >
const std::vector< art::Ptr< recob::Hit > > cheat::BackTracker::SpacePointToHits_Ps ( art::Ptr< recob::SpacePoint > const &  spt,
const Evt &  evt 
) const
template<typename Evt >
const std::vector< double > cheat::BackTracker::SpacePointToXYZ ( art::Ptr< recob::SpacePoint > const &  spt,
const Evt &  evt 
) const
std::vector< std::vector< art::Ptr< recob::Hit > > > cheat::BackTracker::TrackIdsToHits_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::Hit > > const &  hitsIn 
) const

Definition at line 241 of file BackTracker.cc.

References recob::Hit::Channel(), ChannelToTrackIDEs(), fMinHitEnergyFraction, recob::Hit::PeakTimeMinusRMS(), and recob::Hit::PeakTimePlusRMS().

Referenced by HitToEveTrackIDEs(), and cheat::BackTrackerService::TrackIdsToHits_Ps().

241  {
242  // returns a subset of the hits in the hitsIn collection that are matched
243  // to MC particles listed in tkIds
244 
245  // temporary vector of TrackIds and Ptrs to hits so only one
246  // loop through the (possibly large) hitsIn collection is needed
247  std::vector<std::pair<int, art::Ptr<recob::Hit>>> hitList;
248  std::vector<sim::TrackIDE> tids;
249  for(auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
250  tids.clear();
251  art::Ptr<recob::Hit> const& hit = *itr;
252  tids=this->ChannelToTrackIDEs( hit->Channel(), hit->PeakTimeMinusRMS(), hit->PeakTimePlusRMS());
253  for(auto itid = tids.begin(); itid != tids.end(); ++itid) {
254  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
255  if(itid->trackID == *itkid) {
256  if(itid->energyFrac > fMinHitEnergyFraction)
257  hitList.push_back(std::make_pair(*itkid, hit));
258  }
259  } // itkid
260  } // itid
261  } // itr
262 
263  // now build the truHits vector that will be returned to the caller
264  std::vector<std::vector<art::Ptr<recob::Hit>>> truHits;
265  // temporary vector containing hits assigned to one MC particle
266  std::vector<art::Ptr<recob::Hit>> tmpHits;
267  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
268  tmpHits.clear();
269  for(auto itr = hitList.begin(); itr != hitList.end(); ++itr) {
270  if(*itkid == (*itr).first) tmpHits.push_back((*itr).second);
271  }
272  truHits.push_back(tmpHits);
273  }
274  return truHits;
275  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:114
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:240
Detector simulation of raw signals on wires.
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:237
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
std::vector< art::Ptr< recob::Hit > > cheat::BackTracker::TrackIdToHits_Ps ( const int &  tkId,
std::vector< art::Ptr< recob::Hit > > const &  hitsIn 
) const

Definition at line 218 of file BackTracker.cc.

References recob::Hit::Channel(), ChannelToTrackIDEs(), fMinHitEnergyFraction, recob::Hit::PeakTimeMinusRMS(), and recob::Hit::PeakTimePlusRMS().

Referenced by HitToEveTrackIDEs(), and cheat::BackTrackerService::TrackIdToHits_Ps().

218  {
219  // returns a subset of the hits in the hitsIn collection that are matched
220  // to the given track
221 
222  // temporary vector of TrackIds and Ptrs to hits so only one
223  // loop through the (possibly large) hitsIn collection is needed
224  std::vector< art::Ptr<recob::Hit>> hitList;
225  std::vector<sim::TrackIDE> trackIDE;
226  for(auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
227  trackIDE.clear();
228  art::Ptr<recob::Hit> const& hit = *itr;
229  trackIDE = this->ChannelToTrackIDEs( hit->Channel(), hit->PeakTimeMinusRMS(), hit->PeakTimePlusRMS());
230  for(auto itr_trakIDE = trackIDE.begin(); itr_trakIDE != trackIDE.end(); ++itr_trakIDE) {
231  if(itr_trakIDE->trackID == tkId && itr_trakIDE->energyFrac > fMinHitEnergyFraction)
232  hitList.push_back( hit);
233  } // itr_trakIDE
234  } // itr
235  return hitList;
236  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:114
const double fMinHitEnergyFraction
Definition: BackTracker.h:162
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:240
Detector simulation of raw signals on wires.
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:237
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
const std::vector< const sim::IDE * > cheat::BackTracker::TrackIdToSimIDEs_Ps ( int const &  id) const

Definition at line 59 of file BackTracker.cc.

References fSimChannels.

Referenced by SimChannels(), and cheat::BackTrackerService::TrackIdToSimIDEs_Ps().

59  {
60  std::vector< const sim::IDE* > ideps;
61  for(size_t sc = 0; sc < fSimChannels.size(); ++sc){
62  const auto & tdcidemap = fSimChannels[sc]->TDCIDEMap(); //This returns a reference.
63  // loop over the IDEMAP
64  for(auto mapitr = tdcidemap.begin(); mapitr != tdcidemap.end(); mapitr++){
65  // loop over the vector of IDE objects.
66  const std::vector<sim::IDE>& idevec = (*mapitr).second; //note, mapitr.second returns the actual data from the map, not a copy
67  for(size_t iv = 0; iv < idevec.size(); ++iv){
68  //const sim::IDE* const idep = &idevec[iv];
69  //if( abs(idevec[iv].trackID) == id) continue;
70  //ideps.push_back(idep);
71  if( abs(idevec[iv].trackID) == id) ideps.push_back(&(idevec[iv]));
72  }//end for index in idevec
73  } // end loop over map from sim::SimChannel
74  } // end loop over sim::SimChannels
75  return ideps;
76  }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
const std::vector< const sim::IDE * > cheat::BackTracker::TrackIdToSimIDEs_Ps ( int const &  id,
const geo::View_t  view 
) const

Definition at line 80 of file BackTracker.cc.

References fGeom, fSimChannels, sim::IDE::trackID, and geo::GeometryCore::View().

81  {
82  std::vector<const sim::IDE*> ide_Ps;
84  if (fGeom->View(sc->Channel()) != view) continue;
85 
86  // loop over the IDEMAP
87  for(const auto & item : sc->TDCIDEMap()){
88 
89  // loop over the vector of IDE objects.
90  for(const sim::IDE & ide : item.second){
91  if (abs(ide.trackID) == id) ide_Ps.push_back(&ide);
92  }
93  } // end loop over map from sim::SimChannel
94  } // end loop over sim::SimChannels
95 
96  return ide_Ps;
97  }
TrackID_t trackID
Geant4 supplied track ID.
Definition: SimChannel.h:115
const geo::GeometryCore * fGeom
Definition: BackTracker.h:158
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:165
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:87
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.

Member Data Documentation

const detinfo::DetectorClocks* cheat::BackTracker::fDetClocks
private

Definition at line 159 of file BackTracker.h.

Referenced by ChannelToTrackIDEs(), HitToAvgSimIDEs(), and HitToSimIDEs_Ps().

const art::InputTag cheat::BackTracker::fG4ModuleLabel
private

Definition at line 160 of file BackTracker.h.

const geo::GeometryCore* cheat::BackTracker::fGeom
private

Definition at line 158 of file BackTracker.h.

Referenced by SpacePointHitsToWeightedXYZ(), and TrackIdToSimIDEs_Ps().

const art::InputTag cheat::BackTracker::fHitLabel
private

Definition at line 161 of file BackTracker.h.

const double cheat::BackTracker::fMinHitEnergyFraction
private
const bool cheat::BackTracker::fOverrideRealData
private

Definition at line 163 of file BackTracker.h.

Referenced by CanRun().

const cheat::ParticleInventory* cheat::BackTracker::fPartInv
private

Definition at line 157 of file BackTracker.h.

Referenced by GetSetOfEveIds(), GetSetOfTrackIds(), and HitToEveTrackIDEs().

std::vector<art::Ptr<sim::SimChannel> > cheat::BackTracker::fSimChannels
mutableprivate

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