LArSoft  v09_90_00
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)
 
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBTRs ()
 
const double GetDelay ()
 
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int const &id)
 
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int const &id, geo::View_t const &view)
 
art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int const &opDetNum)
 
const std::vector< sim::TrackSDPOpDetToTrackSDPs (int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (recob::OpHit const &opHit)
 
const std::vector< int > OpHitToTrackIds (recob::OpHit const &opHit)
 
const std::vector< int > OpHitToTrackIds (art::Ptr< recob::OpHit > const &opHit_P)
 
const std::vector< int > OpHitToEveTrackIds (recob::OpHit const &opHit)
 
const 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)
 
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps (int const &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::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (recob::OpHit const &opHit)
 
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (art::Ptr< recob::OpHit > &opHit_P)
 
const std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps) const &
 
const std::vector< double > SimSDPsToXYZ (std::vector< const sim::SDP * > const &sdps_Ps)
 
const std::vector< double > OpHitToXYZ (recob::OpHit const &opHit)
 
const std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &opHit_P)
 
const std::set< int > GetSetOfEveIds ()
 
const std::set< int > GetSetOfTrackIds ()
 
const std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
const std::set< int > GetSetOfEveIds (const std::vector< recob::OpHit > &opHits)
 
const std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
const std::set< int > GetSetOfTrackIds (std::vector< recob::OpHit > const &opHits)
 
const double OpHitCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
const double OpHitLightCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps)
 
const 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, geo::View_t const &view)
 
const 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)
 
const 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, geo::View_t const &view)
 
const 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)
 
const 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)
 
const std::set< int > OpFlashToTrackIds (art::Ptr< recob::OpFlash > &flash_P) const
 
const 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)
 

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)
 
const std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
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)
 
const 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 >
const bool CanRun (Evt const &evt)
 
template<typename Evt >
void PrepOpDetBTRs (Evt const &evt)
 
template<typename Evt >
void PrepOpFlashToOpHits (Evt const &evt)
 
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps (art::Ptr< recob::OpFlash > &flash_P) const
 
const std::vector< double > OpFlashToXYZ (art::Ptr< recob::OpFlash > &flash_P) const
 
void ClearEvent ()
 
const bool BTRsReady ()
 
const bool OpFlashToOpHitsReady ()
 
const art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int const &opDetNum) const
 
const std::vector< sim::TrackSDPOpDetToTrackSDPs (int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
 
const std::vector< int > OpHitToTrackIds (recob::OpHit const &opHit) const
 
const std::vector< int > OpHitToTrackIds (art::Ptr< recob::OpHit > const &opHit) const
 
const std::vector< sim::TrackSDPOpHitToEveTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
const std::vector< sim::TrackSDPOpHitToEveTrackSDPs (recob::OpHit const &opHit) const
 
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (recob::OpHit const &opHit) const
 
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (art::Ptr< recob::OpHit > const &opHit_P) const
 
const std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
const std::vector< double > OpHitsToXYZ (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
const std::set< int > GetSetOfEveIds () const
 
const std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) const
 
const std::set< int > GetSetOfEveIds (std::vector< recob::OpHit > const &opHits) const
 
const std::set< int > GetSetOfTrackIds () const
 
const std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) const
 
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 38 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>(),
30  lar::providerFrom<geo::Geometry>() //,
31  // lar::providerFrom<detinfo::DetectorClocksService>()
32  )
33  {
35  }
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 38 of file PhotonBackTrackerService.cc.

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

40  : PhotonBackTracker(config.PhotonBackTrackerTable(),
41  lar::providerFrom<cheat::ParticleInventoryService>(),
42  lar::providerFrom<geo::Geometry>() //,
43  // lar::providerFrom<detinfo::DetectorClocksService>()
44  )
45  {
47  }
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

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

Definition at line 84 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::priv_OpDetBTRs.

85  {
86  return !(priv_OpDetBTRs.empty());
87  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
template<typename Evt >
const 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, geo::GeometryCore::OpDetFromOpChannel(), 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 {
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  }
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
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 77 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::priv_OpDetBTRs, and cheat::PhotonBackTracker::priv_OpFlashToOpHits.

Referenced by priv_PrepEvent().

78  {
79  priv_OpDetBTRs.clear();
80  priv_OpFlashToOpHits.clear();
81  }
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 const &  opDetNum)

Definition at line 159 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::FindOpDetBTR().

160  {
161  return PhotonBackTracker::FindOpDetBTR(opDetNum);
162  }
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
const art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTracker::FindOpDetBTR ( int const &  opDetNum) const
inherited

Definition at line 128 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::priv_OpDetBTRs, and sc.

Referenced by FindOpDetBTR(), cheat::PhotonBackTracker::OpDetToTrackSDPs(), and cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

130  {
132  for (size_t sc = 0; sc < priv_OpDetBTRs.size(); ++sc) {
133  //This could become a bug. What if it occurs twice (shouldn't happen in correct records, but still, no error handeling included for the situation
134  if (priv_OpDetBTRs.at(sc)->OpDetNum() == opDetNum) opDet = priv_OpDetBTRs.at(sc);
135  }
136  if (!opDet) {
137  throw cet::exception("PhotonBackTracker2") << "No sim:: OpDetBacktrackerRecord corresponding "
138  << "to opDetNum: " << opDetNum << "\n";
139  }
140  return opDet;
141  }
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
const double cheat::PhotonBackTrackerService::GetDelay ( )

Definition at line 139 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetDelay().

140  {
142  }
const std::set< int > cheat::PhotonBackTrackerService::GetSetOfEveIds ( )

Definition at line 306 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

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

Definition at line 318 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

320  {
321  return PhotonBackTracker::GetSetOfEveIds(opHits_Ps);
322  }
const std::set< int > GetSetOfEveIds() const
const std::set< int > cheat::PhotonBackTrackerService::GetSetOfEveIds ( const std::vector< recob::OpHit > &  opHits)

Definition at line 324 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfEveIds().

326  {
327  return PhotonBackTracker::GetSetOfEveIds(opHits);
328  }
const 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
const std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( ) const
inherited

Definition at line 508 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::fPartInv, and cheat::ParticleInventory::GetSetOfEveIds().

Referenced by GetSetOfEveIds().

509  {
510  //std::set<int> out = fPartInv->GetSetOfEveIds();
511  return fPartInv->GetSetOfEveIds();
512  //return out;
513  }
const cheat::ParticleInventory * fPartInv
std::set< int > GetSetOfEveIds() const
const std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( std::vector< art::Ptr< recob::OpHit >> const &  opHits) const
inherited

Definition at line 522 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

524  {
525  std::set<int> eveIds;
526  for (auto const& opHit_P : opHits_Ps) {
527  const std::vector<sim::TrackSDP> sdps = this->OpHitToEveTrackSDPs(opHit_P);
528  for (auto const& sdp : sdps) {
529  eveIds.insert(sdp.trackID);
530  } //end sdps
531  } //End for hits
532  return eveIds;
533  }
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( std::vector< recob::OpHit > const &  opHits) const
inherited

Definition at line 536 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

538  { /*NEW*/ /*COMPLETE*/
539  std::set<int> eveIds;
540  for (auto const& opHit : opHits) {
541  const std::vector<sim::TrackSDP> sdps = this->OpHitToEveTrackSDPs(opHit);
542  for (auto const& sdp : sdps) {
543  eveIds.insert(sdp.trackID);
544  } //end sdps
545  } //End for hits
546  return eveIds;
547  }
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const std::set< int > cheat::PhotonBackTrackerService::GetSetOfTrackIds ( )

Definition at line 312 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

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

Definition at line 331 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

