1 |
arizzi |
1.1 |
#ifndef TRIGGERWEIGHT_H
|
2 |
|
|
#define TRIGGERWEIGHT_H
|
3 |
|
|
|
4 |
|
|
#include "FWCore/ParameterSet/interface/ProcessDesc.h"
|
5 |
|
|
#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
|
6 |
arizzi |
1.4 |
#include "VHbbAnalysis/VHbbDataFormats/interface/TriggerZnunuCurve.h"
|
7 |
|
|
#include "VHbbAnalysis/VHbbDataFormats/interface/MultiThresholdEfficiency.h"
|
8 |
arizzi |
1.1 |
#include <TH1F.h>
|
9 |
arizzi |
1.3 |
#include <TF1.h>
|
10 |
arizzi |
1.1 |
#include <TFile.h>
|
11 |
|
|
#include <TTree.h>
|
12 |
|
|
#include <iostream>
|
13 |
|
|
|
14 |
|
|
class TriggerWeight
|
15 |
|
|
{
|
16 |
|
|
public:
|
17 |
arizzi |
1.4 |
TriggerWeight(const edm::ParameterSet& ana) : tscaleHLTele1(0),tscaleHLTele2(0),tscaleHLTeleJet1(0),tscaleHLTeleJet2(0),tscaleIDele(0), tscaleHLTmu(0), tscaleIDmu(0),combiner2Thr(2)
|
18 |
arizzi |
1.1 |
{
|
19 |
arizzi |
1.4 |
tscaleHLTmu=openFile(ana,"hltMuFileName");
|
20 |
|
|
tscaleIDmu=openFile(ana,"idMuFileName");
|
21 |
|
|
tscaleHLTele1=openFile(ana,"hltEle1FileName");
|
22 |
|
|
tscaleHLTele2=openFile(ana,"hltEle2FileName");
|
23 |
|
|
tscaleIDele=openFile(ana,"idEleFileName");
|
24 |
|
|
tscaleHLTeleJet1=openFile(ana,"hltJetEle1FileName");
|
25 |
|
|
tscaleHLTeleJet2=openFile(ana,"hltJetEle2FileName");
|
26 |
|
|
|
27 |
arizzi |
1.1 |
if(tscaleHLTmu == 0 || tscaleIDmu == 0)
|
28 |
|
|
{
|
29 |
|
|
std::cout << "ERROR: cannot load Muon Trigger efficiencies" << std::endl;
|
30 |
|
|
}
|
31 |
arizzi |
1.4 |
|
32 |
|
|
|
33 |
arizzi |
1.1 |
|
34 |
|
|
}
|
35 |
arizzi |
1.4 |
|
36 |
|
|
TTree * openFile(const edm::ParameterSet& ana, const char * name)
|
37 |
|
|
{
|
38 |
|
|
TFile *hltMuFile = new TFile (ana.getParameter<std::string> ("hltMuFileName").c_str(),"read");
|
39 |
|
|
if(hltMuFile) return (TTree*) hltMuFile->Get("tree");
|
40 |
|
|
else return 0;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
std::pair<float,float> efficiencyFromPtEta(float pt1, float eta1, TTree *t)
|
44 |
|
|
{
|
45 |
|
|
float s1 = 1.,err=1.;
|
46 |
|
|
std::pair<float,float> r(s1,err);
|
47 |
|
|
if(!t) return r;
|
48 |
|
|
float ptMin,ptMax,etaMin,etaMax,scale,error;
|
49 |
|
|
int count = 0;
|
50 |
|
|
t->SetBranchAddress("ptMin",&ptMin);
|
51 |
|
|
t->SetBranchAddress("ptMax",&ptMax);
|
52 |
|
|
t->SetBranchAddress("etaMin",&etaMin);
|
53 |
|
|
t->SetBranchAddress("etaMax",&etaMax);
|
54 |
|
|
t->SetBranchAddress("scale",&scale);
|
55 |
|
|
t->SetBranchAddress("error",&error);
|
56 |
|
|
|
57 |
|
|
for(int jentry = 0; jentry < t->GetEntries(); jentry++)
|
58 |
|
|
{
|
59 |
|
|
t->GetEntry(jentry);
|
60 |
|
|
if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
|
61 |
|
|
{
|
62 |
|
|
s1 = scale;
|
63 |
|
|
err=error;
|
64 |
|
|
count++;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
if(count == 0 || s1 == 0)
|
69 |
|
|
{
|
70 |
|
|
return r;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
r.first=s1;
|
74 |
|
|
r.second = err;
|
75 |
|
|
return (r);
|
76 |
|
|
}
|
77 |
arizzi |
1.1 |
|
78 |
|
|
float scaleMuIsoHLT(float pt1, float eta1)
|
79 |
|
|
{
|
80 |
arizzi |
1.4 |
return efficiencyFromPtEta(pt1,eta1,tscaleHLTmu).first;
|
81 |
|
|
/* if(!tscaleHLTmu) return 1;
|
82 |
arizzi |
1.1 |
float ptMin,ptMax,etaMin,etaMax,scale,error;
|
83 |
|
|
float s1 = 0;
|
84 |
|
|
int count = 0;
|
85 |
|
|
tscaleHLTmu->SetBranchAddress("ptMin",&ptMin);
|
86 |
|
|
tscaleHLTmu->SetBranchAddress("ptMax",&ptMax);
|
87 |
|
|
tscaleHLTmu->SetBranchAddress("etaMin",&etaMin);
|
88 |
|
|
tscaleHLTmu->SetBranchAddress("etaMax",&etaMax);
|
89 |
|
|
tscaleHLTmu->SetBranchAddress("scale",&scale);
|
90 |
|
|
tscaleHLTmu->SetBranchAddress("error",&error);
|
91 |
|
|
|
92 |
|
|
for(int jentry = 0; jentry < tscaleHLTmu->GetEntries(); jentry++)
|
93 |
|
|
{
|
94 |
|
|
tscaleHLTmu->GetEntry(jentry);
|
95 |
|
|
if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
|
96 |
|
|
{
|
97 |
|
|
s1 = scale;
|
98 |
|
|
count++;
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
if(count == 0 || s1 == 0)
|
103 |
|
|
{
|
104 |
|
|
//caleFile->Close();
|
105 |
|
|
return 1;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
//aleFile->Close();
|
110 |
arizzi |
1.4 |
return (s1);*/
|
111 |
arizzi |
1.1 |
}
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
float scaleMuID(float pt1, float eta1)
|
116 |
|
|
{
|
117 |
arizzi |
1.4 |
return efficiencyFromPtEta(pt1,eta1,tscaleIDmu).first;
|
118 |
|
|
|
119 |
arizzi |
1.3 |
// changed to !tscale...
|
120 |
|
|
if(!tscaleIDmu) return 1;
|
121 |
arizzi |
1.1 |
|
122 |
|
|
float ptMin,ptMax,etaMin,etaMax,scale,error;
|
123 |
|
|
float s1 = 0;
|
124 |
|
|
int count = 0;
|
125 |
|
|
tscaleIDmu->SetBranchAddress("ptMin",&ptMin);
|
126 |
|
|
tscaleIDmu->SetBranchAddress("ptMax",&ptMax);
|
127 |
|
|
tscaleIDmu->SetBranchAddress("etaMin",&etaMin);
|
128 |
|
|
tscaleIDmu->SetBranchAddress("etaMax",&etaMax);
|
129 |
|
|
tscaleIDmu->SetBranchAddress("scale",&scale);
|
130 |
|
|
tscaleIDmu->SetBranchAddress("error",&error);
|
131 |
|
|
|
132 |
|
|
for(int jentry = 0; jentry < tscaleIDmu->GetEntries(); jentry++)
|
133 |
|
|
{
|
134 |
|
|
|
135 |
|
|
tscaleIDmu->GetEntry(jentry);
|
136 |
|
|
if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
|
137 |
|
|
{
|
138 |
|
|
s1 = scale;
|
139 |
|
|
count++;
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
if(count == 0 || s1 == 0)
|
144 |
|
|
{
|
145 |
|
|
//caleFile->Close();
|
146 |
|
|
return 1;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
//aleFile->Close();
|
150 |
|
|
return (s1);
|
151 |
|
|
|
152 |
|
|
}
|
153 |
|
|
|
154 |
arizzi |
1.3 |
double scaleMetHLT( double met){
|
155 |
|
|
|
156 |
|
|
float s1 = 1;
|
157 |
|
|
TF1 * f = new TF1 ("f",TriggerZnunuCurve::trigMet, 0,99999, 0, "triggerZnunuCurve" );
|
158 |
|
|
|
159 |
|
|
s1 = f->Eval(met);
|
160 |
|
|
|
161 |
|
|
return (s1);
|
162 |
|
|
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
|
166 |
arizzi |
1.4 |
double scaleJet30Jet25( std::vector<float> eta, std::vector<float> pt)
|
167 |
|
|
{
|
168 |
|
|
return 1;
|
169 |
|
|
// if(!tscaleEleJet1) return 1;
|
170 |
|
|
// if(!tscaleEleJet2) return 1;
|
171 |
|
|
vector<vector<float > > bah;
|
172 |
|
|
combiner2Thr.weight<Trigger1High2Loose>(bah);
|
173 |
|
|
}
|
174 |
arizzi |
1.3 |
|
175 |
|
|
|
176 |
|
|
|
177 |
arizzi |
1.1 |
private:
|
178 |
arizzi |
1.4 |
TTree * tscaleHLTele1;
|
179 |
|
|
TTree * tscaleHLTele2;
|
180 |
|
|
TTree * tscaleHLTeleJet1;
|
181 |
|
|
TTree * tscaleHLTeleJet2;
|
182 |
|
|
TTree * tscaleIDele;
|
183 |
|
|
|
184 |
arizzi |
1.1 |
TTree * tscaleHLTmu;
|
185 |
|
|
TTree * tscaleIDmu;
|
186 |
arizzi |
1.4 |
MultiThresholdEfficiency combiner2Thr;
|
187 |
arizzi |
1.1 |
};
|
188 |
|
|
|
189 |
|
|
#endif
|