PIDCutTuningDefs.h
Go to the documentation of this file.
1 #ifndef NUCRYSTALBALL_H
2 #define NUCRYSTALBALL_H
3 
4 #include "CAFAna/Prediction/IPrediction.h" // IPrediction
5 #include "CAFAna/Vars/Vars.h" // Var, kUnweighted
6 #include "CAFAna/Core/Binning.h" // Binning
7 #include "CAFAna/Core/Cut.h" // Cut, kNoCut
8 #include "CAFAna/Core/Spectrum.h" // Spectrum
9 #include "CAFAna/Vars/GenieWeights.h" // kXSecCVWgt2018
10 #include "CAFAna/Vars/PPFXWeights.h" // kPPFXFluxCVWgt
11 #include "StandardRecord/Proxy/SRProxy.h" // SRProxy
12 #include "3FlavorAna/Cuts/NueCuts2017.h" // kNue2017CorePresel,
13 #include "3FlavorAna/Cuts/NueCuts2018.h" // kNue2018CorePresel,
14 #include "3FlavorAna/Cuts/NumuCuts2017.h" // kNumuContainFD2017, kNumuCosmicRej2017
15 #include "NuXAna/Cuts/NusCuts17.h" // kNus17FDPresel, kNus17BackwardCut
16  // kNus17NCCosRejAlt, kNus17SlcTimeGap, kNus17SlcDist, kNus17ShwPtpLow
17  // kNus17ShwPtpHigh, kNus17EnergyCut
18 #include "3FlavorAna/Vars/NueVars.h" // kNueEnergy2017
19 #include "3FlavorAna/Vars/NumuVars.h" // kCCE, kHadE
20 #include "NuXAna/Vars/NusVars.h" // kNus17Energy
21 
22 #include "TString.h"
24 
25 #include <vector>
26 
27 namespace ana
28 {
29  //! Struct to hold prediction information
30  struct PredDef
31  {
33  const TString cutName;
34  const TString pidCutName;
35  const TString varName;
36  const TString polarity;
37  const TString weightName;
38  };
39 
40  //! Struct to hold Var/plot information
41  struct VarDef
42  {
43  const TString name;
44  const Var var;
46  const TString type;
47  const TString shortName;
48  };
49 
50  //! Struct to hold cut information
51  struct CutDef
52  {
53  const TString name;
54  const Cut cut;
55  const TString type;
56  };
57 
58  //! Struct to hold PID cut information
59  struct PIDCutDef
60  {
61  const TString name;
62  const Cut cut;
63  const TString type;
64  };
65 
66  //! Struct to hold weight information
67  struct WeightDef
68  {
69  const TString name;
70  const Var weight;
71  };
72 
73  //! Structure to hold Spectra information
74  struct SpecDef
75  {
77  const TString cutName;
78  const TString pidCutName;
79  const TString varName;
80  const TString polarity;
81  const TString weightName;
82  };
83 
84  // Define binnings
85  const Binning kPIDBinning = Binning::Simple(100, 0.0, 1.);
86  const Binning kPIDZoomBinning = Binning::Simple(50, 0.75, 1.);
88  const Binning kModeBinning = Binning::Simple(4, -0.5, 3.5);
89  const Binning kYBinning = Binning::Simple(50, 0, 1);
90  const Binning kYvertexBinning = Binning::Simple(40, -800, 800);
91  const Binning kXvertexBinning = Binning::Simple(40, -800, 800);
92  const Binning kZvertexBinning = Binning::Simple(40, 0, 6000);
93  //const Binning kNue2018CVNBinning = Binning::Simple(36, 0, 36);
94 
95  // Define weight
96  const Var weight = kXSecCVWgt2018 * kPPFXFluxCVWgt; // Shiqi's reccommendation
97 
98  // Some general Vars we want to plot
99  const Var kTrueEVis(//{"mc.nu.E", "mc.nu.y", "mc.nu.iscc"},
100  [](const caf::SRProxy* sr)
101  {
102  if (sr->mc.nu.empty())
103  return 0.;
104  double ret = sr->mc.nu[0].E;
105  if (!sr->mc.nu[0].iscc)
106  ret *= sr->mc.nu[0].y;
107  return ret;
108  });
109 
110  // ***Nue***
111  // New CVN CAF variables for PIDs
112  //! \f$ \nu_e \f$ CVN short-simple PID
113  const Var kCVNeSS([](const caf::SRProxy* sr){
114  return sr->sel.cvnProd3Train.nueid;});
115  //! \f$ \nu_e \f$ CVN ELU PID
116  const Var kCVNeELU([](const caf::SRProxy* sr){
117  return sr->sel.cvn.nueid;});
118  //! \f$ \nu_e \f$ CVN 2017 PID
119  const Var kCVNe2017([](const caf::SRProxy* sr){
120  return sr->sel.cvn2017.nueid;});
121 
122  // Nue cuts
123  //! Nearest slice cuts without CVN
124  //! Uses Nue2018CorePresel
125  const Cut kNearestSliceCosRejCoreNoCVN([](const caf::SRProxy* sr)
126  {
127  if (kNue2018CorePresel(sr))
128  {
129  return !(sr->slc.closestslicetime > -100. &&
130  sr->slc.closestslicetime < 100. &&
131  sr->slc.closestsliceminfromtop < 400 &&
132  sr->slc.closestslicemindist < 500.);
133  }
134  return false;
135  });
136 
137  //! Full FD nue selection for 2018 analysis - with all CVN dependence removed
140 
141  // 1-bin RHC
142  // - kOneAnaBinRHC | .89 |
143  const Var kOneSelBinRHC([](const caf::SRProxy *sr)
144  {
145  if (sr->sel.cvnProd3Train.nueid >= 0.89)
146  return float(0.5);
147  else
148  return float(-5.0);
149  });
150 
151  const Var kOneAnaBinRHC([](const caf::SRProxy *sr)
152  {
153  int selBin = kOneSelBinRHC(sr);
154  float nuE = kNueEnergy2018(sr);
155  int nuEBin = nuE/0.5;
156 
157  // TODO: keeps failing this assertion
158  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
159 
160  int anaBin = 9*selBin + nuEBin;
161 
162  return anaBin;
163  });
164 
165  const HistAxis kOneBinRHCAxis(
166  "NuE Energy / RHC Analysis Bin", kNue2018Binning, kOneAnaBinRHC);
167 
168  // 2-bin RHC
169  // - kTwoAnaBinRHC | .76 | .96 |
170 
171  const Var kTwoSelBinRHC([](const caf::SRProxy *sr)
172  {
173  if (sr->sel.cvnProd3Train.nueid >= 0.76 && sr->sel.cvnProd3Train.nueid < 0.96)
174  return float(0.5);
175  else if(sr->sel.cvnProd3Train.nueid >= 0.96)
176  return float(1.5);
177  else
178  return float(-5.0);
179  });
180 
181  const Var kTwoAnaBinRHC([](const caf::SRProxy *sr)
182  {
183  int selBin = kTwoSelBinRHC(sr);
184  float nuE = kNueEnergy2018(sr);
185  int nuEBin = nuE/0.5;
186 
187  // TODO: keeps failing this assertion
188  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
189 
190  int anaBin = 9*selBin + nuEBin;
191 
192  return anaBin;
193  });
194 
195  const HistAxis kTwoBinRHCAxis(
196  "NuE Energy / RHC Analysis Bin", kNue2018Binning, kTwoAnaBinRHC);
197 
198  // 2-bin high purity RHC
199  // - kTwoAnaBinHiPurRHC | .89 | .99 |
200  const Var kTwoSelBinHiPurRHC([](const caf::SRProxy *sr)
201  {
202  if (sr->sel.cvnProd3Train.nueid >= 0.89 && sr->sel.cvnProd3Train.nueid < 0.99)
203  return float(0.5);
204  else if(sr->sel.cvnProd3Train.nueid >= 0.99)
205  return float(1.5);
206  else
207  return float(-5.0);
208  });
209 
210  const Var kTwoAnaBinHiPurRHC([](const caf::SRProxy *sr)
211  {
212  int selBin = kTwoSelBinHiPurRHC(sr);
213  float nuE = kNueEnergy2018(sr);
214  int nuEBin = nuE/0.5;
215 
216  // TODO: keeps failing this assertion
217  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
218 
219  int anaBin = 9*selBin + nuEBin;
220 
221  return anaBin;
222  });
223 
224  const HistAxis kTwoBinHiPurRHCAxis(
225  "NuE Energy / RHC Analysis Bin", kNue2018Binning, kTwoAnaBinHiPurRHC);
226 
227  // 3-bin RHC
228  // - kThreeAnaBinRHC | .71 | .92 | .98 |
229  const Var kThreeSelBinRHC([](const caf::SRProxy *sr)
230  {
231  if(sr->sel.cvnProd3Train.nueid >= 0.71 && sr->sel.cvnProd3Train.nueid < 0.92)
232  return float(0.5);
233  else if(sr->sel.cvnProd3Train.nueid >= 0.92 &&
234  sr->sel.cvnProd3Train.nueid < 0.98)
235  return float(1.5);
236  else if(sr->sel.cvnProd3Train.nueid >= 0.98)
237  return float(2.5);
238  else
239  return float(-5.0);
240  });
241 
242  const Var kThreeAnaBinRHC([](const caf::SRProxy *sr)
243  {
244  int selBin = kThreeSelBinRHC(sr);
245  float nuE = kNueEnergy2018(sr);
246  int nuEBin = nuE/0.5;
247 
248  // TODO: keeps failing this assertion
249  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
250 
251  int anaBin = 9*selBin + nuEBin;
252 
253  return anaBin;
254  });
255 
256  const HistAxis kThreeBinRHCAxis(
257  "NuE Energy / RHC Analysis Bin", kNue2018Binning, kThreeAnaBinRHC);
258 
259  // 4-bin RHC
260  // - kFourAnaBinRHC | .71 | .92 | .98 | .99 |
261  const Var kFourSelBinRHC([](const caf::SRProxy *sr)
262  {
263  if (sr->sel.cvnProd3Train.nueid >= 0.71 &&
264  sr->sel.cvnProd3Train.nueid < 0.92)
265  return float(0.5);
266  else if(sr->sel.cvnProd3Train.nueid >= 0.92 &&
267  sr->sel.cvnProd3Train.nueid < 0.98)
268  return float(1.5);
269  else if(sr->sel.cvnProd3Train.nueid >= 0.98 &&
270  sr->sel.cvnProd3Train.nueid < 0.99)
271  return float(2.5);
272  else if(sr->sel.cvnProd3Train.nueid >= 0.99)
273  return float(3.5);
274  else
275  return float(-5.0);
276  });
277 
278  const Var kFourAnaBinRHC([](const caf::SRProxy *sr)
279  {
280  int selBin = kFourSelBinRHC(sr);
281  float nuE = kNueEnergy2018(sr);
282  int nuEBin = nuE/0.5;
283 
284  // TODO: keeps failing this assertion
285  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
286 
287  int anaBin = 9*selBin + nuEBin;
288 
289  return anaBin;
290  });
291 
292  const HistAxis kFourBinRHCAxis(
293  "NuE Energy / RHC Analysis Bin", kNue2018Binning, kFourAnaBinRHC);
294 
295  // 1-bin FHC
296  // - kOneAnaBinFHC | .86 |
297  const Var kOneSelBinFHC([](const caf::SRProxy *sr)
298  {
299  if (sr->sel.cvnProd3Train.nueid >= 0.86)
300  return float(0.5);
301  else
302  return float(-5.0);
303  });
304 
305  const Var kOneAnaBinFHC([](const caf::SRProxy *sr)
306  {
307  int selBin = kOneSelBinFHC(sr);
308  float nuE = kNueEnergy2018(sr);
309  int nuEBin = nuE/0.5;
310 
311  // TODO: keeps failing this assertion
312  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
313 
314  int anaBin = 9*selBin + nuEBin;
315 
316  return anaBin;
317  });
318 
319  const HistAxis kOneBinFHCAxis(
320  "NuE Energy / FHC Analysis Bin", kNue2018Binning, kOneAnaBinFHC);
321 
322  // 2-bin FHC
323  // - kTwoAnaBinFHC | .72 | .94 |
324  const Var kTwoSelBinFHC([](const caf::SRProxy *sr)
325  {
326  if (sr->sel.cvnProd3Train.nueid >= 0.72 && sr->sel.cvnProd3Train.nueid < 0.94)
327  return float(0.5);
328  else if(sr->sel.cvnProd3Train.nueid >= 0.94)
329  return float(1.5);
330  else
331  return float(-5.0);
332  });
333 
334  const Var kTwoAnaBinFHC([](const caf::SRProxy *sr)
335  {
336  int selBin = kTwoSelBinFHC(sr);
337  float nuE = kNueEnergy2018(sr);
338  int nuEBin = nuE/0.5;
339 
340  // TODO: keeps failing this assertion
341  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
342 
343  int anaBin = 9*selBin + nuEBin;
344 
345  return anaBin;
346  });
347 
348  const HistAxis kTwoBinFHCAxis(
349  "NuE Energy / FHC Analysis Bin", kNue2018Binning, kTwoAnaBinFHC);
350 
351  // 3-bin FHC
352  // - kThreeAnaBinFHC | .54 | .84 | .96 |
353  const Var kThreeSelBinFHC([](const caf::SRProxy *sr)
354  {
355  if(sr->sel.cvnProd3Train.nueid >= 0.54 && sr->sel.cvnProd3Train.nueid < 0.84)
356  return float(0.5);
357  else if(sr->sel.cvnProd3Train.nueid >= 0.84 &&
358  sr->sel.cvnProd3Train.nueid < 0.96)
359  return float(1.5);
360  else if(sr->sel.cvnProd3Train.nueid >= 0.96)
361  return float(2.5);
362  else
363  return float(-5.0);
364  });
365 
366  const Var kThreeAnaBinFHC([](const caf::SRProxy *sr)
367  {
368  int selBin = kThreeSelBinFHC(sr);
369  float nuE = kNueEnergy2018(sr);
370  int nuEBin = nuE/0.5;
371 
372  // TODO: keeps failing this assertion
373  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
374 
375  int anaBin = 9*selBin + nuEBin;
376 
377  return anaBin;
378  });
379 
380  const HistAxis kThreeBinFHCAxis(
381  "NuE Energy / FHC Analysis Bin", kNue2018Binning, kThreeAnaBinFHC);
382 
383  // 4-bin FHC
384  // - kFourAnaBinFHC | .54 | .84 | .96 | .99 |
385  const Var kFourSelBinFHC([](const caf::SRProxy *sr)
386  {
387  if (sr->sel.cvnProd3Train.nueid >= 0.54 &&
388  sr->sel.cvnProd3Train.nueid < 0.84)
389  return float(0.5);
390  else if(sr->sel.cvnProd3Train.nueid >= 0.84 &&
391  sr->sel.cvnProd3Train.nueid < 0.96)
392  return float(1.5);
393  else if(sr->sel.cvnProd3Train.nueid >= 0.96 &&
394  sr->sel.cvnProd3Train.nueid < 0.99)
395  return float(2.5);
396  else if(sr->sel.cvnProd3Train.nueid >= 0.99)
397  return float(3.5);
398  else
399  return float(-5.0);
400  });
401 
402  const Var kFourAnaBinFHC([](const caf::SRProxy *sr)
403  {
404  int selBin = kFourSelBinFHC(sr);
405  float nuE = kNueEnergy2018(sr);
406  int nuEBin = nuE/0.5;
407 
408  // TODO: keeps failing this assertion
409  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
410 
411  int anaBin = 9*selBin + nuEBin;
412 
413  return anaBin;
414  });
415 
416  const HistAxis kFourBinFHCAxis(
417  "NuE Energy / FHC Analysis Bin", kNue2018Binning, kFourAnaBinFHC);
418 
419  // Optimised CVN cuts
420  // FHC --> short-simple --> Sosb
421  const Cut kNueFHCSosbCVNSS([](const caf::SRProxy* sr)
422  {
423  return (sr->sel.cvnProd3Train.nueid > 0.97);
424  });
425  // FHC --> short-simple --> Sossb
426  const Cut kNueFHCSossbCVNSS([](const caf::SRProxy* sr)
427  {
428  return (sr->sel.cvnProd3Train.nueid > 0.86);
429  });
430  // FHC --> ELU --> Sosb
431  const Cut kNueFHCSosbCVNELU([](const caf::SRProxy* sr)
432  {
433  return (sr->sel.cvn.nueid > 0.93);
434  });
435  // FHC --> ELU --> Sossb
436  const Cut kNueFHCSossbCVNELU([](const caf::SRProxy* sr)
437  {
438  return (sr->sel.cvn.nueid > 0.66);
439  });
440  // FHC --> CVN 2017 --> Sosb
441  const Cut kNueFHCSosbCVN2017([](const caf::SRProxy* sr)
442  {
443  return (sr->sel.cvn2017.nueid > 0.96);
444  });
445  // FHC --> CVN 2017 --> Sossb
446  const Cut kNueFHCSossbCVN2017([](const caf::SRProxy* sr)
447  {
448  return (sr->sel.cvn2017.nueid > 0.66);
449  });
450 
451  // RHC --> short-simple --> Sosb
452  const Cut kNueRHCSosbCVNSS([](const caf::SRProxy* sr)
453  {
454  return (sr->sel.cvnProd3Train.nueid > 0.98);
455  });
456  // RHC --> short-simple --> Sossb
457  const Cut kNueRHCSossbCVNSS([](const caf::SRProxy* sr)
458  {
459  return (sr->sel.cvnProd3Train.nueid > 0.89);
460  });
461  // RHC --> ELU --> Sosb
462  const Cut kNueRHCSosbCVNELU([](const caf::SRProxy* sr)
463  {
464  return (sr->sel.cvn.nueid > 0.92);
465  });
466  // RHC --> ELU --> Sossb
467  const Cut kNueRHCSossbCVNELU([](const caf::SRProxy* sr)
468  {
469  return (sr->sel.cvn.nueid > 0.67);
470  });
471  // RHC --> CVN 2017 --> Sosb
472  const Cut kNueRHCSosbCVN2017([](const caf::SRProxy* sr)
473  {
474  return (sr->sel.cvn2017.nueid > 0.94);
475  });
476  // RHC --> CVN 2017 --> Sossb
477  const Cut kNueRHCSossbCVN2017([](const caf::SRProxy* sr)
478  {
479  return (sr->sel.cvn2017.nueid > 0.72);
480  });
481 
482  // ***Numu***
483  // New CVN CAF variales for PIDs
484  //! \f$ \nu_e \f$ CVN short-simple PID
485  const Var kCVNmuSS([](const caf::SRProxy* sr){
486  return sr->sel.cvnProd3Train.numuid;});
487  /// \f$ \nu_e \f$ CVN ELU PID
488  const Var kCVNmuELU([](const caf::SRProxy* sr){
489  return sr->sel.cvn.numuid;});
490  /// \f$ \nu_e \f$ CVN 2017 PID
491  const Var kCVNmu2017([](const caf::SRProxy* sr){
492  return sr->sel.cvn2017.numuid;});
493 
494  //! Full FD Numu selection for 2017 analysis, minus CVN because we
495  //! need to optimise this first
496  const Cut kNumu2017MinusCVN = (kNumuQuality && kNumuContainFD2017 &&
497  kNumuCosmicRej2017);
498 
499  //! Numu RemID cut
500  const Cut kNumu2017remid([](const caf::SRProxy* sr)
501  {
502  return (sr->sel.remid.pid > 0.5);
503  });
504 
505  // Optimised RemID cuts
506  const Cut kNumuFHCSosbRemID([](const caf::SRProxy* sr)
507  {
508  return (sr->sel.remid.pid > 0.99);
509  });
510  const Cut kNumuFHCSossbRemID([](const caf::SRProxy* sr)
511  {
512  return (sr->sel.remid.pid > 0.68);
513  });
514  const Cut kNumuRHCSosbRemID([](const caf::SRProxy* sr)
515  {
516  return (sr->sel.remid.pid > 0.99);
517  });
518  const Cut kNumuRHCSossbRemID([](const caf::SRProxy* sr)
519  {
520  return (sr->sel.remid.pid > 0.69);
521  });
522 
523  // Optimised CVN cuts
524  // FHC --> short-simple --> Sosb
525  const Cut kNumuFHCSosbCVNSS([](const caf::SRProxy* sr)
526  {
527  return (sr->sel.cvnProd3Train.numuid > 0.98);
528  });
529  // FHC --> short-simple --> Sossb
530  const Cut kNumuFHCSossbCVNSS([](const caf::SRProxy* sr)
531  {
532  return (sr->sel.cvnProd3Train.numuid > 0.38);
533  });
534  // FHC --> ELU --> Sosb
535  const Cut kNumuFHCSosbCVNELU([](const caf::SRProxy* sr)
536  {
537  return (sr->sel.cvn.numuid > 0.98);
538  });
539  // FHC --> ELU --> Sossb
540  const Cut kNumuFHCSossbCVNELU([](const caf::SRProxy* sr)
541  {
542  return (sr->sel.cvn.numuid > 0.52);
543  });
544  // FHC --> CVN 2017 --> Sosb
545  const Cut kNumuFHCSosbCVN2017([](const caf::SRProxy* sr)
546  {
547  return (sr->sel.cvn2017.numuid > 0.98);
548  });
549  // FHC --> CVN 2017 --> Sossb
550  const Cut kNumuFHCSossbCVN2017([](const caf::SRProxy* sr)
551  {
552  return (sr->sel.cvn2017.numuid > 0.43);
553  });
554 
555  // RHC --> short-simple --> Sosb
556  const Cut kNumuRHCSosbCVNSS([](const caf::SRProxy* sr)
557  {
558  return (sr->sel.cvnProd3Train.numuid > 0.99);
559  });
560  // RHC --> short-simple --> Sossb
561  const Cut kNumuRHCSossbCVNSS([](const caf::SRProxy* sr)
562  {
563  return (sr->sel.cvnProd3Train.numuid > 0.36);
564  });
565  // RHC --> ELU --> Sosb
566  const Cut kNumuRHCSosbCVNELU([](const caf::SRProxy* sr)
567  {
568  return (sr->sel.cvn.numuid > 0.95);
569  });
570  // RHC --> ELU --> Sossb
571  const Cut kNumuRHCSossbCVNELU([](const caf::SRProxy* sr)
572  {
573  return (sr->sel.cvn.numuid > 0.50);
574  });
575  // RHC --> CVN 2017 --> Sosb
576  const Cut kNumuRHCSosbCVN2017([](const caf::SRProxy* sr)
577  {
578  return (sr->sel.cvn2017.numuid > 0.97);
579  });
580  // RHC --> CVN 2017 --> Sossb
581  const Cut kNumuRHCSossbCVN2017([](const caf::SRProxy* sr)
582  {
583  return (sr->sel.cvn2017.numuid > 0.34);
584  });
585 
586  // ***NC***
587  // New CVN CAF variables for PIDs
588  //! \f$ nc \f$ CVN short-simple PID
589  const Var kCVNncSS([](const caf::SRProxy* sr){
590  return sr->sel.cvnProd3Train.ncid;});
591  //! \f$ nc \f$ CVN ELU PID
592  const Var kCVNncELU([](const caf::SRProxy* sr){
593  return sr->sel.cvn.ncid;});
594  //! \f$ nc \f$ CVN 2017 PID
595  const Var kCVNnc2017([](const caf::SRProxy* sr){
596  return sr->sel.cvn2017.ncid;});
597 
598  //! Full FD Nus selection for 2017 analysis, minus CVN because we
599  //! need to optimise this first
600  const Cut kNus2017MinusCVN = kNus17FDPresel &&
601  kNus17BackwardCut && kNus17NCCosRejAlt &&
602  !(kNus17SlcTimeGap && kNus17SlcDist) &&
603  !(kNus17ShwPtpLow || kNus17ShwPtpHigh) && kNus17EnergyCut;
604 
605  // Optimised CVN cuts
606  // FHC --> short-simple --> Sosb
607  const Cut kNusFHCSosbCVNSS([](const caf::SRProxy* sr)
608  {
609  return (sr->sel.cvnProd3Train.ncid > 0.99);
610  });
611  // FHC --> short-simple --> Sossb
612  const Cut kNusFHCSossbCVNSS([](const caf::SRProxy* sr)
613  {
614  return (sr->sel.cvnProd3Train.ncid > 0.24);
615  });
616  // FHC --> ELU --> Sosb
617  const Cut kNusFHCSosbCVNELU([](const caf::SRProxy* sr)
618  {
619  return (sr->sel.cvn.ncid > 0.97);
620  });
621  // FHC --> ELU --> Sossb
622  const Cut kNusFHCSossbCVNELU([](const caf::SRProxy* sr)
623  {
624  return (sr->sel.cvn.ncid > 0.21);
625  });
626  // FHC --> CVN 2017 --> Sosb
627  const Cut kNusFHCSosbCVN2017([](const caf::SRProxy* sr)
628  {
629  return (sr->sel.cvn2017.ncid > 0.88);
630  });
631  // FHC --> CVN 2017 --> Sossb
632  const Cut kNusFHCSossbCVN2017([](const caf::SRProxy* sr)
633  {
634  return (sr->sel.cvn2017.ncid > 0.24);
635  });
636 
637  // RHC --> short-simple --> Sosb
638  const Cut kNusRHCSosbCVNSS([](const caf::SRProxy* sr)
639  {
640  return (sr->sel.cvnProd3Train.ncid > 0.99);
641  });
642  // RHC --> short-simple --> Sossb
643  const Cut kNusRHCSossbCVNSS([](const caf::SRProxy* sr)
644  {
645  return (sr->sel.cvnProd3Train.ncid > 0.24);
646  });
647  // RHC --> ELU --> Sosb
648  const Cut kNusRHCSosbCVNELU([](const caf::SRProxy* sr)
649  {
650  return (sr->sel.cvn.ncid > 0.99);
651  });
652  // RHC --> ELU --> Sossb
653  const Cut kNusRHCSossbCVNELU([](const caf::SRProxy* sr)
654  {
655  return (sr->sel.cvn.ncid > 0.20);
656  });
657  // RHC --> CVN 2017 --> Sosb
658  const Cut kNusRHCSosbCVN2017([](const caf::SRProxy* sr)
659  {
660  return (sr->sel.cvn2017.ncid > 0.85);
661  });
662  // RHC --> CVN 2017 --> Sossb
663  const Cut kNusRHCSossbCVN2017([](const caf::SRProxy* sr)
664  {
665  return (sr->sel.cvn2017.ncid > 0.22);
666  });
667 
668  //! Get the appropriate list of Vars (including PID Vars)
669  //!
670  //! \param[in] opt TString describing the options you wish to run
671  //! e.g. Nue/Numu/Nus, CVNe2017/AllPIDs, NoPIDCut.
672  //! \param[in] type TString used to filter Vars from the list. For
673  //! example if you just want the PID variables pass "pid" as this
674  //! argument.
675  //! \return vars A vector containing the filtered list of Vars.
676  const std::vector<VarDef> GetVars(TString opt, TString type="all")
677  {
678  std::vector<VarDef> vars;
679 
680  if (opt.Contains("nue", TString::kIgnoreCase))
681  {
682  /// Add Nue PIDs
683  /// Default for Nue is only short simple CVN
684  /// If opt contains CVNeELU --> CVNeShortSimple & CVNeELU
685  /// If opt contains CVNe2017 --> CVNeShortSimple & CVNe2017
686  /// If opt contains AllPIDs --> CVNeShortSimple & CVNeELU & CVNe2017
687  vars.push_back(
688  {"CVNeShortSimple", kCVNeSS, kPIDBinning, "pid", "CVNeShortSimple"});
689  if (!opt.Contains("NoPIDCut", TString::kIgnoreCase))
690  vars.push_back(
691  {"CVNeShortSimpleZoom", kCVNeSS,
692  kPIDZoomBinning, "pid", "CVNeShortSimple"});
693  if (opt.Contains("CVNeELU") ||
694  opt.Contains("AllPIDs", TString::kIgnoreCase))
695  {
696  vars.push_back({"CVNeELU", kCVNeELU, kPIDBinning, "pid", "CVNeELU"});
697  if (!opt.Contains("NoPIDCut", TString::kIgnoreCase))
698  vars.push_back(
699  {"CVNeELUZoom", kCVNeELU, kPIDZoomBinning, "pid", "CVNeELU"});
700  }
701  if (opt.Contains("CVNe2017") ||
702  opt.Contains("AllPIDs", TString::kIgnoreCase))
703  {
704  vars.push_back({"CVNe2017", kCVNe2017, kPIDBinning, "pid", "CVNe2017"});
705  if (!opt.Contains("NoPIDCut", TString::kIgnoreCase))
706  vars.push_back(
707  {"CVNe2017Zoom", kCVNe2017, kPIDZoomBinning, "pid", "CVNe2017"});
708  }
709 
710  if (type.Contains("pid"))
711  return vars;
712 
713  // Add analysis vars
714  // RHC
715  if (!opt.Contains("FHC"))
716  {
717  vars.push_back(
718  {"OneAnaBinRHC", kOneAnaBinRHC,
719  kNue2018Binning, "ana18", "OneAnaBinRHC"});
720  vars.push_back(
721  {"TwoAnaBinRHC", kTwoAnaBinRHC,
722  kNue2018Binning, "ana18", "TwoAnaBinRHC"});
723  vars.push_back(
724  {"TwoAnaBinHiPurRHC", kTwoAnaBinHiPurRHC,
725  kNue2018Binning, "ana18", "TwoAnaBinHiPurRHC"});
726  vars.push_back(
727  {"ThreeAnaBinRHC", kThreeAnaBinRHC,
728  kNue2018Binning, "ana18", "ThreeAnaBinRHC"});
729  vars.push_back(
730  {"FourAnaBinRHC", kFourAnaBinRHC,
731  kNue2018Binning, "ana18", "FourAnaBinRHC"});
732  }
733 
734  // FHC
735  if (!opt.Contains("RHC"))
736  {
737  vars.push_back(
738  {"OneAnaBinFHC", kOneAnaBinFHC,
739  kNue2018Binning, "ana18", "OneAnaBinFHC"});
740  vars.push_back(
741  {"TwoAnaBinFHC", kTwoAnaBinFHC,
742  kNue2018Binning, "ana18", "TwoAnaBinFHC"});
743  vars.push_back(
744  {"ThreeAnaBinFHC", kThreeAnaBinFHC,
745  kNue2018Binning, "ana18", "ThreeAnaBinFHC"});
746  vars.push_back(
747  {"FourAnaBinFHC", kFourAnaBinFHC,
748  kNue2018Binning, "ana18", "FourAnaBinFHC"});
749  }
750 
751  // Add Reco E
752  vars.push_back(
753  {"NueEnergy2018", kNueEnergy2018,
754  kRecoEBinning, "var", "NueEnergy2018"});
755  vars.push_back(
756  {"Nue2018AnaBin", kNue2018AnaBin,
757  kNue2018Binning, "var", "Nue2018AnaBin"});
758  }
759 
760  if (opt.Contains("numu", TString::kIgnoreCase))
761  {
762  /// Add Numu PIDs
763  /// Default for Numu is all PIDs
764  vars.push_back(
765  {"CVNmuShortSimple", kCVNmuSS, kPIDBinning, "pid", "CVNmuShortSimple"});
766  vars.push_back({"CVNmuELU", kCVNmuELU, kPIDBinning, "pid", "CVNmuELU"});
767  vars.push_back(
768  {"CVNmu2017", kCVNmu2017, kPIDBinning, "pid", "CVNmu2017"});
769  if (type.Contains("pid"))
770  return vars;
771 
772  // Add Reco energy
773  vars.push_back({"CCE", kCCE, kRecoEBinning, "var", "CCE"});
774  vars.push_back({"HadE", kHadE, kRecoEBinning, "var", "HadE"});
775  }
776 
777  if (opt.Contains("nus", TString::kIgnoreCase))
778  {
779  /// Add Nus PIDs
780  /// Default for Nus is all PIDs
781  vars.push_back(
782  {"CVNncShortSimple", kCVNncSS, kPIDBinning, "pid", "CVNncShortSimple"});
783  vars.push_back({"CVNncELU", kCVNncELU, kPIDBinning, "pid", "CVNncELU"});
784  vars.push_back(
785  {"CVNnc2017", kCVNnc2017, kPIDBinning, "pid", "CVNnc2017"});
786  if (type.Contains("pid"))
787  return vars;
788 
789  // Add Reco E
790  vars.push_back(
791  {"Nus17Energy", kNus17Energy, kRecoEBinning, "vars", "Nus17Energy"});
792  }
793 
794  // Add visible energy
795  vars.push_back({"TrueEVis", kTrueEVis, kRecoEBinning, "var", "TrueEVis"});
796 
797  // Add mode
798  vars.push_back({"Mode", kMode, kModeBinning, "var", "Mode"});
799 
800  return vars;
801  };
802 
803  //! Get the appropriate list of Cuts (not PID Cuts)
804  //!
805  //! \param[in] opt TString describing the options you wish to run
806  //! e.g. Nue/Numu/Nus, CVNe2017/AllPIDs, NoPIDCut.
807  //! \param[in] pastCuts Boolean switch, includes cuts from previous
808  //! analyses.
809  //! \param[in] noCut Boolean to switch between returning including
810  //! `kNoCut` for reference, or not.
811  //! \return cuts A vector containing the filtered list of Cuts.
812  std::vector<CutDef> GetCuts(TString opt, bool pastCuts=false, bool noCut=true)
813  {
814  std::vector<CutDef> cuts;
815 
816  if (noCut) // default is to always include NoCut option
817  cuts.push_back({"NoCut", kNoCut, "selection"});
818 
819  if (opt.Contains("nue", TString::kIgnoreCase))
820  {
821  cuts.push_back({"Nue2018CorePresel", kNue2018CorePresel, "selection"});
822  if (pastCuts || opt.Contains("CVNe2017", TString::kIgnoreCase))
823  cuts.push_back({"Nue2017CorePresel", kNue2017CorePresel, "selection"});
824  if (pastCuts || opt.Contains("Contain", TString::kIgnoreCase))
825  cuts.push_back({"Nue2018FDNoCVN", kNue2018FDNoCVN, "selection"});
826  }
827 
828  if (opt.Contains("numu", TString::kIgnoreCase))
829  cuts.push_back({"Numu2017MinusCVN", kNumu2017MinusCVN, "selection"});
830 
831  if (opt.Contains("nus", TString::kIgnoreCase))
832  cuts.push_back({"Nus2017MinusCVN", kNus2017MinusCVN, "selection"});
833 
834  return cuts;
835  }; // GetCuts
836 
837  //! Get the appropriate list of weights
838  //!
839  //! \param[in] opt TString describing the options you wish to run
840  //! e.g. Nue/Numu/Nus, CVNe2017/AllPIDs, NoPIDCut.
841  //! \param[in] pastCuts Boolean switch, exclude no weight (default).
842  //! \return weights A vector containing the filtered list of Weights.
843  std::vector<WeightDef> GetWeights(TString opt, bool noWeight=false)
844  {
845  std::vector<WeightDef> weights;
846 
847  if (noWeight) // default is to always include no weight option
848  weights.push_back({"noWeight", kUnweighted});
849  if (opt.Contains("nue", TString::kIgnoreCase))
850  weights.push_back({"XSecCVWgt2018PPFXFluxCVWgt", weight});
851  if (opt.Contains("numu", TString::kIgnoreCase))
852  weights.push_back({"XSecCVWgt2018PPFXFluxCVWgt", weight});
853  if (opt.Contains("nus", TString::kIgnoreCase))
854  weights.push_back({"XSecCVWgt2018PPFXFluxCVWgt", weight});
855 
856  return weights;
857  }; // GetWeights
858 
859 
860  //! Get the appropriate list of PID Cuts
861  //!
862  //! \param[in] opt TString describing the options you wish to run
863  //! e.g. Nue/Numu/Nus, CVNe2017/AllPIDs, NoPIDCut.
864  //! \param[in] noCut Boolean to switch between returning including
865  //! PID `kNoCut` for reference, or not.
866  //! \return pidCuts A vector containing the filtered list of PID
867  //! Cuts.
868  std::vector<std::vector<PIDCutDef> > GetPIDCuts(TString opt, bool noCut=true)
869  {
870  std::vector<std::vector<PIDCutDef> > pidCuts(2);
871 
872  if (noCut) // default is to always include NoCut option
873  {
874  pidCuts[0].push_back({"NoPIDCut", kNoCut, "selection"});
875  pidCuts[1].push_back({"NoPIDCut", kNoCut, "selection"});
876 
877  if (opt.Contains("NoPIDCut", TString::kIgnoreCase))
878  return pidCuts;
879  }
880 
881  if (opt.Contains("nue", TString::kIgnoreCase))
882  {
883  /// Default for Nue is only short simple CVN
884  /// If opt contains CVNeELU --> CVNeShortSimple & CVNeELU
885  /// If opt contains CVNe2017 --> CVNeShortSimple & CVNe2017
886  /// If opt contains AllPIDs --> CVNeShortSimple & CVNeELU & CVNe2017
887 
888  if (!opt.Contains("SosbOnly", TString::kIgnoreCase))
889  {
890  pidCuts[0].push_back({
891  "CVNeShortSimpleSossb", kNueFHCSossbCVNSS, "pidCut"});
892  pidCuts[1].push_back({
893  "CVNeShortSimpleSossb", kNueRHCSossbCVNSS, "pidCut"});
894  }
895  if (!opt.Contains("SossbOnly", TString::kIgnoreCase))
896  {
897  pidCuts[0].push_back(
898  {"CVNeShortSimpleSosb", kNueFHCSosbCVNSS, "pidCut"});
899  pidCuts[1].push_back(
900  {"CVNeShortSimpleSosb", kNueRHCSosbCVNSS, "pidCut"});
901  }
902 
903  if (opt.Contains("CVNeELU") ||
904  opt.Contains("AllPIDs", TString::kIgnoreCase))
905  {
906  if (!opt.Contains("SosbOnly", TString::kIgnoreCase))
907  {
908  pidCuts[0].push_back({"CVNeELUSossb", kNueFHCSossbCVNELU, "pidCut"});
909  pidCuts[1].push_back({"CVNeELUSossb", kNueRHCSossbCVNELU, "pidCut"});
910  }
911  if (!opt.Contains("SossbOnly", TString::kIgnoreCase))
912  {
913  pidCuts[0].push_back({"CVNeELUSosb", kNueFHCSosbCVNELU, "pidCut"});
914  pidCuts[1].push_back({"CVNeELUSosb", kNueRHCSosbCVNELU, "pidCut"});
915  }
916  }
917 
918  if (opt.Contains("CVNe2017") ||
919  opt.Contains("AllPIDs", TString::kIgnoreCase))
920  {
921  if (!opt.Contains("SosbOnly", TString::kIgnoreCase))
922  {
923  pidCuts[0].push_back(
924  {"CVNe2017Sossb", kNueFHCSossbCVN2017, "pidCut"});
925  pidCuts[1].push_back(
926  {"CVNe2017Sossb", kNueRHCSossbCVN2017, "pidCut"});
927  }
928  if (!opt.Contains("SossbOnly", TString::kIgnoreCase))
929  {
930  pidCuts[0].push_back({"CVNe2017Sosb", kNueFHCSosbCVN2017, "pidCut"});
931  pidCuts[1].push_back({"CVNe2017Sosb", kNueRHCSosbCVN2017, "pidCut"});
932  }
933  }
934  }
935 
936  if (opt.Contains("numu", TString::kIgnoreCase))
937  {
938  /// Default for Numu is all cuts at the moment
939  /// Fill FHC branch
940  pidCuts[0].push_back({
941  "CVNmuShortSimpleSosb", kNumuFHCSosbCVNSS, "pidCut"});
942  pidCuts[0].push_back({
943  "CVNmuShortSimpleSossb", kNumuFHCSossbCVNSS, "pidCut"});
944  pidCuts[0].push_back({"CVNmuELUSosb", kNumuFHCSosbCVNELU, "pidCut"});
945  pidCuts[0].push_back({"CVNmuELUSossb", kNumuFHCSossbCVNELU, "pidCut"});
946  pidCuts[0].push_back({"CVNmu2017Sosb", kNumuFHCSosbCVN2017, "pidCut"});
947  pidCuts[0].push_back({"CVNmu2017Sossb", kNumuFHCSossbCVN2017, "pidCut"});
948 
949  /// Fill RHC branch
950  pidCuts[1].push_back({
951  "CVNmuShortSimpleSosb", kNumuRHCSosbCVNSS, "pidCut"});
952  pidCuts[1].push_back({
953  "CVNmuShortSimpleSossb", kNumuRHCSossbCVNSS, "pidCut"});
954  pidCuts[1].push_back({"CVNmuELUSosb", kNumuRHCSosbCVNELU, "pidCut"});
955  pidCuts[1].push_back({"CVNmuELUSossb", kNumuRHCSossbCVNELU, "pidCut"});
956  pidCuts[1].push_back({"CVNmu2017Sosb", kNumuRHCSosbCVN2017, "pidCut"});
957  pidCuts[1].push_back({"CVNmu2017Sossb", kNumuRHCSossbCVN2017, "pidCut"});
958  }
959 
960  if (opt.Contains("nus", TString::kIgnoreCase))
961  {
962  /// Default for Nus is all cuts at the moment
963  /// Fill FHC branch
964  pidCuts[0].push_back({
965  "CVNncShortSimpleSosb", kNusFHCSosbCVNSS, "pidCut"});
966  pidCuts[0].push_back({
967  "CVNncShortSimpleSossb", kNusFHCSossbCVNSS, "pidCut"});
968  pidCuts[0].push_back({"CVNncELUSosb", kNusFHCSosbCVNELU, "pidCut"});
969  pidCuts[0].push_back({"CVNncELUSossb", kNusFHCSossbCVNELU, "pidCut"});
970  pidCuts[0].push_back({"CVNnc2017Sosb", kNusFHCSosbCVN2017, "pidCut"});
971  pidCuts[0].push_back({"CVNnc2017Sossb", kNusFHCSossbCVN2017, "pidCut"});
972 
973  /// Fill RHC branch
974  pidCuts[1].push_back({
975  "CVNncShortSimpleSosb", kNusRHCSosbCVNSS, "pidCut"});
976  pidCuts[1].push_back({
977  "CVNncShortSimpleSossb", kNusRHCSossbCVNSS, "pidCut"});
978  pidCuts[1].push_back({"CVNncELUSosb", kNusRHCSosbCVNELU, "pidCut"});
979  pidCuts[1].push_back({"CVNncELUSossb", kNusRHCSossbCVNELU, "pidCut"});
980  pidCuts[1].push_back({"CVNnc2017Sosb", kNusRHCSosbCVN2017, "pidCut"});
981  pidCuts[1].push_back({"CVNnc2017Sossb", kNusRHCSossbCVN2017, "pidCut"});
982  }
983 
984  return pidCuts;
985  };
986 }// namespace ana
987 
988 #endif
const Binning kModeBinning
const Var kCVNeSS([](const caf::SRProxy *sr){return sr->sel.cvnProd3Train.nueid;})
CVN short-simple PID
const TString cutName
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const TString type
const Binning kYBinning
const TString polarity
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const TString weightName
const Var weight
const TString name
Struct to hold prediction information.
Struct to hold weight information.
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2109
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:597
const TString polarity
const Var kTrueEVis([](const caf::SRProxy *sr){if(sr->mc.nu.empty()) return 0.;double ret=sr->mc.nu[0].E;if(!sr->mc.nu[0].iscc) ret *=sr->mc.nu[0].y;return ret;})
const TString type
Struct to hold PID cut information.
const Var kOneAnaBinRHC([](const caf::SRProxy *sr){int selBin=kOneSelBinRHC(sr);float nuE=kNueEnergy2018(sr);int nuEBin=nuE/0.5;assert(nuEBin<=8 &&"An event with nuE > 4.5 should never happen");int anaBin=9 *selBin+nuEBin;return anaBin;})
const TString pidCutName
const Var kCVNeELU([](const caf::SRProxy *sr){return sr->sel.cvn.nueid;})
CVN ELU PID
const TString name
const IPrediction * prediction
const Binning binning
_Var< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:74
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const TString cutName
caf::Proxy< float > closestslicetime
Definition: SRProxy.h:1281
const Binning kXvertexBinning
const TString shortName
const Var kNueEnergy2018([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;if(kIsRHC(sr)) return kNueEnergyRHC(sr);else return kNueEnergyFHC(sr);})
Definition: NueEnergy2018.h:25
const TString name
caf::Proxy< caf::SRCVNResult > cvn
Definition: SRProxy.h:1232
caf::Proxy< float > nueid
Definition: SRProxy.h:885
const Cut Energy
Struct to hold Var/plot information.
const TString name
Struct to hold cut information.
const Binning kYvertexBinning
const Binning kPIDBinning
caf::StandardRecord * sr
const std::map< std::pair< std::string, std::string >, Variable > vars
caf::Proxy< float > closestsliceminfromtop
Definition: SRProxy.h:1278
const Cut kNue2018CorePresel
Definition: NueCuts2018.h:37
const Binning kZvertexBinning
const Binning kPIDZoomBinning
Structure to hold Spectra information.
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2121
const Var var
const TString pidCutName
const TString varName
const TString type
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2125
const Cut kNue2018FDNoCVN
Full FD nue selection for 2018 analysis - with all CVN dependence removed.
const Cut cut
double Mode(TH1D *hist)
Definition: DedxComp.C:173
caf::Proxy< float > closestslicemindist
Definition: SRProxy.h:1273
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
const Spectrum * spectrum
const Cut kNearestSliceCosRejCoreNoCVN([](const caf::SRProxy *sr){if(kNue2018CorePresel(sr)){return!(sr->slc.closestslicetime >-100.&& sr->slc.closestslicetime< 100.&& sr->slc.closestsliceminfromtop< 400 && sr->slc.closestslicemindist< 500.);}return false;})
assert(nhit_max >=nhit_nbins)
const Var kOneSelBinRHC([](const caf::SRProxy *sr){if(sr->sel.cvnProd3Train.nueid >=0.89) return float(0.5);else return float(-5.0);})
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const Var kCVNe2017([](const caf::SRProxy *sr){return sr->sel.cvn2017.nueid;})
CVN 2017 PID
caf::Proxy< caf::SRIDBranch > sel
Definition: SRProxy.h:2124
const Binning kRecoEBinning
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:114
const TString varName
const TString weightName