1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/AnaRpcVsOth.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 "UserCode/L1RpcTriggerAnalysis/interface/MuonObj.h"
|
9 |
#include "UserCode/L1RpcTriggerAnalysis/interface/L1Obj.h"
|
10 |
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjColl.h"
|
11 |
#include "UserCode/L1RpcTriggerAnalysis/interface/Utilities.h"
|
12 |
#include <math.h>
|
13 |
#include <vector>
|
14 |
#include <sstream>
|
15 |
|
16 |
const double AnaRpcVsOth::binsEff[ AnaRpcVsOth::nBinsEff+1 ] = { 1., 5., 12., 16., 30., 100.,1000.};
|
17 |
|
18 |
void AnaRpcVsOth::init(TObjArray& histos)
|
19 |
{
|
20 |
std::string base("hRpcVsOth_");
|
21 |
std::string tag[7]={"AnyPt","MinPt","MaxPt","RanPt","OthPt","RpcPt","AlgPt"};
|
22 |
std::string reg[3]={"_Bar","_Int","_End"};
|
23 |
std::string opt[5]={"Mu","RpcPtCut","OthPtCut","RpcNoCut","OthNoCut"};
|
24 |
for (unsigned int ir=0; ir<3; ++ir) {
|
25 |
// statistics by algorithms
|
26 |
for (unsigned int it=0; it<7; ++it) {
|
27 |
std::string name=base+"Events"+tag[it]+reg[ir];
|
28 |
TH1D *h= new TH1D(name.c_str(),name.c_str(), AnaRpcVsOth::nBinsEff, AnaRpcVsOth::binsEff);
|
29 |
h->SetXTitle("global muon p_{T} [GeV/c] "); h->SetYTitle("events");
|
30 |
histos.Add(h);
|
31 |
h1[name]=h;
|
32 |
}
|
33 |
// qality for events discarded
|
34 |
for (unsigned int it=0; it<7; ++it) {
|
35 |
std::string name=base+"QualEvLostBy"+tag[it]+reg[ir];
|
36 |
TH2D *h= new TH2D(name.c_str(),name.c_str(), 4,-0.5,3.5, 8,-0.5,7.5);
|
37 |
h->SetXTitle("quality RPC"); h->SetYTitle("quality Other");
|
38 |
histos.Add(h);
|
39 |
h2[name]=h;
|
40 |
}
|
41 |
// coarse efficiency
|
42 |
for (unsigned int io=0; io<5; ++io) {
|
43 |
std::string name=base+"EffCoarse"+opt[io]+reg[ir];
|
44 |
TH1D *h= new TH1D(name.c_str(),name.c_str(), AnaRpcVsOth::nBinsEff, AnaRpcVsOth::binsEff);
|
45 |
h->SetXTitle("global muon p_{T} [GeV/c] "); h->SetYTitle("events");
|
46 |
histos.Add(h); h1[name]=h;
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
|
51 |
double AnaRpcVsOth::maxPt(const std::vector<L1Obj> & l1Objs) const
|
52 |
{
|
53 |
double result = 0.;
|
54 |
for (unsigned int i=0; i<l1Objs.size(); i++) if (l1Objs[i].pt > result) result = l1Objs[i].pt;
|
55 |
return result;
|
56 |
}
|
57 |
|
58 |
void AnaRpcVsOth::run( const TrackObj *muon, const L1ObjColl *l1Coll)
|
59 |
{
|
60 |
|
61 |
double etaMu = fabs(muon->eta());
|
62 |
double ptMu = muon->pt();
|
63 |
// if (!muon->isGlobal()) return;
|
64 |
|
65 |
static double matchingdR = theConfig.getParameter<double>("maxDR");
|
66 |
std::vector<L1Obj> l1Rpcs = l1Coll->l1RpcColl().selectByDeltaR(matchingdR).selectByBx(0,0).getL1Objs();
|
67 |
std::vector<L1Obj> l1Oths = l1Coll->l1OthColl().selectByDeltaR(matchingdR).selectByBx(0,0).selectByEta(-1.61,1.61).getL1Objs();
|
68 |
|
69 |
unsigned int iregion;
|
70 |
if (etaMu < 0.83) iregion = 0;
|
71 |
else if (etaMu < 1.24) iregion = 1;
|
72 |
else iregion = 2;
|
73 |
std::string reg[3]={"_Bar","_Int","_End"};
|
74 |
|
75 |
|
76 |
|
77 |
std::string base("hRpcVsOth_");
|
78 |
double thr = 15.99;
|
79 |
//
|
80 |
// efficiencies
|
81 |
//
|
82 |
if (maxPt(l1Rpcs) > 0.) h1[ base+"EffCoarseRpcNoCut"+reg[iregion] ]->Fill(ptMu);
|
83 |
if (maxPt(l1Rpcs) > thr) h1[ base+"EffCoarseRpcPtCut"+reg[iregion] ]->Fill(ptMu);
|
84 |
if (maxPt(l1Oths) > 0.) h1[ base+"EffCoarseOthNoCut"+reg[iregion] ]->Fill(ptMu);
|
85 |
if (maxPt(l1Oths) > thr) h1[ base+"EffCoarseOthPtCut"+reg[iregion] ]->Fill(ptMu);
|
86 |
h1[ base+"EffCoarseMu" +reg[iregion] ]->Fill(ptMu);
|
87 |
|
88 |
//
|
89 |
// relative histos
|
90 |
//
|
91 |
if (l1Rpcs.size() != 1 || l1Oths.size() != 1 ) return;
|
92 |
|
93 |
const L1Obj & rpc = l1Rpcs[0];
|
94 |
const L1Obj & oth = l1Oths[0];
|
95 |
|
96 |
double rankpt = 0.;
|
97 |
if (oth.q > rpc.q) rankpt = oth.pt;
|
98 |
else if ( rpc.q > oth.q) rankpt = rpc.pt;
|
99 |
else rankpt = std::max(rpc.pt,oth.pt);
|
100 |
|
101 |
/*
|
102 |
double algpt = oth.pt;
|
103 |
if (rpc.q >=2) algpt = rpc.pt;
|
104 |
if (rpc.q==1) algpt = std::max(rpc.pt,oth.pt);
|
105 |
*/
|
106 |
|
107 |
/*
|
108 |
double algpt = oth.pt;
|
109 |
if (2*rpc.q+1 > oth.q) algpt = rpc.pt;
|
110 |
else if (2*rpc.q+1 < oth.q) algpt = oth.pt;
|
111 |
else algpt = std::max(rpc.pt,oth.pt);
|
112 |
*/
|
113 |
|
114 |
/*
|
115 |
double algpt = oth.pt;
|
116 |
if (rpc.q+2 > oth.q) algpt = rpc.pt;
|
117 |
else if (2+rpc.q < oth.q) algpt = oth.pt;
|
118 |
else algpt = std::min(rpc.pt,oth.pt);
|
119 |
*/
|
120 |
double algpt = oth.pt;
|
121 |
if (iregion==0) {
|
122 |
if (rpc.q>=2) algpt = rpc.pt;
|
123 |
else if (oth.q>=3) algpt = oth.pt;
|
124 |
else algpt = std::min( rpc.pt, oth.pt);
|
125 |
/*
|
126 |
if (rpc.q>= 2 && oth.q >4) algpt = std::min( rpc.pt, oth.pt);
|
127 |
else if (rpc.q>=2) algpt = rpc.pt;
|
128 |
else if (oth.q>=2) algpt = oth.pt;
|
129 |
else algpt = std::min( rpc.pt, oth.pt);
|
130 |
*/
|
131 |
/*
|
132 |
if (rpc.q==3) algpt = rpc.pt;
|
133 |
else if (rpc.q==2 && oth.q >3) algpt = std::max( rpc.pt, oth.pt);
|
134 |
else if (rpc.q==1 && oth.q >4) algpt = std::min( rpc.pt, oth.pt);
|
135 |
else if (rpc.q==0 && oth.q >3) algpt = std::min( rpc.pt, oth.pt);
|
136 |
else if (oth.q >2) algpt = oth.pt;
|
137 |
else algpt = rpc.pt;
|
138 |
*/
|
139 |
/*
|
140 |
if (rpc.q==3 && oth.q > 3) algpt = std::max(rpc.pt,oth.pt);
|
141 |
else if (rpc.q==3) algpt = rpc.pt;
|
142 |
else if (rpc.q==2 && oth.q >3) algpt = std::max( rpc.pt, oth.pt);
|
143 |
else if (rpc.q==1 && oth.q >4) algpt = std::min( rpc.pt, oth.pt);
|
144 |
else if (rpc.q==0 && oth.q >3) algpt = std::min( rpc.pt, oth.pt);
|
145 |
else if (oth.q >2) algpt = oth.pt;
|
146 |
else algpt = rpc.pt;
|
147 |
*/
|
148 |
} else if (iregion==1) {
|
149 |
algpt= oth.pt;
|
150 |
} else {
|
151 |
if (oth.q > 1) algpt = std::min( rpc.pt, oth.pt);
|
152 |
else algpt = rpc.pt;
|
153 |
}
|
154 |
|
155 |
double maxpt = std::max(rpc.pt, oth.pt);
|
156 |
double minpt = std::min(rpc.pt, oth.pt);
|
157 |
|
158 |
h1[ base+"EventsAnyPt"+reg[iregion] ]->Fill(ptMu);
|
159 |
if ( minpt > thr) h1[ base+"EventsMinPt"+reg[iregion] ]->Fill(ptMu);
|
160 |
if ( maxpt > thr) h1[ base+"EventsMaxPt"+reg[iregion] ]->Fill(ptMu);
|
161 |
if ( rankpt > thr) h1[ base+"EventsRanPt"+reg[iregion] ]->Fill(ptMu);
|
162 |
if ( rpc.pt > thr) h1[ base+"EventsRpcPt"+reg[iregion] ]->Fill(ptMu);
|
163 |
if ( oth.pt > thr) h1[ base+"EventsOthPt"+reg[iregion] ]->Fill(ptMu);
|
164 |
if ( algpt > thr) h1[ base+"EventsAlgPt"+reg[iregion] ]->Fill(ptMu);
|
165 |
|
166 |
//
|
167 |
// quality of candidates for events lost
|
168 |
//
|
169 |
if (ptMu > 30.) {
|
170 |
if ( minpt < thr) h2[ base+"QualEvLostByMinPt"+reg[iregion] ]->Fill(rpc.q, oth.q);
|
171 |
if ( maxpt < thr) h2[ base+"QualEvLostByMaxPt"+reg[iregion] ]->Fill(rpc.q, oth.q);
|
172 |
if ( rpc.pt < thr) h2[ base+"QualEvLostByRpcPt"+reg[iregion] ]->Fill(rpc.q, oth.q);
|
173 |
if ( oth.pt < thr) h2[ base+"QualEvLostByOthPt"+reg[iregion] ]->Fill(rpc.q, oth.q);
|
174 |
if ( algpt < thr) h2[ base+"QualEvLostByAlgPt"+reg[iregion] ]->Fill(rpc.q, oth.q);
|
175 |
}
|
176 |
}
|
177 |
|