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

#include <Selection.h>

Inheritance diagram for ana::SBNOsc::Selection:
core::PostProcessorBase

Public Member Functions

void FileCleanup (TTree *eventTree)
 
void FileSetup (TFile *f, TTree *eventTree)
 
void Initialize (fhicl::ParameterSet *config)
 
void ProcessEvent (const event::Event *event)
 
void ProcessSubRun (const SubRun *subrun)
 
void ProcessFileMeta (const FileMeta *meta)
 
void Finalize ()
 
- Public Member Functions inherited from core::PostProcessorBase
 PostProcessorBase ()
 
virtual ~PostProcessorBase ()
 
void Run (std::vector< std::string > filelist)
 
void Initialize (char *config=NULL, const std::string &output_fname="", unsigned n_workers=1)
 

Private Attributes

sbnd::CRTGeoAlgfCRTGeo
 
Cuts fCuts
 
ROC fROC
 
Histograms fHistograms
 
Histograms fCosmicHistograms
 
HistogramsfHistsToFill
 
CRTHistos fCRTCosmicHistos
 
CRTHistos fCRTNeutrinoHistos
 
Normalize fNormalize
 
fhicl::ParameterSet fCutConfig
 
double fCRTHitDistance
 
bool fDoNormalize
 
bool fFillAllTracks
 
double fGoalPOT
 
double fNCosmicData
 
std::vector< numu::TrackSelectorfTrackSelectors
 
std::vector< std::string > fTrackSelectorNames
 
std::vector< numu::TrackFunctionfTrackProfileValues
 
numu::RecoEventfRecoEvent
 
TFile * fOutputFile
 
std::string fHistogramPostfix
 
bool fUseCalorimetry
 
int fFileIndex
 
numu::MCType fFileType
 

Additional Inherited Members

- Protected Member Functions inherited from core::PostProcessorBase
virtual void InitializeThread ()
 
unsigned NWorkers ()
 
unsigned WorkerID ()
 
- Protected Attributes inherited from core::PostProcessorBase
ProviderManagerfProviderManager
 Interface for provider access. More...
 
int fConfigExperimentID
 

Detailed Description

Definition at line 42 of file Selection.h.

Member Function Documentation

void ana::SBNOsc::Selection::FileCleanup ( TTree *  eventTree)
inlinevirtual

Any cleanup needed per file

Parameters
eventTreethe TTree associated with the sbncode event.

Reimplemented from core::PostProcessorBase.

Definition at line 45 of file Selection.h.

45 {}
void ana::SBNOsc::Selection::FileSetup ( TFile *  f,
TTree *  eventTree 
)
virtual

Setup anything needed per file

Parameters
fthe TFile being opened
eventTreethe TTree associated with the sbncode event. Use this TTree to set branch addresses for everything other than the sbncode event.

Files are guaranteed to be processed in the order they are specified on the command line for sbn-postprocess

Reimplemented from core::PostProcessorBase.

Definition at line 88 of file Selection.cc.

88  {
89  eventTree->SetBranchAddress("reco_event", &fRecoEvent);
91  TParameter<int> *file_type = (TParameter<int> *)f->Get("MCType");
92  fFileType = (numu::MCType) file_type->GetVal();
93 
94  if (fDoNormalize) {
97  }
98  else if (fFileType == numu::fOverlay) {
100  }
101  else assert(false);
102  }
103  else {
105  }
106  fFileIndex += 1;
107 
108  CRTHistos crt_from_file;
109  crt_from_file.Get(*f, "_all");
111  fCRTCosmicHistos.Add(crt_from_file);
112  }
113  else if (fFileType == numu::fOverlay) {
114  fCRTNeutrinoHistos.Add(crt_from_file);
115  }
116  }
CRTHistos fCRTCosmicHistos
Definition: Selection.h:61
Histograms fCosmicHistograms
Definition: Selection.h:58
Histograms fHistograms
Definition: Selection.h:57
Histograms * fHistsToFill
Definition: Selection.h:59
CRTHistos fCRTNeutrinoHistos
Definition: Selection.h:62
const geo::GeometryCore * GetGeometryProvider() const
numu::MCType fFileType
Definition: Selection.h:83
void Add(const HistoList &other)
Definition: HistoList.cc:25
fhicl::ParameterSet fCutConfig
Definition: Selection.h:65
MCType
Definition: MCType.h:5
ProviderManager * fProviderManager
Interface for provider access.
void Initialize(const fhicl::ParameterSet &cfg, const geo::GeometryCore *geometry)
Definition: Cuts.cc:10
numu::RecoEvent * fRecoEvent
Definition: Selection.h:77
void ana::SBNOsc::Selection::Finalize ( )
virtual

Perform user-level finalization. Called after all events have been processed.

Reimplemented from core::PostProcessorBase.

Definition at line 168 of file Selection.cc.

168  {
169  fOutputFile->cd();
170  std::cout << "Finalizing!\n";
171  if (fDoNormalize) {
172  std::cout << "Normalizing!\n";
173  // save scale per 1e20 POT
174  TParameter<float> scale_neutrino("ScaleNeutrino", fNormalize.ScaleNeutrino(1.e20));
175  TParameter<float> scale_cosmic("ScaleCosmic", fNormalize.ScaleCosmic(1.e20));
176  scale_neutrino.Write();
177  scale_cosmic.Write();
178  std::cout << "Scale Neutrino: " << fNormalize.ScaleNeutrino(1.e20) << std::endl;
179  std::cout << "Scale Cosmic: " << fNormalize.ScaleCosmic(1.e20) << std::endl;
180 
183 
186 
189  }
190  fROC.BestCuts();
191  fROC.Write();
192  fHistograms.Write();
195 
196  }
double ScaleCosmic(double goal_pot) const
Definition: Normalize.cc:34
CRTHistos fCRTCosmicHistos
Definition: Selection.h:61
Histograms fCosmicHistograms
Definition: Selection.h:58
Histograms fHistograms
Definition: Selection.h:57
void Scale(double scale)
Definition: HistoList.cc:16
CRTHistos fCRTNeutrinoHistos
Definition: Selection.h:62
void Write() const
Definition: ROC.cc:12
Normalize fNormalize
Definition: Selection.h:64
void Normalize(float neutrino_scale, float cosmic_scale)
Definition: ROC.cc:18
void Add(const HistoList &other)
Definition: HistoList.cc:25
void BestCuts() const
Definition: ROC.cc:24
double ScaleNeutrino(double goal_pot) const
Definition: Normalize.cc:62
BEGIN_PROLOG could also be cout
void ana::SBNOsc::Selection::Initialize ( fhicl::ParameterSet *  config)
virtual

Perform user-level initialization.

Parameters
configA configuration, as a JSON object.

Implements core::PostProcessorBase.

Definition at line 32 of file Selection.cc.

