TimingCuts.cxx
Go to the documentation of this file.
2 
4 
6 
7 namespace ana
8 {
9  /// \brief Apply a time window plus additionally cut the 1usec at the
10  /// start/end of CVNVeto windows, while correctly computing livetime.
11  ///
12  /// See docdb 42766 for the CVNVeto itself and docdb 42952 for the problems
13  /// in the first/last usec of each window.
14  ///
15  /// The window edges are passed as integers to make the calculations simpler
16  ///
17  /// \param tlo First time (in usec) that should be included in the window
18  /// \param thi Last time (in usec) that should be included in the window
19  Cut CVNVetoOverlapWindowCut(int tlo, int thi)
20  {
21  return Cut([tlo, thi](const caf::SRProxy* sr)
22  {
23  const double t = sr->slc.meantime / 1000.;
24  const double w = sr->spill.cosmiccvn[0].timeWinMin / 1000.;
25  const double delta = t - w;
26 
27  return (delta > 1 && delta <= 15) && (t >= tlo && t <= thi);
28  },
29  [tlo, thi](const caf::SRSpillProxy* spill)
30  {
31  // Zero indicates the beginning of one of the overlapped
32  // 16usec windows. One would correspond to the end of one of
33  // those windows. Use addition of a constant so that we don't
34  // have to think about what modulus of a negative number
35  // means.
36  const int phaselo = (tlo+144)%15;
37  const int phasehi = (thi+144)%15;
38 
39  // Rounds down, so this is the number of CVN windows that fit
40  // completely within the overall window. We definitely lose
41  // this many 1usec edges.
42  int nEdges = (thi-tlo)/15;
43 
44  // Things are lined up correctly to include one more window
45  // edge within our range.
46  if(phasehi < phaselo) ++nEdges;
47 
48  // Units are seconds
49  return 1e-6 * (thi - tlo - nEdges);
50  });
51  }
52 
53 
54  // This is only for the (2020) MR* studies
55  //
56  // CosmicCVN was not run on the MR* files, so no need to cut out the regions
57  // at the edges of the CVNCosmic windows.
58  Cut WindowCut_FD_MR(int tlo, int thi)
59  {
60  return Cut([tlo, thi](const caf::SRProxy* sr)
61  {
62  const double t = sr->slc.meantime / 1000.;
63  return (t >= tlo && t <= thi);
64  },
65  [tlo, thi](const caf::SRSpillProxy* spill)
66  {
67  // Units are seconds
68  return 1e-6 * (thi - tlo);
69  });
70  }
71 
72 
73  // Implementation details for kInBeamSpill
80 
81  const Cut kInBeamSpill(
82  [](const caf::SRProxy* sr)
83  {
85  return kInBeamSpill_main(sr);
86  else
87  return kInBeamSpill_main(sr) || kInBeamSpill_shifted(sr);
88  },
89  [](const caf::SRSpillProxy* spill)
90  {
92  return kInBeamSpill_main.Livetime(spill);
93  else
94  return kInBeamSpill_main.Livetime(spill) + kInBeamSpill_shifted.Livetime(spill);
95  },
96  [](const caf::SRSpillProxy* spill) -> double
97  {
98 
99  // Decided not to do the below and take this as a systematic instead...
100  return spill->spillpot;
101 
102  /*
103  if(spill->run > util::kLastBadTimingRun){
104  return spill->spillpot;
105  }
106  else{
107  // 1usec is lost from the second window. Approx 40% of our events are
108  // in the second window (6/15), and we lose 1us/10us. This is only a 4%
109  // effect in the bad period, which makes up <5% of our total
110  // dataset. See docdb 42952.
111  return (1 - .4*.1) * spill->spillpot;
112  }
113  */
114  }
115  );
116 
117 
118  // Implementation details for kInTimingSideband
125 
126  // The two parts that the "after" window is split into by the +64usec shifted window
133 
134 
135  const Cut kInTimingSideband(
136  [](const caf::SRProxy* sr)
137  {
139  return (kInTimingSideband_before(sr) ||
141  else
142  return (kInTimingSideband_before(sr) ||
145  },
146  [](const caf::SRSpillProxy* spill)
147  {
148  if(spill->run > util::kLastBadTimingRun)
149  return (kInTimingSideband_before.Livetime(spill) +
150  kInTimingSideband_after.Livetime(spill));
151  else
152  return (kInTimingSideband_before.Livetime(spill) +
153  kInTimingSideband_afterA.Livetime(spill) +
154  kInTimingSideband_afterB.Livetime(spill));
155  },
156  [](const caf::SRSpillProxy* spill)
157  {
158  // Out of time with the beam -> no POT
159  return 0;
160  }
161  );
162 
163 
164  // Away from the beginning and end of the spill
167 
168  //Again, the same as the above cut, but adjusted for use for the (2020) MR*
169  //studies by removing all mention of CosmicCVN
172 
173 }
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2125
const Cut kInBeamSpill_main
Definition: TimingCuts.cxx:74
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Cut WindowCut_FD_MR(int tlo, int thi)
Definition: TimingCuts.cxx:58
double Livetime(const caf::SRSpillProxy *spill) const
Provide a Livetime function if your cut is a timing cut etc.
Definition: Cut.h:39
const int kBeamWindowMinMicroSec
double delta
Definition: runWimpSim.h:98
const int kLastBadTimingRun
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2108
const int kBeamWindowShiftedMinMicroSec
const int kMinTimingSidebandAfterShiftedWindowMicroSec
const Cut kInTimingSideband_afterB
Definition: TimingCuts.cxx:130
const int kMinTimingSidebandAfterMicroSec
const int kBeamWindowMaxMicroSec
const int kMaxTimingSidebandBeforeShiftedWindowMicroSec
const int kMaxTimingSidebandBeforeMicroSec
const Cut kInTimingSideband([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return(kInTimingSideband_before(sr)|| kInTimingSideband_after(sr));else return(kInTimingSideband_before(sr)|| kInTimingSideband_afterA(sr)|| kInTimingSideband_afterB(sr));}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_after.Livetime(spill));else return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_afterA.Livetime(spill)+ kInTimingSideband_afterB.Livetime(spill));}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:12
const int kMinTimingSidebandBeforeMicroSec
const Cut kInCosmicTimingWindow
Is the event far from the start and ends of the spill ? For FD cosmic selection.
Definition: TimingCuts.cxx:165
const int kBeamWindowShiftedMaxMicroSec
const Cut kInTimingSideband_afterA
Definition: TimingCuts.cxx:127
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
Definition: Cut.h:96
caf::StandardRecord * sr
const Cut kInTimingSideband_after
Definition: TimingCuts.cxx:122
caf::Proxy< std::vector< caf::SRCosmicCVN > > cosmiccvn
Definition: SRProxy.h:1337
const Cut kInTimingSideband_before
Definition: TimingCuts.cxx:119
caf::Proxy< caf::SRSlice > slc
Definition: SRProxy.h:2124
caf::Proxy< unsigned int > run
Definition: SRProxy.h:1385
caf::Proxy< float > meantime
Definition: SRProxy.h:1290
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const Cut kInBeamSpill_shifted
Definition: TimingCuts.cxx:77
const Cut kInCosmicTimingWindow_FD_MR
Definition: TimingCuts.cxx:170
Float_t e
Definition: plot.C:35
Cut CVNVetoOverlapWindowCut(int tlo, int thi)
Apply a time window plus additionally cut the 1usec at the start/end of CVNVeto windows, while correctly computing livetime.
Definition: TimingCuts.cxx:19
Float_t w
Definition: plot.C:20
const int kMaxTimingSidebandAfterMicroSec