SpectrumSink.h
Go to the documentation of this file.
1 #pragma once
2 
4 
7 
8 #include "CAFAna/Core/Var.h"
9 #include "CAFAna/Core/MultiVar.h"
10 
12 
13 namespace ana
14 {
15  // --------------------------------------------------------------------------
16  template<class T> class SpectrumSinkBase: public IRecordSink, public IExposureSink
17  {
18  public:
19  SpectrumSinkBase(T* s) : fSpect(s) {fSpect->AddLoader(&fSpect);}
20  ~SpectrumSinkBase() {if(fSpect) fSpect->RemoveLoader(&fSpect);}
21 
22  void HandlePOT(double pot) override;
23  void HandleLivetime(double t) override;
24 
25  int NSinks() const override {return 1;}
26 
27  protected:
28  T* fSpect; ///< May be null if Spectrum deregisters itself
29  };
30 
31  // --------------------------------------------------------------------------
32  class SpectrumSink: public SpectrumSinkBase<Spectrum>
33  {
34  public:
36  : SpectrumSinkBase(s), fVar(v)
37  {
38  }
39 
40  void HandleRecord(caf::SRProxy* sr, double wei) override;
41  protected:
43  };
44 
45  // --------------------------------------------------------------------------
46  class MultiVarSpectrumSink: public SpectrumSinkBase<Spectrum>
47  {
48  public:
50  : SpectrumSinkBase(s), fVar(v)
51  {
52  }
53 
54  void HandleRecord(caf::SRProxy* sr, double wei) override;
55  protected:
57  };
58 
59  // --------------------------------------------------------------------------
60  class ReweightableSpectrumSink: public SpectrumSinkBase<ReweightableSpectrum>
61  {
62  public:
64  const Var& rwv,
66  : SpectrumSinkBase(s), fVar(v), fRWVar(rwv)
67  {
68  }
69 
70  void HandleRecord(caf::SRProxy* sr, double wei) override;
71  protected:
72  Var fVar, fRWVar;
73  };
74 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void HandlePOT(double pot) override
virtual void HandleRecord(caf::SRProxy *sr, double wei)=0
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Spectrum with the value of a second variable, allowing for reweighting
void HandleLivetime(double t) override
MultiVarSpectrumSink(const MultiVar &v, Spectrum *s)
Definition: SpectrumSink.h:49
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const XML_Char * s
Definition: expat.h:262
ReweightableSpectrumSink(const Var &v, const Var &rwv, ReweightableSpectrum *s)
Definition: SpectrumSink.h:63
#define pot
caf::StandardRecord * sr
int NSinks() const override
Definition: SpectrumSink.h:25
T * fSpect
May be null if Spectrum deregisters itself.
Definition: SpectrumSink.h:28
double T
Definition: Xdiff_gwt.C:5
SpectrumSink(const Var &v, Spectrum *s)
Definition: SpectrumSink.h:35