Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cheat::BackTracker Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-14/MCCheater/BackTracker.h"

Classes

struct  Params
 
class  RawWeightedHit
 Helper for HitCollectionEfficiency and HitCollectionPurity. More...
 

Public Types

using Parameters = art::ServiceTable< Params >
 

Public Member Functions

 BackTracker (const Parameters &params, art::ActivityRegistry &reg)
 
 ~BackTracker ()
 
void preProcessEvent (art::Event const &evt, art::ScheduleContext)
 
void Rebuild (art::Event const &evt)
 
bool HaveTruthInfo () const
 Is this a file with truth info in? (Is BackTracker going to be any use to you?) More...
 
const std::vector< sim::PhotonSignalCellToPhotonSignal (unsigned int const &plane, unsigned int const &cell) const
 Returns the PhotonSignals contributing the signal in the specified cell. WARNING: Use with extreme caution! Most users should use HitToPhotonSignal instead. Only use the cell version if you really want to know ALL the photon signals in the cell for the entire time window, NOT time-associated with the hit. More...
 
const std::vector< sim::PhotonSignalHitToPhotonSignal (const art::Ptr< rb::CellHit > &hit) const
 Returns the PhotonSignals contributing the signal in the specified hit. More...
 
const std::vector< sim::FLSHitCellToFLSHit (unsigned int const &plane, unsigned int const &cell) const
 Returns the FLSHits contributing the signal in the specified cell. WARNING: Use with extreme caution! Most users should use HitToFLSHit instead. Only use the cell version if you really want to know ALL the FLSHits in the cell for the entire time window, NOT time-associated with the hit. More...
 
std::vector< sim::FLSHitHitToFLSHit (const rb::CellHit &hit) const
 All the FLSHits that contributed to this hit, sorted from most to least light. More...
 
std::vector< sim::FLSHitHitToFLSHit (const art::Ptr< rb::CellHit > &hit) const
 
std::vector< sim::FLSHitParticleToFLSHit (const int &trackID) const
 All the FLSHits that were created by the track id trackID, sorted from most to least light. More...
 
std::vector< sim::FLSHitParticleToFLSHit (const int trackID, const int pdg) const
 All the FLSHits that were created by the track id trackID, which also have a particular pdg. Most users should use the other version of this function. However, sometimes when our truth is condensed, the same mother track ID is assigned to FLS hits made by non-important daughters, who can have different PDG values. An example of this is a muon track, whose delta rays often have the track id of the mother muon. By using this version of the function, you can ensure you are looking only at the FLS hits deposited by the muon. More...
 
const double EnergyFromTrackId (const art::Ptr< rb::CellHit > &hit, int trackId, bool useBirksE=false) const
 The total energy deposited in this cell by all FLSHits with this trackId. More...
 
const sim::ParticleHitToParticle (art::Ptr< rb::CellHit > const &hit, bool quiet=false) const
 Returns the sim::Particle object contributing the most light to the specified rb::CellHit. More...
 
const sim::ParticleHitToParticle (const rb::CellHit &hit, bool quiet=false) const
 Returns the sim::Particle object contributing the most light to the specified rb::CellHit. More...
 
bool IsNoise (const art::Ptr< rb::CellHit > &hit) const
 Is this hit not associated with any particles? More...
 
bool IsNoise (const rb::CellHit &hit) const
 Is this hit not associated with any particles? More...
 
bool IsHitsNoise (std::vector< art::Ptr< rb::CellHit > > const &hits) const
 Of this collection of hits, is it mostly noise or physics hits? True indicates noise. More...
 
const sim::ParticleTrackIDToParticle (int const &id) const
 Returns a pointer to the sim::Particle object corresponding to the given TrackID. More...
 
const sim::ParticleTrackIDToMotherParticle (int const &id) const
 
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth (int const &id) const
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth (const sim::Particle *p) const
 
std::vector< const sim::Particle * > MCTruthToParticles (art::Ptr< simb::MCTruth > const &mct) const
 
TVector3 HitToXYZ (art::Ptr< rb::CellHit > const &hit, bool useBirksE=false) const
 Returns the XYZ position of the energy deposition for a given hit. More...
 
std::vector< const sim::Particle * > HitsToParticle (const std::vector< const rb::CellHit * > &hits) const
 Returns vector of sim::Particle objects contributing to the given collection of hits. More...
 
std::vector< const sim::Particle * > HitsToParticle (const std::vector< rb::CellHit > &hits) const
 
std::vector< const sim::Particle * > HitsToParticle (const std::vector< art::Ptr< rb::CellHit >> &hits) const
 
std::vector< const sim::Particle * > HitsToParticle (const art::PtrVector< rb::CellHit > &hits) const
 
std::vector< TrackIDEHitsToTrackIDE (const std::vector< const rb::CellHit * > &hits, bool useBirksE=false) const
 Returns vector of TrackIDE structs contributing to the given collection of hits. More...
 
std::vector< TrackIDEHitsToTrackIDE (const std::vector< rb::CellHit > &hits, bool useBirksE=false) const
 
std::vector< TrackIDEHitsToTrackIDE (const std::vector< art::Ptr< rb::CellHit >> &hits, bool useBirksE=false) const
 
std::vector< TrackIDEHitsToTrackIDE (const art::PtrVector< rb::CellHit > &hits, bool useBirksE=false) const
 
std::vector< TrackIDEHitToTrackIDE (const rb::CellHit &hit, bool useBirksE=false) const
 Convenience function. HitsToTrackIDE but for a single hit. More...
 
std::vector< TrackIDEHitToTrackIDE (const art::Ptr< rb::CellHit > &hit, bool useBirksE=false) const
 
double HitCollectionPurity (const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 Returns the fraction of hits in a collection that come from the specified Geant4 track ids. More...
 
double HitCollectionPurity (const std::set< int > &trackIDs, const std::vector< const rb::CellHit * > &hits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 Returns the fraction of hits in a collection that come from the specified Geant4 track ids. More...
 
double HitCollectionPurity (const std::set< int > &trackIDs, const std::vector< rb::CellHit > &hits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 
double HitCollectionPurity (const std::set< int > &trackIDs, const std::vector< art::Ptr< rb::CellHit >> &hits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 
double HitCollectionPurity (const std::set< int > &trackIDs, const art::PtrVector< rb::CellHit > &hits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are represented in a collection of weighted hits. More...
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< rb::CellHit > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< art::Ptr< rb::CellHit >> &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const art::PtrVector< rb::CellHit > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< const rb::CellHit * > &hits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 Returns the fraction of all hits in an event from a specific set of Geant4 track IDs that are represented in a collection of hits. More...
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< rb::CellHit > &hits, const std::vector< rb::CellHit > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< art::Ptr< rb::CellHit >> &hits, const std::vector< art::Ptr< rb::CellHit >> &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
double HitCollectionEfficiency (std::set< int > trackIDs, const art::PtrVector< rb::CellHit > &hits, const art::PtrVector< rb::CellHit > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 
bool PassMuonCuts (int trackID, art::PtrVector< rb::CellHit > const &hits) const
 Tool for NumuEAna that allows one to see if primary muon (or any track ID you feed the function) contributes to enough hits in the slice to pass the hit cut. It is currently set at 4 hits in each view. More...
 
std::vector< intSliceToNeutrinoIndex (const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
 Given a collection of hits (often a slice), returns vector of neutrino indices corresponding to the vector from SliceToNeutrinoInteractions. More...
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
 Given a collection of hits (often a slice), returns vector of structures of neutrino interactions, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. More...
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const std::vector< rb::CellHit > &sliceHits, const std::vector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const std::vector< art::Ptr< rb::CellHit >> &sliceHits, const std::vector< art::Ptr< rb::CellHit >> &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const art::PtrVector< rb::CellHit > &sliceHits, const art::PtrVector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< art::Ptr< rb::CellHit >> &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToNeutrinoInteractions (const art::Ptr< rb::Cluster > &sliceCluster, const art::PtrVector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< intSliceToOrderedNuIds (const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
 Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu. More...
 
std::vector< intSliceToOrderedNuIdsByEff (const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable) const
 
std::vector< intSliceToOrderedNuIdsByPur (const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable) const
 
std::vector< intSliceToOrderedNuIdsByEffPur (const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable) const
 
std::vector< intSliceToOrderedNuIdsByEnergy (const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
 Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics. More...
 
std::vector< NeutrinoEffPurSliceToMCTruth (const std::vector< rb::CellHit > &sliceHits, const std::vector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const std::vector< art::Ptr< rb::CellHit >> &sliceHits, const std::vector< art::Ptr< rb::CellHit >> &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const art::PtrVector< rb::CellHit > &sliceHits, const art::PtrVector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const art::Ptr< rb::Cluster > &sliceCluster, const std::vector< art::Ptr< rb::CellHit >> &allHits, bool sortPur=false) const
 
std::vector< NeutrinoEffPurSliceToMCTruth (const art::Ptr< rb::Cluster > &sliceCluster, const art::PtrVector< rb::CellHit > &allHits, bool sortPur=false) const
 
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable (const std::vector< const rb::Cluster * > &sliceList) const
 Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures of MCTruth, efficiency, and purity of that MCTruth interaction relative to the slice. The returned vector is the same size as the total number of slices, including the noise slice, which is treated the same as any other slice. It is sorted in the same order as the slice list. For each entry, there is a vector of NeutrinoEffPurs. This vector is the same size as the MCTruth list. It is sorted in the same order as the MCTruth list. Every slice/MCTruth pair shows up, even if the contribution is zero. Efficiency is defined as FLS energy from a MCTruth in a slice / total FLS energy from a MCTruth in event. This function is agnostic to MCTruth and treates them all the same, including those without neutrino interactions, i.e. cosmics. More...
 
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable (const std::vector< rb::Cluster > &sliceList) const
 
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable (const std::vector< art::Ptr< rb::Cluster >> &sliceList) const
 
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable (const art::PtrVector< rb::Cluster > &sliceList) const
 
std::vector< ParticleEffPurTracksToParticles (const std::vector< const rb::Track * > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< const rb::CellHit * > &allHits) const
 Given a collection of reconstructed tracks, this method finds the best match for each reco track to the input track id particles. More...
 
std::vector< ParticleEffPurTracksToParticles (const std::vector< rb::Track > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< rb::CellHit > &allHits) const
 
std::vector< ParticleEffPurTracksToParticles (const std::vector< art::Ptr< rb::Track >> &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< art::Ptr< rb::CellHit >> &allHits) const
 
std::vector< ParticleEffPurTracksToParticles (const art::PtrVector< rb::Track > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const art::PtrVector< rb::CellHit > &allHits) const
 
std::vector< ParticleEffPurTracksToParticles (const std::vector< art::Ptr< rb::Track >> &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const art::PtrVector< rb::CellHit > &allHits) const
 
std::vector< NeutrinoWithIndexallNeutrinoInteractions () const
 Function primarily for CAFMaker - returns a vector of all MCTruth interactions along with their truth vector position. More...
 
std::vector< NeutrinoWithIndexallMCTruth () const
 
const sim::ParticleNavigatorParticleNavigator () const
 Get a reference to the ParticleNavigator. More...
 
const std::set< intGetTrackIDList () const
 Get all G4 track ids present in the event. More...
 
std::vector< rb::ClusterClusterByTruth (std::vector< art::Ptr< rb::CellHit > > const &hits)
 : More...
 
rb::Cluster MCTruthToCluster (art::Ptr< simb::MCTruth > const &truth, std::vector< art::Ptr< rb::CellHit > > const &hits)
 : More...
 
void HitToParticlesMap (const std::vector< const rb::Cluster * > &sliceList, const int &sliceIdx)
 
void HitToParticlesMap (const std::vector< rb::Cluster > &sliceList, const int &sliceIdx)
 
void HitToParticlesMap (const std::vector< art::Ptr< rb::Cluster >> &sliceList, const int &sliceIdx)
 
void HitToParticlesMap (const art::PtrVector< rb::Cluster > &sliceList, const int &sliceIdx)
 
cheat::ParticleEffPur ClusterToParticle (const std::vector< const rb::Cluster * > &sliceList, const std::vector< const rb::CellHit * > &hits, const int &sliceIdx)
 
cheat::ParticleEffPur ClusterToParticle (const std::vector< rb::Cluster > &sliceList, const std::vector< rb::CellHit > &hits, const int &sliceIdx)
 
cheat::ParticleEffPur ClusterToParticle (const std::vector< art::Ptr< rb::Cluster >> &sliceList, const std::vector< art::Ptr< rb::CellHit >> &hits, const int &sliceIdx)
 
cheat::ParticleEffPur ClusterToParticle (const art::PtrVector< rb::Cluster > &sliceList, const art::PtrVector< rb::CellHit > &hits, const int &sliceIdx)
 
float CalcEscapingEnergy (const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
 A function to calculate the amount of energy from a given MCParticle which is not contained in the detector. Will return the energy the particle had when it exited the detector. Should a particle stop in the detector then the "Escaping energy" is 0. It has the option of returning the energy that a particle deposited energy in the detector. This is calclated from EnEnt - EnEsc, this has the deficiency that depositions from daughters may be doubly counted, however this is what the function CalcDaughterEscapingEnergy is for. There is a flag "UseMCPart", this controls whether to use the saved MCParticles, or to use the more accurate GEANT4 information, which takes into account all daughter particles. Currently it is defaulted to true, ie use the MCParticles, as the GEANT4 info is not usually in the event record yet. More...
 
float CalcEscapingEnergy (const sim::Particle &Par, float &EnDep, bool UseMCPart=true, std::string G4Label="trueens")
 
float CalcDaughterEscapingEnergy (const sim::Particle &Par)
 A function to be used in conjunction with CalcTotalEscapingEnergy to calculate the energy which the daughters of a a given sim::Particle deposited in the detector. More...
 
float CalcTotalEscapingEnergy (const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
 An extension of CalcEscapingEnergy which also takes into account the energy which the daughters of given sim::Particle's deposit in the detector. To do this it calls CalcDaughterEscapingEnergy, which in turn calls CalcEscapingEnergy for all of the daughters. More...
 
float CalcTotalEscapingEnergy (const sim::Particle &Par, float &ParEnDep, bool UseMCPart=true, std::string G4Label="trueens")
 
bool InterceptsDetector (const sim::Particle &Par, int &TrajEnt, int &TrajEx)
 A function which returns the trajectory point at which the particle first enters and leave the detector volume. The trajectory point is returned so that the user can determine the energies etc which the particle had at this point. Should the particle have been generated in the detector then TrajEnt == 0 will be returned. Should the particle stop in the detector then TrajEx == NumberTrajectoryPoints()-1 will be returned. Should the particle never enter the detector then holder values TrajEnter == TrajEx == -5 will be returned. More...
 

Static Public Member Functions

static bool sort_eff (const NeutrinoEffPur &a, const NeutrinoEffPur &b)
 Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest efficiency first. More...
 
static bool sort_pur (const NeutrinoEffPur &a, const NeutrinoEffPur &b)
 Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest purity first. More...
 
static bool sort_idxeff (const std::pair< int, NeutrinoEffPur > &a, const std::pair< int, NeutrinoEffPur > &b)
 Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest efficiency first. More...
 
static bool sort_idxpur (const std::pair< int, NeutrinoEffPur > &a, const std::pair< int, NeutrinoEffPur > &b)
 Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest purity first. More...
 

Private Member Functions

template<class T >
std::vector< const T * > PtrVecToVecRawPtr (const art::PtrVector< T > &xs) const
 Helper function for implementing overloads. More...
 
template<class T >
std::vector< const T * > VecPtrToVecRawPtr (const std::vector< art::Ptr< T >> &xs) const
 
template<class T >
std::vector< const T * > VecToVecRawPtr (const std::vector< T > &xs) const
 
double HitCollectionPurity (const std::set< int > &trackIDs, const std::vector< RawWeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
 Internal implementation of public HitCollectionPurity. More...
 
double HitCollectionEfficiency (const std::set< int > &trackIDs, const std::vector< RawWeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
 Internal implementation of public HitCollectionEfficiency. More...
 
bool CloseInTime (const rb::CellHit &chit, const sim::PhotonSignal &phot) const
 Internal helper, decides if a PhotonSignal and CellHit are close enough to match. More...
 
void AccumulateHitContributions (rb::CellHit const &hit, std::map< int, int > &idToNPhot) const
 Internal helper, adds the contributions from each particle in this cell to the map. More...
 

Private Attributes

Params fParams
 
bool fHaveTruthInfo
 Set by Rebuild. More...
 
novadaq::cnv::DetId fDetID
 detector id More...
 
std::unordered_map< geo::OfflineChan, std::list< sim::FLSHit > > fCellToFLSHit
 map of FLSHits in each cell in event More...
 
std::unordered_map< int, std::list< sim::FLSHit > > fTrackIDToFLSHit
 map of G4 track ids to FLSHits More...
 
std::unordered_map< geo::OfflineChan, std::vector< sim::PhotonSignal > > fCellToPhotonSignal
 map of PhotonSignals in each cell in event More...
 
sim::ParticleNavigator fParticleNav
 Particle navigator to map track ID to Particle. More...
 
std::set< intfTrackIDs
 G4 track ids for all particles in the events. More...
 
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
 all the MCTruths for this event More...
 
std::map< int, intfTrackIDToMCTruthIndex
 map of track id values to MCTruthList entry More...
 
std::vector< art::Ptr< sim::TrueEnergy > > fTrueEnergyList
 all the TrueEnergy's for this event More...
 
std::map< int, intfTrackIDToTrueEIndex
 map of track id values to TrueEnergy entry More...
 
std::map< double, std::vector< cheat::TrackIDE > > fCellToIDs
 
std::map< int, float > fIdToEnergy
 
int fSliceIDForHitParticleMap
 
int fNumTrueEnergyWarnings
 

Detailed Description

Many functions come in four variants. The core implementation is in terms of vector<const T*>, which is the common basis all the others can be converted to. If you have an art::Handle<vector<T>> you can just dereference it to get this type. If you happen to have a vector<T> or vector<Ptr<T>> or PtrVector<T>, overloads are provided so that those are just as easy to work with.

Definition at line 95 of file BackTracker.h.

Member Typedef Documentation

Definition at line 116 of file BackTracker.h.

Constructor & Destructor Documentation

cheat::BackTracker::BackTracker ( const Parameters params,
art::ActivityRegistry reg 
)

Definition at line 70 of file BackTracker_service.cc.

References fNumTrueEnergyWarnings, preProcessEvent(), and art::ActivityRegistry::sPreProcessEvent.

72  : fParams(params()), fHaveTruthInfo(false)
73  {
76  }
void preProcessEvent(art::Event const &evt, art::ScheduleContext)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
bool fHaveTruthInfo
Set by Rebuild.
Definition: BackTracker.h:939
cheat::BackTracker::~BackTracker ( )

Definition at line 79 of file BackTracker_service.cc.

80  {
81  }

Member Function Documentation

void cheat::BackTracker::AccumulateHitContributions ( rb::CellHit const &  hit,
std::map< int, int > &  idToNPhot 
) const
private

Internal helper, adds the contributions from each particle in this cell to the map.

Definition at line 1500 of file BackTracker_service.cc.

References rb::CellHit::Cell(), CloseInTime(), fCellToPhotonSignal, MECModelEnuComparisons::i, it, sim::PhotonSignal::NPhoton(), rb::CellHit::Plane(), and sim::PhotonSignal::TrackId().

Referenced by HitsToParticle(), HitToFLSHit(), and HitToParticle().

1502  {
1503  auto it = fCellToPhotonSignal.find(geo::OfflineChan(hit.Plane(), hit.Cell()));
1504  // Nothing to accumulate from this cell
1505  if(it == fCellToPhotonSignal.end()) return;
1506 
1507  // Candidate photons, in that they're in the right cell.
1508  const std::vector<sim::PhotonSignal>& phots = it->second;
1509 
1510  // For every photon that's sufficiently in time with the hit,
1511  // accumulate its energy into the relevant trackID.
1512  for(unsigned int i = 0; i < phots.size(); ++i){
1513  const sim::PhotonSignal& phot = phots[i];
1514  if(CloseInTime(hit, phot)){
1515  idToNPhot[phot.TrackId()] += phot.NPhoton();
1516  }
1517  }
1518  }
std::unordered_map< geo::OfflineChan, std::vector< sim::PhotonSignal > > fCellToPhotonSignal
map of PhotonSignals in each cell in event
Definition: BackTracker.h:945
set< int >::iterator it
int TrackId() const
Definition: PhotonSignal.h:33
int NPhoton() const
Definition: PhotonSignal.h:30
Definition: structs.h:12
A (plane, cell) pair.
Definition: OfflineChan.h:17
bool CloseInTime(const rb::CellHit &chit, const sim::PhotonSignal &phot) const
Internal helper, decides if a PhotonSignal and CellHit are close enough to match. ...
std::vector< NeutrinoWithIndex > cheat::BackTracker::allMCTruth ( ) const

Definition at line 1456 of file BackTracker_service.cc.

References fMCTruthList.

Referenced by tut::RecoValidationTutorial::analyze(), cvn::CVNEventDump::analyze(), cvn::CVNCosmicEventDump::analyze(), earms::ElasticArmsValidate::analyze(), cvn::CVNEventProngDump::analyze(), fuzz::FuzzyKValidate::analyze(), bpf::BPFCVNAna::analyze(), cvn::CVNAddTrainingData::produce(), fuzz::FuzzyKVertex::produce(), caf::CAFMaker::produce(), skim::SkimmingUtils::SliceMCTruthAssociation(), and SlicesToMCTruthsTable().

1457  {
1458  std::vector <NeutrinoWithIndex> allTruth;
1459 
1460  for (unsigned int s = 0; s < fMCTruthList.size(); s++){
1461  const art::Ptr<simb::MCTruth> neutrinoInteraction = fMCTruthList[s];
1462  NeutrinoWithIndex neutrino = {neutrinoInteraction, s};
1463  allTruth.push_back(neutrino);
1464  }
1465 
1466  return allTruth;
1467  }
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
const XML_Char * s
Definition: expat.h:262
std::vector< NeutrinoWithIndex > cheat::BackTracker::allNeutrinoInteractions ( ) const

Function primarily for CAFMaker - returns a vector of all MCTruth interactions along with their truth vector position.

Definition at line 1439 of file BackTracker_service.cc.

References fMCTruthList, and simb::MCTruth::NeutrinoSet().

Referenced by cheat::TestTrackIds::analyze(), and slid::LIDTraining::analyze().

1440  {
1441  std::vector <NeutrinoWithIndex> allNeutrinoInteractions;
1442 
1443  for (unsigned int s = 0; s < fMCTruthList.size(); s++){
1444  const art::Ptr<simb::MCTruth> neutrinoInteraction = fMCTruthList[s];
1445  if(!neutrinoInteraction->NeutrinoSet())
1446  continue;
1447 
1448  NeutrinoWithIndex neutrino = {neutrinoInteraction, s};
1449  allNeutrinoInteractions.push_back(neutrino);
1450  }
1451 
1452  return allNeutrinoInteractions;
1453  }
std::vector< NeutrinoWithIndex > allNeutrinoInteractions() const
Function primarily for CAFMaker - returns a vector of all MCTruth interactions along with their truth...
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
const XML_Char * s
Definition: expat.h:262
bool NeutrinoSet() const
Definition: MCTruth.h:78
float cheat::BackTracker::CalcDaughterEscapingEnergy ( const sim::Particle Par)

A function to be used in conjunction with CalcTotalEscapingEnergy to calculate the energy which the daughters of a a given sim::Particle deposited in the detector.

Definition at line 1762 of file BackTracker_service.cc.

References CalcEscapingEnergy(), simb::MCParticle::Daughter(), std::max(), simb::MCParticle::NumberDaughters(), and TrackIDToParticle().

Referenced by CalcTotalEscapingEnergy().

1762  {
1763  float DauEsc = 0.;
1764  int NumDaught = Par.NumberDaughters();
1765  for (int dau=0; dau<NumDaught; ++dau) {
1766  const sim::Particle* ThisDau = TrackIDToParticle( Par.Daughter( dau ) );
1767  float ThisEsc = CalcEscapingEnergy( (*ThisDau), true );
1768  DauEsc += std::max((float)0., ThisEsc);
1769  /*
1770  std::cout << "\tDaughter " << dau << " of " << NumDaught << " was a " << ThisDau->PdgCode() << ", TrackId " << ThisDau->TrackId()
1771  << ", it had " << ThisDau->NumberDaughters() << " daughters itself. "
1772  << " EscEn for this particle = " << ThisEsc << " ==> DauEsc = " << DauEsc
1773  << std::endl;
1774  */
1775  if ( ThisDau->NumberDaughters() ) {
1776  //std::cout << "\t\t****** This particle has daughters, so recall the function... ******" << std::endl;
1777  float DaughtEsc = CalcDaughterEscapingEnergy( (*ThisDau) );
1778  DauEsc += DaughtEsc;
1779  //std::cout << "\t\t****** The sum of all EEscs was " << DaughtEsc << " ==> DauEsc is " << DauEsc << std::endl;
1780  } // If this particle has daughters itself
1781  } // Loop through the daughters of my particle.
1782  //std::cout << "\n\tAt the end of all of that, the sum of all escaping daughters was " << DauEsc << std::endl;
1783  return DauEsc;
1784  } // end of CalcDaughterEscapingEnergy
T max(const caf::Proxy< T > &a, T b)
float CalcEscapingEnergy(const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
A function to calculate the amount of energy from a given MCParticle which is not contained in the de...
float CalcDaughterEscapingEnergy(const sim::Particle &Par)
A function to be used in conjunction with CalcTotalEscapingEnergy to calculate the energy which the d...
int NumberDaughters() const
Definition: MCParticle.h:216
int Daughter(const int i) const
Definition: MCParticle.cxx:112
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
float cheat::BackTracker::CalcEscapingEnergy ( const sim::Particle Par,
bool  UseMCPart = true,
std::string  G4Label = "trueens" 
)

A function to calculate the amount of energy from a given MCParticle which is not contained in the detector. Will return the energy the particle had when it exited the detector. Should a particle stop in the detector then the "Escaping energy" is 0. It has the option of returning the energy that a particle deposited energy in the detector. This is calclated from EnEnt - EnEsc, this has the deficiency that depositions from daughters may be doubly counted, however this is what the function CalcDaughterEscapingEnergy is for. There is a flag "UseMCPart", this controls whether to use the saved MCParticles, or to use the more accurate GEANT4 information, which takes into account all daughter particles. Currently it is defaulted to true, ie use the MCParticles, as the GEANT4 info is not usually in the event record yet.

Definition at line 1695 of file BackTracker_service.cc.

Referenced by CalcDaughterEscapingEnergy(), and CalcTotalEscapingEnergy().

1695  {
1696  float TempVar = -5;
1697  return CalcEscapingEnergy( Par, TempVar, UseMCPart, G4Label );
1698  }// end of CalcEscapingEnergy
float CalcEscapingEnergy(const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
A function to calculate the amount of energy from a given MCParticle which is not contained in the de...
float cheat::BackTracker::CalcEscapingEnergy ( const sim::Particle Par,
float &  EnDep,
bool  UseMCPart = true,
std::string  G4Label = "trueens" 
)

A function to calculate the amount of energy from a given MCParticle which is not contained in the detector. Will return the energy the particle had when it exited the detector. Should a particle stop in the detector then the "Escaping energy" is 0. It has the option of returning the energy that a particle deposited energy in the detector. This is calclated from EnEnt - EnEsc, this has the deficiency that depositions from daughters may be doubly counted, however this is what the function CalcDaughterEscapingEnergy is for. There is a flag "UseMCPart", this controls whether to use the saved MCParticles, or to use the more accurate GEANT4 information, which takes into account all daughter particles. Currently it is defaulted to true, ie use the MCParticles, as the GEANT4 info is not usually in the event record yet.

Definition at line 1702 of file BackTracker_service.cc.

References simb::MCParticle::E(), check_time_usage::float, fTrackIDToTrueEIndex, fTrueEnergyList, InterceptsDetector(), simb::MCParticle::Mass(), simb::MCParticle::NumberTrajectoryPoints(), sim::TrueEnergy::TotalDepEnergy(), sim::TrueEnergy::TotalEscEnergy(), and simb::MCParticle::TrackId().

1702  {
1703  /// A function to calculate the amount of energy from a given MCParticle which is not contained in the detector.
1704  /// Will return the energy the particle had when it exited the detector.
1705  /// Should a particle stop in the detector then the "Escaping energy" is 0.
1706  /// It has the option of returning the energy that a particle deposited energy in the detector.
1707  /// This is calclated from EnEnt - EnEsc, this has the deficiency that depositions from daughters may be doubly counted,
1708  /// however this is what the function CalcDaughterEscapingEnergy is for.
1709  /// There is a flag "UseMCPart", this controls whether to use the saved MCParticles, or to use the more accurate GEANT4
1710  /// information, which takes into account all daughter particles.
1711  /// Currently it is defaulted to true, ie use the MCParticles, as the GEANT4 info is not usually in the event record yet.
1712 
1713  // Set to some default values.
1714  float EnEsc, EnEnt;
1715  EnEsc = EnEnt = EnDep = -5;
1716 
1717  // --- Do I want to use the information stored in MCParticle?
1718  if (UseMCPart) {
1719  // Make variables to call InterceptsDetector.
1720  int TrajEnter, TrajExit;
1721  TrajEnter = TrajExit = -1;
1722  // Call InterceptsDetector
1723  bool IntDet = InterceptsDetector( Par, TrajEnter, TrajExit );
1724 
1725  // If IntDet == false then the particle never entered the detector, so return 0's.
1726  if (!IntDet) {
1727  return EnEsc;
1728  } else {
1729  // Now work out the energy which the particle deposited...
1730  // Set EnEnt
1731  EnEnt = (float)Par.E( TrajEnter ) - Par.Mass();
1732  // If TrajExit isn't NTraj-1, the particle left the volume then some energy was lost!
1733  // If TrajExit == NTraj-1 then we can just leave EnEsc as 0.
1734  if ( TrajExit != (int)Par.NumberTrajectoryPoints()-1 ) {
1735  EnEsc = (float)Par.E( TrajExit ) - Par.Mass();
1736  }
1737  // The energy deposited is just the entering energy - the exiting energy.
1738  EnDep = EnEnt - EnEsc;
1739  }
1740  // now return
1741  return EnEsc;
1742  } else {
1743  std::map<int, int>::iterator TrEIt = fTrackIDToTrueEIndex.find( Par.TrackId() );
1744  if ( TrEIt != fTrackIDToTrueEIndex.end() ) {
1745  art::Ptr< sim::TrueEnergy > ThisEn = fTrueEnergyList[ TrEIt->second ];
1746  /*
1747  std::cout << "Looking at the sim::TrueEnergy from the data product it is, TrackID " << ThisEn->TrackID() << ", EntEn " << ThisEn->EnteringEnergy()
1748  << ", EscEn " << ThisEn->EscapingEnergy() << ", TotEDep " << ThisEn->TotalDepEnergy() << ", TotEscEn " << ThisEn->TotalEscEnergy()
1749  << std::endl;
1750  */
1751  EnDep = ThisEn->TotalDepEnergy();
1752  return ThisEn->TotalEscEnergy();
1753  } else {
1754  mf::LogWarning("BackTracker") << "Didn't find TrackId " << Par.TrackId() << " in my map of sim::TrueEnergy's, returning -5.";
1755  return -5;
1756  }
1757  }
1758  }// end of CalcEscapingEnergy
double E(const int i=0) const
Definition: MCParticle.h:232
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:217
bool InterceptsDetector(const sim::Particle &Par, int &TrajEnt, int &TrajEx)
A function which returns the trajectory point at which the particle first enters and leave the detect...
double Mass() const
Definition: MCParticle.h:238
float TotalEscEnergy() const
Definition: TrueEnergy.h:40
int TrackId() const
Definition: MCParticle.h:209
std::vector< art::Ptr< sim::TrueEnergy > > fTrueEnergyList
all the TrueEnergy&#39;s for this event
Definition: BackTracker.h:950
std::map< int, int > fTrackIDToTrueEIndex
map of track id values to TrueEnergy entry
Definition: BackTracker.h:951
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
float TotalDepEnergy() const
Definition: TrueEnergy.h:39
Definition: fwd.h:29
float cheat::BackTracker::CalcTotalEscapingEnergy ( const sim::Particle Par,
bool  UseMCPart = true,
std::string  G4Label = "trueens" 
)

An extension of CalcEscapingEnergy which also takes into account the energy which the daughters of given sim::Particle's deposit in the detector. To do this it calls CalcDaughterEscapingEnergy, which in turn calls CalcEscapingEnergy for all of the daughters.

Definition at line 1788 of file BackTracker_service.cc.

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

1788  {
1789  float TempVar = 0.;
1790  return CalcTotalEscapingEnergy( Par, TempVar, UseMCPart, G4Label );
1791  }
float CalcTotalEscapingEnergy(const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
An extension of CalcEscapingEnergy which also takes into account the energy which the daughters of gi...
float cheat::BackTracker::CalcTotalEscapingEnergy ( const sim::Particle Par,
float &  ParEnDep,
bool  UseMCPart = true,
std::string  G4Label = "trueens" 
)

Definition at line 1795 of file BackTracker_service.cc.

References abs(), CalcDaughterEscapingEnergy(), CalcEscapingEnergy(), fTrackIDToTrueEIndex, fTrueEnergyList, simb::MCParticle::Mass(), std::max(), simb::MCParticle::PdgCode(), sim::TrueEnergy::TotalDepEnergy(), sim::TrueEnergy::TotalEscEnergy(), and simb::MCParticle::TrackId().

1795  {
1796  if ( UseMCPart ) {
1797  float ParEDep = 0;
1798  float ParEEsc = CalcEscapingEnergy( Par, ParEDep, UseMCPart, G4Label );
1799  float DauEEsc = CalcDaughterEscapingEnergy( Par );
1800 
1801  float TotEnEsc = std::max((float)0., ParEEsc) + std::max((float)0., DauEEsc);
1802  TotEnDep = ParEDep - DauEEsc;
1803  // --- If negative, then had particle had very little energy --> may need to consider rest mass energy.
1804  if ( TotEnDep < 0 ) {
1805  //std::cout << "\t\t ** TotEnDep is negative " << TotEnDep << ", initially set to 0, but will check Part type. " << std::endl;
1806  // --- Default TotEnDep to 0.
1807  TotEnDep = 0;
1808  // --- If this particle decayed in the detector (ParEdep != 0) then it's likely that the particles it produced left the detector,
1809  // and the sum of their energies will be more than the initial KE of the particle.
1810  // For now I will modify this for some choice particles, not sure how best to do this...
1811  if ( ParEDep != 0 &&
1812  ( abs(Par.PdgCode()) == 11 || // Electron
1813  abs(Par.PdgCode()) == 13 || // Muon
1814  abs(Par.PdgCode()) == 111 || // Pi0
1815  abs(Par.PdgCode()) == 211 || // Pion
1816  abs(Par.PdgCode()) == 321 ) // Kaon
1817  ) {
1818  /*
1819  std::cout << "\t\t ** This particle likely decayed, so adding RestMass of " << Par.Mass()
1820  << " --- TotEnDep = " << ParEDep << " - " << DauEEsc << " + " << Par.Mass() << " = " << ParEDep - DauEEsc + Par.Mass()
1821  << std::endl;
1822  */
1823  TotEnDep = std::max( 0., ParEDep - DauEEsc + Par.Mass() );
1824  }
1825  }
1826  /*
1827  std::cout << "\t***The end of CalcTotalEscapingEnergy -- ParEEsc " << ParEEsc << ", ParEDep " << ParEDep << ", DauEEsc " << DauEEsc << ".\n"
1828  << "\t TotEnEsc = " << ParEEsc << " + " << DauEEsc << " = " << TotEnEsc << ".\n"
1829  << "\t TotEnDep = " << ParEDep << " - " << DauEEsc << " = " << TotEnDep << "."
1830  << std::endl;
1831  */
1832  return TotEnEsc;
1833  } else {
1834  std::map<int, int>::iterator TrEIt = fTrackIDToTrueEIndex.find( Par.TrackId() );
1835  if ( TrEIt != fTrackIDToTrueEIndex.end() ) {
1836  art::Ptr< sim::TrueEnergy > ThisEn = fTrueEnergyList[ TrEIt->second ];
1837  /*
1838  std::cout << "Looking at the sim::TrueEnergy from the data product it is, TrackID " << ThisEn->TrackID() << ", EntEn " << ThisEn->EnteringEnergy()
1839  << ", EscEn " << ThisEn->EscapingEnergy() << ", TotEDep " << ThisEn->TotalDepEnergy() << ", TotEscEn " << ThisEn->TotalEscEnergy()
1840  << std::endl;
1841  */
1842  TotEnDep = ThisEn->TotalDepEnergy();
1843  return ThisEn->TotalEscEnergy();
1844  } else {
1845  mf::LogWarning("BackTracker") << "Didn't find TrackId " << Par.TrackId() << " in my map of sim::TrueEnergy's, returning -5.";
1846  return -5;
1847  }
1848  }
1849  }
T max(const caf::Proxy< T > &a, T b)
int PdgCode() const
Definition: MCParticle.h:211
double Mass() const
Definition: MCParticle.h:238
float CalcEscapingEnergy(const sim::Particle &Par, bool UseMCPart=true, std::string G4Label="trueens")
A function to calculate the amount of energy from a given MCParticle which is not contained in the de...
void abs(TH1 *hist)
float CalcDaughterEscapingEnergy(const sim::Particle &Par)
A function to be used in conjunction with CalcTotalEscapingEnergy to calculate the energy which the d...
float TotalEscEnergy() const
Definition: TrueEnergy.h:40
int TrackId() const
Definition: MCParticle.h:209
std::vector< art::Ptr< sim::TrueEnergy > > fTrueEnergyList
all the TrueEnergy&#39;s for this event
Definition: BackTracker.h:950
std::map< int, int > fTrackIDToTrueEIndex
map of track id values to TrueEnergy entry
Definition: BackTracker.h:951
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
float TotalDepEnergy() const
Definition: TrueEnergy.h:39
Definition: fwd.h:29
const std::vector< sim::FLSHit > cheat::BackTracker::CellToFLSHit ( unsigned int const &  plane,
unsigned int const &  cell 
) const

Returns the FLSHits contributing the signal in the specified cell. WARNING: Use with extreme caution! Most users should use HitToFLSHit instead. Only use the cell version if you really want to know ALL the FLSHits in the cell for the entire time window, NOT time-associated with the hit.

The vector is sorted to return in order of highest contributing Geant4 track to lowest.

Definition at line 332 of file BackTracker_service.cc.

References fCellToFLSHit, it, and MF_LOG_DEBUG.

Referenced by cheat::TestTrackIds::analyze(), and cheat::CheckBackTracking::CheckFLSHitConsistency().

334  {
335  auto it = fCellToFLSHit.find(geo::OfflineChan(plane, cell));
336 
337  if(it == fCellToFLSHit.end()){
338  MF_LOG_DEBUG("BackTracker") << "no collection of sim::FLSHit for "
339  << " plane = " << plane << " cell = " << cell
340  << " probably this was a noise hit, returning an"
341  << " empty vector";
342  const std::vector<sim::FLSHit> empty;
343  return empty;
344  }
345  return std::vector<sim::FLSHit>(it->second.begin(), it->second.end());
346  }
set< int >::iterator it
std::unordered_map< geo::OfflineChan, std::list< sim::FLSHit > > fCellToFLSHit
map of FLSHits in each cell in event
Definition: BackTracker.h:943
A (plane, cell) pair.
Definition: OfflineChan.h:17
#define MF_LOG_DEBUG(id)
const std::vector< sim::PhotonSignal > cheat::BackTracker::CellToPhotonSignal ( unsigned int const &  plane,
unsigned int const &  cell 
) const

Returns the PhotonSignals contributing the signal in the specified cell. WARNING: Use with extreme caution! Most users should use HitToPhotonSignal instead. Only use the cell version if you really want to know ALL the photon signals in the cell for the entire time window, NOT time-associated with the hit.

Sorted from highest signal to lowest (which is probably not much use, since energy from one particle can be split over several signals).

Definition at line 284 of file BackTracker_service.cc.

References fCellToPhotonSignal, it, and MF_LOG_DEBUG.

Referenced by mcchk::CloseInTime::analyze(), calib::PCHitsList::ProcessTrackForBelowThresholdHits(), and calib::PCHitsList::ProcessTrackForFLSHits().

286  {
288 
289  if(it == fCellToPhotonSignal.end()){
290  MF_LOG_DEBUG("BackTracker") << "no collection of sim::PhotonSignal for "
291  << " plane = " << plane << " cell = " << cell
292  << " probably this was a noise hit, returning an"
293  << " empty vector";
294  const std::vector<sim::PhotonSignal> empty;
295  return empty;
296  }
297  return it->second;
298  }
std::unordered_map< geo::OfflineChan, std::vector< sim::PhotonSignal > > fCellToPhotonSignal
map of PhotonSignals in each cell in event
Definition: BackTracker.h:945
set< int >::iterator it
A (plane, cell) pair.
Definition: OfflineChan.h:17
#define MF_LOG_DEBUG(id)
bool cheat::BackTracker::CloseInTime ( const rb::CellHit chit,
const sim::PhotonSignal phot 
) const
private

Internal helper, decides if a PhotonSignal and CellHit are close enough to match.

Definition at line 1471 of file BackTracker_service.cc.

References fDetID, rb::CellHit::GoodTiming(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, sim::PhotonSignal::TimeMean(), and rb::CellHit::TNS().

Referenced by AccumulateHitContributions(), and HitToPhotonSignal().

1472  {
1473  //The constants used to determine this value change depending on detector
1474  //and hit timing reconstruction. See docdb 9092 to see how the current
1475  //constants were determined (May 2013). To redo the study and see if new
1476  //constants are required, use MCCheckOut/CloseInTime_module.cc.
1477 
1478  // Empirically determined as an over-generous width of the timing reconstruction.
1479  double kWindowNs = 1000;
1480  // Empirically determined as the approximate mean bias of the timing reconstruction.
1481  // This is the amount the CellHit is expected to be earlier than the photons.
1482  double kOffsetNs = 350;
1483 
1484  if ((fDetID == novadaq::cnv::kFARDET)&&(chit.GoodTiming())){
1485  kWindowNs = 500;
1486  kOffsetNs = 10;
1487  }
1488 
1489  if ((fDetID == novadaq::cnv::kNEARDET)&&(chit.GoodTiming())){
1490  kWindowNs = 200;
1491  kOffsetNs = 10;
1492  }
1493 
1494  const double dt = chit.TNS()-phot.TimeMean();
1495 
1496  return fabs(dt+kOffsetNs) <= kWindowNs;
1497  }
float TNS() const
Definition: CellHit.h:46
Definition: Cand.cxx:23
Far Detector at Ash River, MN.
Near Detector in the NuMI cavern.
bool GoodTiming() const
Definition: CellHit.h:48
novadaq::cnv::DetId fDetID
detector id
Definition: BackTracker.h:941
double TimeMean() const
Definition: PhotonSignal.h:29
std::vector< rb::Cluster > cheat::BackTracker::ClusterByTruth ( std::vector< art::Ptr< rb::CellHit > > const &  hits)

:

Definition at line 1557 of file BackTracker_service.cc.

References fMCTruthList, fTrackIDToMCTruthIndex, hits(), HitToParticle(), compare_h5_caf::idx, IsNoise(), part, and simb::MCParticle::TrackId().

Referenced by slicer::TruthSlicer::produce().

1558  {
1559  std::vector<rb::Cluster> clusters(fMCTruthList.size()+1);
1560 
1561  for(unsigned int hiti = 0; hiti < hits.size(); ++hiti) {
1562  art::Ptr<rb::CellHit> hit = hits[hiti];
1563 
1564  // If the hit is noise, put it into the last cluster.
1565  if(this->IsNoise(hit)) {
1566  clusters[fMCTruthList.size()].Add(hit);
1567  continue;
1568  }
1569 
1570  const sim::Particle *part = this->HitToParticle(hit);
1571  unsigned int idx = fTrackIDToMCTruthIndex[part->TrackId()];
1572  clusters[idx].Add(hit);
1573 
1574  } // end loop over hits
1575 
1576  // Label the noise slice.
1577  clusters[fMCTruthList.size()].SetNoise(true);
1578 
1579  return clusters;
1580  }
const sim::Particle * HitToParticle(art::Ptr< rb::CellHit > const &hit, bool quiet=false) const
Returns the sim::Particle object contributing the most light to the specified rb::CellHit.
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
int TrackId() const
Definition: MCParticle.h:209
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
std::map< int, int > fTrackIDToMCTruthIndex
map of track id values to MCTruthList entry
Definition: BackTracker.h:949
Definition: structs.h:12
cheat::ParticleEffPur cheat::BackTracker::ClusterToParticle ( const std::vector< const rb::Cluster * > &  sliceList,
const std::vector< const rb::CellHit * > &  hits,
const int sliceIdx 
)

Definition at line 1642 of file BackTracker_service.cc.

References rb::CellHit::Cell(), febshutoff_auto::chan, cheat::ParticleEffPur::efficiency, fCellToIDs, fIdToEnergy, fSliceIDForHitParticleMap, HitToParticlesMap(), maxE, maxID(), cheat::ParticleEffPur::pdg, simb::MCParticle::PdgCode(), rb::CellHit::Plane(), cheat::ParticleEffPur::purity, rawdata::RawDigit::TDC(), cheat::ParticleEffPur::trackID, and TrackIDToParticle().

Referenced by caf::FillParticleTruth().

1645  {
1646 
1647  if(sliceIdx != fSliceIDForHitParticleMap){
1648  HitToParticlesMap(sliceList, sliceIdx);
1649  }
1650 
1651  double totalE = 0.0;
1652  unsigned int nh = hits.size();
1653 
1654  // make a map of how much energy each track ID contributes to
1655  // this cluster. Also keep track of how much total true energy
1656  // there is in this cluster.
1657 
1658  std::map< int, double> idToEnergyInProng;
1659  for(unsigned int ih = 0; ih < nh; ih++){
1660  const rb::CellHit* hit = hits[ih];
1661  double chan = (hit->TDC()*1000000) + (hit->Plane()*1000) + hit->Cell();
1662  std::vector<cheat::TrackIDE> ides = fCellToIDs[chan];
1663  for(auto ide: ides){
1664  idToEnergyInProng[ide.trackID] += ide.energy;
1665  totalE += ide.energy;
1666  }// end loop over ides
1667  }// end loop over cluster hits
1668 
1669  // now find which trackID contributed the most energy to
1670  // the cluster
1671  int maxID = -1;
1672  double maxE = -1.0;
1673 
1674  cheat::ParticleEffPur puff = {-1,-1,-1,-1};
1675  if(idToEnergyInProng.size() == 0)
1676  return puff;
1677 
1678  for(auto idtoe: idToEnergyInProng){
1679  if(idtoe.second > maxE ){
1680  maxE = idtoe.second;
1681  maxID = idtoe.first;
1682  }
1683  }// end loop over trackID to energy map
1684 
1685  puff.trackID = maxID;
1686  puff.purity = maxE/totalE;
1687  puff.efficiency = maxE/fIdToEnergy[maxID];
1688  puff.pdg = TrackIDToParticle(maxID)->PdgCode();
1689 
1690  return puff;
1691  }// end of ClusterToParticle
int PdgCode() const
Definition: MCParticle.h:211
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
void HitToParticlesMap(const std::vector< const rb::Cluster * > &sliceList, const int &sliceIdx)
unsigned short Plane() const
Definition: CellHit.h:39
std::map< double, std::vector< cheat::TrackIDE > > fCellToIDs
Definition: BackTracker.h:955
int trackID
Truth particle track ID.
Definition: BackTracker.h:68
double purity
Putity of particle relative to track.
Definition: BackTracker.h:70
int maxID(double arrayInput[])
unsigned short Cell() const
Definition: CellHit.h:40
std::map< int, float > fIdToEnergy
Definition: BackTracker.h:956
void hits()
Definition: readHits.C:15
double efficiency
Efficiency of particle relative to track.
Definition: BackTracker.h:69
int pdg
Pdg of particle.
Definition: BackTracker.h:71
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
Definition: structs.h:12
double maxE
Definition: plot_hist.C:8
cheat::ParticleEffPur cheat::BackTracker::ClusterToParticle ( const std::vector< rb::Cluster > &  sliceList,
const std::vector< rb::CellHit > &  hits,
const int sliceIdx 
)
inline

Definition at line 798 of file BackTracker.h.

801  {
802  return ClusterToParticle(VecToVecRawPtr(sliceList),
804  sliceIdx);
805  }
cheat::ParticleEffPur ClusterToParticle(const std::vector< const rb::Cluster * > &sliceList, const std::vector< const rb::CellHit * > &hits, const int &sliceIdx)
void hits()
Definition: readHits.C:15
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
cheat::ParticleEffPur cheat::BackTracker::ClusterToParticle ( const std::vector< art::Ptr< rb::Cluster >> &  sliceList,
const std::vector< art::Ptr< rb::CellHit >> &  hits,
const int sliceIdx 
)
inline

Definition at line 807 of file BackTracker.h.

810  {
811  return ClusterToParticle(VecPtrToVecRawPtr(sliceList),
813  sliceIdx);
814  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
cheat::ParticleEffPur ClusterToParticle(const std::vector< const rb::Cluster * > &sliceList, const std::vector< const rb::CellHit * > &hits, const int &sliceIdx)
void hits()
Definition: readHits.C:15
cheat::ParticleEffPur cheat::BackTracker::ClusterToParticle ( const art::PtrVector< rb::Cluster > &  sliceList,
const art::PtrVector< rb::CellHit > &  hits,
const int sliceIdx 
)
inline

Definition at line 816 of file BackTracker.h.

References string.

819  {
820  return ClusterToParticle(PtrVecToVecRawPtr(sliceList),
821  PtrVecToVecRawPtr(hits),
822  sliceIdx);
823  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
cheat::ParticleEffPur ClusterToParticle(const std::vector< const rb::Cluster * > &sliceList, const std::vector< const rb::CellHit * > &hits, const int &sliceIdx)
const double cheat::BackTracker::EnergyFromTrackId ( const art::Ptr< rb::CellHit > &  hit,
int  trackId,
bool  useBirksE = false 
) const

The total energy deposited in this cell by all FLSHits with this trackId.

Definition at line 396 of file BackTracker_service.cc.

References rb::CellHit::Cell(), energy, fCellToFLSHit, art::Ptr< T >::get(), HitToParticle(), it, and rb::CellHit::Plane().

397  {
398  auto it = fCellToFLSHit.find(geo::OfflineChan(hit->Plane(), hit->Cell()));
399  if(it == fCellToFLSHit.end()){
400  mf::LogWarning("BackTracker") << "No FLSHits in this cell";
401  return 0;
402  }
403 
404  const std::list<sim::FLSHit>& flshits = it->second;
405 
406  double energy = 0;
407 
408  for(const sim::FLSHit& fls: flshits){
409  if(fls.GetTrackID() == trackId){
410  energy += ((useBirksE) ? fls.GetEdepBirks() : fls.GetEdep());
411  }
412  } // end for flsIdx
413 
414  return energy;
415  }
set< int >::iterator it
unsigned short Plane() const
Definition: CellHit.h:39
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
std::unordered_map< geo::OfflineChan, std::list< sim::FLSHit > > fCellToFLSHit
map of FLSHits in each cell in event
Definition: BackTracker.h:943
unsigned short Cell() const
Definition: CellHit.h:40
double energy
Definition: plottest35.C:25
A (plane, cell) pair.
Definition: OfflineChan.h:17
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const std::set<int> cheat::BackTracker::GetTrackIDList ( ) const
inline

Get all G4 track ids present in the event.

These do not include ids from EM shower secondaries, tertiaries, etc as they are not saved as particles.

Definition at line 754 of file BackTracker.h.

Referenced by cheat::TestTrackIds::analyze(), remid::ReMIdValidate::analyze(), remid::ReMIdTrain::analyze(), cheat::CheckBackTracking::CheckPurityAndEfficiency(), cheat::RecoCheckAna::CheckRecoClusters(), trk::KalmanTrackAna::CheckRecoTracks(), and cheat::CheckBackTracking::CheckTrackIdToParticle().

754 { return fTrackIDs; }
std::set< int > fTrackIDs
G4 track ids for all particles in the events.
Definition: BackTracker.h:947
bool cheat::BackTracker::HaveTruthInfo ( ) const
inline

Is this a file with truth info in? (Is BackTracker going to be any use to you?)

True if we succeeded in retrieving FLSHits, ie in general for MC files. Expected false in data, and mock data etc.

Definition at line 137 of file BackTracker.h.

References getBrightness::cell, and NDAPDHVSetting::plane.

Referenced by qeef::QeFinderVal::analyze(), calhit::CalHitAna::analyze(), mcchk::CloseInTime::analyze(), mmc::Validation::analyze(), numue::NumuEAna::analyze(), calib::EnergyStandardCandles::analyze(), CerenkovSelection::analyze(), remid::ReMIdDedx::analyze(), trk::KalmanTrackAna::analyze(), cvn::CVNEventDump::analyze(), cvn::CVNCosmicEventDump::analyze(), mono::SlowMonopoleAna::analyze(), remid::ReMIdDedxRock::analyze(), remid::ReMIdDedxStudies::analyze(), remid::ReMIdDedxFD::analyze(), mono::Monopole::analyze(), CerenkovResponse::analyze(), htk::HoughTrack::analyze(), trk::CosmicTrackAna::analyze(), htk::HoughTrack::beginJob(), numue::NumuEAlg::checkIsMC(), calib::StopperThreshold::FillHist(), CerenkovSelection::FillTree(), calib::StopperThreshold::FillTree(), trk::CosmicTrackAna::FillTrueInfo(), filter::Filter::FillTruthVariables(), nuesand::FillNueSandbox::FillTruthVars(), mono::EventSelector::filter(), mono::MonopoleCluster::filter(), bsf::BremShowerFilter::findShowerByTruth(), calib::EnergyStandardCandles::FindStoppingMuons(), numusand::NumuSandFxs::getMissingE(), calib::PCHitsList::GetTrueEnergyPathAndLightForCell(), cvn::HitClassify(), cvn::HitNuIndex(), cvn::HitObject(), caf::IsTrueDiF(), numue::NumuEAlg::MCTruthEnergyVariables(), mono::Monopole::n_mc_hits(), mmc::Validation::print_truth_info(), mono::SlowMonopoleAna::print_truth_info(), calib::PCHitsList::ProcessTrackForBelowThresholdHits(), calib::PCHitsList::ProcessTrackForFLSHits(), util::TruthExpand::produce(), numusand::FillSandbox::produce(), cosrej::CosRej::produce(), numue::NumuEnergy::produce(), calib::TimingCalibration::produce(), cvn::CVNAddTrainingData::produce(), murem::MuonRemove::produce(), and caf::CAFMaker::produce().

137 {return fHaveTruthInfo;}
bool fHaveTruthInfo
Set by Rebuild.
Definition: BackTracker.h:939
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< rb::WeightedHit > &  whits,
const std::vector< const rb::CellHit * > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const

Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are represented in a collection of weighted hits.

desiredHits and totalHits are also optional parameters that are the number of hits from the given set of trackIds in the given slice and the total number of hits from these trackId's in the detector respectively

Definition at line 815 of file BackTracker_service.cc.

Referenced by remid::ReMIdValidate::analyze(), numue::NumuEAna::analyze(), murem::MuonRemoveAna::analyze(), remid::ReMIdDedx::analyze(), remid::ReMIdDedxStudies::analyze(), fuzz::FuzzyKValidate::analyze(), slid::LIDTraining::analyze(), cheat::CheckBackTracking::CheckPurityAndEfficiency(), cheat::RecoCheckAna::CheckRecoClusters(), trk::KalmanTrackAna::CheckRecoTracks(), trk::CosmicTrackAna::FillTrueInfo(), cvn::Get2DProngEfficiencyByPDG(), cvn::GetProngEfficiencyByPDG(), HitCollectionEfficiency(), HitCollectionPurity(), murem::MuonRemove::RemoveByEfficiency(), SliceToMCTruth(), SliceToNeutrinoIndex(), SliceToNeutrinoInteractions(), and TracksToParticles().

825  {
826  const std::vector<RawWeightedHit> rwh(whits.begin(), whits.end());
827  return HitCollectionEfficiency(trackIDs, rwh, allhits, view,
828  effMap, energyEff, desiredEnergy, totalEnergy, desiredHits, totHits);
829  }
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< rb::WeightedHit > &  whits,
const std::vector< rb::CellHit > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 341 of file BackTracker.h.

References LSTME::totalEnergy().

351  {
352  return HitCollectionEfficiency(trackIDs, whits, VecToVecRawPtr(allhits), view, effMap, energyEff, desiredEnergy, totalEnergy, desiredHits, totalHits);
353  }
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< rb::WeightedHit > &  whits,
const std::vector< art::Ptr< rb::CellHit >> &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 355 of file BackTracker.h.

References LSTME::totalEnergy().

365  {
366  return HitCollectionEfficiency(trackIDs, whits, VecPtrToVecRawPtr(allhits), view, effMap, energyEff, desiredEnergy, totalEnergy, desiredHits, totalHits);
367  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< rb::WeightedHit > &  whits,
const art::PtrVector< rb::CellHit > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 369 of file BackTracker.h.

References LSTME::totalEnergy().

379  {
380  return HitCollectionEfficiency(trackIDs, whits, PtrVecToVecRawPtr(allhits), view, effMap, energyEff, desiredEnergy, totalEnergy, desiredHits, totalHits);
381  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< const rb::CellHit * > &  hits,
const std::vector< const rb::CellHit * > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const

Returns the fraction of all hits in an event from a specific set of Geant4 track IDs that are represented in a collection of hits.

The optional effMap parameter returns the efficiencies for each of the track IDs individually.

The optional energyPur parameter allows the efficiency to be calculated based on FLS energy instead of number of hits desiredHits and totalHits are also optional parameters that are the number of hits from the given set of trackIds in the given slice and the total number of hits from these trackId's in the detector respectively

Definition at line 793 of file BackTracker_service.cc.

References make_syst_table_plots::h, and HitCollectionEfficiency().

803  {
804 
805  // convert cell hits to weighted hits with weight 1
806  std::vector<RawWeightedHit> wHits;
807  for(const rb::CellHit* h: hits) wHits.emplace_back(h, 1);
808 
809  return HitCollectionEfficiency(trackIDs, wHits, allhits, view,
810  effMap, energyEff, desiredEnergy,
811  totalEnergy, desiredHits, totHits);
812  }
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
void hits()
Definition: readHits.C:15
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< rb::CellHit > &  hits,
const std::vector< rb::CellHit > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 405 of file BackTracker.h.

References LSTME::totalEnergy().

415  {
416  return HitCollectionEfficiency(trackIDs,
418  VecToVecRawPtr(allhits),
419  view,
420  effMap, energyEff, desiredEnergy,
421  totalEnergy, desiredHits, totalHits);
422  }
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
void hits()
Definition: readHits.C:15
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< art::Ptr< rb::CellHit >> &  hits,
const std::vector< art::Ptr< rb::CellHit >> &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 424 of file BackTracker.h.

References LSTME::totalEnergy().

434  {
435  return HitCollectionEfficiency(trackIDs,
437  VecPtrToVecRawPtr(allhits),
438  view,
439  effMap, energyEff, desiredEnergy,
440  totalEnergy, desiredHits, totalHits);
441  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
void hits()
Definition: readHits.C:15
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( std::set< int trackIDs,
const art::PtrVector< rb::CellHit > &  hits,
const art::PtrVector< rb::CellHit > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
inline

Definition at line 443 of file BackTracker.h.

References a, b, and LSTME::totalEnergy().

453  {
454  return HitCollectionEfficiency(trackIDs,
455  PtrVecToVecRawPtr(hits),
456  PtrVecToVecRawPtr(allhits),
457  view,
458  effMap, energyEff, desiredEnergy,
459  totalEnergy, desiredHits, totalHits);
460  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
double cheat::BackTracker::HitCollectionEfficiency ( const std::set< int > &  trackIDs,
const std::vector< RawWeightedHit > &  whits,
const std::vector< const rb::CellHit * > &  allhits,
const geo::View_t view,
std::map< int, double > *  effMap = 0,
bool  energyEff = false,
double *  desiredEnergy = 0,
double *  totalEnergy = 0,
int desiredHits = 0,
int totalHits = 0 
) const
private

Internal implementation of public HitCollectionEfficiency.

Definition at line 833 of file BackTracker_service.cc.

References ana::assert(), cheat::BackTracker::Params::DoHitsCheck, efficiency(), fParams, make_syst_table_plots::h, HitToTrackIDE(), MECModelEnuComparisons::i, makeTrainCVSamples::int, IsNoise(), it, geo::kXorY, cheat::BackTracker::Params::MinContribFrac, confusionMatrixTree::t, produceInfoGainMatrix::total, LSTME::totalEnergy(), rb::CellHit::View(), and ana::weight.

844  {
845 
846  // allhits should be a superset of hits
847  assert(allhits.size() >= whits.size());
848 
849  // to check it's a superset more thoroughly, optional
850  if(fParams.DoHitsCheck()){
851  for(unsigned int n = 0; n < whits.size(); ++n){
852  // TODO: should be checking actual equality not the pointers
853  // assert(std::find(allhits.begin(), allhits.end(), whits[n].hit) != allhits.end());
854  }
855  }
856  std::vector<const rb::CellHit*> hits_copy;
857  for(int i = 0; i < (int)whits.size(); i++)
858  hits_copy.push_back(whits[i].hit);
859 
860  // Check for duplicates
861  std::sort(hits_copy.begin(), hits_copy.end());
862  for(unsigned int n = 0; n+1 < hits_copy.size(); ++n)
863  assert(hits_copy[n] < hits_copy[n+1]);
864 
865  // get the list of EveIDs that correspond to the hits in this collection
866  // and the energy associated with the desired trackID
867 
868  double desired = 0.;
869  double total = 0.;
870 
871  double desiredE = 0.;
872  double totalE = 0.;
873 
874  if(effMap) effMap->clear();
875  std::map<int, double> totMap;
876 
877  for(size_t h = 0; h < whits.size(); ++h){
878 
879  double totalEInCell = 0.;
880  double desiredEInCell = 0.;
881 
882  const rb::CellHit* hit = whits[h].hit;
883  double weight = whits[h].weight;
884  assert( weight <= 1);
885 
886  if(IsNoise(*hit)) continue;
887 
888  bool hitCounted = false;
889 
890  std::vector<TrackIDE> tracks = HitToTrackIDE(*hit);
891 
892  assert(hit->View() == view || view == geo::kXorY);
893 
894  // don't double count if this hit has more than one of the
895  // desired track IDs associated with it
896  for(size_t t = 0; t < tracks.size(); ++t){
897  totalEInCell += tracks[t].energy;
898  if(trackIDs.find(tracks[t].trackID) != trackIDs.end() ){
899  desiredEInCell += tracks[t].energy;
900  if(tracks[t].energyFrac >= fParams.MinContribFrac()){
901  if(!hitCounted){
902  desired += 1.;
903  hitCounted = true;
904  }
905  if(effMap) ++(*effMap)[tracks[t].trackID];
906  }
907  }
908  }// end loop over track IDEs
909 
910  if( (weight*totalEInCell) >= desiredEInCell)
911  desiredE += desiredEInCell;
912  else
913  desiredE += (weight*totalEInCell);
914 
915  }// end loop over hits
916 
917  // now figure out how many hits in the whole collection are associated with this id
918  for(size_t h = 0; h < allhits.size(); ++h){
919  const rb::CellHit* hit = allhits[h];
920  if(IsNoise(*hit)) continue;
921 
922  std::vector<TrackIDE> tracks = HitToTrackIDE(*hit);
923 
924  bool hitCounted = false;
925 
926  // check that we are looking at the appropriate view here
927  // in the case of 3D objects we take all hits
928  if(hit->View() != view && view != geo::kXorY) continue;
929 
930  for(size_t t = 0; t < tracks.size(); ++t){
931  // don't worry about hits where the energy fraction for the chosen
932  // trackID is < MinContribFrac
933  // also don't double count if this hit has more than one of the
934  // desired track IDs associated with it
935  if(trackIDs.find(tracks[t].trackID) != trackIDs.end()){
936  totalE += tracks[t].energy;
937  if(tracks[t].energyFrac >= fParams.MinContribFrac()){
938  if(!hitCounted){
939  total += 1.;
940  hitCounted = true;
941  }
942  if(effMap) ++totMap[tracks[t].trackID];
943  }// end if energy fraction is above threshold
944  }// end if the current track ID is in the list of ones to check
945  }// end loop over tracks
946  }// end loop over all hits
947 
948  double efficiency = 0.;
949  if((total > 0.) && !energyEff) efficiency = desired/total;
950  if((totalE > 0.) && energyEff) efficiency = desiredE/totalE;
951 
952  if((total > 0.) && desiredHits ) *desiredHits = desired;
953  if((total > 0.) && totHits ) *totHits = total;
954  if((totalE > 0.) && desiredEnergy) *desiredEnergy = desiredE;
955  if((totalE > 0.) && totalEnergy ) *totalEnergy = totalE;
956 
957  if(effMap){
958  for(std::map<int, double>::iterator it = effMap->begin(); it != effMap->end(); ++it){
959  if(totMap[it->first] > 0)
960  it->second /= totMap[it->first];
961  // This is an efficiency. It should be between 0-100%
962  assert(it->second >= 0);
963  assert(it->second <= 1);
964  }
965  }
966 
967  return efficiency;
968  }
set< int >::iterator it
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
const Var weight
X or Y views.
Definition: PlaneGeo.h:30
geo::View_t View() const
Definition: CellHit.h:41
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
std::void_t< T > n
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
Definition: structs.h:12
assert(nhit_max >=nhit_nbins)
static Var totalEnergy(const std::shared_ptr< CAFAnaModel > &model)
Definition: LSTMEVar.h:77
void efficiency()
Definition: efficiency.C:58
Atom< double > MinContribFrac
Definition: BackTracker.h:107
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const std::vector< rb::WeightedHit > &  whits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const

Returns the fraction of hits in a collection that come from the specified Geant4 track ids.

Definition at line 662 of file BackTracker_service.cc.

Referenced by numue::NumuEAna::analyze(), murem::MuonRemoveAna::analyze(), remid::ReMIdDedx::analyze(), fuzz::FuzzyKValidate::analyze(), remid::ReMIdDedxStudies::analyze(), slid::LIDTraining::analyze(), cheat::CheckBackTracking::CheckPurityAndEfficiency(), cheat::RecoCheckAna::CheckRecoClusters(), trk::KalmanTrackAna::CheckRecoTracks(), trk::CosmicTrackAna::FillTrueInfo(), cvn::Get2DProngPurityByPDG(), cvn::GetProngPurityByPDG(), cvn::HitClassify(), HitCollectionPurity(), cvn::HitObject(), HitToXYZ(), cvn::ProngClassify(), SliceToMCTruth(), SliceToNeutrinoIndex(), SliceToNeutrinoInteractions(), and TracksToParticles().

667  {
668  const std::vector<RawWeightedHit> rwh(whits.begin(), whits.end());
669  return HitCollectionPurity(trackIDs, rwh, purMap, parents, energyPur);
670  }
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const std::vector< const rb::CellHit * > &  hits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const

Returns the fraction of hits in a collection that come from the specified Geant4 track ids.

The optional purMap parameter returns the purities for each of the track IDs individually.

The optional parents parameter maps particle IDs to the IDs they

The optional energyPur parameter allows the purity to be calculated based on FLS energy instead of number of hits

Definition at line 777 of file BackTracker_service.cc.

References make_syst_table_plots::h, HitCollectionEfficiency(), and HitCollectionPurity().

782  {
783  // convert all cell hits to weighted hits with weight 1.
784  std::vector<RawWeightedHit> wHits;
785  for(const rb::CellHit* h: hits) wHits.emplace_back(h, 1);
786 
787  return HitCollectionPurity(trackIDs, wHits, purMap, parents, energyPur);
788 
789  }
void hits()
Definition: readHits.C:15
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const std::vector< rb::CellHit > &  hits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const
inline

Definition at line 297 of file BackTracker.h.

302  {
303  return HitCollectionPurity(trackIDs, VecToVecRawPtr(hits), purMap, parents, energyPur);
304  }
void hits()
Definition: readHits.C:15
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const std::vector< art::Ptr< rb::CellHit >> &  hits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const
inline

Definition at line 306 of file BackTracker.h.

311  {
312  return HitCollectionPurity(trackIDs, VecPtrToVecRawPtr(hits), purMap, parents, energyPur);
313  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
void hits()
Definition: readHits.C:15
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const art::PtrVector< rb::CellHit > &  hits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const
inline

Definition at line 315 of file BackTracker.h.

References LSTME::totalEnergy(), and POTSpillRate::view.

320  {
321  return HitCollectionPurity(trackIDs, PtrVecToVecRawPtr(hits), purMap, parents, energyPur);
322  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
double cheat::BackTracker::HitCollectionPurity ( const std::set< int > &  trackIDs,
const std::vector< RawWeightedHit > &  whits,
std::map< int, double > *  purMap = 0,
std::map< int, int > *  parents = 0,
bool  energyPur = false 
) const
private

Internal implementation of public HitCollectionPurity.

Definition at line 674 of file BackTracker_service.cc.

References ana::assert(), make_syst_table_plots::h, HitCollectionPurity(), HitToTrackIDE(), IsNoise(), it, purity(), confusionMatrixTree::t, produceInfoGainMatrix::total, trackID, and ana::weight.

680  {
681  // get the list of EveIDs that correspond to the hits in this collection
682  // if the EveID shows up in the input list of trackIDs, then it counts
683  double total = whits.size();
684  double desired = 0;
685 
686  double desiredE = 0;
687  double totalE = 0;
688 
689  if(purMap) purMap->clear();
690 
691  for(size_t h = 0; h < whits.size(); ++h){
692 
693  double totalEInCell = 0;
694  double desiredEInCell = 0;
695 
696  const rb::CellHit* hit = whits[h].hit;
697  double weight = whits[h].weight;
698 
699  assert( weight <= 1);
700 
701  if(IsNoise(*hit)) continue;
702 
703  std::vector<TrackIDE> tracks = HitToTrackIDE(*hit);
704 
705  // The set of trackIDs (or parents) that contributed to this hit
706  std::set<int> tally;
707 
708  for(size_t t = 0; t < tracks.size(); ++t){
709  const int trackID = tracks[t].trackID;
710  if(trackIDs.find(trackID) != trackIDs.end()){
711  tally.insert(trackID);
712  }
713  if(parents){
714  std::map<int, int>::iterator parentsIt = parents->find(trackID);
715  if(parentsIt != parents->end()){
716  tally.insert(parentsIt->second);
717  }
718  }
719  } // end for t
720 
721 
722  if (energyPur){
723  for(size_t t = 0; t < tracks.size(); ++t){
724  totalEInCell += tracks[t].energy * weight;
725  if(trackIDs.find(tracks[t].trackID) != trackIDs.end()){
726  desiredE += tracks[t].energy;
727  desiredEInCell += tracks[t].energy;
728  }
729  }
730  }//End of loop for counting energy when doing purity based on FLS hits
731 
732  // Purity in a cell can sometimes be greater than one if the weight of
733  // a hit is less than the fraction of energy from desired track IDs
734  // in that cell.
735  if( desiredEInCell >= totalEInCell )
736  totalE += desiredEInCell;
737  else
738  totalE += totalEInCell;
739 
740  if(purMap){
741  for(std::set<int>::iterator it = tally.begin(); it != tally.end(); ++it){
742  ++(*purMap)[*it];
743  }
744  }
745 
746  if(!tally.empty()) ++desired;
747 
748 
749  }// end loop over whits
750 
751  double purity = 0.;
752 
753  if((total > 0) && !energyPur) purity = desired/total;
754  if((totalE > 0) && energyPur) purity = desiredE/totalE;
755 
756  assert(purity >= 0);
757  assert(purity <= 1);
758 
759  if(total > 0 && purMap){
760  for(std::map<int, double>::iterator it = purMap->begin(); it != purMap->end(); ++it){
761  it->second /= total;
762  // This is a purity, it should be between 0-100%
763  assert(it->second >= 0);
764  assert(it->second <= 1);
765  }
766  }
767 
768  return purity;
769 
770  }
set< int >::iterator it
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
const Var weight
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
void purity()
Definition: purity.C:35
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
Definition: structs.h:12
assert(nhit_max >=nhit_nbins)
Int_t trackID
Definition: plot.C:84
std::vector< const sim::Particle * > cheat::BackTracker::HitsToParticle ( const std::vector< const rb::CellHit * > &  hits) const

Returns vector of sim::Particle objects contributing to the given collection of hits.

Orders the returned vector with the particle contributing the most light in the collection first.

Definition at line 549 of file BackTracker_service.cc.

References AccumulateHitContributions(), make_syst_table_plots::h, HitsToTrackIDE(), it, make_pair(), part, runNovaSAM::ret, moon_position_table_new3::second, and TrackIDToParticle().

Referenced by calib::TestParticleCorrections::analyze(), remid::ReMIdDedx::analyze(), slicer::SlicerAna::analyze(), remid::ReMIdDedxRock::analyze(), remid::ReMIdDedxFD::analyze(), remid::ReMIdDedxStudies::analyze(), bpfit::BPFTmvaTrainer::analyze(), bpfit::BreakPointProtonAna::analyze(), calib::StopperThreshold::FillHist(), calib::CosmicTrends::FillHistograms(), CerenkovSelection::FillTree(), calib::StopperThreshold::FillTree(), trk::CosmicTrackAna::FillTrueInfo(), numusand::NumuSandFxs::getMissingE(), caf::IsTrueDiF(), calib::RockMuonStopperSelection::IsTrulyContainedStopper(), calib::StopperSelection::IsTrulyContainedStopper(), calib::RockMuonStopperSelection::IsTrulyInFiducial(), calib::ThroughgoingSelection::IsTrulyUncontained(), skim::EvaluatorNumuCCpi::KeepSlice(), MCTruthToParticles(), calib::PCHitsList::ProcessTrackForBelowThresholdHits(), calib::PCHitsList::ProcessTrackForFLSHits(), util::TruthExpand::produce(), numusand::FillSandbox::produce(), and cosrej::CosRej::produce().

550  {
551  std::map<int, int> idToNPhot;
552  for(size_t h = 0; h < hits.size(); ++h){
553  AccumulateHitContributions(*hits[h], idToNPhot);
554  }
555 
556  // Now "all" we need to do is sort by number of photons, and discard any IDs
557  // that we can't find particles for. This turns out to be a bit fiddly.
558 
559  std::vector<std::pair<int, int> > nphotToId;
560  for(std::map<int, int>::iterator it = idToNPhot.begin(); it != idToNPhot.end(); ++it){
561  nphotToId.push_back(std::make_pair(it->second, it->first));
562  }
563 
564  // Sort in reverse order (ie increasing number of photons).
565  // Tuples compare by first element first, so this works
566  std::sort(nphotToId.rbegin(), nphotToId.rend());
567 
568  std::vector<const sim::Particle*> ret;
569  for(unsigned int n = 0; n < nphotToId.size(); ++n){
570  const sim::Particle* part = TrackIDToParticle(nphotToId[n].second);
571  if(part) ret.push_back(part);
572  }
573 
574  return ret;
575  }
set< int >::iterator it
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
void AccumulateHitContributions(rb::CellHit const &hit, std::map< int, int > &idToNPhot) const
Internal helper, adds the contributions from each particle in this cell to the map.
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
std::void_t< T > n
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
std::vector<const sim::Particle*> cheat::BackTracker::HitsToParticle ( const std::vector< rb::CellHit > &  hits) const
inline

Definition at line 232 of file BackTracker.h.

233  {
235  }
void hits()
Definition: readHits.C:15
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector< const sim::Particle * > HitsToParticle(const std::vector< const rb::CellHit * > &hits) const
Returns vector of sim::Particle objects contributing to the given collection of hits.
std::vector<const sim::Particle*> cheat::BackTracker::HitsToParticle ( const std::vector< art::Ptr< rb::CellHit >> &  hits) const
inline

Definition at line 236 of file BackTracker.h.

237  {
239  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
void hits()
Definition: readHits.C:15
std::vector< const sim::Particle * > HitsToParticle(const std::vector< const rb::CellHit * > &hits) const
Returns vector of sim::Particle objects contributing to the given collection of hits.
std::vector<const sim::Particle*> cheat::BackTracker::HitsToParticle ( const art::PtrVector< rb::CellHit > &  hits) const
inline

Definition at line 240 of file BackTracker.h.

241  {
242  return HitsToParticle(PtrVecToVecRawPtr(hits));
243  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< const sim::Particle * > HitsToParticle(const std::vector< const rb::CellHit * > &hits) const
Returns vector of sim::Particle objects contributing to the given collection of hits.
std::vector< TrackIDE > cheat::BackTracker::HitsToTrackIDE ( const std::vector< const rb::CellHit * > &  hits,
bool  useBirksE = false 
) const

Returns vector of TrackIDE structs contributing to the given collection of hits.

Orders the returned vector with the trackID contributing the most energy in the collection first.

Definition at line 581 of file BackTracker_service.cc.

References cheat::CompareByEnergy(), cheat::TrackIDE::energy, cheat::TrackIDE::energyFrac, MakeMiniprodValidationCuts::f, make_syst_table_plots::h, HitToFLSHit(), HitToTrackIDE(), it, and cheat::TrackIDE::trackID.

Referenced by fuzz::FuzzyKValidate::analyze(), slid::LIDTraining::analyze(), calib::EnergyStandardCandles::FindStoppingMuons(), cvn::Get2DProngEfficiencyByPDG(), cvn::Get2DProngEnergyByPDG(), cvn::Get2DProngPurityByPDG(), cvn::GetProngEfficiencyByPDG(), cvn::GetProngEnergyByPDG(), cvn::GetProngPurityByPDG(), HitsToParticle(), HitToTrackIDE(), numusand::FillSandbox::produce(), cosrej::CosRej::produce(), caf::CAFMaker::produce(), and cvn::ProngClassify().

582  {
583 
584  std::map<int, double> sigtracks;
585 
586  double totalE = 0;
587  for(size_t h = 0; h < hits.size(); ++h){
588  const std::vector<sim::FLSHit> fls = HitToFLSHit(*hits[h]);
589  for(size_t f = 0; f < fls.size(); ++f){
590  if( useBirksE){
591  sigtracks[fls[f].GetTrackID()] += fls[f].GetEdepBirks();
592  totalE += fls[f].GetEdepBirks();
593  }
594  else{
595  sigtracks[fls[f].GetTrackID()] += fls[f].GetEdep();
596  totalE += fls[f].GetEdep();
597  }
598  }
599  } // end for h
600 
601  // Make trackIDE objects from our collected energies
602  std::vector<TrackIDE> trackIDE;
603  for(std::map<int, double>::iterator it = sigtracks.begin(); it != sigtracks.end(); ++it){
604  TrackIDE ide;
605  ide.trackID = it->first;
606  ide.energy = it->second;
607  ide.energyFrac = it->second/totalE;
608  trackIDE.push_back(ide);
609  }
610 
611  // Sort TrackIDE objects from most energy contributed to least
612  std::sort(trackIDE.rbegin(), trackIDE.rend(), CompareByEnergy);
613 
614  return trackIDE;
615  }
set< int >::iterator it
void hits()
Definition: readHits.C:15
std::vector< sim::FLSHit > HitToFLSHit(const rb::CellHit &hit) const
All the FLSHits that contributed to this hit, sorted from most to least light.
bool CompareByEnergy(const TrackIDE &a, const TrackIDE &b)
Does a have less energy than b?
std::vector<TrackIDE> cheat::BackTracker::HitsToTrackIDE ( const std::vector< rb::CellHit > &  hits,
bool  useBirksE = false 
) const
inline

Definition at line 252 of file BackTracker.h.

253  {
254  return HitsToTrackIDE(VecToVecRawPtr(hits), useBirksE);
255  }
void hits()
Definition: readHits.C:15
std::vector< TrackIDE > HitsToTrackIDE(const std::vector< const rb::CellHit * > &hits, bool useBirksE=false) const
Returns vector of TrackIDE structs contributing to the given collection of hits.
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector<TrackIDE> cheat::BackTracker::HitsToTrackIDE ( const std::vector< art::Ptr< rb::CellHit >> &  hits,
bool  useBirksE = false 
) const
inline

Definition at line 257 of file BackTracker.h.

258  {
259  return HitsToTrackIDE(VecPtrToVecRawPtr(hits), useBirksE);
260  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
void hits()
Definition: readHits.C:15
std::vector< TrackIDE > HitsToTrackIDE(const std::vector< const rb::CellHit * > &hits, bool useBirksE=false) const
Returns vector of TrackIDE structs contributing to the given collection of hits.
std::vector<TrackIDE> cheat::BackTracker::HitsToTrackIDE ( const art::PtrVector< rb::CellHit > &  hits,
bool  useBirksE = false 
) const
inline

Definition at line 262 of file BackTracker.h.

263  {
264  return HitsToTrackIDE(PtrVecToVecRawPtr(hits), useBirksE);
265  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< TrackIDE > HitsToTrackIDE(const std::vector< const rb::CellHit * > &hits, bool useBirksE=false) const
Returns vector of TrackIDE structs contributing to the given collection of hits.
std::vector< sim::FLSHit > cheat::BackTracker::HitToFLSHit ( const rb::CellHit hit) const

All the FLSHits that contributed to this hit, sorted from most to least light.

Definition at line 349 of file BackTracker_service.cc.

References AccumulateHitContributions(), rb::CellHit::Cell(), fCellToFLSHit, it, make_pair(), MF_LOG_DEBUG, rb::CellHit::Plane(), and runNovaSAM::ret.

Referenced by calhit::CalHitAna::analyze(), ddt::SMMADC::analyze(), calib::TestParticleCorrections::analyze(), calib::AssessCalib::analyze(), showere::ShowerEnergyAna::analyze(), remid::ReMIdDedxRock::analyze(), remid::ReMIdDedxFD::analyze(), remid::ReMIdDedxStudies::analyze(), mono::Monopole::analyze(), fuzz::FuzzyKValidate::analyze(), CerenkovResponse::analyze(), slid::LIDTraining::analyze(), cheat::CheckBackTracking::CheckFLSHitConsistency(), mono::SlowMonopoleAna::fill_hit_tree(), caf::FillParticleTruth(), CerenkovSelection::FillTree(), calhit::CalHitAna::FillTruthInfo(), showere::ShowerEnergyFilterMC::filter(), HitsToTrackIDE(), and HitToXYZ().

350  {
351  std::map<int, int> idToNPhot;
352  AccumulateHitContributions(hit, idToNPhot);
353 
354  // Next, sort by number of photons. This turns out to be a bit fiddly.
355 
356  std::vector<std::pair<int, int> > nphotToId;
357  nphotToId.reserve(idToNPhot.size());
358  for(std::map<int, int>::iterator it = idToNPhot.begin(); it != idToNPhot.end(); ++it){
359  nphotToId.push_back(std::make_pair(it->second, it->first));
360  }
361 
362  if(nphotToId.empty()){
363  MF_LOG_DEBUG("BackTracker") << "No matching photons, this is probably a noise hit. Returning empty vector";
364  return std::vector<sim::FLSHit>();
365  }
366 
367  // Sort in reverse order (ie decreasing number of photons).
368  // Tuples compare by first element first, so this works
369  std::sort(nphotToId.rbegin(), nphotToId.rend());
370 
371  auto it = fCellToFLSHit.find(geo::OfflineChan(hit.Plane(), hit.Cell()));
372  if ( it == fCellToFLSHit.end() ) {
373  throw cet::exception("BackTracker")
374  << "PhotonSignal with no matching FLSHit. That shouldn't be possible\n"
375  << __FILE__ << ":" << __LINE__ << "\n";
376  }
377 
378  std::vector<sim::FLSHit> ret;
379  const std::list<sim::FLSHit>& flshits = it->second;
380 
381  ret.reserve(nphotToId.size()*flshits.size()); // Overestimate
382 
383  for(unsigned int idIdx = 0; idIdx < nphotToId.size(); ++idIdx){
384  const int trackid = nphotToId[idIdx].second;
385  for(const sim::FLSHit& fls: flshits){
386  if(fls.GetTrackID() == trackid){
387  ret.push_back(fls);
388  }
389  } // end for flsIdx
390  } // end for idIdx
391 
392  return ret;
393  }
set< int >::iterator it
unsigned short Plane() const
Definition: CellHit.h:39
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
void AccumulateHitContributions(rb::CellHit const &hit, std::map< int, int > &idToNPhot) const
Internal helper, adds the contributions from each particle in this cell to the map.
std::unordered_map< geo::OfflineChan, std::list< sim::FLSHit > > fCellToFLSHit
map of FLSHits in each cell in event
Definition: BackTracker.h:943
unsigned short Cell() const
Definition: CellHit.h:40
A (plane, cell) pair.
Definition: OfflineChan.h:17
#define MF_LOG_DEBUG(id)
std::vector<sim::FLSHit> cheat::BackTracker::HitToFLSHit ( const art::Ptr< rb::CellHit > &  hit) const
inline

Definition at line 170 of file BackTracker.h.

References hits(), make_root_from_grid_output::pdg, and cheat::TrackIDE::trackID.

171  {
172  return HitToFLSHit(*hit);
173  }
std::vector< sim::FLSHit > HitToFLSHit(const rb::CellHit &hit) const
All the FLSHits that contributed to this hit, sorted from most to least light.
const sim::Particle* cheat::BackTracker::HitToParticle ( art::Ptr< rb::CellHit > const &  hit,
bool  quiet = false 
) const
const sim::Particle * cheat::BackTracker::HitToParticle ( const rb::CellHit hit,
bool  quiet = false 
) const

Returns the sim::Particle object contributing the most light to the specified rb::CellHit.

Definition at line 426 of file BackTracker_service.cc.

References AccumulateHitContributions(), it, and TrackIDToParticle().

428  {
429  std::map<int, int> idToNPhot;
430  AccumulateHitContributions(hit, idToNPhot);
431 
432  // Go through the map and find the particle ID that contributed the most light
433  int bestId = -1;
434  int mostPhot = -1;
435  for(std::map<int, int>::iterator it = idToNPhot.begin(); it != idToNPhot.end(); ++it){
436  if(it->second > mostPhot){
437  mostPhot = it->second;
438  bestId = it->first;
439  }
440  }
441 
442  if(bestId == -1){
443  if(!quiet){
444  mf::LogWarning("BackTracker") << "No photons in this cell are in time with the hit. "
445  << "Returning null pointer";
446  }
447  return 0;
448  }
449 
450  return TrackIDToParticle(bestId);
451  }
set< int >::iterator it
void AccumulateHitContributions(rb::CellHit const &hit, std::map< int, int > &idToNPhot) const
Internal helper, adds the contributions from each particle in this cell to the map.
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void cheat::BackTracker::HitToParticlesMap ( const std::vector< const rb::Cluster * > &  sliceList,
const int sliceIdx 
)

Definition at line 1612 of file BackTracker_service.cc.

References rb::CellHit::Cell(), febshutoff_auto::chan, fCellToIDs, fIdToEnergy, fSliceIDForHitParticleMap, HitToTrackIDE(), IsNoise(), rb::CellHit::Plane(), and rawdata::RawDigit::TDC().

Referenced by ClusterToParticle().

1614  {
1615  fCellToIDs.clear();
1616  fIdToEnergy.clear();
1617 
1618  unsigned int nsli = sliceList.size();
1619 
1620  for (unsigned int isli = 0; isli < nsli; isli++){
1621  unsigned int nh = sliceList[isli]->NCell();
1622  for (unsigned int ih = 0; ih < nh; ih++){
1623 
1624  art::Ptr<rb::CellHit> hit = sliceList[isli]->Cell(ih);
1625 
1626  if (IsNoise(hit)) continue;
1627  double chan = (hit->TDC()*1000000) + (hit->Plane()*1000) + hit->Cell();
1628 
1629  std::vector<cheat::TrackIDE> ides = HitToTrackIDE(hit);
1630  fCellToIDs[chan] = ides;
1631 
1632  for(auto ide : ides)
1633  fIdToEnergy[ide.trackID] += ide.energy;
1634  }// end of loop over slice hits
1635  }// end of loop over slices
1636  fSliceIDForHitParticleMap = sliceIdx;
1637 
1638  }// end of hits to particles table
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
unsigned short Plane() const
Definition: CellHit.h:39
std::map< double, std::vector< cheat::TrackIDE > > fCellToIDs
Definition: BackTracker.h:955
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
unsigned short Cell() const
Definition: CellHit.h:40
std::map< int, float > fIdToEnergy
Definition: BackTracker.h:956
Definition: structs.h:12
void cheat::BackTracker::HitToParticlesMap ( const std::vector< rb::Cluster > &  sliceList,
const int sliceIdx 
)
inline

Definition at line 776 of file BackTracker.h.

778  {
779  return HitToParticlesMap(VecToVecRawPtr(sliceList), sliceIdx);
780  }
void HitToParticlesMap(const std::vector< const rb::Cluster * > &sliceList, const int &sliceIdx)
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
void cheat::BackTracker::HitToParticlesMap ( const std::vector< art::Ptr< rb::Cluster >> &  sliceList,
const int sliceIdx 
)
inline

Definition at line 782 of file BackTracker.h.

784  {
785  return HitToParticlesMap(VecPtrToVecRawPtr(sliceList), sliceIdx);
786  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
void HitToParticlesMap(const std::vector< const rb::Cluster * > &sliceList, const int &sliceIdx)
void cheat::BackTracker::HitToParticlesMap ( const art::PtrVector< rb::Cluster > &  sliceList,
const int sliceIdx 
)
inline

Definition at line 788 of file BackTracker.h.

790  {
791  return HitToParticlesMap(PtrVecToVecRawPtr(sliceList), sliceIdx);
792  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
void HitToParticlesMap(const std::vector< const rb::Cluster * > &sliceList, const int &sliceIdx)
const std::vector< sim::PhotonSignal > cheat::BackTracker::HitToPhotonSignal ( const art::Ptr< rb::CellHit > &  hit) const

Returns the PhotonSignals contributing the signal in the specified hit.

Sorted from highest signal to lowest (which is probably not much use, since energy from one particle can be split over several signals).

Definition at line 301 of file BackTracker_service.cc.

References rb::CellHit::Cell(), CloseInTime(), fCellToPhotonSignal, art::Ptr< T >::get(), MECModelEnuComparisons::i, it, MF_LOG_DEBUG, and rb::CellHit::Plane().

Referenced by mcchk::MonopoleAna::analyze(), mcchk::RockAna::analyze(), calib::StopperThreshold::FillHist(), calib::StopperThreshold::FillTree(), calib::PCHitsList::GetTrueEnergyPathAndLightForCell(), and murem::MuonRemove::RemoveByTruth().

302  {
303  auto it = fCellToPhotonSignal.find(geo::OfflineChan(hit->Plane(), hit->Cell()));
304 
305  // Nothing to accumulate from this cell
306  if(it == fCellToPhotonSignal.end()){
307  MF_LOG_DEBUG("BackTracker") << "no collection of sim::PhotonSignal for "
308  << " plane = " << hit->Plane() << " cell = " << hit->Cell()
309  << " probably this was a noise hit, returning an"
310  << " empty vector";
311  const std::vector<sim::PhotonSignal> empty;
312  return empty;
313  }
314 
315  // Candidate photons, in that they're in the right cell.
316  const std::vector<sim::PhotonSignal>& phots = it->second;
317 
318  std::vector<sim::PhotonSignal> hitPhots;
319 
320  // For every photon that's sufficiently in time with the hit,
321  // accumulate its energy into the relevant trackID.
322  for(unsigned int i = 0; i < phots.size(); ++i){
323  const sim::PhotonSignal& phot = phots[i];
324  if(CloseInTime(*hit.get(), phot)){
325  hitPhots.push_back(phot);
326  }
327  }
328  return hitPhots;
329  }
std::unordered_map< geo::OfflineChan, std::vector< sim::PhotonSignal > > fCellToPhotonSignal
map of PhotonSignals in each cell in event
Definition: BackTracker.h:945
set< int >::iterator it
unsigned short Plane() const
Definition: CellHit.h:39
unsigned short Cell() const
Definition: CellHit.h:40
A (plane, cell) pair.
Definition: OfflineChan.h:17
#define MF_LOG_DEBUG(id)
T const * get() const
Definition: Ptr.h:149
bool CloseInTime(const rb::CellHit &chit, const sim::PhotonSignal &phot) const
Internal helper, decides if a PhotonSignal and CellHit are close enough to match. ...
std::vector< TrackIDE > cheat::BackTracker::HitToTrackIDE ( const rb::CellHit hit,
bool  useBirksE = false 
) const
std::vector< TrackIDE > cheat::BackTracker::HitToTrackIDE ( const art::Ptr< rb::CellHit > &  hit,
bool  useBirksE = false 
) const

Definition at line 619 of file BackTracker_service.cc.

References art::Ptr< T >::get(), HitsToTrackIDE(), and HitToTrackIDE().

620  {
621  return HitsToTrackIDE(std::vector<const rb::CellHit*>(1, hit.get()), useBirksE);
622  }
std::vector< TrackIDE > HitsToTrackIDE(const std::vector< const rb::CellHit * > &hits, bool useBirksE=false) const
Returns vector of TrackIDE structs contributing to the given collection of hits.
T const * get() const
Definition: Ptr.h:149
TVector3 cheat::BackTracker::HitToXYZ ( art::Ptr< rb::CellHit > const &  hit,
bool  useBirksE = false 
) const

Returns the XYZ position of the energy deposition for a given hit.

Note the return value is in cell coordinates, not detector

Definition at line 632 of file BackTracker_service.cc.

References e, HitCollectionPurity(), HitToFLSHit(), w, ana::weight, submit_syst::x, submit_syst::y, and test::z.

Referenced by cheat::CheckBackTracking::analyze(), mcchk::MonopoleAna::analyze(), and calib::AssessCalib::analyze().

633  {
634  double x = 0.;
635  double y = 0.;
636  double z = 0.;
637  double w = 0.;
638 
639  const std::vector<sim::FLSHit> fhits = this->HitToFLSHit(hit);
640 
641  // loop over the FLSHits for this cell and get the weighted central
642  // position of each track id in it.
643  for(const sim::FLSHit& fhit: fhits){
644  double weight = ((useBirksE) ? fhit.GetEdepBirks() : fhit.GetEdep());
645 
646  w += weight;
647  x += weight * 0.5*(fhit.GetExitX() + fhit.GetEntryX());
648  y += weight * 0.5*(fhit.GetExitY() + fhit.GetEntryY());
649  z += weight * 0.5*(fhit.GetExitZ() + fhit.GetEntryZ());
650 
651  }// end loop over sim::FLSHits
652 
653  // if the sum of the weights is still 0, then return
654  // the obviously stupid default values
655  if(w < 1.e-5) return TVector3(-999, -999, -999);
656 
657  return TVector3(x/w, y/w, z/w);
658  }
const Var weight
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
std::vector< sim::FLSHit > HitToFLSHit(const rb::CellHit &hit) const
All the FLSHits that contributed to this hit, sorted from most to least light.
z
Definition: test.py:28
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
bool cheat::BackTracker::InterceptsDetector ( const sim::Particle Par,
int TrajEnt,
int TrajEx 
)

A function which returns the trajectory point at which the particle first enters and leave the detector volume. The trajectory point is returned so that the user can determine the energies etc which the particle had at this point. Should the particle have been generated in the detector then TrajEnt == 0 will be returned. Should the particle stop in the detector then TrajEx == NumberTrajectoryPoints()-1 will be returned. Should the particle never enter the detector then holder values TrajEnter == TrajEx == -5 will be returned.

A function which returns the trajectory point at which the particle first enters and leave the detector volume. The trajectory point is returned so that the user can determine the energies etc which the particle had at this point. Should the particle have been generated in the detector then TrajEnt == 0 will be returned. Should the particle stop in the detector then TrajEx == NumberTrajectoryPoints()-1 will be returned. Should the particle never enter the detector then holder values TrajEnter == TrajEx == -5 will be returned.

Definition at line 1853 of file BackTracker_service.cc.

References DEFINE_ART_SERVICE, geom(), geo::GeometryBase::isInsideDetectorBigBox(), simb::MCParticle::NumberTrajectoryPoints(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

Referenced by CalcEscapingEnergy(), and cheat::TrueEnergy::produce().

1853  {
1854  /// A function which returns the trajectory point at which the particle first enters and leave the detector volume.
1855  /// The trajectory point is returned so that the user can determine the energies etc which the particle had at this
1856  /// point.
1857  /// Should the particle have been generated in the detector then TrajEnt == 0 will be returned.
1858  /// Should the particle stop in the detector then TrajEx == NumberTrajectoryPoints()-1 will be returned.
1859  /// Should the particle never enter the detector then holder values TrajEnter == TrajEx == -5 will be returned.
1860 
1861  // Initially set some holder values.
1862  TrajEnt = TrajEx = -5;
1863  // Make a handle to geometry service
1865  // Get the Number of trajectory points.
1866  unsigned int NumTraj = Par.NumberTrajectoryPoints();
1867  bool EnteredVol = false;
1868  bool PrevHit = false;
1869  for (unsigned int trj=0; trj<NumTraj; ++trj) {
1870  // Is the hit in the detector?
1871  bool InDet = geom->isInsideDetectorBigBox( Par.Vx(trj), Par.Vy(trj), Par.Vz(trj) );
1872  if ( InDet ) {
1873  // If this is the first hit in the volume.
1874  if ( !EnteredVol ) {
1875  TrajEnt = trj;
1876  EnteredVol = true;
1877  }
1878  // If this is the last trajectory point.
1879  if ( EnteredVol && InDet && (trj==NumTraj-1) ) {
1880  TrajEx = trj;
1881  }
1882  }
1883  // If last hit was in volume, and this hit isn't.
1884  if ( PrevHit && !InDet) {
1885  TrajEx = trj-1;
1886  }
1887  // Set the PrevHit variable.
1888  PrevHit = InDet;
1889  } // Loop over TrajPoints
1890  // Finally, return
1891  return EnteredVol;
1892  } //end InterceptsDetector
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:217
bool isInsideDetectorBigBox(const double x_cm, const double y_cm, const double z_cm) const
Is the particle inside the detector Big Box?
double Vx(const int i=0) const
Definition: MCParticle.h:220
void geom(int which=0)
Definition: geom.C:163
double Vz(const int i=0) const
Definition: MCParticle.h:222
double Vy(const int i=0) const
Definition: MCParticle.h:221
bool cheat::BackTracker::IsHitsNoise ( std::vector< art::Ptr< rb::CellHit > > const &  hits) const

Of this collection of hits, is it mostly noise or physics hits? True indicates noise.

Definition at line 466 of file BackTracker_service.cc.

References fParams, make_syst_table_plots::h, hits(), IsNoise(), cheat::BackTracker::Params::MinPhysicsFrac, cheat::BackTracker::Params::MinPhysicsHits, and produceInfoGainMatrix::total.

467  {
468  int totalNoise = 0;
469  int total = hits.size();
470 
471  for(size_t h = 0; h < hits.size(); ++h){
473  if (IsNoise(hit)) totalNoise += 1;
474  }
475 
476  int totalPhysics = total - totalNoise;
477  double physicsFrac = (double)totalPhysics / (double)total;
478 
479  // If at least MinPhysicsHits physics hits in the collection, not a noise group.
480  // If at least MinPhysicsFrac of the hits are physics, not a noise group.
481  // Otherwise, call it a noise group.
482 
483  return((totalPhysics < fParams.MinPhysicsHits()) && (physicsFrac < fParams.MinPhysicsFrac()));
484  }
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
void hits()
Definition: readHits.C:15
Definition: structs.h:12
Atom< double > MinPhysicsFrac
Definition: BackTracker.h:109
bool cheat::BackTracker::IsNoise ( const art::Ptr< rb::CellHit > &  hit) const
bool cheat::BackTracker::IsNoise ( const rb::CellHit hit) const

Is this hit not associated with any particles?

Definition at line 460 of file BackTracker_service.cc.

References HitToParticle().

461  {
462  return (HitToParticle(hit, true) == 0);
463  }
const sim::Particle * HitToParticle(art::Ptr< rb::CellHit > const &hit, bool quiet=false) const
Returns the sim::Particle object contributing the most light to the specified rb::CellHit.
rb::Cluster cheat::BackTracker::MCTruthToCluster ( art::Ptr< simb::MCTruth > const &  truth,
std::vector< art::Ptr< rb::CellHit > > const &  hits 
)

:

Definition at line 1583 of file BackTracker_service.cc.

References rb::Cluster::Add(), fMCTruthList, fTrackIDToMCTruthIndex, hits(), HitToParticle(), compare_h5_caf::idx, IsNoise(), part, and simb::MCParticle::TrackId().

1585  {
1586  rb::Cluster cluster;
1587 
1588  // figure out where in the MCTruth list mct belongs
1589  unsigned int MCTidx;
1590  for(MCTidx = 0; MCTidx < fMCTruthList.size(); ++MCTidx) {
1591  if(fMCTruthList[MCTidx] == mct) break;
1592  }
1593 
1594  // loop over hits and add to the cluster
1595  for(unsigned int hiti = 0; hiti < hits.size(); ++hiti) {
1596  art::Ptr<rb::CellHit> hit = hits[hiti];
1597 
1598  // If the hit is noise, skip it.
1599  if(this->IsNoise(hit)) continue;
1600 
1601  const sim::Particle *part = this->HitToParticle(hit);
1602  unsigned int idx = fTrackIDToMCTruthIndex[part->TrackId()];
1603  if(idx == MCTidx) cluster.Add(hit);
1604 
1605  } // end loop over hits
1606 
1607  return cluster;
1608  }
A collection of associated CellHits.
Definition: Cluster.h:47
const sim::Particle * HitToParticle(art::Ptr< rb::CellHit > const &hit, bool quiet=false) const
Returns the sim::Particle object contributing the most light to the specified rb::CellHit.
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
int TrackId() const
Definition: MCParticle.h:209
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
std::map< int, int > fTrackIDToMCTruthIndex
map of track id values to MCTruthList entry
Definition: BackTracker.h:949
Definition: structs.h:12
std::vector< const sim::Particle * > cheat::BackTracker::MCTruthToParticles ( art::Ptr< simb::MCTruth > const &  mct) const

Definition at line 534 of file BackTracker_service.cc.

References sim::ParticleNavigator::find(), fParticleNav, fTrackIDs, HitsToParticle(), runNovaSAM::ret, and TrackIDToMCTruth().

Referenced by caf::AddCosmicTruthToVec(), caf::CAFMaker::AddMCTruthToVec(), numue::NumuEAna::analyze(), murem::MuonRemoveAna::analyze(), mcchk::LeptonAna::analyze(), earms::ElasticArmsValidate::analyze(), mcchk::DetSimAna::analyze(), fuzz::FuzzyKValidate::analyze(), slid::LIDTraining::analyze(), cheat::CheckBackTracking::CheckTrackIdToParticle(), murem::MuonRemove::FillTruthInfo(), nuesand::FillNueSandbox::FillTruthVars(), nuesand::FillNueSandbox::GetECF(), numue::NumuEAlg::MCTruthEnergyVariables(), g4rwgt::MakeG4WeightTable::produce(), SliceToMCTruth(), SliceToNeutrinoIndex(), and SliceToNeutrinoInteractions().

535  {
536  std::vector<const sim::Particle*> ret;
537 
538  for(std::set<int>::const_iterator itr = fTrackIDs.begin(); itr != fTrackIDs.end(); itr++){
539  if( this->TrackIDToMCTruth(*itr) == mct ) ret.push_back(fParticleNav.find(*itr)->second);
540  }
541 
542  return ret;
543  }
std::set< int > fTrackIDs
G4 track ids for all particles in the events.
Definition: BackTracker.h:947
sim::ParticleNavigator fParticleNav
Particle navigator to map track ID to Particle.
Definition: BackTracker.h:946
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
iterator find(const key_type &key)
const sim::ParticleNavigator& cheat::BackTracker::ParticleNavigator ( ) const
inline

Get a reference to the ParticleNavigator.

Definition at line 748 of file BackTracker.h.

Referenced by cheat::TestTrackIds::analyze(), ve::VertexEva::analyze(), ddt::SMMEff::analyze(), calib::ParticleCorrections::analyze(), ddt::SMMADC::analyze(), mmc::Validation::analyze(), mcchk::ShowerAnaCheck::analyze(), zcl::SMMTriggerAna::analyze(), mcchk::MonopoleAna::analyze(), mcchk::CosmicAna::analyze(), vf::TrackEva::analyze(), zcl::MMCheater::analyze(), zcl::FmmTriggerAna::analyze(), mcchk::LeptonAna::analyze(), ddt::SlicerEva::analyze(), zcl::FmmTrackerValidation::analyze(), showere::ShowerEnergyAna::analyze(), mono::SlowMonopoleAna::analyze(), mono::Monopole::analyze(), zcl::FastMMStudy::analyze(), ncs::GenieTruth::analyze(), ddt::SuperDDTEva::analyze(), slid::LIDTraining::analyze(), ncs::NCAna::analyze(), htk::HoughTrack::analyze(), cheat::CheckBackTracking::CheckTrackIdToParticle(), trk::CosmicTrackAna::FillEventMCTruthHistograms(), caf::FillParticleTruth(), murem::MuonRemove::FillTruthInfo(), nuesand::FillNueSandbox::FillTruthVars(), tut::TutFilter::filter(), mono::EventSelector::filter(), showere::ShowerEnergyFilterMC::filter(), bsf::BremShowerFilter::findShowerByTruth(), calib::PCHitsList::GetTrueEnergyPathAndLightForCell(), skim::EvaluatorNumuCCpi::KeepEventSlices(), evd::MCTrueView::LoadEvent(), evd::SimulationDrawer::MCTruthLongText(), evd::SimulationDrawer::MCTruthTrajectoriesAnyD(), novaddt::UpMuAna::populateFLSmap(), mmc::Validation::print_truth_info(), mono::SlowMonopoleAna::print_truth_info(), evd::SimulationDrawer::PrintParticleAndOffspring(), cheat::ClusterCheater::produce(), tut::TutProducer::produce(), filter::TruthFilter::produce(), cheat::ProngCheater::produce(), cheat::ShowerCheater::produce(), cheat::TrackCheater::produce(), zcl::SMMCluster::produce(), sn::SupernovaMCCluster::produce(), cheat::MCCheater::produce(), cvn::ProngClassify(), murem::MuonRemove::RemoveByEfficiency(), and murem::MuonRemove::RemoveByTruth().

748 { return fParticleNav; }
sim::ParticleNavigator fParticleNav
Particle navigator to map track ID to Particle.
Definition: BackTracker.h:946
std::vector< sim::FLSHit > cheat::BackTracker::ParticleToFLSHit ( const int trackID) const

All the FLSHits that were created by the track id trackID, sorted from most to least light.

Definition at line 1521 of file BackTracker_service.cc.

References fTrackIDToFLSHit, it, and MF_LOG_DEBUG.

Referenced by ddt::SMMEff::analyze(), mmc::Validation::analyze(), zcl::SMMTriggerAna::analyze(), mcchk::MonopoleAna::analyze(), mcchk::CosmicAna::analyze(), numue::NumuEAna::analyze(), zcl::MMCheater::analyze(), mcchk::LeptonAna::analyze(), zcl::FmmTriggerAna::analyze(), ddt::SlicerEva::analyze(), zcl::FmmTrackerValidation::analyze(), mcchk::DetSimAna::analyze(), mono::SlowMonopoleAna::analyze(), mono::Monopole::analyze(), zcl::FastMMStudy::analyze(), ddt::SuperDDTEva::analyze(), upmuana::UpMuRecoAna::analyze(), htk::HoughTrack::analyze(), trk::CosmicTrackAna::FillEventMCTruthHistograms(), calib::StopperThreshold::FillHist(), calib::StopperThreshold::FillTree(), trk::CosmicTrackAna::FillTrueInfo(), calib::EnergyStandardCandles::FillTrueMichelInfo(), bsf::BremShowerFilter::findShowerByTruth(), calib::PCHitsList::GetTrueEnergyPathAndLightForCell(), numue::NumuEAlg::MCTruthEnergyVariables(), ParticleToFLSHit(), mmc::Validation::print_truth_info(), mono::SlowMonopoleAna::print_truth_info(), calib::PCHitsList::ProcessTrackForBelowThresholdHits(), calib::PCHitsList::ProcessTrackForFLSHits(), and zcl::SMMCluster::produce().

1521  {
1522  std::unordered_map< int, std::list<sim::FLSHit> >::const_iterator it = fTrackIDToFLSHit.find(trackID);
1523  if( it == fTrackIDToFLSHit.end() ){
1524  std::vector<sim::FLSHit> empty;
1525  MF_LOG_DEBUG("BackTracker") << "no collection of sim::FLSHit for "
1526  <<"Track ID "<<trackID
1527  << ". Returning empty vector";
1528 
1529  return empty;
1530  }
1531  else
1532  return std::vector<sim::FLSHit>(it->second.begin(), it->second.end());
1533  }
set< int >::iterator it
std::unordered_map< int, std::list< sim::FLSHit > > fTrackIDToFLSHit
map of G4 track ids to FLSHits
Definition: BackTracker.h:944
#define MF_LOG_DEBUG(id)
Int_t trackID
Definition: plot.C:84
std::vector< sim::FLSHit > cheat::BackTracker::ParticleToFLSHit ( const int  trackID,
const int  pdg 
) const

All the FLSHits that were created by the track id trackID, which also have a particular pdg. Most users should use the other version of this function. However, sometimes when our truth is condensed, the same mother track ID is assigned to FLS hits made by non-important daughters, who can have different PDG values. An example of this is a muon track, whose delta rays often have the track id of the mother muon. By using this version of the function, you can ensure you are looking only at the FLS hits deposited by the muon.

Fill only FLSHits with a given PDG

Definition at line 1537 of file BackTracker_service.cc.

References sim::FLSHit::GetPDG(), MECModelEnuComparisons::i, ParticleToFLSHit(), and make_root_from_grid_output::pdg.

1537  {
1538 
1539  const std::vector<sim::FLSHit>& flshits_with_same_track_id = ParticleToFLSHit(trackID);
1540 
1541  std::vector<sim::FLSHit> out_flshits;
1542 
1543  const int nflshits = flshits_with_same_track_id.size();
1544 
1545  /// Fill only FLSHits with a given PDG
1546  for(int i=0; i<nflshits; ++i){
1547  const sim::FLSHit& flshit= flshits_with_same_track_id[i];
1548  if(flshit.GetPDG() == pdg){
1549  out_flshits.push_back(flshit);
1550  }
1551  }
1552 
1553  return out_flshits;
1554  }
std::vector< sim::FLSHit > ParticleToFLSHit(const int &trackID) const
All the FLSHits that were created by the track id trackID, sorted from most to least light...
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
int GetPDG() const
PDG.
Definition: FLSHit.h:43
Int_t trackID
Definition: plot.C:84
const art::Ptr< simb::MCTruth > & cheat::BackTracker::ParticleToMCTruth ( const sim::Particle p) const

Definition at line 528 of file BackTracker_service.cc.

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

Referenced by cheat::TestTrackIds::analyze(), trk::KalmanTrackAna::CheckRecoTracks(), and cheat::CheckBackTracking::CheckTrackIdToParticle().

529  {
530  return this->TrackIDToMCTruth(p->TrackId());
531  }
int TrackId() const
Definition: MCParticle.h:209
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const
bool cheat::BackTracker::PassMuonCuts ( int  trackID,
art::PtrVector< rb::CellHit > const &  hits 
) const

Tool for NumuEAna that allows one to see if primary muon (or any track ID you feed the function) contributes to enough hits in the slice to pass the hit cut. It is currently set at 4 hits in each view.

Definition at line 972 of file BackTracker_service.cc.

References make_syst_table_plots::h, HitToTrackIDE(), geo::kX, geo::kY, art::PtrVector< T >::size(), confusionMatrixTree::t, and rb::CellHit::View().

Referenced by numue::NumuEAna::analyze(), trk::KalmanTrackAna::CheckRecoTracks(), and numue::NumuEAlg::MCTruthEnergyVariables().

974  {
975  int nxcells = 0;
976  int nycells = 0;
977 
978  for(size_t h = 0; h < hits.size(); ++h){
979 
980  art::Ptr<rb::CellHit> hit = hits[h];
981  std::vector<TrackIDE> tracks = HitToTrackIDE(hit);
982  for(size_t t = 0; t < tracks.size(); ++t){
983  if(tracks[t].trackID == trackID){
984 
985  if (hit->View() == geo::kX){
986  nxcells++;
987  }// end of loop over x hits
988 
989  if (hit->View() == geo::kY){
990  nycells++;
991  }// end of loop over y hits
992 
993  }// end of loop over hits from the muon
994  }// end of loop over tracks
995  }// end loop over hits
996 
997 
998  if ((nxcells >= 3) && (nycells >= 3)) return 1;
999  else return 0;
1000  }
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
geo::View_t View() const
Definition: CellHit.h:41
Vertical planes which measure X.
Definition: PlaneGeo.h:28
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
size_type size() const
Definition: PtrVector.h:302
Definition: structs.h:12
Int_t trackID
Definition: plot.C:84
void cheat::BackTracker::preProcessEvent ( art::Event const &  evt,
art::ScheduleContext   
)

This function rebuilds the various maps we need to answer backtracking queries. It is called automatically before each event is processed. For jobs involving Monte Carlo generation, this is too soon. So, ReadoutSim also calls this function when it knows all the relevant products have been produced. Requiring this kind of cooperation from other modules for a service to function properly is not recommended in general. In this case it seems like the least-bad option, but think very carefully before adding any other examples. "Do as I say, not as I do".

Definition at line 84 of file BackTracker_service.cc.

References Rebuild().

Referenced by BackTracker().

86  {
87  this->Rebuild(evt);
88  }
void Rebuild(art::Event const &evt)
int evt
template<class T >
std::vector<const T*> cheat::BackTracker::PtrVecToVecRawPtr ( const art::PtrVector< T > &  xs) const
inlineprivate

Helper function for implementing overloads.

NB the pointers are only valid so long as the parent xs is still around

Definition at line 865 of file BackTracker.h.

References runNovaSAM::ret, art::PtrVector< T >::size(), and submit_syst::x.

Referenced by SliceToMCTruth(), SliceToNeutrinoInteractions(), and TracksToParticles().

866  {
867  std::vector<const T*> ret;
868  ret.reserve(xs.size());
869  for(const art::Ptr<T>& x: xs) ret.push_back(x.get());
870  return ret;
871  }
size_type size() const
Definition: PtrVector.h:302
Definition: fwd.h:29
void cheat::BackTracker::Rebuild ( art::Event const &  evt)

Definition at line 91 of file BackTracker_service.cc.

References sim::ParticleNavigator::Add(), sim::PhotonSignal::Cell(), febshutoff_auto::chan, sim::ParticleNavigator::clear(), sim::CompareByNPhoton(), geo::GeometryBase::DetId(), MakeMiniprodValidationCuts::f, art::Handle< T >::failedToGet(), fCellToFLSHit, fCellToPhotonSignal, fDetID, fHaveTruthInfo, fMCTruthList, fNumTrueEnergyWarnings, fParams, fParticleNav, fSliceIDForHitParticleMap, fTrackIDs, fTrackIDToFLSHit, fTrackIDToMCTruthIndex, fTrackIDToTrueEIndex, fTrueEnergyList, cheat::BackTracker::Params::GeantModuleLabel, geom(), art::DataViewImpl::getByLabel(), sim::FLSHit::GetCellID(), sim::FLSHit::GetPlaneID(), sim::FLSHit::GetTrackID(), hits(), MECModelEnuComparisons::i, art::DataViewImpl::isRealData(), it, novadaq::cnv::kUNKNOWN_DET, submit_hadd::l, cheat::BackTracker::Params::MCOverlayMode, MF_LOG_DEBUG, cheat::BackTracker::Params::MRMode, part, cheat::BackTracker::Params::PhotonModuleLabel, sim::PhotonSignal::Plane(), cheat::sortFLSHit(), and cheat::BackTracker::Params::TrueEnergyModuleLabel.

Referenced by preProcessEvent(), MergeDaqCollections::MergeDaqCollections::produce(), and rsim::ReadoutSim::produce().

92  {
93  // Clear out anything remaining from previous calls to Rebuild
94  fCellToFLSHit.clear();
95  fTrackIDToFLSHit.clear();
96  fCellToPhotonSignal.clear();
97  fTrackIDs.clear();
99  fMCTruthList.clear();
101  fTrueEnergyList.clear();
102  fTrackIDToTrueEIndex.clear();
103  fHaveTruthInfo = false; // Haven't got anything yet
104  fDetID = novadaq::cnv::kUNKNOWN_DET; // Haven't found detector type yet
105 
106  // do nothing if this is data
107  if(evt.isRealData() && !fParams.MRMode()
108  && !fParams.MCOverlayMode()) return;
109 
110  // get detector for CloseInTime function
112  fDetID = geom->DetId();
113 
114  // fill the map of OfflineChan to std::vector<FLSHit>
115  // first get the FLSHitList from the event
117  evt.getByLabel(fParams.GeantModuleLabel(), flslistHandle);
118 
119  // Probably this is a MC generation job and this is the preEvent callback
120  // which is too early. That's OK, we'll get called at the right time by
121  // ReadoutSim in a moment. Or we're mock data or something.
122  if(flslistHandle.failedToGet()) return;
123 
124  fHaveTruthInfo = true; // We got FLSHits, the rest should go well too
125 
126  // loop over the FLSHits and fill the std::vector for each
127  // channel
128  for( size_t l = 0; l < flslistHandle->size(); ++l){
129  const std::vector<sim::FLSHit> &hits = flslistHandle->at(l).fHits;
130  for( size_t f = 0; f < hits.size(); ++f){
131  const sim::FLSHit& hit = hits[f];
132  const geo::OfflineChan chan(hit.GetPlaneID(), hit.GetCellID());
133  fCellToFLSHit[chan].push_back(hit);
134  fTrackIDToFLSHit[hit.GetTrackID()].push_back(hit);
135  }// end loop over flshits
136  }// end loop over flshit lists
137 
138  // loop over the map and sort the vectors of flshits
139  for(auto itr = fCellToFLSHit.begin(); itr != fCellToFLSHit.end(); itr++){
140  itr->second.sort(sortFLSHit);
141  }
142 
143  // loop over the map and sort the vectors of flshits
144  for(auto pfitr = fTrackIDToFLSHit.begin(); pfitr != fTrackIDToFLSHit.end(); pfitr++){
145  pfitr->second.sort(sortFLSHit);
146  }
147 
148  // Similarly, PhotonSignals
150  evt.getByLabel(fParams.PhotonModuleLabel(), phots);
151 
152  if(!phots.failedToGet()){
153  for(size_t i = 0; i < phots->size(); ++i){
154  const sim::PhotonSignal& phot = (*phots)[i];
155  const geo::OfflineChan chan(phot.Plane(), phot.Cell());
156  fCellToPhotonSignal[chan].push_back(phot);
157  } // end for i
158 
159  for(auto it = fCellToPhotonSignal.begin(); it != fCellToPhotonSignal.end(); ++it){
160  // Sort in reverse order, ie from most photons to least
161  std::sort(it->second.rbegin(), it->second.rend(), sim::CompareByNPhoton);
162  }
163  }
164  else{
165  mf::LogWarning("BackTracker") << "unable to find PhotonTransport "
166  << "created in " << fParams.PhotonModuleLabel() << " "
167  << "any attempt to get the PhotonTransport objects from "
168  << "the backtracker will fail";
169  }
170 
172  evt.getByLabel(fParams.GeantModuleLabel(), pHandle);
173  if(pHandle.failedToGet()){
174  mf::LogWarning("BackTracker") << "unable to find sim::Particles "
175  << "created in " << fParams.GeantModuleLabel() << " "
176  << "any attempt to get the Particles from "
177  << "the backtracker will fail";
178  }
179  else{
180  // Keep track of all the MCTruths we discover associated to the particles
181  std::set<art::Ptr<simb::MCTruth>> truths;
182  // And which truth each particle points at
183  std::map<int, art::Ptr<simb::MCTruth>> trackIDToMCTruthPtr;
184 
186  for(size_t p = 0; p < pHandle->size(); ++p){
187 
188  sim::Particle *part = new sim::Particle(pHandle->at(p));
189  fParticleNav.Add(part);
190 
191  // get the simb::MCTruth associated to this vector<Particle>
192  art::Ptr<simb::MCTruth> mct = fo.at(p);
193  truths.insert(mct);
194  try{
195  trackIDToMCTruthPtr.emplace(pHandle->at(p).TrackId(), mct);
196  }
197  catch(cet::exception &ex){
198  mf::LogWarning("BackTracker") << "unable to find MCTruth from Particle list "
199  << "created in " << fParams.GeantModuleLabel() << " "
200  << "any attempt to get the MCTruth objects from "
201  << "the backtracker will fail\n"
202  << "message from caught exception:\n" << ex;
203  }
204  } // end loop over particles to get MCTruthList
205 
206  // Flatten the MCTruth set into a vector
207  fMCTruthList.insert(fMCTruthList.end(), truths.begin(), truths.end());
208 
209  // Translate all the truth pointers into indices
210  std::map<art::Ptr<simb::MCTruth>, int> truthIdxs;
211  for(unsigned int i = 0; i < fMCTruthList.size(); ++i){
212  truthIdxs.emplace(fMCTruthList[i], i);
213  }
214 
215  // Convert trackIDToMCTruthPtr from Ptrs to indices
216  for(auto it: trackIDToMCTruthPtr){
217  fTrackIDToMCTruthIndex[it.first] = truthIdxs[it.second];
218  }
219  }
220 
221 
222  // fill the set of track ids from the ParticleNavigator
223  fTrackIDs.clear();
224  for(auto& it: fParticleNav) fTrackIDs.insert(it.first);
225 
226  MF_LOG_DEBUG("BackTracker") << fParticleNav;
227 
228  // Get the sim::TrueEnergy data products out of the event. I don't think that I'll be able to utilise the Assn
229  // between sim::Particle and sim::TrueEnergy here, as I would have to somehow have to pass the Assn around.
231  evt.getByLabel(fParams.TrueEnergyModuleLabel(), teHandle);
232  if(!teHandle.failedToGet()) {
233  // Get the TrueEnergy Assn, and loop through the particles.
235  for(size_t p = 0; p < pHandle->size(); ++p){
236  int parTrId = pHandle->at(p).TrackId();
237  // There should just be a 1 to 1 correspondance, however for some reason
238  // the first few particles may have multiple assns, and the last few none.
239  bool match_truep = false;
240  for(size_t te = 0; te < teAssn.at(p).size(); ++te){
241  if (parTrId == teAssn.at(p)[te]->TrackId()) {
242  match_truep = true;
243  fTrueEnergyList.push_back ( teAssn.at(p)[te] );
244  fTrackIDToTrueEIndex.emplace( parTrId, p );
245  }
246  }
247  if (!match_truep) {
248  // If didn't match, then it's one of the last particles, and so has an assn with a particle at the.
249  // start of the particle loop. Lets restart the loop over the particles, pulling those assns...
250  for(size_t par2 = 0; par2 < pHandle->size(); ++par2){
251  for(size_t te = 0; te < teAssn.at(par2).size(); ++te){
252  if (parTrId == teAssn.at(par2)[te]->TrackId()) {
253  fTrueEnergyList.push_back ( teAssn.at(par2)[te] );
254  fTrackIDToTrueEIndex.emplace( parTrId, p );
255  match_truep = true;
256  }
257  if (match_truep) break;
258  }
259  if (match_truep) break;
260  }
261  }
262  }
263 
264  /*
265  // I think that if using the true energy module you may have to use this technique.
266  // Totally my fault, I made the assns in different way for some reason...
267  art::FindOneP<sim::TrueEnergy> teAssn(pHandle, evt, fParams.TrueEnergyModuleLabel());
268  for(size_t p = 0; p < pHandle->size(); ++p){
269  art::Ptr<sim::TrueEnergy > MyEns = teAssn.at( p );
270  fTrueEnergyList.push_back( MyEns );
271  fTrackIDToTrueEIndex.emplace( pHandle->at(p).TrackId(), p );
272  }
273  */
274  } else if (fNumTrueEnergyWarnings<10) {
275  mf::LogWarning("BackTracker") << "unable to find sim::TrueEnergy "
276  << "created in " << fParams.TrueEnergyModuleLabel() << " "
277  << "any attempt to get the sim::TrueEnergy's from "
278  << "the backtracker will fail";
280  }
281  }
std::unordered_map< geo::OfflineChan, std::vector< sim::PhotonSignal > > fCellToPhotonSignal
map of PhotonSignals in each cell in event
Definition: BackTracker.h:945
set< int >::iterator it
int GetPlaneID() const
Plane ID.
Definition: FLSHit.h:37
std::set< int > fTrackIDs
G4 track ids for all particles in the events.
Definition: BackTracker.h:947
Atom< std::string > GeantModuleLabel
Definition: BackTracker.h:104
int GetCellID() const
Cell ID.
Definition: FLSHit.h:39
const char * p
Definition: xmltok.h:285
Atom< std::string > PhotonModuleLabel
Definition: BackTracker.h:105
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
std::unordered_map< geo::OfflineChan, std::list< sim::FLSHit > > fCellToFLSHit
map of FLSHits in each cell in event
Definition: BackTracker.h:943
Atom< std::string > TrueEnergyModuleLabel
Definition: BackTracker.h:112
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
TString part[npart]
Definition: Style.C:32
std::unordered_map< int, std::list< sim::FLSHit > > fTrackIDToFLSHit
map of G4 track ids to FLSHits
Definition: BackTracker.h:944
void hits()
Definition: readHits.C:15
std::vector< art::Ptr< sim::TrueEnergy > > fTrueEnergyList
all the TrueEnergy&#39;s for this event
Definition: BackTracker.h:950
sim::ParticleNavigator fParticleNav
Particle navigator to map track ID to Particle.
Definition: BackTracker.h:946
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
int evt
std::map< int, int > fTrackIDToTrueEIndex
map of track id values to TrueEnergy entry
Definition: BackTracker.h:951
int Cell() const
Definition: PhotonSignal.h:31
bool CompareByNPhoton(const sim::PhotonSignal &a, const sim::PhotonSignal &b)
Helper for SortByNPhoton.
int GetTrackID() const
Track ID.
Definition: FLSHit.h:45
bool fHaveTruthInfo
Set by Rebuild.
Definition: BackTracker.h:939
std::map< int, int > fTrackIDToMCTruthIndex
map of track id values to MCTruthList entry
Definition: BackTracker.h:949
Definition: structs.h:12
A (plane, cell) pair.
Definition: OfflineChan.h:17
static bool sortFLSHit(sim::FLSHit const &a, sim::FLSHit const &b)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geom(int which=0)
Definition: geom.C:163
#define MF_LOG_DEBUG(id)
ParticleNavigator Add(const int &offset) const
novadaq::cnv::DetId fDetID
detector id
Definition: BackTracker.h:941
bool failedToGet() const
Definition: Handle.h:190
int Plane() const
Definition: PhotonSignal.h:32
std::vector< std::vector< cheat::NeutrinoEffPur > > cheat::BackTracker::SlicesToMCTruthsTable ( const std::vector< const rb::Cluster * > &  sliceList) const

Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures of MCTruth, efficiency, and purity of that MCTruth interaction relative to the slice. The returned vector is the same size as the total number of slices, including the noise slice, which is treated the same as any other slice. It is sorted in the same order as the slice list. For each entry, there is a vector of NeutrinoEffPurs. This vector is the same size as the MCTruth list. It is sorted in the same order as the MCTruth list. Every slice/MCTruth pair shows up, even if the contribution is zero. Efficiency is defined as FLS energy from a MCTruth in a slice / total FLS energy from a MCTruth in event. This function is agnostic to MCTruth and treates them all the same, including those without neutrino interactions, i.e. cosmics.

Definition at line 1266 of file BackTracker_service.cc.

References abs(), allMCTruth(), efficiency(), fTrackIDToMCTruthIndex, make_syst_table_plots::h, HitToTrackIDE(), IsNoise(), cheat::NeutrinoEffPur::neutrinoInt, purity(), confusionMatrixTree::t, getGoodRuns4SAM::table, trackID, and TracksToParticles().

Referenced by tut::RecoValidationTutorial::analyze(), bpfit::BPFEnergyAna::analyze(), cvn::CVNEventDump::analyze(), cvn::CVNCosmicEventDump::analyze(), earms::ElasticArmsValidate::analyze(), cvn::CVNEventProngDump::analyze(), slicer::SlicerAna::analyze(), fuzz::FuzzyKValidate::analyze(), bpfit::BPFTmvaTrainer::analyze(), bpf::BPFCVNAna::analyze(), bpfit::BreakPointProtonAna::analyze(), cvn::CVNAddTrainingData::produce(), murem::FindMREParent::produce(), fuzz::FuzzyKVertex::produce(), caf::CAFMaker::produce(), skim::SkimmingUtils::SliceMCTruthAssociation(), and SliceToMCTruth().

1267  {
1268 
1269  unsigned int numSlices = sliceList.size();
1270  std::vector<NeutrinoWithIndex> truthList = allMCTruth();
1271  unsigned int numTruths = truthList.size();
1272 
1273  //This is what will eventually be returned
1274  std::vector< std::vector<cheat::NeutrinoEffPur> > table(numSlices,std::vector<cheat::NeutrinoEffPur>(numTruths));
1275 
1276  //Loop to fill NeutrinoEffPur's with proper truth information
1277  for (unsigned int s = 0; s < numSlices; s++){
1278  for (unsigned int t = 0; t < numTruths; t++){
1279  cheat::NeutrinoEffPur truthFill = {truthList[t].neutrinoInt,0.0,0.0,truthList[t].truthColIndex,0.0,0.0,0,0};
1280  table[s][t] = truthFill;
1281  }
1282  }//End of defining basic container with truths filled in
1283 
1284  for (unsigned int s = 0; s < numSlices; s++){
1285  //Vector to hold the total energy contributions to slice from each MC Truth
1286  std::vector<double> sliceEnergies(numTruths,0.0);
1287  //Vector to hold the total number of hits in the slice from each MC Truth
1288  std::vector<int> sliceHits(numTruths,0);
1289 
1290  for (unsigned int h = 0; h < sliceList[s]->NCell(); h++){
1291  //Don't worry about noise hits - they can't count towards the energy an interaction deposited
1292  if (IsNoise(sliceList[s]->Cell(h))) continue;
1293  //Vector to hold the total energy contributions to hit from each MC Truth
1294  std::vector<double> hitEnergies(numTruths,0.0);
1295 
1296  const std::vector<TrackIDE> trackIDs = HitToTrackIDE(sliceList[s]->Cell(h));
1297  for (unsigned int id = 0; id < trackIDs.size(); id++){
1298  int trackID = trackIDs[id].trackID;
1299  //Gets the MCTruth index for the particle trackID
1300  int truthID = fTrackIDToMCTruthIndex.find(abs(trackID))->second;
1301  hitEnergies[truthID] += trackIDs[id].energy;
1302  }//End of loop over track ids for the hit
1303 
1304  //Add hit values into the slice vectors
1305  for (unsigned int q = 0; q < numTruths; q++){
1306  if (hitEnergies[q] > 0.0){
1307  sliceEnergies[q] += hitEnergies[q];
1308  sliceHits[q] += 1;
1309  }//Only do for MCTruths with nonzero contributions to hit
1310  }//End of loop adding hit values to slice vectors
1311 
1312  }//End of loop over hits in slice
1313 
1314  double totalSliceE = std::accumulate(sliceEnergies.begin(),sliceEnergies.end(),0.0);
1315  for (unsigned int t = 0; t < numTruths; t++){
1316 
1317  double purity = 0.0;
1318  if (totalSliceE > 0){
1319  purity = (sliceEnergies[t])/totalSliceE;
1320  }
1321 
1322  if ((purity < 0) || (purity > 1)) {
1323  throw cet::exception("BackTrackerIllegalPurity")
1324  << "The purity value "<<purity<<" is not allowed. \n";
1325  }
1326 
1327  table[s][t].purity = purity;
1328  table[s][t].energySlice = sliceEnergies[t];
1329  table[s][t].nSliceHits = sliceHits[t];
1330 
1331  }//End of loop over MCTruths for the slice
1332  }//End of loop over slices
1333 
1334  for (unsigned int t = 0; t < numTruths; t++){
1335 
1336  double totalMCTruthE = 0.0;
1337  int totalMCTruthHits = 0;
1338 
1339  for (unsigned int s = 0; s < numSlices; s++){
1340  totalMCTruthE += table[s][t].energySlice;
1341  totalMCTruthHits += table[s][t].nSliceHits;
1342  }//Loop over slices to find summed values
1343 
1344  for (unsigned int s = 0; s < numSlices; s++){
1345 
1346  double efficiency = 0.0;
1347  if (totalMCTruthE > 0){
1348  efficiency = (table[s][t].energySlice)/totalMCTruthE;
1349  }
1350 
1351  if ((efficiency < 0) || (efficiency > 1)) {
1352  throw cet::exception("BackTrackerIllegalEfficiency")
1353  << "The efficiency value "<<efficiency<<" is not allowed. \n";
1354  }
1355 
1356  table[s][t].efficiency = efficiency;
1357  table[s][t].energyTotal = totalMCTruthE;
1358  table[s][t].nTotalHits = totalMCTruthHits;
1359  }//Loop over slices to insert final values
1360 
1361  }//End of final loop over MCTruths for summed values
1362 
1363  return table;
1364  }
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
std::vector< NeutrinoWithIndex > allMCTruth() const
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
void abs(TH1 *hist)
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
const XML_Char * s
Definition: expat.h:262
void purity()
Definition: purity.C:35
std::map< int, int > fTrackIDToMCTruthIndex
map of track id values to MCTruthList entry
Definition: BackTracker.h:949
Int_t trackID
Definition: plot.C:84
void efficiency()
Definition: efficiency.C:58
art::Ptr< simb::MCTruth > neutrinoInt
Truth information about neutrino interaction.
Definition: BackTracker.h:49
std::vector<std::vector<cheat::NeutrinoEffPur> > cheat::BackTracker::SlicesToMCTruthsTable ( const std::vector< rb::Cluster > &  sliceList) const
inline

Definition at line 663 of file BackTracker.h.

664  {
665  return SlicesToMCTruthsTable(VecToVecRawPtr(sliceList));
666  }
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector<std::vector<cheat::NeutrinoEffPur> > cheat::BackTracker::SlicesToMCTruthsTable ( const std::vector< art::Ptr< rb::Cluster >> &  sliceList) const
inline

Definition at line 669 of file BackTracker.h.

670  {
671  return SlicesToMCTruthsTable(VecPtrToVecRawPtr(sliceList));
672  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
std::vector<std::vector<cheat::NeutrinoEffPur> > cheat::BackTracker::SlicesToMCTruthsTable ( const art::PtrVector< rb::Cluster > &  sliceList) const
inline

Definition at line 675 of file BackTracker.h.

676  {
677  return SlicesToMCTruthsTable(PtrVecToVecRawPtr(sliceList));
678  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
std::vector< NeutrinoEffPur > cheat::BackTracker::SliceToMCTruth ( const std::vector< const rb::CellHit * > &  sliceHits,
const std::vector< const rb::CellHit * > &  allHits,
bool  sortPur = false 
) const

Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.

Definition at line 1219 of file BackTracker_service.cc.

References fMCTruthList, HitCollectionEfficiency(), HitCollectionPurity(), MECModelEnuComparisons::i, geo::kXorY, MCTruthToParticles(), demo::particleList, sort_eff(), and sort_pur().

Referenced by showere::ShowerEnergyAna::analyze(), ncid::NCNNKerasVal::analyze(), slid::LIDTraining::analyze(), showere::ShowerEnergyFilterMC::filter(), evd::SliceNavigator::GetProducts(), ncid::NCNNKeras::produce(), SliceToMCTruth(), and SliceToOrderedNuIdsByEnergy().

1222  {
1223  std::vector <NeutrinoEffPur> sliceNeutrinoInteractions;
1224 
1225  for (unsigned int s = 0; s < fMCTruthList.size(); s++){
1226  const art::Ptr<simb::MCTruth> neutrinoInteraction = fMCTruthList[s];
1227 
1228  std::vector<const sim::Particle*> particleList = MCTruthToParticles(neutrinoInteraction);
1229  std::set<int> neutrinoTrackIDs;
1230  for (unsigned int i = 0; i < particleList.size(); ++i){
1231  neutrinoTrackIDs.insert(particleList[i]->TrackId());
1232  }
1233 
1234  double energySlice = -1.0;
1235  double energyTotal = -1.0;
1236  int nSliceHits = 0;
1237  int nTotalHits = 0;
1238 
1239  double sliceEff = HitCollectionEfficiency(neutrinoTrackIDs, sliceHits, allHits, geo::kXorY, 0, true, &energySlice, &energyTotal, &nSliceHits, &nTotalHits);
1240  double slicePur = HitCollectionPurity(neutrinoTrackIDs, sliceHits, 0, 0, true);
1241 
1242  if (sliceEff > 0){
1243  NeutrinoEffPur sliceNeutrinoInteraction = {neutrinoInteraction, sliceEff, slicePur, s, energySlice, energyTotal, nSliceHits, nTotalHits};
1244  sliceNeutrinoInteractions.push_back(sliceNeutrinoInteraction);
1245  }
1246  }//End of loop over neutrino interactions
1247 
1248  if (!sortPur) std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_eff);
1249  else std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_pur);
1250 
1251  return sliceNeutrinoInteractions;
1252  }
X or Y views.
Definition: PlaneGeo.h:30
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
const XML_Char * s
Definition: expat.h:262
static bool sort_pur(const NeutrinoEffPur &a, const NeutrinoEffPur &b)
Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest p...
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
static bool sort_eff(const NeutrinoEffPur &a, const NeutrinoEffPur &b)
Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest e...
particleList
Definition: demo.py:41
std::vector< const sim::Particle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const std::vector< rb::CellHit > &  sliceHits,
const std::vector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 592 of file BackTracker.h.

595  {
596  return SliceToMCTruth(VecToVecRawPtr(sliceHits),
597  VecToVecRawPtr(allHits),
598  sortPur);
599  }
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const std::vector< art::Ptr< rb::CellHit >> &  sliceHits,
const std::vector< art::Ptr< rb::CellHit >> &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 602 of file BackTracker.h.

605  {
606  return SliceToMCTruth(VecPtrToVecRawPtr(sliceHits),
607  VecPtrToVecRawPtr(allHits),
608  sortPur);
609  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const art::PtrVector< rb::CellHit > &  sliceHits,
const art::PtrVector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 612 of file BackTracker.h.

615  {
616  return SliceToMCTruth(PtrVecToVecRawPtr(sliceHits),
617  PtrVecToVecRawPtr(allHits),
618  sortPur);
619  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector< NeutrinoEffPur > cheat::BackTracker::SliceToMCTruth ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< const rb::CellHit * > &  allHits,
bool  sortPur = false 
) const

Definition at line 1256 of file BackTracker_service.cc.

References rb::Cluster::AllCells(), PtrVecToVecRawPtr(), SlicesToMCTruthsTable(), and SliceToMCTruth().

1259  {
1260  return SliceToMCTruth(PtrVecToVecRawPtr(sliceCluster->AllCells()),
1261  allHits, sortPur);
1262  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 627 of file BackTracker.h.

630  {
631  return SliceToMCTruth(sliceCluster, VecToVecRawPtr(allHits), sortPur);
632  }
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< art::Ptr< rb::CellHit >> &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 635 of file BackTracker.h.

638  {
639  return SliceToMCTruth(sliceCluster, VecPtrToVecRawPtr(allHits), sortPur);
640  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToMCTruth ( const art::Ptr< rb::Cluster > &  sliceCluster,
const art::PtrVector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 643 of file BackTracker.h.

646  {
647  return SliceToMCTruth(sliceCluster, PtrVecToVecRawPtr(allHits), sortPur);
648  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
std::vector< int > cheat::BackTracker::SliceToNeutrinoIndex ( const std::vector< const rb::CellHit * > &  sliceHits,
const std::vector< const rb::CellHit * > &  allHits,
bool  sortPur = false 
) const

Given a collection of hits (often a slice), returns vector of neutrino indices corresponding to the vector from SliceToNeutrinoInteractions.

Definition at line 1023 of file BackTracker_service.cc.

References fMCTruthList, HitCollectionEfficiency(), HitCollectionPurity(), MECModelEnuComparisons::i, geo::kXorY, make_pair(), MCTruthToParticles(), simb::MCTruth::NeutrinoSet(), demo::particleList, SliceToNeutrinoInteractions(), sort_idxeff(), and sort_idxpur().

Referenced by cvn::HitNuIndex(), and sort_idxpur().

1026  {
1027  std::vector < std::pair<unsigned int,NeutrinoEffPur> > sliceNeutrinoInteractions;
1028 
1029  for (unsigned int s = 0; s < fMCTruthList.size(); s++){
1030  const art::Ptr<simb::MCTruth> neutrinoInteraction = fMCTruthList[s];
1031  if(!neutrinoInteraction->NeutrinoSet())
1032  continue;
1033 
1034  std::vector<const sim::Particle*> particleList = MCTruthToParticles(neutrinoInteraction);
1035  std::set<int> neutrinoTrackIDs;
1036  for (unsigned int i = 0; i < particleList.size(); ++i){
1037  neutrinoTrackIDs.insert(particleList[i]->TrackId());
1038  }
1039 
1040  double energySlice = -1.0;
1041  double energyTotal = -1.0;
1042  int nSliceHits = 0;
1043  int nTotalHits = 0;
1044 
1045  double sliceEff = HitCollectionEfficiency(neutrinoTrackIDs, sliceHits, allHits, geo::kXorY, 0, true, &energySlice, &energyTotal, &nSliceHits, &nTotalHits);
1046  double slicePur = HitCollectionPurity(neutrinoTrackIDs, sliceHits, 0, 0, true);
1047 
1048  if (sliceEff > 0){
1049  NeutrinoEffPur sliceNeutrinoInteraction = {neutrinoInteraction, sliceEff, slicePur, s, energySlice, energyTotal, nSliceHits, nTotalHits};
1050  sliceNeutrinoInteractions.push_back( std::make_pair(s,sliceNeutrinoInteraction) );
1051  }
1052  }//End of loop over neutrino interactions
1053 
1054  if (!sortPur) std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_idxeff);
1055  else std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_idxpur);
1056 
1057  std::vector<int> nuIndex;
1058 
1059  for (unsigned int i = 0; i<sliceNeutrinoInteractions.size(); ++i ){
1060  nuIndex.push_back( int(sliceNeutrinoInteractions[i].first) );
1061  }
1062 
1063  return nuIndex;
1064  }
static bool sort_idxeff(const std::pair< int, NeutrinoEffPur > &a, const std::pair< int, NeutrinoEffPur > &b)
Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest efficien...
X or Y views.
Definition: PlaneGeo.h:30
static bool sort_idxpur(const std::pair< int, NeutrinoEffPur > &a, const std::pair< int, NeutrinoEffPur > &b)
Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest purity f...
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
const XML_Char * s
Definition: expat.h:262
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
particleList
Definition: demo.py:41
bool NeutrinoSet() const
Definition: MCTruth.h:78
std::vector< const sim::Particle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
std::vector< NeutrinoEffPur > cheat::BackTracker::SliceToNeutrinoInteractions ( const std::vector< const rb::CellHit * > &  sliceHits,
const std::vector< const rb::CellHit * > &  allHits,
bool  sortPur = false 
) const

Given a collection of hits (often a slice), returns vector of structures of neutrino interactions, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest.

Definition at line 1069 of file BackTracker_service.cc.

References fMCTruthList, HitCollectionEfficiency(), HitCollectionPurity(), MECModelEnuComparisons::i, geo::kXorY, MCTruthToParticles(), simb::MCTruth::NeutrinoSet(), demo::particleList, sort_eff(), and sort_pur().

Referenced by qeef::QeFinderVal::analyze(), remid::ReMIdValidate::analyze(), remid::ReMIdTrain::analyze(), numue::NumuEAna::analyze(), murem::MuonRemoveAna::analyze(), remid::ReMIdDedx::analyze(), showere::ShowerEnergyAna::analyze(), remid::ReMIdDedxRock::analyze(), remid::ReMIdDedxStudies::analyze(), ncs::Xbeam::analyze(), ncs::Xeff::analyze(), ncs::NCAna::analyze(), nuesand::FillNueSandbox::FillTruthVars(), numue::NumuEAlg::MCTruthEnergyVariables(), SliceToNeutrinoIndex(), and SliceToNeutrinoInteractions().

1072  {
1073  std::vector <NeutrinoEffPur> sliceNeutrinoInteractions;
1074 
1075  for (unsigned int s = 0; s < fMCTruthList.size(); s++){
1076  const art::Ptr<simb::MCTruth> neutrinoInteraction = fMCTruthList[s];
1077  if(!neutrinoInteraction->NeutrinoSet())
1078  continue;
1079 
1080  std::vector<const sim::Particle*> particleList = MCTruthToParticles(neutrinoInteraction);
1081  std::set<int> neutrinoTrackIDs;
1082  for (unsigned int i = 0; i < particleList.size(); ++i){
1083  neutrinoTrackIDs.insert(particleList[i]->TrackId());
1084  }
1085 
1086  double energySlice = -1.0;
1087  double energyTotal = -1.0;
1088  int nSliceHits = 0;
1089  int nTotalHits = 0;
1090 
1091  double sliceEff = HitCollectionEfficiency(neutrinoTrackIDs, sliceHits, allHits, geo::kXorY, 0, true, &energySlice, &energyTotal, &nSliceHits, &nTotalHits);
1092  double slicePur = HitCollectionPurity(neutrinoTrackIDs, sliceHits, 0, 0, true);
1093 
1094  if (sliceEff > 0){
1095  NeutrinoEffPur sliceNeutrinoInteraction = {neutrinoInteraction, sliceEff, slicePur, s, energySlice, energyTotal, nSliceHits, nTotalHits};
1096  sliceNeutrinoInteractions.push_back(sliceNeutrinoInteraction);
1097  }
1098  }//End of loop over neutrino interactions
1099 
1100  if (!sortPur) std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_eff);
1101  else std::sort(sliceNeutrinoInteractions.begin(),sliceNeutrinoInteractions.end(),sort_pur);
1102 
1103  return sliceNeutrinoInteractions;
1104  }
X or Y views.
Definition: PlaneGeo.h:30
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
const XML_Char * s
Definition: expat.h:262
static bool sort_pur(const NeutrinoEffPur &a, const NeutrinoEffPur &b)
Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest p...
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
static bool sort_eff(const NeutrinoEffPur &a, const NeutrinoEffPur &b)
Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest e...
particleList
Definition: demo.py:41
bool NeutrinoSet() const
Definition: MCTruth.h:78
std::vector< const sim::Particle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const std::vector< rb::CellHit > &  sliceHits,
const std::vector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 496 of file BackTracker.h.

499  {
501  VecToVecRawPtr(allHits),
502  sortPur);
503  }
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const std::vector< art::Ptr< rb::CellHit >> &  sliceHits,
const std::vector< art::Ptr< rb::CellHit >> &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 506 of file BackTracker.h.

509  {
511  VecPtrToVecRawPtr(allHits),
512  sortPur);
513  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const art::PtrVector< rb::CellHit > &  sliceHits,
const art::PtrVector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 516 of file BackTracker.h.

519  {
521  PtrVecToVecRawPtr(allHits),
522  sortPur);
523  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector< NeutrinoEffPur > cheat::BackTracker::SliceToNeutrinoInteractions ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< const rb::CellHit * > &  allHits,
bool  sortPur = false 
) const

Definition at line 1108 of file BackTracker_service.cc.

References rb::Cluster::AllCells(), PtrVecToVecRawPtr(), SliceToNeutrinoInteractions(), and SliceToOrderedNuIds().

1111  {
1112  return SliceToNeutrinoInteractions(PtrVecToVecRawPtr(sliceCluster->AllCells()),
1113  allHits, sortPur);
1114  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 531 of file BackTracker.h.

534  {
535  return SliceToNeutrinoInteractions(sliceCluster,
536  VecToVecRawPtr(allHits),
537  sortPur);
538  }
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const art::Ptr< rb::Cluster > &  sliceCluster,
const std::vector< art::Ptr< rb::CellHit >> &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 541 of file BackTracker.h.

544  {
545  return SliceToNeutrinoInteractions(sliceCluster,
546  VecPtrToVecRawPtr(allHits),
547  sortPur);
548  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector<NeutrinoEffPur> cheat::BackTracker::SliceToNeutrinoInteractions ( const art::Ptr< rb::Cluster > &  sliceCluster,
const art::PtrVector< rb::CellHit > &  allHits,
bool  sortPur = false 
) const
inline

Definition at line 551 of file BackTracker.h.

554  {
555  return SliceToNeutrinoInteractions(sliceCluster,
556  PtrVecToVecRawPtr(allHits),
557  sortPur);
558  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< NeutrinoEffPur > SliceToNeutrinoInteractions(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of neutrino interactions...
std::vector< int > cheat::BackTracker::SliceToOrderedNuIds ( const std::vector< cheat::NeutrinoWithIndex > &  nusWithIdx,
const std::vector< std::vector< cheat::NeutrinoEffPur >> &  slTruthTable,
std::function< double(const cheat::NeutrinoEffPur &)>  slMetric,
std::function< double(const cheat::NeutrinoEffPur &)>  nuMetric 
) const

Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.

Definition at line 1118 of file BackTracker_service.cc.

References ana::assert(), art::Ptr< T >::isNull(), cheat::NeutrinoEffPur::neutrinoInt, PandAna.Demos.tute_pid_validation::slc, and SliceToOrderedNuIdsByEff().

Referenced by tut::RecoValidationTutorial::analyze(), bpf::BPFCVNAna::analyze(), caf::CAFMaker::produce(), skim::SkimmingUtils::SliceMCTruthAssociation(), SliceToNeutrinoInteractions(), SliceToOrderedNuIdsByEff(), SliceToOrderedNuIdsByEffPur(), SliceToOrderedNuIdsByEnergy(), and SliceToOrderedNuIdsByPur().

1122  {
1123 
1124  for( auto slc: slTruthTable )
1125  assert( slc.size() == nusWithIdx.size() && "Badly shaped Slice/truth table!" );
1126 
1127  // Fill with one Nu Id per slice
1128  std::vector<int> nuIds( slTruthTable.size(), -1 );
1129  if( nusWithIdx.empty() ) return nuIds;
1130 
1131  // Find the best slice for each nu
1132  std::vector<int> bestSlices( nusWithIdx.size() );
1133  for( size_t nuIdx = 0; nuIdx < nusWithIdx.size(); ++nuIdx ){
1134  float maxValue = 0;
1135  int bestSlice = -1;
1136 
1137  for( size_t sliceIdx = 0; sliceIdx < slTruthTable.size(); ++sliceIdx ){
1138  const cheat::NeutrinoEffPur& effpur = slTruthTable[sliceIdx][nuIdx];
1139 
1140  if( !effpur.neutrinoInt.isNull() ){
1141  if( slMetric(effpur) > maxValue ){
1142  maxValue = slMetric(effpur);
1143  bestSlice = sliceIdx;
1144  }
1145  }
1146 
1147  } //sliceIdx
1148 
1149  bestSlices[nuIdx] = bestSlice;
1150 
1151  } // nuIdx
1152 
1153  // Find the best nu for each slice.
1154  for( size_t sliceIdx = 0; sliceIdx < slTruthTable.size(); ++sliceIdx ){
1155  float maxValue = 0;
1156  int bestNu = -1;
1157 
1158  for( size_t nuIdx = 0; nuIdx < slTruthTable[sliceIdx].size(); ++nuIdx ){
1159  const cheat::NeutrinoEffPur& effpur = slTruthTable[sliceIdx][nuIdx];
1160 
1161  if( !effpur.neutrinoInt.isNull() ){
1162  if( nuMetric(effpur) > maxValue ){
1163  maxValue = nuMetric(effpur);
1164  bestNu = nuIdx;
1165  }
1166  }
1167  } //nuIdx
1168 
1169  if( bestNu >= 0 && bestSlices[bestNu] == (int)sliceIdx )
1170  nuIds[sliceIdx] = bestNu;
1171 
1172  }//sliceIdx
1173 
1174  return nuIds;
1175  }
bool isNull() const noexcept
Definition: Ptr.h:193
assert(nhit_max >=nhit_nbins)
art::Ptr< simb::MCTruth > neutrinoInt
Truth information about neutrino interaction.
Definition: BackTracker.h:49
std::vector< int > cheat::BackTracker::SliceToOrderedNuIdsByEff ( const std::vector< cheat::NeutrinoWithIndex > &  nusWithIdx,
const std::vector< std::vector< cheat::NeutrinoEffPur >> &  slTruthTable 
) const

Definition at line 1179 of file BackTracker_service.cc.

References cheat::EffMetric(), SliceToOrderedNuIds(), and SliceToOrderedNuIdsByPur().

Referenced by earms::ElasticArmsValidate::analyze(), fuzz::FuzzyKValidate::analyze(), slid::LIDTraining::analyze(), fuzz::FuzzyKVertex::produce(), and SliceToOrderedNuIds().

1181  {
1182 
1183  return SliceToOrderedNuIds(nusWithIdx, slTruthTable, EffMetric, EffMetric);
1184 
1185  }
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
double EffMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur&#39;s nu interaction to slice efficiency.
std::vector< int > cheat::BackTracker::SliceToOrderedNuIdsByEffPur ( const std::vector< cheat::NeutrinoWithIndex > &  nusWithIdx,
const std::vector< std::vector< cheat::NeutrinoEffPur >> &  slTruthTable 
) const

Definition at line 1199 of file BackTracker_service.cc.

References cheat::EffPurMetric(), SliceToOrderedNuIds(), and SliceToOrderedNuIdsByEnergy().

Referenced by SliceToOrderedNuIdsByPur().

1201  {
1202 
1203  return SliceToOrderedNuIds(nusWithIdx, slTruthTable, EffPurMetric, EffPurMetric);
1204 
1205  }
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
double EffPurMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur&#39;s nu interaction to slice efficiency * purity.
std::vector< int > cheat::BackTracker::SliceToOrderedNuIdsByEnergy ( const std::vector< cheat::NeutrinoWithIndex > &  nusWithIdx,
const std::vector< std::vector< cheat::NeutrinoEffPur >> &  slTruthTable 
) const

Definition at line 1209 of file BackTracker_service.cc.

References cheat::EnergyMetric(), SliceToMCTruth(), and SliceToOrderedNuIds().

Referenced by cvn::CVNEventDump::analyze(), cvn::CVNCosmicEventDump::analyze(), cvn::CVNEventProngDump::analyze(), cvn::CVNAddTrainingData::produce(), and SliceToOrderedNuIdsByEffPur().

1211  {
1212 
1213  return SliceToOrderedNuIds(nusWithIdx, slTruthTable, EnergyMetric, EnergyMetric);
1214 
1215  }
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
double EnergyMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur&#39;s nu interaction to slice energy.
std::vector< int > cheat::BackTracker::SliceToOrderedNuIdsByPur ( const std::vector< cheat::NeutrinoWithIndex > &  nusWithIdx,
const std::vector< std::vector< cheat::NeutrinoEffPur >> &  slTruthTable 
) const

Definition at line 1189 of file BackTracker_service.cc.

References cheat::PurMetric(), SliceToOrderedNuIds(), and SliceToOrderedNuIdsByEffPur().

Referenced by SliceToOrderedNuIdsByEff().

1191  {
1192 
1193  return SliceToOrderedNuIds(nusWithIdx, slTruthTable, PurMetric, PurMetric);
1194 
1195  }
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
double PurMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur&#39;s nu interaction to slice purity.
bool cheat::BackTracker::sort_eff ( const NeutrinoEffPur a,
const NeutrinoEffPur b 
)
static

Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest efficiency first.

Definition at line 1004 of file BackTracker_service.cc.

References cheat::NeutrinoEffPur::efficiency.

Referenced by SliceToMCTruth(), and SliceToNeutrinoInteractions().

1004  {
1005  return a.efficiency>b.efficiency;
1006  }
const double a
const hit & b
Definition: hits.cxx:21
bool cheat::BackTracker::sort_idxeff ( const std::pair< int, NeutrinoEffPur > &  a,
const std::pair< int, NeutrinoEffPur > &  b 
)
static

Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest efficiency first.

Definition at line 1013 of file BackTracker_service.cc.

Referenced by SliceToNeutrinoIndex().

1013  {
1014  return a.second.efficiency>b.second.efficiency;
1015  }
const double a
const hit & b
Definition: hits.cxx:21
bool cheat::BackTracker::sort_idxpur ( const std::pair< int, NeutrinoEffPur > &  a,
const std::pair< int, NeutrinoEffPur > &  b 
)
static

Tool for function SliceToNeutrinoIndex, tells how to sort by putting structures with highest purity first.

Definition at line 1017 of file BackTracker_service.cc.

References SliceToNeutrinoIndex().

Referenced by SliceToNeutrinoIndex().

1017  {
1018  return a.second.purity>b.second.purity;
1019  }
const double a
const hit & b
Definition: hits.cxx:21
bool cheat::BackTracker::sort_pur ( const NeutrinoEffPur a,
const NeutrinoEffPur b 
)
static

Tool for function SliceToNeutrinoInteractions, tells how to sort by putting structures with highest purity first.

Definition at line 1009 of file BackTracker_service.cc.

References cheat::NeutrinoEffPur::purity.

Referenced by SliceToMCTruth(), and SliceToNeutrinoInteractions().

1009  {
1010  return a.purity>b.purity;
1011  }
const double a
const hit & b
Definition: hits.cxx:21
const art::Ptr< simb::MCTruth > & cheat::BackTracker::TrackIDToMCTruth ( int const &  id) const

Definition at line 512 of file BackTracker_service.cc.

References abs(), fMCTruthList, and fTrackIDToMCTruthIndex.

Referenced by caf::CAFMaker::AddMCTruthToVec(), cheat::CheckBackTracking::CheckTrackIdToParticle(), MCTruthToParticles(), and ParticleToMCTruth().

513  {
514  // find the entry in the MCTruth collection for this track id
515  size_t mct = fTrackIDToMCTruthIndex.find(abs(id))->second;
516 
517  if (mct > fMCTruthList.size() ) {
518  throw cet::exception("BackTracker")
519  << "attempting to find MCTruth index for "
520  << "out of range value: " << mct
521  << "/" << fMCTruthList.size() << "\n"
522  << __FILE__ << ":" << __LINE__ << "\n";
523  }
524  return fMCTruthList[mct];
525  }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
void abs(TH1 *hist)
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for this event
Definition: BackTracker.h:948
std::map< int, int > fTrackIDToMCTruthIndex
map of track id values to MCTruthList entry
Definition: BackTracker.h:949
const sim::Particle * cheat::BackTracker::TrackIDToMotherParticle ( int const &  id) const

Definition at line 503 of file BackTracker_service.cc.

References abs(), sim::ParticleNavigator::EveId(), fParticleNav, and TrackIDToParticle().

Referenced by remid::ReMIdTrain::analyze(), numue::NumuEAna::analyze(), fuzz::FuzzyKValidate::analyze(), trk::KalmanTrackAna::CheckRecoTracks(), cheat::CheckBackTracking::CheckTrackIdToParticle(), caf::FillParticleTruth(), numue::NumuEAlg::MCTruthEnergyVariables(), and murem::MergeTruth::produce().

504  {
505  // get the mother id from the particle navigator
506  // the EveId was adopted in the Rebuild method
507 
508  return this->TrackIDToParticle(fParticleNav.EveId(abs(id)));
509  }
void abs(TH1 *hist)
sim::ParticleNavigator fParticleNav
Particle navigator to map track ID to Particle.
Definition: BackTracker.h:946
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
int EveId(const int trackID) const
const sim::Particle * cheat::BackTracker::TrackIDToParticle ( int const &  id) const

Returns a pointer to the sim::Particle object corresponding to the given TrackID.

Definition at line 488 of file BackTracker_service.cc.

References abs(), sim::ParticleNavigator::end(), sim::ParticleNavigator::find(), and fParticleNav.

Referenced by caf::CAFMaker::AddMCTruthToVec(), caf::AddParticleToVec(), cheat::TestTrackIds::analyze(), remid::ReMIdValidate::analyze(), calib::ParticleCorrections::analyze(), numue::NumuEAna::analyze(), showere::ShowerEnergyAna::analyze(), bpfit::BreakPointProtonAna::analyze(), slid::LIDTraining::analyze(), sn::SupernovaMCCluster::BuildInteractionHitMap(), CalcDaughterEscapingEnergy(), cheat::RecoCheckAna::CheckRecoClusters(), trk::KalmanTrackAna::CheckRecoTracks(), cheat::CheckBackTracking::CheckTrackIdToParticle(), ClusterToParticle(), caf::FillParticleTruth(), calib::EnergyStandardCandles::FillTrueMichelInfo(), calib::EnergyStandardCandles::FillTruthInfo(), filter::TruthContain::filter(), showere::ShowerEnergyFilterMC::filter(), caf::FindAndAddMichels(), caf::FindDaughterVisE(), calib::EnergyStandardCandles::FindStoppingMuons(), calib::EnergyStandardCandles::FixPhotonAncestry(), cvn::Get2DProngEfficiencyByPDG(), cvn::Get2DProngEnergyByPDG(), cvn::Get2DProngPurityByPDG(), cvn::GetProngEfficiencyByPDG(), cvn::GetProngEnergyByPDG(), cvn::GetProngPurityByPDG(), cvn::HitClassify(), HitsToParticle(), HitToParticle(), caf::IsTrueDiF(), makeTraj(), numue::NumuEAlg::MCTruthEnergyVariables(), lem::MakeLibrary::produce(), cvn::ProngClassify(), TrackIDToMotherParticle(), and TracksToParticles().

489  {
491 
492  if(part_it == fParticleNav.end()){
493  mf::LogWarning("BackTracker") << "can't find particle with track id "
494  << id << " in sim::ParticleNavigator"
495  << " returning null pointer";
496  return 0;
497  }
498 
499  return part_it->second;
500  }
list_type::const_iterator const_iterator
void abs(TH1 *hist)
sim::ParticleNavigator fParticleNav
Particle navigator to map track ID to Particle.
Definition: BackTracker.h:946
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
iterator find(const key_type &key)
std::vector< ParticleEffPur > cheat::BackTracker::TracksToParticles ( const std::vector< const rb::Track * > &  tracks,
const std::set< int > &  trkIDs,
const std::set< int > &  allowedDaughters,
const std::vector< const rb::CellHit * > &  allHits 
) const

Given a collection of reconstructed tracks, this method finds the best match for each reco track to the input track id particles.

For each reconstructed track, the true particle that best matches the track by purity from the input trkIDs is determined. Each input track ID is only allowed to match at most one input track and any track IDs specified in the input allowedDaughters are not counted against a tracks purity. The tracks are matched to particles in the order that they appear in the input vector. Each entry in the returned vector of ParticleEffPur corresponds to the track in the same position as the input track vector and holds the matched track id, efficiency, purity, and pdg of the best matched particle for the given track. If no track id is found to match the track, then the purity, efficiency, and pdg will be zero. You need to check that a match exists before trying to use the matched track id in other functions

Definition at line 1368 of file BackTracker_service.cc.

References ana::assert(), simb::MCParticle::Daughter(), HitCollectionEfficiency(), HitCollectionPurity(), MECModelEnuComparisons::i, ideff, it, geo::kXorY, cafExposure::match, overlay_prestage_def::matches, simb::MCParticle::NumberDaughters(), genie::utils::res::PdgCode(), simb::MCParticle::PdgCode(), PtrVecToVecRawPtr(), and TrackIDToParticle().

Referenced by remid::ReMIdTrain::analyze(), and SlicesToMCTruthsTable().

1372  {
1373  std::vector<ParticleEffPur> matches;
1374 
1375  std::set<int> trkIDs = trackIDs;
1376  std::set<int> allowedDaughters = allowedDaughterIDs;
1377 
1378  std::map<int, int> parents;
1379  for(std::set<int>::iterator it = trkIDs.begin(); it != trkIDs.end(); ++it){
1380  const sim::Particle* mother = TrackIDToParticle(*it);
1381  if(!mother) continue;
1382  for(int i = 0; i < mother->NumberDaughters(); ++i){
1383  const int id = mother->Daughter(i);
1385  if(allowedDaughters.count(TrackIDToParticle(id)->PdgCode())){
1386  parents[id] = *it;
1387  }
1388  } // end for i
1389  } // end for it
1390 
1391  // loop over all tracks
1392  for(unsigned int itrack = 0; itrack < tracks.size(); ++itrack){
1393  // get the purity of the track for all track IDs
1394  std::map<int, double> purs;
1395  HitCollectionPurity(trkIDs,tracks[itrack]->AllCells(),&purs,&parents);
1396  // find the most pure trackID for this track
1397  int bestid = -1;
1398  double bestpur = 0.0;
1399  for(std::set<int>::iterator it = trkIDs.begin(); it != trkIDs.end(); ++it){
1400  const double p = purs[*it];
1401  if(p > bestpur){
1402  bestpur = p;
1403  bestid = *it;
1404  }
1405  } // end of loop over track ids
1406 
1407  // update this tracks info for the matched true particle
1408  double recoPur = bestpur;
1409  int recotrkid = bestid;
1410  int recopdg = 0;
1411  double recoEff = 0.0;
1412  if(bestpur > 0.0){
1413  // found a real particle that matched the track, update pdg and efficiency to match this
1414  recopdg = TrackIDToParticle(recotrkid)->PdgCode();
1415  std::set<int> ideff;
1416  ideff.insert(recotrkid);
1417  recoEff = HitCollectionEfficiency(ideff,
1418  PtrVecToVecRawPtr(tracks[itrack]->AllCells()),
1419  allHits, geo::kXorY);
1420  // remove this track id from the set of track ids so no other tracks can try to match to it
1421  trkIDs.erase(trkIDs.find(recotrkid));
1422  // remove any instance where this track id is the parent particle in the parents map
1423  std::map<int, int>::iterator parentsIt = parents.begin();
1424  while(parentsIt != parents.end()){
1425  if(parentsIt->second == recotrkid){ parents.erase(parentsIt++); }
1426  else{ ++parentsIt; }
1427  }
1428  }
1429  // record this tracks match
1430  ParticleEffPur match = {recotrkid, recoEff, recoPur, recopdg};
1431  matches.push_back(match);
1432  } // end of loop over tracks for matching to truth
1433 
1434  return matches;
1435 
1436  }
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
int PdgCode() const
Definition: MCParticle.h:211
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
set< int >::iterator it
X or Y views.
Definition: PlaneGeo.h:30
const char * p
Definition: xmltok.h:285
int NumberDaughters() const
Definition: MCParticle.h:216
double HitCollectionEfficiency(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, const std::vector< const rb::CellHit * > &allhits, const geo::View_t &view, std::map< int, double > *effMap=0, bool energyEff=false, double *desiredEnergy=0, double *totalEnergy=0, int *desiredHits=0, int *totalHits=0) const
Returns the fraction of all energy in an event from a specific set of Geant4 track IDs that are repre...
int Daughter(const int i) const
Definition: MCParticle.cxx:112
int PdgCode(Resonance_t res, int Q)
(resonance id, charge) -> PDG code
double HitCollectionPurity(const std::set< int > &trackIDs, const std::vector< rb::WeightedHit > &whits, std::map< int, double > *purMap=0, std::map< int, int > *parents=0, bool energyPur=false) const
Returns the fraction of hits in a collection that come from the specified Geant4 track ids...
const sim::Particle * TrackIDToParticle(int const &id) const
Returns a pointer to the sim::Particle object corresponding to the given TrackID. ...
assert(nhit_max >=nhit_nbins)
double ideff[10]
Definition: Xdiff_gwt.C:104
std::vector<ParticleEffPur> cheat::BackTracker::TracksToParticles ( const std::vector< rb::Track > &  tracks,
const std::set< int > &  trkIDs,
const std::set< int > &  allowedDaughters,
const std::vector< rb::CellHit > &  allHits 
) const
inline

Definition at line 698 of file BackTracker.h.

702  {
703  return TracksToParticles(VecToVecRawPtr(tracks),
704  trkIDs, allowedDaughters,
705  VecToVecRawPtr(allHits));
706  }
std::vector< const T * > VecToVecRawPtr(const std::vector< T > &xs) const
Definition: BackTracker.h:891
std::vector< ParticleEffPur > TracksToParticles(const std::vector< const rb::Track * > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< const rb::CellHit * > &allHits) const
Given a collection of reconstructed tracks, this method finds the best match for each reco track to t...
std::vector<ParticleEffPur> cheat::BackTracker::TracksToParticles ( const std::vector< art::Ptr< rb::Track >> &  tracks,
const std::set< int > &  trkIDs,
const std::set< int > &  allowedDaughters,
const std::vector< art::Ptr< rb::CellHit >> &  allHits 
) const
inline

Definition at line 709 of file BackTracker.h.

713  {
714  return TracksToParticles(VecPtrToVecRawPtr(tracks),
715  trkIDs, allowedDaughters,
716  VecPtrToVecRawPtr(allHits));
717  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< ParticleEffPur > TracksToParticles(const std::vector< const rb::Track * > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< const rb::CellHit * > &allHits) const
Given a collection of reconstructed tracks, this method finds the best match for each reco track to t...
std::vector<ParticleEffPur> cheat::BackTracker::TracksToParticles ( const art::PtrVector< rb::Track > &  tracks,
const std::set< int > &  trkIDs,
const std::set< int > &  allowedDaughters,
const art::PtrVector< rb::CellHit > &  allHits 
) const
inline

Definition at line 720 of file BackTracker.h.

724  {
725  return TracksToParticles(PtrVecToVecRawPtr(tracks),
726  trkIDs, allowedDaughters,
727  PtrVecToVecRawPtr(allHits));
728  }
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< ParticleEffPur > TracksToParticles(const std::vector< const rb::Track * > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< const rb::CellHit * > &allHits) const
Given a collection of reconstructed tracks, this method finds the best match for each reco track to t...
std::vector<ParticleEffPur> cheat::BackTracker::TracksToParticles ( const std::vector< art::Ptr< rb::Track >> &  tracks,
const std::set< int > &  trkIDs,
const std::set< int > &  allowedDaughters,
const art::PtrVector< rb::CellHit > &  allHits 
) const
inline

Definition at line 731 of file BackTracker.h.

735  {
736  return TracksToParticles(VecPtrToVecRawPtr(tracks),
737  trkIDs, allowedDaughters,
738  PtrVecToVecRawPtr(allHits));
739  }
std::vector< const T * > VecPtrToVecRawPtr(const std::vector< art::Ptr< T >> &xs) const
Definition: BackTracker.h:878
std::vector< const T * > PtrVecToVecRawPtr(const art::PtrVector< T > &xs) const
Helper function for implementing overloads.
Definition: BackTracker.h:865
std::vector< ParticleEffPur > TracksToParticles(const std::vector< const rb::Track * > &tracks, const std::set< int > &trkIDs, const std::set< int > &allowedDaughters, const std::vector< const rb::CellHit * > &allHits) const
Given a collection of reconstructed tracks, this method finds the best match for each reco track to t...
template<class T >
std::vector<const T*> cheat::BackTracker::VecPtrToVecRawPtr ( const std::vector< art::Ptr< T >> &  xs) const
inlineprivate

Helper function for implementing overloads

NB the pointers are only valid so long as the parent xs is still around

Definition at line 878 of file BackTracker.h.

References runNovaSAM::ret, and submit_syst::x.

879  {
880  std::vector<const T*> ret;
881  ret.reserve(xs.size());
882  for(const art::Ptr<T>& x: xs) ret.push_back(x.get());
883  return ret;
884  }
Definition: fwd.h:29
template<class T >
std::vector<const T*> cheat::BackTracker::VecToVecRawPtr ( const std::vector< T > &  xs) const
inlineprivate

Helper function for implementing overloads

NB the pointers are only valid so long as the parent xs is still around

Definition at line 891 of file BackTracker.h.

References runNovaSAM::ret, T, and submit_syst::x.

892  {
893  std::vector<const T*> ret;
894  ret.reserve(xs.size());
895  for(const T& x: xs) ret.push_back(&x);
896  return ret;
897  }
double T
Definition: Xdiff_gwt.C:5

Member Data Documentation

std::unordered_map< geo::OfflineChan, std::list<sim::FLSHit> > cheat::BackTracker::fCellToFLSHit
private

map of FLSHits in each cell in event

Definition at line 943 of file BackTracker.h.

Referenced by CellToFLSHit(), EnergyFromTrackId(), HitToFLSHit(), and Rebuild().

std::map<double, std::vector<cheat::TrackIDE> > cheat::BackTracker::fCellToIDs
private

map of cellHit to trackIDEs that contributed energy to the hit. cellhit information is encoded as TDC*1000,000+Plane*1000+Cell

Definition at line 955 of file BackTracker.h.

Referenced by ClusterToParticle(), and HitToParticlesMap().

std::unordered_map< geo::OfflineChan, std::vector<sim::PhotonSignal> > cheat::BackTracker::fCellToPhotonSignal
private

map of PhotonSignals in each cell in event

Definition at line 945 of file BackTracker.h.

Referenced by AccumulateHitContributions(), CellToPhotonSignal(), HitToPhotonSignal(), and Rebuild().

novadaq::cnv::DetId cheat::BackTracker::fDetID
private

detector id

Definition at line 941 of file BackTracker.h.

Referenced by CloseInTime(), and Rebuild().

bool cheat::BackTracker::fHaveTruthInfo
private

Set by Rebuild.

Definition at line 939 of file BackTracker.h.

Referenced by Rebuild().

std::map<int, float > cheat::BackTracker::fIdToEnergy
private

Definition at line 956 of file BackTracker.h.

Referenced by ClusterToParticle(), and HitToParticlesMap().

std::vector< art::Ptr<simb::MCTruth> > cheat::BackTracker::fMCTruthList
private
int cheat::BackTracker::fNumTrueEnergyWarnings
private

Definition at line 959 of file BackTracker.h.

Referenced by BackTracker(), and Rebuild().

Params cheat::BackTracker::fParams
private

Definition at line 937 of file BackTracker.h.

Referenced by HitCollectionEfficiency(), IsHitsNoise(), and Rebuild().

sim::ParticleNavigator cheat::BackTracker::fParticleNav
private

Particle navigator to map track ID to Particle.

Definition at line 946 of file BackTracker.h.

Referenced by MCTruthToParticles(), Rebuild(), TrackIDToMotherParticle(), and TrackIDToParticle().

int cheat::BackTracker::fSliceIDForHitParticleMap
private

Definition at line 958 of file BackTracker.h.

Referenced by ClusterToParticle(), HitToParticlesMap(), and Rebuild().

std::set<int> cheat::BackTracker::fTrackIDs
private

G4 track ids for all particles in the events.

Definition at line 947 of file BackTracker.h.

Referenced by MCTruthToParticles(), and Rebuild().

std::unordered_map< int, std::list<sim::FLSHit> > cheat::BackTracker::fTrackIDToFLSHit
private

map of G4 track ids to FLSHits

Definition at line 944 of file BackTracker.h.

Referenced by ParticleToFLSHit(), and Rebuild().

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

map of track id values to MCTruthList entry

Definition at line 949 of file BackTracker.h.

Referenced by ClusterByTruth(), MCTruthToCluster(), Rebuild(), SlicesToMCTruthsTable(), and TrackIDToMCTruth().

std::map<int, int> cheat::BackTracker::fTrackIDToTrueEIndex
private

map of track id values to TrueEnergy entry

Definition at line 951 of file BackTracker.h.

Referenced by CalcEscapingEnergy(), CalcTotalEscapingEnergy(), and Rebuild().

std::vector< art::Ptr<sim::TrueEnergy> > cheat::BackTracker::fTrueEnergyList
private

all the TrueEnergy's for this event

Definition at line 950 of file BackTracker.h.

Referenced by CalcEscapingEnergy(), CalcTotalEscapingEnergy(), and Rebuild().


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