333  {
334  return PhotonBackTracker::GetSetOfTrackIds(opHits_Ps);
335  }
const std::set< int > GetSetOfTrackIds() const
const std::set< int > cheat::PhotonBackTrackerService::GetSetOfTrackIds ( std::vector< recob::OpHit > const &  opHits)

Definition at line 337 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::GetSetOfTrackIds().

339  {
341  }
const 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
const std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( ) const
inherited

Definition at line 516 of file PhotonBackTracker.cc.

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

Referenced by GetSetOfTrackIds().

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

Definition at line 550 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

552  {
553  std::set<int> tids;
554  for (auto const& opHit : opHits) {
555  for (auto const& sdp : this->OpHitToTrackSDPs(opHit)) {
556  tids.insert(sdp.trackID);
557  } //End for TrackSDPs
558  } //End for hits
559  return tids;
560  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
const std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( std::vector< recob::OpHit > const &  opHits) const
inherited

Definition at line 563 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

565  { /*NEW*/ /*COMPLETE*/
566  std::set<int> tids;
567  for (auto const& opHit : opHits) {
568  for (auto const& sdp : this->OpHitToTrackSDPs(opHit)) {
569  tids.insert(sdp.trackID);
570  } //End for TrackSDPs
571  } //End for hits
572  return tids;
573  }
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.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<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<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 133 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpDetBTRs().

134  {
136  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs()
const std::vector< sim::TrackSDP > cheat::PhotonBackTrackerService::OpDetToTrackSDPs ( int const &  OpDetNum,
double const &  opHit_start_time,
double const &  opHit_end_time 
)

Definition at line 165 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpDetToTrackSDPs().

169  {
170  return PhotonBackTracker::OpDetToTrackSDPs(OpDetNum, opHit_start_time, opHit_end_time);
171  }
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpDetToTrackSDPs ( int const &  OpDetNum,
double const &  opHit_start_time,
double const &  opHit_end_time 
) const
inherited

Definition at line 144 of file PhotonBackTracker.cc.

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

Referenced by OpDetToTrackSDPs(), cheat::PhotonBackTracker::OpHitToTrackSDPs(), and cheat::PhotonBackTracker::TrackIdsToOpHits_Ps().

148  {
149  std::vector<sim::TrackSDP> tSDPs;
150  double totalE = 0;
151  try {
152  const art::Ptr<sim::OpDetBacktrackerRecord> opDetBTR = this->FindOpDetBTR(OpDetNum);
153  // ( fGeom->OpDetFromOpChannel(channel) );
154  std::vector<sim::SDP> simSDPs =
155  opDetBTR->TrackIDsAndEnergies(opHit_start_time, opHit_end_time);
156  for (size_t e = 0; e < simSDPs.size(); ++e)
157  totalE += simSDPs[e].energy;
158  if (totalE < 1.e-5) totalE = 1.;
159  for (size_t e = 0; e < simSDPs.size(); ++e) {
160  if (simSDPs[e].trackID == sim::NoParticleId) continue;
161  sim::TrackSDP info;
162  info.trackID = std::abs(simSDPs[e].trackID);
163  info.energyFrac = simSDPs[e].energy / totalE;
164  info.energy = simSDPs[e].energy;
165  tSDPs.push_back(info);
166  }
167  }
168  catch (
169  cet::exception const&
170  e) { //This needs to go. Make it specific if there is a really an exception we would like to catch.
171  mf::LogWarning("PhotonBackTracker") << "Exception caught\n" << e;
172  }
173  return tSDPs;
174  }
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &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
const std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::OpFlashToOpHits_Ps ( art::Ptr< recob::OpFlash > &  flash_P) const
inherited

Definition at line 748 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::priv_OpFlashToOpHits.

Referenced by OpFlashToOpHits_Ps(), cheat::PhotonBackTracker::OpFlashToTrackIds(), and cheat::PhotonBackTracker::OpFlashToXYZ().

751  { //There is not "non-pointer" version of this because the art::Ptr is needed to look up the assn. One could loop the Ptrs and dereference them, but I will not encourage the behavior by building the tool to do it.
752  //
753  std::vector<art::Ptr<recob::OpHit>> const& hits_Ps = priv_OpFlashToOpHits.at(flash_P);
754  return hits_Ps;
755  }
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
const std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTrackerService::OpFlashToOpHits_Ps ( art::Ptr< recob::OpFlash > &  flash_P)

Definition at line 407 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToOpHits_Ps().

409  {
411  }
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
const bool cheat::PhotonBackTracker::OpFlashToOpHitsReady ( )
inherited

Definition at line 90 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::priv_OpFlashToOpHits.

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

Definition at line 400 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToTrackIds().

402  {
403  return PhotonBackTracker::OpFlashToTrackIds(flash_P);
404  }
const std::set< int > OpFlashToTrackIds(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< double > cheat::PhotonBackTracker::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P) const
inherited

Definition at line 758 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpFlashToOpHits_Ps(), and cheat::PhotonBackTracker::OpHitsToXYZ().

Referenced by OpFlashToXYZ().

759  {
760  const std::vector<art::Ptr<recob::OpHit>> opHits_Ps = this->OpFlashToOpHits_Ps(flash_P);
761  const std::vector<double> retVec = this->OpHitsToXYZ(opHits_Ps);
762  //const std::vector<double> retVec(0.0,3);
763  return retVec;
764  }
const std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< double > cheat::PhotonBackTrackerService::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P)

Definition at line 414 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpFlashToXYZ().

416  {
417  return PhotonBackTracker::OpFlashToXYZ(flash_P);
418  }
const std::vector< double > OpFlashToXYZ(art::Ptr< recob::OpFlash > &flash_P) const
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 122 of file PhotonBackTrackerService.h.

126  {
127  return PhotonBackTracker::OpHitLightCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
128  } //Exists only temporarily. Is deprecated.
const 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
const 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,
geo::View_t const &  view 
)

