All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ana::SBNOsc::NumuReco Class Reference

Electron neutrino event selection. More...

#include <NumuReco.h>

Inheritance diagram for ana::SBNOsc::NumuReco:
core::SelectionBase core::ProcessorBase

Classes

struct  Config
 

Public Member Functions

 NumuReco ()
 
void Initialize (fhicl::ParameterSet *config=NULL)
 
void Finalize ()
 
bool ProcessEvent (const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
 
- Public Member Functions inherited from core::SelectionBase
 SelectionBase ()
 
virtual ~SelectionBase ()
 
- Public Member Functions inherited from core::ProcessorBase
 ProcessorBase ()
 
virtual ~ProcessorBase ()
 
virtual void FillTree ()
 
virtual void FillRecoTree ()
 
virtual void EventCleanup ()
 
template<class T >
TBranch * AddBranch (std::string name, T *obj)
 
template<class T >
TBranch * AddRecoBranch (std::string name, T *obj)
 

Protected Member Functions

numu::RecoEvent Reconstruct (const gallery::Event &ev, const std::vector< event::Interaction > &truth)
 
std::map< size_t,
numu::TrueParticle
MCParticleInfos ()
 
numu::TrueParticle MCParticleInfo (const simb::MCParticle &particle)
 
std::vector< numu::CRTHitInTimeCRTHits ()
 
void FillCRTHits ()
 
numu::CRTHit SBND2numuCRTHit (const sbn::crt::CRTHit &hit)
 
bool InBeamSpill (float time)
 
std::vector< numu::RecoParticleRecoParticleInfo ()
 
bool SelectSlice (const numu::RecoSlice &slice)
 
std::map< size_t, numu::RecoTrackRecoTrackInfo ()
 
std::vector< numu::RecoSliceRecoSliceInfo (std::map< size_t, numu::RecoTrack > &reco_tracks, const std::vector< numu::RecoParticle > &particles)
 
bool HasPrimaryTrack (const std::map< size_t, numu::RecoTrack > &tracks, const numu::RecoSlice &slice)
 
std::vector< size_t > RecoSliceTracks (const std::map< size_t, numu::RecoTrack > &tracks, const std::map< size_t, numu::RecoParticle > &particles)
 
event::RecoInteraction CoreRecoInteraction (const std::vector< event::Interaction > &truth, const numu::RecoInteraction &vertex, double weight)
 
int GetPhotonMotherID (int mcparticle_id)
 
numu::FlashMatch FlashMatching (const recob::Track &pandora_track, const numu::RecoTrack &track)
 
numu::CRTMatch CRTMatching (const numu::RecoTrack &track, const recob::Track &pandora_track, const std::vector< art::Ptr< recob::Hit >> &track_hits)
 
void ApplyCosmicID (numu::RecoTrack &track)
 
std::array< bool, 4 > RecoTrackTopology (const art::Ptr< recob::Track > &track)
 
numu::TrackTruthMatch MatchTrack2Truth (size_t track_id)
 
void CollectPMTInformation (const gallery::Event &ev)
 
void CollectCRTInformation (const gallery::Event &ev)
 
void CollectTPCInformation (const gallery::Event &ev)
 
void CollectTruthInformation (const gallery::Event &ev)
 
bool InActive (const TVector3 &v) const
 
- Protected Member Functions inherited from core::ProcessorBase
virtual void Initialize (char *config=NULL)
 
virtual void Setup (char *config=NULL)
 
virtual void Setup (fhicl::ParameterSet *config=NULL)
 
virtual void Teardown ()
 
void BuildEventTree (gallery::Event &ev)
 
void SetupServices (gallery::Event &ev)
 
void UpdateSubRuns (gallery::Event &ev)
 
void UpdateFileMeta (gallery::Event &ev)
 

Protected Attributes

unsigned _event_counter
 Count processed events. More...
 
unsigned _nu_count
 Count selected events. More...
 
TGraph * _cut_counts
 Keep track of neutrinos per cut. More...
 
Config _config
 The config. More...
 
trkf::TrackMomentumCalculator_track_momentum_calculator
 Calculator for range-based track momentum. More...
 
trkf::TrajectoryMCSFitter_mcs_fitter
 Calculator for MCS based momentum. More...
 
numu::RecoEvent _recoEvent
 Branch container for the RecoEvent. More...
 
std::vector
< numu::RecoInteraction > * 
_selected
 Branch container for the list of selected reco vertices. More...
 
sbnd::CRTTrackMatchAlg_crt_track_matchalg
 Algorithm for matching reco Tracks -> CRT Tracks. More...
 
sbnd::CRTT0MatchAlg_crt_hit_matchalg
 Algorithm for matching reco Tracks -> CRT hits (T0's) More...
 
ApaCrossCosmicIdAlg _apa_cross_cosmic_alg
 Algorithm for doing cosmic ID by looking for tracks crossing APA. More...
 
StoppingParticleCosmicIdAlg _stopping_cosmic_alg
 Algorithm for doing cosmic ID using a fit to the energy deposits. More...
 
opdet::opHitFinderSBND_op_hit_maker
 Optical hit maker. More...
 
const std::vector
< sbn::crt::CRTTrack > * 
_crt_tracks
 
std::vector< sbn::crt::CRTTrack_crt_tracks_local
 
std::vector< sbn::crt::CRTHit_crt_hits_local
 
const std::vector
< sbn::crt::CRTHit > * 
_crt_hits
 
bool _has_crt_hits
 
bool _has_crt_tracks
 
std::vector< art::Ptr
< recob::OpHit > > 
_op_hit_ptrs
 
std::vector< recob::OpHit_op_hits_local
 
std::vector< art::Ptr
< recob::Slice > > 
_tpc_slices
 
std::vector< art::Ptr
< recob::Track > > 
_tpc_tracks
 
std::vector< art::Ptr
< recob::PFParticle > > 
_tpc_particles
 
std::vector< std::vector
< art::Ptr< recob::PFParticle > > > 
_tpc_slices_to_particles
 
std::vector< std::vector
< unsigned > > 
_tpc_slices_to_particle_index
 
std::vector< art::Ptr
< recob::PFParticle > > 
_tpc_tracks_to_particles
 
std::vector< unsigned > _tpc_tracks_to_particle_index
 
std::map< unsigned, unsigned > _tpc_particles_to_track_index
 
std::vector< std::vector
< art::Ptr< anab::Calorimetry > > > 
_tpc_tracks_to_calo
 
std::vector< std::vector
< art::Ptr< anab::ParticleID > > > 
_tpc_tracks_to_pid
 
std::vector< std::vector
< art::Ptr< recob::Hit > > > 
_tpc_tracks_to_hits
 
std::vector< std::vector
< art::Ptr< anab::T0 > > > 
_tpc_particles_to_T0
 
std::vector< std::vector
< art::Ptr< recob::Vertex > > > 
_tpc_particles_to_vertex
 
std::vector< std::vector
< unsigned > > 
_tpc_particles_to_daughters
 
std::vector< art::Ptr
< larpandoraobj::PFParticleMetadata > > 
_tpc_particles_to_metadata
 
std::vector< std::vector
< art::Ptr< anab::T0 > > > 
_tpc_particles_to_flashT0
 
std::vector< art::Ptr
< simb::MCParticle > > 
_true_particles
 
std::map< int, art::Ptr
< simb::MCTruth > > 
_true_particles_to_truth
 
std::map< int, const
sim::GeneratedParticleInfo * > 
_true_particles_to_generator_info
 
numu::MCType fType
 
CRTHistos _crt_histograms
 
- Protected Attributes inherited from core::ProcessorBase
unsigned long fEventIndex
 An incrementing index. More...
 
Experiment fExperimentID
 Experiment identifier. More...
 
ProviderManagerfProviderManager
 Interface for provider access. More...
 
std::string fOutputFilename
 The output filename. More...
 
std::string fProviderConfig
 A custom provider config fcl file. More...
 
std::vector< geo::BoxBoundedGeofActiveVolumes
 List of active volumes in configured detector. More...
 
bool fWriteTree
 Enable writing of the main tree. More...
 
TFile * fOutputFile
 The output ROOT file. More...
 
TTree * fTree
 The output ROOT tree. More...
 
event::EventfEvent
 The standard output event data structure. More...
 
bool fWriteRecoTree
 Enable writing of the reco tree. More...
 
TTree * fRecoTree
 The output reco ROOT tree. More...
 
event::RecoEventfRecoEvent
 The standard output reco event data structure. More...
 
TTree * fSubRunTree
 Subrun output tree. More...
 
SubRunfSubRun
 Standard output subrun structure. More...
 
TTree * fFileMetaTree
 File metadata output tree. More...
 
FileMetafFileMeta
 standard output file metadata structure More...
 
TParameter< int > * fExperimentParameter
 Saves value of experiment enum. More...
 
std::set< std::pair< int, int > > fSubRunCache
 Cache stored subruns. More...
 
art::InputTag fTruthTag
 art tag for MCTruth information More...
 
art::InputTag fFluxTag
 art tag for MCFlux information More...
 
std::vector< art::InputTag > fWeightTags
 art tag(s) for MCEventWeight information More...
 
art::InputTag fMCTrackTag
 art tag for MCTrack More...
 
art::InputTag fMCShowerTag
 art tag for MCShower More...
 
art::InputTag fMCParticleTag
 art tag for MCParticle More...
 
std::string fGeneratorProcess
 process_name of process used to run genie. Used to extract subrun/POT information More...
 

Additional Inherited Members

- Public Attributes inherited from core::ProcessorBase
std::vector
< event::RecoInteraction > * 
fReco
 Reco interaction list. More...
 

Detailed Description

Electron neutrino event selection.

Definition at line 69 of file NumuReco.h.

Constructor & Destructor Documentation

ana::SBNOsc::NumuReco::NumuReco ( )

Constructor.

Definition at line 164 of file NumuReco.cxx.

164  :
165  SelectionBase(),
166  _event_counter(0),
167  _nu_count(0),
168  _selected(new std::vector<numu::RecoInteraction>) {}
std::vector< numu::RecoInteraction > * _selected
Branch container for the list of selected reco vertices.
Definition: NumuReco.h:340
unsigned _event_counter
Count processed events.
Definition: NumuReco.h:328
unsigned _nu_count
Count selected events.
Definition: NumuReco.h:329

Member Function Documentation

void ana::SBNOsc::NumuReco::ApplyCosmicID ( numu::RecoTrack track)
protected

Definition at line 754 of file NumuReco.cxx.

754  {
755  unsigned track_id = _tpc_particles_to_track_index.at(track.ID);
756  const art::Ptr<recob::Track> &pfp_track = _tpc_tracks[track_id];
757 
758  // do CRT matching
759  track.crt_match = CRTMatching(track, *pfp_track, _tpc_tracks_to_hits.at(track_id));
760 
761  // Cosmic ID:
762  //
763  // See if start or end looks like stopping
764  track.stopping_chisq_start = _stopping_cosmic_alg.StoppingChiSq(pfp_track->Vertex(), _tpc_tracks_to_calo.at(track_id));
765  track.stopping_chisq_finish = _stopping_cosmic_alg.StoppingChiSq(pfp_track->End(), _tpc_tracks_to_calo.at(track_id));
766 }
CRTMatch crt_match
CRTMatch.
Definition: RecoTrack.h:59
StoppingParticleCosmicIdAlg _stopping_cosmic_alg
Algorithm for doing cosmic ID using a fit to the energy deposits.
Definition: NumuReco.h:345
std::vector< art::Ptr< recob::Track > > _tpc_tracks
Definition: NumuReco.h:362
numu::CRTMatch CRTMatching(const numu::RecoTrack &track, const recob::Track &pandora_track, const std::vector< art::Ptr< recob::Hit >> &track_hits)
Definition: NumuReco.cxx:1172
std::vector< std::vector< art::Ptr< recob::Hit > > > _tpc_tracks_to_hits
Definition: NumuReco.h:371
float stopping_chisq_finish
Chi2 fraction of stopping vs. not-stopping hypotheis to track end point.
Definition: RecoTrack.h:64
std::vector< std::vector< art::Ptr< anab::Calorimetry > > > _tpc_tracks_to_calo
Definition: NumuReco.h:369
std::map< unsigned, unsigned > _tpc_particles_to_track_index
Definition: NumuReco.h:368
float stopping_chisq_start
Chi2 fraction of stopping vs. not-stopping hypothesis to track start points.
Definition: RecoTrack.h:63
double StoppingChiSq(geo::Point_t end, std::vector< art::Ptr< anab::Calorimetry >> calos)
int ID
ID/index of this track. Does not necessarily correspond to the Pandora index.
Definition: RecoTrack.h:61
void ana::SBNOsc::NumuReco::CollectCRTInformation ( const gallery::Event &  ev)
protected

Fill up the CRT information containers from the gallery Event

Parameters
evThe gallery Event

Definition at line 1131 of file NumuReco.cxx.

1131  {
1132  _crt_tracks_local.clear();
1133  _crt_hits_local.clear();
1134 
1135  // collect the CRT Tracks
1136  gallery::Handle<std::vector<sbn::crt::CRTTrack>> crt_tracks_sbnd;
1137  bool has_crt_tracks_sbnd = ev.getByLabel(_config.CRTTrackTag, crt_tracks_sbnd);
1138  gallery::Handle<std::vector<sbn::crt::CRTTrack>> crt_tracks_icarus;
1139  // bool has_crt_tracks_icarus = ev.getByLabel(_config.CRTTrackTag, crt_tracks_icarus);
1140  bool has_crt_tracks_icarus = false;
1141  _has_crt_tracks = has_crt_tracks_sbnd || has_crt_tracks_icarus;
1142 
1143  if (has_crt_tracks_icarus) {
1144  for (unsigned i = 0; i < crt_tracks_icarus->size(); i++) {
1145  _crt_tracks_local.emplace_back();
1146  memcpy(&_crt_tracks_local[i], &crt_tracks_icarus->at(i), sizeof(sbn::crt::CRTTrack));
1147  }
1148  }
1150  ( (has_crt_tracks_sbnd) ? crt_tracks_sbnd.product() : &_crt_tracks_local) :
1151  NULL;
1152 
1153  // collect the CRT Hits
1154  gallery::Handle<std::vector<sbn::crt::CRTHit>> crt_hits_sbnd;
1155  bool has_crt_hits_sbnd = ev.getByLabel(_config.CRTHitTag, crt_hits_sbnd);
1156  gallery::Handle<std::vector<sbn::crt::CRTHit>> crt_hits_icarus;
1157  bool has_crt_hits_icarus = ev.getByLabel(_config.CRTHitTag, crt_hits_icarus);
1158  _has_crt_hits = has_crt_hits_sbnd || has_crt_hits_icarus;
1159 
1160  // Convert ICARUS Hits to SBND Hits
1161  if (has_crt_hits_icarus) {
1162  for (unsigned i = 0; i < crt_hits_icarus->size(); i++) {
1163  _crt_hits_local.push_back(ICARUS2SBNDCrtHit(crt_hits_icarus->at(i)));
1164  }
1165  }
1166 
1167  _crt_hits = (_has_crt_hits) ?
1168  ( (has_crt_hits_sbnd) ? crt_hits_sbnd.product() : &_crt_hits_local) :
1169  NULL;
1170 }
std::vector< sbn::crt::CRTHit > _crt_hits_local
Definition: NumuReco.h:351
std::string CRTTrackTag
art tag for CRT tracks
Definition: NumuReco.h:139
sbn::crt::CRTHit ICARUS2SBNDCrtHit(const sbn::crt::CRTHit &inp)
Definition: NumuReco.cxx:138
const std::vector< sbn::crt::CRTHit > * _crt_hits
Definition: NumuReco.h:352
Config _config
The config.
Definition: NumuReco.h:332
const std::vector< sbn::crt::CRTTrack > * _crt_tracks
Definition: NumuReco.h:349
std::vector< sbn::crt::CRTTrack > _crt_tracks_local
Definition: NumuReco.h:350
void ana::SBNOsc::NumuReco::CollectPMTInformation ( const gallery::Event &  ev)
protected

Fill up the Optical information containers from the gallery Event

Parameters
evThe gallery Event

Definition at line 1233 of file NumuReco.cxx.

1233  {
1234  // std::vector<art::Ptr<recob::OpHit>> op_hit_ptrs;
1235  // std::vector<recob::OpHit> op_hits;
1236 
1237  _op_hit_ptrs.clear();
1238  _op_hits_local.clear();
1239 
1240  return;
1241 
1242  // get the OpDet hits
1243  art::ProductID local_opdets("local_opdets");
1244  if (_config.MakeOpHits) {
1245  const std::vector<raw::OpDetWaveform> &op_waveforms = *ev.getValidHandle<std::vector<raw::OpDetWaveform>>("opdaq");
1246  _op_hits_local = _op_hit_maker->MakeHits(op_waveforms);
1247  for (unsigned i = 0; i < _op_hits_local.size(); i++) {
1248  _op_hit_ptrs.emplace_back(local_opdets, &_op_hits_local[i], i);
1249  }
1250  }
1251  else {
1252  gallery::Handle<std::vector<recob::OpHit>> op_hits;
1253  ev.getByLabel(_config.OpFlashTag, op_hits);
1254  art::fill_ptr_vector(_op_hit_ptrs, op_hits);
1255  }
1256 
1257 }
std::vector< recob::OpHit > _op_hits_local
Definition: NumuReco.h:358
std::vector< recob::OpHit > MakeHits(const std::vector< raw::OpDetWaveform > &waveforms)
opdet::opHitFinderSBND * _op_hit_maker
Optical hit maker.
Definition: NumuReco.h:346
std::vector< art::Ptr< recob::OpHit > > _op_hit_ptrs
Definition: NumuReco.h:357
Config _config
The config.
Definition: NumuReco.h:332
void ana::SBNOsc::NumuReco::CollectTPCInformation ( const gallery::Event &  ev)
protected

Fill up the TPC information containers from the gallery Event

Parameters
evThe gallery Event

Definition at line 1008 of file NumuReco.cxx.

1008  {
1009  // clear out old stuff
1010  _tpc_slices.clear();
1011  _tpc_tracks.clear();
1012  _tpc_particles.clear();
1013  _tpc_slices_to_particles.clear();
1015  _tpc_tracks_to_particles.clear();
1018  _tpc_tracks_to_calo.clear();
1019  _tpc_tracks_to_pid.clear();
1020  _tpc_tracks_to_hits.clear();
1021  _tpc_particles_to_T0.clear();
1022  _tpc_particles_to_vertex.clear();
1025  _tpc_particles_to_flashT0.clear();
1026 
1027  for (const std::string &suffix: _config.TPCRecoTagSuffixes) {
1028  // Offset to convert a pandora particle ID to a NumuReco particle ID
1029  //
1030  // The different ID's are required because in ICARUS TPC reconstruction
1031  // is done per-cryostat. Thus, the pandora particle ID's may not be unique
1032  unsigned particle_id_offset = _tpc_particles.size();
1033 
1034  // get the slices
1035  const auto &slice_handle = ev.getValidHandle<std::vector<recob::Slice>>(_config.RecoSliceTag + suffix);
1036  art::fill_ptr_vector(_tpc_slices, slice_handle);
1037 
1038  // get the particles
1039  const auto &particle_handle = ev.getValidHandle<std::vector<recob::PFParticle>>(_config.PFParticleTag + suffix);
1040  art::fill_ptr_vector(_tpc_particles, particle_handle);
1041 
1042  // get the tracks
1043  const auto &track_handle = ev.getValidHandle<std::vector<recob::Track>>(_config.RecoTrackTag + suffix);
1044  art::fill_ptr_vector(_tpc_tracks, track_handle);
1045 
1046  // slice to particle
1047  art::FindManyP<recob::PFParticle> slice_to_particle(slice_handle, ev, _config.PFParticleTag + suffix);
1048  unsigned i0 = _tpc_slices_to_particle_index.size();
1049  for (unsigned i = 0; i < slice_handle->size(); i++) {
1050  unsigned iset = i + i0;
1051  _tpc_slices_to_particles.push_back(slice_to_particle.at(i));
1052  _tpc_slices_to_particle_index.emplace_back();
1053  for (unsigned j = 0; j < slice_to_particle.at(i).size(); j++) {
1054  _tpc_slices_to_particle_index[iset].push_back(slice_to_particle.at(i)[j]->Self() + particle_id_offset);
1056  }
1057  }
1058 
1059  // track to particle and particle to track
1060  art::FindManyP<recob::PFParticle> track_to_particle(track_handle, ev, _config.RecoTrackTag + suffix);
1061  i0 = _tpc_tracks_to_particles.size();
1062  for (unsigned i = 0; i < track_handle->size(); i++) {
1063  unsigned iset = i + i0;
1064  _tpc_tracks_to_particles.push_back(track_to_particle.at(i).at(0));
1065  _tpc_tracks_to_particle_index.push_back(particle_id_offset + _tpc_tracks_to_particles[iset]->Self());
1066  _tpc_particles_to_track_index[particle_id_offset + _tpc_tracks_to_particles[iset]->Self()] = iset;
1067  // if this isn't true something went wrong
1068  assert(_tpc_particles[_tpc_tracks_to_particle_index[iset]] == _tpc_tracks_to_particles[iset]);
1069  }
1070 
1071  // track to Calo
1072  art::FindManyP<anab::Calorimetry> track_to_calo(track_handle, ev, _config.CaloTag + suffix);
1073  for (unsigned i = 0; i < track_handle->size(); i++) {
1074  _tpc_tracks_to_calo.push_back(track_to_calo.at(i));
1075  }
1076 
1077  // track to PID
1078  art::FindManyP<anab::ParticleID> track_to_pid(track_handle, ev, _config.PIDTag + suffix);
1079  for (unsigned i = 0; i < track_handle->size(); i++) {
1080  _tpc_tracks_to_pid.push_back(track_to_pid.at(i));
1081  }
1082 
1083  // track to hits
1084  art::FindManyP<recob::Hit> track_to_hits(track_handle, ev, _config.RecoTrackTag + suffix);
1085  for (unsigned i = 0; i < track_handle->size(); i++) {
1086  _tpc_tracks_to_hits.push_back(track_to_hits.at(i));
1087  }
1088 
1089  // particle to T0
1090  art::FindManyP<anab::T0> particle_to_T0(particle_handle, ev, _config.PFParticleTag + suffix);
1091  for (unsigned i = 0; i < particle_handle->size(); i++) {
1092  _tpc_particles_to_T0.push_back(particle_to_T0.at(i));
1093  }
1094 
1095  gallery::Handle<art::Assns<recob::PFParticle,anab::T0,void>> assns_check;
1096  ev.getByLabel(_config.FlashMatchTag + suffix, assns_check);
1097  if (assns_check.isValid()) {
1098  // particle to flash match
1099  art::FindManyP<anab::T0> particle_to_flash(particle_handle, ev, _config.FlashMatchTag + suffix);
1100  for (unsigned i = 0; i < particle_handle->size(); i++) {
1101  assert(particle_to_flash.at(i).size() == 0 || particle_to_flash.at(i).size() == 1);
1102  _tpc_particles_to_flashT0.push_back(particle_to_flash.at(i));
1103  }
1104  }
1105 
1106  // particle to vertex
1107  art::FindManyP<recob::Vertex> particle_to_vertex(particle_handle, ev, _config.PFParticleTag + suffix);
1108  for (unsigned i = 0; i < particle_handle->size(); i++) {
1109  assert(particle_to_vertex.at(i).size() == 0 || particle_to_vertex.at(i).size() == 1);
1110  _tpc_particles_to_vertex.push_back(particle_to_vertex.at(i));
1111  }
1112 
1113  // particle to daughters
1114  for (unsigned i = 0; i < particle_handle->size(); i++) {
1115  std::vector<unsigned> daughters;
1116  for (unsigned d: _tpc_particles[i+particle_id_offset]->Daughters()) {
1117  daughters.push_back(particle_id_offset + d);
1118  }
1119  _tpc_particles_to_daughters.push_back(std::move(daughters));
1120  }
1121 
1122  // particle to metadata
1123  art::FindManyP<larpandoraobj::PFParticleMetadata> pfp_metadatas(particle_handle, ev, _config.PFParticleTag + suffix);
1124  for (unsigned i = 0; i < particle_handle->size(); i++) {
1125  _tpc_particles_to_metadata.push_back(pfp_metadatas.at(i).at(0));
1126  }
1127  }
1128 }
std::vector< art::Ptr< recob::PFParticle > > _tpc_particles
Definition: NumuReco.h:363
std::vector< unsigned > _tpc_tracks_to_particle_index
Definition: NumuReco.h:367
std::vector< art::Ptr< larpandoraobj::PFParticleMetadata > > _tpc_particles_to_metadata
Definition: NumuReco.h:375
std::vector< std::vector< unsigned > > _tpc_particles_to_daughters
Definition: NumuReco.h:374
std::vector< art::Ptr< recob::Track > > _tpc_tracks
Definition: NumuReco.h:362
std::vector< std::vector< art::Ptr< recob::Vertex > > > _tpc_particles_to_vertex
Definition: NumuReco.h:373
std::vector< std::vector< art::Ptr< recob::Hit > > > _tpc_tracks_to_hits
Definition: NumuReco.h:371
std::vector< std::string > TPCRecoTagSuffixes
Definition: NumuReco.h:133
std::vector< std::vector< art::Ptr< anab::Calorimetry > > > _tpc_tracks_to_calo
Definition: NumuReco.h:369
std::vector< std::vector< art::Ptr< anab::T0 > > > _tpc_particles_to_T0
Definition: NumuReco.h:372
std::map< unsigned, unsigned > _tpc_particles_to_track_index
Definition: NumuReco.h:368
std::vector< std::vector< art::Ptr< recob::PFParticle > > > _tpc_slices_to_particles
Definition: NumuReco.h:364
std::vector< std::vector< art::Ptr< anab::ParticleID > > > _tpc_tracks_to_pid
Definition: NumuReco.h:370
std::vector< std::vector< art::Ptr< anab::T0 > > > _tpc_particles_to_flashT0
Definition: NumuReco.h:376
std::string PFParticleTag
art tag for PFParticles
Definition: NumuReco.h:136
Config _config
The config.
Definition: NumuReco.h:332
std::vector< std::vector< unsigned > > _tpc_slices_to_particle_index
Definition: NumuReco.h:365
std::vector< art::Ptr< recob::PFParticle > > _tpc_tracks_to_particles
Definition: NumuReco.h:366
std::string RecoTrackTag
art tag for reconstructed tracks
Definition: NumuReco.h:131
std::vector< art::Ptr< recob::Slice > > _tpc_slices
Definition: NumuReco.h:361
void ana::SBNOsc::NumuReco::CollectTruthInformation ( const gallery::Event &  ev)
protected

Fill up truth information containers from the gallery Event

Parameters
evThe gallery Event

Definition at line 991 of file NumuReco.cxx.

991  {
992  _true_particles.clear();
993  _true_particles_to_truth.clear();
995 
996  // mc particles
997  auto const &mcparticles = ev.getValidHandle<std::vector<simb::MCParticle>>(fMCParticleTag);
998  art::fill_ptr_vector(_true_particles, mcparticles);
999 
1000  // MC particle (G4) to MCTruth (generator -- corsika or genie)
1001  art::FindManyP<simb::MCTruth, sim::GeneratedParticleInfo> particles_to_truth(mcparticles, ev, "largeant");
1002  for (unsigned i = 0; i < mcparticles->size(); i++) {
1003  _true_particles_to_truth[mcparticles->at(i).TrackId()] = particles_to_truth.at(i).at(0);
1004  _true_particles_to_generator_info[mcparticles->at(i).TrackId()] = particles_to_truth.data(i).at(0);
1005  }
1006 }
std::map< int, art::Ptr< simb::MCTruth > > _true_particles_to_truth
Definition: NumuReco.h:380
std::vector< art::Ptr< simb::MCParticle > > _true_particles
Definition: NumuReco.h:379
std::map< int, const sim::GeneratedParticleInfo * > _true_particles_to_generator_info
Definition: NumuReco.h:381
art::InputTag fMCParticleTag
art tag for MCParticle
event::RecoInteraction ana::SBNOsc::NumuReco::CoreRecoInteraction ( const std::vector< event::Interaction > &  truth,
const numu::RecoInteraction vertex,
double  weight 
)
protected

Converts the NumuReco::RecoInteraction information into reco information used by sbncode core

Parameters
truththe list of truth vertices produced by sbncode core
vertexthe reconstructed vertex produced by this selection
weightthe calculated weight for this interaction
Returns
Reconstruction information as needed by the sbncode core class

Definition at line 290 of file NumuReco.cxx.

290  {
292  if (vertex.match.mctruth_vertex_id >= 0) {
293  ret.truth_index = vertex.match.mctruth_vertex_id;
294  }
295  ret.reco_energy = vertex.nu_energy;
296  ret.weight = weight;
297  return ret;
298 }
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
Contains truth level information and additional fields for selection-defined reconstruction informati...
Definition: Event.hh:178
float reco_energy
Reconstructed neutrino energy [GeV].
Definition: Event.hh:195
float weight
Selection-defined event weight.
Definition: Event.hh:196
float nu_energy
true/reconstructed neutrino energy
Definition: RecoEvent.h:41
int mctruth_vertex_id
index of the truth vertex into the list of MCThruths. -1 if no match
numu::CRTMatch ana::SBNOsc::NumuReco::CRTMatching ( const numu::RecoTrack track,
const recob::Track pandora_track,
const std::vector< art::Ptr< recob::Hit >> &  track_hits 
)
protected

Returns whether a TPC track has a match to CRT information

Parameters
trackThe track information from this module
pandora_trackThe LArSoft track object
track_hitsThe list of hits associated with this track
Returns
CRTMatch object

Definition at line 1172 of file NumuReco.cxx.

1175  {
1176 
1177  numu::CRTMatch match;
1178 
1179  std::pair<sbn::crt::CRTTrack, double> closest_crt_track = { {}, -99999 };
1180  // try to find a match to CRT Track -- if we have one
1181  if (_has_crt_tracks) {
1182  closest_crt_track = _crt_track_matchalg->ClosestCRTTrackByAngle(pandora_track, hits, *_crt_tracks);
1183  }
1184 
1185  // if there is a track match, fill out the info
1186  if (closest_crt_track.second > -10000 /* Null value */) {
1187  match.track.present = true;
1188  if (_config.TSMode == 0) match.track.time = closest_crt_track.first.ts0_ns / 1000. /* ns -> us */;
1189  else match.track.time = closest_crt_track.first.ts1_ns / 1000. /* ns -> us */;
1190  match.track.angle = closest_crt_track.second;
1191  }
1192  else {
1193  match.track.present = false;
1194  match.track.time = -99999.;
1195  match.track.angle = -99999.;
1196  }
1197 
1198  // try to match a hit
1199  std::pair<sbn::crt::CRTHit, double> hit_pair = std::pair<sbn::crt::CRTHit, double>({sbn::crt::CRTHit(), -1});
1200  if (_has_crt_hits) {
1201  numu::FlashMatch flash_match; // TODO: fix
1202  if (_config.CRTHitinOpHitRange && flash_match.present) {
1203  const numu::FlashMatch &match = flash_match;
1204  double time_width = (_config.CRT2OPTimeWidth) / 2;
1205  std::pair<double, double> time_range;
1206  time_range.first = match.time - time_width;
1207  time_range.second = match.time + time_width;
1209  hit_pair = _crt_hit_matchalg->ClosestCRTHit(pandora_track, time_range, *_crt_hits, drift_dir);
1210  }
1211  else {
1212  std::cout << "Tryin CRT Hit match\n";
1213  hit_pair = _crt_hit_matchalg->ClosestCRTHit(pandora_track, hits, *_crt_hits);
1214  }
1215  }
1216 
1217  double distance = hit_pair.second;
1218  if (distance >= 0 /* matching succeeded*/) {
1219  match.hit_match.present = true;
1220  match.hit_match.distance = distance;
1221  match.hit = SBND2numuCRTHit(hit_pair.first);
1222  match.hit_match.time = match.hit.time;
1223  std::cout << "Match: " << match.hit.location.X() << std::endl;
1224  }
1225  else {
1226  match.hit_match.present = false;
1227  match.hit_match.distance = -99999.;
1228  }
1229 
1230  return match;
1231 }
Track track
CRT Track match.
Definition: CRTMatch.h:30
numu::CRTHit SBND2numuCRTHit(const sbn::crt::CRTHit &hit)
Definition: NumuReco.cxx:1305
bool present
Whether this CRTMatch has a matching track.
Definition: CRTMatch.h:16
const geo::GeometryCore * GetGeometryProvider() const
std::pair< sbn::crt::CRTHit, double > ClosestCRTHit(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::pair< double, double > t0MinMax, std::vector< sbn::crt::CRTHit > crtHits, int driftDirection)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
sbnd::CRTTrackMatchAlg * _crt_track_matchalg
Algorithm for matching reco Tracks -&gt; CRT Tracks.
Definition: NumuReco.h:342
sbnd::CRTT0MatchAlg * _crt_hit_matchalg
Algorithm for matching reco Tracks -&gt; CRT hits (T0&#39;s)
Definition: NumuReco.h:343
const std::vector< sbn::crt::CRTHit > * _crt_hits
Definition: NumuReco.h:352
int DriftDirectionFromHits(const geo::GeometryCore *GeometryService, std::vector< art::Ptr< recob::Hit >> hits)
Config _config
The config.
Definition: NumuReco.h:332
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByAngle(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event, double minDCA=0.)
ProviderManager * fProviderManager
Interface for provider access.
float angle
Angle between TPC track and CRT track.
Definition: CRTMatch.h:18
const std::vector< sbn::crt::CRTTrack > * _crt_tracks
Definition: NumuReco.h:349
BEGIN_PROLOG could also be cout
float time
Matching time [us] of track. T==0 is set to beam spill start time.
Definition: CRTMatch.h:17
void ana::SBNOsc::NumuReco::FillCRTHits ( )
protected

Definition at line 1316 of file NumuReco.cxx.

1316  {
1317  for (const sbn::crt::CRTHit &hit: *_crt_hits) {
1319  }
1320 }
void Fill(const numu::CRTHit &hit)
Definition: CRTHisto.cc:24
CRTHistos _crt_histograms
Definition: NumuReco.h:386
process_name hit
Definition: cheaterreco.fcl:51
const std::vector< sbn::crt::CRTHit > * _crt_hits
Definition: NumuReco.h:352
void ana::SBNOsc::NumuReco::Finalize ( )
virtual

Finalize and write objects to the output file.

Implements core::ProcessorBase.

Definition at line 278 of file NumuReco.cxx.

278  {
279  // cleanup pointers to algorithms
280  if (_crt_track_matchalg != NULL) delete _crt_track_matchalg;
281  if (_crt_hit_matchalg != NULL) delete _crt_hit_matchalg;
282  if (_op_hit_maker != NULL) delete _op_hit_maker;
284  if (_mcs_fitter != NULL) delete _mcs_fitter;
285  fOutputFile->cd();
286  // finish histograms
288 }
TFile * fOutputFile
The output ROOT file.
CRTHistos _crt_histograms
Definition: NumuReco.h:386
trkf::TrackMomentumCalculator * _track_momentum_calculator
Calculator for range-based track momentum.
Definition: NumuReco.h:335
sbnd::CRTTrackMatchAlg * _crt_track_matchalg
Algorithm for matching reco Tracks -&gt; CRT Tracks.
Definition: NumuReco.h:342
sbnd::CRTT0MatchAlg * _crt_hit_matchalg
Algorithm for matching reco Tracks -&gt; CRT hits (T0&#39;s)
Definition: NumuReco.h:343
opdet::opHitFinderSBND * _op_hit_maker
Optical hit maker.
Definition: NumuReco.h:346
trkf::TrajectoryMCSFitter * _mcs_fitter
Calculator for MCS based momentum.
Definition: NumuReco.h:336
numu::FlashMatch ana::SBNOsc::NumuReco::FlashMatching ( const recob::Track pandora_track,
const numu::RecoTrack track 
)
protected

Returns whether a TPC track has a match to Optical information

Parameters
pandora_trackThe LArSoft track object
trackThe track infromation from this module
Returns
Flash Match object

Definition at line 1260 of file NumuReco.cxx.

1262  {
1263 
1264  numu::FlashMatch ret;
1265  ret.present = false;
1266 
1267  // don't run if back tracker is not setup
1269  return ret;
1270  }
1271 
1272  // see if we can do the match
1273  if (track.match.has_match) {
1274  // DumpTrueStart(ev, track.match.mcparticle_id);
1275  // get the correct index
1276  int photon_mother_id = GetPhotonMotherID(track.match.mcparticle_id);
1277  const std::vector<art::Ptr<recob::OpHit>> hit_matches = fProviderManager->GetPhotonBackTrackerProvider()->TrackIdToOpHits_Ps(photon_mother_id, _op_hit_ptrs);
1278  if (hit_matches.size() > 0) {
1279  // average the times weighted by PE
1280  double average = 0.;
1281  double match_pe = 0.;
1282  double min_time = 99999999.;
1283  for (const art::Ptr<recob::OpHit> op_hit: hit_matches) {
1284  average += op_hit->PE() * op_hit->PeakTime();
1285  match_pe += op_hit->PE();
1286  if (op_hit->PeakTime() < min_time) {
1287  min_time = op_hit->PeakTime();
1288  }
1289  }
1290  if (match_pe > 0) {
1291  double match_time = average / match_pe;
1292  numu::FlashMatch match;
1293  match.time = min_time;
1294  return match;
1295  }
1296  }
1297  }
1298  return ret;
1299 }
int GetPhotonMotherID(int mcparticle_id)
Definition: NumuReco.cxx:127
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
std::vector< art::Ptr< recob::OpHit > > _op_hit_ptrs
Definition: NumuReco.h:357
bool has_match
Whether a track match exists.
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
ProviderManager * fProviderManager
Interface for provider access.
cheat::PhotonBackTracker * GetPhotonBackTrackerProvider() const
const std::vector< art::Ptr< recob::OpHit > > TrackIdToOpHits_Ps(int const &tkId, std::vector< art::Ptr< recob::OpHit >> const &hitsIn)
int ana::SBNOsc::NumuReco::GetPhotonMotherID ( int  mcparticle_id)
protected

Gets the ID of a true particle is stored by MC photon information

Parameters
mcparticle_idThe MCParticleID of the true particle as returned by G4
Returns
The ID of the particle as in the photon objects

Definition at line 127 of file NumuReco.cxx.

127  {
128  bool is_cosmic = _true_particles_to_truth.at(mcparticle_id)->Origin() != simb::Origin_t::kBeamNeutrino;
129  if (is_cosmic) {
130  unsigned truth_index = _true_particles_to_generator_info.at(mcparticle_id)->generatedParticleIndex();
131  return (int) truth_index +1;
132  }
133  else {
134  return mcparticle_id;
135  }
136 }
std::map< int, art::Ptr< simb::MCTruth > > _true_particles_to_truth
Definition: NumuReco.h:380
std::map< int, const sim::GeneratedParticleInfo * > _true_particles_to_generator_info
Definition: NumuReco.h:381
bool ana::SBNOsc::NumuReco::HasPrimaryTrack ( const std::map< size_t, numu::RecoTrack > &  tracks,
const numu::RecoSlice slice 
)
protected

Returns whether a primary track (candidate muon) candidate exists for a neutrino interaction candidate

Parameters
tracksThe list of reconstructed tracks in the event
sliceThe candidate neutrino interaction
Returns
Whether a primary track candidate exists

Definition at line 839 of file NumuReco.cxx.

839  {
840  if (slice.primary_index < 0) return false;
841 
842  std::cout << "Checking slice particle: " << slice.primary_index << std::endl;
843  for (const auto &part_pair: slice.particles) {
844  std::cout << "ID: " << part_pair.first << "\n";
845  }
846  const numu::RecoParticle &neutrino = slice.particles.at(slice.primary_index);
847  for (size_t pfp_index: neutrino.daughters) {
848  std::cout << "Neutrino daughter ID: " << pfp_index << std::endl;
849  const numu::RecoParticle &daughter = slice.particles.at(pfp_index);
850  if (tracks.count(daughter.ID)) {
851  if (tracks.at(daughter.ID).length > 1e-4) {
852  return true;
853  }
854  }
855  }
856 
857  return false;
858 }
size_t ID
ID of particle.
Definition: RecoParticle.h:18
std::vector< size_t > daughters
Daughters of the particle in the &quot;particle flow&quot;. Value represents index into pandora information...
Definition: RecoParticle.h:17
std::map< size_t, RecoParticle > particles
Map of particle index to particle information.
Definition: RecoEvent.h:28
do i e
int primary_index
Index of the primary particle of this slice.
Definition: RecoEvent.h:25
BEGIN_PROLOG could also be cout
bool ana::SBNOsc::NumuReco::InActive ( const TVector3 &  v) const
protected

Test whether a point is in the configured fiducial volume

Parameters
vThe point to test
Returns
Whether the point is in the configured fiducial volume

Definition at line 1396 of file NumuReco.cxx.

1396  {
1397  for (auto const& active: _config.active_volumes) {
1398  if (active.ContainsPosition(v)) return true;
1399  }
1400  return false;
1401 }
std::vector< geo::BoxBoundedGeo > active_volumes
List of active volumes per cryostat.
Definition: NumuReco.h:99
Config _config
The config.
Definition: NumuReco.h:332
bool ana::SBNOsc::NumuReco::InBeamSpill ( float  time)
protected

Returns whether the povided time is inside the configured beam spill.

Parameters
timeInput time in us.
Returns
Whether the provided time is inside the configured beam spill.

Definition at line 1301 of file NumuReco.cxx.

1301  {
1302  return time > _config.BeamSpillWindow[0] && time < _config.BeamSpillWindow[1];
1303 }
std::array< float, 2 > BeamSpillWindow
Definition: NumuReco.h:126
Config _config
The config.
Definition: NumuReco.h:332
void ana::SBNOsc::NumuReco::Initialize ( fhicl::ParameterSet *  config = NULL)
virtual

Initialization.

Parameters
configA configuration, as a FHiCL ParameterSet object

Implements core::ProcessorBase.

Definition at line 170 of file NumuReco.cxx.

170  {
171  if (config) {
172  fhicl::ParameterSet pconfig = config->get<fhicl::ParameterSet>("NumuReco");
173 
174  // configure the Cosmic ID algorithms
175  _crt_track_matchalg = new sbnd::CRTTrackMatchAlg(fhicl::Table<sbnd::CRTTrackMatchAlg::Config>(pconfig.get<fhicl::ParameterSet>("CRTTrackMatchAlg"))(),
177 
178  _crt_hit_matchalg = new sbnd::CRTT0MatchAlg(fhicl::Table<sbnd::CRTT0MatchAlg::Config>(pconfig.get<fhicl::ParameterSet>("CRTT0MatchAlg"))(),
180 
181  _apa_cross_cosmic_alg.reconfigure(*fProviderManager, fhicl::Table<ApaCrossCosmicIdAlg::Config>(pconfig.get<fhicl::ParameterSet>("ApaCrossCosmicIdAlg"))());
182 
183  _stopping_cosmic_alg.reconfigure(*fProviderManager, fhicl::Table<StoppingParticleCosmicIdAlg::Config>(pconfig.get<fhicl::ParameterSet>("StoppingParticleCosmicIdAlg"))());
184 
185 
188 
189  // get the beam center
190  _config.beamCenterX = pconfig.get<float>("beamCenterX", 130.);
191  _config.beamCenterY = pconfig.get<float>("beamCenterY", 0.);
192 
193  _config.verbose = pconfig.get<bool>("verbose", false);
194 
195  _config.requireTrack = pconfig.get<bool>("requireTrack", false);
196 
197  _config.trackMatchContainmentCut = pconfig.get<double>("trackMatchContainmentCut", -1);
198 
199  _config.TSMode = pconfig.get<int>("TSMode", 1);
200  _config.MakeOpHits = pconfig.get<bool>("MakeOpHits", false);
201 
202  _config.requireMatched = pconfig.get<bool>("requireMatched", false);
203  _config.requireContained = pconfig.get<bool>("requireContained", false);
204  _config.CRTHitTimeCorrection = pconfig.get<double>("CRTHitTimeCorrection", 0.);
205 
206  _config.BeamSpillWindow = pconfig.get<std::array<float, 2>>("BeamSpillWindow", {-25., 10.}); // default -- give 0.2us buffer on each side
207 
208  // setup weight config
209  _config.uniformWeights = pconfig.get<std::vector<std::string>>("uniformWeights", {});
210  _config.constantWeight = pconfig.get<double>("constantWeight", 1.0);
211  _config.cosmicWeight = pconfig.get<double>("cosmicWeight", 1.0);
212 
213  // flash match method
214  _config.FlashMatchMethod = pconfig.get<int>("FlashMatchMethod", 2);
215  _config.flashMatchTimeDifference = pconfig.get<double>("flashMatchTimeDifference");
216 
217  _config.PMTTriggerThreshold = pconfig.get<int>("PMTTriggerThreshold");
218 
219  _config.CosmicIDAllTracks = pconfig.get<bool>("CosmicIDAllTracks", false);
220 
221  // whether to use flash matching in makin CRT decision
222  _config.CRT2OPTimeWidth = pconfig.get<double>("CRT2OPTimeWidth", 0.);
223  _config.CRTHitinOpHitRange = pconfig.get<bool>("CRTHitinOpHitRange", false);
224 
225  // get tag names
226  _config.RecoTrackTag = config->get<std::string>("RecoTrackTag", "pandoraTrack");
227  _config.RecoSliceTag = config->get<std::string>("RecoSliceTag", "pandora");
228  _config.RecoVertexTag = config->get<std::string>("RecoVertexTag", "pandora");
229  _config.PFParticleTag = config->get<std::string>("PFParticleTag", "pandora");
230  _config.FlashMatchTag = config->get<std::string>("FlashMatchTag ", "fmatch");
231  _config.CaloTag = config->get<std::string>("CaloTag", "pandoraCalo");
232  _config.PIDTag = config->get<std::string>("PIDTag", "pandoraPid");
233  _config.CorsikaTag = config->get<std::string>("CorsikaTag", "cosmgen");
234  _config.CRTTrackTag = config->get<std::string>("CRTTrackTag", "crttrack");
235  _config.CRTHitTag = config->get<std::string>("CRTHitTag", "crthit");
236  _config.OpFlashTag = config->get<std::string>("OpFlashTag", "ophit");
237  _config.MCParticleTag = config->get<std::string>("MCParticleTag", "largeant");
238  _config.TPCRecoTagSuffixes = config->get<std::vector<std::string>>("TPCRecoTagSuffixes", { "" });
239 
240  {
241  fhicl::ParameterSet dCV = \
242  pconfig.get<fhicl::ParameterSet>("containment_volume_inset");
243  double dx = dCV.get<double>("x");
244  double dy = dCV.get<double>("y");
245  double zfront = dCV.get<double>("zfront");
246  double zback = dCV.get<double>("zback");
247  for (const geo::BoxBoundedGeo &geo: _config.active_volumes) {
248  _config.containment_volumes.emplace_back(geo.MinX() + dx, geo.MaxX() - dx, geo.MinY() + dy, geo.MaxY() - dy, geo.MinZ() + zfront, geo.MaxZ() - zback);
249  }
250  }
251 
252  // initialize things to do with reconstruction
253  double min_track_length = pconfig.get<double>("MinTrackLength", 10.);
255  _mcs_fitter = new trkf::TrajectoryMCSFitter(pconfig.get<fhicl::ParameterSet>("MCSFitter", {}));
256 
257  _op_hit_maker = (_config.MakeOpHits) ? new opdet::opHitFinderSBND(pconfig.get<fhicl::ParameterSet>("OpHitMaker"), fProviderManager->GetDetectorClocksProvider()) :
258  NULL;
259  }
260 
261  // Setup histo's for root output
262  fOutputFile->cd();
263 
265  std::vector<double> tagger_volumes = crt_geo.CRTLimits();
266 
267  // crt histograms
268  _crt_histograms.Initialize("crt_all", tagger_volumes);
269 
270  // add branches
271  fTree->Branch("reco_event", &_recoEvent);
272  fTree->Branch("reco_vertices", &_selected);
273 
274  hello();
275 }
bool verbose
Whether to print out info associated w/ selection.
Definition: NumuReco.h:102
bool requireTrack
Apply cut that requires each reconstructed vertex to have an associated primary track.
Definition: NumuReco.h:108
std::vector< geo::BoxBoundedGeo > ActiveVolumes(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:3
std::array< float, 2 > BeamSpillWindow
Definition: NumuReco.h:126
void reconfigure(const core::ProviderManager &manager, const Config &config)
std::vector< numu::RecoInteraction > * _selected
Branch container for the list of selected reco vertices.
Definition: NumuReco.h:340
StoppingParticleCosmicIdAlg _stopping_cosmic_alg
Algorithm for doing cosmic ID using a fit to the energy deposits.
Definition: NumuReco.h:345
std::vector< std::vector< geo::BoxBoundedGeo > > tpc_volumes
List of active tpc volumes – retreived from Geoemtry service.
Definition: NumuReco.h:100
numu::RecoEvent _recoEvent
Branch container for the RecoEvent.
Definition: NumuReco.h:339
std::string CRTTrackTag
art tag for CRT tracks
Definition: NumuReco.h:139
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
const detinfo::DetectorPropertiesStandard * GetDetectorPropertiesProvider() const
TTree * fTree
The output ROOT tree.
const geo::AuxDetGeometryCore * GetAuxDetGeometryProvider() const
TFile * fOutputFile
The output ROOT file.
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
void reconfigure(const core::ProviderManager &manager, const Config &config)
CRTHistos _crt_histograms
Definition: NumuReco.h:386
std::vector< std::string > TPCRecoTagSuffixes
Definition: NumuReco.h:133
ApaCrossCosmicIdAlg _apa_cross_cosmic_alg
Algorithm for doing cosmic ID by looking for tracks crossing APA.
Definition: NumuReco.h:344
const geo::GeometryCore * GetGeometryProvider() const
trkf::TrackMomentumCalculator * _track_momentum_calculator
Calculator for range-based track momentum.
Definition: NumuReco.h:335
std::vector< std::string > uniformWeights
Weights taken from &quot;EventWeight&quot; that should be applied to the weight of each event.
Definition: NumuReco.h:103
bool requireContained
Apply cut that requires each primary track to be contained inside the containment volume...
Definition: NumuReco.h:109
sbnd::CRTTrackMatchAlg * _crt_track_matchalg
Algorithm for matching reco Tracks -&gt; CRT Tracks.
Definition: NumuReco.h:342
double cosmicWeight
Weight applied to all events matched to a cosmic track.
Definition: NumuReco.h:105
bool requireMatched
Apply cut that requires each reconstructed vertex to be matched to a truth vertex.
Definition: NumuReco.h:107
sbnd::CRTT0MatchAlg * _crt_hit_matchalg
Algorithm for matching reco Tracks -&gt; CRT hits (T0&#39;s)
Definition: NumuReco.h:343
double MinZ() const
Returns the world z coordinate of the start of the box.
opdet::opHitFinderSBND * _op_hit_maker
Optical hit maker.
Definition: NumuReco.h:346
const detinfo::DetectorClocksStandard * GetDetectorClocksProvider() const
std::vector< std::vector< geo::BoxBoundedGeo > > TPCVolumes(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:49
std::vector< geo::BoxBoundedGeo > containment_volumes
List of volumes for containment cuts – set by &quot;containment_volumes&quot;.
Definition: NumuReco.h:98
std::string CorsikaTag
art tag for corsika MCTruth
Definition: NumuReco.h:138
double MaxY() const
Returns the world y coordinate of the end of the box.
std::vector< geo::BoxBoundedGeo > active_volumes
List of active volumes per cryostat.
Definition: NumuReco.h:99
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
std::string PFParticleTag
art tag for PFParticles
Definition: NumuReco.h:136
double MaxZ() const
Returns the world z coordinate of the end of the box.
trkf::TrajectoryMCSFitter * _mcs_fitter
Calculator for MCS based momentum.
Definition: NumuReco.h:336
Config _config
The config.
Definition: NumuReco.h:332
ProviderManager * fProviderManager
Interface for provider access.
double constantWeight
Constant weight to apply uniformly to each event.
Definition: NumuReco.h:104
Class for Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Trac...
void Initialize(const std::string &postfix, const std::vector< double > &tagger_volume)
Definition: CRTHisto.cc:6
std::string MCParticleTag
art tag for MCParticle
Definition: NumuReco.h:142
double MinY() const
Returns the world y coordinate of the start of the box.
std::string RecoTrackTag
art tag for reconstructed tracks
Definition: NumuReco.h:131
std::string RecoVertexTag
art tag for reconstructed vertices
Definition: NumuReco.h:132
std::vector< numu::CRTHit > ana::SBNOsc::NumuReco::InTimeCRTHits ( )
protected

Return the list of intime CRTHits in the reconstructed event.

Returns
In time CRT Hits in the numu reco format

Definition at line 1322 of file NumuReco.cxx.

1322  {
1323  std::vector<numu::CRTHit> ret;
1324 
1325  for (const sbn::crt::CRTHit &hit: *_crt_hits) {
1327  if (InBeamSpill(this_hit.time)) {
1328  ret.push_back(this_hit);
1329  }
1330  }
1331 
1332  return std::move(ret);
1333 }
numu::CRTHit SBND2numuCRTHit(const sbn::crt::CRTHit &hit)
Definition: NumuReco.cxx:1305
process_name hit
Definition: cheaterreco.fcl:51
float time
CRT Hit time.
Definition: DetInfo.h:13
const std::vector< sbn::crt::CRTHit > * _crt_hits
Definition: NumuReco.h:352
bool InBeamSpill(float time)
Definition: NumuReco.cxx:1301
numu::TrackTruthMatch ana::SBNOsc::NumuReco::MatchTrack2Truth ( size_t  track_id)
protected

Get matching information from a reconstructed track to truth information

Parameters
track_idthe "ID" of the reconstructed track. NOT the pandora ID.
Returns
The matchinf information of this track to truth information

Definition at line 866 of file NumuReco.cxx.

866  {
867  // get the service
869 
870  // get its hits
871  std::vector<art::Ptr<recob::Hit>> hits = _tpc_tracks_to_hits.at(pfp_track_id);
872 
873  // this id is the same as the mcparticle ID as long as we got it from geant4
874  // int id = SBNRecoUtils::TrueParticleIDFromTotalRecoHits(*fProviderManager, hits, false);
875  int mcp_track_id = SBNRecoUtils::TrueParticleIDFromTotalTrueEnergy(*fProviderManager, hits, true);
876 
877 
878  int mcparticle_index = -1;
879  for (int i = 0; i < _true_particles.size(); i++) {
880  if (_true_particles[i]->TrackId() == mcp_track_id) {
881  mcparticle_index = i;
882  break;
883  }
884  }
885 
886  // number returned to mean "NULL"
887  // no match
888  if (mcparticle_index == -1) return numu::TrackTruthMatch();
889 
890  // We got a match! Try to identify it to an origin
891  art::Ptr<simb::MCTruth> truth = inventory_service->TrackIdToMCTruth_P(mcp_track_id);
892  // and calculate the completion
893  double completion = SBNRecoUtils::TrackCompletion(*fProviderManager, mcp_track_id, hits);
894 
896  // ret.mctruth = truth.get();
897  ret.has_match = true;
898  ret.mctruth_has_neutrino = truth->NeutrinoSet();
899  ret.mctruth_vertex = ret.mctruth_has_neutrino ? truth->GetNeutrino().Nu().Position().Vect() : TVector3(-999, -999, -999);
900  ret.mctruth_origin = truth->Origin();
901 
902  // TODO: fix -- in time cosmics will not have the origin set correctly. Fix and set this to 2.
903  if (ret.mctruth_origin == simb::kUnknown) {
905  }
906 
907  ret.mctruth_ccnc = ret.mctruth_has_neutrino ? truth->GetNeutrino().CCNC() : -1;
908  ret.mcparticle_id = mcp_track_id;
909  ret.completion = completion;
910  ret.match_pdg = _true_particles[mcparticle_index]->PdgCode();
911  ret.is_primary = _true_particles[mcparticle_index]->Process() == "primary";
912  return ret;
913 }
bool mctruth_has_neutrino
Whether the MCTruth object this track matches to is a neutrino interaction.
std::vector< art::Ptr< simb::MCParticle > > _true_particles
Definition: NumuReco.h:379
int mctruth_ccnc
CC (1) / NC (0) value of the MCTruth this object matches to.
int mctruth_origin
Value of Origin_t enum of the MCTruth object this track matches to.
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
std::vector< std::vector< art::Ptr< recob::Hit > > > _tpc_tracks_to_hits
Definition: NumuReco.h:371
cheat::ParticleInventory * GetParticleInventoryProvider() const
double TrackCompletion(const core::ProviderManager &manager, int mcparticle_id, const std::vector< art::Ptr< recob::Hit >> &reco_track_hits)
TVector3 mctruth_vertex
The interaction vertex of the MCTruth object this track matches to.
int TrueParticleIDFromTotalTrueEnergy(const core::ProviderManager &manager, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
float completion
Fraction of energy deposits by true particle matched by this track.
const Cut kCosmicRay
bool has_match
Whether a track match exists.
bool is_primary
Whether this track was produced as the &quot;primary&quot; process.
ProviderManager * fProviderManager
Interface for provider access.
int match_pdg
PDG of the MCParticle this track matches to.
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id) const
numu::TrueParticle ana::SBNOsc::NumuReco::MCParticleInfo ( const simb::MCParticle &  particle)
protected

Adapt an MCParticle to the information needed for this event selection module

Definition at line 381 of file NumuReco.cxx.

381  {
382  numu::TrueParticle ret;
383 
384  // default values
385  ret.length = 0.;
386  ret.crosses_tpc = false;
387  ret.wall_enter = numu::wNone;
388  ret.wall_exit = numu::wNone;
389  ret.deposited_energy = 0.;
390 
391  // If the interaction is outside the active volume, then g4 won't generate positions for the particle.
392  // So size == 0 => outside FV
393  //
394  // If size != 0, then we have to check volumes
395  ret.contained_in_cryo = particle.NumberTrajectoryPoints() > 0;
396  ret.contained_in_tpc = particle.NumberTrajectoryPoints() > 0;
397  ret.is_contained = particle.NumberTrajectoryPoints() > 0;
398 
399  // get the point at which the Trajectory enters the cryostat (which may be non-zero for cosmics)
400  int entry_point = -1;
401 
402  int cryostat_index = -1;
403  int tpc_index = -1;
404 
405  for (unsigned j = 0; j < particle.NumberTrajectoryPoints(); j++) {
406  for (unsigned i = 0; i < _config.active_volumes.size(); i++) {
407  if (_config.active_volumes[i].ContainsPosition(particle.Position(j).Vect())) {
408  entry_point = j;
409  cryostat_index = i;
410  break;
411  }
412  }
413  if (entry_point != -1) break;
414  }
415 
416  // find the entering wall
417  if (entry_point > 0) {
418  ret.wall_enter = GetWallCross(_config.active_volumes[cryostat_index], particle.Position(entry_point).Vect(), particle.Position(entry_point-1).Vect());
419  }
420 
421  std::vector<geo::BoxBoundedGeo> volumes;
422  if (entry_point >= 0) {
423  volumes = _config.tpc_volumes[cryostat_index];
424  // setup the initial TPC index
425  for (int i = 0; i < volumes.size(); i++) {
426  if (volumes[i].ContainsPosition(particle.Position(entry_point).Vect())) {
427  tpc_index = i;
428  ret.contained_in_tpc = entry_point == 0;
429  break;
430  }
431  }
432  ret.is_contained = entry_point == 0;
433  ret.contained_in_cryo = entry_point == 0;
434  }
435  // if we couldn't find a volume for the intial point, set not contained
436  else {
437  ret.contained_in_cryo = false;
438  ret.is_contained = false;
439  }
440  if (tpc_index < 0) {
441  ret.contained_in_tpc = false;
442  }
443 
444  // setup aa volumes too for length calc
445  std::vector<geoalgo::AABox> aa_volumes;
446  for (auto const &v: volumes) {
447  aa_volumes.emplace_back(v.MinX(), v.MinY(), v.MinZ(), v.MaxX(), v.MaxY(), v.MaxZ());
448  }
449 
450  int exit_point = -1;
451 
452  // Get the length and determine if any point leaves the active volume
453  //
454  // Use every trajectory point if possible
455  if (entry_point >= 0) {
456  // particle trajectory
457  const simb::MCTrajectory &trajectory = particle.Trajectory();
458  TVector3 pos = trajectory.Position(entry_point).Vect();
459  for (int i = entry_point+1; i < particle.NumberTrajectoryPoints(); i++) {
460  TVector3 this_point = trajectory.Position(i).Vect();
461  // get the exit point
462  // update if particle is contained
463  if (ret.contained_in_cryo) {
464  ret.contained_in_cryo = _config.active_volumes[cryostat_index].ContainsPosition(this_point);
465  }
466  // check if particle has crossed TPC
467  if (!ret.crosses_tpc) {
468  for (int j = 0; j < volumes.size(); j++) {
469  if (volumes[j].ContainsPosition(this_point) && j != tpc_index) {
470  ret.crosses_tpc = true;
471  break;
472  }
473  }
474  }
475  // check if particle has left tpc
476  if (ret.contained_in_tpc) {
477  ret.contained_in_tpc = volumes[tpc_index].ContainsPosition(this_point);
478  }
479 
480  if (ret.is_contained) {
481  ret.is_contained = _config.containment_volumes[cryostat_index].ContainsPosition(this_point);
482  }
483 
484  // update length
485  ret.length += containedLength(this_point, pos, aa_volumes);
486 
487  if (!_config.active_volumes[cryostat_index].ContainsPosition(this_point) && _config.active_volumes[cryostat_index].ContainsPosition(pos)) {
488  exit_point = i-1;
489  }
490 
491  // update energy
492  if (InActive(this_point) && InActive(pos)) {
493  ret.deposited_energy += trajectory.Momentum(i-1).E() - trajectory.Momentum(i).E();
494  }
495  pos = trajectory.Position(i).Vect();
496  }
497  }
498  if (exit_point < 0 && entry_point >= 0) {
499  exit_point = particle.NumberTrajectoryPoints() - 1;
500  }
501  if (exit_point < particle.NumberTrajectoryPoints() - 1) {
502  ret.wall_exit = GetWallCross(_config.active_volumes[cryostat_index], particle.Position(exit_point).Vect(), particle.Position(exit_point+1).Vect());
503  }
504 
505  // get the generation mode
506  ret.is_cosmic = _true_particles_to_truth.at(particle.TrackId())->Origin() != simb::kBeamNeutrino;
507 
508  //double costh = (entry_point >= 0 && particle.Momentum(entry_point).Vect().Mag() > 1e-4) ? particle.Pz(entry_point) / particle.Momentum(entry_point).Vect().Mag(): -999.;
509  //double kinetic_energy = (entry_point >= 0) ? particle.E(entry_point) /* already in GeV*/ - PDGMass(pdgid) / 1000. /* MeV -> GeV */: -999.;
510 
511  // other truth information
512  ret.pdgid = particle.PdgCode();
513 
514  ret.start = (entry_point >= 0) ? particle.Position(entry_point).Vect(): TVector3(-9999, -9999, -9999);
515  ret.start_time = (entry_point >= 0) ? particle.Position(entry_point).T() / 1000. /* ns-> us*/: -9999;
516  ret.end = (exit_point >= 0) ? particle.Position(exit_point).Vect(): TVector3(-9999, -9999, -9999);
517  ret.end_time = (exit_point >= 0) ? particle.Position(exit_point).T() / 1000. /* ns -> us */ : -9999;
518 
519  ret.start_momentum = (entry_point >= 0) ? particle.Momentum(entry_point).Vect() : TVector3(-9999, -9999, -9999);
520  ret.start_energy = (entry_point >= 0) ? particle.Momentum(entry_point).E() : -9999.;
521  ret.end_momentum = (exit_point >= 0) ? particle.Momentum(exit_point).Vect() : TVector3(-9999, -9999, -9999);
522  ret.end_energy = (exit_point >= 0) ? particle.Momentum(exit_point).E() : -9999.;
523 
524  ret.ID = particle.TrackId();
525 
526  return ret;
527 }
std::map< int, art::Ptr< simb::MCTruth > > _true_particles_to_truth
Definition: NumuReco.h:380
TVector3 start_momentum
Particle directional momentum for first trajectory point inside TPC AV [GeV].
Definition: TrueParticle.h:24
int ID
ID/index of this particle (taken from MCParticle ID)
Definition: TrueParticle.h:47
bool is_cosmic
Whether this particle is of cosmic origin.
Definition: TrueParticle.h:45
std::vector< std::vector< geo::BoxBoundedGeo > > tpc_volumes
List of active tpc volumes – retreived from Geoemtry service.
Definition: NumuReco.h:100
TVector3 end_momentum
Particle directional momentum for last trajectory point inside TPC AV [GeV].
Definition: TrueParticle.h:25
bool is_contained
is it contained in a single cryostat active volume
Definition: TrueParticle.h:40
float length
Length of track contained in any TPC active volume [cm].
Definition: TrueParticle.h:42
TVector3 start
start position of track
Definition: TrueParticle.h:30
bool crosses_tpc
does it cross a tpc?
Definition: TrueParticle.h:39
float end_energy
Particle energy for last point inside TPC AV [GeV].
Definition: TrueParticle.h:27
bool InActive(const TVector3 &v) const
Definition: NumuReco.cxx:1396
bool contained_in_cryo
is it contained a single cryostat?
Definition: TrueParticle.h:37
float start_energy
Particle energy for first point inside TPC AV [GeV].
Definition: TrueParticle.h:26
TVector3 end
end position of track
Definition: TrueParticle.h:31
numu::Wall GetWallCross(const geo::BoxBoundedGeo &volume, const TVector3 p0, const TVector3 p1)
Definition: NumuReco.cxx:79
std::vector< geo::BoxBoundedGeo > containment_volumes
List of volumes for containment cuts – set by &quot;containment_volumes&quot;.
Definition: NumuReco.h:98
std::vector< geo::BoxBoundedGeo > active_volumes
List of active volumes per cryostat.
Definition: NumuReco.h:99
float deposited_energy
Total particle energy depositive in TPC AV [GeV].
Definition: TrueParticle.h:28
double containedLength(const TVector3 &v0, const TVector3 &v1, const std::vector< geoalgo::AABox > &boxes)
int pdgid
Particle ID code.
Definition: TrueParticle.h:43
Config _config
The config.
Definition: NumuReco.h:332
bool contained_in_tpc
is it contained in a single TPC?
Definition: TrueParticle.h:38
Wall wall_enter
the face of the TPC that the particle crosses on enter
Definition: TrueParticle.h:35
Wall wall_exit
the face of the TPC that the particle crosses on exit
Definition: TrueParticle.h:36
float start_time
start time of track
Definition: TrueParticle.h:32
float end_time
end time of track
Definition: TrueParticle.h:33
std::map< size_t, numu::TrueParticle > ana::SBNOsc::NumuReco::MCParticleInfos ( )
protected

Collect information on true particles for this event

Definition at line 529 of file NumuReco.cxx.

529  {
530  std::map<size_t, numu::TrueParticle> ret;
531  for (unsigned i = 0; i < _true_particles.size(); i++) {
532  ret[_true_particles[i]->TrackId()] = MCParticleInfo(*_true_particles[i]);
533  }
534  return ret;
535 }
std::vector< art::Ptr< simb::MCParticle > > _true_particles
Definition: NumuReco.h:379
numu::TrueParticle MCParticleInfo(const simb::MCParticle &particle)
Definition: NumuReco.cxx:381
bool ana::SBNOsc::NumuReco::ProcessEvent ( const gallery::Event &  ev,
const std::vector< event::Interaction > &  truth,
std::vector< event::RecoInteraction > &  reco 
)
virtual

Process one event.

Parameters
evA single event, as a gallery::Event
Reconstructedinteractions
Returns
True to keep event

Implements core::ProcessorBase.

Definition at line 300 of file NumuReco.cxx.

300  {
301  if (_event_counter % 10 == 0) {
302  std::cout << "NumuReco: Processing event " << _event_counter << " "
303  << "(" << _nu_count << " neutrinos selected)"
304  << std::endl;
305  }
306  // on the first event, store the type of MC we are processing
307  if (_event_counter == 0) {
308  // Get neutrino truth
309  gallery::Handle<std::vector<simb::MCTruth>> mctruth_handle;
310  bool has_mctruth = ev.getByLabel(fTruthTag, mctruth_handle);
311 
312  // also cosmics
313  gallery::Handle<std::vector<simb::MCTruth>> cosmics;
314  bool has_cosmics = ev.getByLabel(_config.CorsikaTag, cosmics);
315 
316  // cosmic + neutrino -- overlay
317  if (has_mctruth && has_cosmics) {
319  }
320  else if (has_cosmics) {
322  }
323  else {
325  }
326  TParameter<int> mc_type("MCType", (int)fType);
327  fOutputFile->cd();
328  mc_type.Write();
329  }
330 
331 
332  std::cout << "New Event! " << _event_counter << std::endl;
333  std::cout << "ART Event no: " << ev.eventAuxiliary().event() << std::endl;
334  // clear out old containers
335  _selected->clear();
336 
337  bool selected = false;
338 
339  _event_counter++;
341 
342  std::map<size_t, numu::TrueParticle> particles = MCParticleInfos();
343 
344  // get the event info
345  _recoEvent = Reconstruct(ev, core_truth);
346 
347  // complete the information
348  _recoEvent.particles = std::move(particles);
349 
350  // set the file type
352 
353  // save the information
354  for (unsigned i = 0; i < _recoEvent.reco.size(); i++) {
356  // compute the weight for this interaction
357  double weight = 1.;
358  weight *= _config.constantWeight;
359  // TODO: what about cosmics?
360  // if (vertex.match.mctruth_vertex_id >= 0) {
361  // for (auto const &key: _config.uniformWeights) {
362  // weight *= core_truth[vertex.match.mctruth_vertex_id].weightmap.at(key)[0];
363  // }
364  // }
365  if (vertex.match.mode == numu::mCosmic) {
366  weight *= _config.cosmicWeight;
367  }
368 
369  // store reco interaction
370  _selected->push_back(vertex);
371  // store sbncode reco interaction
372  reco.push_back(CoreRecoInteraction(core_truth, vertex, weight));
373  selected = true;
374  _nu_count++;
375  }
376 
377  return true;
378 }
InteractionMode mode
Mode of the interaction.
process_name vertex
Definition: cheaterreco.fcl:51
std::vector< numu::RecoInteraction > * _selected
Branch container for the list of selected reco vertices.
Definition: NumuReco.h:340
event::RecoInteraction CoreRecoInteraction(const std::vector< event::Interaction > &truth, const numu::RecoInteraction &vertex, double weight)
Definition: NumuReco.cxx:290
art::InputTag fTruthTag
art tag for MCTruth information
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
numu::RecoEvent _recoEvent
Branch container for the RecoEvent.
Definition: NumuReco.h:339
unsigned _event_counter
Count processed events.
Definition: NumuReco.h:328
TFile * fOutputFile
The output ROOT file.
std::map< size_t, TrueParticle > particles
Map of indices to True particle information.
Definition: RecoEvent.h:49
void CollectTruthInformation(const gallery::Event &ev)
Definition: NumuReco.cxx:991
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
numu::RecoEvent Reconstruct(const gallery::Event &ev, const std::vector< event::Interaction > &truth)
Definition: NumuReco.cxx:1335
double cosmicWeight
Weight applied to all events matched to a cosmic track.
Definition: NumuReco.h:105
std::map< size_t, numu::TrueParticle > MCParticleInfos()
Definition: NumuReco.cxx:529
std::string CorsikaTag
art tag for corsika MCTruth
Definition: NumuReco.h:138
unsigned _nu_count
Count selected events.
Definition: NumuReco.h:329
Config _config
The config.
Definition: NumuReco.h:332
double constantWeight
Constant weight to apply uniformly to each event.
Definition: NumuReco.h:104
BEGIN_PROLOG could also be cout
numu::MCType fType
Definition: NumuReco.h:384
numu::RecoEvent ana::SBNOsc::NumuReco::Reconstruct ( const gallery::Event &  ev,
const std::vector< event::Interaction > &  truth 
)
protected

Produce all reconstruction information from the gallery event

Parameters
evthe gallery Event
truththe list of truth interactions for this event
Returns
the RecoEvent object for this event

Definition at line 1335 of file NumuReco.cxx.

1335  {
1336  // setup products
1340 
1341  // colect PFParticle information
1342  std::vector<numu::RecoParticle> reco_particles = RecoParticleInfo();
1343 
1344  // collect track information
1345  std::map<size_t, numu::RecoTrack> reco_tracks = RecoTrackInfo();
1346 
1347  // collect Pandora slice information
1348  std::vector<numu::RecoSlice> reco_slices = RecoSliceInfo(reco_tracks, reco_particles);
1349 
1350  std::vector<numu::RecoInteraction> reco;
1351  for (unsigned reco_i = 0; reco_i < reco_slices.size(); reco_i++) {
1352  const numu::RecoParticle &neutrino = reco_slices[reco_i].particles.at(reco_slices[reco_i].primary_index);
1353 
1354  numu::RecoInteraction this_interaction;
1355 
1356  this_interaction.slice = reco_slices[reco_i];
1357  this_interaction.position = neutrino.vertices[0];
1358 
1359  // TODO: get the enrgy
1360  this_interaction.nu_energy = -1;
1361 
1362  // Track multiplicity
1363  this_interaction.multiplicity = this_interaction.slice.particles.at(this_interaction.slice.primary_index).daughters.size();
1364 
1365  // do initial truth matching
1366  this_interaction.match = numu::InteractionTruthMatch(truth, reco_tracks, this_interaction);
1367 
1368  // store
1369  reco.push_back(std::move(this_interaction));
1370  }
1371 
1372  numu::RecoEvent event;
1373  event.reco = std::move(reco);
1374  event.tracks = std::move(reco_tracks);
1375 
1376  // collect spare detector information
1377  event.in_time_crt_hits = InTimeCRTHits();
1378  gallery::Handle<std::vector<raw::OpDetWaveform>> waveforms;
1379  if (ev.getByLabel("opdaq", waveforms)) {
1380  double tick_period = fProviderManager->GetDetectorClocksProvider()->OpticalClock().TickPeriod();
1381  int threshold = _config.PMTTriggerThreshold;
1382  bool is_sbnd = fExperimentID == kExpSBND;
1383  std::pair<double, double> window;
1384  if (is_sbnd) window = {0., 2.}; // go out to 0.4us past end of beam gate
1385  else window = {1500., 1502.};
1386  event.flash_trigger_primitives = numu::TriggerPrimitives(*waveforms, tick_period, window, threshold, is_sbnd);
1387  }
1388 
1389  // fill spare histograms
1390  FillCRTHits();
1391 
1392 
1393  return std::move(event);
1394 }
std::vector< numu::RecoSlice > RecoSliceInfo(std::map< size_t, numu::RecoTrack > &reco_tracks, const std::vector< numu::RecoParticle > &particles)
Definition: NumuReco.cxx:915
std::vector< numu::CRTHit > InTimeCRTHits()
Definition: NumuReco.cxx:1322
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
std::vector< FlashTriggerPrimitive > TriggerPrimitives(const std::vector< raw::OpDetWaveform > &waveforms, double tick_period, std::pair< double, double > &window, int thresh, bool is_sbnd)
Definition: PMTTrigger.cc:7
std::vector< numu::RecoParticle > RecoParticleInfo()
Definition: NumuReco.cxx:784
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
std::map< size_t, numu::RecoTrack > RecoTrackInfo()
Definition: NumuReco.cxx:621
void CollectTPCInformation(const gallery::Event &ev)
Definition: NumuReco.cxx:1008
TVector3 position
location of the vertex
Definition: RecoEvent.h:40
process_name standard_reco_uboone reco
Experiment fExperimentID
Experiment identifier.
void CollectCRTInformation(const gallery::Event &ev)
Definition: NumuReco.cxx:1131
TruthMatch InteractionTruthMatch(const std::vector< event::Interaction > &truth, const std::map< size_t, numu::RecoTrack > &reco_tracks, const numu::RecoInteraction &reco)
Definition: TruthMatch.cc:10
std::vector< TVector3 > vertices
List of vertices associated with the particle.
Definition: RecoParticle.h:16
const detinfo::DetectorClocksStandard * GetDetectorClocksProvider() const
float nu_energy
true/reconstructed neutrino energy
Definition: RecoEvent.h:41
RecoSlice slice
Particle content of the interaction.
Definition: RecoEvent.h:39
Config _config
The config.
Definition: NumuReco.h:332
std::map< size_t, RecoParticle > particles
Map of particle index to particle information.
Definition: RecoEvent.h:28
int multiplicity
Number of tracks in this interaction.
Definition: RecoEvent.h:43
ProviderManager * fProviderManager
Interface for provider access.
int tick_period
Definition: constants.py:3
int primary_index
Index of the primary particle of this slice.
Definition: RecoEvent.h:25
void CollectPMTInformation(const gallery::Event &ev)
Definition: NumuReco.cxx:1233
std::vector< numu::RecoParticle > ana::SBNOsc::NumuReco::RecoParticleInfo ( )
protected

Gathers together reconstruction information on each individual particle.

Returns
the list of RecoParticle objects for every reconstructed particle in the event

Definition at line 784 of file NumuReco.cxx.

784  {
785  // ret
786  std::vector<numu::RecoParticle> ret;
787 
788  // iterate over all of the pfparticles
789  for (size_t i = 0; i < _tpc_particles.size(); i++) {
790  // new reco particle
791  numu::RecoParticle this_particle;
792  this_particle.ID = i;
793 
794  // get the PFParticle
795  const recob::PFParticle& this_pfp = *_tpc_particles.at(i);
796 
797  // assign pandora PDG
798  this_particle.pandora_pid = this_pfp.PdgCode();
799 
800  // get its daughters in the partcle "flow"
802  // get the metadata
804  // and the properties dict
805  auto const &properties = this_metadata.GetPropertiesMap();
806  // get the reco vertices
807  for (const art::Ptr<recob::Vertex> vert: _tpc_particles_to_vertex.at(i)) {
808  TVector3 vect(vert->position().X(), vert->position().Y(), vert->position().Z());
809  this_particle.vertices.push_back(vect);
810  }
811 
812  // access pandora special values
813  if (properties.count("IsClearCosmic")) {
814  this_particle.p_is_clear_cosmic = properties.at("IsClearCosmic");
815  }
816  else {
817  this_particle.p_is_clear_cosmic = false;
818  }
819  if (properties.count("NuScore")) {
820  this_particle.p_nu_score = properties.at("NuScore");
821  }
822  else {
823  this_particle.p_nu_score = -1;
824  }
825  if (properties.count("IsNeutrino")) {
826  this_particle.p_is_neutrino = properties.at("IsNeutrino");
827  }
828  else {
829  this_particle.p_is_neutrino = false;
830  }
831 
832  ret.push_back(std::move(this_particle));
833  }
834 
835  return ret;
836 }
int pandora_pid
Particle ID from pandora.
Definition: RecoParticle.h:19
std::vector< art::Ptr< recob::PFParticle > > _tpc_particles
Definition: NumuReco.h:363
std::vector< art::Ptr< larpandoraobj::PFParticleMetadata > > _tpc_particles_to_metadata
Definition: NumuReco.h:375
std::vector< std::vector< unsigned > > _tpc_particles_to_daughters
Definition: NumuReco.h:374
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
std::vector< std::vector< art::Ptr< recob::Vertex > > > _tpc_particles_to_vertex
Definition: NumuReco.h:373
size_t ID
ID of particle.
Definition: RecoParticle.h:18
std::vector< size_t > daughters
Daughters of the particle in the &quot;particle flow&quot;. Value represents index into pandora information...
Definition: RecoParticle.h:17
float p_nu_score
Take from Pandora metadata &quot;nu_score&quot;.
Definition: RecoParticle.h:15
Metadata associated to PFParticles.
const PropertiesMap & GetPropertiesMap() const
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
std::vector< TVector3 > vertices
List of vertices associated with the particle.
Definition: RecoParticle.h:16
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
bool p_is_neutrino
Taken from Pandora metadata &quot;is_neutrino&quot;.
Definition: RecoParticle.h:14
bool p_is_clear_cosmic
Taken from Pandora metadata &quot;is_clear_cosmic&quot;.
Definition: RecoParticle.h:13
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
std::vector< numu::RecoSlice > ana::SBNOsc::NumuReco::RecoSliceInfo ( std::map< size_t, numu::RecoTrack > &  reco_tracks,
const std::vector< numu::RecoParticle > &  particles 
)
protected

Gathers the list of reconstructed candidate neutrino interactions as a list of TPC slices.

Parameters
reco_tracksThe list of reconstructed tracks in the event
particlesThe list of reconstructed PFParticles in the event

Definition at line 915 of file NumuReco.cxx.

917  {
918 
919  std::vector<numu::RecoSlice> ret;
920  // store all the particles in the slice
921  for (size_t i = 0; i < _tpc_slices.size(); i++) {
922  const recob::Slice &slice = *_tpc_slices[i];
923  numu::RecoSlice slice_ret;
924  slice_ret.primary_index = -1;
925  bool primary_particle_set = false;
926  // get the particles
927  const std::vector<art::Ptr<recob::PFParticle>> &pfp_particles = _tpc_slices_to_particles.at(i);
928  // find the primary one and store all of them
929  // Find the priamry particle
930  for (unsigned j = 0; j < pfp_particles.size(); j++) {
931  const art::Ptr<recob::PFParticle> pfp_part = pfp_particles[j];
932  if (pfp_part->IsPrimary()) {
933  assert(!primary_particle_set);
934  primary_particle_set = true;
936  }
937  }
938  // match the RecoParticle's to the once that match this slice
939  for (const numu::RecoParticle &part: particles) {
940  if (std::find(_tpc_slices_to_particle_index[i].begin(), _tpc_slices_to_particle_index[i].end(), (unsigned)part.ID) != _tpc_slices_to_particle_index[i].end()) {
941  slice_ret.particles[part.ID] = part;
942  }
943  }
944  // throw away bad slices
945  if (!SelectSlice(slice_ret)) continue;
946 
947  // now get information from particles which are tracks
948  slice_ret.tracks = RecoSliceTracks(reco_tracks, slice_ret.particles);
949 
950  std::cout << "Primary index: " << slice_ret.primary_index << std::endl;
951  std::cout << "Is primary: " << _tpc_particles[slice_ret.primary_index]->IsPrimary() << std::endl;
952  if (_tpc_particles_to_flashT0.size() && _tpc_particles_to_flashT0.at(slice_ret.primary_index).size()) {
953  const anab::T0 &fmatch = *_tpc_particles_to_flashT0.at(slice_ret.primary_index).at(0);
954  slice_ret.flash_match.present = true;
955  slice_ret.flash_match.time = fmatch.Time();
956  slice_ret.flash_match.score = fmatch.TriggerConfidence();
957  slice_ret.flash_match.pe = fmatch.TriggerType();
958  std::cout << "Match time: " << slice_ret.flash_match.time << std::endl;
959  std::cout << "Match score: " << slice_ret.flash_match.score << std::endl;
960  std::cout << "Match PE: " << slice_ret.flash_match.pe << std::endl;
961  }
962  else {
963  slice_ret.flash_match.present = false;
964  std::cout << "No match :(\n";
965  }
966 
967  // throw away slices which do not have a primary track candidate
968  if (!HasPrimaryTrack(reco_tracks, slice_ret)) continue;
969 
970  // First guess of primary track
971  slice_ret.primary_track_index = numu::SelectLongestTrack(reco_tracks, slice_ret);
972  assert(slice_ret.primary_track_index >= 0);
973 
974  // if we didn't do the cosmic ID for all tracks, do it for all priamry track candidates
975  if (!_config.CosmicIDAllTracks) {
976  const numu::RecoParticle &neutrino = slice_ret.particles.at(slice_ret.primary_index);
977  for (size_t ind: neutrino.daughters) {
978  const numu::RecoParticle &daughter = slice_ret.particles.at(ind);
979  if (reco_tracks.count(daughter.ID)) {
980  ApplyCosmicID(reco_tracks.at(daughter.ID));
981  }
982  }
983  }
984 
985  ret.push_back(std::move(slice_ret));
986  }
987 
988  return ret;
989 }
std::vector< art::Ptr< recob::PFParticle > > _tpc_particles
Definition: NumuReco.h:363
const unsigned int & TriggerType() const
Definition: T0.h:45
const double & Time() const
Definition: T0.h:44
int primary_track_index
Index of the primary track.
Definition: RecoEvent.h:27
unsigned pe
number of photo electons in flash
Definition: T0.h:16
size_t ID
ID of particle.
Definition: RecoParticle.h:18
std::vector< size_t > daughters
Daughters of the particle in the &quot;particle flow&quot;. Value represents index into pandora information...
Definition: RecoParticle.h:17
std::vector< size_t > RecoSliceTracks(const std::map< size_t, numu::RecoTrack > &tracks, const std::map< size_t, numu::RecoParticle > &particles)
Definition: NumuReco.cxx:769
FlashMatch flash_match
Result of flash matching algorithm on this slice.
Definition: RecoEvent.h:30
bool HasPrimaryTrack(const std::map< size_t, numu::RecoTrack > &tracks, const numu::RecoSlice &slice)
Definition: NumuReco.cxx:839
bool SelectSlice(const numu::RecoSlice &slice)
Definition: NumuReco.cxx:860
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
std::vector< std::vector< art::Ptr< recob::PFParticle > > > _tpc_slices_to_particles
Definition: NumuReco.h:364
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch fmatch
Definition: reco_sbnd.fcl:182
std::vector< std::vector< art::Ptr< anab::T0 > > > _tpc_particles_to_flashT0
Definition: NumuReco.h:376
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
int SelectLongestTrack(const std::map< size_t, RecoTrack > &tracks, const RecoSlice &slice)
Definition: PrimaryTrack.cc:3
const double & TriggerConfidence() const
Definition: T0.h:48
Config _config
The config.
Definition: NumuReco.h:332
std::map< size_t, RecoParticle > particles
Map of particle index to particle information.
Definition: RecoEvent.h:28
std::vector< size_t > tracks
List of track indices contained in this slice.
Definition: RecoEvent.h:29
int primary_index
Index of the primary particle of this slice.
Definition: RecoEvent.h:25
std::vector< std::vector< unsigned > > _tpc_slices_to_particle_index
Definition: NumuReco.h:365
BEGIN_PROLOG could also be cout
void ApplyCosmicID(numu::RecoTrack &track)
Definition: NumuReco.cxx:754
std::vector< art::Ptr< recob::Slice > > _tpc_slices
Definition: NumuReco.h:361
std::vector< size_t > ana::SBNOsc::NumuReco::RecoSliceTracks ( const std::map< size_t, numu::RecoTrack > &  tracks,
const std::map< size_t, numu::RecoParticle > &  particles 
)
protected

Return the list of tracks associated with a neutrino interaction candidate.

Parameters
tracksThe list of all reconstructed tracks in the event
particlesThe list of reconstructed particles associated with this neutrino interaction canidate
Returns
The list of track IDs associated with this slice

Definition at line 769 of file NumuReco.cxx.

771  {
772 
773  std::vector<size_t> ret;
774 
775  for (const auto &particle_pair: particles) {
776  if (tracks.count(particle_pair.first)) {
777  ret.push_back(particle_pair.first);
778  }
779  }
780 
781  return ret;
782 }
std::map< size_t, numu::RecoTrack > ana::SBNOsc::NumuReco::RecoTrackInfo ( )
protected

Gathers a map of track ID's to RecoTrack objects. This ID may not be the same as the pandora ID.

Returns
Map of track ID's to track objects

Definition at line 621 of file NumuReco.cxx.

621  {
622  std::map<size_t, numu::RecoTrack> ret;
623  for (unsigned pfp_track_index = 0; pfp_track_index < _tpc_tracks.size(); pfp_track_index++) {
624  const art::Ptr<recob::Track> &track = _tpc_tracks[pfp_track_index];
625 
626  // information to be saved
627  numu::RecoTrack this_track;
628 
629  // Use the particle ID as a global ID
630  this_track.ID = _tpc_tracks_to_particle_index.at(pfp_track_index);
631 
632  // track length
633  this_track.length = track->Length();
634 
635  // get the associated PID and Calo
636  assert(_tpc_tracks_to_pid.at(pfp_track_index).size() == 3); //one per plane
637 
638  // sum up all the pid scores weighted by n dof
639  double chi2_proton = 0.;
640  double chi2_kaon = 0.;
641  double chi2_muon = 0.;
642  double chi2_pion = 0.;
643  int n_dof = 0;
644  int particle_pdg = 0;
645  double min_chi2 = 0.;
646  for (int i =0; i < 3; i++) {
647  // invalid plane means invalid calorimetry
648  if (!_tpc_tracks_to_pid.at(pfp_track_index).at(i)->PlaneID()) continue;
649  const art::Ptr<anab::ParticleID> &particle_id = _tpc_tracks_to_pid.at(pfp_track_index).at(i);
650  // only use particle ID on collection plane
651  if (fProviderManager->GetGeometryProvider()->SignalType(particle_id->PlaneID()) == geo::kCollection) {
652  n_dof += particle_id->Ndf();
653  chi2_proton += particle_id->Chi2Proton() * particle_id->Ndf();
654  chi2_kaon += particle_id->Chi2Kaon() * particle_id->Ndf();
655  chi2_pion += particle_id->Chi2Pion() * particle_id->Ndf();
656  chi2_muon += particle_id->Chi2Muon() * particle_id->Ndf();
657  }
658  }
659  if (n_dof > 0) {
660  /*
661  chi2_proton /= n_dof;
662  chi2_kaon /= n_dof;
663  chi2_pion /= n_dof;
664  chi2_muon /= n_dof;*/
665  // min chi2 is PID
666  std::vector<double> chi2s {chi2_proton, chi2_muon, chi2_kaon, chi2_pion};
667  int min_ind = std::distance(chi2s.begin(), std::min_element(chi2s.begin(), chi2s.end()));
668  min_chi2 = *std::min_element(chi2s.begin(), chi2s.end());
669  if (min_ind == 0) {
670  particle_pdg = 2212;
671  }
672  else if (min_ind == 1) {
673  particle_pdg = 13;
674  }
675  else if (min_ind == 2) {
676  particle_pdg = 312;
677  }
678  else if (min_ind == 3) {
679  particle_pdg = 211;
680  }
681  else {
682  assert(false);
683  }
684  }
685  else {
686  // No particle ID was provided -- set things to nonsense
687  chi2_proton = -1;
688  chi2_kaon = -1;
689  chi2_muon = -1;
690  chi2_pion = -1;
691  min_chi2 = -1.5;
692  }
693  this_track.pdgid = particle_pdg;
694  this_track.chi2_proton = chi2_proton;
695  this_track.chi2_kaon = chi2_kaon;
696  this_track.chi2_pion = chi2_pion;
697  this_track.chi2_muon = chi2_muon;
698  this_track.min_chi2 = min_chi2;
699  this_track.pid_n_dof = n_dof;
700 
701  // TODO: add in calo stuff??
702  assert(_tpc_tracks_to_calo.at(pfp_track_index).size() == 3);
703 
704  // calculator only has inputs for protons and muons
707 
708  recob::MCSFitResult mcs_fit_muon = _mcs_fitter->fitMcs(*track, 13);
709  this_track.mcs_muon.fwd_mcs_momentum = mcs_fit_muon.fwdMomentum();
710  this_track.mcs_muon.fwd_mcs_momentum_err = mcs_fit_muon.fwdMomUncertainty();
711  this_track.mcs_muon.bwd_mcs_momentum = mcs_fit_muon.bwdMomentum();
712  this_track.mcs_muon.bwd_mcs_momentum_err = mcs_fit_muon.bwdMomUncertainty();
713 
714  recob::MCSFitResult mcs_fit_pion = _mcs_fitter->fitMcs(*track, 211);
715  this_track.mcs_pion.fwd_mcs_momentum = mcs_fit_pion.fwdMomentum();
716  this_track.mcs_pion.fwd_mcs_momentum_err = mcs_fit_pion.fwdMomUncertainty();
717  this_track.mcs_pion.bwd_mcs_momentum = mcs_fit_pion.bwdMomentum();
718  this_track.mcs_pion.bwd_mcs_momentum_err = mcs_fit_pion.bwdMomUncertainty();
719 
720  recob::MCSFitResult mcs_fit_proton = _mcs_fitter->fitMcs(*track, 2212);
721  this_track.mcs_proton.fwd_mcs_momentum = mcs_fit_proton.fwdMomentum();
722  this_track.mcs_proton.fwd_mcs_momentum_err = mcs_fit_proton.fwdMomUncertainty();
723  this_track.mcs_proton.bwd_mcs_momentum = mcs_fit_proton.bwdMomentum();
724  this_track.mcs_proton.bwd_mcs_momentum_err = mcs_fit_proton.bwdMomUncertainty();
725 
726  recob::MCSFitResult mcs_fit_kaon = _mcs_fitter->fitMcs(*track, 321);
727  this_track.mcs_kaon.fwd_mcs_momentum = mcs_fit_kaon.fwdMomentum();
728  this_track.mcs_kaon.fwd_mcs_momentum_err = mcs_fit_kaon.fwdMomUncertainty();
729  this_track.mcs_kaon.bwd_mcs_momentum = mcs_fit_kaon.bwdMomentum();
730  this_track.mcs_kaon.bwd_mcs_momentum_err = mcs_fit_kaon.bwdMomUncertainty();
731 
732  this_track.costh = track->StartDirection().Z() / sqrt( track->StartDirection().Mag2() );
733 
734  // get track topology
735  std::array<bool, 4> topology = RecoTrackTopology(track);
736  this_track.crosses_tpc = topology[2];
737 
738  this_track.start = TVector3(track->Start().X(), track->Start().Y(), track->Start().Z());
739  this_track.end = TVector3(track->End().X(), track->End().Y(), track->End().Z());
740 
741  // do truth matching
742  this_track.match = MatchTrack2Truth(pfp_track_index);
743 
744  // if configured, apply Cosmic ID to all tracks
746  ApplyCosmicID(this_track);
747  }
748 
749  ret[this_track.ID] = this_track;
750  }
751  return ret;
752 }
int pdgid
Particle ID that minimizes chi2.
Definition: RecoTrack.h:46
float chi2_muon
Chi2 of dE/dx to muon hypotheis. Combined agaisnt all planes.
Definition: RecoTrack.h:43
float chi2_kaon
Chi2 of dE/dx to kaon hypotheis. Combined against all planes.
Definition: RecoTrack.h:41
numu::TrackTruthMatch MatchTrack2Truth(size_t track_id)
Definition: NumuReco.cxx:866
float bwd_mcs_momentum_err
MCS momentum calculation fit error under hypothesis track is backward.
Definition: RecoTrack.h:17
MCSFitResult mcs_proton
MCS calculation result for Proton PID hypothesis.
Definition: RecoTrack.h:37
MCSFitResult mcs_pion
MCS calculation result for Pion PID hypothesis.
Definition: RecoTrack.h:36
std::vector< unsigned > _tpc_tracks_to_particle_index
Definition: NumuReco.h:367
float bwdMomentum() const
momentum value from fit assuming a backward track direction
Definition: MCSFitResult.h:38
float min_chi2
Minimum chi2 value across all hypotheses.
Definition: RecoTrack.h:44
float fwdMomUncertainty() const
momentum uncertainty from fit assuming a forward track direction
Definition: MCSFitResult.h:32
std::vector< art::Ptr< recob::Track > > _tpc_tracks
Definition: NumuReco.h:362
process_name use argoneut_mc_hitfinder track
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
const geo::GeometryCore * GetGeometryProvider() const
trkf::TrackMomentumCalculator * _track_momentum_calculator
Calculator for range-based track momentum.
Definition: NumuReco.h:335
float bwd_mcs_momentum
MCS momentum calculation under hypothesis track is backward.
Definition: RecoTrack.h:16
std::vector< std::vector< art::Ptr< anab::Calorimetry > > > _tpc_tracks_to_calo
Definition: NumuReco.h:369
MCSFitResult mcs_kaon
MCS calculation result for Kaon PID hypothesis.
Definition: RecoTrack.h:38
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
TVector3 start
start position of track
Definition: RecoTrack.h:54
float range_momentum_muon
Range momentum calculation of the track using range under the assumption it is a muon [GeV]...
Definition: RecoTrack.h:33
float chi2_pion
Chi2 of dE/dx to pion hypotheis. Combined against all planes.
Definition: RecoTrack.h:42
float length
Length of track.
Definition: RecoTrack.h:48
float fwd_mcs_momentum
MCS momentum calculation under hypothesis track is forward.
Definition: RecoTrack.h:14
bool crosses_tpc
does it cross a tpc?
Definition: RecoTrack.h:51
Class storing the result of the Maximum Likelihood fit of Multiple Coulomb Scattering angles between ...
Definition: MCSFitResult.h:19
std::vector< std::vector< art::Ptr< anab::ParticleID > > > _tpc_tracks_to_pid
Definition: NumuReco.h:370
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
float bwdMomUncertainty() const
momentum uncertainty from fit assuming a backward track direction
Definition: MCSFitResult.h:41
int pid_n_dof
Number of d.o.f. in chi2 fit.
Definition: RecoTrack.h:45
trkf::TrajectoryMCSFitter * _mcs_fitter
Calculator for MCS based momentum.
Definition: NumuReco.h:336
Config _config
The config.
Definition: NumuReco.h:332
ProviderManager * fProviderManager
Interface for provider access.
float range_momentum_proton
Range momentum calculation of track using range using the assumption it is a proton [GeV]...
Definition: RecoTrack.h:34
TVector3 end
end position of track
Definition: RecoTrack.h:55
std::array< bool, 4 > RecoTrackTopology(const art::Ptr< recob::Track > &track)
Definition: NumuReco.cxx:549
float fwdMomentum() const
momentum value from fit assuming a forward track direction
Definition: MCSFitResult.h:29
MCSFitResult mcs_muon
MCS calculation result for Muon PID hypothesis.
Definition: RecoTrack.h:35
int ID
ID/index of this track. Does not necessarily correspond to the Pandora index.
Definition: RecoTrack.h:61
float fwd_mcs_momentum_err
MCS momentum calculation fit error under hypothesis track is forward.
Definition: RecoTrack.h:15
double GetTrackMomentum(double trkrange, int pdg) const
float costh
cosine of angle to z axis
Definition: RecoTrack.h:49
void ApplyCosmicID(numu::RecoTrack &track)
Definition: NumuReco.cxx:754
Signal from collection planes.
Definition: geo_types.h:146
float chi2_proton
Chi2 of dE/dx to proton hypothesis. Combined against all planes.
Definition: RecoTrack.h:40
std::array< bool, 4 > ana::SBNOsc::NumuReco::RecoTrackTopology ( const art::Ptr< recob::Track > &  track)
protected

Calculate some topology factoids about a reconstructed track

Parameters
trackThe pointer to LArSoft track information
Returns
A list of bools associated with track topology. See the code for what is what.

Definition at line 549 of file NumuReco.cxx.

549  {
550  // returned info
551  bool contained_in_cryo = true;
552  bool contained_in_tpc = true;
553  bool crosses_tpc = false;
554 
555  bool is_contained = true;
556 
557  // start point
558  geo::Point_t start = track->Start();
559  // get the active volume that the start position is in
560  int cryostat_index = -1;
561  int tpc_index = -1;
562  int containment_index = -1;
563  for (int i = 0; i < _config.containment_volumes.size(); i++) {
564  if (_config.containment_volumes[i].ContainsPosition(start)) {
565  containment_index = i;
566  }
567  break;
568  }
569  for (int i = 0; i < _config.active_volumes.size(); i++) {
570  if (_config.active_volumes[i].ContainsPosition(start)) {
571  cryostat_index = i;
572  break;
573  }
574  }
575  if (containment_index < 0) {
576  is_contained = false;
577  }
578  std::vector<geo::BoxBoundedGeo> volumes;
579  if (cryostat_index >= 0) {
580  volumes = _config.tpc_volumes[cryostat_index];
581  for (int i = 0; i < volumes.size(); i++) {
582  if (volumes[i].ContainsPosition(start)) {
583  tpc_index = i;
584  break;
585  }
586  }
587  }
588  else {
589  contained_in_cryo = false;
590  }
591  if (tpc_index < 0) {
592  contained_in_tpc = false;
593  }
594 
595  // now check for all track points
596  for (int i = 1; i < track->CountValidPoints(); i++) {
597  geo::Point_t this_point = track->LocationAtPoint(i);
598  if (is_contained) {
599  is_contained = _config.containment_volumes[containment_index].ContainsPosition(this_point);
600  }
601  if (contained_in_cryo) {
602  contained_in_cryo = _config.active_volumes[cryostat_index].ContainsPosition(this_point);
603  }
604  if (contained_in_cryo && !crosses_tpc) {
605  for (int j = 0; j < volumes.size(); j++) {
606  if (volumes[j].ContainsPosition(this_point) && j != tpc_index) {
607  crosses_tpc = true;
608  break;
609  }
610  }
611  }
612  if (contained_in_tpc) {
613  contained_in_tpc = volumes[tpc_index].ContainsPosition(this_point);
614  }
615  }
616 
617  return {contained_in_cryo, contained_in_tpc, crosses_tpc, is_contained};
618 }
std::vector< std::vector< geo::BoxBoundedGeo > > tpc_volumes
List of active tpc volumes – retreived from Geoemtry service.
Definition: NumuReco.h:100
return track match has_match and!particle is_contained
Definition: selectors.fcl:108
process_name use argoneut_mc_hitfinder track
std::vector< geo::BoxBoundedGeo > containment_volumes
List of volumes for containment cuts – set by &quot;containment_volumes&quot;.
Definition: NumuReco.h:98
std::vector< geo::BoxBoundedGeo > active_volumes
List of active volumes per cryostat.
Definition: NumuReco.h:99
Config _config
The config.
Definition: NumuReco.h:332
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
numu::CRTHit ana::SBNOsc::NumuReco::SBND2numuCRTHit ( const sbn::crt::CRTHit hit)
protected

Definition at line 1305 of file NumuReco.cxx.

1305  {
1306  numu::CRTHit ret;
1307  if (_config.TSMode == 0) ret.time = (int)hit.ts0_ns / 1000. /* ns -> us */;
1308  else ret.time = (int)hit.ts1_ns / 1000. /* ns -> us */;
1310  ret.pes = hit.peshit;
1311  ret.location = TVector3(hit.x_pos, hit.y_pos, hit.z_pos);
1312  ret.uncertainty = TVector3(hit.x_err, hit.y_err, hit.z_err);
1313  return ret;
1314 }
float z_err
position uncertainty in z-direction (cm).
Definition: CRTHit.hh:43
float x_err
position uncertainty in x-direction (cm).
Definition: CRTHit.hh:39
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
Definition: CRTHit.hh:34
float peshit
Total photo-electron (PE) in a crt hit.
Definition: CRTHit.hh:27
float y_err
position uncertainty in y-direction (cm).
Definition: CRTHit.hh:41
TVector3 uncertainty
Uncertainty on the location of the hit.
Definition: DetInfo.h:17
TVector3 location
Location of the hit.
Definition: DetInfo.h:16
float z_pos
position in z-direction (cm).
Definition: CRTHit.hh:42
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
Definition: CRTHit.hh:32
float time
CRT Hit time.
Definition: DetInfo.h:13
float y_pos
position in y-direction (cm).
Definition: CRTHit.hh:40
float x_pos
position in x-direction (cm).
Definition: CRTHit.hh:38
float pes
Number of PE&#39;s in hit.
Definition: DetInfo.h:15
Config _config
The config.
Definition: NumuReco.h:332
bool ana::SBNOsc::NumuReco::SelectSlice ( const numu::RecoSlice slice)
protected

Returns whether this slice is designated as a neutrino interaction by Pandora

Parameters
sliceThe neutrino slice gathered from pandora information
Returns
Boolean which is true if the slice is a neutrino interaction

Definition at line 860 of file NumuReco.cxx.

860  {
861  return slice.primary_index >= 0 &&
862  slice.particles.at(slice.primary_index).p_is_neutrino &&
863  abs(slice.particles.at(slice.primary_index).pandora_pid) == 14;
864 }
T abs(T value)
std::map< size_t, RecoParticle > particles
Map of particle index to particle information.
Definition: RecoEvent.h:28
int primary_index
Index of the primary particle of this slice.
Definition: RecoEvent.h:25

Member Data Documentation

ApaCrossCosmicIdAlg ana::SBNOsc::NumuReco::_apa_cross_cosmic_alg
protected

Algorithm for doing cosmic ID by looking for tracks crossing APA.

Definition at line 344 of file NumuReco.h.

Config ana::SBNOsc::NumuReco::_config
protected

The config.

Definition at line 332 of file NumuReco.h.

CRTHistos ana::SBNOsc::NumuReco::_crt_histograms
protected

Definition at line 386 of file NumuReco.h.

sbnd::CRTT0MatchAlg* ana::SBNOsc::NumuReco::_crt_hit_matchalg
protected

Algorithm for matching reco Tracks -> CRT hits (T0's)

Definition at line 343 of file NumuReco.h.

const std::vector<sbn::crt::CRTHit>* ana::SBNOsc::NumuReco::_crt_hits
protected

Definition at line 352 of file NumuReco.h.

std::vector<sbn::crt::CRTHit> ana::SBNOsc::NumuReco::_crt_hits_local
protected

Definition at line 351 of file NumuReco.h.

sbnd::CRTTrackMatchAlg* ana::SBNOsc::NumuReco::_crt_track_matchalg
protected

Algorithm for matching reco Tracks -> CRT Tracks.

Definition at line 342 of file NumuReco.h.

const std::vector<sbn::crt::CRTTrack>* ana::SBNOsc::NumuReco::_crt_tracks
protected

Definition at line 349 of file NumuReco.h.

std::vector<sbn::crt::CRTTrack> ana::SBNOsc::NumuReco::_crt_tracks_local
protected

Definition at line 350 of file NumuReco.h.

TGraph* ana::SBNOsc::NumuReco::_cut_counts
protected

Keep track of neutrinos per cut.

Definition at line 330 of file NumuReco.h.

unsigned ana::SBNOsc::NumuReco::_event_counter
protected

Count processed events.

Definition at line 328 of file NumuReco.h.

bool ana::SBNOsc::NumuReco::_has_crt_hits
protected

Definition at line 353 of file NumuReco.h.

bool ana::SBNOsc::NumuReco::_has_crt_tracks
protected

Definition at line 354 of file NumuReco.h.

trkf::TrajectoryMCSFitter* ana::SBNOsc::NumuReco::_mcs_fitter
protected

Calculator for MCS based momentum.

Definition at line 336 of file NumuReco.h.

unsigned ana::SBNOsc::NumuReco::_nu_count
protected

Count selected events.

Definition at line 329 of file NumuReco.h.

opdet::opHitFinderSBND* ana::SBNOsc::NumuReco::_op_hit_maker
protected

Optical hit maker.

Definition at line 346 of file NumuReco.h.

std::vector<art::Ptr<recob::OpHit> > ana::SBNOsc::NumuReco::_op_hit_ptrs
protected

Definition at line 357 of file NumuReco.h.

std::vector<recob::OpHit> ana::SBNOsc::NumuReco::_op_hits_local
protected

Definition at line 358 of file NumuReco.h.

numu::RecoEvent ana::SBNOsc::NumuReco::_recoEvent
protected

Branch container for the RecoEvent.

Definition at line 339 of file NumuReco.h.

std::vector<numu::RecoInteraction>* ana::SBNOsc::NumuReco::_selected
protected

Branch container for the list of selected reco vertices.

Definition at line 340 of file NumuReco.h.

StoppingParticleCosmicIdAlg ana::SBNOsc::NumuReco::_stopping_cosmic_alg
protected

Algorithm for doing cosmic ID using a fit to the energy deposits.

Definition at line 345 of file NumuReco.h.

std::vector<art::Ptr<recob::PFParticle> > ana::SBNOsc::NumuReco::_tpc_particles
protected

Definition at line 363 of file NumuReco.h.

std::vector<std::vector<unsigned> > ana::SBNOsc::NumuReco::_tpc_particles_to_daughters
protected

Definition at line 374 of file NumuReco.h.

std::vector<std::vector<art::Ptr<anab::T0> > > ana::SBNOsc::NumuReco::_tpc_particles_to_flashT0
protected

Definition at line 376 of file NumuReco.h.

std::vector<art::Ptr<larpandoraobj::PFParticleMetadata> > ana::SBNOsc::NumuReco::_tpc_particles_to_metadata
protected

Definition at line 375 of file NumuReco.h.

std::vector<std::vector<art::Ptr<anab::T0> > > ana::SBNOsc::NumuReco::_tpc_particles_to_T0
protected

Definition at line 372 of file NumuReco.h.

std::map<unsigned, unsigned> ana::SBNOsc::NumuReco::_tpc_particles_to_track_index
protected

Definition at line 368 of file NumuReco.h.

std::vector<std::vector<art::Ptr<recob::Vertex> > > ana::SBNOsc::NumuReco::_tpc_particles_to_vertex
protected

Definition at line 373 of file NumuReco.h.

std::vector<art::Ptr<recob::Slice> > ana::SBNOsc::NumuReco::_tpc_slices
protected

Definition at line 361 of file NumuReco.h.

std::vector<std::vector<unsigned> > ana::SBNOsc::NumuReco::_tpc_slices_to_particle_index
protected

Definition at line 365 of file NumuReco.h.

std::vector<std::vector<art::Ptr<recob::PFParticle> > > ana::SBNOsc::NumuReco::_tpc_slices_to_particles
protected

Definition at line 364 of file NumuReco.h.

std::vector<art::Ptr<recob::Track> > ana::SBNOsc::NumuReco::_tpc_tracks
protected

Definition at line 362 of file NumuReco.h.

std::vector<std::vector<art::Ptr<anab::Calorimetry> > > ana::SBNOsc::NumuReco::_tpc_tracks_to_calo
protected

Definition at line 369 of file NumuReco.h.

std::vector<std::vector<art::Ptr<recob::Hit> > > ana::SBNOsc::NumuReco::_tpc_tracks_to_hits
protected

Definition at line 371 of file NumuReco.h.

std::vector<unsigned> ana::SBNOsc::NumuReco::_tpc_tracks_to_particle_index
protected

Definition at line 367 of file NumuReco.h.

std::vector<art::Ptr<recob::PFParticle> > ana::SBNOsc::NumuReco::_tpc_tracks_to_particles
protected

Definition at line 366 of file NumuReco.h.

std::vector<std::vector<art::Ptr<anab::ParticleID> > > ana::SBNOsc::NumuReco::_tpc_tracks_to_pid
protected

Definition at line 370 of file NumuReco.h.

trkf::TrackMomentumCalculator* ana::SBNOsc::NumuReco::_track_momentum_calculator
protected

Calculator for range-based track momentum.

Definition at line 335 of file NumuReco.h.

std::vector<art::Ptr<simb::MCParticle> > ana::SBNOsc::NumuReco::_true_particles
protected

Definition at line 379 of file NumuReco.h.

std::map<int, const sim::GeneratedParticleInfo *> ana::SBNOsc::NumuReco::_true_particles_to_generator_info
protected

Definition at line 381 of file NumuReco.h.

std::map<int, art::Ptr<simb::MCTruth> > ana::SBNOsc::NumuReco::_true_particles_to_truth
protected

Definition at line 380 of file NumuReco.h.

numu::MCType ana::SBNOsc::NumuReco::fType
protected

Definition at line 384 of file NumuReco.h.


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