LArSoft  v06_85_00
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

Definition at line 71 of file BackTracker.h.

References cheat::BackTracker::ClearEvent(), cheat::BackTracker::SpacePointToHits_Ps(), and cheat::BackTracker::SpacePointToXYZ().

Referenced by priv_CanRun().

71 { return !(evt.isRealData());}
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:112
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 112 of file BackTracker.cc.

References e, energy, sim::TrackIDE::energy, sim::TrackIDE::energyFrac, cheat::BackTracker::fDetClocks, cheat::BackTracker::FindSimChannel(), sim::NoParticleId, 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().

112  {
113  std::vector< sim::TrackIDE > trackIDEs;
114  double totalE=0.;
115  try{
116  art::Ptr<sim::SimChannel> schannel = this->FindSimChannel(channel);
117 
118  // loop over the electrons in the channel and grab those that are in time
119  // with the identified hit start and stop times
120  int start_tdc = fDetClocks->TPCTick2TDC( hit_start_time );
121  int end_tdc = fDetClocks->TPCTick2TDC( hit_end_time );
122  if(start_tdc<0) start_tdc = 0;
123  if(end_tdc<0) end_tdc = 0;
124  std::vector<sim::IDE> simides = schannel->TrackIDsAndEnergies(start_tdc, end_tdc);
125 
126  // first get the total energy represented by all track ids for
127  // this channel and range of tdc values
128  for(size_t e = 0; e < simides.size(); ++e)
129  totalE += simides[e].energy;
130 
131 
132  // protect against a divide by zero below
133  if(totalE < 1.e-5) totalE = 1.;
134 
135  // loop over the entries in the map and fill the input vectors
136 
137  for(size_t e = 0; e < simides.size(); ++e){
138 
139  if(simides[e].trackID == sim::NoParticleId) continue;
140 
141  sim::TrackIDE info;
142  info.trackID = simides[e].trackID;
143  info.energyFrac = simides[e].energy/totalE;
144  info.energy = simides[e].energy;
145 
146  trackIDEs.push_back(info);
147 
148  }
149  }// end try
150  catch(cet::exception e){
151  mf::LogWarning("BackTracker") << "caught exception \n"
152  << e;
153  }
154 
155  return trackIDEs;
156 
157  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:158
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:99
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 51 of file BackTracker.cc.

References cheat::BackTracker::fSimChannels.

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

51  {
52  fSimChannels.clear();
53 // fAllHitList.clear();
54  }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:164
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:99
art::Ptr< sim::SimChannel > cheat::BackTracker::FindSimChannel ( raw::ChannelID_t  channel) const
inherited

Definition at line 99 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().

99  {
101  auto ilb = std::lower_bound(fSimChannels.begin(),fSimChannels.end(),channel,[](art::Ptr<sim::SimChannel> a, raw:: ChannelID_t channel) {return(a->Channel()<channel);});
102  if (ilb != fSimChannels.end())
103  if ( (*ilb)->Channel() == channel) {chan = *ilb;}
104  if(!chan)
105  throw cet::exception("BackTracker") << "No sim::SimChannel corresponding "
106  << "to channel: " << channel << "\n";
107  return chan;
108  }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:164
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:148
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:148
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 485 of file BackTracker.cc.

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

485  {
486  std::set<int> eveIds;
487  for(const auto& hit : hits){
488  const std::vector<sim::TrackIDE> ides = this->HitToEveTrackIDEs(hit);
489  for(const auto& ide : ides){eveIds.insert(ide.trackID);}//end ides
490  }//End for hits
491  return eveIds;
492  }
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:181
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:147
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:147
const std::set<int> cheat::BackTracker::GetSetOfTrackIds ( ) const
inlineinherited

Definition at line 147 of file BackTracker.h.

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

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

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

Definition at line 471 of file BackTracker.cc.

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

471  {
472  std::set<int> tids;
473  for( const auto& hit : hits){
474  const double start = hit->PeakTimeMinusRMS();
475  const double end = hit->PeakTimePlusRMS();
476  std::vector<sim::TrackIDE> trackIDEs = this->ChannelToTrackIDEs(hit->Channel(), start, end);
477  for(const auto& ide : trackIDEs) {
478  tids.insert(ide.trackID);
479  }//End for TrackIDEs
480  }//End for hits
481  return tids;
482  }//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:112
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:438
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 438 of file BackTracker.cc.

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

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

441  {
442  double desired=0.,total=0.;
443  for( const auto& hit : hits){
444  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
445  for(const auto& hitIDE : hitTrackIDEs){
446  if(trackIds.find(hitIDE.trackID) != trackIds.end() && hitIDE.energyFrac >= fMinHitEnergyFraction){
447  desired+=hit->Integral();
448  break;
449  }//end if hit id matches and energy sufficient.
450  }//End for IDE in HitTrackIDEs.
451  }//End for hit in hits.
452 
453  for( const auto& hit : allHits ){
454  if(hit->View() != view && view != geo::k3D){ continue; }
455  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
456  for( const auto& hitIDE : hitTrackIDEs ){
457  if(trackIds.find(hitIDE.trackID) != trackIds.end() && hitIDE.energyFrac >= fMinHitEnergyFraction){
458  total += hit->Integral();
459  break;
460  }//end if hit matches
461  }//end for ide in ides
462  }//End for hit in allHits
463 
464  if(total>0.) {return desired/total;}
465  return 0.;
466 
467  }
const double fMinHitEnergyFraction
Definition: BackTracker.h:161
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:389
const double cheat::BackTracker::HitChargeCollectionPurity ( 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 HitChargeCollectionPurity(), and cheat::BackTracker::HitToXYZ().

389  {
390  double totalCharge=0.,desired=0.;
391  for(const auto& hit : hits){
392  totalCharge+=hit->Integral();
393  std::vector<sim::TrackIDE> trackIDEs= this->HitToTrackIDEs(hit);
394  for(const auto& trackIDE : trackIDEs){
395  if(trackIds.find(trackIDE.trackID)!=trackIds.end()){
396  desired+=hit->Integral();
397  break;
398  }//End if trackId in trackIds.
399  }//End for trackIDE in trackIDEs
400  }//End for Hit in Hits
401  if(totalCharge>0.0){return (desired/totalCharge);}
402  return 0.0;
403  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:406
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 406 of file BackTracker.cc.

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

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

409  {
410 
411  int desired=0,total=0;
412 
413  for( const auto& hit : hits){
414  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
415  for( const auto& trackIDE : hitTrackIDEs){
416  if( trackIds.find(trackIDE.trackID)!=trackIds.end() && trackIDE.energyFrac >= fMinHitEnergyFraction){
417  ++desired;
418  break;
419  }//End if trackID in trackIds.
420  }//end for trackIDE in TrackIDEs
421  }//end for hit in hits
422 
423  for( const auto& hit : allHits){
424  if(hit->View()!=view && view != geo::k3D) {continue;}//End if hit.view = view or view = geo::k3D
425  std::vector<sim::TrackIDE> hitTrackIDEs = this->HitToTrackIDEs(hit);
426  for( const auto& hitIDE : hitTrackIDEs){
427  if(trackIds.find(hitIDE.trackID)!=trackIds.end() && hitIDE.energyFrac>=fMinHitEnergyFraction){
428  ++total;
429  break;
430  }
431  }//END for all IDEs in HitTrackIDEs.
432  }//end for hit in allHits.
433  if(total >= 0){ return double(double(desired)/double(total));}
434  return 0.;
435  }
const double fMinHitEnergyFraction
Definition: BackTracker.h:161
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:373
const double cheat::BackTracker::HitCollectionPurity ( std::set< int > const &  trackIds,
std::vector< art::Ptr< recob::Hit > > const &  hits 
) const
inherited

Definition at line 373 of file BackTracker.cc.

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

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

373  {
374  int desired =0;
375  for( const auto& hit : hits ){
376  std::vector<sim::TrackIDE> hitTrackIDEs=this->HitToTrackIDEs(hit);
377  for(const auto& tIDE : hitTrackIDEs){
378  if(trackIds.find(tIDE.trackID)!=trackIds.end()){
379  ++desired;
380  break;
381  }//End if TID Found
382  }//END for trackIDE in TrackIDEs
383  }//End for hit in hits
384  if(hits.size()>0){return double(double(desired)/double(hits.size()));}
385  return 0;
386  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:263
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:263
const std::vector< sim::IDE > cheat::BackTracker::HitToAvgSimIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 263 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().

263  {
264  // Get services.
265 
266  int start_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimeMinusRMS() );
267  int end_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimePlusRMS() );
268  if(start_tdc<0) start_tdc = 0;
269  if(end_tdc<0) end_tdc = 0;
270 
271  return (this->FindSimChannel(hit.Channel()))->TrackIDsAndEnergies(start_tdc, end_tdc);
272  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:158
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:99
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 123 of file BackTracker.h.

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

Referenced by cheat::BackTracker::HitToAvgSimIDEs().

123 { return this->HitToAvgSimIDEs(*hit);}
const std::vector< sim::IDE > HitToAvgSimIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:263
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(), and DUNE::NeutrinoShowerEff::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:181
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:181
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToEveTrackIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 181 of file BackTracker.cc.

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

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

181  {
182  std::vector<sim::TrackIDE> eveIDEs;
183  std::vector<sim::TrackIDE> trackIDEs = this->HitToTrackIDEs(hit);
184  std::map<int, double> eveToEMap;
185  double totalE=0.0;
186  for (const auto& trackIDE : trackIDEs){
187  eveToEMap[fPartInv->TrackIdToEveTrackId(trackIDE.trackID)] += trackIDE.energy;
188  totalE+=trackIDE.energy;
189  }//End for trackIDEs
190  eveIDEs.reserve(eveToEMap.size());
191  for(const auto& eveToE : eveToEMap){
192  sim::TrackIDE eveTrackIDE_tmp;
193  eveTrackIDE_tmp.trackID = eveToE.first;
194  eveTrackIDE_tmp.energy = eveToE.second;
195  eveTrackIDE_tmp.energyFrac = (eveTrackIDE_tmp.energy)/(totalE);
196  eveIDEs.push_back(eveTrackIDE_tmp);
197  }//END eveToEMap loop
198  return eveIDEs;
199  }
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:161
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:156
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:275
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:275
const std::vector< const sim::IDE * > cheat::BackTracker::HitToSimIDEs_Ps ( recob::Hit const &  hit) const
inherited

Definition at line 275 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().

275  {
276  std::vector< const sim::IDE* > retVec;
277 // const auto start_tdc = hit.PeakTimeMinusRMS();
278 // const auto end_tdc = hit.PeakTimePlusRMS();
279  int start_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimeMinusRMS() );
280  int end_tdc = fDetClocks->TPCTick2TDC( hit.PeakTimePlusRMS() );
281  if(start_tdc<0) start_tdc = 0;
282  if(end_tdc<0) end_tdc = 0;
283 
284  if(start_tdc > end_tdc){throw;}
285 
286 /* auto sc = this->FindSimChannel(hit.Channel());
287  auto tdcidemap = sc->TDCIDEMap();
288  auto& tdcidemapref = sc->TDCIDEMap();*/
289 
290  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...
291  std::vector<const std::pair<unsigned short, std::vector<sim::IDE>>*> tdcIDEMap_SortedPointers;
292  for ( auto& pair : tdcIDEMap ){
293  tdcIDEMap_SortedPointers.push_back(&pair);
294  }
295 
296  //Sort a vector of pointers to the TDCIDEs
297  /*
298  auto pairSort = [](auto& a, auto& b) { return a.first < b.first ; } ;
299  if( !std::is_sorted( tdcIDEMap.begin(), tdcIDEMap.end(), pairSort)) {
300  std::cout<<"AlreadySorted\n";
301  // std::sort (tdcIDEMap.begin(), tdcIDEMap.end(), pairSort);
302  }else{
303  throw;
304  }*/
305 
306  //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.)
307  auto pairSort = [](auto& a, auto& b) { return a->first < b->first ; } ;
308  if( !std::is_sorted( tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), pairSort)) {
309  std::sort (tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), pairSort);
310  }
311 
312 
313  std::vector<sim::IDE> dummyVec; //I need something to stick in a pair to compare pair<tdcVal, IDE>. This is an otherwise useless "hack".
314  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.
315  std::pair<double, std::vector<sim::IDE>> end_tdcPair = std::make_pair(end_tdc,dummyVec);
316  //const std::vector<std::pair<unsigned short, std::vector<sim::IDE> > >::iterator //iterator to the first interesting IDE
317  auto start_tdcPair_P = &start_tdcPair;
318  auto end_tdcPair_P = &end_tdcPair;
319  auto
320  mapFirst = std::lower_bound(tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), start_tdcPair_P, pairSort);
321  //mapFirst = std::lower_bound(tdcIDEMap.begin(), tdcIDEMap.end(), start_tdcPair, pairSort);
322  //const std::vector<std::pair<unsigned short, std::vector<sim::IDE> > >::iterator //iterator to just after the last interesting IDE
323  auto
324  mapLast = std::upper_bound(tdcIDEMap_SortedPointers.begin(), tdcIDEMap_SortedPointers.end(), end_tdcPair_P, pairSort);
325  for( auto& mapitr = mapFirst; mapitr != mapLast; ++mapitr ){
326  for( auto& ide : (*mapitr)->second){
327  retVec.push_back(&ide);
328  //std::cout<<"Dumping Selected IDEs from tdcIDEMap:\nTrackID: "<<ide.trackID<<"\nnumElectrons: "<<ide.numElectrons<<"\nenergy: "<<ide.energy<<"\nXYZ: "<<ide.x<<" "<<ide.y<<" "<<ide.z<<"\n";
329  } //Add all interesting IDEs to the retVec
330  }
331 /* for( auto ide : retVec){
332  std::cout<<"Dumping Selected IDEs from retVec:\nTrackID: "<<ide->trackID<<"\nnumElectrons: "<<ide->numElectrons<<"\nenergy: "<<ide->energy<<"\nXYZ: "<<ide->x<<" "<<ide->y<<" "<<ide->z<<"\n";
333  }*/
334  return retVec;
335  }
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:158
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:99
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 126 of file BackTracker.h.

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

