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

#include "old.PhotonBackTracker.h"

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

Classes

struct  fhiclConfig
 

Public Member Functions

 PhotonBackTracker (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~PhotonBackTracker ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void Rebuild (const art::Event &evt)
 
const sim::ParticleListParticleList () const
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
const simb::MCParticleTrackIDToParticle (int const &id) const
 
const simb::MCParticleTrackIDToMotherParticle (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 > & ParticleToMCTruth (const simb::MCParticle *p) const
 
std::vector< const simb::MCParticle * > MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const
 
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector () const
 
DEPRECATED std::vector< sim::TrackSDPOpHitToTrackID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &hit)
 
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::TrackSDPOpHitToEveID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps)
 
std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &hit)
 
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 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 > GetSetOfTrackIDs ()
 
std::set< int > GetSetOfEveIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
std::set< int > GetSetOfTrackIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
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)
 
 PhotonBackTracker (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~PhotonBackTracker ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void Rebuild (const art::Event &evt)
 
const sim::ParticleListParticleList () const
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
const simb::MCParticleTrackIDToParticle (int const &id) const
 
const simb::MCParticleTrackIDToMotherParticle (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 > & ParticleToMCTruth (const simb::MCParticle *p) const
 
std::vector< const simb::MCParticle * > MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const
 
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector () const
 
DEPRECATED std::vector< sim::TrackSDPOpHitToTrackID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &hit)
 
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::TrackSDPOpHitToEveID (art::Ptr< recob::OpHit > const &hit)
 
std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps)
 
std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &hit)
 
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 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 > GetSetOfTrackIDs ()
 
std::set< int > GetSetOfEveIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
std::set< int > GetSetOfTrackIDs (std::vector< art::Ptr< recob::OpHit >> const &hits)
 
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)
 
 PhotonBackTracker (fhiclConfig const &config, const cheat::ParticleInventory *partInv, geo::WireReadoutGeom const *wireReadoutGeom)
 
 PhotonBackTracker (fhicl::ParameterSet const &pSet, const cheat::ParticleInventory *partInv, geo::WireReadoutGeom const *wireReadoutGeom)
 
 PhotonBackTracker (PhotonBackTracker const &)=delete
 
template<typename Evt >
void PrepEvent (Evt const &evt)
 
template<typename Evt >
bool CanRun (Evt const &evt)
 
template<typename Evt >
void PrepOpDetBTRs (Evt const &evt)
 
template<typename Evt >
void PrepOpFlashToOpHits (Evt const &evt)
 
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps (art::Ptr< recob::OpFlash > &flash_P) const
 
std::vector< double > OpFlashToXYZ (art::Ptr< recob::OpFlash > &flash_P) const
 
std::set< int > OpFlashToTrackIds (art::Ptr< recob::OpFlash > &flash_P) const
 
double GetDelay () const
 
void ClearEvent ()
 
bool BTRsReady () const
 
bool OpFlashToOpHitsReady () const
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs () const
 
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int id) const
 
art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int opDetNum) const
 
std::vector< sim::TrackSDPOpDetToTrackSDPs (int OpDetNum, double opHit_start_time, double opHit_end_time) const
 
std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
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) const
 
std::vector< int > OpHitToEveTrackIds (recob::OpHit const &opHit)
 
std::vector< int > OpHitToEveTrackIds (art::Ptr< recob::OpHit > const &opHit_P)
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
std::vector< sim::TrackSDPOpHitToEveTrackSDPs (recob::OpHit const &opHit) const
 
std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps (int tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
 
std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps (std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn) const
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (recob::OpHit const &opHit) const
 
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (art::Ptr< recob::OpHit > const &opHit_P) const
 
std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps) const &
 
std::vector< double > SimSDPsToXYZ (std::vector< const sim::SDP * > const &sdps_Ps) const &
 
std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &opHit)
 
std::vector< double > OpHitToXYZ (recob::OpHit const &opHit)
 
std::vector< double > OpHitsToXYZ (std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
 
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (recob::OpHit const &opHit)
 
std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (art::Ptr< recob::OpHit > &opHit_P)
 
std::set< int > GetSetOfEveIds () const
 
std::set< int > GetSetOfTrackIds () const
 
std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) const
 
std::set< int > GetSetOfEveIds (std::vector< recob::OpHit > const &opHits) const
 
std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit >> const &opHits) 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)
 
double OpHitLightCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits)
 
double OpHitCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn)
 
double OpHitLightCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &opHits, std::vector< art::Ptr< recob::OpHit >> const &opHitsIn)
 
void OpHitToSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (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 (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 
void OpHitToSDPs (recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
 
DEPRECATED void OpHitToSimSDPs (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 (art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
 

Private Member Functions

const art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBacktrackerRecord (int channel) const
 
const void shouldThisFail () const
 
const art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBacktrackerRecord (int channel) const
 
const void shouldThisFail () const
 

Private Attributes

geo::GeometryCore const * geom = lar::providerFrom<geo::Geometry>()
 
bool have_complained
 
sim::ParticleList fParticleList
 ParticleList to map track ID to sim::Particle. More...
 
sim::LArVoxelList fVoxelList
 
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
 all the MCTruths for the event More...
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
 all the OpDetBacktrackerRecords for the event More...
 
std::map< int, int > fTrackIDToMCTruthIndex
 map of track ids to MCTruthList entry More...
 
std::string fG4ModuleLabel
 label for geant4 module More...
 
double fMinOpHitEnergyFraction
 minimum fraction of energy a track id has to More...
 
double fDelay
 
const cheat::ParticleInventoryfPartInv
 
const geo::WireReadoutGeomfWireReadoutGeom
 
const double fDelay
 
const art::InputTag fG4ModuleLabel
 
const std::vector< art::InputTagfG4ModuleLabels
 
const art::InputTag fOpHitLabel
 
const art::InputTag fOpFlashLabel
 
const double fMinOpHitEnergyFraction
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
 
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
 

Detailed Description

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

Constructor & Destructor Documentation

cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)
cheat::PhotonBackTracker::~PhotonBackTracker ( )
cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)
cheat::PhotonBackTracker::~PhotonBackTracker ( )
cheat::PhotonBackTracker::PhotonBackTracker ( fhiclConfig const &  config,
const cheat::ParticleInventory partInv,
geo::WireReadoutGeom const *  wireReadoutGeom 
)
cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pSet,
const cheat::ParticleInventory partInv,
geo::WireReadoutGeom const *  wireReadoutGeom 
)
cheat::PhotonBackTracker::PhotonBackTracker ( PhotonBackTracker const &  )
delete

Member Function Documentation

bool cheat::PhotonBackTracker::BTRsReady ( ) const

Definition at line 74 of file PhotonBackTracker.cc.

75  {
76  return !priv_OpDetBTRs.empty();
77  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
template<typename Evt >
bool cheat::PhotonBackTracker::CanRun ( Evt const &  evt)
void cheat::PhotonBackTracker::ChannelToTrackSDPs ( std::vector< sim::TrackSDP > &  trackSDPs,
int  channel,
const double  hit_start_time,
const double  hit_end_time 
)
void cheat::PhotonBackTracker::ChannelToTrackSDPs ( std::vector< sim::TrackSDP > &  trackSDPs,
int  channel,
const double  hit_start_time,
const double  hit_end_time 
)

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

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

Referenced by GetSetOfTrackIDs(), OpDetBacktrackerRecords(), OpHitToTrackSDPs(), and TrackIDsToOpHits().

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

Definition at line 67 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::priv_PrepEvent().

68  {
69  priv_OpDetBTRs.clear();
70  priv_OpFlashToOpHits.clear();
71  }
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
const art::Ptr<sim::OpDetBacktrackerRecord> cheat::PhotonBackTracker::FindOpDetBacktrackerRecord ( int  channel) const
private
const art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTracker::FindOpDetBacktrackerRecord ( int  channel) const
private

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

References cOpDetBacktrackerRecords, sc, and shouldThisFail().

Referenced by ChannelToTrackSDPs(), OpDetBacktrackerRecords(), and OpHitToSDPs().

641  {
642  shouldThisFail();
644 
645  for (size_t sc = 0; sc < cOpDetBacktrackerRecords.size(); ++sc) {
646  //This could become a bug. What if it occurs twice (shouldn't happen in correct recorts, but still, no error handeling included for the situation
647  if (cOpDetBacktrackerRecords[sc]->OpDetNum() == opDetNum)
648  opDet = cOpDetBacktrackerRecords[sc];
649  }
650 
651  if (!opDet) {
652  throw cet::exception("PhotonBackTracker2") << "No sim::OpDetBacktrackerRecord corresponding "
653  << "to opDetNum: " << opDetNum << "\n";
654  }
655 
656  return opDet;
657  }
Float_t sc
Definition: plot.C:23
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTracker::FindOpDetBTR ( int  opDetNum) const

Definition at line 108 of file PhotonBackTracker.cc.

References sc.

Referenced by cheat::PhotonBackTrackerService::FindOpDetBTR().

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

Definition at line 61 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::GetDelay().

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

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

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

Referenced by 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 ( )
std::set<int> cheat::PhotonBackTracker::GetSetOfEveIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIDs ( std::vector< art::Ptr< recob::OpHit >> const &  hits)

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

References OpHitToEveID(), and 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 ( ) const

Definition at line 468 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::GetSetOfEveIds().

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

Definition at line 480 of file PhotonBackTracker.cc.

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

Definition at line 494 of file PhotonBackTracker.cc.

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

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

References fParticleList, and shouldThisFail().

Referenced by OpHitToSimSDPs(), and 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 ( std::vector< art::Ptr< recob::OpHit >> const &  hits)

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

References ChannelToTrackSDPs(), util::end(), fDelay, and 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)
std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( ) const

Definition at line 474 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::GetSetOfTrackIds().

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

Definition at line 507 of file PhotonBackTracker.cc.

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

Definition at line 520 of file PhotonBackTracker.cc.

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

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

References fParticleList, shouldThisFail(), and TrackIDToMCTruth().

Referenced by 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
const std::vector<art::Ptr<simb::MCTruth> >& cheat::PhotonBackTracker::MCTruthVector ( ) const
inline

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

References 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
inline

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

References 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
inline

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

References ChannelToTrackSDPs(), cOpDetBacktrackerRecords, DECLARE_ART_SERVICE, fDelay, fG4ModuleLabel, FindOpDetBacktrackerRecord(), fMCTruthList, fMinOpHitEnergyFraction, fParticleList, fTrackIDToMCTruthIndex, fVoxelList, geom, have_complained, and shouldThisFail().

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

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

References ChannelToTrackSDPs(), and cOpDetBacktrackerRecords.

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

Definition at line 86 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpDetBTRs().

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

Definition at line 124 of file PhotonBackTracker.cc.

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

Referenced by cheat::PhotonBackTrackerService::OpDetToTrackSDPs().

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

Definition at line 674 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpFlashToOpHits_Ps().

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

Definition at line 80 of file PhotonBackTracker.cc.

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

Definition at line 690 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpFlashToTrackIds().

691  {
692  std::vector<art::Ptr<recob::OpHit>> opHits_Ps = OpFlashToOpHits_Ps(flash_P);
693  std::set<int> ids;
694  for (auto& opHit_P : opHits_Ps) {
695  for (const int& id : OpHitToTrackIds(opHit_P)) {
696  ids.insert(id);
697  } // end for ids
698  } // end for opHits
699  return ids;
700  }
std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
std::vector< double > cheat::PhotonBackTracker::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P) const

Definition at line 684 of file PhotonBackTracker.cc.

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

685  {
686  return OpHitsToXYZ(OpFlashToOpHits_Ps(flash_P));
687  }
std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit >> const &opHits_Ps) const
std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
double cheat::PhotonBackTracker::OpHitChargeCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits 
)

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

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

Referenced by 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 
)
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 
)
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 
)

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 
)

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

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

Referenced by 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 
)
double cheat::PhotonBackTracker::OpHitCollectionEfficiency ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits,
std::vector< art::Ptr< recob::OpHit >> const &  allhits 
)

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

References e, fMinOpHitEnergyFraction, OpHitToTrackSDPs(), and shouldThisFail().

Referenced by cheat::PhotonBackTrackerService::OpHitCollectionEfficiency(), and 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 
)
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 
)

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

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

Definition at line 586 of file PhotonBackTracker.cc.

References e.

590  {
591  float desired = 0.;
592  float total = 0.;
593  for (size_t h = 0; h < opHits.size(); ++h) {
594  art::Ptr<recob::OpHit> opHit = opHits[h];
595  std::vector<sim::TrackSDP> opHitTrackSDPs = OpHitToTrackSDPs(opHit);
596  // also don't double count if this opHit has more than one of the desired track IDs
597  // associated with it
598  for (size_t e = 0; e < opHitTrackSDPs.size(); ++e) {
599  if (tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end() &&
600  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction) {
601  desired += 1.;
602  break;
603  }
604  }
605  } // end loop over opHits
606  // now figure out how many opHits in the whole collection are associated with this id
607  for (size_t h = 0; h < opHitsIn.size(); ++h) {
608  art::Ptr<recob::OpHit> opHit = opHitsIn[h];
609  std::vector<sim::TrackSDP> opHitTrackSDPs = OpHitToTrackSDPs(opHit);
610  for (size_t e = 0; e < opHitTrackSDPs.size(); ++e) {
611  // don't worry about opHits where the energy fraction for the chosen trackID is <
612  // 0.1; also don't double count if this opHit has more than one of the desired
613  // track IDs associated with it
614  if (tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end() &&
615  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction) {
616  total += 1.;
617  break;
618  }
619  }
620  } // end loop over all opHits
621  double efficiency = 0.;
622  if (total > 0.) efficiency = desired / total;
623  return efficiency;
624  }
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::OpHitCollectionPurity ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit >> const &  hits 
)

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

References e, OpHitToTrackSDPs(), and shouldThisFail().

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

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

Definition at line 532 of file PhotonBackTracker.cc.

References e.

534  {
535  // get the list of EveIDs that correspond to the opHits in this collection if the
536  // EveID shows up in the input list of tkIds, then it counts
537  float total = 1. * opHits.size();
538  float desired = 0.;
539  for (size_t h = 0; h < opHits.size(); ++h) {
540  art::Ptr<recob::OpHit> opHit = opHits[h];
541  std::vector<sim::TrackSDP> opHitTrackSDPs = OpHitToTrackSDPs(opHit);
542  // don't double count if this opHit has more than one of the desired track IDs
543  // associated with it
544  for (size_t e = 0; e < opHitTrackSDPs.size(); ++e) {
545  if (tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end()) {
546  desired += 1.;
547  break;
548  }
549  }
550  } // end loop over opHits
551  double purity = 0.;
552  if (total > 0) purity = desired / total;
553  return purity;
554  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
Float_t e
Definition: plot.C:35
double cheat::PhotonBackTracker::OpHitLightCollectionEfficiency ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits,
std::vector< art::Ptr< recob::OpHit >> const &  opHitsIn 
)

Definition at line 627 of file PhotonBackTracker.cc.

References recob::OpHit::Area(), and e.

Referenced by cheat::PhotonBackTrackerService::OpHitLightCollectionEfficiency().

631  {
632  float desired = 0.;
633  float total = 0.;
634 
635  // don't have to check the view in the opHits collection because those are assumed to
636  // be from the object we are testing and will the correct view by definition then.
637  for (size_t h = 0; h < opHits.size(); ++h) {
638 
639  art::Ptr<recob::OpHit> opHit = opHits[h];
640  std::vector<sim::TrackSDP> opHitTrackIDs = OpHitToTrackSDPs(opHit);
641 
642  // don't worry about opHits where the energy fraction for the chosen trackID is <
643  // 0.1; also don't double count if this opHit has more than one of the desired track
644  // IDs associated with it
645  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
646  if (tkIds.find(opHitTrackIDs[e].trackID) != tkIds.end() &&
647  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction) {
648  desired += opHit->Area();
649  break;
650  }
651  }
652  } // end loop over opHits
653  for (size_t h = 0; h < opHitsIn.size(); ++h) {
654  art::Ptr<recob::OpHit> opHit = opHitsIn[h];
655  // check that we are looking at the appropriate view here in the case of 3D objects
656  // we take all opHits
657  std::vector<sim::TrackSDP> opHitTrackIDs = OpHitToTrackSDPs(opHit);
658  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
659  // don't worry about opHits where the energy fraction for the chosen trackID is <
660  // 0.1; also don't double count if this opHit has more than one of the desired
661  // track IDs associated with it
662  if (tkIds.find(opHitTrackIDs[e].trackID) != tkIds.end() &&
663  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction) {
664  total += opHit->Area();
665  break;
666  }
667  }
668  } // end loop over all opHits
669  double efficiency = 0.;
670  if (total > 0.) efficiency = desired / total;
671  return efficiency;
672  }
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::OpHitLightCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  opHits 
)

Definition at line 557 of file PhotonBackTracker.cc.

References recob::OpHit::Area(), and e.

Referenced by cheat::PhotonBackTrackerService::OpHitLightCollectionPurity().

560  {
561  // get the list of EveIDs that correspond to the opHits in this collection if the
562  // EveID shows up in the input list of tkIds, then it counts
563  float total = 0;
564  float desired = 0.;
565  // don't have to check the view in the opHits collection because those are assumed to
566  // be from the object we are testing and will the correct view by definition then.
567  for (size_t h = 0; h < opHits.size(); ++h) {
568  art::Ptr<recob::OpHit> opHit = opHits[h];
569  std::vector<sim::TrackSDP> opHitTrackIDs = OpHitToTrackSDPs(opHit);
570  total += opHit->Area(); // sum up the charge in the cluster
571  // don't double count if this opHit has more than one of the desired track IDs
572  // associated with it
573  for (size_t e = 0; e < opHitTrackIDs.size(); ++e) {
574  if (tkIds.find(opHitTrackIDs[e].trackID) != tkIds.end()) {
575  desired += opHit->Area();
576  break;
577  }
578  }
579  } // end loop over opHits
580  double purity = 0.;
581  if (total > 0) purity = desired / total;
582  return purity;
583  }
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
std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitsToSimSDPs_Ps ( std::vector< art::Ptr< recob::OpHit >> const &  opHits_Ps) const

Definition at line 418 of file PhotonBackTracker.cc.

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

Definition at line 430 of file PhotonBackTracker.cc.

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

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

References OpHitToEveSDPs().

Referenced by GetSetOfEveIDs(), and 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)
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveSDPs ( art::Ptr< recob::OpHit > const &  hit)

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

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

Referenced by OpHitToEveID(), and 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)
std::unordered_set< const sim::SDP * > cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 438 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpHitToEveSimSDPs_Ps().

440  {
441  const std::vector<int> ids = OpHitToEveTrackIds(opHit_P);
442  std::unordered_set<const sim::SDP*> sdps;
443  for (auto const& id : ids) {
444  std::vector<const sim::SDP*> tmp_sdps = TrackIdToSimSDPs_Ps(id);
445  for (const sim::SDP* tmp_sdp : tmp_sdps) {
446  sdps.insert(tmp_sdp); //emplace not needed here.
447  }
448  }
449  return sdps;
450  }
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int id) const
std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
std::unordered_set< const sim::SDP * > cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps ( art::Ptr< recob::OpHit > &  opHit_P)

Definition at line 453 of file PhotonBackTracker.cc.

455  {
456  const std::vector<int> ids = OpHitToEveTrackIds(opHit);
457  std::unordered_set<const sim::SDP*> sdps;
458  for (auto const& id : ids) {
459  std::vector<const sim::SDP*> tmp_sdps = TrackIdToSimSDPs_Ps(id);
460  for (const sim::SDP* tmp_sdp : tmp_sdps) {
461  sdps.insert(tmp_sdp); //emplace not needed here.
462  }
463  }
464  return sdps;
465  }
std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int id) const
std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
std::vector< int > cheat::PhotonBackTracker::OpHitToEveTrackIds ( recob::OpHit const &  opHit)

Definition at line 194 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpHitToEveTrackIds().

195  {
196  std::vector<int> retVec;
197  for (auto const trackSDP : OpHitToEveTrackSDPs(opHit)) {
198  retVec.push_back(trackSDP.trackID);
199  }
200  return retVec;
201  }
std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
std::vector< int > cheat::PhotonBackTracker::OpHitToEveTrackIds ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 204 of file PhotonBackTracker.cc.

205  {
206  return OpHitToEveTrackIds(*opHit_P);
207  }
std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const

Definition at line 210 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpHitToEveTrackSDPs().

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

Definition at line 217 of file PhotonBackTracker.cc.

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

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

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

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

Referenced by OpHitToSDPs(), OpHitToSimSDPs(), OpHitToTrackID(), and OpHitToXYZ().

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

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

References 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
inline

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

References 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
inline

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

References 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
inline

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

References 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 ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inline
DEPRECATED void cheat::PhotonBackTracker::OpHitToSimSDPs ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inline
std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitToSimSDPs_Ps ( recob::OpHit const &  opHit) const

Definition at line 293 of file PhotonBackTracker.cc.

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

Referenced by cheat::PhotonBackTrackerService::OpHitToSimSDPs_Ps().

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

Definition at line 341 of file PhotonBackTracker.cc.

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

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

References OpHitToEveID(), OpHitToEveSDPs(), OpHitToSDPs(), OpHitToTrackSDPs(), TrackIDsToOpHits(), and lar::dump::vector().

82  {
83  return OpHitToTrackSDPs(hit);
84  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
DEPRECATED std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToTrackID ( art::Ptr< recob::OpHit > const &  hit)
inline

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

References OpHitToEveID(), OpHitToEveSDPs(), OpHitToSDPs(), OpHitToTrackSDPs(), TrackIDsToOpHits(), and lar::dump::vector().

82  {
83  return OpHitToTrackSDPs(hit);
84  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< int > cheat::PhotonBackTracker::OpHitToTrackIds ( recob::OpHit const &  opHit) const

Definition at line 178 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::OpHitToTrackIds().

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

Definition at line 188 of file PhotonBackTracker.cc.

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

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

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

Referenced by OpHitChargeCollectionEfficiency(), OpHitChargeCollectionPurity(), OpHitCollectionEfficiency(), OpHitCollectionPurity(), OpHitToEveSDPs(), OpHitToTrackID(), and cheat::PhotonBackTrackerService::OpHitToTrackSDPs().

273  {
274  shouldThisFail();
275  std::vector<sim::TrackSDP> trackSDPs;
276  const double pTime = opHit->PeakTime();
277  const double pWidth = opHit->Width();
278  const double start = (pTime - pWidth) * 1000 - fDelay;
279  const double end = (pTime + pWidth) * 1000 - fDelay;
280 
281  this->ChannelToTrackSDPs(trackSDPs, opHit->OpChannel(), start, end);
282 
283  return trackSDPs;
284  }
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::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToTrackSDPs ( art::Ptr< recob::OpHit > const &  hit)
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const

Definition at line 155 of file PhotonBackTracker.cc.

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

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

Definition at line 167 of file PhotonBackTracker.cc.

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

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

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

References DEFINE_ART_SERVICE, OpHitToSDPs(), shouldThisFail(), and SimSDPsToXYZ().

Referenced by OpHitToSimSDPs(), cheat::PhotonBackTrackerService::OpHitToXYZ(), and OpHitToXYZ().

770  {
771  shouldThisFail();
772  std::vector<sim::SDP> sdps;
773  OpHitToSDPs(opHit, sdps);
774  return SimSDPsToXYZ(sdps);
775  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
std::vector<double> cheat::PhotonBackTracker::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  hit)
std::vector<double> cheat::PhotonBackTracker::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  opHit)
std::vector< double > cheat::PhotonBackTracker::OpHitToXYZ ( recob::OpHit const &  opHit)

Definition at line 406 of file PhotonBackTracker.cc.

References OpHitToXYZ().

407  {
408  return SimSDPsToXYZ(OpHitToSimSDPs_Ps(opHit));
409  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const sim::ParticleList& cheat::PhotonBackTracker::ParticleList ( ) const
inline

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

References fParticleList.

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

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

References 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

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

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

Referenced by 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
template<typename Evt >
void cheat::PhotonBackTracker::PrepEvent ( Evt const &  evt)
template<typename Evt >
void cheat::PhotonBackTracker::PrepOpDetBTRs ( Evt const &  evt)
template<typename Evt >
void cheat::PhotonBackTracker::PrepOpFlashToOpHits ( Evt const &  evt)
void cheat::PhotonBackTracker::Rebuild ( const art::Event evt)

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

References sim::ParticleList::Add(), sim::ParticleList::AdoptEveIdCalculator(), sim::ParticleList::clear(), cOpDetBacktrackerRecords, art::Handle< T >::failedToGet(), fG4ModuleLabel, art::fill_ptr_vector(), fMCTruthList, fParticleList, fTrackIDToMCTruthIndex, art::ProductRetriever::getByLabel(), GetSetOfTrackIDs(), 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::Rebuild ( const art::Event evt)
void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)

Referenced by ~PhotonBackTracker().

void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)
void cheat::PhotonBackTracker::SetEveIdCalculator ( sim::EveIdCalculator ec)
inline
void cheat::PhotonBackTracker::SetEveIdCalculator ( sim::EveIdCalculator ec)
inline
const void cheat::PhotonBackTracker::shouldThisFail ( ) const
private

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

