MichelTaggingSyst.cxx
Go to the documentation of this file.
2 
4 #include "CAFAna/Core/Var.h"
5 #include "CAFAna/Vars/Vars.h"
6 
8 
9 namespace ana
10 {
11  // 2020 version
12  // Doing it the easiest way possible, copy the 2018 version only
14  {
15  if(sr->me.nslc != sr->me.slc.size()){
16  std::cout << "me.nslc (" << sr->me.nslc << ") does not match "
17  << "me.slc.size() (" << sr->me.slc.size() << ")..."
18  << std::endl;
19  }
20 
21  if(sr->me.nkalman != sr->me.trkkalman.size()){
22  std::cout << "me.nkalman (" << sr->me.nkalman << ") does not match "
23  << "me.trkkalman.size() (" << sr->me.trkkalman.size() << ")..."
24  << std::endl;
25  }
26 
27  // for the random numbers
28  int hash = Hash(sr);
29  fMRnd.SetSeed(hash);
30 
31  // are shifting the MEs UP or DOWN?
32  double fProb = (sigma >= 0) ? fProbUP : fProbDO;
33 
34  // force to pass/fail MID and deltat criteria in me.slc
35  for(caf::SRSlcMEProxy& slc: sr->me.slc){
36  if(std::abs(slc.truth.pdg) == 11 &&
37  fMRnd.Uniform() < std::abs(sigma*fProb)){
38  slc.mid = (sigma >= 0) ? 4.0 : -1.0;
39  if(slc.deltat <= 1200.) slc.deltat = 1201.;
40  }
41  }
42 
43  // force to pass/fail MID and deltat criteria in trkkalman
44  for(caf::SRTrkMEProxy& trk: sr->me.trkkalman){
45  if(std::abs(trk.truth.pdg) == 11 &&
46  fMRnd.Uniform() < std::abs(sigma*fProb)){
47  trk.mid = (sigma >= 0) ? 4.0 : -1.0;
48  if(trk.deltat <= 1200.) trk.deltat = 1201.;
49  }
50  }
51  }
52 
53  // --------------------------------------------------------------------------
54  // Jeremy's trick for random numbers
56  {
57  std::size_t seed = 0;
58  std::vector<unsigned int> evtNums {sr->hdr.run, sr->hdr.subrun, (unsigned int)(sr->hdr.cycle), sr->hdr.evt, sr->hdr.subevt};
59  for (auto v : evtNums)
60  seed ^= std::hash<unsigned int>{}(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
61  return seed;
62  }
63 
65 
66  // --------------------------------------------------------------------------
68  {
69  if(sr->me.nslc != sr->me.slc.size()){
70  std::cout << "me.nslc (" << sr->me.nslc << ") does not match "
71  << "me.slc.size() (" << sr->me.slc.size() << ")..."
72  << std::endl;
73  }
74 
75  if(sr->me.nkalman != sr->me.trkkalman.size()){
76  std::cout << "me.nkalman (" << sr->me.nkalman << ") does not match "
77  << "me.trkkalman.size() (" << sr->me.trkkalman.size() << ")..."
78  << std::endl;
79  }
80 
81  // for the random numbers
82  int hash = Hash(sr);
83  fMRnd.SetSeed(hash);
84 
85  // are shifting the MEs UP or DOWN?
86  double fProb = (sigma >= 0) ? fProbUP : fProbDO;
87 
88  // force to pass/fail MID and deltat criteria in me.slc
89  for(caf::SRSlcMEProxy& slc: sr->me.slc){
90  if(std::abs(slc.truth.pdg) == 11 &&
91  fMRnd.Uniform() < std::abs(sigma*fProb)){
92  slc.mid = (sigma >= 0) ? 1.0 : -1.0;
93  if(slc.deltat <= 800.) slc.deltat = 801.;
94  }
95  }
96 
97  // force to pass/fail MID and deltat criteria in trkkalman
98  for(caf::SRTrkMEProxy& trk: sr->me.trkkalman){
99  if(std::abs(trk.truth.pdg) == 11 &&
100  fMRnd.Uniform() < std::abs(sigma*fProb)){
101  trk.mid = (sigma >= 0) ? 1.0 : -1.0;
102  if(trk.deltat <= 800.) trk.deltat = 801.;
103  }
104  }
105  }
106 
107  // --------------------------------------------------------------------------
108  // Jeremy's trick for random numbers
110  {
111  std::size_t seed = 0;
112  std::vector<unsigned int> evtNums {sr->hdr.run, sr->hdr.subrun, (unsigned int)(sr->hdr.cycle), sr->hdr.evt, sr->hdr.subevt};
113  for (auto v : evtNums)
114  seed ^= std::hash<unsigned int>{}(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
115  return seed;
116  }
117 
119 }
caf::Proxy< size_t > nslc
Definition: SRProxy.h:715
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
caf::Proxy< std::vector< caf::SRTrkME > > trkkalman
Definition: SRProxy.h:720
caf::Proxy< unsigned int > subrun
Definition: SRProxy.h:253
caf::Proxy< std::vector< caf::SRSlcME > > slc
Definition: SRProxy.h:716
const Var weight
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2136
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2125
caf::Proxy< caf::SRMichelE > me
Definition: SRProxy.h:2138
float abs(float number)
Definition: d0nt_math.hpp:39
caf::Proxy< unsigned int > run
Definition: SRProxy.h:247
Track finder for cosmic rays.
caf::Proxy< size_t > nkalman
Definition: SRProxy.h:714
caf::Proxy< short unsigned int > subevt
Definition: SRProxy.h:249
unsigned int seed
Definition: runWimpSim.h:102
caf::StandardRecord * sr
caf::Proxy< int > cycle
Definition: SRProxy.h:229
double sigma(TH1F *hist, double percentile)
const MichelTaggingSyst2020 kMichelTaggingSyst2020
caf::Proxy< unsigned int > evt
Definition: SRProxy.h:236
OStream cout
Definition: OStream.cxx:6
void Shift(double sigma, caf::SRProxy *sr, double &weight) const override
Perform the systematic shift.
const MichelTaggingSyst2018 kMichelTaggingSyst2018
int Hash(caf::SRProxy *sr) const
int Hash(caf::SRProxy *sr) const
void Shift(double sigma, caf::SRProxy *sr, double &weight) const override
Perform the systematic shift.