Referenced by cheat::BackTracker::HitToSimIDEs_Ps().

126 { return this->HitToSimIDEs_Ps (*hit); }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:275
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:161
const std::vector< sim::TrackIDE > cheat::BackTracker::HitToTrackIDEs ( recob::Hit const &  hit) const
inherited

Definition at line 161 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().

161  {
162  std::vector< sim::TrackIDE > trackIDEs;
163  const double start = hit.PeakTimeMinusRMS();
164  const double end = hit.PeakTimePlusRMS();
165  trackIDEs = this->ChannelToTrackIDEs(hit.Channel(), start, end);
166  return trackIDEs;
167  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:112
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 104 of file BackTracker.h.

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

Referenced by cheat::BackTracker::HitToTrackIDEs().

104 { return this->HitToTrackIDEs(*hit);}
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:171
Detector simulation of raw signals on wires.
const std::vector< int > cheat::BackTracker::HitToTrackIds ( recob::Hit const &  hit) const
inherited

Definition at line 171 of file BackTracker.cc.

References cheat::BackTracker::HitToTrackIDEs().

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

171  {
172  std::vector< int > retVec;
173  for(auto const trackIDE : this->HitToTrackIDEs( hit ) ){
174  retVec.push_back( trackIDE.trackID );
175  }
176  return retVec;
177  }
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
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:367
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 367 of file BackTracker.cc.

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

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

367  {
368  std::vector<const sim::IDE*> ide_Ps = this->HitToSimIDEs_Ps(hit);
369  return this->SimIDEsToXYZ(ide_Ps);
370  }
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:275
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:338
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
void cheat::BackTrackerService::priv_PrepEvent ( const art::Event evt)
private

Definition at line 63 of file BackTrackerService_service.cc.

References cheat::BackTracker::ClearEvent(), 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)
void cheat::BackTrackerService::priv_PrepFailed ( )
private

Definition at line 77 of file BackTrackerService_service.cc.

Referenced by priv_PrepSimChannels(), SpacePointHitsToWeightedXYZ(), SpacePointToHits_Ps(), and SpacePointToXYZ().

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:86
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:89
const std::vector<art::Ptr<sim::SimChannel> >& cheat::BackTracker::SimChannels ( ) const
inlineinherited
bool cheat::BackTracker::SimChannelsReady ( ) const
inlineinherited

Definition at line 86 of file BackTracker.h.

References cheat::BackTracker::fSimChannels.

Referenced by priv_SimChannelsReady().

86 { return !( fSimChannels.empty() ); }
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:164
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:338
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:338
const std::vector< double > cheat::BackTracker::SimIDEsToXYZ ( std::vector< sim::IDE > const &  ides) const
inherited

Definition at line 338 of file BackTracker.cc.

References e, w, and weight.

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

339  {
340  std::vector<double> xyz(3,0.0);
341  double w = 0.0;
342  for( auto const& ide : ides){
343  double weight=ide.numElectrons;
344  w += weight;
345  xyz[0] += (weight*ide.x);
346  xyz[1] += (weight*ide.y);
347  xyz[2] += (weight*ide.z);
348  }
349  if(w<1.e-5)
350  throw cet::exception("BackTracker")<<"No sim::IDEs providing non-zero number of electrons"
351  << " can't determine originating location from truth\n";
352  xyz[0] = xyz[0]/w;
353  xyz[1] = xyz[1]/w;
354  xyz[2] = xyz[2]/w;
355  return xyz;
356  }
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 359 of file BackTracker.cc.

