ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/plugins/L1RpcTreeAnalysis.cc
(Generate patch)

Comparing UserCode/L1RpcTriggerAnalysis/plugins/L1RpcTreeAnalysis.cc (file contents):
Revision 1.7 by konec, Tue Oct 23 20:17:44 2012 UTC vs.
Revision 1.24 by akalinow, Tue Jun 25 10:49:35 2013 UTC

# Line 16 | Line 16
16  
17   #include "UserCode/L1RpcTriggerAnalysis/interface/L1Obj.h"
18   #include "UserCode/L1RpcTriggerAnalysis/interface/EventObj.h"
19 + #include "UserCode/L1RpcTriggerAnalysis/interface/EventObjBXExtra.h"
20   #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   #include "UserCode/L1RpcTriggerAnalysis/interface/DetCluDigiObj.h"
25   #include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
26 + #include "UserCode/L1RpcTriggerAnalysis/interface/HitSpecObj.h"
27 +
28  
29   #include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
30  
31 + L1RpcTreeAnalysis::L1RpcTreeAnalysis(const edm::ParameterSet & cfg)
32 +  : theConfig(cfg),
33 +    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 +    theAnaSiMuDistribution(0),
49 +    theAnaOtfEff(0)
50 + {
51 +
52 +  if (theConfig.exists("anaMuonDistribution")) theAnaMuonDistribution = new AnaMuonDistribution( cfg.getParameter<edm::ParameterSet>("anaMuonDistribution"));
53 +  if (theConfig.exists("anaMenu")) theAnaMenu = new AnaMenu(theConfig.getParameter<edm::ParameterSet>("anaMenu"));
54 +  if (theConfig.exists("anaTimingL1")) theAnaTimingL1 = new AnaTimingL1( theConfig.getParameter<edm::ParameterSet>("anaTimingL1") );
55 +  if (theConfig.exists("anaEvent")) theAnaEvent = new   AnaEvent(cfg.getParameter<edm::ParameterSet>("anaEvent") );
56 +  if (theConfig.exists("anaDigiSpec")) theAnaDigiSpec = new AnaDigiSpec(cfg.getParameter<edm::ParameterSet>("anaDigiSpec"));
57 +  if (theConfig.exists("anaHitSpec")) theAnaHitSpec = new AnaHitSpec(cfg.getParameter<edm::ParameterSet>("anaHitSpec"));
58 +  if (theConfig.exists("patternProducer")) thePatternProducer = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProducer"));
59 +  if (theConfig.exists("patternProvider")) thePatternProvider = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProvider"));
60 +  if (theConfig.exists("anaSiMuDistribution")) theAnaSiMuDistribution = new AnaSiMuDistribution( cfg.getParameter<edm::ParameterSet>("anaSiMuDistribution"));
61 +  if (theConfig.exists("anaOtfEff")) theAnaOtfEff = new AnaOtfEff( cfg.getParameter<edm::ParameterSet>("anaOtfEff"));
62 +  if (theConfig.exists("anaEff")) theAnaEff = new   AnaEff(cfg.getParameter<edm::ParameterSet>("anaEff") );
63 +  if (theConfig.exists("anaRpcVsOth")) theAnaRpcVsOth = new   AnaRpcVsOth(cfg.getParameter<edm::ParameterSet>("anaRpcVsOth") );
64 +  
65 + }
66  
67   void L1RpcTreeAnalysis::beginJob()
68   {
69 +
70    theHistos.SetOwner();
71  
72 <  theAnaMuonDistribution.init(theHistos);
73 <  theAnaRpcVsOth.init(theHistos);
74 <  theAnaRpcMisc.init(theHistos);
75 <  theAnaEff.init(theHistos);
76 <  theAnaDet.init(theHistos);
77 <  theAnaEmu.init(theHistos);
78 <  theAnaSynch.init(theHistos);
79 <  theAnaClu.init(theHistos);
80 <  theAnaTimingL1.init(theHistos);
72 >  if (theAnaMuonDistribution) theAnaMuonDistribution->init(theHistos);
73 >  if (theAnaRpcVsOth)         theAnaRpcVsOth->init(theHistos);
74 >  if (theAnaRpcMisc)          theAnaRpcMisc->init(theHistos);
75 >  if (theAnaEff)              theAnaEff->init(theHistos);
76 >  if (theAnaDet)              theAnaDet->init(theHistos);
77 >  if (theAnaEmu)              theAnaEmu->init(theHistos);
78 >  if (theAnaSynch)            theAnaSynch->init(theHistos);
79 >  if (theAnaClu)              theAnaClu->init(theHistos);
80 >  if (theAnaTimingL1)         theAnaTimingL1->init(theHistos);
81 >  if (theAnaEvent)            theAnaEvent->init(theHistos);
82 >  if (theAnaMenu)             theAnaMenu->init(theHistos);
83 >  if (theAnaDigiSpec)         theAnaDigiSpec->init(theHistos);
84 >  if (theAnaHitSpec)          theAnaHitSpec->init(theHistos);
85 >  if (theAnaSiMuDistribution) theAnaSiMuDistribution->init(theHistos);
86 >  if (theAnaOtfEff)           theAnaOtfEff->init(theHistos);
87  
88 +  if (thePatternProvider)     thePatternProvider->beginJob();
89   }
90  
91   void L1RpcTreeAnalysis::beginRun(const edm::Run& ru, const edm::EventSetup& es)
92   {
93 <  theAnaSynch.beginRun(ru,es);
93 >  if (theAnaSynch) theAnaSynch->beginRun(ru,es);
94   }
95  
96   void L1RpcTreeAnalysis::analyze(const edm::Event&, const edm::EventSetup&)
# Line 62 | Line 108 | void L1RpcTreeAnalysis::analyze(const ed
108    //
109    // define input chain
110    //
111 +
112    TChain chain("tL1Rpc");
113    std::vector<std::string> treeFileNames = theConfig.getParameter<std::vector<std::string> >("treeFileNames");
114    for (std::vector<std::string>::const_iterator it = treeFileNames.begin(); it != treeFileNames.end(); ++it)  chain.Add((*it).c_str() );
115  
69
116    //
117    // prepare datastructures and branches
118    //
# Line 75 | Line 121 | void L1RpcTreeAnalysis::analyze(const ed
121    std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
122    std::vector<DetCluDigiObj> *detsHitsCompatibleWithMuon = 0;
123    std::vector<uint32_t> *detsSIMU = 0;
124 +  std::vector<std::pair<uint32_t, uint32_t> > *digSpec = 0;
125  
126    EventObj * event = 0;
127    MuonObj * muon = 0;
128 +  TrackObj * simu = 0;
129  
130    TriggerMenuResultObj *bitsL1  = 0;
131    TriggerMenuResultObj *bitsHLT = 0;
# Line 87 | Line 135 | void L1RpcTreeAnalysis::analyze(const ed
135    TBranch *bdetsCrossedByMuonDeepInside =0;
136    TBranch *bdetsHitsCompatibleWithMuon = 0;
137    TBranch *bdetsSIMU =0;
138 +  TBranch *bdigSpec = 0;
139  
140 <  L1ObjColl* l1RpcColl = 0;
141 <  L1ObjColl* l1OtherColl = 0;
142 <  L1ObjColl* l1RpcCollEmu = 0;
94 <  L1ObjColl* l1GmtColl = 0;
140 >  L1ObjColl* l1ObjColl = 0;
141 >  HitSpecObj* hitSpec = 0;
142 >  
143  
144    chain.SetBranchAddress("event",&event);
145    chain.SetBranchAddress("muon",&muon);
146 +  chain.SetBranchAddress("simu",&simu);
147  
148    chain.SetBranchAddress("bitsL1",&bitsL1);
149    chain.SetBranchAddress("bitsHLT",&bitsHLT);
# Line 104 | Line 153 | void L1RpcTreeAnalysis::analyze(const ed
153    chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
154    chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
155    chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
156 +  chain.SetBranchAddress("digSpec",&digSpec,&bdigSpec);
157  
158 <  chain.SetBranchAddress("l1RpcColl",&l1RpcColl);
159 <  chain.SetBranchAddress("l1OtherColl",&l1OtherColl);
110 <  chain.SetBranchAddress("l1RpcCollEmu",&l1RpcCollEmu);
111 <  chain.SetBranchAddress("l1GmtColl",&l1GmtColl);
112 <
158 >  chain.SetBranchAddress("l1ObjColl",&l1ObjColl);
159 >  chain.SetBranchAddress("hitSpec",&hitSpec);
160  
161    //
162    // number of events
# Line 118 | Line 165 | void L1RpcTreeAnalysis::analyze(const ed
165    std::cout <<" ENTRIES: " << nentries << std::endl;
166  
167  
168 +
169    //
170    // main loop
171    //
172    unsigned int lastRun = 0;
173    for (int ev=0; ev<nentries; ev++) {
174      chain.GetEntry(ev);
175 +    if (theAnaMenu) theAnaMenu->updateMenu(bitsL1->names, bitsHLT->names);
176  
177 <    if (lastRun != (*event).run) {
177 > //    if (ev < 44055) continue;
178 >    if ( (lastRun != (*event).run) || (ev%10000==0) ) {
179 > //    if (true) {
180 > //    if (! ((*event).run==204601 && (*event).id ==109463402)) { continue;
181        lastRun = (*event).run;
182        std::cout <<"RUN:"    << std::setw(7) << (*event).run
183                  <<" event:" << std::setw(8) << ev
184 <                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%"<<std::endl;
184 >                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%";
185 >      std::cout<<std::endl;
186      }
187  
188 < //    if (ev > 10) break;
189 <
190 < //    if (event->run != 178854) continue;
191 < //    if (lastLumi != (*event).lumi) { lastLumi = (*event).lumi; std::cout <<"lumi: " << (*event).lumi<<std::endl; }
192 < //   theAnaDet.debug = false;
193 < //    if ((*event).id==60422922)theAnaRpcMisc.debug = true;
194 <
195 <   static std::vector<std::string>   namesL1;
196 <   if (bitsL1->names.size() != 0)    namesL1=bitsL1->names;
197 <   static std::vector<std::string>   namesHLT;
198 <   if (bitsHLT->names.size() != 0)   namesHLT=bitsHLT->names;
199 <   const std::vector<unsigned int> & algosL1 = bitsL1->firedAlgos;
200 <   const std::vector<unsigned int> & algosHLT = bitsHLT->firedAlgos;
201 <
202 < /*
203 <   std::cout <<" Number of bits L1: " <<  bitsL1->names.size()<<"/"<<namesL1.size()<<"/"<<bitsL1->firedAlgos.size()
204 <                           <<" HLT: "<< bitsHLT->names.size()<<"/"<<namesHLT.size()<<"/"<<bitsHLT->firedAlgos.size()<<std::endl;
205 <   std::cout <<"----------------------- L1: "<<std::endl;
153 <   for (std::vector<unsigned int>::const_iterator it=algosL1.begin(); it< algosL1.end(); ++it) std::cout <<"L1 idx: "<<*it<<" "<<namesL1[*it]<< std::endl;
154 <   std::cout <<"----------------------- HLT: "<<std::endl;
155 <   for (std::vector<unsigned int>::const_iterator it=algosHLT.begin(); it< algosHLT.end(); ++it) std::cout<<" HLT idx: "<<*it<<" "<<namesHLT[*it]<< std::endl;
188 > /*  
189 >   if (     event->id == 597978012
190 >        ||  event->id == 14791798  
191 >        ||  event->id == 436261807
192 >        ||  event->id == 873776280  
193 >        ||  event->id == 960307389
194 >        ||  event->id == 150097556
195 >        ||  event->id == 42062946
196 >        ||  event->id == 1064121551
197 >        ||  event->id == 1499489591
198 >        ||  event->id == 60161631
199 >        ||  event->id == 624624695
200 >        ||  event->id == 727298833
201 >        ||  event->id == 835600542
202 >        ||  event->id == 216373776
203 >        ||  event->id == 1107585611
204 >        ||  event->id == 197907027
205 >      ) theAnaMenu.debug = true; else theAnaMenu.debug = false;
206   */
207  
208 <   theAnaMuonDistribution.run(muon);
209 <   theAnaRpcVsOth.run(muon,l1RpcColl,l1OtherColl);
210 <   theAnaEff.run(muon,l1RpcColl,l1OtherColl);
211 <   theAnaRpcMisc.run(event,muon,l1RpcColl,l1OtherColl);
212 <   theAnaDet.run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
213 <   theAnaEmu.run ( event, muon, l1RpcCollEmu, l1RpcColl);
214 <   theAnaSynch.run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
215 <   theAnaClu.run( event, muon, l1RpcColl, *detsHitsCompatibleWithMuon);
216 <   theAnaTimingL1.run(event,muon,l1RpcColl,l1OtherColl);
217 <
218 < /*
219 <   std::cout <<"----------------"<<std::endl;
220 <   std::cout <<"GmtColl:"<<std::endl; l1GmtColl->print();
221 <   std::cout <<"RpcColl:"<<std::endl; l1RpcColl->print();
222 <   std::cout <<"OtherColl:"<<std::endl; l1OtherColl->print();
223 < */
224 < //   theAnaEmu.debug =theAnaDet.debug;
225 < //    std::cout <<"----------"<<std::endl;
226 < //   theAnaDet.debug =theAnaEmu.debug;
227 < //    if (anaDet.debug) std::cout <<" Event: "<<(*event).id <<" Lumi: "<<(*event).lumi<< std::endl;
228 <  
208 >   // EVENT NUMBER, BX structure etc.
209 >   EventObjBXExtra eventBx(*event);
210 >   if ( theAnaEvent && !theAnaEvent->filter(&eventBx) && theConfig.getParameter<bool>("filterByAnaEvent") ) continue;
211 >   // ANALYSE AND FILTER KINEMCTICS
212 >   if ( theAnaMuonDistribution && !theAnaMuonDistribution->filter(muon) && theConfig.getParameter<bool>("filterByAnaMuonDistribution") ) continue;
213 >   // ANALYSE AND FILTER TRIGGER MENU
214 >   if ( theAnaMenu && !theAnaMenu->filter(event, muon, bitsL1, bitsHLT) && theConfig.getParameter<bool>("filterByAnaMenu") ) continue;
215 >   // ANALYSE AND FILTER SIMU KONEMATICs
216 >   if ( theAnaSiMuDistribution && !theAnaSiMuDistribution->filter(event, simu, hitSpec) && theConfig.getParameter<bool>("filterByAnaSiMuDistribution") ) continue;
217 >
218 >   const TrackObj * refTrack = theConfig.getParameter<bool>("useSiMuReference") ? simu : muon;
219 >
220 >   // ANALYSES
221 >   if (theAnaRpcVsOth) theAnaRpcVsOth->run(refTrack,l1ObjColl);
222 >
223 > //   std::cout <<"refTrack: "<< *refTrack<<std::endl;
224 > //   std::cout <<"l1ObjColl: "<< *l1ObjColl << std::endl;
225 >
226 >   if (theAnaRpcMisc)  theAnaRpcMisc->run(event,muon,l1ObjColl);
227 >   if (theAnaDet)      theAnaDet->run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
228 >   if (theAnaEmu)      theAnaEmu->run ( event, muon, l1ObjColl);
229 >   if (theAnaSynch)    theAnaSynch->run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
230 >   if (theAnaClu)      theAnaClu->run( event, muon, l1ObjColl, *detsHitsCompatibleWithMuon);
231 >   if (theAnaTimingL1) theAnaTimingL1->run( &eventBx, muon, l1ObjColl);
232 >
233 >   // HITPATTERN ANALYSES & OTF EFFICIENCY
234 >   if (theAnaHitSpec) theAnaHitSpec->run(event, simu, hitSpec);
235 >   if (theAnaDigiSpec) theAnaDigiSpec->run(event, simu, hitSpec, *digSpec);
236 >   if (thePatternProducer) thePatternProducer->run(event, simu, hitSpec, *digSpec);
237 >   L1Obj l1otf;
238 >   if (thePatternProvider) l1otf=thePatternProvider->check(event, simu, hitSpec, *digSpec);
239 >   if (theAnaOtfEff) theAnaOtfEff->run(event,simu,l1otf);  
240 >   L1ObjColl myL1ObjColl = *l1ObjColl;
241 >   myL1ObjColl.push_back(l1otf, false, 0.);
242 >   if (theAnaEff)      theAnaEff->run(refTrack, &myL1ObjColl);
243    }
244   }
245  
246   void L1RpcTreeAnalysis::endJob()
247   {
248    std::cout <<"ENDJOB, summaries:"<<std::endl;
249 <  TGraph* hGraph_DetEff = theAnaDet.resume();
250 <  theAnaRpcMisc.resume(theHistos);
251 <  TGraph* hGraph_RunClu = theAnaClu.resume();
252 <  theAnaTimingL1.resume(theHistos);
253 <
254 <  theAnaSynch.endJob();
249 >  TGraph* hGraph_DetEff = (theAnaDet) ? theAnaDet->resume() : 0;
250 >  TGraph* hGraph_RunClu = (theAnaClu) ? theAnaClu->resume(): 0;
251 >  if (theAnaRpcMisc) theAnaRpcMisc->resume(theHistos);
252 >  if (theAnaTimingL1)  theAnaTimingL1->resume(theHistos);
253 >  if (theAnaMenu)     theAnaMenu->resume(theHistos);
254 >  if (theAnaMenu) theAnaEvent->resume(theHistos);
255 >  if (theAnaHitSpec) theAnaHitSpec->resume(theHistos);
256 >  if (theAnaDigiSpec) theAnaDigiSpec->resume(theHistos);
257 >
258 >  if (theAnaSynch) theAnaSynch->endJob();
259 >  if (thePatternProducer) thePatternProducer->endJob();
260 >  if (thePatternProvider) thePatternProvider->endJob();
261  
262    std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
263    TFile f(histoFile.c_str(),"RECREATE");
264    theHistos.Write();
265 <  hGraph_DetEff->Write("hGraph_DetEff");
266 <  hGraph_RunClu->Write("hGraph_RunClu");
265 >  if (hGraph_DetEff) hGraph_DetEff->Write("hGraph_DetEff");
266 >  if (hGraph_RunClu) hGraph_RunClu->Write("hGraph_RunClu");
267    f.Close();
268    std::cout <<"END"<<std::endl;
269 +
270 +  delete theAnaMuonDistribution;
271 +  delete theAnaRpcVsOth;
272 +  delete theAnaRpcMisc;
273 +  delete theAnaEff;
274 +  delete theAnaDet;
275 +  delete theAnaEmu;
276 +  delete theAnaSynch;
277 +  delete theAnaClu;
278 +  delete theAnaTimingL1;
279 +  delete theAnaMenu;
280 +  delete theAnaEvent;
281 +  delete theAnaDigiSpec;
282 +  delete theAnaHitSpec;
283 +  delete thePatternProducer;
284 +  delete thePatternProvider;
285 +  delete theAnaSiMuDistribution;
286 +  delete theAnaOtfEff;
287   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines