Skip to content

Commit 65c565c

Browse files
committed
reweighting op updated
1 parent 2b544a3 commit 65c565c

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

interface/ReWeightingOperator.h

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@
1212

1313
public:
1414

15-
int a_;
16-
std::vector<std::string> sam_list;
17-
18-
ReWeightingOperator( int a) :
19-
a_(a)
20-
{
21-
sam_list = {"SM","BM2","BM3","BM4","BM5","BM6",
15+
std::string filew_name_;
16+
std::string osample_;
17+
std::vector<std::string> sam_list_;
18+
TFile filew_;
19+
TH1F hw_;
20+
21+
ReWeightingOperator(std::string filew_name, std::string osample) :
22+
filew_name_(filew_name),
23+
osample_(osample)
24+
{
25+
sam_list_ = {"SM","BM2","BM3","BM4","BM5","BM6",
2226
"BM7","BM8","BM9","BM10","BM11","BM12","BM13","BMbox"};
27+
28+
//get histogram related to sample
29+
std::string hanme = osample; //DEBUG
30+
filew_ = TFile::Open(filew_name.c_str());
31+
hw_ = (TH1F*)filew_.Get(hanme.c_str());
32+
2333
}
2434

2535
virtual ~ReWeightingOperator() {}
@@ -30,22 +40,24 @@
3040
std::map<std::string, float> weight_map;
3141

3242
// inititialize all weights to 1.0 - safety
33-
for (const auto & sam : sam_list) {
43+
for (const auto & sam : sam_list_) {
3444
// at(syst) would return exception when no element exists
3545
weight_map["ReWeighting_"+sam] = 1.0;
3646
}
3747

38-
for (const auto & sam : sam_list) {
48+
for (const auto & sam : sam_list_) {
3949

4050
//example on how to call ev variables
41-
float costh = ev.dihiggs_.at(0).costhst();
42-
float mhh = ev.dihiggs_.at(0).mass();
51+
float costh = ev.tl_genhh_.at(0).costhst();
52+
float mhh = ev.tl_genhh_.at(0).mass();
4353

4454
//code to get weight
45-
//...........
4655
float weight = 1.;
47-
//code to get weight
48-
56+
float mergecostSum = 0;
57+
// for ii in range(1,11) : mergecostSum+= sumHBenchBin.GetBinContent(bmhh,ii) DEBUG
58+
if (mergecostSum >0) {
59+
weight = (hw_.GetBinContent(mhh,costh) / mergecostSum);
60+
}
4961
weight_map.at("ReWeighting_"+sam) *= weight;
5062
}
5163

0 commit comments

Comments
 (0)