Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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::ParticleList & ParticleList () 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::ParticleList & ParticleList () 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, const geo::GeometryCore *geom)
 
 PhotonBackTracker (fhicl::ParameterSet const &pSet, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom)
 
 PhotonBackTracker (PhotonBackTracker const &)=delete
 
template<typename Evt >
void PrepEvent (Evt const &evt)
 
template<typename Evt >
const bool CanRun (Evt const &evt)
 
template<typename Evt >
void PrepOpDetBTRs (Evt const &evt)
 
template<typename Evt >
void PrepOpFlashToOpHits (Evt const &evt)
 
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps (art::Ptr< recob::OpFlash > &flash_P) const
 
const std::vector< double > OpFlashToXYZ (art::Ptr< recob::OpFlash > &flash_P) const
 
const std::set< int > OpFlashToTrackIds (art::Ptr< recob::OpFlash > &flash_P) const
 
const double GetDelay ()
 
void ClearEvent ()
 
const bool BTRsReady ()
 
const bool OpFlashToOpHitsReady ()
 
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > const & OpDetBTRs ()
 
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int const &id)
 
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps (int const &id, geo::View_t const &view)
 
const art::Ptr< sim::OpDetBacktrackerRecordFindOpDetBTR (int const &opDetNum) const
 
const std::vector< sim::TrackSDPOpDetToTrackSDPs (int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
 
const std::vector< sim::TrackSDPOpHitToTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
const std::vector< sim::TrackSDPOpHitToTrackSDPs (recob::OpHit const &opHit) const
 
const std::vector< int > OpHitToTrackIds (recob::OpHit const &opHit) const
 
const std::vector< int > OpHitToTrackIds (art::Ptr< recob::OpHit > const &opHit) const
 
const std::vector< int > OpHitToEveTrackIds (recob::OpHit const &opHit)
 
const std::vector< int > OpHitToEveTrackIds (art::Ptr< recob::OpHit > const &opHit_P)
 
const std::vector< sim::TrackSDPOpHitToEveTrackSDPs (art::Ptr< recob::OpHit > const &opHit_P) const
 
const std::vector< sim::TrackSDPOpHitToEveTrackSDPs (recob::OpHit const &opHit) const
 
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps (int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
 
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIdsToOpHits_Ps (std::vector< int > const &tkIds, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
 
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (recob::OpHit const &opHit) const
 
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps (art::Ptr< recob::OpHit > const &opHit_P) const
 
const std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps (std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
 
const std::vector< double > SimSDPsToXYZ (std::vector< sim::SDP > const &sdps) const &
 
const std::vector< double > SimSDPsToXYZ (std::vector< const sim::SDP * > const &sdps_Ps) const &
 
const std::vector< double > OpHitToXYZ (art::Ptr< recob::OpHit > const &opHit)
 
const std::vector< double > OpHitToXYZ (recob::OpHit const &opHit)
 
const std::vector< double > OpHitsToXYZ (std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
 
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (recob::OpHit const &opHit)
 
const std::unordered_set< const sim::SDP * > OpHitToEveSimSDPs_Ps (art::Ptr< recob::OpHit > &opHit_P)
 
const std::set< int > GetSetOfEveIds () const
 
const std::set< int > GetSetOfTrackIds () const
 
const std::set< int > GetSetOfEveIds (std::vector< art::Ptr< recob::OpHit > > const &opHits) const
 
const std::set< int > GetSetOfEveIds (std::vector< recob::OpHit > const &opHits) const
 
const std::set< int > GetSetOfTrackIds (std::vector< art::Ptr< recob::OpHit > > const &opHits) const
 
const std::set< int > GetSetOfTrackIds (std::vector< recob::OpHit > const &opHits) const
 
const double OpHitCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits)
 
const double OpHitLightCollectionPurity (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits)
 
const double OpHitCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn)
 
const double OpHitCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn, geo::View_t const &view)
 
const double OpHitLightCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn)
 
const double OpHitLightCollectionEfficiency (std::set< int > const &tkIds, std::vector< art::Ptr< recob::OpHit > > const &opHits, std::vector< art::Ptr< recob::OpHit > > const &opHitsIn, geo::View_t const &view)
 
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::GeometryCorefGeom
 
const double fDelay
 
const art::InputTag fG4ModuleLabel
 
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 45 of file old.PhotonBackTracker.h.

Constructor & Destructor Documentation

cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)
cheat::PhotonBackTracker::~PhotonBackTracker ( )

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

43  {
44  }
cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)
cheat::PhotonBackTracker::~PhotonBackTracker ( )
cheat::PhotonBackTracker::PhotonBackTracker ( fhiclConfig const &  config,
const cheat::ParticleInventory partInv,
const geo::GeometryCore geom 
)

Definition at line 36 of file PhotonBackTracker.cc.

40  :fPartInv (partInv),
41  fGeom (geom),
42 // fDetClocks (detClock),
43  fDelay (config.Delay()),
44  fG4ModuleLabel(config.G4ModuleLabel()),
45  fOpHitLabel(config.OpHitLabel()),
46  fOpFlashLabel(config.OpFlashLabel()),
47  //fWavLabel(config.WavLabel()),
48  fMinOpHitEnergyFraction(config.MinOpHitEnergyFraction())
49  {}
std::string fG4ModuleLabel
label for geant4 module
const cheat::ParticleInventory * fPartInv
static Config * config
Definition: config.cpp:1054
const geo::GeometryCore * fGeom
const art::InputTag fOpFlashLabel
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
const art::InputTag fOpHitLabel
cheat::PhotonBackTracker::PhotonBackTracker ( fhicl::ParameterSet const &  pSet,
const cheat::ParticleInventory partInv,
const geo::GeometryCore geom 
)

Definition at line 52 of file PhotonBackTracker.cc.

56  :fPartInv (partInv),
57  fGeom (geom),
58 // fDetClocks(detClock),
59  fDelay(pSet.get<double>("Delay")),
60  fG4ModuleLabel(pSet.get<art::InputTag>("G4ModuleLabel", "largeant")),
61  fOpHitLabel(pSet.get<art::InputTag>("OpHitLabel", "ophit")),
62  fOpFlashLabel(pSet.get<art::InputTag>("OpFlashLabel", "opflash")),
63  fMinOpHitEnergyFraction(pSet.get<double>("MinimumOpHitEnergyFraction", 0.1))
64  {}
std::string fG4ModuleLabel
label for geant4 module
const cheat::ParticleInventory * fPartInv
const geo::GeometryCore * fGeom
const art::InputTag fOpFlashLabel
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
const art::InputTag fOpHitLabel
cheat::PhotonBackTracker::PhotonBackTracker ( PhotonBackTracker const &  )
delete

Member Function Documentation

const bool cheat::PhotonBackTracker::BTRsReady ( )

Definition at line 77 of file PhotonBackTracker.cc.

78  {
79  return !( priv_OpDetBTRs.empty() ) ;
80  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
template<typename Evt >
const 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 636 of file old.PhotonBackTracker_service.cc.

640  {
641  shouldThisFail();
642  trackSDPs.clear();
643 
644  double totalE = 0.;
645 
646  try{
648 
649  // loop over the photons in the channel and grab those that are in time
650  // with the identified opHit start and stop times
651  //const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
652  //int start_tdc = ts->OpticalG4Time2TDC( opHit_start_time );
653  //int end_tdc = ts->OpticalG4Time2TDC( opHit_end_time );
654  // if(start_tdc<0) start_tdc = 0;
655  // if(end_tdc<0) end_tdc = 0;
656  std::vector<sim::SDP> simSDPs = schannel->TrackIDsAndEnergies(opHit_start_time, opHit_end_time);
657 
658  // first get the total energy represented by all track ids for
659  // this channel and range of tdc values
660  for(size_t e = 0; e < simSDPs.size(); ++e)
661  totalE += simSDPs[e].energy;
662 
663 
664  // protect against a divide by zero below
665  if(totalE < 1.e-5) totalE = 1.;
666 
667  // loop over the entries in the map and fill the input vectors
668 
669  for(size_t e = 0; e < simSDPs.size(); ++e){
670 
671  if(simSDPs[e].trackID == sim::NoParticleId) continue;
672 
674  info.trackID = simSDPs[e].trackID;
675  info.energyFrac = simSDPs[e].energy/totalE;
676  info.energy = simSDPs[e].energy;
677 
678  trackSDPs.push_back(info);
679 
680  }
681  }// end try
682  catch(cet::exception e){
683  mf::LogWarning("PhotonBackTracker") << "caught exception \n"
684  << e;
685  }
686 
687  return;
688  }
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
const double e
int trackID
Geant4 supplied trackID.
static const int NoParticleId
Definition: sim.h:28
float energyFrac
fraction of OpHit energy from the particle with this trackID
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]
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cheat::PhotonBackTracker::ClearEvent ( )

