reduce_prod5_nue.C
Go to the documentation of this file.
4 #include "CAFAna/Cuts/Cuts.h"
13 
14 using namespace ana;
16  const caf::SRProxy* srProxy)
17 {
18 
19  ClearMultiNuInfo(sr);
21 
22  if(sr->hdr.det == caf::kFARDET) return;
23 
25 
26  // remove these completely
29  sr->me = caf::SRMichelE();
30 
31  // slc branch
32  // keeping some basic slice info for various cuts
33  unsigned int tempncontplanes = sr->slc.ncontplanes;
34  unsigned int tempnhit = sr->slc.nhit;
35  unsigned int tempfirstplane = sr->slc.firstplane;
36  unsigned int templastplane = sr->slc.lastplane;
37  unsigned int tempncellsfromedge = sr->slc.ncellsfromedge;
38  float tempcalE = sr->slc.calE;
39  caf::SRVector3D tempmeanpos = sr->slc.meanpos;
40  caf::SRVector3D tempboxmax = sr->slc.boxmax;
41  caf::SRVector3D tempboxmin = sr->slc.boxmin;
42 
43  sr->slc = caf::SRSlice();
44 
45  sr->slc.ncontplanes = tempncontplanes;
46  sr->slc.nhit = tempnhit;
47  sr->slc.firstplane = tempfirstplane;
48  sr->slc.lastplane = templastplane;
49  sr->slc.ncellsfromedge = tempncellsfromedge;
50  sr->slc.calE = tempcalE;
51  sr->slc.meanpos = tempmeanpos;
52  sr->slc.boxmin = tempboxmin;
53  sr->slc.boxmax = tempboxmax;
54 
55  // energy branch
56  // keeping only a few numu energy vars
57  float temprecotrkcchadE = sr->energy.numu.recotrkcchadE;
58  float temptrkccE = sr->energy.numu.trkccE;
59  float temptrknonqeE = sr->energy.numu.trknonqeE;
60  float temptrkqeE = sr->energy.numu.trkqeE;
61  float tempndhadcaltranE = sr->energy.numu.ndhadcaltranE;
62  float tempndhadcalcatE = sr->energy.numu.ndhadcalcatE;
63  float tempE = sr->energy.numu.E;
64  float temphadcalE = sr->energy.numu.hadcalE;
65  float temphadtrkE = sr->energy.numu.hadtrkE;
66  float tempndtrkcaltranE = sr->energy.numu.ndtrkcaltranE;
67  float tempndtrkcalcatE = sr->energy.numu.ndtrkcalcatE;
68  float tempndtrkcalactE = sr->energy.numu.ndtrkcalactE;
69  float tempndtrklencat = sr->energy.numu.ndtrklencat;
70  float tempndtrklenact = sr->energy.numu.ndtrklenact;
71 
73 
74  sr->energy.numu.recotrkcchadE = temprecotrkcchadE;
75  sr->energy.numu.trkccE = temptrkccE;
76  sr->energy.numu.trknonqeE = temptrknonqeE;
77  sr->energy.numu.trkqeE = temptrkqeE;
78  sr->energy.numu.ndhadcaltranE = tempndhadcaltranE;
79  sr->energy.numu.ndhadcalcatE = tempndhadcalcatE;
80  sr->energy.numu.E = tempE;
81  sr->energy.numu.hadcalE = temphadcalE;
82  sr->energy.numu.hadtrkE = temphadtrkE;
83  sr->energy.numu.ndtrkcaltranE = tempndtrkcaltranE;
84  sr->energy.numu.ndtrkcalcatE = tempndtrkcalcatE;
85  sr->energy.numu.ndtrkcalactE = tempndtrkcalactE;
86  sr->energy.numu.ndtrklencat = tempndtrklencat;
87  sr->energy.numu.ndtrklenact = tempndtrklenact;
88 
89  ResetBPFEnergy(sr);
90 
91  // sel branch
92 
93  sr->sel.bpfid = caf::SRBpfId();
94  sr->sel.xnuepid = caf::SRXnue();
95 
96  ResetLEMInfo(sr);
97  ResetLIDInfo(sr);
98  ResetRVPInfo(sr);
99  ResetCosRejInfo(sr);
100 
101  //
102  // track branch
103  // need number of cosmic tracks, therefore we create a dummy vector
104  sr->trk.cosmic.tracks.clear();
105  sr->trk.cosmic.tracks.resize(sr->trk.cosmic.ntracks);
106 
107  // need start and stop coordinates
108  if(sr->trk.kalman.ntracks > 0){
109  std::vector<caf::SRVector3D> temptrackstart;
110  std::vector<caf::SRVector3D> temptrackstop;
111  std::vector<caf::SRVector3D> temptrackdir;
112  unsigned int tempidxremid = sr->trk.kalman.idxremid;
113  for(int i = 0; i < (int)sr->trk.kalman.tracks.size(); i++){
114  temptrackstart.push_back(sr->trk.kalman.tracks[i].start);
115  temptrackstop.push_back(sr->trk.kalman.tracks[i].stop);
116  temptrackdir.push_back(sr->trk.kalman.tracks[i].dir);
117  }
118  float temptrackslen = sr->trk.kalman.tracks[0].len;
119 
120  sr->trk.kalman.tracks.clear();
121  sr->trk.kalman.tracks.resize(sr->trk.kalman.ntracks);
122 
123  for(int i = 0; i < (int)sr->trk.kalman.tracks.size(); i++){
124  sr->trk.kalman.tracks[i].start = temptrackstart[i];
125  sr->trk.kalman.tracks[i].stop = temptrackstop[i];
126  sr->trk.kalman.tracks[i].dir = temptrackdir[i];
127  }
128  sr->trk.kalman.tracks[0].len = temptrackslen;
129  sr->trk.kalman.idxremid = tempidxremid;
130  }
131 
132  // vertex branch
133  // need vtx coordinates
134  if(sr->vtx.elastic.IsValid && sr->vtx.elastic.fuzzyk.npng > 0){
135  float tempvtxX = sr->vtx.elastic.vtx.X();
136  float tempvtxY = sr->vtx.elastic.vtx.Y();
137  float tempvtxZ = sr->vtx.elastic.vtx.Z();
138  float tempnshwlid = sr->vtx.elastic.fuzzyk.nshwlid;
139  float tempnpng = sr->vtx.elastic.fuzzyk.npng;
140  float tempdedx0 = sr->vtx.elastic.fuzzyk.png[0].shwlid.lid.dedx0;
141  int templongestidx = sr->vtx.elastic.fuzzyk.longestidx;
142  float templen = sr->vtx.elastic.fuzzyk.png[templongestidx].len;
143 
144  std::vector<caf::SRVector3D> tempshwlidstart;
145  std::vector<caf::SRVector3D> tempshwlidstop;
146  std::vector<caf::SRVector3D> temppngstart;
147  std::vector<caf::SRCVNParticleResult> tempcvnpart;
148  std::vector<float> tempshwlidcale;
149 
150  for(int pngidx = 0; pngidx < (int)sr->vtx.elastic.fuzzyk.nshwlid; pngidx++){
151  tempshwlidstart.push_back(sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.start);
152  tempshwlidstop.push_back(sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.stop);
153  }
154  for(int pngidx = 0; pngidx < (int)sr->vtx.elastic.fuzzyk.npng; pngidx++){
155  temppngstart.push_back(sr->vtx.elastic.fuzzyk.png[pngidx].start);
156  tempcvnpart.push_back(sr->vtx.elastic.fuzzyk.png[pngidx].cvnpart);
157  tempshwlidcale.push_back(sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.calE);
158  }
159 
160 
161  sr->vtx.elastic.IsValid = true;
162  sr->vtx.elastic.vtx.x = tempvtxX;
163  sr->vtx.elastic.vtx.y = tempvtxY;
164  sr->vtx.elastic.vtx.z = tempvtxZ;
165 
166  sr->vtx.elastic.fuzzyk.npng = tempnpng;
167  sr->vtx.elastic.fuzzyk.nshwlid = tempnshwlid;
168  sr->vtx.elastic.fuzzyk.png.resize(tempnpng);
169  for(int pngidx = 0; pngidx < (int)sr->vtx.elastic.fuzzyk.nshwlid; pngidx++){
170  sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.start = tempshwlidstart[pngidx];
171  sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.stop = tempshwlidstop[pngidx];
172  }
173  for(int pngidx = 0; pngidx < (int)sr->vtx.elastic.fuzzyk.npng; pngidx++){
174  sr->vtx.elastic.fuzzyk.png[pngidx].start = temppngstart[pngidx];
175  sr->vtx.elastic.fuzzyk.png[pngidx].cvnpart = tempcvnpart[pngidx];
176  sr->vtx.elastic.fuzzyk.png[pngidx].shwlid.calE = tempshwlidcale[pngidx];
177  }
178  sr->vtx.elastic.fuzzyk.png[0].shwlid.lid.dedx0 = tempdedx0;
179  sr->vtx.elastic.fuzzyk.longestidx = templongestidx;
180  sr->vtx.elastic.fuzzyk.png[templongestidx].len = templen;
181 
183  }
184 
185  // truth branch
186  if(sr->hdr.ismc == 1 && sr->mc.nnu > 0) {
187 
188  sr->mc.nu[0].rwgt.ppfx.vuniv.clear();
189  sr->mc.nu[0].rwgt.ppfx.nvuniv = 0;
190 
192  }
193 
194  }
195 
196 }
197 
199 {
200  FileReducer reduce(fname, outname);
201  reduce.SetMetadata("nova.decaf_skim", "nue2020_numundv2");
202 
203  const Cut kIsND(
204  [](const caf::SRProxy* sr)
205  {
206  return sr->hdr.det==caf::kNEARDET;
207  });
208 
209  const Cut kIsFD(
210  [](const caf::SRProxy* sr)
211  {
212  return sr->hdr.det==caf::kFARDET;
213  });
214 
215  const Cut fdCut = (kIsFD && kNue2020FDDecafCut);
217 
218  reduce.AddEventCut(fdCut || ndCut);
222  reduce.Go();
223 }
Det_t det
Detector, ND = 1, FD = 2, NDOS = 3.
Definition: SRHeader.h:28
Near Detector underground.
Definition: SREnums.h:10
Far Detector at Ash River.
Definition: SREnums.h:11
A 3-vector with more efficient storage than TVector3.
Definition: SRVector3D.h:14
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Event ID training variables.
SRHeader hdr
Header branch: run, subrun, etc.
float ndtrklenact
Near detector – muon track length in active region [cm].
Definition: SRNumuEnergy.h:37
float ndtrkcaltranE
Near detector – muon calorimetric energy in transition plane [GeV].
Definition: SRNumuEnergy.h:40
void ResetCosRejInfo(caf::StandardRecord *sr)
void ClearSecondaryTrackInfo(caf::StandardRecord *sr)
unsigned int lastplane
last plane
Definition: SRSlice.h:27
unsigned int firstplane
first plane
Definition: SRSlice.h:26
size_t ntracks
Definition: SRKalman.h:23
float trknonqeE
Track length non-quasielastic neutrino energy [GeV].
Definition: SRNumuEnergy.h:26
unsigned int idxremid
index number of the best ReMId track
Definition: SRKalman.h:32
SRVector3D boxmax
Maximum coordinates box containing all the hits [cm].
Definition: SRSlice.h:47
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2049
std::vector< SRFuzzyKProng > png
Vector of 3D prong objects.
Definition: SRFuzzyK.h:19
SRMichelE me
Michel electron branch.
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2038
float Y() const
Definition: SRVector3D.h:33
float ndtrkcalcatE
Near detector – muon calorimetric energy in muon catcher [GeV].
Definition: SRNumuEnergy.h:41
SRTrainingBranch training
Extra training information for prototyping PIDs etc.
void reduce_prod5_nue(std::string fname, std::string outname)
unsigned int longestidx
index of longest prong
Definition: SRFuzzyK.h:23
void SetMetadata(const std::string &key, const std::string &val)
Cause the output file to be systematically shifted.
Definition: FileReducer.h:102
bool ismc
data or MC? True if MC
Definition: SRHeader.h:27
Store BDT variables for the short-baseline oscillation study.
Definition: SRXnue.h:12
Breakpoint ID (BpfId) output.
Definition: SRBpfId.h:18
void AddReductionStep(const std::function< ReductionFunc > &f)
Run the specified reduction function over each event.
Definition: FileReducer.h:85
float X() const
Definition: SRVector3D.h:32
void ResetRVPInfo(caf::StandardRecord *sr)
float trkccE
Track length cc neutrino energy [GeV].
Definition: SRNumuEnergy.h:27
SRKalman kalman
Tracks produced by KalmanTrack.
Definition: SRTrackBranch.h:24
unsigned int nshwlid
number of shwlid showers - either 0 or number of 3d prongs
Definition: SRFuzzyK.h:24
SRVector3D boxmin
Minimum coordinates box containing all the hits [cm].
Definition: SRSlice.h:46
float ndhadcalcatE
Near detector – hadronic calorimetric energy NOT on the muon track in muon catcher [GeV]...
Definition: SRNumuEnergy.h:44
float trkqeE
Track length quasielastic neutrino energy [GeV].
Definition: SRNumuEnergy.h:25
float hadtrkE
Hadronic calorimetric energy on the muon track[GeV].
Definition: SRNumuEnergy.h:36
const Cut kNue2020NDDecafCut
Definition: NueCuts2020.h:176
void ClearHoughVertexInfo(caf::StandardRecord *sr)
void ClearMichelTruthInfo(caf::StandardRecord *sr)
Definition: FileReducer.cxx:46
float calE
Calorimetric energy of the cluster [GeV].
Definition: SRSlice.h:38
void AddEventCut(const Cut &cut)
Only copy records to the output file if they pass this cut.
Numu energy estimator output.
Definition: SRNumuEnergy.h:17
const Cut kNue2020FDDecafCut
Definition: NueCuts2020.h:31
SRVector3D vtx
Vertex position in detector coordinates. [cm].
Definition: SRElastic.h:26
short nnu
Number of neutrinos in nu vector (0 or 1)
Definition: SRTruthBranch.h:37
size_t npng
Definition: SRFuzzyK.h:26
float E
Neutrino energy, set to match trkccE [GeV].
Definition: SRNumuEnergy.h:23
An SRSlice contains overarching information for a slice.
Definition: SRSlice.h:15
float Z() const
Definition: SRVector3D.h:34
unsigned int nhit
number of hits
Definition: SRSlice.h:22
virtual void Go() override
Load all the registered spectra.
Create smaller CAFs.
Definition: FileReducer.h:56
SRBpfId bpfid
Output from the BreakPointFitter PID (BPFPIdMaker) package.
Definition: SRIDBranch.h:41
void ReduceForSignalDecaf(caf::StandardRecord *sr, const caf::SRProxy *srProxy)
unsigned int ncellsfromedge
minimum number of cells to edge of detector
Definition: SRSlice.h:30
const Cut kNumuUncontainNDDecafCut
Definition: BeamNueCuts.h:23
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
The StandardRecord is the primary top-level object in the Common Analysis File trees.
void ResetBPFEnergy(caf::StandardRecord *sr)
float ndhadcaltranE
Near detector – hadronic calorimetric energy NOT on the muon track in transition plane [GeV]...
Definition: SRNumuEnergy.h:43
SRNumuEnergy numu
Numu energy estimator.
float ndtrkcalactE
Near detector – muon calorimetric energy in active region [GeV].
Definition: SRNumuEnergy.h:39
void ResetLEMInfo(caf::StandardRecord *sr)
float ndtrklencat
Near detector – muon track length in muon catcher [cm].
Definition: SRNumuEnergy.h:38
SRIDBranch sel
Selector (PID) branch.
SRElastic elastic
Single vertex found by Elastic Arms.
SRSlice slc
Slice branch: nhit, extents, time, etc.
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
SRFuzzyK fuzzyk
Primary 3D prong object.
Definition: SRElastic.h:30
float recotrkcchadE
Reconstructed hadronic energy for track cc neutrino energy estimator [GeV].
Definition: SRNumuEnergy.h:34
void ResetLIDInfo(caf::StandardRecord *sr)
SRVector3D meanpos
Mean position of hits in slice, weighted by charge [cm].
Definition: SRSlice.h:48
SRParentBranch parent
True parent branch for matching, e.g. MRCC.
unsigned int ncontplanes
number of continuous planes
Definition: SRSlice.h:25
SRTrackBranch trk
Track branch: nhit, len, etc.
SREnergyBranch energy
Energy estimator branch.
SRTrackBase cosmic
Tracks produced by CosmicTrack.
Definition: SRTrackBranch.h:26
std::vector< SRNeutrino > nu
implemented as a vector to maintain mc.nu structure, i.e. not a pointer, but with 0 or 1 entries...
Definition: SRTruthBranch.h:25
std::vector< SRTrack > tracks
Definition: SRTrackBase.h:15
float hadcalE
Hadronic calorimetric energy NOT on the muon track[GeV].
Definition: SRNumuEnergy.h:35
void ClearMultiNuInfo(caf::StandardRecord *sr)
Definition: FileReducer.cxx:29
static constexpr Double_t sr
Definition: Munits.h:164
std::vector< SRKalmanTrack > tracks
3D Tracks produced by KalmanTrack
Definition: SRKalman.h:16
const Cut kNumuContainNDDecafCut
Definition: BeamNueCuts.h:22
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:227
SRVertexBranch vtx
Vertex branch: location, time, etc.
SRXnue xnuepid
Output from BDT (XnuePID)
Definition: SRIDBranch.h:57