Skip to content

Commit e32c139

Browse files
committed
updated rew
1 parent 65c565c commit e32c139

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

interface/ReWeightingOperator.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
std::string filew_name_;
1616
std::string osample_;
1717
std::vector<std::string> sam_list_;
18+
std::vector<std::string> hist_list_;
1819
TFile filew_;
19-
TH1F hw_;
20+
std::vector<TH1F> hw_;
2021

2122
ReWeightingOperator(std::string filew_name, std::string osample) :
2223
filew_name_(filew_name),
@@ -25,11 +26,17 @@
2526
sam_list_ = {"SM","BM2","BM3","BM4","BM5","BM6",
2627
"BM7","BM8","BM9","BM10","BM11","BM12","BM13","BMbox"};
2728

29+
//DEBUG - edit with same order of same list!
30+
hist_list_ = {"SM","BM2","BM3","BM4","BM5","BM6",
31+
"BM7","BM8","BM9","BM10","BM11","BM12","BM13","BMbox"};
32+
2833
//get histogram related to sample
2934
std::string hanme = osample; //DEBUG
3035
filew_ = TFile::Open(filew_name.c_str());
31-
hw_ = (TH1F*)filew_.Get(hanme.c_str());
32-
36+
for (int i=0; i<hist_list_.size(); i++) {
37+
TH1F h = (TH1F)filew_.Get(hist_list_.at(i).c_str());
38+
hw_.push_back(h);
39+
}
3340
}
3441

3542
virtual ~ReWeightingOperator() {}
@@ -45,7 +52,7 @@
4552
weight_map["ReWeighting_"+sam] = 1.0;
4653
}
4754

48-
for (const auto & sam : sam_list_) {
55+
for (unsigned int i=0; i<sam_list_.size(); i++) {
4956

5057
//example on how to call ev variables
5158
float costh = ev.tl_genhh_.at(0).costhst();
@@ -56,9 +63,9 @@
5663
float mergecostSum = 0;
5764
// for ii in range(1,11) : mergecostSum+= sumHBenchBin.GetBinContent(bmhh,ii) DEBUG
5865
if (mergecostSum >0) {
59-
weight = (hw_.GetBinContent(mhh,costh) / mergecostSum);
66+
weight = (hw_.at(i).GetBinContent(mhh,costh) / mergecostSum);
6067
}
61-
weight_map.at("ReWeighting_"+sam) *= weight;
68+
weight_map.at("ReWeighting_"+sam_list_.at(i)) *= weight;
6269
}
6370

6471
// add weights to event info

0 commit comments

Comments
 (0)