Definition at line 71 of file PhotonBackTracker.cc.

71  {
72  priv_OpDetBTRs.clear();
73  priv_OpFlashToOpHits.clear();
74  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
std::map< art::Ptr< recob::OpFlash >, std::vector< art::Ptr< recob::OpHit > > > priv_OpFlashToOpHits
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 616 of file old.PhotonBackTracker_service.cc.

617  {
618  shouldThisFail();
620 
621  for(size_t sc = 0; sc < cOpDetBacktrackerRecords.size(); ++sc){
622  //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
623  if(cOpDetBacktrackerRecords[sc]->OpDetNum() == opDetNum) opDet = cOpDetBacktrackerRecords[sc];
624  }
625 
626  if(!opDet)
627  {
628  throw cet::exception("PhotonBackTracker2") << "No sim::OpDetBacktrackerRecord corresponding "
629  << "to opDetNum: " << opDetNum << "\n";
630  }
631 
632  return opDet;
633  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const art::Ptr< sim::OpDetBacktrackerRecord > cheat::PhotonBackTracker::FindOpDetBTR ( int const &  opDetNum) const

Definition at line 121 of file PhotonBackTracker.cc.

122  {
124  for(size_t sc = 0; sc < priv_OpDetBTRs.size(); ++sc){
125  //This could become a bug. What if it occurs twice (shouldn't happen in correct records, but still, no error handeling included for the situation
126  if(priv_OpDetBTRs.at(sc)->OpDetNum() == opDetNum) opDet = priv_OpDetBTRs.at(sc);
127  }
128  if(!opDet)
129  {
130  throw cet::exception("PhotonBackTracker2") << "No sim:: OpDetBacktrackerRecord corresponding "
131  << "to opDetNum: " << opDetNum << "\n";
132  }
133  return opDet;
134  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const double cheat::PhotonBackTracker::GetDelay ( )

Definition at line 68 of file PhotonBackTracker.cc.

68 { return this->fDelay;}
std::set< int > cheat::PhotonBackTracker::GetSetOfEveIDs ( )

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

358  {
359  shouldThisFail();
360  std::set<int> eveIDs;
361 
363  while(plitr != fParticleList.end() ){
364  int eveID = fParticleList.EveId((*plitr).first);
365  // look to see if this eveID is already in the set
366  if( eveIDs.find(eveID) == eveIDs.end() ) eveIDs.insert(eveID);
367  plitr++;
368  }
369 
370  return eveIDs;
371  }
intermediate_table::const_iterator const_iterator
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 386 of file old.PhotonBackTracker_service.cc.

387  {
388  shouldThisFail();
389  std::set<int> eveIDs;
390 
391  std::vector< art::Ptr<recob::OpHit> >::const_iterator itr = opHits.begin();
392  while(itr != opHits.end() ){
393 
394  // get the eve ids corresponding to this opHit
395  const std::vector<sim::TrackSDP> sdps = OpHitToEveID(*itr);
396 
397  // loop over the sdps and extract the track ids
398  for(size_t i = 0; i < sdps.size(); ++i) eveIDs.insert(sdps[i].trackID);
399 
400  itr++;
401  }
402 
403  return eveIDs;
404  }
std::vector< sim::TrackSDP > OpHitToEveID(art::Ptr< recob::OpHit > const &hit)
const std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( ) const

Definition at line 481 of file PhotonBackTracker.cc.

482  {
483  //std::set<int> out = fPartInv->GetSetOfEveIds();
484  return fPartInv->GetSetOfEveIds();
485  //return out;
486  }
const cheat::ParticleInventory * fPartInv
std::set< int > GetSetOfEveIds() const
const std::set< int > cheat::PhotonBackTracker::GetSetOfEveIds ( std::vector< art::Ptr< recob::OpHit > > const &  opHits) const

Definition at line 495 of file PhotonBackTracker.cc.

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

Definition at line 506 of file PhotonBackTracker.cc.

507  { /*NEW*/ /*COMPLETE*/
508  std::set<int> eveIds;
509  for(auto const& opHit : opHits){
510  const std::vector<sim::TrackSDP> sdps = this->OpHitToEveTrackSDPs(opHit);
511  for(auto const& sdp : sdps){eveIds.insert(sdp.trackID);}//end sdps
512  }//End for hits
513  return eveIds;
514  }
const 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 374 of file old.PhotonBackTracker_service.cc.

375  {
376  shouldThisFail();
377  // fParticleList::value_type is a pair (track, particle pointer)
378  std::set<int> trackIDs;
379  for (const sim::ParticleList::value_type& pl: fParticleList)
380  trackIDs.insert(pl.first);
381 
382  return trackIDs;
383  }
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 407 of file old.PhotonBackTracker_service.cc.

408  {
409  shouldThisFail();
410  std::set<int> trackIDs;
411 
412  std::vector< art::Ptr<recob::OpHit> >::const_iterator itr = opHits.begin();
413  while(itr != opHits.end() ){
414 
415  std::vector<sim::TrackSDP> trackSDPs;
416 
417  // get the track ids corresponding to this opHit
418  const double pTime = (*itr)->PeakTime();
419  const double pWidth= (*itr)->Width();
420  const double start = (pTime-pWidth)*1000.0-fDelay;
421  const double end = (pTime+pWidth)*1000.0-fDelay;
422  // const double start = (*itr)->PeakTimeMinusRMS();
423  // const double end = (*itr)->PeakTimePlusRMS();
424 
425  this->ChannelToTrackSDPs(trackSDPs, (*itr)->OpChannel(), start, end);
426 
427  // loop over the sdps and extract the track ids
428  for(size_t i = 0; i < trackSDPs.size(); ++i) {
429  trackIDs.insert(trackSDPs[i].trackID);
430  }
431 
432  itr++;
433  }
434 
435  return trackIDs;
436  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
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)
const std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( ) const

Definition at line 489 of file PhotonBackTracker.cc.

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

Definition at line 517 of file PhotonBackTracker.cc.

518  {
519  std::set<int> tids;
520  for( auto const& opHit : opHits){
521  for(auto const& sdp : this->OpHitToTrackSDPs(opHit)) {
522  tids.insert(sdp.trackID);
523  }//End for TrackSDPs
524  }//End for hits
525  return tids;
526  }
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
const std::set< int > cheat::PhotonBackTracker::GetSetOfTrackIds ( std::vector< recob::OpHit > const &  opHits) const

Definition at line 529 of file PhotonBackTracker.cc.

530  { /*NEW*/ /*COMPLETE*/
531  std::set<int> tids;
532  for( auto const& opHit : opHits){
533  for(auto const& sdp : this->OpHitToTrackSDPs(opHit)) {
534  tids.insert(sdp.trackID);
535  }//End for TrackSDPs
536  }//End for hits
537  return tids;
538  }
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 247 of file old.PhotonBackTracker_service.cc.

248  {
249  shouldThisFail();
250  std::vector<const simb::MCParticle*> ret;
251 
252  // sim::ParticleList::value_type is a pair (track ID, particle pointer)
253  for (const sim::ParticleList::value_type& TrackIDpair: fParticleList) {
254  if( TrackIDToMCTruth(TrackIDpair.first) == mct )
255  ret.push_back(TrackIDpair.second);
256  }
257 
258  return ret;
259  }
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 81 of file old.PhotonBackTracker.h.

81 { 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 81 of file old.PhotonBackTrackerService.h.

81 { 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 167 of file old.PhotonBackTrackerService.h.

167 { return cOpDetBacktrackerRecords; }
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 167 of file old.PhotonBackTracker.h.

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

Definition at line 89 of file PhotonBackTracker.cc.

90  {
91  return priv_OpDetBTRs;
92  }
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpDetToTrackSDPs ( int const &  OpDetNum,
double const &  opHit_start_time,
double const &  opHit_end_time 
) const

Definition at line 137 of file PhotonBackTracker.cc.

139  {
140  std::vector< sim::TrackSDP > tSDPs;
141  double totalE=0;
142  try{
144  this->FindOpDetBTR(OpDetNum);
145  // ( fGeom->OpDetFromOpChannel(channel) );
146  std::vector<sim::SDP> simSDPs =
147  opDetBTR->TrackIDsAndEnergies(opHit_start_time, opHit_end_time);
148  for(size_t e = 0; e < simSDPs.size(); ++e)
149  totalE += simSDPs[e].energy;
150  if(totalE < 1.e-5) totalE = 1.;
151  for(size_t e = 0; e < simSDPs.size(); ++e){
152  if(simSDPs[e].trackID == sim::NoParticleId) continue;
154  info.trackID = simSDPs[e].trackID;
155  info.energyFrac = simSDPs[e].energy/totalE;
156  info.energy = simSDPs[e].energy;
157  tSDPs.push_back(info);
158  }
159  }
160  catch(cet::exception const& e){//This needs to go. Make it specific if there is a really an exception we would like to catch.
161  mf::LogWarning("PhotonBackTracker")<<"Exception caught\n"
162  <<e;
163  }
164  return tSDPs;
165  }
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBTR(int const &opDetNum) const
const double e
int trackID
Geant4 supplied trackID.
static const int NoParticleId
Definition: sim.h:28
float energyFrac
fraction of OpHit energy from the particle with this trackID
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]
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::OpFlashToOpHits_Ps ( art::Ptr< recob::OpFlash > &  flash_P) const

Definition at line 704 of file PhotonBackTracker.cc.

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

Definition at line 83 of file PhotonBackTracker.cc.

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

Definition at line 722 of file PhotonBackTracker.cc.

723  {
724  std::vector<art::Ptr<recob::OpHit> > opHits_Ps = this->OpFlashToOpHits_Ps(flash_P);
725  std::set<int> ids;
726  for( auto& opHit_P : opHits_Ps){
727  for( const int& id : this->OpHitToTrackIds(opHit_P) ){
728  ids.insert( id) ;
729  } // end for ids
730  }// end for opHits
731  // std::set<int> ids;
732  return ids;
733  }// end OpFlashToTrackIds
const std::vector< int > OpHitToTrackIds(recob::OpHit const &opHit) const
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
const std::vector< double > cheat::PhotonBackTracker::OpFlashToXYZ ( art::Ptr< recob::OpFlash > &  flash_P) const

Definition at line 713 of file PhotonBackTracker.cc.

714  {
715  const std::vector< art::Ptr< recob::OpHit > > opHits_Ps = this->OpFlashToOpHits_Ps(flash_P);
716  const std::vector<double> retVec = this->OpHitsToXYZ(opHits_Ps);
717  //const std::vector<double> retVec(0.0,3);
718  return retVec;
719  }
const std::vector< double > OpHitsToXYZ(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
const std::vector< art::Ptr< recob::OpHit > > OpFlashToOpHits_Ps(art::Ptr< recob::OpFlash > &flash_P) const
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 551 of file old.PhotonBackTracker_service.cc.

554  {
555  shouldThisFail();
556  // get the list of EveIDs that correspond to the opHits in this collection
557  // and the energy associated with the desired trackID
558  float desired = 0.;
559  float total = 0.;
560 
561  // don't have to check the view in the opHits collection because
562  // those are assumed to be from the object we are testing and will
563  // the correct view by definition then.
564  for(size_t h = 0; h < opHits.size(); ++h){
565 
566  art::Ptr<recob::OpHit> opHit = opHits[h];
567  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
568 
569  // don't worry about opHits where the energy fraction for the chosen
570  // trackID is < 0.1
571  // also don't double count if this opHit has more than one of the
572  // desired track IDs associated with it
573  for(size_t e = 0; e < opHitTrackIDs.size(); ++e){
574  if(trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end() &&
575  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction){
576  desired += opHit->Area();
577  break;
578  }
579  }
580  }// end loop over opHits
581 
582  // now figure out how many opHits in the whole collection are associated with this id
583  for(size_t h = 0; h < allOpHits.size(); ++h){
584 
585  art::Ptr<recob::OpHit> opHit = allOpHits[h];
586 
587  // check that we are looking at the appropriate view here
588  // in the case of 3D objects we take all opHits
589  //if(opHit->View() != view && view != geo::k3D ) continue;
590 
591  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
592 
593  for(size_t e = 0; e < opHitTrackIDs.size(); ++e){
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  if(trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end() &&
599  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction){
600  total += opHit->Area();
601  break;
602  }
603  }
604 
605  }// end loop over all opHits
606 
607  double efficiency = 0.;
608  if(total > 0.) efficiency = desired/total;
609 
610  return efficiency;
611  }
const double e
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:67
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 544 of file old.PhotonBackTracker_service.cc.

548  {
549  throw cet::exception("PhotonBackTracker")<<"This function is not supported. OpHits do not have type View.\n";
550  }
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 465 of file old.PhotonBackTracker_service.cc.

467  {
468  shouldThisFail();
469  // get the list of EveIDs that correspond to the opHits in this collection
470  // if the EveID shows up in the input list of trackIDs, then it counts
471  float total = 0;
472  float desired = 0.;
473  // don't have to check the view in the opHits collection because
474  // those are assumed to be from the object we are testing and will
475  // the correct view by definition then.
476  for(size_t h = 0; h < opHits.size(); ++h){
477  art::Ptr<recob::OpHit> opHit = opHits[h];
478  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
479  total+=opHit->Area(); // sum up the charge in the cluster
480  // don't double count if this opHit has more than one of the
481  // desired track IDs associated with it
482  for(size_t e = 0; e < opHitTrackIDs.size(); ++e){
483  if(trackIDs.find(opHitTrackIDs[e].trackID) != trackIDs.end()){
484  desired += opHit->Area();
485  break;
486  }
487  }
488  }// end loop over opHits
489  double purity = 0.;
490  if(total > 0) purity = desired/total;
491  return purity;
492  }
const double e
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double Area() const
Definition: OpHit.h:67
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 504 of file old.PhotonBackTracker_service.cc.

505  {
506  shouldThisFail();
507  float desired = 0.;
508  float total = 0.;
509  for(size_t h = 0; h < opHits.size(); ++h){
510  art::Ptr<recob::OpHit> opHit = opHits[h];
511  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
512  // also don't double count if this opHit has more than one of the
513  // desired track IDs associated with it
514  for(size_t e = 0; e < opHitTrackSDP.size(); ++e){
515  if(trackIDs.find(opHitTrackSDPs[e].trackID) != trackIDs.end() &&
516  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction){
517  desired += 1.;
518  break;
519  }
520  }
521  }// end loop over opHits
522  // now figure out how many opHits in the whole collection are associated with this id
523  for(size_t h = 0; h < allOpHits.size(); ++h){
524  art::Ptr<recob::OpHit> opHit = allOpHits[h];
525  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
526  for(size_t e = 0; e < opHitTrackSDPs.size(); ++e){
527  // don't worry about opHits where the energy fraction for the chosen
528  // trackID is < 0.1
529  // also don't double count if this opHit has more than one of the
530  // desired track IDs associated with it
531  if(trackIDs.find(opHitTrackSDPs[e].trackID) != trackIDs.end() &&
532  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction){
533  total += 1.;
534  break;
535  }
536  }
537  }// end loop over all opHits
538  double efficiency = 0.;
539  if(total > 0.) efficiency = desired/total;
540  return efficiency;
541  }
const double e
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
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 496 of file old.PhotonBackTracker_service.cc.

500  {
501  throw cet::exception("PhotonBackTracker")<<"This function is not supported. OpHits do not have type View.\n";
502  }
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 
)
const 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 604 of file PhotonBackTracker.cc.

607  {
608  float desired = 0.;
609  float total = 0.;
610  for(size_t h = 0; h < opHits.size(); ++h){
611  art::Ptr<recob::OpHit> opHit = opHits[h];
612  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
613  // also don't double count if this opHit has more than one of the
614  // desired track IDs associated with it
615  for(size_t e = 0; e < opHitTrackSDPs.size(); ++e){
616  if(tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end() &&
617  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction){
618  desired += 1.;
619  break;
620  }
621  }
622  }// end loop over opHits
623  // now figure out how many opHits in the whole collection are associated with this id
624  for(size_t h = 0; h < opHitsIn.size(); ++h){
625  art::Ptr<recob::OpHit> opHit = opHitsIn[h];
626  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
627  for(size_t e = 0; e < opHitTrackSDPs.size(); ++e){
628  // don't worry about opHits where the energy fraction for the chosen
629  // trackID is < 0.1
630  // also don't double count if this opHit has more than one of the
631  // desired track IDs associated with it
632  if(tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end() &&
633  opHitTrackSDPs[e].energyFrac >= fMinOpHitEnergyFraction){
634  total += 1.;
635  break;
636  }
637  }
638  }// end loop over all opHits
639  double efficiency = 0.;
640  if(total > 0.) efficiency = desired/total;
641  return efficiency;
642  }
const double e
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
const 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,
geo::View_t const &  view 
)

Definition at line 595 of file PhotonBackTracker.cc.

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

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

441  {
442  shouldThisFail();
443  // get the list of EveIDs that correspond to the opHits in this collection
444  // if the EveID shows up in the input list of trackIDs, then it counts
445  float total = 1.*opHits.size();;
446  float desired = 0.;
447  for(size_t h = 0; h < opHits.size(); ++h){
448  art::Ptr<recob::OpHit> opHit = opHits[h];
449  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
450  // don't double count if this opHit has more than one of the
451  // desired track IDs associated with it
452  for(size_t e = 0; e < opHitTrackSDPs.size(); ++e){
453  if(trackIds.find(opHitTrackSDPs[e].trackID) != trackIds.end()){
454  desired += 1.;
455  break;
456  }
457  }
458  }// end loop over opHits
459  double purity = 0.;
460  if(total > 0) purity = desired/total;
461  return purity;
462  }
const double e
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
double cheat::PhotonBackTracker::OpHitCollectionPurity ( std::set< int >  trackIDs,
std::vector< art::Ptr< recob::OpHit > > const &  hits 
)
const double cheat::PhotonBackTracker::OpHitCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit > > const &  opHits 
)

Definition at line 541 of file PhotonBackTracker.cc.

543  {
544  // get the list of EveIDs that correspond to the opHits in this collection
545  // if the EveID shows up in the input list of tkIds, then it counts
546  float total = 1.*opHits.size();;
547  float desired = 0.;
548  for(size_t h = 0; h < opHits.size(); ++h){
549  art::Ptr<recob::OpHit> opHit = opHits[h];
550  std::vector<sim::TrackSDP> opHitTrackSDPs = this->OpHitToTrackSDPs(opHit);
551  // don't double count if this opHit has more than one of the
552  // desired track IDs associated with it
553  for(size_t e = 0; e < opHitTrackSDPs.size(); ++e){
554  if(tkIds.find(opHitTrackSDPs[e].trackID) != tkIds.end()){
555  desired += 1.;
556  break;
557  }
558  }
559  }// end loop over opHits
560  double purity = 0.;
561  if(total > 0) purity = desired/total;
562  return purity;
563  }
const double e
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
const 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 654 of file PhotonBackTracker.cc.

657  {
658  float desired = 0.;
659  float total = 0.;
660 
661  // don't have to check the view in the opHits collection because
662  // those are assumed to be from the object we are testing and will
663  // the correct view by definition then.
664  for(size_t h = 0; h < opHits.size(); ++h){
665 
666  art::Ptr<recob::OpHit> opHit = opHits[h];
667  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
668 
669  // don't worry about opHits where the energy fraction for the chosen
670  // trackID is < 0.1
671  // also don't double count if this opHit has more than one of the
672  // desired track IDs associated with it
673  for(size_t e = 0; e < opHitTrackIDs.size(); ++e){
674  if(tkIds.find(opHitTrackIDs[e].trackID) != tkIds.end() &&
675  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction){
676  desired += opHit->Area();
677  break;
678  }
679  }
680  }// end loop over opHits
681  for(size_t h = 0; h < opHitsIn.size(); ++h){
682  art::Ptr<recob::OpHit> opHit = opHitsIn[h];
683  // check that we are looking at the appropriate view here
684  // in the case of 3D objects we take all opHits
685  //if(opHit->View() != view && view != geo::k3D ) continue;
686  std::vector<sim::TrackSDP> opHitTrackIDs = this->OpHitToTrackSDPs(opHit);
687  for(size_t e = 0; e < opHitTrackIDs.size(); ++e){
688  // don't worry about opHits where the energy fraction for the chosen
689  // trackID is < 0.1
690  // also don't double count if this opHit has more than one of the
691  // desired track IDs associated with it
692  if(tkIds.find(opHitTrackIDs[e].trackID) != tkIds.end() &&
693  opHitTrackIDs[e].energyFrac >= fMinOpHitEnergyFraction){
694  total += opHit->Area();
695  break;
696  }
697  }
698  }// end loop over all opHits
699  double efficiency = 0.;
700  if(total > 0.) efficiency = desired/total;
701  return efficiency;
702  }
const double e
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:67
const 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,
geo::View_t const &  view 
)

Definition at line 645 of file PhotonBackTracker.cc.

649  {
650  throw cet::exception("PhotonBackTracker")<<"This function is not supported. OpHits do not have type View.\n";
651  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const double cheat::PhotonBackTracker::OpHitLightCollectionPurity ( std::set< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit > > const &  opHits 
)

Definition at line 566 of file PhotonBackTracker.cc.

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

Definition at line 435 of file PhotonBackTracker.cc.

436  {
437  std::vector < const sim::SDP* > sdps_Ps;
438  for ( auto opHit_P : opHits_Ps ){
439  std::vector < const sim::SDP* > to_add_sdps_Ps = this->OpHitToSimSDPs_Ps(opHit_P);
440  sdps_Ps.insert( sdps_Ps.end(), to_add_sdps_Ps.begin(), to_add_sdps_Ps.end() );
441  }
442  return sdps_Ps;
443  }
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const std::vector< double > cheat::PhotonBackTracker::OpHitsToXYZ ( std::vector< art::Ptr< recob::OpHit > > const &  opHits_Ps) const

Definition at line 446 of file PhotonBackTracker.cc.

447  {
448  const std::vector<const sim::SDP*> SDPs_Ps = OpHitsToSimSDPs_Ps(opHits_Ps);
449  return this->SimSDPsToXYZ(SDPs_Ps);
450  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
const std::vector< const sim::SDP * > OpHitsToSimSDPs_Ps(std::vector< art::Ptr< recob::OpHit > > const &opHits_Ps) const
std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveID ( art::Ptr< recob::OpHit > const &  hit)

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

350  {
351  mf::LogWarning("PhotonBackTracker") << "PhotonBackTracker::OpHitToEveID is being replaced with PhotonBackTracker::OpHitToEveSDPs. Please \n update your code accordingly.\n ";
352  std::vector<sim::TrackSDP> eveSDPs = OpHitToEveSDPs(opHit);
353  return eveSDPs;
354  }
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 321 of file old.PhotonBackTracker_service.cc.

322  {
323  shouldThisFail();
324  std::vector<sim::TrackSDP> trackSDPs = this->OpHitToTrackSDPs(opHit);
325 
326  // make a map of evd ID values and fraction of energy represented by
327  // that eve id in this opHit
328  std::map<int, float> eveIDtoEfrac;
329 
330  double totalE = 0.;
331  for(size_t t = 0; t < trackSDPs.size(); ++t){
332  eveIDtoEfrac[fParticleList.EveId( trackSDPs[t].trackID )] += trackSDPs[t].energy;
333  totalE += trackSDPs[t].energy;
334  }
335 
336  // now fill the eveSDPs vector from the map
337  std::vector<sim::TrackSDP> eveSDPs;
338  eveSDPs.reserve(eveIDtoEfrac.size());
339  for(auto itr = eveIDtoEfrac.begin(); itr != eveIDtoEfrac.end(); itr++){
341  temp.trackID = (*itr).first;
342  temp.energyFrac = (*itr).second/totalE;
343  temp.energy = (*itr).second;
344  eveSDPs.push_back(std::move(temp));
345  }
346 
347  return eveSDPs;
348  }
int trackID
Geant4 supplied trackID.
def move(depos, offset)
Definition: depos.py:107
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)
const std::unordered_set< const sim::SDP * > cheat::PhotonBackTracker::OpHitToEveSimSDPs_Ps ( recob::OpHit const &  opHit)

Definition at line 453 of file PhotonBackTracker.cc.

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

Definition at line 467 of file PhotonBackTracker.cc.

468  { /*NEW*/ /*COMPLETE*/
469  const std::vector < int > ids = this->OpHitToEveTrackIds(opHit);
470  std::unordered_set <const sim::SDP* > sdps;
471  for( auto const& id : ids ){
472  std::vector<const sim::SDP* > tmp_sdps = TrackIdToSimSDPs_Ps(id);
473  for( const sim::SDP* tmp_sdp : tmp_sdps ){
474  sdps.insert(tmp_sdp); //emplace not needed here.
475  }
476  }
477  return sdps;
478  }
const std::vector< const sim::SDP * > TrackIdToSimSDPs_Ps(int const &id)
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
const std::vector< int > cheat::PhotonBackTracker::OpHitToEveTrackIds ( recob::OpHit const &  opHit)

Definition at line 219 of file PhotonBackTracker.cc.

220  {/*NEW*/ /*COMPLETE*/
221  std::vector< int > retVec;
222  for( auto const trackSDP : this->OpHitToEveTrackSDPs(opHit) ){
223  retVec.push_back( trackSDP.trackID);
224  }
225  return retVec;
226  }
const std::vector< sim::TrackSDP > OpHitToEveTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P) const
const std::vector< int > cheat::PhotonBackTracker::OpHitToEveTrackIds ( art::Ptr< recob::OpHit > const &  opHit_P)

Definition at line 229 of file PhotonBackTracker.cc.

230  {/*NEW*/ /*COMPLETE*/
231  return this->OpHitToEveTrackIds(*opHit_P);
232  }
const std::vector< int > OpHitToEveTrackIds(recob::OpHit const &opHit)
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToEveTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const

Definition at line 235 of file PhotonBackTracker.cc.

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

Definition at line 241 of file PhotonBackTracker.cc.

242  {
243  std::vector<sim::TrackSDP> trackSDPs = this->OpHitToTrackSDPs(opHit);
244 
245  // make a map of evd ID values and fraction of energy represented by
246  // // that eve id in this opHit
247  std::map<int, float> eveIDtoEfrac;
248 
249  double totalE = 0.;
250  for(size_t t = 0; t < trackSDPs.size(); ++t){
251  eveIDtoEfrac[(fPartInv->ParticleList()).EveId( trackSDPs[t].trackID )] += trackSDPs[t].energy;
252  totalE += trackSDPs[t].energy;
253  }
254 
255  // now fill the eveSDPs vector from the map
256  std::vector<sim::TrackSDP> eveSDPs;
257  eveSDPs.reserve(eveIDtoEfrac.size());
258  for(auto itr = eveIDtoEfrac.begin(); itr != eveIDtoEfrac.end(); itr++){
260  temp.trackID = (*itr).first;
261  temp.energyFrac = (*itr).second/totalE;
262  temp.energy = (*itr).second;
263  eveSDPs.push_back(std::move(temp));
264  }
265  return eveSDPs;
266  }
int trackID
Geant4 supplied trackID.
const cheat::ParticleInventory * fPartInv
def move(depos, offset)
Definition: depos.py:107
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 691 of file old.PhotonBackTracker_service.cc.

693  {
694  shouldThisFail();
695  // Get services.
696  //const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
697 
698  double fPeakTime = opHit.PeakTime();
699  double fWidth = opHit.Width();
700  sim::OpDetBacktrackerRecord::timePDclock_t start_time = ((fPeakTime-fWidth)*1000.0)-fDelay;
701  sim::OpDetBacktrackerRecord::timePDclock_t end_time = ((fPeakTime+fWidth)*1000.0)-fDelay;
702 
703  sdps = FindOpDetBacktrackerRecord( geom->OpDetFromOpChannel(opHit.OpChannel()) )->TrackIDsAndEnergies(start_time, end_time);
704 
705  }
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
double timePDclock_t
Type for iTimePDclock tick used in the interface.
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBacktrackerRecord(int channel) const
geo::GeometryCore const * geom
std::vector< sim::SDP > TrackIDsAndEnergies(timePDclock_t startTimePDclock, timePDclock_t endTimePDclock) const
Return all the recorded energy deposition within a time interval.
void cheat::PhotonBackTracker::OpHitToSDPs ( recob::OpHit const &  hit,
std::vector< sim::SDP > &  sdps 
) const
void cheat::PhotonBackTracker::OpHitToSDPs ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inline

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

107  { OpHitToSDPs(*hit, sdps); }
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 105 of file old.PhotonBackTracker.h.

107  { OpHitToSDPs(*hit, sdps); }
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 102 of file old.PhotonBackTracker.h.

104  { OpHitToSDPs( hit, sdps); }
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 102 of file old.PhotonBackTrackerService.h.

104  { OpHitToSDPs( hit, sdps); }
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

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

110  { OpHitToSDPs(*hit, sdps); }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
DEPRECATED void cheat::PhotonBackTracker::OpHitToSimSDPs ( art::Ptr< recob::OpHit > const &  hit,
std::vector< sim::SDP > &  sdps 
) const
inline

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

110  { OpHitToSDPs(*hit, sdps); }
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
const std::vector< const sim::SDP * > cheat::PhotonBackTracker::OpHitToSimSDPs_Ps ( recob::OpHit const &  opHit) const

Definition at line 315 of file PhotonBackTracker.cc.

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

Definition at line 360 of file PhotonBackTracker.cc.

361  {
362  return this->OpHitToSimSDPs_Ps(*opHit_P);
363  }
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
DEPRECATED std::vector<sim::TrackSDP> cheat::PhotonBackTracker::OpHitToTrackID ( art::Ptr< recob::OpHit > const &  hit)
inline

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

86  {return OpHitToTrackSDPs(hit);}
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 85 of file old.PhotonBackTrackerService.h.

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

Definition at line 203 of file PhotonBackTracker.cc.

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

Definition at line 213 of file PhotonBackTracker.cc.

214  {
215  return this->OpHitToTrackIds(*opHit);
216  }
const 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 262 of file old.PhotonBackTracker_service.cc.

263  {
264  shouldThisFail();
265  std::vector<sim::TrackSDP> trackSDPs;
266  const double pTime = opHit->PeakTime();
267  const double pWidth= opHit->Width();
268  const double start = (pTime-pWidth)*1000-fDelay;
269  const double end = (pTime+pWidth)*1000-fDelay;
270 
271  this->ChannelToTrackSDPs(trackSDPs, opHit->OpChannel(), start, end);
272 
273  return trackSDPs;
274  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
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)
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( art::Ptr< recob::OpHit > const &  opHit_P) const

Definition at line 168 of file PhotonBackTracker.cc.

169  {
170  //auto opHit = *opHit_P;
171  auto OpDetNum = fGeom->OpDetFromOpChannel(opHit_P->OpChannel()) ;
172  std::vector<sim::TrackSDP> trackSDPs;
173  const double pTime = opHit_P->PeakTime();
174  const double pWidth= opHit_P->Width();
175  const double start = (pTime-pWidth)*1000-fDelay;
176  const double end = (pTime+pWidth)*1000-fDelay;
177 
178  //this->OpDetToTrackSDPs(trackSDPs, opHit_P->OpChannel(), start, end);
179 
180 
181  //return trackSDPs;
182  //return this->OpDetToTrackSDPs( opHit_P->OpChannel(), start, end);
183  return this->OpDetToTrackSDPs( OpDetNum, start, end);
184 
185  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double PeakTime() const
Definition: OpHit.h:64
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
double Width() const
Definition: OpHit.h:66
const geo::GeometryCore * fGeom
int OpChannel() const
Definition: OpHit.h:62
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const std::vector< sim::TrackSDP > cheat::PhotonBackTracker::OpHitToTrackSDPs ( recob::OpHit const &  opHit) const

Definition at line 188 of file PhotonBackTracker.cc.

189  {
190  auto OpDetNum = fGeom->OpDetFromOpChannel(opHit.OpChannel()) ;
191  std::vector<sim::TrackSDP> trackSDPs;
192  const double pTime = opHit.PeakTime();
193  const double pWidth= opHit.Width();
194  const double start = (pTime-pWidth)*1000-fDelay;
195  const double end = (pTime+pWidth)*1000-fDelay;
196 
197 
198  return this->OpDetToTrackSDPs( OpDetNum, start, end);
199 
200  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
const geo::GeometryCore * fGeom
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
std::vector<double> cheat::PhotonBackTracker::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  hit)
const std::vector< double > cheat::PhotonBackTracker::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  hit)

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

746  {
747  shouldThisFail();
748  std::vector<sim::SDP> sdps;
749  OpHitToSDPs(opHit, sdps);
750  return SimSDPsToXYZ(sdps);
751  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
const std::vector< double > cheat::PhotonBackTracker::OpHitToXYZ ( art::Ptr< recob::OpHit > const &  opHit)
const std::vector< double > cheat::PhotonBackTracker::OpHitToXYZ ( recob::OpHit const &  opHit)

Definition at line 421 of file PhotonBackTracker.cc.

422  {
423  return SimSDPsToXYZ(this->OpHitToSimSDPs_Ps(opHit));
424  }
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
const std::vector< const sim::SDP * > OpHitToSimSDPs_Ps(recob::OpHit const &opHit) const
const sim::ParticleList& cheat::PhotonBackTracker::ParticleList ( ) const
inline

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

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

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

65 { 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 240 of file old.PhotonBackTracker_service.cc.

241  {
242  shouldThisFail();
243  return this->TrackIDToMCTruth(p->TrackId());
244  }
int TrackId() const
Definition: MCParticle.h:210
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 56 of file old.PhotonBackTracker_service.cc.

57  {
58  // do nothing if this is data
59  if(evt.isRealData()) return;
60 
61  // get the particles from the event
63  evt.getByLabel(fG4ModuleLabel, pHandle);
64 
65  // first check to see if we got called to early, that is the particles are
66  // and sim channels are not made yet in a MC production job
67  // if that is the case, we'll take care of it later
68  if(pHandle.failedToGet()){
69  mf::LogWarning("PhotonBackTracker") << "failed to get handle to simb::MCParticle from "
71  << ", return";
72  return;
73  }
74 
75  // Clear out anything remaining from previous calls to Rebuild
76  fParticleList.clear();
77  fMCTruthList .clear();
78  cOpDetBacktrackerRecords .clear();
79  //fVoxelList .clear();
80 
81  art::FindOneP<simb::MCTruth> fo(pHandle, evt, fG4ModuleLabel);
82 
83  if( fo.isValid() ){
84  for(size_t p = 0; p < pHandle->size(); ++p){
85 
86  simb::MCParticle *part = new simb::MCParticle(pHandle->at(p));
87  fParticleList.Add(part);
88 
89  // get the simb::MCTruth associated to this sim::ParticleList
90  try{
91  art::Ptr<simb::MCTruth> mct = fo.at(p);
92  if(fMCTruthList.size() < 1) fMCTruthList.push_back(mct);
93  else{
94  // check that we are not adding a simb::MCTruth twice to the collection
95  // we know that all the particles for a given simb::MCTruth are put into the
96  // collection of particles at the same time, so we can just check that the
97  // current art::Ptr has a different id than the last one put
98  if(!(mct == fMCTruthList.back())) fMCTruthList.push_back(mct);
99  }
100  // fill the track id to mctruth index map
101  fTrackIDToMCTruthIndex[pHandle->at(p).TrackId()] = fMCTruthList.size() - 1;
102  }
103  catch(cet::exception &ex){
104  mf::LogWarning("PhotonBackTracker") << "unable to find MCTruth from ParticleList "
105  << "created in " << fG4ModuleLabel << " "
106  << "any attempt to get the MCTruth objects from "
107  << "the photon backtracker will fail\n"
108  << "message from caught exception:\n" << ex;
109  }
110  }// end loop over particles to get MCTruthList
111  }// end if fo.isValid()
112 
113  // grab the sim::OpDetBacktrackerRecords for this event
114 
115  /*
116  try{evt.getView(fG4ModuleLabel, cOpDetBacktrackerRecords);}
117  catch(art::Exception const& e){
118  if(e.categoryCode() != art::errors::ProductNotFound) throw;
119  if(have_complained==false){
120  }
121  }
122  */
123 
125  // std::vector< art::Ptr< sim::OpDetBacktrackerRecords > > cOpDetBacktrackerRecords;
126  evt.getByLabel(fG4ModuleLabel, cPBTRHandle);
127  if(cPBTRHandle.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) throw;
130  else if(have_complained==false){
131  std::cout<<"FAILED BECAUSE "<<(*failMode)<<"\n";
132  have_complained=true;
133  mf::LogWarning("PhotonBackTracker")<<"Failed to get BackTrackerRecords from this event. All calls to the PhotonBackTracker will fail.\n"
134  <<"This message will be generated only once per lar invokation. If this is event one, be aware the PhotonBackTracker may not work on any events from this file.\n"
135  <<"Please change the log level to debug if you need more information for each event.\n"
136  <<"Failed with :"<<(*failMode)<<"\n";
137  mf::LogDebug("PhotonBackTracker")<<"Failed to get BackTrackerRecords from this event.\n";
138  }else{
139  mf::LogDebug("PhotonBackTracker")<<"Failed to get BackTrackerRecords from this event.\n";
140  }
141  }else{//Did not fail to get products. All is well. Run as expected.
143  }
144 
145 
146  // grab the voxel list for this event
147  //fVoxelList = sim::SimListUtils::GetLArVoxelList(evt, fG4ModuleLabel);
148 
149  fParticleList.AdoptEveIdCalculator(new sim::EmEveIdCalculator);
150 
151  MF_LOG_DEBUG("PhotonBackTracker") << "PhotonBackTracker has " << cOpDetBacktrackerRecords.size()
152  << " sim::OpDetBacktrackerRecords and " << GetSetOfTrackIDs().size()
153  << " tracks. The particles are:\n"
154  << fParticleList
155  << "\n the MCTruth information is\n";
156  for(size_t mc = 0; mc < fMCTruthList.size(); ++mc)
157  MF_LOG_DEBUG("PhotonBackTracker") << *(fMCTruthList.at(mc).get());
158 
159  return;
160  }
std::map< int, int > fTrackIDToMCTruthIndex
map of track ids to MCTruthList entry
std::string fG4ModuleLabel
label for geant4 module
bool isRealData() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
p
Definition: test.py:223
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:219
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
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
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:198
void cheat::PhotonBackTracker::Rebuild ( const art::Event evt)
void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)
void cheat::PhotonBackTracker::reconfigure ( fhicl::ParameterSet const &  pset)
void cheat::PhotonBackTracker::SetEveIdCalculator ( sim::EveIdCalculator *  ec)
inline

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

68 { fParticleList.AdoptEveIdCalculator(ec); }
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
void cheat::PhotonBackTracker::SetEveIdCalculator ( sim::EveIdCalculator *  ec)
inline

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

68 { fParticleList.AdoptEveIdCalculator(ec); }
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
const void cheat::PhotonBackTracker::shouldThisFail ( ) const
private

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

163  {
164  //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.
165  //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,
166  // it should happen in all events of the file.
167  if( have_complained==true ){
168  throw cet::exception("PhotonBackTracker1") << "PhotonBackTracker methods called on a file without OpDetPhotonBacktrackerRecords. Backtracked information is not available.";
169  }
170  }
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)

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

709  {
710  shouldThisFail();
711  std::vector<double> xyz(3, -999.);
712 
713  double x = 0.;
714  double y = 0.;
715  double z = 0.;
716  double w = 0.;
717 
718  // loop over photons.
719 
720  for(auto const& sdp : sdps) {
721 
722  double weight = sdp.numPhotons;
723 
724  w += weight;
725  x += weight * sdp.x;
726  y += weight * sdp.y;
727  z += weight * sdp.z;
728 
729  }// end loop over sim::SDPs
730 
731  //If the sum of the weights is still zero, then fail to return a value.
732  //A hit with no contributing photons does't make sense.
733  if(w < 1.e-5)
734  throw cet::exception("PhotonBackTracker") << "No sim::SDPs providing non-zero number of photons"
735  << " can't determine originating location from truth\n";
736 
737  xyz[0] = x/w;
738  xyz[1] = y/w;
739  xyz[2] = z/w;
740 
741  return xyz;
742  }
weight
Definition: test.py:257
const double e
list x
Definition: train.py:276
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector<double> cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps)
const std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< sim::SDP > const &  sdps) const

Definition at line 366 of file PhotonBackTracker.cc.

367  {
368  std::vector<double> xyz(3, -999.);
369  double x = 0.;
370  double y = 0.;
371  double z = 0.;
372  double w = 0.;
373  // loop over photons.
374  for(auto const& sdp : sdps) {
375  double weight = sdp.numPhotons;
376  w += weight;
377  x += weight * sdp.x;
378  y += weight * sdp.y;
379  z += weight * sdp.z;
380  }// end loop over sim::SDPs
381  //If the sum of the weights is still zero, then fail to return a value.
382  //A hit with no contributing photons does't make sense.
383  if(w < 1.e-5)
384  throw cet::exception("PhotonBackTracker") << "No sim::SDPs providing non-zero number of photons"
385  << " can't determine originating location from truth\n";
386  xyz[0] = x/w;
387  xyz[1] = y/w;
388  xyz[2] = z/w;
389  return xyz;
390  }
weight
Definition: test.py:257
const double e
list x
Definition: train.py:276
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const std::vector< double > cheat::PhotonBackTracker::SimSDPsToXYZ ( std::vector< const sim::SDP * > const &  sdps_Ps) const