Definition at line 360 of file PhotonBackTrackerService.cc.

365  {
366  throw cet::exception("PhotonBackTrackerService")
367  << "This function is not supported. OpHits do not have type View.\n";
368  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const 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 371 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitCollectionEfficiency().

375  {
376  return PhotonBackTracker::OpHitCollectionEfficiency(tkIds, opHits_Ps, opHitsIn_Ps);
377  }
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
const double cheat::PhotonBackTrackerService::OpHitCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps 
)

Definition at line 344 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitCollectionPurity().

347  {
348  return PhotonBackTracker::OpHitCollectionPurity(tkIds, opHits_Ps);
349  }
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
const 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,
geo::View_t const &  view 
)

Definition at line 380 of file PhotonBackTrackerService.cc.

385  {
386  throw cet::exception("PhotonBackTrackerService")
387  << "This function is not supported. OpHits do not have type View.\n";
388  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const 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 391 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitLightCollectionEfficiency().

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

Definition at line 352 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitLightCollectionPurity().

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

Definition at line 458 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

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

460  {
461  std::vector<const sim::SDP*> sdps_Ps;
462  for (auto opHit_P : opHits_Ps) {
463  std::vector<const sim::SDP*> to_add_sdps_Ps = this->OpHitToSimSDPs_Ps(opHit_P);
464  sdps_Ps.insert(sdps_Ps.end(), to_add_sdps_Ps.begin(), to_add_sdps_Ps.end());
465  }
466  return sdps_Ps;
467  }
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const std::vector< double > cheat::PhotonBackTracker::OpHitsToXYZ ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps) const
inherited

Definition at line 470 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitsToSimSDPs_Ps(), and cheat::PhotonBackTracker::SimSDPsToXYZ().

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