32  {
33  std::cout << "Input Configuration:\n";
34  std::cout << config->to_indented_string() << std::endl;
35  fOutputFile = new TFile(config->get<std::string>("OutputFile", "output.root").c_str(), "CREATE");
36  fOutputFile->cd();
37  fCRTHitDistance = config->get<double>("CRTHitDistance", -1);
38 
39  fFileIndex = 0;
40 
41  fCutConfig = config->get<fhicl::ParameterSet>("Cuts");
42 
43  fDoNormalize = config->get<bool>("DoNormalize", false);
44  fGoalPOT = config->get<double>("GoalPOT", 0.);
45  fFillAllTracks = config->get<bool>("FillAllTracks", true);
46 
47  fUseCalorimetry = config->get<bool>("UseCalorimetry", true);
48 
49  fHistogramPostfix = config->get<std::string>("HistogramPostfix", "");
50 
51  std::vector<std::vector<std::string>> track_selector_strings = config->get<std::vector<std::vector<std::string>>>("TrackSelectors", {{""}});
52  std::vector<std::vector<std::string>> track_selector_names = config->get<std::vector<std::vector<std::string>>>("TrackSelectorNames", {{""}});
53 
54  assert(track_selector_strings.size() == track_selector_names.size());
55 
56  fTrackSelectorNames = numu::MultiplyNames(track_selector_names, '/');
57  fTrackSelectors = numu::MultiplyTrackSelectors(track_selector_strings);
58 
59  assert(fTrackSelectorNames.size() == fTrackSelectors.size());
60 
61  std::vector<std::string> track_profile_values = config->get<std::vector<std::string>>("TrackProfileValues", {});
62  for (const std::string &source: track_profile_values) {
63  fTrackProfileValues.push_back(uscript::compile<numu::RecoTrack, numu::TrueParticle, unsigned>("track", "particle", "mctype", source.c_str()));
64  }
65 
66  std::vector<std::string> track_profile_value_names = config->get<std::vector<std::string>>("TrackProfileValueNames", {});
67  std::vector<std::tuple<unsigned, float, float>> track_profile_xranges = config->get<std::vector<std::tuple<unsigned, float, float>>>("TrackProfileXRanges", {});
68 
69  assert(track_profile_value_names.size() == track_profile_xranges.size());
70  assert(fTrackProfileValues.size() == track_profile_xranges.size());
71 
72  if (fDoNormalize) {
73  fNormalize.Initialize(config->get<fhicl::ParameterSet>("Normalize", {}));
74  }
75  fROC.Initialize();
76  fRecoEvent = NULL;
77 
79 
81 
82  if (fDoNormalize) {
83  fCosmicHistograms.Initialize(fProviderManager->GetGeometryProvider(), *fCRTGeo, fCuts, "Cosmic", fTrackSelectorNames, track_profile_value_names, track_profile_xranges);
84  }
85  fHistograms.Initialize(fProviderManager->GetGeometryProvider(), *fCRTGeo, fCuts, fHistogramPostfix, fTrackSelectorNames, track_profile_value_names, track_profile_xranges);
86  }
std::vector< numu::TrackSelector > fTrackSelectors
Definition: Selection.h:72
Histograms fCosmicHistograms
Definition: Selection.h:58
Histograms fHistograms
Definition: Selection.h:57
do source
const geo::AuxDetGeometryCore * GetAuxDetGeometryProvider() const
Normalize fNormalize
Definition: Selection.h:64
const geo::GeometryCore * GetGeometryProvider() const
std::vector< TrackSelector > MultiplyTrackSelectors(const std::vector< std::vector< std::string >> &track_function_strings)
std::vector< std::string > fTrackSelectorNames
Definition: Selection.h:73
void Initialize(const geo::GeometryCore *geometry, const sbnd::CRTGeoAlg &crt_geo, const Cuts &cuts, const std::string &prefix, const std::vector< std::string > &track_histo_types, const std::vector< std::string > &track_profile_types, const std::vector< std::tuple< unsigned, float, float >> &track_profile_xranges)
Definition: Histograms.cc:111
fhicl::ParameterSet fCutConfig
Definition: Selection.h:65
sbnd::CRTGeoAlg * fCRTGeo
Definition: Selection.h:54
std::string fHistogramPostfix
Definition: Selection.h:80
ProviderManager * fProviderManager
Interface for provider access.
void Initialize(const fhicl::ParameterSet &fcl)
Definition: Normalize.cc:5
void Initialize(const fhicl::ParameterSet &cfg, const geo::GeometryCore *geometry)
Definition: Cuts.cc:10
numu::RecoEvent * fRecoEvent
Definition: Selection.h:77
std::vector< numu::TrackFunction > fTrackProfileValues
Definition: Selection.h:75
std::vector< std::string > MultiplyNames(const std::vector< std::vector< std::string >> &strings, char join='_')
BEGIN_PROLOG could also be cout
void Initialize()
Definition: ROC.cc:5
void ana::SBNOsc::Selection::ProcessEvent ( const event::Event event)
virtual

Process one event.

Parameters
eventThe sbncode event for the current event

Implements core::PostProcessorBase.

Definition at line 130 of file Selection.cc.

130  {
131  std::cout << "Event: " << core_event->metadata.eventID << std::endl;
132 
133  // set stuff in the event
135 
136  for (const numu::RecoInteraction &reco: fRecoEvent->reco) {
137  std::cout << "Event type: " << Histograms::mode2Str(reco.match.mode) << std::endl;
138  const std::vector<size_t> &tracks = reco.slice.tracks;
139  for (size_t ind: tracks) {
140  const numu::RecoTrack &track = fRecoEvent->tracks.at(ind);
141  const numu::RecoParticle &t_particle = reco.slice.particles.at(ind);
142  std::cout << "Reco track: ";
143  std::cout << "length: " << track.length << " PID: " << track.match.match_pdg << " Chi2 m: " << track.chi2_muon << " Chi2 p: " << track.chi2_proton << " n daughter: " << t_particle.daughters.size() << std::endl;
144  for (size_t d_ind: t_particle.daughters) {
145  if (fRecoEvent->tracks.count(d_ind)) {
146  std::cout << "Daughter track: ";
147  const numu::RecoTrack &d_track = fRecoEvent->tracks.at(ind);
148  const numu::RecoParticle &d_t_particle = reco.slice.particles.at(ind);
149  std::cout << "length: " << d_track.length << " PID: " << d_track.match.match_pdg << " Chi2 m: " << d_track.chi2_muon << " Chi2 p: " << d_track.chi2_proton <<" n daughter: " << d_t_particle.daughters.size() << std::endl;
150  }
151  else {
152  std::cout << "Shower Daughter\n";
153  }
154  }
155  }
156  }
157 
160 
161  if (fDoNormalize) {
163  else fNormalize.AddNeutrinoEvent(*core_event);
164  }
165 
166  }
InteractionMode mode
Mode of the interaction.
float chi2_muon
Chi2 of dE/dx to muon hypotheis. Combined agaisnt all planes.
Definition: RecoTrack.h:43
ClusterModuleLabel join with tracks
std::vector< numu::TrackSelector > fTrackSelectors
Definition: Selection.h:72
static std::string mode2Str(const numu::InteractionMode &mode)
Definition: Histograms.h:78
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
void AddNeutrinoEvent(const event::Event &event)
Definition: Normalize.cc:25
Histograms * fHistsToFill
Definition: Selection.h:59
process_name use argoneut_mc_hitfinder track
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
Normalize fNormalize
Definition: Selection.h:64
void AddCosmicEvent(const event::Event &event)
Definition: Normalize.cc:23
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
process_name standard_reco_uboone reco
std::map< size_t, RecoTrack > tracks
Map of track indices to Track information.
Definition: RecoEvent.h:48
void Fill(const numu::RecoEvent &event, const event::Event &core, const Cuts &cutmaker, const std::vector< numu::TrackSelector > &selectors, const std::vector< numu::TrackFunction > &xfunctions, bool fill_all_tracks=true)
Definition: Histograms.cc:14
float length
Length of track.
Definition: RecoTrack.h:48
void Fill(const Cuts &cuts, const numu::RecoEvent &event, bool file_is_neutrino)
Definition: ROC.cc:30
numu::MCType fFileType
Definition: Selection.h:83
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
RecoSlice slice
Particle content of the interaction.
Definition: RecoEvent.h:39
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
void SetEvent(numu::RecoEvent &event, const event::Event &core, const ana::SBNOsc::Cuts &cuts, numu::MCType file_type, bool use_calorimetry=true)
Definition: SetEvent.cc:5
int match_pdg
PDG of the MCParticle this track matches to.
numu::RecoEvent * fRecoEvent
Definition: Selection.h:77
std::vector< numu::TrackFunction > fTrackProfileValues
Definition: Selection.h:75
BEGIN_PROLOG could also be cout
float chi2_proton
Chi2 of dE/dx to proton hypothesis. Combined against all planes.
Definition: RecoTrack.h:40
void ana::SBNOsc::Selection::ProcessFileMeta ( const FileMeta meta)
virtual