References have_complained.

Referenced by ChannelToTrackSDPs(), FindOpDetBacktrackerRecord(), GetSetOfEveIDs(), GetSetOfTrackIDs(), MCTruthToParticles(), OpDetBacktrackerRecords(), OpHitChargeCollectionEfficiency(), OpHitChargeCollectionPurity(), OpHitCollectionEfficiency(), OpHitCollectionPurity(), OpHitToEveSDPs(), OpHitToSDPs(), OpHitToTrackSDPs(), OpHitToXYZ(), ParticleToMCTruth(), SimSDPsToXYZ(), TrackIDsToOpHits(), TrackIDToMCTruth(), TrackIDToMotherParticle(), TrackIDToParticle(), and TrackIDToSimSDP().

169  {
170  //I need to revisit this and see if this check is too aggressive, as it only takes one failed event to set have_complained to true for the rest of the file.
171  //I currently do believe this is okay, as have_complained only flips on ProductNotFound errors, and if that happens in one event of a file,
172  // it should happen in all events of the file.
173  if (have_complained == true) {
174  throw cet::exception("PhotonBackTracker1")
175  << "PhotonBackTracker methods called on a file without OpDetPhotonBacktrackerRecords. "
176  "Backtracked information is not available.";
177  }
178  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const void cheat::PhotonBackTracker::shouldThisFail ( ) const
private
std::vector<double> cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps)
std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps)

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

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

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

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

Definition at line 348 of file PhotonBackTracker.cc.

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

349  {
350  std::vector<double> xyz(3, -999.);
351  double x = 0.;
352  double y = 0.;
353  double z = 0.;
354  double w = 0.;
355  // loop over photons.
356  for (auto const& sdp : sdps) {
357  double weight = sdp.numPhotons;
358  w += weight;
359  x += weight * sdp.x;
360  y += weight * sdp.y;
361  z += weight * sdp.z;
362  } // end loop over sim::SDPs
363  // If the sum of the weights is still zero, then fail to return a value. A hit with
364  // no contributing photons does't make sense.
365  if (w < 1.e-5)
366  throw cet::exception("PhotonBackTracker")
367  << "No sim::SDPs providing non-zero number of photons"
368  << " can't determine originating location from truth\n";
369  xyz[0] = x / w;
370  xyz[1] = y / w;
371  xyz[2] = z / w;
372  return xyz;
373  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
double weight
Definition: plottest35.C:25
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps) const

Definition at line 376 of file PhotonBackTracker.cc.

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

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

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

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

Referenced by 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
std::vector< std::vector< art::Ptr< recob::OpHit > > > cheat::PhotonBackTracker::TrackIdsToOpHits_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
) const

Definition at line 259 of file PhotonBackTracker.cc.

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

Referenced by cheat::PhotonBackTrackerService::TrackIdsToOpHits_Ps().

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

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

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

Referenced by MCTruthToParticles(), ParticleToMCTruth(), and SetEveIdCalculator().

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

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

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

Referenced by 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
std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::TrackIdToOpHits_Ps ( int  tkId,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
) const

Definition at line 246 of file PhotonBackTracker.cc.

Referenced by cheat::PhotonBackTrackerService::TrackIdToOpHits_Ps().

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

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

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

Referenced by SetEveIdCalculator(), and 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.
const simb::MCParticle* cheat::PhotonBackTracker::TrackIDToParticle ( int const &  id) const
std::vector< sim::SDP > cheat::PhotonBackTracker::TrackIDToSimSDP ( int const &  id) const

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

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

Referenced by SetEveIdCalculator().

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

Definition at line 92 of file PhotonBackTracker.cc.

References util::abs().

Referenced by cheat::PhotonBackTrackerService::TrackIdToSimSDPs_Ps().

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

Member Data Documentation

std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cheat::PhotonBackTracker::cOpDetBacktrackerRecords
private

all the OpDetBacktrackerRecords for the event

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

Referenced by FindOpDetBacktrackerRecord(), OpDetBacktrackerRecords(), Rebuild(), and TrackIDToSimSDP().

const double cheat::PhotonBackTracker::fDelay
private

Definition at line 196 of file PhotonBackTracker.h.

double cheat::PhotonBackTracker::fDelay
private
std::string cheat::PhotonBackTracker::fG4ModuleLabel
private

label for geant4 module

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

Referenced by OpDetBacktrackerRecords(), Rebuild(), and ~PhotonBackTracker().

const art::InputTag cheat::PhotonBackTracker::fG4ModuleLabel
private

Definition at line 197 of file PhotonBackTracker.h.

const std::vector<art::InputTag> cheat::PhotonBackTracker::fG4ModuleLabels
private

Definition at line 198 of file PhotonBackTracker.h.

std::vector< art::Ptr< simb::MCTruth > > cheat::PhotonBackTracker::fMCTruthList
private

all the MCTruths for the event

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

Referenced by MCTruthVector(), OpDetBacktrackerRecords(), Rebuild(), and TrackIDToMCTruth().

double cheat::PhotonBackTracker::fMinOpHitEnergyFraction
private

minimum fraction of energy a track id has to

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

Referenced by OpDetBacktrackerRecords(), OpHitChargeCollectionEfficiency(), OpHitCollectionEfficiency(), TrackIDsToOpHits(), and ~PhotonBackTracker().

const double cheat::PhotonBackTracker::fMinOpHitEnergyFraction
private

Definition at line 201 of file PhotonBackTracker.h.

const art::InputTag cheat::PhotonBackTracker::fOpFlashLabel
private

Definition at line 200 of file PhotonBackTracker.h.

const art::InputTag cheat::PhotonBackTracker::fOpHitLabel
private

Definition at line 199 of file PhotonBackTracker.h.

sim::ParticleList cheat::PhotonBackTracker::fParticleList
private
const cheat::ParticleInventory* cheat::PhotonBackTracker::fPartInv
private

Definition at line 194 of file PhotonBackTracker.h.

std::map< int, int > cheat::PhotonBackTracker::fTrackIDToMCTruthIndex
private

map of track ids to MCTruthList entry

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

Referenced by OpDetBacktrackerRecords(), Rebuild(), and TrackIDToMCTruth().

sim::LArVoxelList cheat::PhotonBackTracker::fVoxelList
private

List to map the position of energy depostions in voxels to the particles depositing the energy

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

Referenced by OpDetBacktrackerRecords().

const geo::WireReadoutGeom* cheat::PhotonBackTracker::fWireReadoutGeom
private

Definition at line 195 of file PhotonBackTracker.h.

geo::GeometryCore const * cheat::PhotonBackTracker::geom = lar::providerFrom<geo::Geometry>()
private
bool cheat::PhotonBackTracker::have_complained
private
std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > cheat::PhotonBackTracker::priv_OpDetBTRs
mutableprivate

Definition at line 202 of file PhotonBackTracker.h.

std::map<art::Ptr<recob::OpFlash>, std::vector<art::Ptr<recob::OpHit> > > cheat::PhotonBackTracker::priv_OpFlashToOpHits
private

Definition at line 203 of file PhotonBackTracker.h.


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