472  {
473  const std::vector<const sim::SDP*> SDPs_Ps = OpHitsToSimSDPs_Ps(opHits_Ps);
474  return this->SimSDPsToXYZ(SDPs_Ps);
475  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
const 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
const std::unordered_set< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToEveSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 265 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps().

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

Definition at line 272 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps().

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

Definition at line 201 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackIds().

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

Definition at line 207 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackIds().

209  {
211  }
const 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 214 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

216  {
218  }
const 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 221 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToEveTrackSDPs().

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

Definition at line 235 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTracker::GetSetOfEveIds(), cheat::PhotonBackTracker::OpHitToEveTrackIds(), and OpHitToEveTrackSDPs().

237  {
238  return this->OpHitToEveTrackSDPs(*opHit_P);
239  }
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveTrackSDPs ( recob::OpHit const &  opHit) const
inherited

Definition at line 242 of file PhotonBackTracker.cc.

References sim::TrackSDP::energy, sim::TrackSDP::energyFrac, cheat::PhotonBackTracker::fPartInv, cheat::PhotonBackTracker::OpHitToTrackSDPs(), cheat::ParticleInventory::ParticleList(), and sim::TrackSDP::trackID.

244  {
245  std::vector<sim::TrackSDP> trackSDPs = this->OpHitToTrackSDPs(opHit);
246 
247  // make a map of evd ID values and fraction of energy represented by
248  // // that eve id in this opHit
249  std::map<int, float> eveIDtoEfrac;
250 
251  double totalE = 0.;
252  for (size_t t = 0; t < trackSDPs.size(); ++t) {
253  eveIDtoEfrac[(fPartInv->ParticleList()).EveId(trackSDPs[t].trackID)] += trackSDPs[t].energy;
254  totalE += trackSDPs[t].energy;
255  }
256 
257  // now fill the eveSDPs vector from the map
258  std::vector<sim::TrackSDP> eveSDPs;
259  eveSDPs.reserve(eveIDtoEfrac.size());
260  for (auto itr = eveIDtoEfrac.begin(); itr != eveIDtoEfrac.end(); itr++) {
261  sim::TrackSDP temp;
262  temp.trackID = (*itr).first;
263  temp.energyFrac = (*itr).second / totalE;
264  temp.energy = (*itr).second;
265  eveSDPs.push_back(std::move(temp));
266  }
267  return eveSDPs;
268  }
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(), geo::GeometryCore::OpDetFromOpChannel(), 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  }
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
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.PhotonBackTrackerService.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.PhotonBackTracker.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.
const std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::OpHitToSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 244 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

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

Definition at line 251 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

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