References cheat::BackTracker::SimIDEsToXYZ().

359  {
360  std::vector<sim::IDE> ides;
361  for(auto ide_P : ide_Ps ){ ides.push_back(*ide_P);}
362  return this->SimIDEsToXYZ(ides);
363  }
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:338
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 fEvt, hits(), priv_CanRun(), priv_PrepFailed(), 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:496
bool priv_CanRun(const art::Event &evt)
const std::vector< double > cheat::BackTracker::SpacePointHitsToWeightedXYZ ( std::vector< art::Ptr< recob::Hit >> const &  hits) const
inherited

Definition at line 496 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().

496  {
497  std::vector<double> xyz(3,-99999.9);
498  std::vector< std::vector<std::vector<int>>> numHits (fGeom->Ncryostats());
499  std::vector< std::vector<std::vector<double>>> hitWeight (fGeom->Ncryostats());
500  std::vector< std::vector<std::vector<std::vector<double>>>> hitPos (fGeom->Ncryostats());
501  //Do we need to resize everything...
502  for(size_t c = 0; c < numHits.size(); ++c){
503  numHits[c].resize( fGeom->NTPC(c) );
504  hitWeight[c].resize( fGeom->NTPC(c) );
505  hitPos[c].resize( fGeom->NTPC(c) );
506  for(size_t t = 0; t < numHits[c].size(); ++t){
507  numHits[c][t].resize( fGeom->Nplanes(t, c) );
508  hitWeight[c][t].resize( fGeom->Nplanes(t, c) );
509  hitPos[c][t].resize( fGeom->Nplanes(t, c) );
510  }
511  }
512 
513  for(art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit) {
514 
515  const recob::Hit& hit = **ihit;
516 
517  // use the HitToXYZ and Geometry::PositionToTPC
518  // to figure out which drift volume the hit originates from
519  std::vector<double> hitOrigin = this->HitToXYZ(*ihit);
520  unsigned int cstat = 0;
521  unsigned int tpc = 0;
522  const double worldLoc[3] = {hitOrigin[0], hitOrigin[1], hitOrigin[2]};
523  fGeom->PositionToTPC(worldLoc, tpc, cstat);
524 
525  if(hit.WireID().Cryostat == cstat && hit.WireID().TPC == tpc){
526  ++numHits[cstat][tpc][hit.WireID().Plane];
527  hitWeight[cstat][tpc][hit.WireID().Plane] = hit.Integral();
528  hitPos[cstat][tpc][hit.WireID().Plane] = hitOrigin;
529  }
530 
531  }
532 
533  // loop over the vectors we made and find the average position for the hits
534  // in the future we might take a weighted average
535  int nhits = 0;
536  xyz[0] = 0.;
537  xyz[1] = 0.;
538  xyz[2] = 0.;
539  for(size_t c = 0; c < numHits.size(); ++c){
540  for(size_t t = 0; t < numHits[c].size(); ++t){
541  for(size_t p = 0; p < numHits[c][t].size(); ++p){
542 
543  if(numHits[c][t][p] == 1) {
544  ++nhits;
545  xyz[0] += hitPos[c][t][p][0];
546  xyz[1] += hitPos[c][t][p][1];
547  xyz[2] += hitPos[c][t][p][2];
548  }
549 
550  } // end loop over planes
551  } // end loop over tpcs
552  } // end loop over cryostats
553 
554  // get the average position
555  if(nhits < 1)
556  throw cet::exception("BackTracker") << "No hits to determine originating location from truth\n";
557 
558 
559  xyz[0] /= nhits;
560  xyz[1] /= nhits;
561  xyz[2] /= nhits;
562 
563  // Done.
564  return xyz;
565 
566  }
const geo::GeometryCore * fGeom
Definition: BackTracker.h:157
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:367
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, priv_CanRun(), priv_PrepFailed(), 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(); }
361  }
const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
bool priv_CanRun(const art::Event &evt)
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 364 of file BackTrackerService_service.cc.

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

Referenced by provider().

364  {
365  if( !this->priv_CanRun(*fEvt)) { this->priv_PrepFailed(); }
366  return BackTracker::SpacePointToXYZ(spt, *fEvt);
367  }
bool priv_CanRun(const art::Event &evt)
const std::vector< double > SpacePointToXYZ(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
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:225
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 225 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().

225  {
226  // returns a subset of the hits in the hitsIn collection that are matched
227  // to MC particles listed in tkIds
228 
229  // temporary vector of TrackIds and Ptrs to hits so only one
230  // loop through the (possibly large) hitsIn collection is needed
231  std::vector<std::pair<int, art::Ptr<recob::Hit>>> hitList;
232  std::vector<sim::TrackIDE> tids;
233  for(auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
234  tids.clear();
235  art::Ptr<recob::Hit> const& hit = *itr;
236  tids=this->ChannelToTrackIDEs( hit->Channel(), hit->PeakTimeMinusRMS(), hit->PeakTimePlusRMS());
237  for(auto itid = tids.begin(); itid != tids.end(); ++itid) {
238  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
239  if(itid->trackID == *itkid) {
240  if(itid->energyFrac > fMinHitEnergyFraction)
241  hitList.push_back(std::make_pair(*itkid, hit));
242  }
243  } // itkid
244  } // itid
245  } // itr
246 
247  // now build the truHits vector that will be returned to the caller
248  std::vector<std::vector<art::Ptr<recob::Hit>>> truHits;
249  // temporary vector containing hits assigned to one MC particle
250  std::vector<art::Ptr<recob::Hit>> tmpHits;
251  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
252  tmpHits.clear();
253  for(auto itr = hitList.begin(); itr != hitList.end(); ++itr) {
254  if(*itkid == (*itr).first) tmpHits.push_back((*itr).second);
255  }
256  truHits.push_back(tmpHits);
257  }
258  return truHits;
259  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:112
const double fMinHitEnergyFraction
Definition: BackTracker.h:161
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:202
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 202 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().

202  {
203  // returns a subset of the hits in the hitsIn collection that are matched
204  // to the given track
205 
206  // temporary vector of TrackIds and Ptrs to hits so only one
207  // loop through the (possibly large) hitsIn collection is needed
208  std::vector< art::Ptr<recob::Hit>> hitList;
209  std::vector<sim::TrackIDE> trackIDE;
210  for(auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
211  trackIDE.clear();
212  art::Ptr<recob::Hit> const& hit = *itr;
213  trackIDE = this->ChannelToTrackIDEs( hit->Channel(), hit->PeakTimeMinusRMS(), hit->PeakTimePlusRMS());
214  for(auto itr_trakIDE = trackIDE.begin(); itr_trakIDE != trackIDE.end(); ++itr_trakIDE) {
215  if(itr_trakIDE->trackID == tkId && itr_trakIDE->energyFrac > fMinHitEnergyFraction)
216  hitList.push_back( hit);
217  } // itr_trakIDE
218  } // itr
219  return hitList;
220  }
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:112
const double fMinHitEnergyFraction
Definition: BackTracker.h:161
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:57
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:57
const std::vector< const sim::IDE * > cheat::BackTracker::TrackIdToSimIDEs_Ps ( int const &  id) const
inherited

Definition at line 57 of file BackTracker.cc.

References cheat::BackTracker::fSimChannels.

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

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

Definition at line 78 of file BackTracker.cc.

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

79  {
80  std::vector<const sim::IDE*> ide_Ps;
82  if (fGeom->View(sc->Channel()) != view) continue;
83 
84  // loop over the IDEMAP
85  for(const auto & item : sc->TDCIDEMap()){
86 
87  // loop over the vector of IDE objects.
88  for(const sim::IDE & ide : item.second){
89  if (abs(ide.trackID) == id) ide_Ps.push_back(&ide);
90  }
91  } // end loop over map from sim::SimChannel
92  } // end loop over sim::SimChannels
93 
94  return ide_Ps;
95  }
TrackID_t trackID
Geant4 supplied track ID.
Definition: SimChannel.h:115
const geo::GeometryCore * fGeom
Definition: BackTracker.h:157
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:164
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

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