LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
cheat::PhotonBackTrackerService Class Reference

#include "PhotonBackTrackerService.h"

Inheritance diagram for cheat::PhotonBackTrackerService:
cheat::PhotonBackTracker

Classes

struct  fhiclConfig
 

Public Types

using provider_type = PhotonBackTracker
 

Public Member Functions

const provider_typeprovider () const
 
 PhotonBackTrackerService (fhicl::ParameterSet const &pSet, art::ActivityRegistry &reg)
 
 PhotonBackTrackerService (fhiclConfig const &config, art::ActivityRegistry &reg)
 
void Rebuild (art::Event const &evt)
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs ()
 
double GetDelay ()
 
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int id)
 
art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int opDetNum)
 
std::vector< sim::TrackSDPOpDetToTrackSDPs (int OpDetNum, double opHit_start_time, double opHit_end_time)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (recob::OpHit const &opHit)
 
std::vector< int > OpHitToTrackIds (recob::OpHit const &opHit)
 
std::vector< int > OpHitToTrackIds (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< int > OpHitToEveTrackIds (recob::OpHit const &opHit)
 
std::vector< int > OpHitToEveTrackIds (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (recob::OpHit const &opHit)
 
std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps (int tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
 
std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps (std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (recob::OpHit const &opHit)
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (art::Ptr< recob::OpHit > const &opHit_P)
 
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (recob::OpHit const &opHit)
 
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (art::Ptr< recob::OpHit > &opHit_P)
 
std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps) const &
 
std::vector< double > SimSDPsToXYZ (std::vector< const sim::SDP * > const &sdps_Ps)
 
std::vector< double > OpHitToXYZ (recob::OpHit const &opHit)
 
std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &opHit_P)
 
std::set< int > GetSetOfEveIds ()
 
std::set< int > GetSetOfTrackIds ()
 
std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
std::set< int > GetSetOfEveIds (const std::vector< recob::OpHit > &opHits)
 
std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
std::set< int > GetSetOfTrackIds (std::vector< recob::OpHit > const &opHits)
 
double OpHitCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
double OpHitLightCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
double OpHitCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn_Ps)
 
double OpHitLightCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn_Ps)
 
double OpHitChargeCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn_Ps)
 
std::set< int > OpFlashToTrackIds (art::Ptr< recob::OpFlash > &flash_P) const
 
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps (art::Ptr< recob::OpFlash > &flash_P)
 
std::vector< double > OpFlashToXYZ (art::Ptr< recob::OpFlash > &flash_P)
 

Private Member Functions

void priv_PrepEvent (art::Event const &evt, art::ScheduleContext)
 
void priv_PrepFailed ()
 
void priv_PrepOpDetBTRs (art::Event const &evt)
 
void priv_PrepOpFlashToOpHits (art::Event const &evt)
 
bool priv_CanRun (art::Event const &evt)
 
bool priv_OpDetBTRsReady ()
 
bool priv_OpFlashToOpHitsReady ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void Rebuild (const art::Event &evt)
 
const sim::ParticleListParticleList () const
 
const sim::ParticleListParticleList () const
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
const simb::MCParticleTrackIDToParticle (int const &id) const
 
const simb::MCParticleTrackIDToParticle (int const &id) const
 
const simb::MCParticleTrackIDToMotherParticle (int const &id) const
 
const simb::MCParticleTrackIDToMotherParticle (int const &id) const
 
std::vector< sim::SDPTrackIDToSimSDP (int const &id) const
 
std::vector< sim::SDPTrackIDToSimSDP (int const &id) const
 
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth (int const &id) const
 
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth (int const &id) const
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth (const simb::MCParticle *p) const
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth (const simb::MCParticle *p) const
 
std::vector< const simb::MCParticle * > MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const
 
std::vector< const simb::MCParticle * > MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const
 
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector () const
 
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector () const
 
DEPRECATED std::vector< sim::TrackSDPOpHitToTrackID (art::Ptr< recob::OpHit > const &hit)
 
DEPRECATED std::vector< sim::TrackSDPOpHitToTrackID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (recob::OpHit const &opHit) const
 
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIDsToOpHits (std::vector< art::Ptr< recob::OpHit >> const &allhits, std::vector< int > const &tkIDs)
 
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIDsToOpHits (std::vector< art::Ptr< recob::OpHit >> const &allhits, std::vector< int > const &tkIDs)
 
std::vector< sim::TrackSDPOpHitToEveSDPs (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToEveSDPs (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToEveID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToEveID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps)
 
std::vector< double > SimSDPsToXYZ (std::vector< const sim::SDP * > const &sdps_Ps) const &
 
double OpHitCollectionPurity (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
 
double OpHitCollectionEfficiency (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
 
double OpHitCollectionEfficiency (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits, geo::View_t const &view)
 
double OpHitChargeCollectionPurity (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
 
double OpHitChargeCollectionPurity (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
 
double OpHitChargeCollectionEfficiency (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
 
double OpHitChargeCollectionEfficiency (std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits, geo::View_t const &view)
 
std::set< int > GetSetOfEveIDs ()
 
std::set< int > GetSetOfEveIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
std::set< int > GetSetOfEveIDs ()
 
std::set< int > GetSetOfEveIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
std::set< int > GetSetOfTrackIDs ()
 
std::set< int > GetSetOfTrackIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
std::set< int > GetSetOfTrackIDs ()
 
std::set< int > GetSetOfTrackIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBacktrackerRecords () const
 
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBacktrackerRecords () const
 
void ChannelToTrackSDPs (std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
 
void ChannelToTrackSDPs (std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
 
template<typename Evt >
void PrepEvent (Evt const &evt)
 
template<typename Evt >
bool CanRun (Evt const &evt)
 
template<typename Evt >
void PrepOpDetBTRs (Evt const &evt)
 
template<typename Evt >
void PrepOpFlashToOpHits (Evt const &evt)
 
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps (art::Ptr< recob::OpFlash > &flash_P) const
 
std::vector< double > OpFlashToXYZ (art::Ptr< recob::OpFlash > &flash_P) const
 
double GetDelay () const
 
void ClearEvent ()
 
bool BTRsReady () const
 
bool OpFlashToOpHitsReady () const
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs () const
 
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int id) const
 
art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int opDetNum) const
 
std::vector< sim::TrackSDPOpDetToTrackSDPs (int OpDetNum, double opHit_start_time, double opHit_end_time) const
 
std::vector< int > OpHitToTrackIds (recob::OpHit const &opHit) const
 
std::vector< int > OpHitToTrackIds (art::Ptr< recob::OpHit > const &opHit) const
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (recob::OpHit const &opHit) const
 
std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps (int tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
 
std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps (std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (recob::OpHit const &opHit) const
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (art::Ptr< recob::OpHit > const &opHit_P) const
 
std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
std::vector< double > OpHitsToXYZ (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
std::set< int > GetSetOfEveIds () const
 
std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) const
 
std::set< int > GetSetOfEveIds (std::vector< recob::OpHit > const &opHits) const
 
std::set< int > GetSetOfTrackIds () const
 
std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) const
 
std::set< int > GetSetOfTrackIds (std::vector< recob::OpHit > const &opHits) const
 
void OpHitToSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
void OpHitToSDPs (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 
void OpHitToSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
void OpHitToSDPs (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 

Detailed Description

Definition at line 35 of file PhotonBackTrackerService.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 26 of file PhotonBackTrackerService.cc.

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

28  : PhotonBackTracker(pSet.get<fhicl::ParameterSet>("PhotonBackTracker"),
29  lar::providerFrom<cheat::ParticleInventoryService>(),
31  {
33  }
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
PhotonBackTracker(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
void priv_PrepEvent(art::Event const &evt, art::ScheduleContext)
cheat::PhotonBackTrackerService::PhotonBackTrackerService ( fhiclConfig const &  config,
art::ActivityRegistry reg 
)

Definition at line 36 of file PhotonBackTrackerService.cc.

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

38  : PhotonBackTracker(config.PhotonBackTrackerTable(),
39  lar::providerFrom<cheat::ParticleInventoryService>(),
41  {
43  }
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
PhotonBackTracker(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
void priv_PrepEvent(art::Event const &evt, art::ScheduleContext)

Member Function Documentation

bool cheat::PhotonBackTracker::BTRsReady ( ) const
inherited

Definition at line 74 of file PhotonBackTracker.cc.

75  {
76  return !priv_OpDetBTRs.empty();
77  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
template<typename Evt >
bool cheat::PhotonBackTracker::CanRun ( Evt const &  evt)
inherited

Referenced by priv_CanRun().

void cheat::PhotonBackTracker::ChannelToTrackSDPs ( std::vector< sim::TrackSDP > &  trackSDPs,
int  channel,
const double  hit_start_time,
const double  hit_end_time 
)
inherited
void cheat::PhotonBackTracker::ChannelToTrackSDPs ( std::vector< sim::TrackSDP > &  trackSDPs,
int  channel,
const double  hit_start_time,
const double  hit_end_time 
)
inherited

Definition at line 660 of file old.PhotonBackTracker_service.cc.

References e, sim::TrackSDP::energy, energy, sim::TrackSDP::energyFrac, cheat::PhotonBackTracker::FindOpDetBacktrackerRecord(), cheat::PhotonBackTracker::geom, sim::NoParticleId, cheat::PhotonBackTracker::shouldThisFail(), sim::TrackSDP::trackID, and sim::OpDetBacktrackerRecord::TrackIDsAndEnergies().

Referenced by cheat::PhotonBackTracker::GetSetOfTrackIDs(), cheat::PhotonBackTracker::OpDetBacktrackerRecords(), cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::TrackIDsToOpHits().

664  {
665  shouldThisFail();
666  trackSDPs.clear();
667 
668  double totalE = 0.;
669 
670  try {
672  this->FindOpDetBacktrackerRecord(geom->OpDetFromOpChannel(channel));
673 
674  // loop over the photons in the channel and grab those that are in time
675  // with the identified opHit start and stop times
676  //const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
677  //int start_tdc = ts->OpticalG4Time2TDC( opHit_start_time );
678  //int end_tdc = ts->OpticalG4Time2TDC( opHit_end_time );
679  // if(start_tdc<0) start_tdc = 0;
680  // if(end_tdc<0) end_tdc = 0;
681  std::vector<sim::SDP> simSDPs =
682  schannel->TrackIDsAndEnergies(opHit_start_time, opHit_end_time);
683 
684  // first get the total energy represented by all track ids for
685  // this channel and range of tdc values
686  for (size_t e = 0; e < simSDPs.size(); ++e)
687  totalE += simSDPs[e].energy;
688 
689  // protect against a divide by zero below
690  if (totalE < 1.e-5) totalE = 1.;
691 
692  // loop over the entries in the map and fill the input vectors
693 
694  for (size_t e = 0; e < simSDPs.size(); ++e) {
695 
696  if (simSDPs[e].trackID == sim::NoParticleId) continue;
697 
698  sim::TrackSDP info;
699  info.trackID = simSDPs[e].trackID;
700  info.energyFrac = simSDPs[e].energy / totalE;
701  info.energy = simSDPs[e].energy;
702 
703  trackSDPs.push_back(info);
704  }
705  } // end try
706  catch (cet::exception e) {
707  mf::LogWarning("PhotonBackTracker") << "caught exception \n" << e;
708  }
709 
710  return;
711  }
int trackID
Geant4 supplied trackID.
static const int NoParticleId
Definition: sim.h:21
float energyFrac
fraction of OpHit energy from the particle with this trackID
double energy
Definition: plottest35.C:25
Ionization photons from a Geant4 track.
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBacktrackerRecord(int channel) const
geo::GeometryCore const * geom
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< sim::SDP > TrackIDsAndEnergies(timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
Return all the recorded energy deposition within a time interval.
float energy
energy from the particle with this trackID [MeV]
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::PhotonBackTracker::ClearEvent ( )
inherited

Definition at line 67 of file PhotonBackTracker.cc.

Referenced by priv_PrepEvent().

68  {
69  priv_OpDetBTRs.clear();
70  priv_OpFlashToOpHits.clear();
71  }
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTrackerService::FindOpDetBTR ( int  opDetNum)

Definition at line 133 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::FindOpDetBTR().

134  {
135  return PhotonBackTracker::FindOpDetBTR(opDetNum);
136  }
art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int opDetNum) const
art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTracker::FindOpDetBTR ( int  opDetNum) const
inherited

Definition at line 108 of file PhotonBackTracker.cc.

References sc.

Referenced by FindOpDetBTR().

109  {
111  for (size_t sc = 0; sc < priv_OpDetBTRs.size(); ++sc) {
112  // This could become a bug. What if it occurs twice (shouldn't happen in correct
113  // records, but still, no error handeling included for the situation
114  if (priv_OpDetBTRs.at(sc)->OpDetNum() == opDetNum) opDet = priv_OpDetBTRs.at(sc);
115  }
116  if (!opDet) {
117  throw cet::exception("PhotonBackTracker2") << "No sim:: OpDetBacktrackerRecord corresponding "
118  << "to opDetNum: " << opDetNum << "\n";
119  }
120  return opDet;
121  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
Float_t sc
Definition: plot.C:23
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double cheat::PhotonBackTrackerService::GetDelay ( )

Definition at line 121 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetDelay().

122  {
124  }
double cheat::PhotonBackTracker::GetDelay ( ) const
inherited

Definition at line 61 of file PhotonBackTracker.cc.

Referenced by GetDelay().

62  {
63  return fDelay;
64  }
std::set< int > cheat::PhotonBackTrackerService::GetSetOfEveIds ( )

Definition at line 271 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

272  {
274  }
std::set< int > GetSetOfEveIds() const
std::set< int > cheat::PhotonBackTrackerService::GetSetOfEveIds ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps)

Definition at line 283 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

285  {
286  return PhotonBackTracker::GetSetOfEveIds(opHits_Ps);
287  }
std::set< int > GetSetOfEveIds() const
std::set< int > cheat::PhotonBackTrackerService::GetSetOfEveIds ( const std::vector< recob::OpHit > &  opHits)

Definition at line 289 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

290  {
291  return PhotonBackTracker::GetSetOfEveIds(opHits);
292  }
std::set< int > GetSetOfEveIds() const
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIDs ( )
inherited

Definition at line 371 of file old.PhotonBackTracker_service.cc.

References sim::ParticleList::begin(), sim::ParticleList::end(), sim::ParticleList::EveId(), cheat::PhotonBackTracker::fParticleList, and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::OpHitToSimSDPs().

372  {
373  shouldThisFail();
374  std::set<int> eveIDs;
375 
377  while (plitr != fParticleList.end()) {
378  int eveID = fParticleList.EveId((*plitr).first);
379  // look to see if this eveID is already in the set
380  if (eveIDs.find(eveID) == eveIDs.end()) eveIDs.insert(eveID);
381  plitr++;
382  }
383 
384  return eveIDs;
385  }
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
int EveId(const int trackID) const
iterator begin()
Definition: ParticleList.h:305
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
std::set<int> cheat::PhotonBackTracker::GetSetOfEveIDs ( )
inherited
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)
inherited

Definition at line 400 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::OpHitToEveID(), and cheat::PhotonBackTracker::shouldThisFail().

401  {
402  shouldThisFail();
403  std::set<int> eveIDs;
404 
405  std::vector<art::Ptr<recob::OpHit>>::const_iterator itr = opHits.begin();
406  while (itr != opHits.end()) {
407 
408  // get the eve ids corresponding to this opHit
409  const std::vector<sim::TrackSDP> sdps = OpHitToEveID(*itr);
410 
411  // loop over the sdps and extract the track ids
412  for (size_t i = 0; i < sdps.size(); ++i)
413  eveIDs.insert(sdps[i].trackID);
414 
415  itr++;
416  }
417 
418  return eveIDs;
419  }
std::vector< sim::TrackSDP > OpHitToEveID(art::Ptr< recob::OpHit > const &hit)
std::set<int> cheat::PhotonBackTracker::GetSetOfEveIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)
inherited
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( ) const
inherited

Definition at line 468 of file PhotonBackTracker.cc.

Referenced by GetSetOfEveIds().

469  {
470  return fPartInv->GetSetOfEveIds();
471  }
const cheat::ParticleInventory * fPartInv
std::set< int > GetSetOfEveIds() const
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( std::vector< art::Ptr< recob::OpHit >> const &  opHits) const
inherited

Definition at line 480 of file PhotonBackTracker.cc.

482  {
483  std::set<int> eveIds;
484  for (auto const& opHit_P : opHits_Ps) {
485  const std::vector<sim::TrackSDP> sdps = OpHitToEveTrackSDPs(opHit_P);
486  for (auto const& sdp : sdps) {
487  eveIds.insert(sdp.trackID);
488  } //end sdps
489  } //End for hits
490  return eveIds;
491  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( std::vector< recob::OpHit > const &  opHits) const
inherited

Definition at line 494 of file PhotonBackTracker.cc.

495  {
496  std::set<int> eveIds;
497  for (auto const& opHit : opHits) {
498  const std::vector<sim::TrackSDP> sdps = OpHitToEveTrackSDPs(opHit);
499  for (auto const& sdp : sdps) {
500  eveIds.insert(sdp.trackID);
501  } //end sdps
502  } //End for hits
503  return eveIds;
504  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::set< int > cheat::PhotonBackTrackerService::GetSetOfTrackIds ( )

Definition at line 277 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

278  {
280  }
std::set< int > GetSetOfTrackIds() const
std::set< int > cheat::PhotonBackTrackerService::GetSetOfTrackIds ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps)

Definition at line 295 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

297  {
298  return PhotonBackTracker::GetSetOfTrackIds(opHits_Ps);
299  }
std::set< int > GetSetOfTrackIds() const
std::set< int > cheat::PhotonBackTrackerService::GetSetOfTrackIds ( std::vector< recob::OpHit > const &  opHits)

Definition at line 301 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

302  {
304  }
std::set< int > GetSetOfTrackIds() const
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIDs ( )
inherited

Definition at line 388 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::fParticleList, and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::OpHitToSimSDPs(), and cheat::PhotonBackTracker::Rebuild().

389  {
390  shouldThisFail();
391  // fParticleList::value_type is a pair (track, particle pointer)
392  std::set<int> trackIDs;
394  trackIDs.insert(pl.first);
395 
396  return trackIDs;
397  }
list_type::value_type value_type
Definition: ParticleList.h:130
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
std::set<int> cheat::PhotonBackTracker::GetSetOfTrackIDs ( )
inherited
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)
inherited

Definition at line 422 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::ChannelToTrackSDPs(), util::end(), cheat::PhotonBackTracker::fDelay, and cheat::PhotonBackTracker::shouldThisFail().

424  {
425  shouldThisFail();
426  std::set<int> trackIDs;
427 
428  std::vector<art::Ptr<recob::OpHit>>::const_iterator itr = opHits.begin();
429  while (itr != opHits.end()) {
430 
431  std::vector<sim::TrackSDP> trackSDPs;
432 
433  // get the track ids corresponding to this opHit
434  const double pTime = (*itr)->PeakTime();
435  const double pWidth = (*itr)->Width();
436  const double start = (pTime - pWidth) * 1000.0 - fDelay;
437  const double end = (pTime + pWidth) * 1000.0 - fDelay;
438  // const double start = (*itr)->PeakTimeMinusRMS();
439  // const double end = (*itr)->PeakTimePlusRMS();
440 
441  this->ChannelToTrackSDPs(trackSDPs, (*itr)->OpChannel(), start, end);
442 
443  // loop over the sdps and extract the track ids
444  for (size_t i = 0; i < trackSDPs.size(); ++i) {
445  trackIDs.insert(trackSDPs[i].trackID);
446  }
447 
448  itr++;
449  }
450 
451  return trackIDs;
452  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void ChannelToTrackSDPs(std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
std::set<int> cheat::PhotonBackTracker::GetSetOfTrackIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)
inherited
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( ) const
inherited

Definition at line 474 of file PhotonBackTracker.cc.

Referenced by GetSetOfTrackIds().

475  {
476  return fPartInv->GetSetOfTrackIds();
477  }
const cheat::ParticleInventory * fPartInv
std::set< int > GetSetOfTrackIds() const
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( std::vector< art::Ptr< recob::OpHit >> const &  opHits) const
inherited

Definition at line 507 of file PhotonBackTracker.cc.

509  {
510  std::set<int> tids;
511  for (auto const& opHit : opHits) {
512  for (auto const& sdp : OpHitToTrackSDPs(opHit)) {
513  tids.insert(sdp.trackID);
514  } //End for TrackSDPs
515  } //End for hits
516  return tids;
517  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( std::vector< recob::OpHit > const &  opHits) const
inherited

Definition at line 520 of file PhotonBackTracker.cc.

521  {
522  std::set<int> tids;
523  for (auto const& opHit : opHits) {
524  for (auto const& sdp : OpHitToTrackSDPs(opHit)) {
525  tids.insert(sdp.trackID);
526  } //End for TrackSDPs
527  } //End for hits
528  return tids;
529  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< const simb::MCParticle * > cheat::PhotonBackTracker::MCTruthToParticles ( art::Ptr< simb::MCTruth > const &  mct) const
inherited

Definition at line 256 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::fParticleList, cheat::PhotonBackTracker::shouldThisFail(), and cheat::PhotonBackTracker::TrackIDToMCTruth().

Referenced by cheat::PhotonBackTracker::SetEveIdCalculator().

258  {
259  shouldThisFail();
260  std::vector<const simb::MCParticle*> ret;
261 
262  // sim::ParticleList::value_type is a pair (track ID, particle pointer)
263  for (const sim::ParticleList::value_type& TrackIDpair : fParticleList) {
264  if (TrackIDToMCTruth(TrackIDpair.first) == mct) ret.push_back(TrackIDpair.second);
265  }
266 
267  return ret;
268  }
list_type::value_type value_type
Definition: ParticleList.h:130
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
std::vector<const simb::MCParticle*> cheat::PhotonBackTracker::MCTruthToParticles ( art::Ptr< simb::MCTruth > const &  mct) const
inherited
const std::vector<art::Ptr<simb::MCTruth> >& cheat::PhotonBackTracker::MCTruthVector ( ) const
inlineinherited

Definition at line 77 of file old.PhotonBackTrackerService.h.

References cheat::PhotonBackTracker::fMCTruthList.

77 { return fMCTruthList; }
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
const std::vector<art::Ptr<simb::MCTruth> >& cheat::PhotonBackTracker::MCTruthVector ( ) const
inlineinherited

Definition at line 77 of file old.PhotonBackTracker.h.

References cheat::PhotonBackTracker::fMCTruthList.

77 { return fMCTruthList; }
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
const std::vector<art::Ptr<sim::OpDetBacktrackerRecord> >& cheat::PhotonBackTracker::OpDetBacktrackerRecords ( ) const
inlineinherited

Definition at line 169 of file old.PhotonBackTracker.h.

References cheat::PhotonBackTracker::ChannelToTrackSDPs(), and cheat::PhotonBackTracker::cOpDetBacktrackerRecords.

170  {
172  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & cheat::PhotonBackTrackerService::OpDetBTRs ( )

Definition at line 115 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpDetBTRs().

116  {
118  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs() const
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & cheat::PhotonBackTracker::OpDetBTRs ( ) const
inherited

Definition at line 86 of file PhotonBackTracker.cc.

Referenced by OpDetBTRs().

87  {
88  return priv_OpDetBTRs;
89  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpDetToTrackSDPs ( int  OpDetNum,
double  opHit_start_time,
double  opHit_end_time 
)

Definition at line 139 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpDetToTrackSDPs().

143  {
144  return PhotonBackTracker::OpDetToTrackSDPs(OpDetNum, opHit_start_time, opHit_end_time);
145  }
std::vector< sim::TrackSDP > OpDetToTrackSDPs(int OpDetNum, double opHit_start_time, double opHit_end_time) const
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpDetToTrackSDPs ( int  OpDetNum,
double  opHit_start_time,
double  opHit_end_time 
) const
inherited

Definition at line 124 of file PhotonBackTracker.cc.

References util::abs(), e, energy, sim::TrackSDP::energy, sim::TrackSDP::energyFrac, sim::NoParticleId, sim::TrackSDP::trackID, and sim::OpDetBacktrackerRecord::TrackIDsAndEnergies().

Referenced by OpDetToTrackSDPs().

127  {
128  std::vector<sim::TrackSDP> tSDPs;
129  double totalE = 0;
130  try {
131  const art::Ptr<sim::OpDetBacktrackerRecord> opDetBTR = FindOpDetBTR(OpDetNum);
132  std::vector<sim::SDP> simSDPs =
133  opDetBTR->TrackIDsAndEnergies(opHit_start_time, opHit_end_time);
134  for (size_t e = 0; e < simSDPs.size(); ++e)
135  totalE += simSDPs[e].energy;
136  if (totalE < 1.e-5) totalE = 1.;
137  for (size_t e = 0; e < simSDPs.size(); ++e) {
138  if (simSDPs[e].trackID == sim::NoParticleId) continue;
139  sim::TrackSDP info;
140  info.trackID = std::abs(simSDPs[e].trackID);
141  info.energyFrac = simSDPs[e].energy / totalE;
142  info.energy = simSDPs[e].energy;
143  tSDPs.push_back(info);
144  }
145  }
146  catch (cet::exception const& e) {
147  // This needs to go. Make it specific if there is a really an exception we would
148  // like to catch.
149  mf::LogWarning("PhotonBackTracker") << "Exception caught\n" << e;
150  }
151  return tSDPs;
152  }
art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int opDetNum) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
int trackID
Geant4 supplied trackID.
static const int NoParticleId
Definition: sim.h:21
float energyFrac
fraction of OpHit energy from the particle with this trackID
double energy
Definition: plottest35.C:25
Ionization photons from a Geant4 track.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< sim::SDP > TrackIDsAndEnergies(timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
Return all the recorded energy deposition within a time interval.
float energy
energy from the particle with this trackID [MeV]
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTrackerService::OpFlashToOpHits_Ps ( art::Ptr< recob::OpFlash > &  flash_P)

Definition at line 347 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToOpHits_Ps().

349  {
351  }
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::OpFlashToOpHits_Ps ( art::Ptr< recob::OpFlash > &  flash_P) const
inherited

Definition at line 674 of file PhotonBackTracker.cc.

Referenced by OpFlashToOpHits_Ps().

676  {
677  // There is not "non-pointer" version of this because the art::Ptr is needed to look
678  // up the assn. One could loop the Ptrs and dereference them, but I will not encourage
679  // the behavior by building the tool to do it.
680  return priv_OpFlashToOpHits.at(flash_P);
681  }
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
bool cheat::PhotonBackTracker::OpFlashToOpHitsReady ( ) const
inherited

Definition at line 80 of file PhotonBackTracker.cc.

81  {
82  return !priv_OpFlashToOpHits.empty();
83  }
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
std::set< int > cheat::PhotonBackTrackerService::OpFlashToTrackIds ( art::Ptr< recob::OpFlash > &  flash_P) const

Definition at line 341 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToTrackIds().

342  {
343  return PhotonBackTracker::OpFlashToTrackIds(flash_P);
344  }
std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< double > cheat::PhotonBackTrackerService::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P)

Definition at line 354 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToXYZ().

355  {
356  return PhotonBackTracker::OpFlashToXYZ(flash_P);
357  }
std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< double > cheat::PhotonBackTracker::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P) const
inherited

Definition at line 684 of file PhotonBackTracker.cc.

Referenced by OpFlashToXYZ().

685  {
686  return OpHitsToXYZ(OpFlashToOpHits_Ps(flash_P));
687  }
std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
double cheat::PhotonBackTrackerService::OpHitChargeCollectionEfficiency ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps,
std::vector< art::Ptr< recob::OpHit >> const &  opHitsIn_Ps 
)
inline

Definition at line 101 of file PhotonBackTrackerService.h.

104  {
105  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
106  } //Exists only temporarily. Is deprecated.
double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn)
double cheat::PhotonBackTracker::OpHitChargeCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits 
)
inherited

Definition at line 575 of file old.PhotonBackTracker_service.cc.

References recob::OpHit::Area(), e, cheat::PhotonBackTracker::fMinOpHitEnergyFraction, cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::OpHitToSimSDPs().

579  {
580  shouldThisFail();
581  // get the list of EveIDs that correspond to the opHits in this collection
582  // and the energy associated with the desired trackID
583  float desired = 0.;
584  float total = 0.;
585 
586  // don't have to check the view in the opHits collection because
587  // those are assumed to be from the object we are testing and will
588  // the correct view by definition then.
589  for (size_t h = 0; h < opHits.size(); ++h) {
590 
591  art::Ptr<recob::OpHit> opHit = opHits[h];
592  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
593 
594  // don't worry about opHits where the energy fraction for the chosen
595  // trackID is < 0.1
596  // also don't double count if this opHit has more than one of the
597  // desired track IDs associated with it
598  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
599  if (trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end() &&
600  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction) {
601  desired += opHit->Area();
602  break;
603  }
604  }
605  } // end loop over opHits
606 
607  // now figure out how many opHits in the whole collection are associated with this id
608  for (size_t h = 0; h < allOpHits.size(); ++h) {
609 
610  art::Ptr<recob::OpHit> opHit = allOpHits[h];
611 
612  // check that we are looking at the appropriate view here
613  // in the case of 3D objects we take all opHits
614  //if(opHit->View() != view && view != geo::k3D ) continue;
615 
616  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
617 
618  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
619  // don't worry about opHits where the energy fraction for the chosen
620  // trackID is < 0.1
621  // also don't double count if this opHit has more than one of the
622  // desired track IDs associated with it
623  if (trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end() &&
624  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction) {
625  total += opHit->Area();
626  break;
627  }
628  }
629 
630  } // end loop over all opHits
631 
632  double efficiency = 0.;
633  if (total > 0.) efficiency = desired / total;
634 
635  return efficiency;
636  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
double Area() const
Definition: OpHit.h:114
Float_t e
Definition: plot.C:35
double cheat::PhotonBackTracker::OpHitChargeCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits,
geo::View_t const &  view 
)
inherited

Definition at line 566 of file old.PhotonBackTracker_service.cc.

571  {
572  throw cet::exception("PhotonBackTracker")
573  << "This function is not supported. OpHits do not have type View.\n";
574  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double cheat::PhotonBackTracker::OpHitChargeCollectionPurity ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits 
)
inherited

Definition at line 482 of file old.PhotonBackTracker_service.cc.

References recob::OpHit::Area(), e, cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::OpHitToSimSDPs().

485  {
486  shouldThisFail();
487  // get the list of EveIDs that correspond to the opHits in this collection
488  // if the EveID shows up in the input list of trackIDs, then it counts
489  float total = 0;
490  float desired = 0.;
491  // don't have to check the view in the opHits collection because
492  // those are assumed to be from the object we are testing and will
493  // the correct view by definition then.
494  for (size_t h = 0; h < opHits.size(); ++h) {
495  art::Ptr<recob::OpHit> opHit = opHits[h];
496  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
497  total += opHit->Area(); // sum up the charge in the cluster
498  // don't double count if this opHit has more than one of the
499  // desired track IDs associated with it
500  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
501  if (trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end()) {
502  desired += opHit->Area();
503  break;
504  }
505  }
506  } // end loop over opHits
507  double purity = 0.;
508  if (total > 0) purity = desired / total;
509  return purity;
510  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double Area() const
Definition: OpHit.h:114
Float_t e
Definition: plot.C:35
double cheat::PhotonBackTracker::OpHitChargeCollectionPurity ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits 
)
inherited
double cheat::PhotonBackTrackerService::OpHitCollectionEfficiency ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps,
std::vector< art::Ptr< recob::OpHit >> const &  opHitsIn_Ps 
)

Definition at line 323 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitCollectionEfficiency().

327  {
328  return PhotonBackTracker::OpHitCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
329  }
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
double cheat::PhotonBackTracker::OpHitCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits 
)
inherited

Definition at line 523 of file old.PhotonBackTracker_service.cc.

References e, cheat::PhotonBackTracker::fMinOpHitEnergyFraction, cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::shouldThisFail().

Referenced by OpHitCollectionEfficiency(), and cheat::PhotonBackTracker::OpHitToSimSDPs().

527  {
528  shouldThisFail();
529  float desired = 0.;
530  float total = 0.;
531  for (size_t h = 0; h < opHits.size(); ++h) {
532  art::Ptr<recob::OpHit> opHit = opHits[h];
533  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
534  // also don't double count if this opHit has more than one of the
535  // desired track IDs associated with it
536  for (size_t e = 0; e < opHitTrackSDP.size(); ++e) {
537  if (trackIDs.find(opHitTrackSDPs[e].trackID) != trackIDs.end() &&
538  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction) {
539  desired += 1.;
540  break;
541  }
542  }
543  } // end loop over opHits
544  // now figure out how many opHits in the whole collection are associated with this id
545  for (size_t h = 0; h < allOpHits.size(); ++h) {
546  art::Ptr<recob::OpHit> opHit = allOpHits[h];
547  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
548  for (size_t e = 0; e < opHitTrackSDPs.size(); ++e) {
549  // don't worry about opHits where the energy fraction for the chosen
550  // trackID is < 0.1
551  // also don't double count if this opHit has more than one of the
552  // desired track IDs associated with it
553  if (trackIDs.find(opHitTrackSDPs[e].trackID) != trackIDs.end() &&
554  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction) {
555  total += 1.;
556  break;
557  }
558  }
559  } // end loop over all opHits
560  double efficiency = 0.;
561  if (total > 0.) efficiency = desired / total;
562  return efficiency;
563  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
Float_t e
Definition: plot.C:35
double cheat::PhotonBackTracker::OpHitCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits,
geo::View_t const &  view 
)
inherited

Definition at line 513 of file old.PhotonBackTracker_service.cc.

518  {
519  throw cet::exception("PhotonBackTracker")
520  << "This function is not supported. OpHits do not have type View.\n";
521  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double cheat::PhotonBackTrackerService::OpHitCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps 
)

Definition at line 307 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitCollectionPurity().

310  {
311  return PhotonBackTracker::OpHitCollectionPurity(tkIds, opHits_Ps);
312  }
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
double cheat::PhotonBackTracker::OpHitCollectionPurity ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits 
)
inherited

Definition at line 455 of file old.PhotonBackTracker_service.cc.

References e, cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::shouldThisFail().

Referenced by OpHitCollectionPurity(), and cheat::PhotonBackTracker::OpHitToSimSDPs().

457  {
458  shouldThisFail();
459  // get the list of EveIDs that correspond to the opHits in this collection
460  // if the EveID shows up in the input list of trackIDs, then it counts
461  float total = 1. * opHits.size();
462  ;
463  float desired = 0.;
464  for (size_t h = 0; h < opHits.size(); ++h) {
465  art::Ptr<recob::OpHit> opHit = opHits[h];
466  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
467  // don't double count if this opHit has more than one of the
468  // desired track IDs associated with it
469  for (size_t e = 0; e < opHitTrackSDPs.size(); ++e) {
470  if (trackIds.find(opHitTrackSDPs[e].trackID) != trackIds.end()) {
471  desired += 1.;
472  break;
473  }
474  }
475  } // end loop over opHits
476  double purity = 0.;
477  if (total > 0) purity = desired / total;
478  return purity;
479  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
Float_t e
Definition: plot.C:35
double cheat::PhotonBackTrackerService::OpHitLightCollectionEfficiency ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps,
std::vector< art::Ptr< recob::OpHit >> const &  opHitsIn_Ps 
)

Definition at line 332 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitLightCollectionEfficiency().

336  {
337  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
338  }
double OpHitLightCollectionEfficiency(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn)
double cheat::PhotonBackTrackerService::OpHitLightCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps 
)

Definition at line 315 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitLightCollectionPurity().

318  {
319  return PhotonBackTracker::OpHitLightCollectionPurity(tkIds, opHits_Ps);
320  }
double OpHitLightCollectionPurity(std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits)
std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitsToSimSDPs_Ps ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps) const
inherited

Definition at line 418 of file PhotonBackTracker.cc.

420  {
421  std::vector<const sim::SDP*> sdps_Ps;
422  for (auto opHit_P : opHits_Ps) {
423  std::vector<const sim::SDP*> to_add_sdps_Ps = OpHitToSimSDPs_Ps(opHit_P);
424  sdps_Ps.insert(sdps_Ps.end(), to_add_sdps_Ps.begin(), to_add_sdps_Ps.end());
425  }
426  return sdps_Ps;
427  }
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
std::vector< double > cheat::PhotonBackTracker::OpHitsToXYZ ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps) const
inherited

Definition at line 430 of file PhotonBackTracker.cc.

432  {
433  const std::vector<const sim::SDP*> SDPs_Ps = OpHitsToSimSDPs_Ps(opHits_Ps);
434  return SimSDPsToXYZ(SDPs_Ps);
435  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps(std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveID ( art::Ptr< recob::OpHit > const &  hit)
inherited

Definition at line 361 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::OpHitToEveSDPs().

Referenced by cheat::PhotonBackTracker::GetSetOfEveIDs(), and cheat::PhotonBackTracker::OpHitToTrackID().

362  {
363  mf::LogWarning("PhotonBackTracker")
364  << "PhotonBackTracker::OpHitToEveID is being replaced with "
365  "PhotonBackTracker::OpHitToEveSDPs. Please \n update your code accordingly.\n ";
366  std::vector<sim::TrackSDP> eveSDPs = OpHitToEveSDPs(opHit);
367  return eveSDPs;
368  }
std::vector< sim::TrackSDP > OpHitToEveSDPs(art::Ptr< recob::OpHit > const &hit)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToEveID ( art::Ptr< recob::OpHit > const &  hit)
inherited
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveSDPs ( art::Ptr< recob::OpHit > const &  hit)
inherited

Definition at line 333 of file old.PhotonBackTracker_service.cc.

References sim::TrackSDP::energy, sim::TrackSDP::energyFrac, sim::ParticleList::EveId(), cheat::PhotonBackTracker::fParticleList, cheat::PhotonBackTracker::OpHitToTrackSDPs(), cheat::PhotonBackTracker::shouldThisFail(), and sim::TrackSDP::trackID.

Referenced by cheat::PhotonBackTracker::OpHitToEveID(), and cheat::PhotonBackTracker::OpHitToTrackID().

334  {
335  shouldThisFail();
336  std::vector<sim::TrackSDP> trackSDPs = this->OpHitToTrackSDPs(opHit);
337 
338  // make a map of evd ID values and fraction of energy represented by
339  // that eve id in this opHit
340  std::map<int, float> eveIDtoEfrac;
341 
342  double totalE = 0.;
343  for (size_t t = 0; t < trackSDPs.size(); ++t) {
344  eveIDtoEfrac[fParticleList.EveId(trackSDPs[t].trackID)] += trackSDPs[t].energy;
345  totalE += trackSDPs[t].energy;
346  }
347 
348  // now fill the eveSDPs vector from the map
349  std::vector<sim::TrackSDP> eveSDPs;
350  eveSDPs.reserve(eveIDtoEfrac.size());
351  for (auto itr = eveIDtoEfrac.begin(); itr != eveIDtoEfrac.end(); itr++) {
352  sim::TrackSDP temp;
353  temp.trackID = (*itr).first;
354  temp.energyFrac = (*itr).second / totalE;
355  temp.energy = (*itr).second;
356  eveSDPs.push_back(std::move(temp));
357  }
358 
359  return eveSDPs;
360  }
int EveId(const int trackID) const
int trackID
Geant4 supplied trackID.
float energyFrac
fraction of OpHit energy from the particle with this trackID
Ionization photons from a Geant4 track.
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
float energy
energy from the particle with this trackID [MeV]
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToEveSDPs ( art::Ptr< recob::OpHit > const &  hit)
inherited
std::unordered_set< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToEveSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 231 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps().

233  {
235  }
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
std::unordered_set< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToEveSimSDPs_Ps ( art::Ptr< recob::OpHit > &  opHit_P)

Definition at line 238 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps().

240  {
242  }
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps(recob::OpHit const &opHit)
std::vector< int > cheat::PhotonBackTrackerService::OpHitToEveTrackIds ( recob::OpHit const &  opHit)

Definition at line 174 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackIds().

175  {
177  }
std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
std::vector< int > cheat::PhotonBackTrackerService::OpHitToEveTrackIds ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 180 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackIds().

182  {
184  }
std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpHitToEveTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 187 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

189  {
191  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpHitToEveTrackSDPs ( recob::OpHit const &  opHit)

Definition at line 194 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

196  {
198  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const
inherited

Definition at line 210 of file PhotonBackTracker.cc.

Referenced by OpHitToEveTrackSDPs().

212  {
213  return OpHitToEveTrackSDPs(*opHit_P);
214  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveTrackSDPs ( recob::OpHit const &  opHit) const
inherited

Definition at line 217 of file PhotonBackTracker.cc.

References sim::TrackSDP::energy, sim::TrackSDP::energyFrac, and sim::TrackSDP::trackID.

218  {
219  std::vector<sim::TrackSDP> trackSDPs = OpHitToTrackSDPs(opHit);
220 
221  // make a map of evd ID values and fraction of energy represented by that eve id in
222  // this opHit
223  std::map<int, float> eveIDtoEfrac;
224 
225  double totalE = 0.;
226  for (size_t t = 0; t < trackSDPs.size(); ++t) {
227  eveIDtoEfrac[(fPartInv->ParticleList()).EveId(trackSDPs[t].trackID)] += trackSDPs[t].energy;
228  totalE += trackSDPs[t].energy;
229  }
230 
231  // now fill the eveSDPs vector from the map
232  std::vector<sim::TrackSDP> eveSDPs;
233  eveSDPs.reserve(eveIDtoEfrac.size());
234  for (auto itr = eveIDtoEfrac.begin(); itr != eveIDtoEfrac.end(); itr++) {
235  sim::TrackSDP temp;
236  temp.trackID = (*itr).first;
237  temp.energyFrac = (*itr).second / totalE;
238  temp.energy = (*itr).second;
239  eveSDPs.push_back(std::move(temp));
240  }
241  return eveSDPs;
242  }
int trackID
Geant4 supplied trackID.
const cheat::ParticleInventory * fPartInv
float energyFrac
fraction of OpHit energy from the particle with this trackID
Ionization photons from a Geant4 track.
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
float energy
energy from the particle with this trackID [MeV]
const sim::ParticleList & ParticleList() const
void cheat::PhotonBackTracker::OpHitToSDPs ( recob::OpHit const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inherited

Definition at line 714 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::fDelay, cheat::PhotonBackTracker::FindOpDetBacktrackerRecord(), cheat::PhotonBackTracker::geom, recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), cheat::PhotonBackTracker::shouldThisFail(), sim::OpDetBacktrackerRecord::TrackIDsAndEnergies(), and recob::OpHit::Width().

Referenced by cheat::PhotonBackTracker::OpHitToSDPs(), cheat::PhotonBackTracker::OpHitToSimSDPs(), cheat::PhotonBackTracker::OpHitToTrackID(), and cheat::PhotonBackTracker::OpHitToXYZ().

715  {
716  shouldThisFail();
717  // Get services.
718  //const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
719 
720  double fPeakTime = opHit.PeakTime();
721  double fWidth = opHit.Width();
723  ((fPeakTime - fWidth) * 1000.0) - fDelay;
724  sim::OpDetBacktrackerRecord::timePDclock_t end_time = ((fPeakTime + fWidth) * 1000.0) - fDelay;
725 
726  sdps = FindOpDetBacktrackerRecord(geom->OpDetFromOpChannel(opHit.OpChannel()))
727  ->TrackIDsAndEnergies(start_time, end_time);
728  }
double timePDclock_t
Type for iTimePDclock tick used in the interface.
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBacktrackerRecord(int channel) const
geo::GeometryCore const * geom
std::vector< sim::SDP > TrackIDsAndEnergies(timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
Return all the recorded energy deposition within a time interval.
void cheat::PhotonBackTracker::OpHitToSDPs ( recob::OpHit const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inherited
void cheat::PhotonBackTracker::OpHitToSDPs ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inlineinherited

Definition at line 104 of file old.PhotonBackTracker.h.

References cheat::PhotonBackTracker::OpHitToSDPs().

105  {
106  OpHitToSDPs(*hit, sdps);
107  }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
void cheat::PhotonBackTracker::OpHitToSDPs ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inlineinherited

Definition at line 104 of file old.PhotonBackTrackerService.h.

References cheat::PhotonBackTracker::OpHitToSDPs().

105  {
106  OpHitToSDPs(*hit, sdps);
107  }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
DEPRECATED void cheat::PhotonBackTracker::OpHitToSimSDPs ( recob::OpHit const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inlineinherited

Definition at line 100 of file old.PhotonBackTracker.h.

References cheat::PhotonBackTracker::OpHitToSDPs().

101  {
102  OpHitToSDPs(hit, sdps);
103  }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
Detector simulation of raw signals on wires.
DEPRECATED void cheat::PhotonBackTracker::OpHitToSimSDPs ( recob::OpHit const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inlineinherited

Definition at line 100 of file old.PhotonBackTrackerService.h.

References cheat::PhotonBackTracker::OpHitToSDPs().

101  {
102  OpHitToSDPs(hit, sdps);
103  }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
Detector simulation of raw signals on wires.
std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 217 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

219  {
221  }
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToSimSDPs_Ps ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 224 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

226  {
227  return PhotonBackTracker::OpHitToSimSDPs_Ps(opHit_P);
228  }
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitToSimSDPs_Ps ( recob::OpHit const &  opHit) const
inherited

Definition at line 293 of file PhotonBackTracker.cc.

References recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

Referenced by OpHitToSimSDPs_Ps().

294  {
295  std::vector<const sim::SDP*> retVec;
296  double fPeakTime = opHit.PeakTime();
297  double fWidth = opHit.Width();
299  ((fPeakTime - fWidth) * 1000.0) - fDelay;
300  sim::OpDetBacktrackerRecord::timePDclock_t end_time = ((fPeakTime + fWidth) * 1000.0) - fDelay;
301  if (start_time > end_time) { throw; }
302 
303  auto const& timeSDPMap = FindOpDetBTR(fWireReadoutGeom->OpDetFromOpChannel(opHit.OpChannel()))
304  ->timePDclockSDPsMap(); //Not guranteed to be sorted.
305 
306  std::vector<const std::pair<double, std::vector<sim::SDP>>*> timePDclockSDPMap_SortedPointers;
307  for (auto& pair : timeSDPMap) {
308  timePDclockSDPMap_SortedPointers.push_back(&pair);
309  }
310  auto pairSort = [](auto& a, auto& b) { return a->first < b->first; };
311  if (!std::is_sorted(timePDclockSDPMap_SortedPointers.begin(),
312  timePDclockSDPMap_SortedPointers.end(),
313  pairSort)) {
314  std::sort(
315  timePDclockSDPMap_SortedPointers.begin(), timePDclockSDPMap_SortedPointers.end(), pairSort);
316  }
317 
318  //This section is a hack to make comparisons work right.
319  std::vector<sim::SDP> dummyVec;
320  std::pair<double, std::vector<sim::SDP>> start_timePair = std::make_pair(start_time, dummyVec);
321  std::pair<double, std::vector<sim::SDP>> end_timePair = std::make_pair(end_time, dummyVec);
322  auto start_timePair_P = &start_timePair;
323  auto end_timePair_P = &end_timePair;
324  //First interesting iterator.
325  auto mapFirst = std::lower_bound(timePDclockSDPMap_SortedPointers.begin(),
326  timePDclockSDPMap_SortedPointers.end(),
327  start_timePair_P,
328  pairSort);
329  //Last interesting iterator.
330  auto mapLast =
331  std::upper_bound(mapFirst, timePDclockSDPMap_SortedPointers.end(), end_timePair_P, pairSort);
332 
333  for (auto& mapitr = mapFirst; mapitr != mapLast; ++mapitr)
334  for (auto& sdp : (*mapitr)->second)
335  retVec.push_back(&sdp);
336 
337  return retVec;
338  }
art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int opDetNum) const
const geo::WireReadoutGeom * fWireReadoutGeom
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
double timePDclock_t
Type for iTimePDclock tick used in the interface.
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitToSimSDPs_Ps ( art::Ptr< recob::OpHit > const &  opHit_P) const
inherited

Definition at line 341 of file PhotonBackTracker.cc.

343  {
344  return OpHitToSimSDPs_Ps(*opHit_P);
345  }
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
DEPRECATED std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToTrackID ( art::Ptr< recob::OpHit > const &  hit)
inlineinherited
DEPRECATED std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToTrackID ( art::Ptr< recob::OpHit > const &  hit)
inlineinherited
std::vector< int > cheat::PhotonBackTrackerService::OpHitToTrackIds ( recob::OpHit const &  opHit)

Definition at line 161 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackIds().

162  {
164  }
std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
std::vector< int > cheat::PhotonBackTrackerService::OpHitToTrackIds ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 167 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackIds().

168  {
169  return PhotonBackTracker::OpHitToTrackIds(opHit_P);
170  }
std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
std::vector< int > cheat::PhotonBackTracker::OpHitToTrackIds ( recob::OpHit const &  opHit) const
inherited

Definition at line 178 of file PhotonBackTracker.cc.

Referenced by OpHitToTrackIds().

179  {
180  std::vector<int> retVec;
181  for (auto const trackSDP : OpHitToTrackSDPs(opHit)) {
182  retVec.push_back(trackSDP.trackID);
183  }
184  return retVec;
185  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< int > cheat::PhotonBackTracker::OpHitToTrackIds ( art::Ptr< recob::OpHit > const &  opHit) const
inherited

Definition at line 188 of file PhotonBackTracker.cc.

189  {
190  return OpHitToTrackIds(*opHit);
191  }
std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpHitToTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 148 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

150  {
151  return PhotonBackTracker::OpHitToTrackSDPs(opHit_P);
152  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpHitToTrackSDPs ( recob::OpHit const &  opHit)

Definition at line 155 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

156  {
158  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const
inherited

Definition at line 155 of file PhotonBackTracker.cc.

References util::end(), recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

157  {
158  auto OpDetNum = fWireReadoutGeom->OpDetFromOpChannel(opHit_P->OpChannel());
159  const double pTime = opHit_P->PeakTime();
160  const double pWidth = opHit_P->Width();
161  const double start = (pTime - pWidth) * 1000 - fDelay;
162  const double end = (pTime + pWidth) * 1000 - fDelay;
163  return OpDetToTrackSDPs(OpDetNum, start, end);
164  }
std::vector< sim::TrackSDP > OpDetToTrackSDPs(int OpDetNum, double opHit_start_time, double opHit_end_time) const
const geo::WireReadoutGeom * fWireReadoutGeom
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
double PeakTime() const
Definition: OpHit.h:94
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
double Width() const
Definition: OpHit.h:110
int OpChannel() const
Definition: OpHit.h:86
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( recob::OpHit const &  opHit) const
inherited

Definition at line 167 of file PhotonBackTracker.cc.

References util::end(), recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

168  {
169  auto OpDetNum = fWireReadoutGeom->OpDetFromOpChannel(opHit.OpChannel());
170  const double pTime = opHit.PeakTime();
171  const double pWidth = opHit.Width();
172  const double start = (pTime - pWidth) * 1000 - fDelay;
173  const double end = (pTime + pWidth) * 1000 - fDelay;
174  return OpDetToTrackSDPs(OpDetNum, start, end);
175  }
std::vector< sim::TrackSDP > OpDetToTrackSDPs(int OpDetNum, double opHit_start_time, double opHit_end_time) const
const geo::WireReadoutGeom * fWireReadoutGeom
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::vector< double > cheat::PhotonBackTrackerService::OpHitToXYZ ( recob::OpHit const &  opHit)

Definition at line 259 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToXYZ().

260  {
261  return PhotonBackTracker::OpHitToXYZ(opHit);
262  }
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
std::vector< double > cheat::PhotonBackTrackerService::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 265 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToXYZ().

266  {
267  return PhotonBackTracker::OpHitToXYZ(opHit_P);
268  }
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
const sim::ParticleList& cheat::PhotonBackTracker::ParticleList ( ) const
inlineinherited

Definition at line 60 of file old.PhotonBackTracker.h.

References cheat::PhotonBackTracker::fParticleList.

60 { return fParticleList; }
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
const sim::ParticleList& cheat::PhotonBackTracker::ParticleList ( ) const
inlineinherited

Definition at line 60 of file old.PhotonBackTrackerService.h.

References cheat::PhotonBackTracker::fParticleList.

60 { return fParticleList; }
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
const art::Ptr< simb::MCTruth > & cheat::PhotonBackTracker::ParticleToMCTruth ( const simb::MCParticle p) const
inherited

Definition at line 248 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::shouldThisFail(), simb::MCParticle::TrackId(), and cheat::PhotonBackTracker::TrackIDToMCTruth().

Referenced by cheat::PhotonBackTracker::SetEveIdCalculator().

250  {
251  shouldThisFail();
252  return this->TrackIDToMCTruth(p->TrackId());
253  }
int TrackId() const
Definition: MCParticle.h:211
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
const art::Ptr<simb::MCTruth>& cheat::PhotonBackTracker::ParticleToMCTruth ( const simb::MCParticle p) const
inherited
template<typename Evt >
void cheat::PhotonBackTracker::PrepEvent ( Evt const &  evt)
inherited
template<typename Evt >
void cheat::PhotonBackTracker::PrepOpDetBTRs ( Evt const &  evt)
inherited

Referenced by priv_PrepOpDetBTRs().

template<typename Evt >
void cheat::PhotonBackTracker::PrepOpFlashToOpHits ( Evt const &  evt)
inherited
bool cheat::PhotonBackTrackerService::priv_CanRun ( art::Event const &  evt)
private

Definition at line 65 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::CanRun().

Referenced by priv_PrepEvent(), priv_PrepOpDetBTRs(), and priv_PrepOpFlashToOpHits().

66  {
68  }
bool CanRun(Evt const &evt)
TCEvent evt
Definition: DataStructs.cxx:8
bool cheat::PhotonBackTrackerService::priv_OpDetBTRsReady ( )
inlineprivate

Definition at line 120 of file PhotonBackTrackerService.h.

Referenced by priv_PrepOpDetBTRs().

bool cheat::PhotonBackTrackerService::priv_OpFlashToOpHitsReady ( )
inlineprivate

Definition at line 121 of file PhotonBackTrackerService.h.

References DECLARE_ART_SERVICE, and art::LEGACY.

Referenced by priv_PrepOpFlashToOpHits().

void cheat::PhotonBackTrackerService::priv_PrepEvent ( art::Event const &  evt,
art::ScheduleContext   
)
private
void cheat::PhotonBackTrackerService::priv_PrepFailed ( )
private

Definition at line 71 of file PhotonBackTrackerService.cc.

Referenced by priv_PrepOpDetBTRs(), and priv_PrepOpFlashToOpHits().

72  {
73  throw cet::exception("PhotonBackTrackerService")
74  << "The called Prep Fucntion failed. This is most likely due "
75  << "to a PhotonBackTracker fucntion being used on a file that "
76  << "is real data.";
77  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::PhotonBackTrackerService::priv_PrepOpDetBTRs ( art::Event const &  evt)
private

Definition at line 80 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::PrepOpDetBTRs(), priv_CanRun(), priv_OpDetBTRsReady(), and priv_PrepFailed().

Referenced by priv_PrepEvent().

81  {
82  if (!priv_CanRun(evt)) { priv_PrepFailed(); }
83  if (priv_OpDetBTRsReady()) { return; }
84  try {
86  }
87  catch (cet::exception const&) {
88  //This needs to go. Make it specific if there is a really an exception we would like to catch.
89  mf::LogWarning("PhotonBackTrackerService")
90  << "Rebuild failed to get the OpDetBTRs. This is expected when "
91  << "running on a generation or simulation step.";
92  }
93  }
bool priv_CanRun(art::Event const &evt)
void PrepOpDetBTRs(Evt const &evt)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TCEvent evt
Definition: DataStructs.cxx:8
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::PhotonBackTrackerService::priv_PrepOpFlashToOpHits ( art::Event const &  evt)
private

Definition at line 95 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::PrepOpFlashToOpHits(), priv_CanRun(), priv_OpFlashToOpHitsReady(), and priv_PrepFailed().

Referenced by priv_PrepEvent().

96  {
97  if (!priv_CanRun(evt)) { priv_PrepFailed(); }
98  if (priv_OpFlashToOpHitsReady()) { return; }
99  try {
101  }
102  catch (cet::exception const&) {
103  // This needs to go. Make it specific if there is a really an exception we would like to catch.
104  mf::LogWarning("PhotonBackTrackerService")
105  << "Rebuild failed to get the OpFlashToOpHits. This is expected when "
106  << "running on a generation or simulation stage.";
107  }
108  }
void PrepOpFlashToOpHits(Evt const &evt)
bool priv_CanRun(art::Event const &evt)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TCEvent evt
Definition: DataStructs.cxx:8
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const provider_type* cheat::PhotonBackTrackerService::provider ( ) const
inline

Definition at line 45 of file PhotonBackTrackerService.h.

References tca::evt, and lar::dump::vector().

45 { return static_cast<provider_type const*>(this); }
void cheat::PhotonBackTrackerService::Rebuild ( art::Event const &  evt)

Definition at line 50 of file PhotonBackTrackerService.cc.

References art::ScheduleContext::invalid(), and priv_PrepEvent().

Referenced by cheat::PhotonBackTrackerLoader::produce().

51  {
53  }
static ScheduleContext invalid()
void priv_PrepEvent(art::Event const &evt, art::ScheduleContext)
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::PhotonBackTracker::Rebuild ( const art::Event evt)
inherited

Definition at line 53 of file old.PhotonBackTracker_service.cc.

References sim::ParticleList::Add(), sim::ParticleList::AdoptEveIdCalculator(), sim::ParticleList::clear(), cheat::PhotonBackTracker::cOpDetBacktrackerRecords, art::Handle< T >::failedToGet(), cheat::PhotonBackTracker::fG4ModuleLabel, art::fill_ptr_vector(), cheat::PhotonBackTracker::fMCTruthList, cheat::PhotonBackTracker::fParticleList, cheat::PhotonBackTracker::fTrackIDToMCTruthIndex, art::ProductRetriever::getByLabel(), cheat::PhotonBackTracker::GetSetOfTrackIDs(), cheat::PhotonBackTracker::have_complained, art::Event::isRealData(), MF_LOG_DEBUG, part, art::errors::ProductNotFound, and art::Handle< T >::whyFailed().

54  {
55  // do nothing if this is data
56  if (evt.isRealData()) return;
57 
58  // get the particles from the event
60  evt.getByLabel(fG4ModuleLabel, pHandle);
61 
62  // first check to see if we got called to early, that is the particles are
63  // and sim channels are not made yet in a MC production job
64  // if that is the case, we'll take care of it later
65  if (pHandle.failedToGet()) {
66  mf::LogWarning("PhotonBackTracker")
67  << "failed to get handle to simb::MCParticle from " << fG4ModuleLabel << ", return";
68  return;
69  }
70 
71  // Clear out anything remaining from previous calls to Rebuild
73  fMCTruthList.clear();
75  //fVoxelList .clear();
76 
78 
79  if (fo.isValid()) {
80  for (size_t p = 0; p < pHandle->size(); ++p) {
81 
82  simb::MCParticle* part = new simb::MCParticle(pHandle->at(p));
83  fParticleList.Add(part);
84 
85  // get the simb::MCTruth associated to this sim::ParticleList
86  try {
87  art::Ptr<simb::MCTruth> mct = fo.at(p);
88  if (fMCTruthList.size() < 1)
89  fMCTruthList.push_back(mct);
90  else {
91  // check that we are not adding a simb::MCTruth twice to the collection
92  // we know that all the particles for a given simb::MCTruth are put into the
93  // collection of particles at the same time, so we can just check that the
94  // current art::Ptr has a different id than the last one put
95  if (!(mct == fMCTruthList.back())) fMCTruthList.push_back(mct);
96  }
97  // fill the track id to mctruth index map
98  fTrackIDToMCTruthIndex[pHandle->at(p).TrackId()] = fMCTruthList.size() - 1;
99  }
100  catch (cet::exception& ex) {
101  mf::LogWarning("PhotonBackTracker") << "unable to find MCTruth from ParticleList "
102  << "created in " << fG4ModuleLabel << " "
103  << "any attempt to get the MCTruth objects from "
104  << "the photon backtracker will fail\n"
105  << "message from caught exception:\n"
106  << ex;
107  }
108  } // end loop over particles to get MCTruthList
109  } // end if fo.isValid()
110 
111  // grab the sim::OpDetBacktrackerRecords for this event
112 
113  /*
114  try{evt.getView(fG4ModuleLabel, cOpDetBacktrackerRecords);}
115  catch(art::Exception const& e){
116  if(e.categoryCode() != art::errors::ProductNotFound) throw;
117  if(have_complained==false){
118  }
119  }
120  */
121 
123  // std::vector< art::Ptr< sim::OpDetBacktrackerRecords > > cOpDetBacktrackerRecords;
124  evt.getByLabel(fG4ModuleLabel, cPBTRHandle);
125  if (
126  cPBTRHandle
127  .failedToGet()) { //Failed to get products. Prepare for controlled freak out. Assuming this is because there is no OpDetBacktrackerRecords, we will not cause things to fail, but will prepare to fail if a user tries to call backtracker functionality.
128  auto failMode = cPBTRHandle.whyFailed();
129  if (failMode->categoryCode() != art::errors::ProductNotFound)
130  throw;
131  else if (have_complained == false) {
132  std::cout << "FAILED BECAUSE " << (*failMode) << "\n";
133  have_complained = true;
134  mf::LogWarning("PhotonBackTracker")
135  << "Failed to get BackTrackerRecords from this event. All calls to the PhotonBackTracker "
136  "will fail.\n"
137  << "This message will be generated only once per lar invokation. If this is event one, "
138  "be aware the PhotonBackTracker may not work on any events from this file.\n"
139  << "Please change the log level to debug if you need more information for each event.\n"
140  << "Failed with :" << (*failMode) << "\n";
141  mf::LogDebug("PhotonBackTracker") << "Failed to get BackTrackerRecords from this event.\n";
142  }
143  else {
144  mf::LogDebug("PhotonBackTracker") << "Failed to get BackTrackerRecords from this event.\n";
145  }
146  }
147  else { //Did not fail to get products. All is well. Run as expected.
149  }
150 
151  // grab the voxel list for this event
152  //fVoxelList = sim::SimListUtils::GetLArVoxelList(evt, fG4ModuleLabel);
153 
155 
156  MF_LOG_DEBUG("PhotonBackTracker")
157  << "PhotonBackTracker has " << cOpDetBacktrackerRecords.size()
158  << " sim::OpDetBacktrackerRecords and " << GetSetOfTrackIDs().size()
159  << " tracks. The particles are:\n"
160  << fParticleList << "\n the MCTruth information is\n";
161  for (size_t mc = 0; mc < fMCTruthList.size(); ++mc)
162  MF_LOG_DEBUG("PhotonBackTracker") << *(fMCTruthList.at(mc).get());
163 
164  return;
165  }
std::map< int, int > fTrackIDToMCTruthIndex
map of track ids to MCTruthList entry
void Add(simb::MCParticle *value)
Definition: ParticleList.h:315
bool isRealData() const
Definition: Event.cc:53
std::string fG4ModuleLabel
label for geant4 module
TString part[npart]
Definition: Style.C:32
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define MF_LOG_DEBUG(id)
std::shared_ptr< art::Exception const > whyFailed() const
Definition: Handle.h:231
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
static void AdoptEveIdCalculator(EveIdCalculator *)
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool failedToGet() const
Definition: Handle.h:210
void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)
inherited
void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)
inherited
std::vector< double > cheat::PhotonBackTrackerService::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps) const

Definition at line 245 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::SimSDPsToXYZ().

247  {
248  return PhotonBackTracker::SimSDPsToXYZ(sdps);
249  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
std::vector< double > cheat::PhotonBackTrackerService::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps)

Definition at line 252 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::SimSDPsToXYZ().

254  {
255  return PhotonBackTracker::SimSDPsToXYZ(sdps_Ps);
256  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps)
inherited

Definition at line 731 of file old.PhotonBackTracker_service.cc.

References e, cheat::PhotonBackTracker::shouldThisFail(), w, weight, x, y, and z.

Referenced by cheat::PhotonBackTracker::OpHitToSimSDPs(), cheat::PhotonBackTracker::OpHitToXYZ(), and SimSDPsToXYZ().

732  {
733  shouldThisFail();
734  std::vector<double> xyz(3, -999.);
735 
736  double x = 0.;
737  double y = 0.;
738  double z = 0.;
739  double w = 0.;
740 
741  // loop over photons.
742 
743  for (auto const& sdp : sdps) {
744 
745  double weight = sdp.numPhotons;
746 
747  w += weight;
748  x += weight * sdp.x;
749  y += weight * sdp.y;
750  z += weight * sdp.z;
751 
752  } // end loop over sim::SDPs
753 
754  //If the sum of the weights is still zero, then fail to return a value.
755  //A hit with no contributing photons does't make sense.
756  if (w < 1.e-5)
757  throw cet::exception("PhotonBackTracker")
758  << "No sim::SDPs providing non-zero number of photons"
759  << " can't determine originating location from truth\n";
760 
761  xyz[0] = x / w;
762  xyz[1] = y / w;
763  xyz[2] = z / w;
764 
765  return xyz;
766  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
double weight
Definition: plottest35.C:25
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps) const
inherited

Definition at line 376 of file PhotonBackTracker.cc.

References e, w, weight, x, y, and z.

378  {
379  std::vector<double> xyz(3, -999.);
380  double x = 0.;
381  double y = 0.;
382  double z = 0.;
383  double w = 0.;
384  // loop over photons.
385  for (const sim::SDP* sdp_P : sdps_Ps) {
386  auto& sdp = *sdp_P;
387  double weight = sdp.numPhotons;
388  w += weight;
389  x += weight * sdp.x;
390  y += weight * sdp.y;
391  z += weight * sdp.z;
392  } // end loop over sim::SDPs
393  // If the sum of the weights is still zero, then fail to return a value. A hit with
394  // no contributing photons does't make sense.
395  if (w < 1.e-5)
396  throw cet::exception("PhotonBackTracker")
397  << "No sim::SDPs providing non-zero number of photons"
398  << " can't determine originating location from truth\n";
399  xyz[0] = x / w;
400  xyz[1] = y / w;
401  xyz[2] = z / w;
402  return xyz;
403  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
double weight
Definition: plottest35.C:25
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< std::vector< art::Ptr< recob::OpHit > > > cheat::PhotonBackTracker::TrackIDsToOpHits ( std::vector< art::Ptr< recob::OpHit >> const &  allhits,
std::vector< int > const &  tkIDs 
)
inherited

Definition at line 287 of file old.PhotonBackTracker_service.cc.

References cheat::PhotonBackTracker::ChannelToTrackSDPs(), util::end(), cheat::PhotonBackTracker::fDelay, cheat::PhotonBackTracker::fMinOpHitEnergyFraction, recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), cheat::PhotonBackTracker::shouldThisFail(), and recob::OpHit::Width().

Referenced by cheat::PhotonBackTracker::OpHitToTrackID().

290  {
291  shouldThisFail();
292  // returns a subset of the opHits in the allOpHits collection that are matched
293  // to MC particles listed in tkIDs
294 
295  // temporary vector of TrackIDs and Ptrs to opHits so only one
296  // loop through the (possibly large) allOpHits collection is needed
297  std::vector<std::pair<int, art::Ptr<recob::OpHit>>> opHitList;
298  std::vector<sim::TrackSDP> tids;
299  for (auto itr = allOpHits.begin(); itr != allOpHits.end(); ++itr) {
300  tids.clear();
301  art::Ptr<recob::OpHit> const& opHit = *itr;
302  const double pTime = opHit->PeakTime(), pWidth = opHit->Width();
303  const double start = (pTime - pWidth) * 1000.0 - fDelay,
304  end = (pTime + pWidth) * 1000.0 - fDelay;
305  this->ChannelToTrackSDPs(tids, opHit->OpChannel(), start, end);
306  for (auto itid = tids.begin(); itid != tids.end(); ++itid) {
307  for (auto itkid = tkIDs.begin(); itkid != tkIDs.end(); ++itkid) {
308  if (itid->trackID == *itkid) {
309  if (itid->energyFrac > fMinOpHitEnergyFraction)
310  opHitList.push_back(std::make_pair(*itkid, opHit));
311  }
312  } // itkid
313  } // itid
314  } // itr
315 
316  // now build the truOpHits vector that will be returned to the caller
317  std::vector<std::vector<art::Ptr<recob::OpHit>>> truOpHits;
318  // temporary vector containing opHits assigned to one MC particle
319  std::vector<art::Ptr<recob::OpHit>> tmpOpHits;
320  for (auto itkid = tkIDs.begin(); itkid != tkIDs.end(); ++itkid) {
321  tmpOpHits.clear();
322  for (auto itr = opHitList.begin(); itr != opHitList.end(); ++itr) {
323  if (*itkid == (*itr).first) tmpOpHits.push_back((*itr).second);
324  }
325  truOpHits.push_back(tmpOpHits);
326  }
327 
328  return truOpHits;
329  }
double PeakTime() const
Definition: OpHit.h:94
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
double Width() const
Definition: OpHit.h:110
void ChannelToTrackSDPs(std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
int OpChannel() const
Definition: OpHit.h:86
const std::vector<std::vector<art::Ptr<recob::OpHit> > > cheat::PhotonBackTracker::TrackIDsToOpHits ( std::vector< art::Ptr< recob::OpHit >> const &  allhits,
std::vector< int > const &  tkIDs 
)
inherited
std::vector< std::vector< art::Ptr< recob::OpHit > > > cheat::PhotonBackTrackerService::TrackIdsToOpHits_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
)

Definition at line 209 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdsToOpHits_Ps().

212  {
213  return PhotonBackTracker::TrackIdsToOpHits_Ps(tkIds, hitsIn);
214  }
std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
std::vector< std::vector< art::Ptr< recob::OpHit > > > cheat::PhotonBackTracker::TrackIdsToOpHits_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
) const
inherited

Definition at line 259 of file PhotonBackTracker.cc.

References util::end(), recob::OpHit::OpChannel(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

Referenced by TrackIdsToOpHits_Ps().

262  {
263  std::vector<std::pair<int, art::Ptr<recob::OpHit>>> opHitList;
264  for (auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
265  art::Ptr<recob::OpHit> const& opHit = *itr;
266  auto OpDetNum = fWireReadoutGeom->OpDetFromOpChannel(opHit->OpChannel());
267  const double pTime = opHit->PeakTime(), pWidth = opHit->Width();
268  const double start = (pTime - pWidth) * 1000.0 - fDelay,
269  end = (pTime + pWidth) * 1000.0 - fDelay;
270  std::vector<sim::TrackSDP> tids = OpDetToTrackSDPs(OpDetNum, start, end);
271  for (auto itid = tids.begin(); itid != tids.end(); ++itid) {
272  for (auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
273  if (itid->trackID == *itkid and itid->energyFrac > fMinOpHitEnergyFraction)
274  opHitList.push_back(std::make_pair(*itkid, opHit));
275  } // itkid
276  } // itid
277  } // itr
278  // now build the truOpHits vector that will be returned to the caller
279  std::vector<std::vector<art::Ptr<recob::OpHit>>> truOpHits;
280  // temporary vector containing opHits assigned to one MC particle
281  std::vector<art::Ptr<recob::OpHit>> tmpOpHits;
282  for (auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
283  tmpOpHits.clear();
284  for (auto itr = opHitList.begin(); itr != opHitList.end(); ++itr) {
285  if (*itkid == (*itr).first) tmpOpHits.push_back((*itr).second);
286  }
287  truOpHits.push_back(tmpOpHits);
288  }
289  return truOpHits;
290  }
std::vector< sim::TrackSDP > OpDetToTrackSDPs(int OpDetNum, double opHit_start_time, double opHit_end_time) const
const geo::WireReadoutGeom * fWireReadoutGeom
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
double PeakTime() const
Definition: OpHit.h:94
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
double Width() const
Definition: OpHit.h:110
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
int OpChannel() const
Definition: OpHit.h:86
const art::Ptr< simb::MCTruth > & cheat::PhotonBackTracker::TrackIDToMCTruth ( int const &  id) const
inherited

Definition at line 207 of file old.PhotonBackTracker_service.cc.

References util::abs(), cheat::PhotonBackTracker::fMCTruthList, cheat::PhotonBackTracker::fTrackIDToMCTruthIndex, and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::MCTruthToParticles(), cheat::PhotonBackTracker::ParticleToMCTruth(), and cheat::PhotonBackTracker::SetEveIdCalculator().

208  {
209  shouldThisFail();
210  // find the entry in the MCTruth collection for this track id
211  size_t mct = fTrackIDToMCTruthIndex.find(abs(id))->second;
212 
213  if (/* mct < 0 || */ mct > fMCTruthList.size())
214  throw cet::exception("PhotonBackTracker")
215  << "attempting to find MCTruth index for "
216  << "out of range value: " << mct << "/" << fMCTruthList.size() << "\n";
217 
218  return fMCTruthList[mct];
219  }
std::map< int, int > fTrackIDToMCTruthIndex
map of track ids to MCTruthList entry
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const art::Ptr<simb::MCTruth>& cheat::PhotonBackTracker::TrackIDToMCTruth ( int const &  id) const
inherited
const simb::MCParticle* cheat::PhotonBackTracker::TrackIDToMotherParticle ( int const &  id) const
inherited
const simb::MCParticle * cheat::PhotonBackTracker::TrackIDToMotherParticle ( int const &  id) const
inherited

Definition at line 197 of file old.PhotonBackTracker_service.cc.

References util::abs(), sim::ParticleList::EveId(), cheat::PhotonBackTracker::fParticleList, cheat::PhotonBackTracker::shouldThisFail(), and cheat::PhotonBackTracker::TrackIDToParticle().

Referenced by cheat::PhotonBackTracker::SetEveIdCalculator().

198  {
199  shouldThisFail();
200  // get the mother id from the particle navigator
201  // the EveId was adopted in the Rebuild method
202 
203  return this->TrackIDToParticle(fParticleList.EveId(abs(id)));
204  }
const simb::MCParticle * TrackIDToParticle(int const &id) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
int EveId(const int trackID) const
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTrackerService::TrackIdToOpHits_Ps ( int  tkId,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
)

Definition at line 201 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdToOpHits_Ps().

204  {
205  return PhotonBackTracker::TrackIdToOpHits_Ps(tkId, hitsIn);
206  }
std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::TrackIdToOpHits_Ps ( int  tkId,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
) const
inherited

Definition at line 246 of file PhotonBackTracker.cc.

Referenced by TrackIdToOpHits_Ps().

249  {
250  // One would think we would want to have this function defined, and call this function
251  // in the std::vector<tkids> to opHits, but that would require more loops (and a
252  // higher overhead.) Instead, to provide this, we will just call the existing
253  // std::vector<tkids>ToOpHits with an input of 1.
254  std::vector<int> tkidFake(1, tkId);
255  return TrackIdsToOpHits_Ps(tkidFake, hitsIn).at(0);
256  }
std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
const simb::MCParticle* cheat::PhotonBackTracker::TrackIDToParticle ( int const &  id) const
inherited
const simb::MCParticle * cheat::PhotonBackTracker::TrackIDToParticle ( int const &  id) const
inherited

Definition at line 181 of file old.PhotonBackTracker_service.cc.

References sim::ParticleList::end(), sim::ParticleList::find(), cheat::PhotonBackTracker::fParticleList, and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::SetEveIdCalculator(), and cheat::PhotonBackTracker::TrackIDToMotherParticle().

182  {
183  shouldThisFail();
185 
186  if (part_it == fParticleList.end()) {
187  mf::LogWarning("PhotonBackTracker")
188  << "can't find particle with track id " << id << " in sim::ParticleList"
189  << " returning null pointer";
190  return 0;
191  }
192 
193  return part_it->second;
194  }
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
iterator find(const key_type &key)
Definition: ParticleList.h:318
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
std::vector< sim::SDP > cheat::PhotonBackTracker::TrackIDToSimSDP ( int const &  id) const
inherited

Definition at line 222 of file old.PhotonBackTracker_service.cc.

References util::abs(), cheat::PhotonBackTracker::cOpDetBacktrackerRecords, sc, and cheat::PhotonBackTracker::shouldThisFail().

Referenced by cheat::PhotonBackTracker::SetEveIdCalculator().

223  {
224  shouldThisFail();
225  std::vector<sim::SDP> sdps;
226 
227  // loop over all sim::OpDetBacktrackerRecords and fill a vector
228  // of sim::SDP objects for the given track id
229  for (size_t sc = 0; sc < cOpDetBacktrackerRecords.size(); ++sc) {
230  const auto& pdTimeSDPmap = cOpDetBacktrackerRecords[sc]->timePDclockSDPsMap();
231 
232  // loop over the SDPMAP
233  for (auto mapitr = pdTimeSDPmap.begin(); mapitr != pdTimeSDPmap.end(); mapitr++) {
234 
235  // loop over the vector of SDP objects.
236  const std::vector<sim::SDP>& sdpvec = (*mapitr).second;
237  for (size_t iv = 0; iv < sdpvec.size(); ++iv) {
238  if (abs(sdpvec[iv].trackID) == id) sdps.push_back(sdpvec[iv]);
239  }
240 
241  } // end loop over map from sim::OpDetBacktrackerRecord
242  } // end loop over sim::OpDetBacktrackerRecords
243 
244  return sdps;
245  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
Float_t sc
Definition: plot.C:23
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
std::vector<sim::SDP> cheat::PhotonBackTracker::TrackIDToSimSDP ( int const &  id) const
inherited
std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::TrackIdToSimSDPs_Ps ( int  id)

Definition at line 127 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps().

128  {
130  }
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int id) const
std::vector< const sim::SDP * > cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps ( int  id) const
inherited

Definition at line 92 of file PhotonBackTracker.cc.

References util::abs().

Referenced by TrackIdToSimSDPs_Ps().

93  {
94  std::vector<const sim::SDP*> sdp_Ps;
95  for (size_t odet = 0; odet < priv_OpDetBTRs.size(); ++odet) {
96  const auto& pdTimeSDPmap = priv_OpDetBTRs[odet]->timePDclockSDPsMap();
97  for (auto mapitr = pdTimeSDPmap.begin(); mapitr != pdTimeSDPmap.end(); mapitr++) {
98  std::vector<sim::SDP> const& sdpvec = (*mapitr).second;
99  for (size_t iv = 0; iv < sdpvec.size(); ++iv) {
100  if (abs(sdpvec[iv].trackID) == id) sdp_Ps.push_back(&(sdpvec[iv]));
101  }
102  } // end loop over map from sim::OpDetBacktrackerRecord
103  } // end loop over sim::OpDetBacktrackerRecords
104  return sdp_Ps;
105  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs

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