Definition at line 393 of file PhotonBackTracker.cc.

394  {
395  std::vector<double> xyz(3, -999.);
396  double x = 0.;
397  double y = 0.;
398  double z = 0.;
399  double w = 0.;
400  // loop over photons.
401  for(const sim::SDP* sdp_P : sdps_Ps) {
402  auto& sdp = *sdp_P;
403  double weight = sdp.numPhotons;
404  w += weight;
405  x += weight * sdp.x;
406  y += weight * sdp.y;
407  z += weight * sdp.z;
408  }// end loop over sim::SDPs
409  //If the sum of the weights is still zero, then fail to return a value.
410  //A hit with no contributing photons does't make sense.
411  if(w < 1.e-5)
412  throw cet::exception("PhotonBackTracker") << "No sim::SDPs providing non-zero number of photons"
413  << " can't determine originating location from truth\n";
414  xyz[0] = x/w;
415  xyz[1] = y/w;
416  xyz[2] = z/w;
417  return xyz;
418  }
weight
Definition: test.py:257
const double e
list x
Definition: train.py:276
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 
)

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

279  {
280  shouldThisFail();
281  // returns a subset of the opHits in the allOpHits collection that are matched
282  // to MC particles listed in tkIDs
283 
284  // temporary vector of TrackIDs and Ptrs to opHits so only one
285  // loop through the (possibly large) allOpHits collection is needed
286  std::vector<std::pair<int, art::Ptr<recob::OpHit>>> opHitList;
287  std::vector<sim::TrackSDP> tids;
288  for(auto itr = allOpHits.begin(); itr != allOpHits.end(); ++itr) {
289  tids.clear();
290  art::Ptr<recob::OpHit> const& opHit = *itr;
291  const double pTime = opHit->PeakTime(), pWidth= opHit->Width();
292  const double start = (pTime-pWidth)*1000.0-fDelay, end = (pTime+pWidth)*1000.0-fDelay;
293  this->ChannelToTrackSDPs(tids, opHit->OpChannel(), start, end);
294  for(auto itid = tids.begin(); itid != tids.end(); ++itid) {
295  for(auto itkid = tkIDs.begin(); itkid != tkIDs.end(); ++itkid) {
296  if(itid->trackID == *itkid) {
297  if(itid->energyFrac > fMinOpHitEnergyFraction)
298  opHitList.push_back(std::make_pair(*itkid, opHit));
299  }
300  } // itkid
301  } // itid
302  } // itr
303 
304  // now build the truOpHits vector that will be returned to the caller
305  std::vector<std::vector<art::Ptr<recob::OpHit>>> truOpHits;
306  // temporary vector containing opHits assigned to one MC particle
307  std::vector<art::Ptr<recob::OpHit>> tmpOpHits;
308  for(auto itkid = tkIDs.begin(); itkid != tkIDs.end(); ++itkid) {
309  tmpOpHits.clear();
310  for(auto itr = opHitList.begin(); itr != opHitList.end(); ++itr) {
311  if(*itkid == (*itr).first) tmpOpHits.push_back((*itr).second);
312  }
313  truOpHits.push_back(tmpOpHits);
314  }
315 
316  return truOpHits;
317  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double PeakTime() const
Definition: OpHit.h:64
double Width() const
Definition: OpHit.h:66
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:62
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_Ps ( std::vector< int > const &  tkIds,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
)

Definition at line 281 of file PhotonBackTracker.cc.

282  {
283  std::vector<std::pair<int, art::Ptr<recob::OpHit>>> opHitList;
284  for(auto itr = hitsIn.begin(); itr != hitsIn.end(); ++itr) {
285  art::Ptr<recob::OpHit> const& opHit = *itr;
286  auto OpDetNum = fGeom->OpDetFromOpChannel(opHit->OpChannel());
287  const double pTime = opHit->PeakTime(), pWidth= opHit->Width();
288  const double start = (pTime-pWidth)*1000.0-fDelay, end = (pTime+ pWidth)*1000.0-fDelay;
289  std::vector<sim::TrackSDP> tids = this->OpDetToTrackSDPs( OpDetNum, start, end);
290  //std::vector<sim::TrackSDP> tids = this->OpDetToTrackSDPs( opHit->OpChannel(), start, end);
291  for(auto itid = tids.begin(); itid != tids.end(); ++itid) {
292  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
293  if(itid->trackID == *itkid) {
294  if(itid->energyFrac > fMinOpHitEnergyFraction)
295  opHitList.push_back(std::make_pair(*itkid, opHit));
296  }
297  } // itkid
298  } // itid
299  } // itr
300  // now build the truOpHits vector that will be returned to the caller
301  std::vector<std::vector<art::Ptr<recob::OpHit>>> truOpHits;
302  // temporary vector containing opHits assigned to one MC particle
303  std::vector<art::Ptr<recob::OpHit>> tmpOpHits;
304  for(auto itkid = tkIds.begin(); itkid != tkIds.end(); ++itkid) {
305  tmpOpHits.clear();
306  for(auto itr = opHitList.begin(); itr != opHitList.end(); ++itr) {
307  if(*itkid == (*itr).first) tmpOpHits.push_back((*itr).second);
308  }
309  truOpHits.push_back(tmpOpHits);
310  }
311  return truOpHits;
312  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double PeakTime() const
Definition: OpHit.h:64
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
double Width() const
Definition: OpHit.h:66
const geo::GeometryCore * fGeom
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
int OpChannel() const
Definition: OpHit.h:62
const std::vector< sim::TrackSDP > OpDetToTrackSDPs(int const &OpDetNum, double const &opHit_start_time, double const &opHit_end_time) const
const art::Ptr< simb::MCTruth > & cheat::PhotonBackTracker::TrackIDToMCTruth ( int const &  id) const

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

200  {
201  shouldThisFail();
202  // find the entry in the MCTruth collection for this track id
203  size_t mct = fTrackIDToMCTruthIndex.find(abs(id))->second;
204 
205  if(/* mct < 0 || */ mct > fMCTruthList.size() )
206  throw cet::exception("PhotonBackTracker") << "attempting to find MCTruth index for "
207  << "out of range value: " << mct
208  << "/" << fMCTruthList.size() << "\n";
209 
210  return fMCTruthList[mct];
211  }
std::map< int, int > fTrackIDToMCTruthIndex
map of track ids to MCTruthList entry
T abs(T value)
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 189 of file old.PhotonBackTracker_service.cc.

190  {
191  shouldThisFail();
192  // get the mother id from the particle navigator
193  // the EveId was adopted in the Rebuild method
194 
195  return this->TrackIDToParticle(fParticleList.EveId(abs(id)));
196  }
const simb::MCParticle * TrackIDToParticle(int const &id) const
T abs(T value)
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
const simb::MCParticle* cheat::PhotonBackTracker::TrackIDToMotherParticle ( int const &  id) const
const std::vector< art::Ptr< recob::OpHit > > cheat::PhotonBackTracker::TrackIdToOpHits_Ps ( int const &  tkId,
std::vector< art::Ptr< recob::OpHit >> const &  hitsIn 
)

Definition at line 270 of file PhotonBackTracker.cc.

271  {
272  //One would think we would want to have this function defined, and call this function in the std::vector<tkids> to opHits, but that would require more loops (and a higher overhead.) Instead, to provide this, we will just call the existing std::vector<tkids>ToOpHits with an input of 1.
273  std::vector<int> tkidFake(1, tkId);
274  //std::vector<art::Ptr<recob::OpHit>> retVec = (this->TrackIdsToOpHits_Ps(tkidFake, hitsIn)).at(0);
275  // return (this->TrackIdsToOpHits_Ps(tkidFake, hitsIn));
276  const std::vector<art::Ptr<recob::OpHit>> out = (this->TrackIdsToOpHits_Ps(tkidFake, hitsIn)).at(0);
277  return out;
278  }
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 simb::MCParticle * cheat::PhotonBackTracker::TrackIDToParticle ( int const &  id) const

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

174  {
175  shouldThisFail();
177 
178  if(part_it == fParticleList.end()){
179  mf::LogWarning("PhotonBackTracker") << "can't find particle with track id "
180  << id << " in sim::ParticleList"
181  << " returning null pointer";
182  return 0;
183  }
184 
185  return part_it->second;
186  }
intermediate_table::const_iterator const_iterator
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 214 of file old.PhotonBackTracker_service.cc.

215  {
216  shouldThisFail();
217  std::vector<sim::SDP> sdps;
218 
219  // loop over all sim::OpDetBacktrackerRecords and fill a vector
220  // of sim::SDP objects for the given track id
221  for(size_t sc = 0; sc < cOpDetBacktrackerRecords.size(); ++sc){
222  const auto & pdTimeSDPmap = cOpDetBacktrackerRecords[sc]->timePDclockSDPsMap();
223 
224  // loop over the SDPMAP
225  for(auto mapitr = pdTimeSDPmap.begin(); mapitr != pdTimeSDPmap.end(); mapitr++){
226 
227  // loop over the vector of SDP objects.
228  const std::vector<sim::SDP>& sdpvec = (*mapitr).second;
229  for(size_t iv = 0; iv < sdpvec.size(); ++iv){
230  if( abs(sdpvec[iv].trackID) == id) sdps.push_back(sdpvec[iv]);
231  }
232 
233  } // end loop over map from sim::OpDetBacktrackerRecord
234  } // end loop over sim::OpDetBacktrackerRecords
235 
236  return sdps;
237  }
T abs(T value)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
std::vector<sim::SDP> cheat::PhotonBackTracker::TrackIDToSimSDP ( int const &  id) const
const std::vector< const sim::SDP * > cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps ( int const &  id)

Definition at line 95 of file PhotonBackTracker.cc.

96  {
97  std::vector< const sim::SDP* > sdp_Ps;
98  for(size_t odet=0; odet<priv_OpDetBTRs.size(); ++odet){
99  const auto & pdTimeSDPmap = priv_OpDetBTRs[odet]->timePDclockSDPsMap();
100  for(auto mapitr = pdTimeSDPmap.begin(); mapitr != pdTimeSDPmap. end(); mapitr++){
101  std::vector<sim::SDP> const& sdpvec = (*mapitr).second;
102  for(size_t iv = 0; iv < sdpvec.size(); ++iv){
103  // const sim::SDP* const sdp_P = &sdpvec[iv];
104  if( abs(sdpvec[iv].trackID) == id) sdp_Ps.push_back(&(sdpvec[iv]));
105  }
106  } // end loop over map from sim::OpDetBacktrackerRecord
107 
108 
109  }// end loop over sim::OpDetBacktrackerRecords
110  return sdp_Ps;
111  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
T abs(T value)
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > priv_OpDetBTRs
const std::vector< const sim::SDP * > cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps ( int const &  id,
geo::View_t const &  view 
)

Definition at line 114 of file PhotonBackTracker.cc.

115  {
116  throw cet::exception("PhotonBackTracker")
117  <<"PhotonBackTracker is not equiped to handle geo::Views.";
118  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

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

all the OpDetBacktrackerRecords for the event

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

double cheat::PhotonBackTracker::fDelay
private

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

const double cheat::PhotonBackTracker::fDelay
private

Definition at line 245 of file PhotonBackTracker.h.

std::string cheat::PhotonBackTracker::fG4ModuleLabel
private

label for geant4 module

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

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

Definition at line 246 of file PhotonBackTracker.h.

const geo::GeometryCore* cheat::PhotonBackTracker::fGeom
private

Definition at line 243 of file PhotonBackTracker.h.

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

all the MCTruths for the event

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

double cheat::PhotonBackTracker::fMinOpHitEnergyFraction
private

minimum fraction of energy a track id has to

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

const double cheat::PhotonBackTracker::fMinOpHitEnergyFraction
private

Definition at line 249 of file PhotonBackTracker.h.

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

Definition at line 248 of file PhotonBackTracker.h.

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

Definition at line 247 of file PhotonBackTracker.h.

sim::ParticleList cheat::PhotonBackTracker::fParticleList
private

ParticleList to map track ID to sim::Particle.

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

const cheat::ParticleInventory* cheat::PhotonBackTracker::fPartInv
private

Definition at line 242 of file PhotonBackTracker.h.

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

map of track ids to MCTruthList entry

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

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 185 of file old.PhotonBackTracker.h.

geo::GeometryCore const * cheat::PhotonBackTracker::geom = lar::providerFrom<geo::Geometry>()
private

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

bool cheat::PhotonBackTracker::have_complained
private

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

std::vector<art::Ptr<sim::OpDetBacktrackerRecord> > cheat::PhotonBackTracker::priv_OpDetBTRs
mutableprivate

Definition at line 250 of file PhotonBackTracker.h.

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

Definition at line 251 of file PhotonBackTracker.h.


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