Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ana2019::fakedata::KeepMCEventFunc Class Reference
Inheritance diagram for ana2019::fakedata::KeepMCEventFunc:
ana2019::fakedata::KeepEvtFunc ana2019::fakedata::EvtHashRNG

Public Member Functions

 KeepMCEventFunc (double keepProb, double NCwgt, std::map< std::pair< int, int >, unsigned int > *kept=nullptr)
 
bool operator() (const caf::SRProxy *sr)
 
auto EventsKept () const
 
virtual bool Keep (const caf::SRSpillProxy *sr)
 
virtual bool Keep (const caf::SRProxy *sr)
 
void SetKeepProb (double prob)
 
TRandom * RNG ()
 
void SetSeed (std::size_t seed)
 

Protected Member Functions

bool Keep (std::size_t hash)
 

Private Attributes

double fNCwgt
 
osc::OscCalcPMNSOpt fCalc
 
std::map< std::pair< int, int >, unsigned int > * fEventsKept
 

Detailed Description

Functional for deciding whether to keep an MC event based on a fixed probability (e.g., POT-based) and on oscillation probability. Can be passed to a CAFAna Cut object as its internal function

Definition at line 106 of file generate_fd_fake_events.C.

Constructor & Destructor Documentation

ana2019::fakedata::KeepMCEventFunc::KeepMCEventFunc ( double  keepProb,
double  NCwgt,
std::map< std::pair< int, int >, unsigned int > *  kept = nullptr 
)
inline

'keepProb' is for all events (depends on POT only). 'NCwgt' is because we get NCs from all the swap files too and have too many unless we weight them down... you can pass in 'kept' in case you want to know what kind of events were retained...

Definition at line 113 of file generate_fd_fake_events.C.

References ana::ResetOscCalcToDefault().

114  : KeepEvtFunc(keepProb), fNCwgt(NCwgt), fEventsKept(kept)
115  {
117  }
void ResetOscCalcToDefault(osc::IOscCalcAdjustable *calc)
Reset calculator to default assumptions for all parameters.
Definition: Calcs.cxx:23
std::map< std::pair< int, int >, unsigned int > * fEventsKept

Member Function Documentation

auto ana2019::fakedata::KeepMCEventFunc::EventsKept ( ) const
inline

Definition at line 144 of file generate_fd_fake_events.C.

145  {
146  return fEventsKept;
147  }
std::map< std::pair< int, int >, unsigned int > * fEventsKept
virtual bool ana2019::fakedata::KeepEvtFunc::Keep ( const caf::SRSpillProxy sr)
inlinevirtualinherited

Definition at line 68 of file generate_fd_fake_events.C.

References ana::Hash().

69  {
70  return Keep(Hash(sr));
71  }
virtual bool Keep(const caf::SRSpillProxy *sr)
std::size_t Hash(const std::vector< std::size_t > &vals)
Generate a unique hash from a sequence of integers.
Definition: Utilities.cxx:384
virtual bool ana2019::fakedata::KeepEvtFunc::Keep ( const caf::SRProxy sr)
inlinevirtualinherited

Definition at line 73 of file generate_fd_fake_events.C.

References caf::Proxy< caf::SRHeader >::cycle, samweb_client.utility::hash, ana::Hash(), caf::Proxy< caf::StandardRecord >::hdr, caf::Proxy< caf::StandardRecord >::spill, and caf::Proxy< caf::SRHeader >::subevt.

74  {
75  auto hash = Hash({Hash(&sr->spill), (std::size_t)(sr->hdr.cycle), sr->hdr.subevt});
76  return Keep(hash);
77  }
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2143
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
virtual bool Keep(const caf::SRSpillProxy *sr)
caf::Proxy< short unsigned int > subevt
Definition: SRProxy.h:250
caf::Proxy< int > cycle
Definition: SRProxy.h:230
std::size_t Hash(const std::vector< std::size_t > &vals)
Generate a unique hash from a sequence of integers.
Definition: Utilities.cxx:384
bool ana2019::fakedata::KeepEvtFunc::Keep ( std::size_t  hash)
inlineprotectedinherited

Definition at line 86 of file generate_fd_fake_events.C.

References samweb_client.utility::hash.

87  {
88  if (hash != fLastHash)
89  {
90  SetSeed(hash);
91  fLastHash = hash;
92  }
93 
94  return RNG()->Uniform() < fKeepProb;
95  }
bool ana2019::fakedata::KeepMCEventFunc::operator() ( const caf::SRProxy sr)
inline

Definition at line 120 of file generate_fd_fake_events.C.

References sanity_check_grl::keep, make_pair(), caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRTruthBranch >::nnu, caf::Proxy< caf::SRTruthBranch >::nu, and caf::Proxy< caf::StandardRecord >::spill.

121  {
122  // short-circuit on the POT prob to avoid doing oscillation prob calculations unnecessarily
123  if (!Keep(&sr->spill))
124  return false;
125 
126  if (sr->mc.nnu != 1)
127  return false;
128 
129  bool keep;
130  if (sr->mc.nu[0].iscc)
131  keep = RNG()->Uniform() < fCalc.P(sr->mc.nu[0].pdgorig, sr->mc.nu[0].pdg, sr->mc.nu[0].E);
132  else
133  keep = RNG()->Uniform() < fNCwgt;
134 
135  if (keep && fEventsKept)
136  {
137  auto flav = sr->mc.nu[0].iscc ? (std::make_pair(sr->mc.nu[0].pdgorig, sr->mc.nu[0].pdg))
138  : (std::make_pair(0, 0));
139  (*fEventsKept)[flav]++;
140  }
141  return keep;
142  }
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2143
std::map< std::pair< int, int >, unsigned int > * fEventsKept
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
virtual bool Keep(const caf::SRSpillProxy *sr)
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
T P(int flavBefore, int flavAfter, double E) override
E in GeV; flavors as PDG codes (so, neg==>antinu)
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
TRandom* ana2019::fakedata::EvtHashRNG::RNG ( )
inlineinherited

Definition at line 52 of file generate_fd_fake_events.C.

void ana2019::fakedata::KeepEvtFunc::SetKeepProb ( double  prob)
inlineinherited

Definition at line 79 of file generate_fd_fake_events.C.

80  {
81  fKeepProb = prob;
82  }
void ana2019::fakedata::EvtHashRNG::SetSeed ( std::size_t  seed)
inlineinherited

Definition at line 53 of file generate_fd_fake_events.C.

53 { fRng.SetSeed(seed); }
unsigned int seed
Definition: runWimpSim.h:102

Member Data Documentation

osc::OscCalcPMNSOpt ana2019::fakedata::KeepMCEventFunc::fCalc
mutableprivate

Definition at line 151 of file generate_fd_fake_events.C.

std::map<std::pair<int, int>, unsigned int>* ana2019::fakedata::KeepMCEventFunc::fEventsKept
mutableprivate

Definition at line 153 of file generate_fd_fake_events.C.

double ana2019::fakedata::KeepMCEventFunc::fNCwgt
private

Definition at line 150 of file generate_fd_fake_events.C.


The documentation for this class was generated from the following file: