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 |
|
|
#include <TH1F.h>
|
7 |
|
|
#include <TFile.h>
|
8 |
|
|
#include <TTree.h>
|
9 |
|
|
#include <iostream>
|
10 |
|
|
|
11 |
|
|
class TriggerWeight
|
12 |
|
|
{
|
13 |
|
|
public:
|
14 |
|
|
TriggerWeight(const edm::ParameterSet& ana) : tscaleHLTmu(0), tscaleIDmu(0)
|
15 |
|
|
{
|
16 |
|
|
TFile *hltMuFile = new TFile (ana.getParameter<std::string> ("hltMuFileName").c_str(),"read");
|
17 |
|
|
if(hltMuFile) tscaleHLTmu = (TTree*) hltMuFile->Get("tree");
|
18 |
|
|
TFile *idMuFile = new TFile (ana.getParameter<std::string> ("idMuFileName").c_str(),"read");
|
19 |
|
|
if(idMuFile) tscaleIDmu = (TTree*) idMuFile->Get("tree");
|
20 |
|
|
|
21 |
|
|
if(tscaleHLTmu == 0 || tscaleIDmu == 0)
|
22 |
|
|
{
|
23 |
|
|
std::cout << "ERROR: cannot load Muon Trigger efficiencies" << std::endl;
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
float scaleMuIsoHLT(float pt1, float eta1)
|
31 |
|
|
{
|
32 |
|
|
|
33 |
|
|
if(tscaleHLTmu) return 1;
|
34 |
|
|
float ptMin,ptMax,etaMin,etaMax,scale,error;
|
35 |
|
|
float s1 = 0;
|
36 |
|
|
int count = 0;
|
37 |
|
|
tscaleHLTmu->SetBranchAddress("ptMin",&ptMin);
|
38 |
|
|
tscaleHLTmu->SetBranchAddress("ptMax",&ptMax);
|
39 |
|
|
tscaleHLTmu->SetBranchAddress("etaMin",&etaMin);
|
40 |
|
|
tscaleHLTmu->SetBranchAddress("etaMax",&etaMax);
|
41 |
|
|
tscaleHLTmu->SetBranchAddress("scale",&scale);
|
42 |
|
|
tscaleHLTmu->SetBranchAddress("error",&error);
|
43 |
|
|
|
44 |
|
|
for(int jentry = 0; jentry < tscaleHLTmu->GetEntries(); jentry++)
|
45 |
|
|
{
|
46 |
|
|
tscaleHLTmu->GetEntry(jentry);
|
47 |
|
|
if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
|
48 |
|
|
{
|
49 |
|
|
s1 = scale;
|
50 |
|
|
count++;
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
if(count == 0 || s1 == 0)
|
55 |
|
|
{
|
56 |
|
|
//caleFile->Close();
|
57 |
|
|
return 1;
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
//aleFile->Close();
|
62 |
|
|
return (s1);
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
float scaleMuID(float pt1, float eta1)
|
68 |
|
|
{
|
69 |
|
|
|
70 |
|
|
if(tscaleIDmu) return 1;
|
71 |
|
|
|
72 |
|
|
float ptMin,ptMax,etaMin,etaMax,scale,error;
|
73 |
|
|
float s1 = 0;
|
74 |
|
|
int count = 0;
|
75 |
|
|
tscaleIDmu->SetBranchAddress("ptMin",&ptMin);
|
76 |
|
|
tscaleIDmu->SetBranchAddress("ptMax",&ptMax);
|
77 |
|
|
tscaleIDmu->SetBranchAddress("etaMin",&etaMin);
|
78 |
|
|
tscaleIDmu->SetBranchAddress("etaMax",&etaMax);
|
79 |
|
|
tscaleIDmu->SetBranchAddress("scale",&scale);
|
80 |
|
|
tscaleIDmu->SetBranchAddress("error",&error);
|
81 |
|
|
|
82 |
|
|
for(int jentry = 0; jentry < tscaleIDmu->GetEntries(); jentry++)
|
83 |
|
|
{
|
84 |
|
|
|
85 |
|
|
tscaleIDmu->GetEntry(jentry);
|
86 |
|
|
if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
|
87 |
|
|
{
|
88 |
|
|
s1 = scale;
|
89 |
|
|
count++;
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
if(count == 0 || s1 == 0)
|
94 |
|
|
{
|
95 |
|
|
//caleFile->Close();
|
96 |
|
|
return 1;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
//aleFile->Close();
|
100 |
|
|
return (s1);
|
101 |
|
|
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
private:
|
105 |
|
|
TTree * tscaleHLTmu;
|
106 |
|
|
TTree * tscaleIDmu;
|
107 |
|
|
};
|
108 |
|
|
|
109 |
|
|
#endif
|