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.27 by akalinow, Thu Jul 11 11:25:22 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 +  if (theConfig.exists("anaMuonDistribution")) theAnaMuonDistribution = new AnaMuonDistribution( cfg.getParameter<edm::ParameterSet>("anaMuonDistribution"));
52 +  if (theConfig.exists("anaMenu")) theAnaMenu = new AnaMenu(theConfig.getParameter<edm::ParameterSet>("anaMenu"));
53 +  if (theConfig.exists("anaTimingL1")) theAnaTimingL1 = new AnaTimingL1( theConfig.getParameter<edm::ParameterSet>("anaTimingL1") );
54 +  if (theConfig.exists("anaEvent")) theAnaEvent = new   AnaEvent(cfg.getParameter<edm::ParameterSet>("anaEvent") );
55 +  if (theConfig.exists("anaDigiSpec")) theAnaDigiSpec = new AnaDigiSpec(cfg.getParameter<edm::ParameterSet>("anaDigiSpec"));
56 +  if (theConfig.exists("anaHitSpec")) theAnaHitSpec = new AnaHitSpec(cfg.getParameter<edm::ParameterSet>("anaHitSpec"));
57 +  if (theConfig.exists("patternProducer")) thePatternProducer = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProducer"));
58 +  if (theConfig.exists("patternProvider")) thePatternProvider = new PatternManager(cfg.getParameter<edm::ParameterSet>("patternProvider"));
59 +  if (theConfig.exists("anaSiMuDistribution")) theAnaSiMuDistribution = new AnaSiMuDistribution( cfg.getParameter<edm::ParameterSet>("anaSiMuDistribution"));
60 +  if (theConfig.exists("anaOtfEff")) theAnaOtfEff = new AnaOtfEff( cfg.getParameter<edm::ParameterSet>("anaOtfEff"));
61 +  if (theConfig.exists("anaEff")) theAnaEff = new   AnaEff(cfg.getParameter<edm::ParameterSet>("anaEff") );
62 +  if (theConfig.exists("anaRpcVsOth")) theAnaRpcVsOth = new   AnaRpcVsOth(cfg.getParameter<edm::ParameterSet>("anaRpcVsOth") );
63 +  
64 + }
65  
66   void L1RpcTreeAnalysis::beginJob()
67   {
68    theHistos.SetOwner();
69  
70 <  theAnaMuonDistribution.init(theHistos);
71 <  theAnaRpcVsOth.init(theHistos);
72 <  theAnaRpcMisc.init(theHistos);
73 <  theAnaEff.init(theHistos);
74 <  theAnaDet.init(theHistos);
75 <  theAnaEmu.init(theHistos);
76 <  theAnaSynch.init(theHistos);
77 <  theAnaClu.init(theHistos);
78 <  theAnaTimingL1.init(theHistos);
70 >  if (theAnaMuonDistribution) theAnaMuonDistribution->init(theHistos);
71 >  if (theAnaRpcVsOth)         theAnaRpcVsOth->init(theHistos);
72 >  if (theAnaRpcMisc)          theAnaRpcMisc->init(theHistos);
73 >  if (theAnaEff)              theAnaEff->init(theHistos);
74 >  if (theAnaDet)              theAnaDet->init(theHistos);
75 >  if (theAnaEmu)              theAnaEmu->init(theHistos);
76 >  if (theAnaSynch)            theAnaSynch->init(theHistos);
77 >  if (theAnaClu)              theAnaClu->init(theHistos);
78 >  if (theAnaTimingL1)         theAnaTimingL1->init(theHistos);
79 >  if (theAnaEvent)            theAnaEvent->init(theHistos);
80 >  if (theAnaMenu)             theAnaMenu->init(theHistos);
81 >  if (theAnaDigiSpec)         theAnaDigiSpec->init(theHistos);
82 >  if (theAnaHitSpec)          theAnaHitSpec->init(theHistos);
83 >  if (theAnaSiMuDistribution) theAnaSiMuDistribution->init(theHistos);
84 >  if (theAnaOtfEff)           theAnaOtfEff->init(theHistos);
85  
86 +  if (thePatternProvider)     thePatternProvider->beginJob();
87   }
88  
89   void L1RpcTreeAnalysis::beginRun(const edm::Run& ru, const edm::EventSetup& es)
90   {
91 <  theAnaSynch.beginRun(ru,es);
91 >  if (theAnaSynch) theAnaSynch->beginRun(ru,es);
92   }
93  
94   void L1RpcTreeAnalysis::analyze(const edm::Event&, const edm::EventSetup&)
# Line 75 | Line 119 | void L1RpcTreeAnalysis::analyze(const ed
119    std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
120    std::vector<DetCluDigiObj> *detsHitsCompatibleWithMuon = 0;
121    std::vector<uint32_t> *detsSIMU = 0;
122 +  std::vector<std::pair<uint32_t, uint32_t> > *digSpec = 0;
123  
124    EventObj * event = 0;
125    MuonObj * muon = 0;
126 +  TrackObj * simu = 0;
127  
128    TriggerMenuResultObj *bitsL1  = 0;
129    TriggerMenuResultObj *bitsHLT = 0;
# Line 87 | Line 133 | void L1RpcTreeAnalysis::analyze(const ed
133    TBranch *bdetsCrossedByMuonDeepInside =0;
134    TBranch *bdetsHitsCompatibleWithMuon = 0;
135    TBranch *bdetsSIMU =0;
136 +  TBranch *bdigSpec = 0;
137  
138 <  L1ObjColl* l1RpcColl = 0;
139 <  L1ObjColl* l1OtherColl = 0;
140 <  L1ObjColl* l1RpcCollEmu = 0;
94 <  L1ObjColl* l1GmtColl = 0;
138 >  L1ObjColl* l1ObjColl = 0;
139 >  HitSpecObj* hitSpec = 0;
140 >  
141  
142    chain.SetBranchAddress("event",&event);
143    chain.SetBranchAddress("muon",&muon);
144 +  chain.SetBranchAddress("simu",&simu);
145  
146    chain.SetBranchAddress("bitsL1",&bitsL1);
147    chain.SetBranchAddress("bitsHLT",&bitsHLT);
# Line 104 | Line 151 | void L1RpcTreeAnalysis::analyze(const ed
151    chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
152    chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
153    chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
154 +  chain.SetBranchAddress("digSpec",&digSpec,&bdigSpec);
155  
156 <  chain.SetBranchAddress("l1RpcColl",&l1RpcColl);
157 <  chain.SetBranchAddress("l1OtherColl",&l1OtherColl);
110 <  chain.SetBranchAddress("l1RpcCollEmu",&l1RpcCollEmu);
111 <  chain.SetBranchAddress("l1GmtColl",&l1GmtColl);
156 >  chain.SetBranchAddress("l1ObjColl",&l1ObjColl);
157 >  chain.SetBranchAddress("hitSpec",&hitSpec);
158  
159  
160    //
# Line 116 | Line 162 | void L1RpcTreeAnalysis::analyze(const ed
162    //
163    Int_t nentries = (Int_t) chain.GetEntries();
164    std::cout <<" ENTRIES: " << nentries << std::endl;
165 <
120 <
165 >  //nentries = 10938;
166    //
167    // main loop
168    //
169    unsigned int lastRun = 0;
170 <  for (int ev=0; ev<nentries; ev++) {
170 >  for (int ev=0; ev<nentries; ev+=10) {
171      chain.GetEntry(ev);
172 +    if (theAnaMenu) theAnaMenu->updateMenu(bitsL1->names, bitsHLT->names);
173  
174 <    if (lastRun != (*event).run) {
174 >    if ( (lastRun != (*event).run) || (ev%1000000==0) ) {
175        lastRun = (*event).run;
176        std::cout <<"RUN:"    << std::setw(7) << (*event).run
177                  <<" event:" << std::setw(8) << ev
178 <                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%"<<std::endl;
178 >                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%";
179 >      std::cout<<std::endl;
180      }
181  
182 < //    if (ev > 10) break;
183 <
184 < //    if (event->run != 178854) continue;
185 < //    if (lastLumi != (*event).lumi) { lastLumi = (*event).lumi; std::cout <<"lumi: " << (*event).lumi<<std::endl; }
186 < //   theAnaDet.debug = false;
187 < //    if ((*event).id==60422922)theAnaRpcMisc.debug = true;
188 <
189 <   static std::vector<std::string>   namesL1;
190 <   if (bitsL1->names.size() != 0)    namesL1=bitsL1->names;
191 <   static std::vector<std::string>   namesHLT;
192 <   if (bitsHLT->names.size() != 0)   namesHLT=bitsHLT->names;
193 <   const std::vector<unsigned int> & algosL1 = bitsL1->firedAlgos;
194 <   const std::vector<unsigned int> & algosHLT = bitsHLT->firedAlgos;
195 <
196 < /*
197 <   std::cout <<" Number of bits L1: " <<  bitsL1->names.size()<<"/"<<namesL1.size()<<"/"<<bitsL1->firedAlgos.size()
198 <                           <<" HLT: "<< bitsHLT->names.size()<<"/"<<namesHLT.size()<<"/"<<bitsHLT->firedAlgos.size()<<std::endl;
199 <   std::cout <<"----------------------- L1: "<<std::endl;
200 <   for (std::vector<unsigned int>::const_iterator it=algosL1.begin(); it< algosL1.end(); ++it) std::cout <<"L1 idx: "<<*it<<" "<<namesL1[*it]<< std::endl;
201 <   std::cout <<"----------------------- HLT: "<<std::endl;
202 <   for (std::vector<unsigned int>::const_iterator it=algosHLT.begin(); it< algosHLT.end(); ++it) std::cout<<" HLT idx: "<<*it<<" "<<namesHLT[*it]<< std::endl;
203 < */
204 <
205 <   theAnaMuonDistribution.run(muon);
206 <   theAnaRpcVsOth.run(muon,l1RpcColl,l1OtherColl);
207 <   theAnaEff.run(muon,l1RpcColl,l1OtherColl);
208 <   theAnaRpcMisc.run(event,muon,l1RpcColl,l1OtherColl);
209 <   theAnaDet.run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
210 <   theAnaEmu.run ( event, muon, l1RpcCollEmu, l1RpcColl);
211 <   theAnaSynch.run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
212 <   theAnaClu.run( event, muon, l1RpcColl, *detsHitsCompatibleWithMuon);
213 <   theAnaTimingL1.run(event,muon,l1RpcColl,l1OtherColl);
214 <
215 < /*
216 <   std::cout <<"----------------"<<std::endl;
170 <   std::cout <<"GmtColl:"<<std::endl; l1GmtColl->print();
171 <   std::cout <<"RpcColl:"<<std::endl; l1RpcColl->print();
172 <   std::cout <<"OtherColl:"<<std::endl; l1OtherColl->print();
173 < */
174 < //   theAnaEmu.debug =theAnaDet.debug;
175 < //    std::cout <<"----------"<<std::endl;
176 < //   theAnaDet.debug =theAnaEmu.debug;
177 < //    if (anaDet.debug) std::cout <<" Event: "<<(*event).id <<" Lumi: "<<(*event).lumi<< std::endl;
178 <  
182 >   // EVENT NUMBER, BX structure etc.
183 >   EventObjBXExtra eventBx(*event);
184 >   if ( theAnaEvent && !theAnaEvent->filter(&eventBx) && theConfig.getParameter<bool>("filterByAnaEvent") ) continue;
185 >   // ANALYSE AND FILTER KINEMCTICS
186 >   if ( theAnaMuonDistribution && !theAnaMuonDistribution->filter(muon) && theConfig.getParameter<bool>("filterByAnaMuonDistribution") ) continue;
187 >   // ANALYSE AND FILTER TRIGGER MENU
188 >   if ( theAnaMenu && !theAnaMenu->filter(event, muon, bitsL1, bitsHLT) && theConfig.getParameter<bool>("filterByAnaMenu") ) continue;
189 >   // ANALYSE AND FILTER SIMU KONEMATICs
190 >   if ( theAnaSiMuDistribution && !theAnaSiMuDistribution->filter(event, simu, hitSpec) && theConfig.getParameter<bool>("filterByAnaSiMuDistribution") ) continue;
191 >
192 >   const TrackObj * refTrack = theConfig.getParameter<bool>("useSiMuReference") ? simu : muon;
193 >
194 >   // ANALYSES
195 >   if (theAnaRpcVsOth) theAnaRpcVsOth->run(refTrack,l1ObjColl);
196 >
197 > //   std::cout <<"refTrack: "<< *refTrack<<std::endl;
198 > //   std::cout <<"l1ObjColl: "<< *l1ObjColl << std::endl;
199 >
200 >   if (theAnaRpcMisc)  theAnaRpcMisc->run(event,muon,l1ObjColl);
201 >   if (theAnaDet)      theAnaDet->run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
202 >   if (theAnaEmu)      theAnaEmu->run ( event, muon, l1ObjColl);
203 >   if (theAnaSynch)    theAnaSynch->run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
204 >   if (theAnaClu)      theAnaClu->run( event, muon, l1ObjColl, *detsHitsCompatibleWithMuon);
205 >   if (theAnaTimingL1) theAnaTimingL1->run( &eventBx, muon, l1ObjColl);
206 >
207 >   // HITPATTERN ANALYSES & OTF EFFICIENCY
208 >   if (theAnaHitSpec) theAnaHitSpec->run(event, simu, hitSpec);
209 >   if (theAnaDigiSpec) theAnaDigiSpec->run(event, simu, hitSpec, *digSpec);
210 >   if (thePatternProducer) thePatternProducer->run(event, simu, hitSpec, *digSpec);
211 >   L1Obj l1otf;
212 >   if (thePatternProvider) l1otf=thePatternProvider->check(event, simu, hitSpec, *digSpec);
213 >   if (theAnaOtfEff) theAnaOtfEff->run(event,simu,l1otf);  
214 >   L1ObjColl myL1ObjColl = *l1ObjColl;
215 >   myL1ObjColl.push_back(l1otf, false, 0.);
216 >   if (theAnaEff)      theAnaEff->run(refTrack, &myL1ObjColl, hitSpec);
217    }
218   }
219  
220   void L1RpcTreeAnalysis::endJob()
221   {
222    std::cout <<"ENDJOB, summaries:"<<std::endl;
223 <  TGraph* hGraph_DetEff = theAnaDet.resume();
224 <  theAnaRpcMisc.resume(theHistos);
225 <  TGraph* hGraph_RunClu = theAnaClu.resume();
226 <  theAnaTimingL1.resume(theHistos);
227 <
228 <  theAnaSynch.endJob();
223 >  TGraph* hGraph_DetEff = (theAnaDet) ? theAnaDet->resume() : 0;
224 >  TGraph* hGraph_RunClu = (theAnaClu) ? theAnaClu->resume(): 0;
225 >  if (theAnaRpcMisc) theAnaRpcMisc->resume(theHistos);
226 >  if (theAnaTimingL1)  theAnaTimingL1->resume(theHistos);
227 >  if (theAnaMenu)     theAnaMenu->resume(theHistos);
228 >  if (theAnaMenu) theAnaEvent->resume(theHistos);
229 >  if (theAnaHitSpec) theAnaHitSpec->resume(theHistos);
230 >  if (theAnaDigiSpec) theAnaDigiSpec->resume(theHistos);
231 >
232 >  if (theAnaSynch) theAnaSynch->endJob();
233 >  if (thePatternProducer) thePatternProducer->endJob();
234 >  if (thePatternProvider) thePatternProvider->endJob();
235  
236    std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
237    TFile f(histoFile.c_str(),"RECREATE");
238    theHistos.Write();
239 <  hGraph_DetEff->Write("hGraph_DetEff");
240 <  hGraph_RunClu->Write("hGraph_RunClu");
239 >  if (hGraph_DetEff) hGraph_DetEff->Write("hGraph_DetEff");
240 >  if (hGraph_RunClu) hGraph_RunClu->Write("hGraph_RunClu");
241    f.Close();
242    std::cout <<"END"<<std::endl;
243 +
244 +  delete theAnaMuonDistribution;
245 +  delete theAnaRpcVsOth;
246 +  delete theAnaRpcMisc;
247 +  delete theAnaEff;
248 +  delete theAnaDet;
249 +  delete theAnaEmu;
250 +  delete theAnaSynch;
251 +  delete theAnaClu;
252 +  delete theAnaTimingL1;
253 +  delete theAnaMenu;
254 +  delete theAnaEvent;
255 +  delete theAnaDigiSpec;
256 +  delete theAnaHitSpec;
257 +  delete thePatternProducer;
258 +  delete thePatternProvider;
259 +  delete theAnaSiMuDistribution;
260 +  delete theAnaOtfEff;
261   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines