SpectrumSink.cxx
Go to the documentation of this file.
2 
3 #include "CAFAna/Core/Spectrum.h"
5 
6 #include <iostream>
7 
8 namespace ana
9 {
10  // --------------------------------------------------------------------------
11  bool CheckVal(double val, const char* detail)
12  {
13  if(std::isnan(val) || std::isinf(val)){
14  std::cerr << "Warning: Bad value: " << val
15  << " returned from " << detail
16  << ". The input variable(s) could "
17  << "be NaN in the CAF, or perhaps your "
18  << "Var code computed 0/0?";
19  std::cout << ". Not filling into this histogram for this slice." << std::endl;
20  return false;
21  }
22  return true;
23  }
24 
25  // --------------------------------------------------------------------------
26  template<class T> void SpectrumSinkBase<T>::HandlePOT(double pot)
27  {
28  if(fSpect) fSpect->fPOT += pot;
29  }
30 
31  // --------------------------------------------------------------------------
32  template<class T> void SpectrumSinkBase<T>::HandleLivetime(double t)
33  {
34  if(fSpect) fSpect->fLivetime += t;
35  }
36 
37  // --------------------------------------------------------------------------
39  {
40  if(!fSpect) return;
41  const double val = fVar(sr);
42  if(CheckVal(val, "a Var")) fSpect->Fill(val, wei);
43  }
44 
45  // --------------------------------------------------------------------------
47  {
48  if(!fSpect) return;
49  for(double val: fVar(sr))
50  if(CheckVal(val, "a MultiVar")) fSpect->Fill(val, wei);
51  }
52 
53  // --------------------------------------------------------------------------
55  {
56  if(!fSpect) return;
57  const double val = fVar(sr);
58  const double rwval = fRWVar(sr);
59  if(CheckVal(val, "a Var") && CheckVal(rwval, "a reweighting Var"))
60  fSpect->Fill(val, rwval, wei);
61  }
62 }
int isinf(const stan::math::var &a)
Definition: std_isinf.hpp:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void HandlePOT(double pot) override
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
OStream cerr
Definition: OStream.cxx:7
void Fill(double x, double w=1)
Definition: Spectrum.cxx:293
void HandleLivetime(double t) override
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
void HandleRecord(caf::SRProxy *sr, double wei) override
#define pot
caf::StandardRecord * sr
Spectrum * fSpect
May be null if Spectrum deregisters itself.
Definition: SpectrumSink.h:28
OStream cout
Definition: OStream.cxx:6
void HandleRecord(caf::SRProxy *sr, double wei) override
bool CheckVal(double val, const char *detail)
void HandleRecord(caf::SRProxy *sr, double wei) override