ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/AnaEff.cc
Revision: 1.8
Committed: Thu Jul 11 11:25:22 2013 UTC (11 years, 10 months ago) by akalinow
Content type: text/plain
Branch: MAIN
CVS Tags: Artur_11_07_2013_B, Artur_11_07_2013_A, Artur_11_07_2013, HEAD
Changes since 1.7: +37 -2 lines
Log Message:
*last commit before migration to Git.

File Contents

# Content
1 #include "UserCode/L1RpcTriggerAnalysis/interface/AnaEff.h"
2 #include "TProfile.h"
3 #include "TObjArray.h"
4 #include "TH2F.h"
5 #include "TH1D.h"
6 #include "TGraphErrors.h"
7 #include "TF1.h"
8 #include "TTree.h"
9 #include "TFile.h"
10
11 #include "UserCode/L1RpcTriggerAnalysis/interface/EventData.h"
12 #include "UserCode/L1RpcTriggerAnalysis/interface/MuonObj.h"
13 #include "UserCode/L1RpcTriggerAnalysis/interface/HitSpecObj.h"
14 #include "UserCode/L1RpcTriggerAnalysis/interface/L1Obj.h"
15 #include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjColl.h"
16 #include "UserCode/L1RpcTriggerAnalysis/interface/Utilities.h"
17 #include <math.h>
18 #include <vector>
19 #include <sstream>
20
21 const double AnaEff::ptCuts[ AnaEff::nPtCuts] ={0., 0.1,
22 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 6., 7., 8.,
23 10., 12., 14., 16., 18., 20., 25., 30., 35., 40., 45.,
24 50., 60., 70., 80., 90., 100.};
25
26
27 std::string reg[5]={"_Bar","_Int","_End","_Qeq0","_Qgt0"};
28
29
30 AnaEff::~AnaEff(){
31
32 file->Write();
33 delete file;
34
35 }
36
37 void AnaEff::init(TObjArray& histos)
38 {
39
40
41 file = new TFile("EfficiencyTree.root","RECREATE");
42 tree = new TTree("efficiencyTree","efficiencyTree");
43 myEvent = new EventData();
44 tree->Branch("Events", myEvent);
45
46 hEfficMuPt_D = new TH1D("hEfficMuPt_D","hEfficMuPt_D", L1PtScale::nPtBins, L1PtScale::ptBins); histos.Add(hEfficMuPt_D);
47 hEfficRpcNoCut_N = new TH1D("hEfficRpcNoCut_N","hEfficRpcNoCut_N", L1PtScale::nPtBins, L1PtScale::ptBins); histos.Add(hEfficRpcNoCut_N);
48 hEfficRpcPtCut_N = new TH1D("hEfficRpcPtCut_N","hEfficRpcPtCut_N", L1PtScale::nPtBins, L1PtScale::ptBins); histos.Add(hEfficRpcPtCut_N);
49
50 std::string base("hEff");
51 std::string opt[4]={"_RpcPtCut","_OthPtCut","_GmtPtCut","_OtfPtCut"};
52 for (unsigned int ir=0; ir<5; ++ir) {
53 std::string name=base+"_PtDenom"+reg[ir];
54 TH1D *h= new TH1D(name.c_str(),name.c_str(), L1PtScale::nPtBins, L1PtScale::ptBins);
55 histos.Add(h); hm[name]=h;
56 for (unsigned int iopt=0; iopt<4; ++iopt) {
57 if (iopt >0 && ir >2) continue;
58 for (unsigned int icut=0; icut<AnaEff::nPtCuts; ++icut) {
59 std::stringstream str;
60 str << base << opt[iopt] << ptCuts[icut]<<reg[ir];
61 TH1D *h= new TH1D(str.str().c_str(),str.str().c_str(), L1PtScale::nPtBins, L1PtScale::ptBins);
62 h->SetXTitle("muon p_{T} [GeV/c] "); h->SetYTitle("events");
63 histos.Add(h); hm[str.str()]=h;
64 }
65 }
66 }
67 for (unsigned int icut=0; icut<AnaEff::nPtCuts; ++icut) {
68 std::stringstream strEtaDenom; strEtaDenom << base << "_EtaDenom"<< ptCuts[icut];
69 TH1D *hD = new TH1D(strEtaDenom.str().c_str(),strEtaDenom.str().c_str(), L1RpcEtaScale::nEtaBins, L1RpcEtaScale::etaBins);
70 hD->SetXTitle("muon pseudorapidity"); hD->SetYTitle("events"); histos.Add(hD); hm[strEtaDenom.str()]=hD;
71 std::stringstream strEtaCut ; strEtaCut << base << "_EtaCut"<< ptCuts[icut];
72 TH1D *hN = new TH1D(strEtaCut.str().c_str(),strEtaCut.str().c_str(), L1RpcEtaScale::nEtaBins, L1RpcEtaScale::etaBins);
73 hN->SetXTitle("muon pseudorapidity"); hN->SetYTitle("events"); histos.Add(hN); hm[strEtaCut.str()]=hN;
74 }
75
76 }
77
78 double AnaEff::maxPt(const std::vector<L1Obj> & l1Objs) const
79 {
80 double result = -1.;
81 for (unsigned int i=0; i<l1Objs.size(); i++) if (l1Objs[i].pt > result) result = l1Objs[i].pt;
82 return result;
83 }
84
85 void AnaEff::run( const TrackObj *muon, const L1ObjColl *l1Coll, const HitSpecObj * hitSpec)
86 {
87 double etaMu = fabs(muon->eta());
88 double ptMu = muon->pt();
89
90 //////////Fill plotting tree
91 myEvent->clear();
92 myEvent->weight = 1.0;
93 myEvent->pt = muon->pt();
94 myEvent->eta = muon->eta();
95 myEvent->phi = muon->phi();
96 myEvent->phiHit = hitSpec->position().phi();
97 myEvent->etaHit = hitSpec->position().eta();
98 myEvent->charge = muon->charge();
99 /////////////////////////////
100
101 // if (!muon->isGlobal()) return;
102
103 // if (ptMu < 6.) return;
104 // if (ptMu > 7.) return;
105
106 static double matchingdR = theConfig.getParameter<double>("maxDR");
107 std::vector<L1Obj> l1Rpcs = l1Coll->l1RpcColl().selectByBx().selectByDeltaR( matchingdR);
108 std::vector<L1Obj> l1Oths = l1Coll->l1OthColl().selectByBx().selectByDeltaR( matchingdR).selectByEta();
109 std::vector<L1Obj> l1Gmts = l1Coll->selectByType(L1Obj::GMT).selectByBx().selectByQuality(4,7).selectByDeltaR( matchingdR).selectByEta();
110 std::vector<L1Obj> l1Otfs = l1Coll->selectByType(L1Obj::OTF);
111
112 myEvent->l1ObjectsOtf = l1Otfs;
113 myEvent->l1ObjectsGmt = l1Gmts;
114 tree->Fill();
115
116
117 hEfficMuPt_D->Fill(ptMu);
118 if (maxPt(l1Rpcs) > 0.) hEfficRpcNoCut_N->Fill(ptMu);
119 if (maxPt(l1Rpcs) >= 15.999) hEfficRpcPtCut_N->Fill(ptMu);
120
121 unsigned int iregion;
122 if (etaMu < 0.83) iregion = 0;
123 else if (etaMu < 1.24) iregion = 1;
124 else iregion = 2;
125 // std::string reg[3]={"_Bar","_Int","_End"};
126
127 hm["hEff_PtDenom"+reg[iregion]]->Fill(ptMu);
128 double epsilon=1.e-5;
129 for (unsigned int icut=0; icut < AnaEff::nPtCuts; icut++) {
130 double threshold = AnaEff::ptCuts[icut];
131 std::stringstream strEtaDenom; strEtaDenom << "hEff_EtaDenom"<< ptCuts[icut];
132 if (ptMu >= threshold) hm[strEtaDenom.str()]->Fill(muon->eta());
133 if (maxPt(l1Rpcs)+epsilon > threshold) {
134 std::stringstream strPt; strPt << "hEff_RpcPtCut"<< ptCuts[icut]<<reg[iregion];
135 hm[strPt.str()]->Fill(ptMu);
136 std::stringstream strEtaCut; strEtaCut << "hEff_EtaCut"<< ptCuts[icut];
137 if (ptMu >= threshold) hm[strEtaCut.str()]->Fill(muon->eta());
138 }
139 if (maxPt(l1Oths)+epsilon > threshold) {
140 std::stringstream strPt; strPt << "hEff_OthPtCut"<< ptCuts[icut]<<reg[iregion];
141 hm[strPt.str()]->Fill(ptMu);
142 }
143 if (maxPt(l1Gmts)+epsilon > threshold) {
144 std::stringstream strPt; strPt << "hEff_GmtPtCut"<< ptCuts[icut]<<reg[iregion];
145 hm[strPt.str()]->Fill(ptMu);
146 }
147 if (maxPt(l1Otfs)+epsilon > threshold) {
148 std::stringstream strPt; strPt << "hEff_OtfPtCut"<< ptCuts[icut]<<reg[iregion];
149 hm[strPt.str()]->Fill(ptMu);
150 }
151 }
152
153
154 //
155 // check performance for q=0 and q>0 in 0.7 < |eta| < 1.1
156 //
157 if (etaMu > 0.7 && etaMu < 1.1) {
158 for (unsigned int ir=3; ir <=4; ++ir) {
159 hm["hEff_PtDenom"+reg[ir]]->Fill(ptMu);
160 std::vector<L1Obj> l1RpcsQ;
161 L1ObjColl l1RpcCollQ = l1Coll->l1RpcColl().selectByDeltaR( matchingdR).selectByBx();
162 if (ir==3) l1RpcsQ = l1RpcCollQ.selectByQuality(0,0).getL1Objs();
163 if (ir==4) l1RpcsQ = l1RpcCollQ.selectByQuality(1,7).getL1Objs();
164 double epsilon=1.e-5;
165 for (unsigned int icut=0; icut < AnaEff::nPtCuts; icut++) {
166 double threshold = AnaEff::ptCuts[icut];
167 if (maxPt(l1RpcsQ)+epsilon > threshold) {
168 std::stringstream strPt; strPt << "hEff_RpcPtCut"<< ptCuts[icut]<<reg[ir];
169 hm[strPt.str()]->Fill(ptMu);
170 }
171 }
172 }
173 }
174
175 }
176