13 #include <TParameter.h>
27 #include "../uScript/api.h"
28 #include "../uScript/value.h"
34 std::cout << config->to_indented_string() << std::endl;
35 fOutputFile =
new TFile(config->get<std::string>(
"OutputFile",
"output.root").c_str(),
"CREATE");
41 fCutConfig = config->get<fhicl::ParameterSet>(
"Cuts");
44 fGoalPOT = config->get<
double>(
"GoalPOT", 0.);
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", {{
""}});
54 assert(track_selector_strings.size() == track_selector_names.size());
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()));
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", {});
69 assert(track_profile_value_names.size() == track_profile_xranges.size());
78 fCRTGeo =
new sbnd::CRTGeoAlg(fProviderManager->GetGeometryProvider(), fProviderManager->GetAuxDetGeometryProvider());
80 fCuts.Initialize(fCutConfig, fProviderManager->GetGeometryProvider());
83 fCosmicHistograms.Initialize(fProviderManager->GetGeometryProvider(), *fCRTGeo, fCuts,
"Cosmic", fTrackSelectorNames, track_profile_value_names, track_profile_xranges);
85 fHistograms.Initialize(fProviderManager->GetGeometryProvider(), *fCRTGeo, fCuts, fHistogramPostfix, fTrackSelectorNames, track_profile_value_names, track_profile_xranges);
88 void Selection::FileSetup(TFile *f, TTree *eventTree) {
89 eventTree->SetBranchAddress(
"reco_event", &fRecoEvent);
90 fCuts.Initialize(fCutConfig, fProviderManager->GetGeometryProvider());
96 fHistsToFill = &fCosmicHistograms;
99 fHistsToFill = &fHistograms;
104 fHistsToFill = &fHistograms;
109 crt_from_file.
Get(*f,
"_all");
111 fCRTCosmicHistos.Add(crt_from_file);
114 fCRTNeutrinoHistos.Add(crt_from_file);
118 void Selection::ProcessSubRun(
const SubRun *subrun) {
120 fNormalize.AddNeutrinoSubRun(*subrun);
124 void Selection::ProcessFileMeta(
const FileMeta *meta) {
126 fNormalize.AddCosmicFile(*meta);
134 SetEvent(*fRecoEvent, *core_event, fCuts, fFileType, fUseCalorimetry);
139 for (
size_t ind: tracks) {
144 for (
size_t d_ind: t_particle.
daughters) {
145 if (fRecoEvent->tracks.count(d_ind)) {
159 fHistsToFill->Fill(*fRecoEvent, *core_event, fCuts, fTrackSelectors, fTrackProfileValues, fFillAllTracks);
163 else fNormalize.AddNeutrinoEvent(*core_event);
168 void Selection::Finalize() {
174 TParameter<float> scale_neutrino(
"ScaleNeutrino", fNormalize.ScaleNeutrino(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;
181 fHistograms.Scale(fNormalize.ScaleNeutrino(fGoalPOT));
182 fCosmicHistograms.Scale(fNormalize.ScaleCosmic(fGoalPOT));
184 fCRTCosmicHistos.Scale(fNormalize.ScaleNeutrino(fGoalPOT));
185 fCRTNeutrinoHistos.Scale(fNormalize.ScaleCosmic(fGoalPOT));
187 fHistograms.Add(fCosmicHistograms);
188 fROC.Normalize(fNormalize.ScaleNeutrino(fGoalPOT), fNormalize.ScaleCosmic(fGoalPOT));
193 fCRTCosmicHistos.Write();
194 fCRTNeutrinoHistos.Write();
InteractionMode mode
Mode of the interaction.
float chi2_muon
Chi2 of dE/dx to muon hypotheis. Combined agaisnt all planes.
Metadata metadata
Event metadata.
ClusterModuleLabel join with tracks
std::vector< numu::TrackSelector > fTrackSelectors
TruthMatch match
Info for mathing to truth.
void Get(TFile &f, const std::string &postfix)
process_name use argoneut_mc_hitfinder track
process_name opflashCryoW ana
std::vector< size_t > daughters
Daughters of the particle in the "particle flow". Value represents index into pandora information...
std::vector< TrackSelector > MultiplyTrackSelectors(const std::vector< std::vector< std::string >> &track_function_strings)
process_name standard_reco_uboone reco
std::vector< std::string > fTrackSelectorNames
#define DECLARE_SBN_POSTPROCESSOR(classname)
float length
Length of track.
The standard subrun data definition.
fhicl::ParameterSet fCutConfig
The standard event data definition.
TrackTruthMatch match
Truth matching information.
RecoSlice slice
Particle content of the interaction.
std::map< size_t, RecoParticle > particles
Map of particle index to particle information.
std::string fHistogramPostfix
std::vector< size_t > tracks
List of track indices contained in this slice.
void SetEvent(numu::RecoEvent &event, const event::Event &core, const ana::SBNOsc::Cuts &cuts, numu::MCType file_type, bool use_calorimetry=true)
void Initialize(const fhicl::ParameterSet &fcl)
int match_pdg
PDG of the MCParticle this track matches to.
void Initialize(fhicl::ParameterSet *config)
std::vector< numu::TrackFunction > fTrackProfileValues
std::vector< std::string > MultiplyNames(const std::vector< std::vector< std::string >> &strings, char join='_')
BEGIN_PROLOG could also be cout
float chi2_proton
Chi2 of dE/dx to proton hypothesis. Combined against all planes.