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

#include "BackTrackerService.h"

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

Classes

struct  fhiclConfig
 

Public Types

using provider_type = BackTracker
 

Public Member Functions

const provider_typeprovider () const
 
 BackTrackerService (const fhicl::ParameterSet &pSet, art::ActivityRegistry &reg)
 
 BackTrackerService (const fhiclConfig &config, art::ActivityRegistry &reg)
 
void Rebuild (const art::Event &evt)
 
const std::vector< art::Ptr< sim::SimChannel > > & SimChannels ()
 
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps (int const &id)
 
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 std::vector< sim::TrackIDEChannelToTrackIDEs (raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time)
 
const std::vector< sim::TrackIDEHitToTrackIDEs (recob::Hit const &hit)
 
const std::vector< sim::TrackIDEHitToTrackIDEs (art::Ptr< recob::Hit > const &hit)
 
const std::vector< int > HitToTrackIds (recob::Hit const &hit)
 
const std::vector< sim::TrackIDEHitToEveTrackIDEs (recob::Hit const &hit)
 
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< art::Ptr< recob::Hit > > TrackIdToHits_Ps (const int &tkId)
 
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 std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps (std::vector< int > const &tkIds)
 
const std::vector< sim::IDEHitToAvgSimIDEs (recob::Hit const &hit)
 
const std::vector< sim::IDEHitToAvgSimIDEs (art::Ptr< recob::Hit > hit)
 
const std::vector< const sim::IDE * > HitToSimIDEs_Ps (recob::Hit const &hit)
 
const std::vector< const sim::IDE * > HitToSimIDEs_Ps (art::Ptr< recob::Hit > const &hit)
 
const std::vector< double > SimIDEsToXYZ (std::vector< sim::IDE > const &ides)
 
const std::vector< double > SimIDEsToXYZ (std::vector< const sim::IDE * > const &ide_Ps)
 
const std::vector< double > HitToXYZ (const recob::Hit &hit)
 
const std::vector< double > HitToXYZ (art::Ptr< recob::Hit > const &hit)
 
const double HitCollectionPurity (std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits)
 
const double HitChargeCollectionPurity (std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits)
 
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 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 std::set< int > GetSetOfTrackIds ()
 
const std::set< int > GetSetOfEveIds ()
 
const std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::Hit > > const &hits)
 
const std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::Hit > > const &hits)
 
const std::vector< double > SpacePointHitsToWeightedXYZ (std::vector< art::Ptr< recob::Hit >> const &hits)
 
const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps (art::Ptr< recob::SpacePoint > const &spt)
 
const std::vector< double > SpacePointToXYZ (art::Ptr< recob::SpacePoint > const &spt)
 

Private Member Functions

void priv_PrepEvent (const art::Event &evt)
 
void priv_PrepSimChannels (const art::Event &evt)
 
void priv_PrepFailed ()
 
bool priv_CanRun (const art::Event &evt)
 
bool priv_SimChannelsReady ()
 
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 > GetSetOfTrackIds (std::vector< art::Ptr< recob::Hit > > const &hits) const
 
const std::set< int > GetSetOfEveIds () 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 art::EventfEvt =nullptr
 

Detailed Description

Definition at line 29 of file BackTrackerService.h.

Member Typedef Documentation

Constructor & Destructor Documentation

cheat::BackTrackerService::BackTrackerService ( const fhicl::ParameterSet pSet,
art::ActivityRegistry reg 
)

Definition at line 25 of file BackTrackerService_service.cc.

References priv_PrepEvent(), and art::ActivityRegistry::sPreProcessEvent.

Referenced by provider().

26  :BackTracker(
27  pSet.get<fhicl::ParameterSet>("BackTracker"),
28  lar::providerFrom<cheat::ParticleInventoryService>(),
29  lar::providerFrom<geo::Geometry>(),
30  lar::providerFrom<detinfo::DetectorClocksService>()
31  )
32  {
34  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
void priv_PrepEvent(const art::Event &evt)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
BackTracker(const fhiclConfig &config, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom, const detinfo::DetectorClocks *detClock)
Definition: BackTracker.cc:29
cheat::BackTrackerService::BackTrackerService ( const fhiclConfig config,
art::ActivityRegistry reg 
)

Definition at line 37 of file BackTrackerService_service.cc.

References priv_PrepEvent(), and art::ActivityRegistry::sPreProcessEvent.

38  :BackTracker(
39  config.BackTrackerTable(),
40  lar::providerFrom<cheat::ParticleInventoryService>(),
41  lar::providerFrom<geo::Geometry>(),
42  lar::providerFrom<detinfo::DetectorClocksService>()
43  )
44  {
45  //This line is only to be included until art/LArSoft discussion about lazy rebuild can be completed.
47  }
void priv_PrepEvent(const art::Event &evt)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
BackTracker(const fhiclConfig &config, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom, const detinfo::DetectorClocks *detClock)
Definition: BackTracker.cc:29

Member Function Documentation

template<typename Evt >
bool cheat::BackTracker::CanRun ( const Evt &  evt)
inlineinherited
const std::vector< sim::TrackIDE > cheat::BackTrackerService::ChannelToTrackIDEs ( raw::ChannelID_t  channel,
const double  hit_start_time,
const double  hit_end_time 
)

Definition at line 138 of file BackTrackerService_service.cc.

References cheat::BackTracker::ChannelToTrackIDEs().

Referenced by tca::GetOrigin(), and provider().

138  {
139  //Removed until Lazy Rebuild works
140  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
141  return BackTracker::ChannelToTrackIDEs(channel, hit_start_time, hit_end_time);
142  }
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 std::vector< sim::TrackIDE > cheat::BackTracker::ChannelToTrackIDEs ( raw::ChannelID_t  channel,
const double  hit_start_time,
const double  hit_end_time 
) const
inherited

Definition at line 114 of file BackTracker.cc.

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

Referenced by ChannelToTrackIDEs(), cheat::BackTracker::GetSetOfTrackIds(), cheat::BackTracker::HitToTrackIDEs(), cheat::BackTracker::SimChannels(), cheat::BackTracker::TrackIdsToHits_Ps(), and cheat::BackTracker::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 ( )
inherited

Definition at line 53 of file BackTracker.cc.

References cheat::BackTracker::fSimChannels.

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

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

Definition at line 131 of file BackTrackerService_service.cc.

References cheat::BackTracker::FindSimChannel().

Referenced by provider().

131  {
132  //Removed until Lazy Rebuild works
133  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
134  return BackTracker::FindSimChannel(channel);
135  }
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:101
art::Ptr< sim::SimChannel > cheat::BackTracker::FindSimChannel ( raw::ChannelID_t  channel) const
inherited

Definition at line 101 of file BackTracker.cc.

References cheat::BackTracker::fSimChannels.

Referenced by cheat::BackTracker::ChannelToTrackIDEs(), FindSimChannel(), cheat::BackTracker::HitToAvgSimIDEs(), cheat::BackTracker::HitToSimIDEs_Ps(), and cheat::BackTracker::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::BackTrackerService::GetSetOfEveIds ( )

Definition at line 324 of file BackTrackerService_service.cc.

References cheat::BackTracker::GetSetOfEveIds().

Referenced by provider().

325  {
326  //Removed until Lazy Rebuild works
327  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
329  }
const std::set< int > GetSetOfEveIds() const
Definition: BackTracker.h:149
const std::set< int > cheat::BackTrackerService::GetSetOfEveIds ( std::vector< art::Ptr< recob::Hit > > const &  hits)

Definition at line 343 of file BackTrackerService_service.cc.

References cheat::BackTracker::GetSetOfEveIds(), and hits().

344  {
345  //Removed until Lazy Rebuild works
346  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
347  return BackTracker::GetSetOfEveIds(hits);
348  }
const std::set< int > GetSetOfEveIds() const
Definition: BackTracker.h:149
const std::set<int> cheat::BackTracker::GetSetOfEveIds ( ) const
inlineinherited
const std::set< int > cheat::BackTracker::GetSetOfEveIds ( std::vector< art::Ptr< recob::Hit > > const &  hits) const
inherited

Definition at line 501 of file BackTracker.cc.

References hits(), and cheat::BackTracker::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::BackTrackerService::GetSetOfTrackIds ( )

Definition at line 315 of file BackTrackerService_service.cc.

References cheat::BackTracker::GetSetOfTrackIds().

Referenced by cheat::RecoCheckAna::CheckReco(), cheat::RecoCheckAna::FillResults(), and provider().

316  {
317  //Removed until Lazy Rebuild works
318  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
320  }
const std::set< int > GetSetOfTrackIds() const
Definition: BackTracker.h:148
const std::set< int > cheat::BackTrackerService::GetSetOfTrackIds ( std::vector< art::Ptr< recob::Hit > > const &  hits)

Definition at line 334 of file BackTrackerService_service.cc.

References cheat::BackTracker::GetSetOfTrackIds(), and hits().

335  {
336  //Removed until Lazy Rebuild works
337  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
338  return BackTracker::GetSetOfTrackIds(hits);
339  }
const std::set< int > GetSetOfTrackIds() const
Definition: BackTracker.h:148
const std::set<int> cheat::BackTracker::GetSetOfTrackIds ( ) const
inlineinherited

Definition at line 148 of file BackTracker.h.

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

Referenced by cheat::BackTracker::GetSetOfEveIds(), and 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
inherited

Definition at line 487 of file BackTracker.cc.

References cheat::BackTracker::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::BackTrackerService::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 
)

Definition at line 305 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitChargeCollectionEfficiency(), and hits().

Referenced by provider().

306  {
307  //Removed until Lazy Rebuild works
308  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
309  return BackTracker::HitChargeCollectionEfficiency(trackIds, hits, allhits, view);
310  }
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
Definition: BackTracker.cc:454
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
inherited

Definition at line 454 of file BackTracker.cc.

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

Referenced by HitChargeCollectionEfficiency(), and cheat::BackTracker::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::BackTrackerService::HitChargeCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
)

Definition at line 285 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitChargeCollectionPurity(), and hits().

Referenced by provider().

286  {
287  //Removed until Lazy Rebuild works
288  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
289  return BackTracker::HitChargeCollectionPurity(trackIds, hits);
290  }
const double HitChargeCollectionPurity(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
Definition: BackTracker.cc:405
const double cheat::BackTracker::HitChargeCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
inherited

Definition at line 405 of file BackTracker.cc.

References hits(), and cheat::BackTracker::HitToTrackIDEs().

Referenced by HitChargeCollectionPurity(), and cheat::BackTracker::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::BackTrackerService::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 
)

Definition at line 295 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitCollectionEfficiency(), and hits().

Referenced by cheat::CheckBackTracking::analyze(), cheat::RecoCheckAna::CheckReco(), cheat::RecoCheckAna::CheckRecoEvents(), cheat::RecoCheckAna::CheckRecoVertices(), and provider().

296  {
297  //Removed until Lazy Rebuild works
298  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
299  return BackTracker::HitCollectionEfficiency(trackIds, hits, allhits, view);
300  }
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
Definition: BackTracker.cc:422
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
inherited

Definition at line 422 of file BackTracker.cc.

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

Referenced by HitCollectionEfficiency(), and cheat::BackTracker::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::BackTrackerService::HitCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
)

Definition at line 276 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitCollectionPurity(), and hits().

Referenced by cheat::CheckBackTracking::analyze(), cheat::RecoCheckAna::CheckReco(), cheat::RecoCheckAna::CheckRecoEvents(), cheat::RecoCheckAna::CheckRecoVertices(), and provider().

