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