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 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackObj.h"
|
20 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/MuonObj.h"
|
21 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjColl.h"
|
22 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/SynchroCountsObj.h"
|
23 |
konec |
1.5 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
|
24 |
konec |
1.1 |
|
25 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
void L1RpcTreeAnalysis::beginJob()
|
29 |
|
|
{
|
30 |
|
|
theHistos.SetOwner();
|
31 |
|
|
|
32 |
|
|
theAnaMuonDistribution.init(theHistos);
|
33 |
|
|
theAnaRpcVsOth.init(theHistos);
|
34 |
|
|
theAnaRpcMisc.init(theHistos);
|
35 |
|
|
theAnaEff.init(theHistos);
|
36 |
|
|
theAnaDet.init(theHistos);
|
37 |
|
|
theAnaEmu.init(theHistos);
|
38 |
|
|
theAnaSynch.init(theHistos);
|
39 |
|
|
theAnaClu.init(theHistos);
|
40 |
konec |
1.4 |
theAnaTimingL1.init(theHistos);
|
41 |
konec |
1.1 |
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
void L1RpcTreeAnalysis::beginRun(const edm::Run& ru, const edm::EventSetup& es)
|
45 |
|
|
{
|
46 |
|
|
theAnaSynch.beginRun(ru,es);
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
void L1RpcTreeAnalysis::analyze(const edm::Event&, const edm::EventSetup&)
|
50 |
|
|
{
|
51 |
|
|
//
|
52 |
|
|
// prevent multievent execution
|
53 |
|
|
//
|
54 |
|
|
static bool the_EMERGENCY_STOP = false;
|
55 |
|
|
if (the_EMERGENCY_STOP) {
|
56 |
|
|
std::cout <<"** L1RpcTreeAnalysis::analyze EMERGENCY_STOP fired, skip" << std::endl;
|
57 |
|
|
return;
|
58 |
|
|
}
|
59 |
|
|
the_EMERGENCY_STOP = true;
|
60 |
|
|
|
61 |
|
|
//
|
62 |
|
|
// define input chain
|
63 |
|
|
//
|
64 |
|
|
TChain chain("tL1Rpc");
|
65 |
|
|
std::vector<std::string> treeFileNames = theConfig.getParameter<std::vector<std::string> >("treeFileNames");
|
66 |
|
|
for (std::vector<std::string>::const_iterator it = treeFileNames.begin(); it != treeFileNames.end(); ++it) chain.Add((*it).c_str() );
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
//
|
70 |
|
|
// prepare datastructures and branches
|
71 |
|
|
//
|
72 |
|
|
std::vector<SynchroCountsObj> *counts= 0;
|
73 |
|
|
std::vector<uint32_t> *detsCrossedByMuon = 0;
|
74 |
|
|
std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
|
75 |
|
|
std::vector<uint32_t> *detsHitsCompatibleWithMuon = 0;
|
76 |
|
|
std::vector<uint32_t> *detsSIMU = 0;
|
77 |
|
|
std::vector<uint32_t> *nDigisCompDets = 0;
|
78 |
konec |
1.2 |
std::vector<uint32_t> *clSizeCompDets = 0;
|
79 |
konec |
1.1 |
|
80 |
|
|
EventObj * event = 0;
|
81 |
|
|
MuonObj * muon = 0;
|
82 |
|
|
|
83 |
konec |
1.5 |
TriggerMenuResultObj *bitsL1 = 0;
|
84 |
|
|
TriggerMenuResultObj *bitsHLT = 0;
|
85 |
|
|
|
86 |
konec |
1.1 |
TBranch *bcounts=0;
|
87 |
|
|
TBranch *bdetsCrossedByMuon =0;
|
88 |
|
|
TBranch *bdetsCrossedByMuonDeepInside =0;
|
89 |
|
|
TBranch *bdetsHitsCompatibleWithMuon = 0;
|
90 |
|
|
TBranch *bdetsSIMU =0;
|
91 |
|
|
TBranch *bnDigisCompDets =0;
|
92 |
konec |
1.2 |
TBranch *bclSizeCompDets =0;
|
93 |
konec |
1.1 |
|
94 |
|
|
L1ObjColl* l1RpcColl = 0;
|
95 |
|
|
L1ObjColl* l1OtherColl = 0;
|
96 |
|
|
L1ObjColl* l1RpcCollEmu = 0;
|
97 |
|
|
|
98 |
|
|
chain.SetBranchAddress("event",&event);
|
99 |
|
|
chain.SetBranchAddress("muon",&muon);
|
100 |
|
|
|
101 |
konec |
1.5 |
chain.SetBranchAddress("bitsL1",&bitsL1);
|
102 |
|
|
chain.SetBranchAddress("bitsHLT",&bitsHLT);
|
103 |
|
|
|
104 |
konec |
1.1 |
chain.SetBranchAddress("counts",&counts,&bcounts);
|
105 |
|
|
chain.SetBranchAddress("detsCrossedByMuon",&detsCrossedByMuon,&bdetsCrossedByMuon);
|
106 |
|
|
chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
|
107 |
|
|
chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
|
108 |
|
|
chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
|
109 |
|
|
chain.SetBranchAddress("nDigisCompDets",&nDigisCompDets, &bnDigisCompDets);
|
110 |
konec |
1.2 |
chain.SetBranchAddress("clSizeCompDets",&clSizeCompDets, &bclSizeCompDets);
|
111 |
konec |
1.1 |
|
112 |
|
|
chain.SetBranchAddress("l1RpcColl",&l1RpcColl);
|
113 |
|
|
chain.SetBranchAddress("l1OtherColl",&l1OtherColl);
|
114 |
|
|
chain.SetBranchAddress("l1RpcCollEmu",&l1RpcCollEmu);
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
//
|
118 |
konec |
1.5 |
// number of events
|
119 |
konec |
1.1 |
//
|
120 |
|
|
Int_t nentries = (Int_t) chain.GetEntries();
|
121 |
|
|
std::cout <<" ENTRIES: " << nentries << std::endl;
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
//
|
125 |
|
|
// main loop
|
126 |
|
|
//
|
127 |
|
|
unsigned int lastRun = 0;
|
128 |
|
|
for (int ev=0; ev<nentries; ev++) {
|
129 |
|
|
chain.GetEntry(ev);
|
130 |
|
|
|
131 |
|
|
if (lastRun != (*event).run) {
|
132 |
|
|
lastRun = (*event).run;
|
133 |
|
|
std::cout <<"RUN:" << std::setw(7) << (*event).run
|
134 |
|
|
<<" event:" << std::setw(8) << ev
|
135 |
|
|
<<" done:" << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%"<<std::endl;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
// if (ev > 10) break;
|
139 |
|
|
|
140 |
|
|
// if (event->run != 178854) continue;
|
141 |
|
|
// if (lastLumi != (*event).lumi) { lastLumi = (*event).lumi; std::cout <<"lumi: " << (*event).lumi<<std::endl; }
|
142 |
|
|
// theAnaDet.debug = false;
|
143 |
|
|
// if ((*event).id==60422922)theAnaRpcMisc.debug = true;
|
144 |
|
|
|
145 |
konec |
1.6 |
static std::vector<std::string> namesL1;
|
146 |
|
|
if (bitsL1->names.size() != 0) namesL1=bitsL1->names;
|
147 |
|
|
static std::vector<std::string> namesHLT;
|
148 |
|
|
if (bitsHLT->names.size() != 0) namesHLT=bitsHLT->names;
|
149 |
|
|
const std::vector<unsigned int> & algosL1 = bitsL1->firedAlgos;
|
150 |
|
|
const std::vector<unsigned int> & algosHLT = bitsHLT->firedAlgos;
|
151 |
|
|
|
152 |
|
|
/*
|
153 |
|
|
std::cout <<" Number of bits L1: " << bitsL1->names.size()<<"/"<<namesL1.size()<<"/"<<bitsL1->firedAlgos.size()
|
154 |
|
|
<<" HLT: "<< bitsHLT->names.size()<<"/"<<namesHLT.size()<<"/"<<bitsHLT->firedAlgos.size()<<std::endl;
|
155 |
|
|
std::cout <<"----------------------- L1: "<<std::endl;
|
156 |
|
|
for (std::vector<unsigned int>::const_iterator it=algosL1.begin(); it< algosL1.end(); ++it) std::cout <<"L1 idx: "<<*it<<" "<<namesL1[*it]<< std::endl;
|
157 |
|
|
std::cout <<"----------------------- HLT: "<<std::endl;
|
158 |
|
|
for (std::vector<unsigned int>::const_iterator it=algosHLT.begin(); it< algosHLT.end(); ++it) std::cout<<" HLT idx: "<<*it<<" "<<namesHLT[*it]<< std::endl;
|
159 |
|
|
*/
|
160 |
konec |
1.5 |
|
161 |
konec |
1.1 |
theAnaMuonDistribution.run(muon);
|
162 |
|
|
theAnaRpcVsOth.run(muon,l1RpcColl,l1OtherColl);
|
163 |
|
|
theAnaEff.run(muon,l1RpcColl,l1OtherColl);
|
164 |
|
|
theAnaRpcMisc.run(event,muon,l1RpcColl,l1OtherColl);
|
165 |
|
|
theAnaDet.run( muon, *detsHitsCompatibleWithMuon, *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
|
166 |
|
|
theAnaEmu.run ( event, muon, l1RpcCollEmu, l1RpcColl);
|
167 |
|
|
theAnaSynch.run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
|
168 |
konec |
1.2 |
theAnaClu.run( event, muon, l1RpcColl, *detsHitsCompatibleWithMuon, *nDigisCompDets, *clSizeCompDets);
|
169 |
konec |
1.4 |
theAnaTimingL1.run(event,muon,l1RpcColl,l1OtherColl);
|
170 |
konec |
1.1 |
|
171 |
|
|
// theAnaEmu.debug =theAnaDet.debug;
|
172 |
|
|
// std::cout <<"----------"<<std::endl;
|
173 |
|
|
// theAnaDet.debug =theAnaEmu.debug;
|
174 |
|
|
// if (anaDet.debug) std::cout <<" Event: "<<(*event).id <<" Lumi: "<<(*event).lumi<< std::endl;
|
175 |
|
|
|
176 |
|
|
}
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
void L1RpcTreeAnalysis::endJob()
|
180 |
|
|
{
|
181 |
|
|
std::cout <<"ENDJOB, summaries:"<<std::endl;
|
182 |
konec |
1.3 |
TGraph* hGraph_DetEff = theAnaDet.resume();
|
183 |
|
|
theAnaRpcMisc.resume(theHistos);
|
184 |
konec |
1.2 |
TGraph* hGraph_RunClu = theAnaClu.resume();
|
185 |
konec |
1.4 |
theAnaTimingL1.resume(theHistos);
|
186 |
konec |
1.1 |
|
187 |
|
|
theAnaSynch.endJob();
|
188 |
|
|
|
189 |
|
|
std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
|
190 |
|
|
TFile f(histoFile.c_str(),"RECREATE");
|
191 |
|
|
theHistos.Write();
|
192 |
|
|
hGraph_DetEff->Write("hGraph_DetEff");
|
193 |
konec |
1.2 |
hGraph_RunClu->Write("hGraph_RunClu");
|
194 |
konec |
1.1 |
f.Close();
|
195 |
|
|
std::cout <<"END"<<std::endl;
|
196 |
|
|
}
|