277  {
278  //Removed until Lazy Rebuild works
279  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
280  return BackTracker::HitCollectionPurity(trackIds, hits);
281  }
const double HitCollectionPurity(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
Definition: BackTracker.cc:389
const double cheat::BackTracker::HitCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
inherited

Definition at line 389 of file BackTracker.cc.

References hits(), and cheat::BackTracker::HitToTrackIDEs().

Referenced by HitCollectionPurity(), and cheat::BackTracker::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::BackTrackerService::HitToAvgSimIDEs ( recob::Hit const &  hit)

Definition at line 210 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToAvgSimIDEs().

Referenced by trkf::SpacePointAlg::makeSpacePoints(), and provider().

210  {
211  //Removed until Lazy Rebuild works
212  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
214  }
Detector simulation of raw signals on wires.
const std::vector< sim::IDE > HitToAvgSimIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:279
const std::vector< sim::IDE > cheat::BackTrackerService::HitToAvgSimIDEs ( art::Ptr< recob::Hit hit)

Definition at line 217 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToAvgSimIDEs().

217  {
218  //Removed until Lazy Rebuild works
219  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
220  return BackTracker::HitToAvgSimIDEs(hit);
221  }
const std::vector< sim::IDE > HitToAvgSimIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:279
const std::vector< sim::IDE > cheat::BackTracker::HitToAvgSimIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 279 of file BackTracker.cc.

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

Referenced by HitToAvgSimIDEs(), and cheat::BackTracker::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
inlineinherited

Definition at line 124 of file BackTracker.h.

References cheat::BackTracker::HitToAvgSimIDEs(), and cheat::BackTracker::HitToSimIDEs_Ps().

Referenced by cheat::BackTracker::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::BackTrackerService::HitToEveTrackIDEs ( recob::Hit const &  hit)

Definition at line 166 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToEveTrackIDEs().

Referenced by cheat::CheckBackTracking::analyze(), cluster::DBclusterAna::analyze(), DUNE::NeutrinoShowerEff::checkCNNtrkshw(), cluster::ClusterCheater::produce(), provider(), shower::TCShowerTemplateMaker::showerProfileTrue(), DUNE::NeutrinoShowerEff::truthMatcher(), and shower::TCShowerAnalysis::truthMatcher().

166  {
167  //Removed until Lazy Rebuild works
168  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
170  }
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:184
Detector simulation of raw signals on wires.
const std::vector< sim::TrackIDE > cheat::BackTrackerService::HitToEveTrackIDEs ( art::Ptr< recob::Hit > const &  hit)

Definition at line 173 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToEveTrackIDEs().

173  {
174  //Removed until Lazy Rebuild works
175  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
176  return BackTracker::HitToEveTrackIDEs(hit);
177  }
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:184
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToEveTrackIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 184 of file BackTracker.cc.

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

Referenced by cheat::BackTracker::GetSetOfEveIds(), HitToEveTrackIDEs(), and cheat::BackTracker::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
inlineinherited
const std::vector< const sim::IDE * > cheat::BackTrackerService::HitToSimIDEs_Ps ( recob::Hit const &  hit)

Definition at line 224 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToSimIDEs_Ps().

Referenced by hit::DisambigCheater::InitHitToWids(), and provider().

224  {
225  //Removed until Lazy Rebuild works
226  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
228  }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:291
Detector simulation of raw signals on wires.
const std::vector< const sim::IDE * > cheat::BackTrackerService::HitToSimIDEs_Ps ( art::Ptr< recob::Hit > const &  hit)

Definition at line 231 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToSimIDEs_Ps().

231  {
232  //Removed until Lazy Rebuild works
233  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
234  return BackTracker::HitToSimIDEs_Ps(hit);
235  }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:291
const std::vector< const sim::IDE * > cheat::BackTracker::HitToSimIDEs_Ps ( recob::Hit const &  hit) const
inherited

Definition at line 291 of file BackTracker.cc.

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

Referenced by cheat::BackTracker::HitToAvgSimIDEs(), HitToSimIDEs_Ps(), and cheat::BackTracker::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
inlineinherited

Definition at line 127 of file BackTracker.h.

References cheat::BackTracker::HitToSimIDEs_Ps(), cheat::BackTracker::HitToXYZ(), and cheat::BackTracker::SimIDEsToXYZ().

Referenced by cheat::BackTracker::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::BackTrackerService::HitToTrackIDEs ( recob::Hit const &  hit)
const std::vector< sim::TrackIDE > cheat::BackTrackerService::HitToTrackIDEs ( art::Ptr< recob::Hit > const &  hit)

Definition at line 152 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToTrackIDEs().

152  {
153  //Removed until Lazy Rebuild works
154  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
155  return BackTracker::HitToTrackIDEs(hit);
156  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:164
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToTrackIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 164 of file BackTracker.cc.

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

Referenced by cheat::BackTracker::HitChargeCollectionEfficiency(), cheat::BackTracker::HitChargeCollectionPurity(), cheat::BackTracker::HitCollectionEfficiency(), cheat::BackTracker::HitCollectionPurity(), cheat::BackTracker::HitToEveTrackIDEs(), HitToTrackIDEs(), cheat::BackTracker::HitToTrackIds(), and cheat::BackTracker::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
inlineinherited

Definition at line 105 of file BackTracker.h.

References cheat::BackTracker::HitToEveTrackIDEs(), cheat::BackTracker::HitToTrackIDEs(), and cheat::BackTracker::HitToTrackIds().

Referenced by cheat::BackTracker::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::BackTrackerService::HitToTrackIds ( recob::Hit const &  hit)

Definition at line 159 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToTrackIds().

Referenced by provider().

159  {
160  //Removed until Lazy Rebuild works
161  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
163  }
const std::vector< int > HitToTrackIds(recob::Hit const &hit) const
Definition: BackTracker.cc:174
Detector simulation of raw signals on wires.
const std::vector< int > cheat::BackTracker::HitToTrackIds ( recob::Hit const &  hit) const
inherited

Definition at line 174 of file BackTracker.cc.

References cheat::BackTracker::HitToTrackIDEs().

Referenced by cheat::BackTracker::HitToTrackIDEs(), and 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::BackTrackerService::HitToXYZ ( const recob::Hit hit)

Definition at line 257 of file BackTrackerService_service.cc.

References cheat::BackTracker::HitToXYZ().

Referenced by cheat::CheckBackTracking::analyze(), trkf::SpacePointAna::analyze(), hit::MagDriftAna::analyze(), hit::HitFinderAna::analyze(), hit::GausHitFinderAna::analyze(), HitToXYZ(), shwf::ShowerCheater::produce(), trkf::TrackCheater::produce(), provider(), apa::DisambigAlg::RunDisambig(), apa::DisambigAlg::TrivialDisambig(), and reco3d::PlotSpacePoints::TrueSpacePoints().

258  {
259  //Removed until Lazy Rebuild works
260  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
261  return BackTracker::HitToXYZ(hit);
262  }
const std::vector< double > HitToXYZ(const recob::Hit &hit) const
Definition: BackTracker.cc:383
const std::vector< double > cheat::BackTrackerService::HitToXYZ ( art::Ptr< recob::Hit > const &  hit)

Definition at line 266 of file BackTrackerService_service.cc.

References HitToXYZ().

267  {
268  //Removed until Lazy Rebuild works
269  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
270  return HitToXYZ(*hit);
271  }
const std::vector< double > HitToXYZ(const recob::Hit &hit)
const std::vector< double > cheat::BackTracker::HitToXYZ ( const recob::Hit hit) const
inherited

Definition at line 383 of file BackTracker.cc.

References cheat::BackTracker::HitToSimIDEs_Ps(), and cheat::BackTracker::SimIDEsToXYZ().

Referenced by cheat::BackTracker::HitToSimIDEs_Ps(), HitToXYZ(), and cheat::BackTracker::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
inlineinherited
template<typename Evt >
void cheat::BackTracker::PrepEvent ( const Evt &  evt)
inherited
template<typename Evt >
void cheat::BackTracker::PrepSimChannels ( const Evt &  evt)
inherited

Referenced by priv_PrepSimChannels().

bool cheat::BackTrackerService::priv_CanRun ( const art::Event evt)
private

Definition at line 72 of file BackTrackerService_service.cc.

References cheat::BackTracker::CanRun().

Referenced by priv_PrepEvent(), and priv_PrepSimChannels().

72  {
73  return BackTracker::CanRun(evt);
74  }
bool CanRun(const Evt &evt)
Definition: BackTracker.h:72
void cheat::BackTrackerService::priv_PrepEvent ( const art::Event evt)
private

Definition at line 63 of file BackTrackerService_service.cc.

References cheat::BackTracker::ClearEvent(), tca::evt, fEvt, priv_CanRun(), and priv_PrepSimChannels().

Referenced by BackTrackerService(), and Rebuild().

63  {
64  fEvt=&evt;
66  if( ! this->priv_CanRun(evt) ){ return; }
67  this->priv_PrepSimChannels(evt);
68  fEvt=nullptr; //don't save the pointer because it will be useless after this anyways. I want to make sure calls at the wrong time crash.
69  }
void priv_PrepSimChannels(const art::Event &evt)
bool priv_CanRun(const art::Event &evt)
TCEvent evt
Definition: DataStructs.cxx:5
void cheat::BackTrackerService::priv_PrepFailed ( )
private

Definition at line 77 of file BackTrackerService_service.cc.

Referenced by priv_PrepSimChannels().

77  {
78  throw cet::exception("BackTrackerService")
79  <<"The called Prep Function failed. This is most likely due "
80  <<"to a BackTracker function being used on a file that is real data.";
81  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::BackTrackerService::priv_PrepSimChannels ( const art::Event evt)
private

Definition at line 84 of file BackTrackerService_service.cc.

References cheat::BackTracker::PrepSimChannels(), priv_CanRun(), priv_PrepFailed(), and priv_SimChannelsReady().

Referenced by priv_PrepEvent().

84  {
85  if( !this->priv_CanRun(evt)) { this->priv_PrepFailed(); }
86  if( this->priv_SimChannelsReady()){ return; }
88  catch(...){ mf::LogWarning("BackTrackerService") << "Rebuild failed to get the SimChannels. This is expected when running on a gernation or simulation step.";}
89  }
void PrepSimChannels(const Evt &evt)
bool priv_CanRun(const art::Event &evt)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool cheat::BackTrackerService::priv_SimChannelsReady ( )
inlineprivate

Definition at line 124 of file BackTrackerService.h.

References DECLARE_ART_SERVICE, and cheat::BackTracker::SimChannelsReady().

Referenced by priv_PrepSimChannels().

bool SimChannelsReady() const
Definition: BackTracker.h:87
void cheat::BackTrackerService::Rebuild ( const art::Event evt)

Event Rebuild Implimentation////////// This section contains the implimentation /// of all Prep templates from the service /// provider. ///

Definition at line 58 of file BackTrackerService_service.cc.

References priv_PrepEvent().

Referenced by cheat::BackTrackerLoader::produce(), and provider().

58  {
59  this->priv_PrepEvent(evt);
60  }
void priv_PrepEvent(const art::Event &evt)
const std::vector< art::Ptr< sim::SimChannel > > & cheat::BackTrackerService::SimChannels ( )

Definition at line 110 of file BackTrackerService_service.cc.

References cheat::BackTracker::SimChannels().

Referenced by provider().

110  {
111  //Removed until Lazy Rebuild works
112  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
113  return BackTracker::SimChannels();
114  }
const std::vector< art::Ptr< sim::SimChannel > > & SimChannels() const
Definition: BackTracker.h:90
const std::vector<art::Ptr<sim::SimChannel> >& cheat::BackTracker::SimChannels ( ) const
inlineinherited
bool cheat::BackTracker::SimChannelsReady ( ) const
inlineinherited

Definition at line 87 of file BackTracker.h.

References cheat::BackTracker::fSimChannels.

Referenced by priv_SimChannelsReady().

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

Definition at line 238 of file BackTrackerService_service.cc.

References cheat::BackTracker::SimIDEsToXYZ().

Referenced by hit::DisambigCheater::InitHitToWids(), trkf::SpacePointAlg::makeSpacePoints(), and provider().

239  {
240  //Removed until Lazy Rebuild works
241  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
242  return BackTracker::SimIDEsToXYZ(ides);
243  }
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:354
const std::vector< double > cheat::BackTrackerService::SimIDEsToXYZ ( std::vector< const sim::IDE * > const &  ide_Ps)

Definition at line 247 of file BackTrackerService_service.cc.

References cheat::BackTracker::SimIDEsToXYZ().

248  {
249  //Removed until Lazy Rebuild works
250  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
251  return BackTracker::SimIDEsToXYZ(ide_Ps);
252  }
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:354
const std::vector< double > cheat::BackTracker::SimIDEsToXYZ ( std::vector< sim::IDE > const &  ides) const
inherited

Definition at line 354 of file BackTracker.cc.

References e, w, and weight.

Referenced by cheat::BackTracker::HitToSimIDEs_Ps(), cheat::BackTracker::HitToXYZ(), SimIDEsToXYZ(), and cheat::BackTracker::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
inherited

Definition at line 375 of file BackTracker.cc.

References cheat::BackTracker::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::BackTrackerService::SpacePointHitsToWeightedXYZ ( std::vector< art::Ptr< recob::Hit >> const &  hits)

Definition at line 351 of file BackTrackerService_service.cc.

References hits(), and cheat::BackTracker::SpacePointHitsToWeightedXYZ().

Referenced by trkf::SpacePointAna::analyze(), and provider().

351  {
352  //if( !this->priv_CanRun(*fEvt)) { this->priv_PrepFailed(); }
354  }
const std::vector< double > SpacePointHitsToWeightedXYZ(std::vector< art::Ptr< recob::Hit >> const &hits) const
Definition: BackTracker.cc:512
const std::vector< double > cheat::BackTracker::SpacePointHitsToWeightedXYZ ( std::vector< art::Ptr< recob::Hit >> const &  hits) const
inherited

Definition at line 512 of file BackTracker.cc.

References geo::CryostatID::Cryostat, cheat::BackTracker::fGeom, hits(), cheat::BackTracker::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 cheat::BackTracker::GetSetOfEveIds(), and 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
inherited
const std::vector< art::Ptr< recob::Hit > > cheat::BackTrackerService::SpacePointToHits_Ps ( art::Ptr< recob::SpacePoint > const &  spt)

Definition at line 357 of file BackTrackerService_service.cc.

References fEvt, and cheat::BackTracker::SpacePointToHits_Ps().

Referenced by provider().

357  {
358  //Note, this function is goofy in that it doesn't use the hits prepared by the module. That should likely be changed to make things more uniform.
359  //if( !this->priv_CanRun(*fEvt)) { this->priv_PrepFailed(); }
360  if( ! fEvt ){
361  throw cet::exception("BackTrackerService")
362  <<"This function is not yet implimented pending the implimentation of backtracker lazy loading.";
363  }
365  }
const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename Evt >
const std::vector< double > cheat::BackTracker::SpacePointToXYZ ( art::Ptr< recob::SpacePoint > const &  spt,
const Evt &  evt 
) const
inherited
const std::vector< double > cheat::BackTrackerService::SpacePointToXYZ ( art::Ptr< recob::SpacePoint > const &  spt)

Definition at line 368 of file BackTrackerService_service.cc.

References DEFINE_ART_SERVICE, fEvt, and cheat::BackTracker::SpacePointToXYZ().

Referenced by provider().

368  {
369  //if( !this->priv_CanRun(*fEvt)) { this->priv_PrepFailed(); }
370  if( ! fEvt ){
371  throw cet::exception("BackTrackerService")
372  <<"This function is not yet implimented pending the implimentation of backtracker lazy loading.";
373  }
374  return BackTracker::SpacePointToXYZ(spt, *fEvt);
375  }
const std::vector< double > SpacePointToXYZ(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< std::vector< art::Ptr< recob::Hit > > > cheat::BackTrackerService::TrackIdsToHits_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::Hit > > const &  hitsIn 
)

Definition at line 195 of file BackTrackerService_service.cc.

References cheat::BackTracker::TrackIdsToHits_Ps().

Referenced by cluster::ClusterAna::analyze(), pfpf::PFPAna::analyze(), and provider().

195  {
196  //Removed until Lazy Rebuild works
197  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
198  return BackTracker::TrackIdsToHits_Ps( tkIds, hitsIn);
199  }
std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
Definition: BackTracker.cc:241
const std::vector< std::vector < art::Ptr < recob::Hit > > > cheat::BackTrackerService::TrackIdsToHits_Ps ( std::vector< int > const &  tkIds)
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
inherited

Definition at line 241 of file BackTracker.cc.

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

Referenced by cheat::BackTracker::HitToEveTrackIDEs(), and 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
const std::vector< art::Ptr< recob::Hit > > cheat::BackTrackerService::TrackIdToHits_Ps ( const int &  tkId,
std::vector< art::Ptr< recob::Hit > > const &  hitsIn 
)

Definition at line 180 of file BackTrackerService_service.cc.

References cheat::BackTracker::TrackIdToHits_Ps().

Referenced by provider().

180  {
181  //Removed until Lazy Rebuild works
182  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
183  return BackTracker::TrackIdToHits_Ps( tkId, hitsIn);
184  }
std::vector< art::Ptr< recob::Hit > > TrackIdToHits_Ps(const int &tkId, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
Definition: BackTracker.cc:218
const std::vector< art::Ptr < recob::Hit > > cheat::BackTrackerService::TrackIdToHits_Ps ( const int &  tkId)
std::vector< art::Ptr< recob::Hit > > cheat::BackTracker::TrackIdToHits_Ps ( const int &  tkId,
std::vector< art::Ptr< recob::Hit > > const &  hitsIn 
) const
inherited

Definition at line 218 of file BackTracker.cc.

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

Referenced by cheat::BackTracker::HitToEveTrackIDEs(), and 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::BackTrackerService::TrackIdToSimIDEs_Ps ( int const &  id)

Definition at line 117 of file BackTrackerService_service.cc.

References cheat::BackTracker::TrackIdToSimIDEs_Ps().

Referenced by cheat::RecoCheckAna::FillResults(), and provider().

117  {
118  //Removed until Lazy Rebuild works
119  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
121  }
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id) const
Definition: BackTracker.cc:59
const std::vector< const sim::IDE * > cheat::BackTrackerService::TrackIdToSimIDEs_Ps ( int const &  id,
const geo::View_t  view 
)

Definition at line 124 of file BackTrackerService_service.cc.

References cheat::BackTracker::TrackIdToSimIDEs_Ps().

124  {
125  //Removed until Lazy Rebuild works
126  //if(!this->priv_SimChannelsReady()){this->priv_PrepSimChannels();}
127  return BackTracker::TrackIdToSimIDEs_Ps(id, view);
128  }
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id) const
Definition: BackTracker.cc:59
const std::vector< const sim::IDE * > cheat::BackTracker::TrackIdToSimIDEs_Ps ( int const &  id) const
inherited

Definition at line 59 of file BackTracker.cc.

References cheat::BackTracker::fSimChannels.

Referenced by cheat::BackTracker::SimChannels(), and 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
inherited

Definition at line 80 of file BackTracker.cc.

References cheat::BackTracker::fGeom, cheat::BackTracker::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 art::Event* cheat::BackTrackerService::fEvt =nullptr
private

Definition at line 114 of file BackTrackerService.h.

Referenced by priv_PrepEvent(), SpacePointToHits_Ps(), and SpacePointToXYZ().


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