Definition at line 323 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::fDelay, cheat::PhotonBackTracker::fGeom, cheat::PhotonBackTracker::FindOpDetBTR(), recob::OpHit::OpChannel(), geo::GeometryCore::OpDetFromOpChannel(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

Referenced by cheat::PhotonBackTracker::OpHitsToSimSDPs_Ps(), OpHitToSimSDPs_Ps(), cheat::PhotonBackTracker::OpHitToSimSDPs_Ps(), and cheat::PhotonBackTracker::OpHitToXYZ().

325  {
326  std::vector<const sim::SDP*> retVec;
327  double fPeakTime = opHit.PeakTime();
328  double fWidth = opHit.Width();
330  ((fPeakTime - fWidth) * 1000.0) - fDelay;
331  sim::OpDetBacktrackerRecord::timePDclock_t end_time = ((fPeakTime + fWidth) * 1000.0) - fDelay;
332  if (start_time > end_time) { throw; }
333 
334  //BUG!!!fGeom->OpDetFromOpChannel(channel)
335  const std::vector<std::pair<double, std::vector<sim::SDP>>>& timeSDPMap =
336  (this->FindOpDetBTR(fGeom->OpDetFromOpChannel(opHit.OpChannel())))
337  ->timePDclockSDPsMap(); //Not guranteed to be sorted.
338  //const std::vector<std::pair<double, std::vector<sim::SDP>> >& timeSDPMap = (this->FindOpDetBTR(opHit.OpChannel()))->timePDclockSDPsMap(); //Not guranteed to be sorted.
339 
340  std::vector<const std::pair<double, std::vector<sim::SDP>>*> timePDclockSDPMap_SortedPointers;
341  for (auto& pair : timeSDPMap) {
342  timePDclockSDPMap_SortedPointers.push_back(&pair);
343  }
344  auto pairSort = [](auto& a, auto& b) { return a->first < b->first; };
345  if (!std::is_sorted(timePDclockSDPMap_SortedPointers.begin(),
346  timePDclockSDPMap_SortedPointers.end(),
347  pairSort)) {
348  std::sort(
349  timePDclockSDPMap_SortedPointers.begin(), timePDclockSDPMap_SortedPointers.end(), pairSort);
350  }
351 
352  //This section is a hack to make comparisons work right.
353  std::vector<sim::SDP> dummyVec;
354  std::pair<double, std::vector<sim::SDP>> start_timePair = std::make_pair(start_time, dummyVec);
355  std::pair<double, std::vector<sim::SDP>> end_timePair = std::make_pair(end_time, dummyVec);
356  auto start_timePair_P = &start_timePair;
357  auto end_timePair_P = &end_timePair;
358  //First interesting iterator.
359  auto mapFirst = std::lower_bound(timePDclockSDPMap_SortedPointers.begin(),
360  timePDclockSDPMap_SortedPointers.end(),
361  start_timePair_P,
362  pairSort);
363  //Last interesting iterator.
364  auto mapLast =
365  std::upper_bound(mapFirst, timePDclockSDPMap_SortedPointers.end(), end_timePair_P, pairSort);
366 
367  for (auto& mapitr = mapFirst; mapitr != mapLast; ++mapitr)
368  for (auto& sdp : (*mapitr)->second)
369  retVec.push_back(&sdp);
370 
371  return retVec;
372 
373  //sdps = FindOpDetBTR( geom->OpDetFromOpChannel(opHit. OpChannel()) )->TrackIDsAndEnergies(start_time, end_time);
374  // return (this->FindOpDetBTR( fGeom->OpDetFromOpChannel(opHit.OpChannel()) ))->TrackIDsAndEnergies(start_time, end_time);
375  }
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
const geo::GeometryCore * fGeom
double timePDclock_t
Type for iTimePDclock tick used in the interface.
const std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitToSimSDPs_Ps ( art::Ptr< recob::OpHit > const &  opHit_P) const
inherited

Definition at line 378 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToSimSDPs_Ps().

380  {
381  return this->OpHitToSimSDPs_Ps(*opHit_P);
382  }
const 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
const std::vector< int > cheat::PhotonBackTrackerService::OpHitToTrackIds ( recob::OpHit const &  opHit)

Definition at line 187 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackIds().

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

Definition at line 193 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackIds().

195  {
196  return PhotonBackTracker::OpHitToTrackIds(opHit_P);
197  }
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
const std::vector< int > cheat::PhotonBackTracker::OpHitToTrackIds ( recob::OpHit const &  opHit) const
inherited

Definition at line 201 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

Referenced by cheat::PhotonBackTracker::OpFlashToTrackIds(), OpHitToTrackIds(), and cheat::PhotonBackTracker::OpHitToTrackIds().

202  {
203  std::vector<int> retVec;
204  for (auto const trackSDP : this->OpHitToTrackSDPs(opHit)) {
205  retVec.push_back(trackSDP.trackID);
206  }
207  return retVec;
208  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
const std::vector< int > cheat::PhotonBackTracker::OpHitToTrackIds ( art::Ptr< recob::OpHit > const &  opHit) const
inherited

Definition at line 211 of file PhotonBackTracker.cc.

References cheat::PhotonBackTracker::OpHitToTrackIds().

213  {
214  return this->OpHitToTrackIds(*opHit);
215  }
const 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 174 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

176  {
177  return PhotonBackTracker::OpHitToTrackSDPs(opHit_P);
178  }
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 181 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToTrackSDPs().

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

Definition at line 177 of file PhotonBackTracker.cc.

References util::end(), cheat::PhotonBackTracker::fDelay, cheat::PhotonBackTracker::fGeom, recob::OpHit::OpChannel(), geo::GeometryCore::OpDetFromOpChannel(), cheat::PhotonBackTracker::OpDetToTrackSDPs(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

179  {
180  auto OpDetNum = fGeom->OpDetFromOpChannel(opHit_P->OpChannel());
181  const double pTime = opHit_P->PeakTime();
182  const double pWidth = opHit_P->Width();
183  const double start = (pTime - pWidth) * 1000 - fDelay;
184  const double end = (pTime + pWidth) * 1000 - fDelay;
185  return this->OpDetToTrackSDPs(OpDetNum, start, end);
186  }
double PeakTime() const
Definition: OpHit.h:94
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
double Width() const
Definition: OpHit.h:110
const geo::GeometryCore * fGeom
int OpChannel() const
Definition: OpHit.h:86
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( recob::OpHit const &  opHit) const
inherited

Definition at line 189 of file PhotonBackTracker.cc.

References util::end(), cheat::PhotonBackTracker::fDelay, cheat::PhotonBackTracker::fGeom, recob::OpHit::OpChannel(), geo::GeometryCore::OpDetFromOpChannel(), cheat::PhotonBackTracker::OpDetToTrackSDPs(), recob::OpHit::PeakTime(), and recob::OpHit::Width().

191  {
192  auto OpDetNum = fGeom->OpDetFromOpChannel(opHit.OpChannel());
193  const double pTime = opHit.PeakTime();
194  const double pWidth = opHit.Width();
195  const double start = (pTime - pWidth) * 1000 - fDelay;
196  const double end = (pTime + pWidth) * 1000 - fDelay;
197  return this->OpDetToTrackSDPs(OpDetNum, start, end);
198  }
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
const geo::GeometryCore * fGeom
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const std::vector< double > cheat::PhotonBackTrackerService::OpHitToXYZ ( recob::OpHit const &  opHit)

Definition at line 293 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToXYZ().

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

Definition at line 299 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::OpHitToXYZ().

301  {
302  return PhotonBackTracker::OpHitToXYZ(opHit_P);
303  }
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.PhotonBackTrackerService.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.PhotonBackTracker.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 72 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::CanRun().

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

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

Definition at line 142 of file PhotonBackTrackerService.h.

Referenced by priv_PrepOpDetBTRs().

bool cheat::PhotonBackTrackerService::priv_OpFlashToOpHitsReady ( )
inlineprivate

Definition at line 143 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

Definition at line 63 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::ClearEvent(), priv_CanRun(), priv_PrepOpDetBTRs(), and priv_PrepOpFlashToOpHits().

Referenced by PhotonBackTrackerService(), and Rebuild().

64  {
66  if (!this->priv_CanRun(evt)) { return; }
67  this->priv_PrepOpDetBTRs(evt);
69  }
bool priv_CanRun(art::Event const &evt)
void priv_PrepOpDetBTRs(art::Event const &evt)
TCEvent evt
Definition: DataStructs.cxx:8
void priv_PrepOpFlashToOpHits(art::Event const &evt)
void cheat::PhotonBackTrackerService::priv_PrepFailed ( )
private

Definition at line 78 of file PhotonBackTrackerService.cc.

Referenced by priv_PrepOpDetBTRs(), and priv_PrepOpFlashToOpHits().

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

Definition at line 87 of file PhotonBackTrackerService.cc.

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

Referenced by priv_PrepEvent().

88  {
89  if (!this->priv_CanRun(evt)) { this->priv_PrepFailed(); }
90  if (this->priv_OpDetBTRsReady()) { return; }
91  try {
93  }
94  //catch(...){ mf::LogWarning("PhotonBackTrackerService")//This needs to go. Catch all should not be used.
95  catch (
96  cet::
97  exception const&) { //This needs to go. Make it specific if there is a really an exception we would like to catch.
98  mf::LogWarning("PhotonBackTrackerService")
99  << "Rebuild failed to get the OpDetBTRs. This is expected when "
100  << "running on a generation or simulation step.";
101  }
102  }
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 104 of file PhotonBackTrackerService.cc.

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

Referenced by priv_PrepEvent().

105  {
106  if (!this->priv_CanRun(evt)) { this->priv_PrepFailed(); }
107  if (this->priv_OpFlashToOpHitsReady()) { return; }
108  try {
110  }
111  //catch(...){ //This needs to go. Catch all should not be used.
112  catch (
113  cet::
114  exception const&) { //This needs to go. Make it specific if there is a really an exception we would like to catch.
115  mf::LogWarning("PhotonBackTrackerService")
116  << "Rebuild failed to get the OpFlashToOpHits. This is expected when "
117  << "running on a generation or simulation stage.";
118  }
119  }
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 48 of file PhotonBackTrackerService.h.

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

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

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

Definition at line 57 of file PhotonBackTrackerService.cc.

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

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

58  {
60  }
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
const std::vector< double > cheat::PhotonBackTrackerService::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps) const

Definition at line 279 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::SimSDPsToXYZ().

281  {
282  return PhotonBackTracker::SimSDPsToXYZ(sdps);
283  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
const std::vector< double > cheat::PhotonBackTrackerService::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps)

Definition at line 286 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::SimSDPsToXYZ().

288  {
289  return PhotonBackTracker::SimSDPsToXYZ(sdps_Ps);
290  }
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::OpHitsToXYZ(), 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
const std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps) const
inherited

Definition at line 414 of file PhotonBackTracker.cc.

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

416  {
417  std::vector<double> xyz(3, -999.);
418  double x = 0.;
419  double y = 0.;
420  double z = 0.;
421  double w = 0.;
422  // loop over photons.
423  for (const sim::SDP* sdp_P : sdps_Ps) {
424  auto& sdp = *sdp_P;
425  double weight = sdp.numPhotons;
426  w += weight;
427  x += weight * sdp.x;
428  y += weight * sdp.y;
429  z += weight * sdp.z;
430  } // end loop over sim::SDPs
431  //If the sum of the weights is still zero, then fail to return a value.
432  //A hit with no contributing photons does't make sense.
433  if (w < 1.e-5)
434  throw cet::exception("PhotonBackTracker")
435  << "No sim::SDPs providing non-zero number of photons"
436  << " can't determine originating location from truth\n";
437  xyz[0] = x / w;
438  xyz[1] = y / w;
439  xyz[2] = z / w;
440  return xyz;
441  }
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
const 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 237 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdsToOpHits_Ps().

239  {
240  return PhotonBackTracker::TrackIdsToOpHits_Ps(tkIds, hitsIn);
241  }
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 art::Ptr<simb::MCTruth>& cheat::PhotonBackTracker::TrackIDToMCTruth ( int const &  id) const
inherited
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 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.
const simb::MCParticle* cheat::PhotonBackTracker::TrackIDToMotherParticle ( int const &  id) const
inherited
const std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTrackerService::TrackIdToOpHits_Ps ( int const &  tkId,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
)

Definition at line 228 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdToOpHits_Ps().

231  {
232  return PhotonBackTracker::TrackIdToOpHits_Ps(tkId, hitsIn);
233  }
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
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
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
const std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::TrackIdToSimSDPs_Ps ( int const &  id)

Definition at line 145 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps().

146  {
148  }
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
const std::vector< const sim::SDP * > cheat::PhotonBackTrackerService::TrackIdToSimSDPs_Ps ( int const &  id,
geo::View_t const &  view 
)

Definition at line 151 of file PhotonBackTrackerService.cc.

References cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps().

154  {
156  }
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)

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