ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/interface/TriggerWeight.h
Revision: 1.3
Committed: Tue Sep 13 16:25:53 2011 UTC (13 years, 7 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: Sept14th2011_2, Sept14th2011
Changes since 1.2: +22 -5 lines
Log Message:
added code from michele. slightly modified

File Contents

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