DAS  3.0
Das Analysis System
Observable.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <list>
5 #include <memory>
6 #include <optional>
7 #include <utility>
8 
9 #include <Eigen/Dense>
10 
11 #include <TString.h>
12 #include <TTreeReader.h>
13 #include <TUnfoldBinning.h>
14 
16 
17 class TH1;
18 class TH2;
19 
20 namespace DAS::Unfolding {
21 
38 template<class T>
39 auto initOptionalBranch(TTreeReader& reader, const char *name)
40 {
41  return reader.GetTree()->GetBranch(name) != nullptr
42  ? std::make_optional<typename T::value_type>(reader, name)
43  : std::nullopt;
44 }
45 
56 struct Filler {
59  virtual ~Filler () = default;
60 
66  virtual std::list<int> fillRec (DistVariation&);
67 
70  virtual void match ();
71 
74  virtual void fillMC (DistVariation&);
75 };
76 
85 class Transformer {
86 
87 protected:
88 
89  //static int offset; //!< number of bins before the present distribution in original binning
90 
93  static void AddAxis (TUnfoldBinning *,
94  TUnfoldBinning *,
95  int
96  );
97 
98 public:
99 
100  static Eigen::VectorXd y;
101 
102  TUnfoldBinning * preBinning,
104 
107  virtual ~Transformer () = default;
108 
111  virtual void Transform
112  (const Eigen::VectorXd&
113  ) const;
114 
117  virtual void RemoveBadInputBins (TH1 *,
118  TH2 *
119  );
120 
125  Transformer (TUnfoldBinning *,
126  bool = true
127  );
128 };
129 
142 struct Observable {
143 
144  static bool isMC;
145  static double maxDR;
147 
148  // The following objects may be used either directly in `getUnfHist` command
149  TUnfoldBinning * recBinning,
151 
154  virtual std::unique_ptr<Filler> getFiller (TTreeReader& reader) const;
155 
158  virtual std::unique_ptr<Transformer> getTransformer (TUnfoldBinning *) const;
159 
162  virtual void setLmatrix (const std::unique_ptr<TH1>&,
163  std::unique_ptr<TH2>&
164  );
165 
166  virtual ~Observable () = default;
167 protected:
168 
171  Observable (const char *, const char *);
172 };
173 
176 std::vector<Observable *> GetObservables
177  (boost::property_tree::ptree
178  );
179 
180 } // end of namespace DAS::Unfolding
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
DAS::Unfolding::Transformer::AddAxis
static void AddAxis(TUnfoldBinning *, TUnfoldBinning *, int)
Copy the axis of the source binning object into the target binning object.
Definition: Observable.cc:87
DAS::Unfolding::Transformer::postBinning
TUnfoldBinning * postBinning
target binning
Definition: Observable.h:103
DAS::Unfolding::Filler::fillMC
virtual void fillMC(DistVariation &)
Fill RM, gen, miss, fake histograms for a given variation.
Definition: Observable.cc:80
DAS::Unfolding::Transformer::Transformer
Transformer(TUnfoldBinning *, bool=true)
Definition: Observable.cc:96
DAS::Unfolding::Observable::getFiller
virtual std::unique_ptr< Filler > getFiller(TTreeReader &reader) const
Constructs a filler for the observable. By default, a dummy filler is returned.
Definition: Observable.cc:72
DAS::Unfolding::Observable::getTransformer
virtual std::unique_ptr< Transformer > getTransformer(TUnfoldBinning *) const
Constructs a filler for the observable. By default, no operation is applied.
Definition: Observable.cc:82
DAS::Unfolding::Transformer
Definition: Observable.h:85
DAS::Unfolding::Observable::genBinning
TUnfoldBinning * genBinning
particle-level binning
Definition: Observable.h:150
DAS::Unfolding::Filler::match
virtual void match()
Implementation of matching algorithm.
Definition: Observable.cc:79
DAS::Unfolding
Definition: getToyCalculation.cc:37
DAS::Unfolding::Observable::~Observable
virtual ~Observable()=default
DAS::Unfolding::Transformer::preBinning
TUnfoldBinning * preBinning
source binning (either rec or gen level)
Definition: Observable.h:102
DAS::Unfolding::DistVariation
Definition: DistVariation.h:25
DAS::Unfolding::Transformer::~Transformer
virtual ~Transformer()=default
Destructor.
DAS::Unfolding::Filler
Definition: Observable.h:56
DAS::Unfolding::Observable::setLmatrix
virtual void setLmatrix(const std::unique_ptr< TH1 > &, std::unique_ptr< TH2 > &)
Construct regularisation matrix.
Definition: Observable.cc:38
DAS::Unfolding::Observable::Observable
Observable(const char *, const char *)
Constructor.
Definition: Observable.cc:26
DAS::Unfolding::Observable::isMC
static bool isMC
Definition: Observable.h:144
DAS::Unfolding::Filler::~Filler
virtual ~Filler()=default
Destructor.
DAS::Unfolding::initOptionalBranch
auto initOptionalBranch(TTreeReader &reader, const char *name)
Definition: Observable.h:39
DAS::Unfolding::Filler::fillRec
virtual std::list< int > fillRec(DistVariation &)
Definition: Observable.cc:78
DAS::Unfolding::Transformer::Transform
virtual void Transform(const Eigen::VectorXd &) const
Copies the input distribution by default.
Definition: Observable.cc:144
DAS::Unfolding::Transformer::y
static Eigen::VectorXd y
output vector
Definition: Observable.h:100
DAS::Unfolding::Transformer::RemoveBadInputBins
virtual void RemoveBadInputBins(TH1 *, TH2 *)
Remove bins with too low coverage for Gaussian hypothesis.
Definition: Observable.cc:122
DistVariation.h
DAS::Unfolding::Observable::recBinning
TUnfoldBinning * recBinning
detector-level binning
Definition: Observable.h:149
DAS::Unfolding::GetObservables
std::vector< Observable * > GetObservables(boost::property_tree::ptree)
Get the observables to unfold.
Definition: Observable.cc:43
DAS::Unfolding::Observable
Definition: Observable.h:142
DAS::Unfolding::Observable::maxDR
static double maxDR
max Delta R
Definition: Observable.h:146