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.2 by konec, Tue Oct 2 13:21:26 2012 UTC vs.
Revision 1.23 by konec, Mon May 27 11:02:41 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);
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 70 | Line 117 | void L1RpcTreeAnalysis::analyze(const ed
117    std::vector<SynchroCountsObj> *counts= 0;
118    std::vector<uint32_t> *detsCrossedByMuon = 0;
119    std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
120 <  std::vector<uint32_t> *detsHitsCompatibleWithMuon = 0;
120 >  std::vector<DetCluDigiObj> *detsHitsCompatibleWithMuon = 0;
121    std::vector<uint32_t> *detsSIMU = 0;
122 <  std::vector<uint32_t> *nDigisCompDets = 0;
76 <  std::vector<uint32_t> *clSizeCompDets = 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;
130  
131    TBranch *bcounts=0;
132    TBranch *bdetsCrossedByMuon =0;
133    TBranch *bdetsCrossedByMuonDeepInside =0;
134    TBranch *bdetsHitsCompatibleWithMuon = 0;
135    TBranch *bdetsSIMU =0;
136 <  TBranch *bnDigisCompDets =0;
87 <  TBranch *bclSizeCompDets =0;
136 >  TBranch *bdigSpec = 0;
137  
138 <  L1ObjColl* l1RpcColl = 0;
139 <  L1ObjColl* l1OtherColl = 0;
140 <  L1ObjColl* l1RpcCollEmu = 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);
148 +  
149    chain.SetBranchAddress("counts",&counts,&bcounts);
150    chain.SetBranchAddress("detsCrossedByMuon",&detsCrossedByMuon,&bdetsCrossedByMuon);
151    chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
152    chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
153    chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
154 <  chain.SetBranchAddress("nDigisCompDets",&nDigisCompDets, &bnDigisCompDets);
102 <  chain.SetBranchAddress("clSizeCompDets",&clSizeCompDets, &bclSizeCompDets);
154 >  chain.SetBranchAddress("digSpec",&digSpec,&bdigSpec);
155  
156 <  chain.SetBranchAddress("l1RpcColl",&l1RpcColl);
157 <  chain.SetBranchAddress("l1OtherColl",&l1OtherColl);
106 <  chain.SetBranchAddress("l1RpcCollEmu",&l1RpcCollEmu);
156 >  chain.SetBranchAddress("l1ObjColl",&l1ObjColl);
157 >  chain.SetBranchAddress("hitSpec",&hitSpec);
158  
159  
160    //
161 <  // number of efents
161 >  // number of events
162    //
163    Int_t nentries = (Int_t) chain.GetEntries();
164    std::cout <<" ENTRIES: " << nentries << std::endl;
# Line 119 | Line 170 | void L1RpcTreeAnalysis::analyze(const ed
170    unsigned int lastRun = 0;
171    for (int ev=0; ev<nentries; ev++) {
172      chain.GetEntry(ev);
173 +    if (theAnaMenu) theAnaMenu->updateMenu(bitsL1->names, bitsHLT->names);
174  
175 <    if (lastRun != (*event).run) {
175 > //    if (ev < 44055) continue;
176 >    if ( (lastRun != (*event).run) || (ev/1000*1000==ev) ) {
177 > //    if (true) {
178 > //    if (! ((*event).run==204601 && (*event).id ==109463402)) { continue;
179        lastRun = (*event).run;
180        std::cout <<"RUN:"    << std::setw(7) << (*event).run
181                  <<" event:" << std::setw(8) << ev
182 <                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%"<<std::endl;
182 >                <<" done:"  << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%";
183 >      std::cout<<std::endl;
184      }
185  
186 < //    if (ev > 10) break;
187 <
188 < //    if (event->run != 178854) continue;
189 < //    if (lastLumi != (*event).lumi) { lastLumi = (*event).lumi; std::cout <<"lumi: " << (*event).lumi<<std::endl; }
190 < //   theAnaDet.debug = false;
191 < //    if ((*event).id==60422922)theAnaRpcMisc.debug = true;
192 <
193 <   theAnaMuonDistribution.run(muon);
194 <   theAnaRpcVsOth.run(muon,l1RpcColl,l1OtherColl);
195 <   theAnaEff.run(muon,l1RpcColl,l1OtherColl);
196 <   theAnaRpcMisc.run(event,muon,l1RpcColl,l1OtherColl);
197 <   theAnaDet.run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
198 <   theAnaEmu.run ( event, muon, l1RpcCollEmu, l1RpcColl);
199 <   theAnaSynch.run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
200 <   theAnaClu.run( event, muon, l1RpcColl, *detsHitsCompatibleWithMuon, *nDigisCompDets, *clSizeCompDets);
201 <
202 < //   theAnaEmu.debug =theAnaDet.debug;
203 < //    std::cout <<"----------"<<std::endl;
204 < //   theAnaDet.debug =theAnaEmu.debug;
205 < //    if (anaDet.debug) std::cout <<" Event: "<<(*event).id <<" Lumi: "<<(*event).lumi<< std::endl;
206 <  
186 > /*  
187 >   if (     event->id == 597978012
188 >        ||  event->id == 14791798  
189 >        ||  event->id == 436261807
190 >        ||  event->id == 873776280  
191 >        ||  event->id == 960307389
192 >        ||  event->id == 150097556
193 >        ||  event->id == 42062946
194 >        ||  event->id == 1064121551
195 >        ||  event->id == 1499489591
196 >        ||  event->id == 60161631
197 >        ||  event->id == 624624695
198 >        ||  event->id == 727298833
199 >        ||  event->id == 835600542
200 >        ||  event->id == 216373776
201 >        ||  event->id == 1107585611
202 >        ||  event->id == 197907027
203 >      ) theAnaMenu.debug = true; else theAnaMenu.debug = false;
204 > */
205 >
206 >   // EVENT NUMBER, BX structure etc.
207 >   EventObjBXExtra eventBx(*event);
208 >   if ( theAnaEvent && !theAnaEvent->filter(&eventBx) && theConfig.getParameter<bool>("filterByAnaEvent") ) continue;
209 >   // ANALYSE AND FILTER KINEMCTICS
210 >   if ( theAnaMuonDistribution && !theAnaMuonDistribution->filter(muon) && theConfig.getParameter<bool>("filterByAnaMuonDistribution") ) continue;
211 >   // ANALYSE AND FILTER TRIGGER MENU
212 >   if ( theAnaMenu && !theAnaMenu->filter(event, muon, bitsL1, bitsHLT) && theConfig.getParameter<bool>("filterByAnaMenu") ) continue;
213 >   // ANALYSE AND FILTER SIMU KONEMATICs
214 >   if ( theAnaSiMuDistribution && !theAnaSiMuDistribution->filter(event, simu, hitSpec) && theConfig.getParameter<bool>("filterByAnaSiMuDistribution") ) continue;
215 >
216 >   const TrackObj * refTrack = theConfig.getParameter<bool>("useSiMuReference") ? simu : muon;
217 >
218 >   // ANALYSES
219 >   if (theAnaRpcVsOth) theAnaRpcVsOth->run(refTrack,l1ObjColl);
220 >
221 > //   std::cout <<"refTrack: "<< *refTrack<<std::endl;
222 > //   std::cout <<"l1ObjColl: "<< *l1ObjColl << std::endl;
223 >
224 >   if (theAnaRpcMisc)  theAnaRpcMisc->run(event,muon,l1ObjColl);
225 >   if (theAnaDet)      theAnaDet->run( muon, *detsHitsCompatibleWithMuon,  *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
226 >   if (theAnaEmu)      theAnaEmu->run ( event, muon, l1ObjColl);
227 >   if (theAnaSynch)    theAnaSynch->run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
228 >   if (theAnaClu)      theAnaClu->run( event, muon, l1ObjColl, *detsHitsCompatibleWithMuon);
229 >   if (theAnaTimingL1) theAnaTimingL1->run( &eventBx, muon, l1ObjColl);
230 >
231 >   // HITPATTERN ANALYSES & OTF EFFICIENCY
232 >   if (theAnaHitSpec) theAnaHitSpec->run(event, simu, hitSpec);
233 >   if (theAnaDigiSpec) theAnaDigiSpec->run(event, simu, hitSpec, *digSpec);
234 >   if (thePatternProducer) thePatternProducer->run(event, simu, hitSpec, *digSpec);
235 >   L1Obj l1otf;
236 >   if (thePatternProvider) l1otf=thePatternProvider->check(event, simu, hitSpec, *digSpec);
237 >   if (theAnaOtfEff) theAnaOtfEff->run(event,simu,l1otf);  
238 >   L1ObjColl myL1ObjColl = *l1ObjColl;
239 >   myL1ObjColl.push_back(l1otf, false, 0.);
240 >   if (theAnaEff)      theAnaEff->run(refTrack, &myL1ObjColl);
241    }
242   }
243  
244   void L1RpcTreeAnalysis::endJob()
245   {
246    std::cout <<"ENDJOB, summaries:"<<std::endl;
247 <  TGraph* hGraph_DetEff =theAnaDet.resume();
248 <  TGraph* hGraph_RunEff =theAnaRpcMisc.resume();
249 <  TGraph* hGraph_RunClu = theAnaClu.resume();
250 <
251 <  theAnaSynch.endJob();
247 >  TGraph* hGraph_DetEff = (theAnaDet) ? theAnaDet->resume() : 0;
248 >  TGraph* hGraph_RunClu = (theAnaClu) ? theAnaClu->resume(): 0;
249 >  if (theAnaRpcMisc) theAnaRpcMisc->resume(theHistos);
250 >  if (theAnaTimingL1)  theAnaTimingL1->resume(theHistos);
251 >  if (theAnaMenu)     theAnaMenu->resume(theHistos);
252 >  if (theAnaMenu) theAnaEvent->resume(theHistos);
253 >  if (theAnaHitSpec) theAnaHitSpec->resume(theHistos);
254 >  if (theAnaDigiSpec) theAnaDigiSpec->resume(theHistos);
255 >
256 >  if (theAnaSynch) theAnaSynch->endJob();
257 >  if (thePatternProducer) thePatternProducer->endJob();
258 >  if (thePatternProvider) thePatternProvider->endJob();
259  
260    std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
261    TFile f(histoFile.c_str(),"RECREATE");
262    theHistos.Write();
263 <  hGraph_DetEff->Write("hGraph_DetEff");
264 <  hGraph_RunEff->Write("hGraph_RunEff");
168 <  hGraph_RunClu->Write("hGraph_RunClu");
263 >  if (hGraph_DetEff) hGraph_DetEff->Write("hGraph_DetEff");
264 >  if (hGraph_RunClu) hGraph_RunClu->Write("hGraph_RunClu");
265    f.Close();
266    std::cout <<"END"<<std::endl;
267 +
268 +  delete theAnaMuonDistribution;
269 +  delete theAnaRpcVsOth;
270 +  delete theAnaRpcMisc;
271 +  delete theAnaEff;
272 +  delete theAnaDet;
273 +  delete theAnaEmu;
274 +  delete theAnaSynch;
275 +  delete theAnaClu;
276 +  delete theAnaTimingL1;
277 +  delete theAnaMenu;
278 +  delete theAnaEvent;
279 +  delete theAnaDigiSpec;
280 +  delete theAnaHitSpec;
281 +  delete thePatternProducer;
282 +  delete thePatternProvider;
283 +  delete theAnaSiMuDistribution;
284 +  delete theAnaOtfEff;
285   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines