forked from h2gglobe/h2gglobe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterferenceSmearer.cc
85 lines (72 loc) · 2.53 KB
/
InterferenceSmearer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "InterferenceSmearer.h"
#include "PhotonReducedInfo.h"
#include "TRandom3.h"
#include "TMath.h"
#include <assert.h>
#include "Macros/Normalization_8TeV.h"
InterferenceSmearer::InterferenceSmearer(Normalization_8TeV* norm, double *genCosTheta, bool isConst, float correction, float error, std::string histFile) :
norm_(norm), genCosTheta_(genCosTheta), isConst_(isConst), correction_(correction), error_(error)
{
name_="InterferenceSmearer";
if (histFile != ""){
histFile_ = TFile::Open(histFile.c_str());
assert(histFile_);
TH1 *temp = (TH1F*)histFile_->Get("cosTheta_interference_ggh_m125");
assert(temp!=0);
reweightHist_ggh_ = (TH1F*) temp->Clone("cTinterf_ggh_m125");
reweightHist_ggh_->SetDirectory(0);
temp = (TH1F*)histFile_->Get("cosTheta_interference_gg_grav_m125");
assert(temp!=0);
reweightHist_gg_grav_ = (TH1F*) temp->Clone("cTinterf_gg_grav_m125");
reweightHist_gg_grav_->SetDirectory(0);
histFile_->Close();
delete histFile_;
}
else {
reweightHist_ggh_ = 0;
reweightHist_gg_grav_ = 0;
}
}
// --- this constructor is for back compatibility ----
InterferenceSmearer::InterferenceSmearer(Normalization_8TeV* norm, float correction, float error)
{
InterferenceSmearer(norm,NULL,true,correction,error,"");
}
InterferenceSmearer::~InterferenceSmearer()
{
/*
if (!isConst_) {
histFile_->Close();
delete histFile_;
}
*/
}
bool InterferenceSmearer::smearEvent( float & weight, const TLorentzVector & p4, const int nPu, const int sample_type, float syst_shift ) const
{
int genMassPoint;
if( sample_type >= 0 ) { return true; }
genMassPoint = std::round(norm_->GetMass(sample_type));
if( norm_->GetProcess(sample_type) != "ggh" && norm_->GetProcess(sample_type) != "gg_grav") {
return true;
}
if( genMassPoint > 150 ) { genMassPoint=150; } // Warning: missing k-factor
if( genMassPoint == 100 ) { genMassPoint=105; } // Warning: missing k-factor
//cout << "IntSmear: " << isConst_ << " ";
// const interenference
if (isConst_) {
weight = 1.-(correction_+syst_shift*error_);
}
// cos theta dependent interference
else {
TH1 *reweightHist = 0;
if (norm_->GetProcess(sample_type) == "ggh") reweightHist = reweightHist_ggh_;
else if (norm_->GetProcess(sample_type) == "gg_grav") reweightHist = reweightHist_gg_grav_;
else assert(0);
assert(reweightHist);
assert(genCosTheta_);
//cout << "genCosTheta: " << *genCosTheta_ << " ";
weight = 1.+(reweightHist->GetBinContent(reweightHist->FindBin(TMath::Abs(*genCosTheta_)))/100.);
}
//cout << "wt: " << weight << endl;
return true;
}