Reimplemented from core::PostProcessorBase.

Definition at line 124 of file Selection.cc.

124  {
126  fNormalize.AddCosmicFile(*meta);
127  }
128  }
Normalize fNormalize
Definition: Selection.h:64
numu::MCType fFileType
Definition: Selection.h:83
void AddCosmicFile(const FileMeta &meta)
Definition: Normalize.cc:19
void ana::SBNOsc::Selection::ProcessSubRun ( const SubRun subrun)
virtual

Reimplemented from core::PostProcessorBase.

Definition at line 118 of file Selection.cc.

118  {
120  fNormalize.AddNeutrinoSubRun(*subrun);
121  }
122  }
Normalize fNormalize
Definition: Selection.h:64
numu::MCType fFileType
Definition: Selection.h:83
void AddNeutrinoSubRun(const SubRun &subrun)
Definition: Normalize.cc:29

Member Data Documentation

Histograms ana::SBNOsc::Selection::fCosmicHistograms
private

Definition at line 58 of file Selection.h.

CRTHistos ana::SBNOsc::Selection::fCRTCosmicHistos
private

Definition at line 61 of file Selection.h.

sbnd::CRTGeoAlg* ana::SBNOsc::Selection::fCRTGeo
private

Definition at line 54 of file Selection.h.

double ana::SBNOsc::Selection::fCRTHitDistance
private

Definition at line 66 of file Selection.h.

CRTHistos ana::SBNOsc::Selection::fCRTNeutrinoHistos
private

Definition at line 62 of file Selection.h.

fhicl::ParameterSet ana::SBNOsc::Selection::fCutConfig
private

Definition at line 65 of file Selection.h.

Cuts ana::SBNOsc::Selection::fCuts
private

Definition at line 55 of file Selection.h.

bool ana::SBNOsc::Selection::fDoNormalize
private

Definition at line 67 of file Selection.h.

int ana::SBNOsc::Selection::fFileIndex
private

Definition at line 82 of file Selection.h.

numu::MCType ana::SBNOsc::Selection::fFileType
private

Definition at line 83 of file Selection.h.

bool ana::SBNOsc::Selection::fFillAllTracks
private

Definition at line 68 of file Selection.h.

double ana::SBNOsc::Selection::fGoalPOT
private

Definition at line 69 of file Selection.h.

std::string ana::SBNOsc::Selection::fHistogramPostfix
private

Definition at line 80 of file Selection.h.

Histograms ana::SBNOsc::Selection::fHistograms
private

Definition at line 57 of file Selection.h.

Histograms* ana::SBNOsc::Selection::fHistsToFill
private

Definition at line 59 of file Selection.h.

double ana::SBNOsc::Selection::fNCosmicData
private

Definition at line 70 of file Selection.h.

Normalize ana::SBNOsc::Selection::fNormalize
private

Definition at line 64 of file Selection.h.

TFile* ana::SBNOsc::Selection::fOutputFile
private

Definition at line 78 of file Selection.h.

numu::RecoEvent* ana::SBNOsc::Selection::fRecoEvent
private

Definition at line 77 of file Selection.h.

ROC ana::SBNOsc::Selection::fROC
private

Definition at line 56 of file Selection.h.

std::vector<numu::TrackFunction> ana::SBNOsc::Selection::fTrackProfileValues
private

Definition at line 75 of file Selection.h.

std::vector<std::string> ana::SBNOsc::Selection::fTrackSelectorNames
private

Definition at line 73 of file Selection.h.

std::vector<numu::TrackSelector> ana::SBNOsc::Selection::fTrackSelectors
private

Definition at line 72 of file Selection.h.

bool ana::SBNOsc::Selection::fUseCalorimetry
private

Definition at line 81 of file Selection.h.


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