Go to the documentation of this file.
1 #pragma once
3 #include "CAFAna/Core/Var.h"
6 #include "CAFAna/Cuts/SpillReducer.h" // Provides CleanSpillQualityInfo()
8 #include <set>
10 namespace caf{class StandardRecord; class SRSpill; class SRSpillTruthBranch; class SRNeutrino;}
12 namespace ana
13 {
14  // Truth
21  // Reco/PID
29  //void ClearSecondaryShowerLIDPIDInfo(caf::StandardRecord* sr);
30  //void ClearShowerLIDEnergyInfo(caf::StandardRecord* sr);
32  void ClearProngInfo(caf::StandardRecord* sr); ///< 2D and 3D
46  // The reduction steps applied for these decafs
51  /// \brief Create smaller CAFs
52  ///
53  /// This class can do two seperate things. It can cause non-selected
54  /// variables to be NaN in the output file, causing it to compress very
55  /// well. It can also cut out slices that fail a cut.
57  {
58  public:
60  const std::string& outfile,
61  const bool copyNuTree = false);
62  FileReducer(const std::vector<std::string>& fnames,
63  const std::string& outfile,
64  const bool copyNuTree = false);
65  virtual ~FileReducer();
67  /// Only copy records to the output file if they pass this cut
68  void AddEventCut(const Cut& cut);
70  /// Only copy nuTree neutrinos to the output file if they pass this cut
71  void AddNuTruthCut(const NuTruthCut& cut);
74  /// \brief If called, only events whose run/subrun/event occur in \a fname
75  /// will be retained.
76  void SetEventList(const std::string& fname);
78  /// Set an optional parameter to omit bad files (zombie or no POT)
79  void setOmitBadFiles(bool omit) {fOmitBadFiles = omit;}
81  typedef void (ReductionFunc)(caf::StandardRecord*);
82  typedef void (ReductionFuncWithProxy)(caf::StandardRecord*,
83  const caf::SRProxy*);
84  /// Run the specified reduction function over each event
85  void AddReductionStep(const std::function<ReductionFunc> &f) {fReductionFuncs.push_back(f);}
86  void AddReductionStep(const std::function<ReductionFuncWithProxy> &f) {fReductionFuncsWithProxy.push_back(f);}
88  typedef void (SpillReductionFunc)(caf::SRSpill*, const caf::SRSpillProxy*);
89  /// Run the specified reduction function over each spill
90  void AddSpillReductionStep(const std::function<SpillReductionFunc> &f) {fSpillReductionFuncs.push_back(f);}
92  typedef void (NuTruthReductionFunc)(caf::SRSpillTruthBranch*, const caf::SRNeutrinoProxy*);
93  /// Run the specified reduction function over each spill
94  void AddNuTruthReductionStep(const std::function<NuTruthReductionFunc> &f) {fNuTruthReductionFuncs.push_back(f);}
96  /// \brief Cause the output file to be systematically shifted
97  ///
98  /// Note: reweighting systematics cannot be used.
99  // void SetSystShift(const SystShifts& ss) {fSystShifts = ss;}
101  /// Override any metadata key in the output file
103  {
104  fMetaMap[key] = val;
105  }
107  void CopyMetadata(bool copy=true){fCopyMetadata = copy;};
109  virtual void Go() override;
111  // required by the interface, but not needed for anything done by FileReducer
112  virtual void AccumulateExposures(const caf::SRSpillProxy* spill) override {};
114  protected:
115  void UpdateMetadata(std::map<std::string, std::string>& meta,
116  const std::set<std::string>& mask,
117  const std::vector<std::string>& fnames) const;
122  std::set<std::tuple<int, int, int>> fEventList;
124  std::vector<std::function<ReductionFunc>> fReductionFuncs;
125  std::vector<std::function<ReductionFuncWithProxy>> fReductionFuncsWithProxy;
126  std::vector<std::function<SpillReductionFunc>> fSpillReductionFuncs;
127  std::vector<std::function<NuTruthReductionFunc>> fNuTruthReductionFuncs;
129  // SystShifts fSystShifts;
130  std::map<std::string, std::string> fMetaMap;
133  };
134 }
void ReduceForNusDecaf(caf::StandardRecord *sr)
Definition: FileReducer.cxx:80
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void ClearDiscreteTrackInfo(caf::StandardRecord *sr)
void AddSpillReductionStep(const std::function< SpillReductionFunc > &f)
Run the specified reduction function over each spill.
Definition: FileReducer.h:90
void ClearTrackInfo(caf::StandardRecord *sr)
std::string fOutfile
Definition: FileReducer.h:119
void ResetCosRejInfo(caf::StandardRecord *sr)
void ClearSecondaryTrackInfo(caf::StandardRecord *sr)
void ReduceForNumuDecaf(caf::StandardRecord *sr)
NuTruthCut * fNuTruthCut
Definition: FileReducer.h:121
void CopyMetadata(bool copy=true)
Definition: FileReducer.h:107
Proxy for caf::SRNeutrino.
Definition: SRProxy.h:510
void ResetBeamInfo(caf::StandardRecord *sr)
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
void ClearShowerLIDPIDInfo(caf::StandardRecord *sr)
Truth info for all neutrinos in the spill.
void SetMetadata(const std::string &key, const std::string &val)
Cause the output file to be systematically shifted.
Definition: FileReducer.h:102
virtual void AccumulateExposures(const caf::SRSpillProxy *spill) override
Definition: FileReducer.h:112
void ClearKalman2DInfo(caf::StandardRecord *sr)
The SRNeutrino is a representation of neutrino interaction information.
Definition: SRNeutrino.h:21
void AddReductionStep(const std::function< ReductionFunc > &f)
Run the specified reduction function over each event.
Definition: FileReducer.h:85
void ResetRVPInfo(caf::StandardRecord *sr)
void ClearHoughVertexInfo(caf::StandardRecord *sr)
void ClearMichelTruthInfo(caf::StandardRecord *sr)
Definition: FileReducer.cxx:42
void setOmitBadFiles(bool omit)
Set an optional parameter to omit bad files (zombie or no POT)
Definition: FileReducer.h:79
void ClearProngInfo(caf::StandardRecord *sr)
2D and 3D
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
std::map< std::string, std::string > fMetaMap
Definition: FileReducer.h:130
Class for parsing *.fcl files for their metadata information.
caf::StandardRecord * sr
void ClearWindowTrackInfo(caf::StandardRecord *sr)
void ResetContainInfo(caf::StandardRecord *sr)
Create smaller CAFs.
Definition: FileReducer.h:56
Proxy for caf::SRSpill.
Definition: SRProxy.h:1346
void ResetNumuEnergy(caf::StandardRecord *sr)
Base class for the various types of spectrum loader.
std::vector< std::function< ReductionFunc > > fReductionFuncs
Definition: FileReducer.h:124
void ClearPrimaryInfo(caf::StandardRecord *sr)
Definition: FileReducer.cxx:35
The StandardRecord is the primary top-level object in the Common Analysis File trees.
const Cut cut
Definition: exporter_fd.C:30
void ResetBPFEnergy(caf::StandardRecord *sr)
void ClearShowerLIDRecoInfo(caf::StandardRecord *sr)
void ResetLEMInfo(caf::StandardRecord *sr)
void ResetNueCosRejInfo(caf::StandardRecord *sr)
std::vector< std::function< NuTruthReductionFunc > > fNuTruthReductionFuncs
Definition: FileReducer.h:127
void ClearReweightInfo(caf::StandardRecord *sr)
void ResetNueEnergyInfo(caf::StandardRecord *sr)
std::set< std::tuple< int, int, int > > fEventList
Definition: FileReducer.h:122
void ClearElasticArmsInfo(caf::StandardRecord *sr)
void ClearCosmicTrackInfo(caf::StandardRecord *sr)
void ReduceForNueDecaf(caf::StandardRecord *sr)
Definition: FileReducer.cxx:56
std::vector< std::function< SpillReductionFunc > > fSpillReductionFuncs
Definition: FileReducer.h:126
This module creates Common Analysis Files.
Definition: FileReducer.h:10
void ResetLIDInfo(caf::StandardRecord *sr)
void AddReductionStep(const std::function< ReductionFuncWithProxy > &f)
Definition: FileReducer.h:86
void AddNuTruthReductionStep(const std::function< NuTruthReductionFunc > &f)
Run the specified reduction function over each spill.
Definition: FileReducer.h:94
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
std::vector< std::function< ReductionFuncWithProxy > > fReductionFuncsWithProxy
Definition: FileReducer.h:125
void Clear2DProngInfo(caf::StandardRecord *sr)
void ClearMultiNuInfo(caf::StandardRecord *sr)
Definition: FileReducer.cxx:25
FILE * outfile
Definition: dump_event.C:13
enum BeamMode string