|
DAS
3.0
Das Analysis System
|
Generic structure to hold the histograms and indices corresponding to one variation, for any observable using TUnfoldBinning
.
This class is intended to be used in getUnfHist
only.
#include <DistVariation.h>
|
std::unique_ptr< TH1 > | rec |
|
std::unique_ptr< TH1 > | tmp |
|
std::unique_ptr< TH1 > | gen |
|
std::unique_ptr< TH1 > | missNoMatch |
|
std::unique_ptr< TH1 > | missOut |
|
std::unique_ptr< TH1 > | fakeNoMatch |
|
std::unique_ptr< TH1 > | fakeOut |
|
std::unique_ptr< TH2 > | cov |
|
std::unique_ptr< TH2 > | RM |
|
const TString | group |
|
const TString | name |
|
const std::size_t | index |
|
const int | bit |
|
◆ ~DistVariation()
Destructor.
109 auto apply_to_all = [](
auto&&
f,
auto&& ... x) { (
f(x),...); };
112 auto check_bin_contents_1D = [](
auto&& h) {
114 if (h->GetEntries() == 0)
115 cerr <<
orange << h->GetName() <<
" is empty" <<
def <<
'\n';
116 if (h->GetBinContent(0) > 0)
117 cerr <<
orange << h->GetName() <<
"'s underflow is not empty\n" <<
def;
118 if (h->GetBinContent(h->GetNbinsX()+1) > 0)
119 cerr <<
orange << h->GetName() <<
"'s overflow is not empty\n" <<
def;
121 apply_to_all(check_bin_contents_1D,
125 auto check_bin_contents_2D = [](
auto&& h) {
128 int nBinsX = h->GetNbinsX();
129 int nBinsY = h->GetNbinsY();
131 bool underflowFilled =
false,
132 overflowFilled =
false;
133 for (
int i = 1; i <= nBinsX; ++i) {
134 underflowFilled |= h->GetBinContent(i,0) > 0;
135 overflowFilled |= h->GetBinContent(i,nBinsY+1) > 0;
138 cerr <<
orange << h->GetName() <<
"'s underflow on horizontal axis is not empty\n" <<
def;
140 cerr <<
orange << h->GetName() <<
"'s overflow on horizontal axis is not empty\n" <<
def;
142 underflowFilled =
false;
143 overflowFilled =
false;
144 for (
int i = 1; i <= nBinsX; ++i) {
145 underflowFilled |= h->GetBinContent(0,i) > 0;
146 overflowFilled |= h->GetBinContent(nBinsX+1,0) > 0;
149 cerr <<
orange << h->GetName() <<
"'s underflow on vertical axis is not empty\n" <<
def;
151 cerr <<
orange << h->GetName() <<
"'s overflow on vertical axis is not empty\n" <<
def;
153 apply_to_all(check_bin_contents_2D,
RM,
cov);
157 bool genClosure =
true, recClosure =
true;
158 auto checkbin = [](
const unique_ptr<TH1>& h,
int i) {
159 auto content = h->GetBinContent(i);
160 bool ok = std::abs(content - 1) <
feps || std::abs(content) <
feps;
161 if (!ok)
cerr <<
orange <<
"| " << i <<
" " << content <<
"\n" <<
def;
165 auto RMx = unique_ptr<TH1>(
RM->ProjectionX());
168 RMx->Divide(
gen.get());
169 for (
int i = 1; i <= RMx->GetNbinsX(); ++i)
170 genClosure &= checkbin(RMx, i);
172 auto RMy = unique_ptr<TH1>(
RM->ProjectionY());
175 RMy->Divide(
rec.get());
176 for (
int i = 1; i <= RMy->GetNbinsX(); ++i)
177 recClosure &= checkbin(RMy, i);
180 cerr <<
red <<
name <<
" is not closing at rec level" <<
'\n' <<
def;
182 cerr <<
red <<
name <<
" is not closing at gen level" <<
'\n' <<
def;
◆ DistVariation() [1/3]
DistVariation |
( |
const TString & |
group, |
|
|
const TString & |
name, |
|
|
size_t |
index = 0 , |
|
|
int |
bit = 0 |
|
) |
| |
Normal constructor.
24 cout <<
"|- Setting up " << __func__ <<
" `" <<
name <<
"`." << endl;
27 BOOST_THROW_EXCEPTION( runtime_error(
"Particle-level binning has not been defined") );
29 BOOST_THROW_EXCEPTION( runtime_error(
"Detector-level binning has not been defined") );
38 auto makeRec = [
this,
name](TString subname, TString title) {
39 auto h = unique_ptr<TH1>(
recBinning->CreateHistogram(
name + subname,
40 false,
nullptr, title +
" (detector level)"));
41 h->GetXaxis()->SetTitle(
"rec");
44 rec = makeRec(
"rec",
"all");
45 tmp = makeRec(
"tmp",
"temporary object to calculate covariance");
55 false,
nullptr,
"covariance matrix (detector level)"));
56 cov->GetXaxis()->SetTitle(
"rec");
57 cov->GetYaxis()->SetTitle(
"rec");
60 auto makeGen = [
this,
name](TString subname, TString title) {
61 auto h = unique_ptr<TH1>(
genBinning->CreateHistogram(
name + subname,
62 false,
nullptr, title +
" (particle level)"));
63 h->GetXaxis()->SetTitle(
"gen");
66 gen = makeGen(
"gen" ,
"all");
67 missNoMatch = makeGen(
"missNoMatch",
"truly unmatched");
68 missOut = makeGen(
"missOut" ,
"matched out of the phase space");
69 fakeNoMatch = makeRec(
"fakeNoMatch",
"truly unmatched");
70 fakeOut = makeRec(
"fakeOut" ,
"matched out of the phase space");
80 name +
"RM",
false,
false,
"response matrix"));
81 RM->GetXaxis()->SetTitle(
"gen");
82 RM->GetYaxis()->SetTitle(
"rec");
◆ DistVariation() [2/3]
copy constructor
56 rec (std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.rec ->Clone()))),
57 tmp (std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.tmp ->Clone()))),
58 gen (std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.gen ->Clone()))),
59 missNoMatch(std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.missNoMatch->Clone()))),
60 missOut (std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.missOut ->Clone()))),
61 fakeNoMatch(std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.fakeNoMatch->Clone()))),
62 fakeOut (std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(v.fakeOut ->Clone()))),
63 cov (std::unique_ptr<TH2>(
dynamic_cast<TH2*
>(v.cov ->Clone()))),
64 RM (std::unique_ptr<TH2>(
dynamic_cast<TH2*
>(v.RM ->Clone())))
◆ DistVariation() [3/3]
move constructor
71 rec(std::move(v.rec)),
tmp(std::move(v.tmp)),
gen(std::move(v.gen)),
74 cov(std::move(v.cov)),
RM(std::move(v.RM))
◆ Write()
void Write |
( |
TDirectory * |
d | ) |
|
Create a subdirectory to the directory given in argument where all histograms are written.
87 cout <<
"Writing " <<
name << endl;
89 TDirectory * dd = d->mkdir(
name);
91 auto write = [
this,dd](
auto&& h) {
93 TString n = h->GetName();
94 n.ReplaceAll(
name,
"");
98 auto apply_to_all = [](
auto&&
f,
auto&& ... x) { (
f(x),...); };
◆ cov
◆ fakeNoMatch
std::unique_ptr<TH1> fakeNoMatch |
background (unmatched entries)
◆ fakeOut
std::unique_ptr<TH1> fakeOut |
background (migration out of phase space)
◆ gen
generated-level distribution
◆ genBinning
TUnfoldBinning * genBinning = nullptr |
|
static |
full binning at particle level
◆ isMC
◆ missNoMatch
std::unique_ptr<TH1> missNoMatch |
losses (unmatched entries)
◆ missOut
std::unique_ptr<TH1> missOut |
losses (migration out of phase space)
◆ rec
reconstructed-level distribution
◆ recBinning
TUnfoldBinning * recBinning = nullptr |
|
static |
full binning at detector level
◆ RM
◆ tmp
temporary histogram help fill the covariance matrix
The documentation for this struct was generated from the following files:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Unfolding/interface/DistVariation.h
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Unfolding/src/DistVariation.cc
static bool isMC
flag from metainfo
Definition: DistVariation.h:27
cerr
Definition: Ntupliser_cfg.py:93
std::unique_ptr< TH1 > rec
reconstructed-level distribution
Definition: DistVariation.h:32
static const char * def
Definition: Step.h:36
const TString name
variation name (including "Up" or "Down")
Definition: Variation.h:25
f
Definition: Ntupliser_cfg.py:255
static TUnfoldBinning * recBinning
full binning at detector level
Definition: DistVariation.h:30
static const char * red
Definition: Step.h:34
static const auto feps
Definition: DistVariation.cc:17
const int bit
correlation bit
Definition: Variation.h:28
static const char * orange
Definition: colours.h:6
std::unique_ptr< TH2 > cov
covariance matrix
Definition: DistVariation.h:41
std::unique_ptr< TH1 > gen
generated-level distribution
Definition: DistVariation.h:34
std::unique_ptr< TH1 > tmp
temporary histogram help fill the covariance matrix
Definition: DistVariation.h:33
std::unique_ptr< TH1 > missNoMatch
losses (unmatched entries)
Definition: DistVariation.h:35
const TString group
e.g. event, recjet
Definition: Variation.h:24
std::unique_ptr< TH2 > RM
response matrix
Definition: DistVariation.h:42
std::unique_ptr< TH1 > missOut
losses (migration out of phase space)
Definition: DistVariation.h:36
std::unique_ptr< TH1 > fakeNoMatch
background (unmatched entries)
Definition: DistVariation.h:37
static TUnfoldBinning * genBinning
full binning at particle level
Definition: DistVariation.h:29
Definition: Variation.h:22
const std::size_t index
index in the vector where the variation factor is stored
Definition: Variation.h:27
std::unique_ptr< TH1 > fakeOut
background (migration out of phase space)
Definition: DistVariation.h:38