1 |
konec |
1.1 |
#include "L1RpcTreeAnalysis.h"
|
2 |
|
|
|
3 |
|
|
#include <vector>
|
4 |
|
|
#include <iostream>
|
5 |
|
|
#include <cmath>
|
6 |
|
|
#include <iomanip>
|
7 |
|
|
|
8 |
|
|
#include "TFile.h"
|
9 |
|
|
#include "TChain.h"
|
10 |
|
|
#include "TTree.h"
|
11 |
|
|
#include "TProfile.h"
|
12 |
|
|
#include "TH2F.h"
|
13 |
|
|
#include "TH1D.h"
|
14 |
|
|
#include "TGraphErrors.h"
|
15 |
|
|
#include "TF1.h"
|
16 |
|
|
|
17 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1Obj.h"
|
18 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/EventObj.h"
|
19 |
konec |
1.12 |
#include "UserCode/L1RpcTriggerAnalysis/interface/EventObjBXExtra.h"
|
20 |
konec |
1.1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackObj.h"
|
21 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/MuonObj.h"
|
22 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjColl.h"
|
23 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroCountsObj.h"
|
24 |
konec |
1.7 |
#include "UserCode/L1RpcTriggerAnalysis/interface/DetCluDigiObj.h"
|
25 |
konec |
1.5 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
|
26 |
konec |
1.17 |
#include "UserCode/L1RpcTriggerAnalysis/interface/HitSpecObj.h"
|
27 |
konec |
1.1 |
|
28 |
konec |
1.12 |
|
29 |
konec |
1.1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
|
30 |
|
|
|
31 |
konec |
1.9 |
L1RpcTreeAnalysis::L1RpcTreeAnalysis(const edm::ParameterSet & cfg)
|
32 |
|
|
: theConfig(cfg),
|
33 |
konec |
1.17 |
theAnaMuonDistribution(0),
|
34 |
|
|
theAnaRpcVsOth(0),
|
35 |
|
|
theAnaRpcMisc(0),
|
36 |
|
|
theAnaEff(0),
|
37 |
|
|
theAnaDet(0),
|
38 |
|
|
theAnaEmu(0),
|
39 |
|
|
theAnaSynch(0),
|
40 |
|
|
theAnaClu(0),
|
41 |
|
|
theAnaTimingL1(0),
|
42 |
|
|
theAnaMenu(0),
|
43 |
|
|
theAnaEvent(0),
|
44 |
|
|
theAnaDigiSpec(0),
|
45 |
|
|
theAnaHitSpec(0),
|
46 |
|
|
thePatternProducer(0),
|
47 |
|
|
thePatternProvider(0)
|
48 |
|
|
{
|
49 |
|
|
if (theConfig.exists("anaMuonDistribution")) theAnaMuonDistribution = new AnaMuonDistribution( cfg.getParameter<edm::ParameterSet>("anaMuonDistribution") );
|
50 |
|
|
if (theConfig.exists("anaMenu")) theAnaMenu = new AnaMenu(theConfig.getParameter<edm::ParameterSet>("anaMenu"));
|
51 |
|
|
if (theConfig.exists("anaTimingL1")) theAnaTimingL1 = new AnaTimingL1( theConfig.getParameter<edm::ParameterSet>("anaTimingL1") );
|
52 |
|
|
if (theConfig.exists("anaEvent")) theAnaEvent = new AnaEvent(cfg.getParameter<edm::ParameterSet>("anaEvent") );
|
53 |
|
|
if (theConfig.exists("anaDigiSpec")) theAnaDigiSpec = new AnaDigiSpec(cfg.getParameter<edm::ParameterSet>("anaDigiSpec"));
|
54 |
|
|
if (theConfig.exists("anaHitSpec")) theAnaHitSpec = new AnaHitSpec(cfg.getParameter<edm::ParameterSet>("anaHitSpec"));
|
55 |
|
|
if (theConfig.exists("patternProducer")) thePatternProducer = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProducer"));
|
56 |
|
|
if (theConfig.exists("patternProvider")) thePatternProvider = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProvider"));
|
57 |
|
|
|
58 |
|
|
}
|
59 |
konec |
1.1 |
|
60 |
|
|
void L1RpcTreeAnalysis::beginJob()
|
61 |
|
|
{
|
62 |
|
|
theHistos.SetOwner();
|
63 |
|
|
|
64 |
konec |
1.17 |
if (theAnaMuonDistribution) theAnaMuonDistribution->init(theHistos);
|
65 |
|
|
if (theAnaRpcVsOth) theAnaRpcVsOth->init(theHistos);
|
66 |
|
|
if (theAnaRpcMisc) theAnaRpcMisc->init(theHistos);
|
67 |
|
|
if (theAnaEff) theAnaEff->init(theHistos);
|
68 |
|
|
if (theAnaDet) theAnaDet->init(theHistos);
|
69 |
|
|
if (theAnaEmu) theAnaEmu->init(theHistos);
|
70 |
|
|
if (theAnaSynch) theAnaSynch->init(theHistos);
|
71 |
|
|
if (theAnaClu) theAnaClu->init(theHistos);
|
72 |
|
|
if (theAnaTimingL1) theAnaTimingL1->init(theHistos);
|
73 |
|
|
if (theAnaEvent) theAnaEvent->init(theHistos);
|
74 |
|
|
if (theAnaMenu) theAnaMenu->init(theHistos);
|
75 |
|
|
if (theAnaDigiSpec) theAnaDigiSpec->init(theHistos);
|
76 |
|
|
if (theAnaHitSpec) theAnaHitSpec->init(theHistos);
|
77 |
|
|
|
78 |
|
|
if (thePatternProvider) thePatternProvider->beginJob();
|
79 |
konec |
1.1 |
}
|
80 |
|
|
|
81 |
|
|
void L1RpcTreeAnalysis::beginRun(const edm::Run& ru, const edm::EventSetup& es)
|
82 |
|
|
{
|
83 |
konec |
1.17 |
if (theAnaSynch) theAnaSynch->beginRun(ru,es);
|
84 |
konec |
1.1 |
}
|
85 |
|
|
|
86 |
|
|
void L1RpcTreeAnalysis::analyze(const edm::Event&, const edm::EventSetup&)
|
87 |
|
|
{
|
88 |
|
|
//
|
89 |
|
|
// prevent multievent execution
|
90 |
|
|
//
|
91 |
|
|
static bool the_EMERGENCY_STOP = false;
|
92 |
|
|
if (the_EMERGENCY_STOP) {
|
93 |
|
|
std::cout <<"** L1RpcTreeAnalysis::analyze EMERGENCY_STOP fired, skip" << std::endl;
|
94 |
|
|
return;
|
95 |
|
|
}
|
96 |
|
|
the_EMERGENCY_STOP = true;
|
97 |
|
|
|
98 |
|
|
//
|
99 |
|
|
// define input chain
|
100 |
|
|
//
|
101 |
|
|
TChain chain("tL1Rpc");
|
102 |
|
|
std::vector<std::string> treeFileNames = theConfig.getParameter<std::vector<std::string> >("treeFileNames");
|
103 |
|
|
for (std::vector<std::string>::const_iterator it = treeFileNames.begin(); it != treeFileNames.end(); ++it) chain.Add((*it).c_str() );
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
//
|
107 |
|
|
// prepare datastructures and branches
|
108 |
|
|
//
|
109 |
|
|
std::vector<SynchroCountsObj> *counts= 0;
|
110 |
|
|
std::vector<uint32_t> *detsCrossedByMuon = 0;
|
111 |
|
|
std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
|
112 |
konec |
1.7 |
std::vector<DetCluDigiObj> *detsHitsCompatibleWithMuon = 0;
|
113 |
konec |
1.1 |
std::vector<uint32_t> *detsSIMU = 0;
|
114 |
konec |
1.17 |
std::vector<std::pair<uint32_t, uint32_t> > *digSpec = 0;
|
115 |
konec |
1.1 |
|
116 |
|
|
EventObj * event = 0;
|
117 |
|
|
MuonObj * muon = 0;
|
118 |
konec |
1.17 |
TrackObj * simu = 0;
|
119 |
konec |
1.1 |
|
120 |
konec |
1.5 |
TriggerMenuResultObj *bitsL1 = 0;
|
121 |
|
|
TriggerMenuResultObj *bitsHLT = 0;
|
122 |
|
|
|
123 |
konec |
1.1 |
TBranch *bcounts=0;
|
124 |
|
|
TBranch *bdetsCrossedByMuon =0;
|
125 |
|
|
TBranch *bdetsCrossedByMuonDeepInside =0;
|
126 |
|
|
TBranch *bdetsHitsCompatibleWithMuon = 0;
|
127 |
|
|
TBranch *bdetsSIMU =0;
|
128 |
konec |
1.17 |
TBranch *bdigSpec = 0;
|
129 |
konec |
1.1 |
|
130 |
konec |
1.9 |
L1ObjColl* l1ObjColl = 0;
|
131 |
konec |
1.17 |
HitSpecObj* hitSpec = 0;
|
132 |
|
|
|
133 |
konec |
1.1 |
|
134 |
|
|
chain.SetBranchAddress("event",&event);
|
135 |
|
|
chain.SetBranchAddress("muon",&muon);
|
136 |
konec |
1.17 |
chain.SetBranchAddress("simu",&simu);
|
137 |
konec |
1.1 |
|
138 |
konec |
1.5 |
chain.SetBranchAddress("bitsL1",&bitsL1);
|
139 |
|
|
chain.SetBranchAddress("bitsHLT",&bitsHLT);
|
140 |
|
|
|
141 |
konec |
1.1 |
chain.SetBranchAddress("counts",&counts,&bcounts);
|
142 |
|
|
chain.SetBranchAddress("detsCrossedByMuon",&detsCrossedByMuon,&bdetsCrossedByMuon);
|
143 |
|
|
chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
|
144 |
|
|
chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
|
145 |
|
|
chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
|
146 |
konec |
1.17 |
chain.SetBranchAddress("digSpec",&digSpec,&bdigSpec);
|
147 |
konec |
1.1 |
|
148 |
konec |
1.9 |
chain.SetBranchAddress("l1ObjColl",&l1ObjColl);
|
149 |
konec |
1.17 |
chain.SetBranchAddress("hitSpec",&hitSpec);
|
150 |
konec |
1.1 |
|
151 |
|
|
|
152 |
|
|
//
|
153 |
konec |
1.5 |
// number of events
|
154 |
konec |
1.1 |
//
|
155 |
|
|
Int_t nentries = (Int_t) chain.GetEntries();
|
156 |
|
|
std::cout <<" ENTRIES: " << nentries << std::endl;
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
//
|
160 |
|
|
// main loop
|
161 |
|
|
//
|
162 |
|
|
unsigned int lastRun = 0;
|
163 |
|
|
for (int ev=0; ev<nentries; ev++) {
|
164 |
|
|
chain.GetEntry(ev);
|
165 |
konec |
1.17 |
if (theAnaMenu) theAnaMenu->updateMenu(bitsL1->names, bitsHLT->names);
|
166 |
konec |
1.1 |
|
167 |
konec |
1.17 |
if ( (lastRun != (*event).run) || (ev/10000*10000==ev) ) {
|
168 |
konec |
1.14 |
// if (true) {
|
169 |
konec |
1.16 |
// if (! ((*event).run==204601 && (*event).id ==109463402)) { continue;
|
170 |
konec |
1.1 |
lastRun = (*event).run;
|
171 |
|
|
std::cout <<"RUN:" << std::setw(7) << (*event).run
|
172 |
|
|
<<" event:" << std::setw(8) << ev
|
173 |
konec |
1.11 |
<<" done:" << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%";
|
174 |
|
|
std::cout<<std::endl;
|
175 |
konec |
1.1 |
}
|
176 |
|
|
|
177 |
konec |
1.13 |
/*
|
178 |
|
|
if ( event->id == 597978012
|
179 |
|
|
|| event->id == 14791798
|
180 |
|
|
|| event->id == 436261807
|
181 |
|
|
|| event->id == 873776280
|
182 |
|
|
|| event->id == 960307389
|
183 |
|
|
|| event->id == 150097556
|
184 |
|
|
|| event->id == 42062946
|
185 |
|
|
|| event->id == 1064121551
|
186 |
|
|
|| event->id == 1499489591
|
187 |
|
|
|| event->id == 60161631
|
188 |
|
|
|| event->id == 624624695
|
189 |
|
|
|| event->id == 727298833
|
190 |
|
|
|| event->id == 835600542
|
191 |
|
|
|| event->id == 216373776
|
192 |
|
|
|| event->id == 1107585611
|
193 |
|
|
|| event->id == 197907027
|
194 |
|
|
) theAnaMenu.debug = true; else theAnaMenu.debug = false;
|
195 |
|
|
*/
|
196 |
konec |
1.1 |
|
197 |
konec |
1.12 |
// EVENT NUMBER, BX structure etc.
|
198 |
|
|
EventObjBXExtra eventBx(*event);
|
199 |
konec |
1.17 |
if ( theAnaEvent && !theAnaEvent->filter(&eventBx) && theConfig.getParameter<bool>("filterByAnaEvent") ) continue;
|
200 |
konec |
1.9 |
// ANALYSE AND FILTER KINEMCTICS
|
201 |
konec |
1.17 |
if ( theAnaMuonDistribution && !theAnaMuonDistribution->filter(muon) && theConfig.getParameter<bool>("filterByAnaMuonDistribution") ) continue;
|
202 |
konec |
1.9 |
// ANALYSE AND FILTER TRIGGER MENU
|
203 |
konec |
1.17 |
if ( theAnaMenu && !theAnaMenu->filter(event, muon, bitsL1, bitsHLT) && theConfig.getParameter<bool>("filterByAnaMenu") ) continue;
|
204 |
konec |
1.1 |
|
205 |
konec |
1.17 |
// ANALYSES
|
206 |
|
|
if (theAnaRpcVsOth) theAnaRpcVsOth->run(muon,l1ObjColl);
|
207 |
|
|
if (theAnaEff) theAnaEff->run(muon, l1ObjColl);
|
208 |
|
|
if (theAnaRpcMisc) theAnaRpcMisc->run(event,muon,l1ObjColl);
|
209 |
|
|
if (theAnaDet) theAnaDet->run( muon, *detsHitsCompatibleWithMuon, *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
|
210 |
|
|
if (theAnaEmu) theAnaEmu->run ( event, muon, l1ObjColl);
|
211 |
|
|
if (theAnaSynch) theAnaSynch->run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
|
212 |
|
|
if (theAnaClu) theAnaClu->run( event, muon, l1ObjColl, *detsHitsCompatibleWithMuon);
|
213 |
|
|
if (theAnaTimingL1) theAnaTimingL1->run( &eventBx, muon, l1ObjColl);
|
214 |
|
|
|
215 |
|
|
// HITPATTERN ANALYSES & MC EFFICIENCY
|
216 |
|
|
if (theAnaHitSpec) theAnaHitSpec->run(event, simu, hitSpec);
|
217 |
|
|
if (theAnaDigiSpec) theAnaDigiSpec->run(event, simu, hitSpec, *digSpec);
|
218 |
|
|
if (thePatternProducer) thePatternProducer->run(event, simu, hitSpec, *digSpec);
|
219 |
|
|
if (thePatternProvider) thePatternProvider->check(event, simu, hitSpec, *digSpec);
|
220 |
konec |
1.1 |
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
void L1RpcTreeAnalysis::endJob()
|
224 |
|
|
{
|
225 |
|
|
std::cout <<"ENDJOB, summaries:"<<std::endl;
|
226 |
konec |
1.17 |
TGraph* hGraph_DetEff = (theAnaDet) ? theAnaDet->resume() : 0;
|
227 |
|
|
TGraph* hGraph_RunClu = (theAnaClu) ? theAnaClu->resume(): 0;
|
228 |
|
|
if (theAnaRpcMisc) theAnaRpcMisc->resume(theHistos);
|
229 |
|
|
if (theAnaTimingL1) theAnaTimingL1->resume(theHistos);
|
230 |
|
|
if (theAnaMenu) theAnaMenu->resume(theHistos);
|
231 |
|
|
if (theAnaMenu) theAnaEvent->resume(theHistos);
|
232 |
|
|
if (theAnaHitSpec) theAnaHitSpec->resume(theHistos);
|
233 |
|
|
if (theAnaDigiSpec) theAnaDigiSpec->resume(theHistos);
|
234 |
|
|
|
235 |
|
|
if (theAnaSynch) theAnaSynch->endJob();
|
236 |
|
|
if (thePatternProducer) thePatternProducer->endJob();
|
237 |
|
|
if (thePatternProvider) thePatternProvider->endJob();
|
238 |
konec |
1.1 |
|
239 |
|
|
std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
|
240 |
|
|
TFile f(histoFile.c_str(),"RECREATE");
|
241 |
|
|
theHistos.Write();
|
242 |
konec |
1.17 |
if (hGraph_DetEff) hGraph_DetEff->Write("hGraph_DetEff");
|
243 |
|
|
if (hGraph_RunClu) hGraph_RunClu->Write("hGraph_RunClu");
|
244 |
konec |
1.1 |
f.Close();
|
245 |
|
|
std::cout <<"END"<<std::endl;
|
246 |
konec |
1.17 |
|
247 |
|
|
delete theAnaMuonDistribution;
|
248 |
|
|
delete theAnaRpcVsOth;
|
249 |
|
|
delete theAnaRpcMisc;
|
250 |
|
|
delete theAnaEff;
|
251 |
|
|
delete theAnaDet;
|
252 |
|
|
delete theAnaEmu;
|
253 |
|
|
delete theAnaSynch;
|
254 |
|
|
delete theAnaClu;
|
255 |
|
|
delete theAnaTimingL1;
|
256 |
|
|
delete theAnaMenu;
|
257 |
|
|
delete theAnaEvent;
|
258 |
|
|
delete theAnaDigiSpec;
|
259 |
|
|
delete theAnaHitSpec;
|
260 |
|
|
delete thePatternProducer;
|
261 |
|
|
delete thePatternProvider;
|
262 |
konec |
1.1 |
}
|