ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/plugins/L1RpcTreeAnalysis.cc
Revision: 1.14
Committed: Wed Apr 24 19:54:35 2013 UTC (12 years ago) by konec
Content type: text/plain
Branch: MAIN
Changes since 1.13: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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.1
27 konec 1.12
28 konec 1.1 #include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
29    
30 konec 1.9 L1RpcTreeAnalysis::L1RpcTreeAnalysis(const edm::ParameterSet & cfg)
31     : theConfig(cfg),
32 konec 1.10 theAnaMuonDistribution( cfg.getParameter<edm::ParameterSet>("anaMuonDistribution") ),
33 konec 1.11 theAnaTimingL1 (cfg.getParameter<edm::ParameterSet>("anaTimingL1") ),
34 konec 1.12 theAnaMenu(cfg.getParameter<edm::ParameterSet>("anaMenu") ),
35     theAnaEvent(cfg.getParameter<edm::ParameterSet>("anaEvent") )
36 konec 1.9 { }
37 konec 1.1
38     void L1RpcTreeAnalysis::beginJob()
39     {
40     theHistos.SetOwner();
41    
42     theAnaMuonDistribution.init(theHistos);
43     theAnaRpcVsOth.init(theHistos);
44     theAnaRpcMisc.init(theHistos);
45     theAnaEff.init(theHistos);
46     theAnaDet.init(theHistos);
47     theAnaEmu.init(theHistos);
48     theAnaSynch.init(theHistos);
49     theAnaClu.init(theHistos);
50 konec 1.4 theAnaTimingL1.init(theHistos);
51 konec 1.12 theAnaEvent.init(theHistos);
52 konec 1.8 theAnaMenu.init(theHistos);
53 konec 1.1 }
54    
55     void L1RpcTreeAnalysis::beginRun(const edm::Run& ru, const edm::EventSetup& es)
56     {
57     theAnaSynch.beginRun(ru,es);
58     }
59    
60     void L1RpcTreeAnalysis::analyze(const edm::Event&, const edm::EventSetup&)
61     {
62     //
63     // prevent multievent execution
64     //
65     static bool the_EMERGENCY_STOP = false;
66     if (the_EMERGENCY_STOP) {
67     std::cout <<"** L1RpcTreeAnalysis::analyze EMERGENCY_STOP fired, skip" << std::endl;
68     return;
69     }
70     the_EMERGENCY_STOP = true;
71    
72     //
73     // define input chain
74     //
75     TChain chain("tL1Rpc");
76     std::vector<std::string> treeFileNames = theConfig.getParameter<std::vector<std::string> >("treeFileNames");
77     for (std::vector<std::string>::const_iterator it = treeFileNames.begin(); it != treeFileNames.end(); ++it) chain.Add((*it).c_str() );
78    
79    
80     //
81     // prepare datastructures and branches
82     //
83     std::vector<SynchroCountsObj> *counts= 0;
84     std::vector<uint32_t> *detsCrossedByMuon = 0;
85     std::vector<uint32_t> *detsCrossedByMuonDeepInside = 0;
86 konec 1.7 std::vector<DetCluDigiObj> *detsHitsCompatibleWithMuon = 0;
87 konec 1.1 std::vector<uint32_t> *detsSIMU = 0;
88    
89     EventObj * event = 0;
90     MuonObj * muon = 0;
91    
92 konec 1.5 TriggerMenuResultObj *bitsL1 = 0;
93     TriggerMenuResultObj *bitsHLT = 0;
94    
95 konec 1.1 TBranch *bcounts=0;
96     TBranch *bdetsCrossedByMuon =0;
97     TBranch *bdetsCrossedByMuonDeepInside =0;
98     TBranch *bdetsHitsCompatibleWithMuon = 0;
99     TBranch *bdetsSIMU =0;
100    
101 konec 1.9 L1ObjColl* l1ObjColl = 0;
102 konec 1.1
103     chain.SetBranchAddress("event",&event);
104     chain.SetBranchAddress("muon",&muon);
105    
106 konec 1.5 chain.SetBranchAddress("bitsL1",&bitsL1);
107     chain.SetBranchAddress("bitsHLT",&bitsHLT);
108    
109 konec 1.1 chain.SetBranchAddress("counts",&counts,&bcounts);
110     chain.SetBranchAddress("detsCrossedByMuon",&detsCrossedByMuon,&bdetsCrossedByMuon);
111     chain.SetBranchAddress("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside,&bdetsCrossedByMuonDeepInside);
112     chain.SetBranchAddress("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon,&bdetsHitsCompatibleWithMuon);
113     chain.SetBranchAddress("detsSIMU",&detsSIMU,&bdetsSIMU);
114    
115 konec 1.9 chain.SetBranchAddress("l1ObjColl",&l1ObjColl);
116 konec 1.1
117    
118     //
119 konec 1.5 // number of events
120 konec 1.1 //
121     Int_t nentries = (Int_t) chain.GetEntries();
122     std::cout <<" ENTRIES: " << nentries << std::endl;
123    
124    
125     //
126     // main loop
127     //
128     unsigned int lastRun = 0;
129     for (int ev=0; ev<nentries; ev++) {
130     chain.GetEntry(ev);
131 konec 1.11 theAnaMenu.updateMenu(bitsL1->names, bitsHLT->names);
132 konec 1.1
133     if (lastRun != (*event).run) {
134 konec 1.14 // if (true) {
135 konec 1.1 lastRun = (*event).run;
136     std::cout <<"RUN:" << std::setw(7) << (*event).run
137     <<" event:" << std::setw(8) << ev
138 konec 1.11 <<" done:" << std::setw(6)<< std::setiosflags(std::ios::fixed) << std::setprecision(2) << ev*100./nentries<<"%";
139     std::cout<<std::endl;
140 konec 1.1 }
141    
142 konec 1.13 /*
143     if ( event->id == 597978012
144     || event->id == 14791798
145     || event->id == 436261807
146     || event->id == 873776280
147     || event->id == 960307389
148     || event->id == 150097556
149     || event->id == 42062946
150     || event->id == 1064121551
151     || event->id == 1499489591
152     || event->id == 60161631
153     || event->id == 624624695
154     || event->id == 727298833
155     || event->id == 835600542
156     || event->id == 216373776
157     || event->id == 1107585611
158     || event->id == 197907027
159     ) theAnaMenu.debug = true; else theAnaMenu.debug = false;
160     */
161 konec 1.1
162 konec 1.12 // EVENT NUMBER, BX structure etc.
163     EventObjBXExtra eventBx(*event);
164     if ( !theAnaEvent.filter(&eventBx) && theConfig.getParameter<bool>("filterByAnaEvent") ) continue;
165 konec 1.9 // ANALYSE AND FILTER KINEMCTICS
166 konec 1.10 if ( !theAnaMuonDistribution.filter(muon) && theConfig.getParameter<bool>("filterByAnaMuonDistribution") ) continue;
167 konec 1.9 // ANALYSE AND FILTER TRIGGER MENU
168 konec 1.12 if ( !theAnaMenu.filter(event, muon, bitsL1, bitsHLT) && theConfig.getParameter<bool>("filterByAnaMenu") ) continue;
169 konec 1.9
170 konec 1.11 // theAnaRpcVsOth.run(muon,l1ObjColl);
171 konec 1.12 // theAnaEff.run(muon, l1ObjColl);
172     // theAnaRpcMisc.run(event,muon,l1ObjColl);
173 konec 1.11 // theAnaDet.run( muon, *detsHitsCompatibleWithMuon, *detsCrossedByMuon, *detsCrossedByMuonDeepInside);
174     // theAnaEmu.run ( event, muon, l1ObjColl);
175 konec 1.14 // theAnaSynch.run( event, muon, ConverterRPCRawSynchroSynchroCountsObj::toRawSynchro( *counts));
176 konec 1.12 // theAnaClu.run( event, muon, l1ObjColl, *detsHitsCompatibleWithMuon);
177     theAnaTimingL1.run( &eventBx, muon, l1ObjColl);
178 konec 1.1
179     }
180     }
181    
182     void L1RpcTreeAnalysis::endJob()
183     {
184     std::cout <<"ENDJOB, summaries:"<<std::endl;
185 konec 1.3 TGraph* hGraph_DetEff = theAnaDet.resume();
186     theAnaRpcMisc.resume(theHistos);
187 konec 1.2 TGraph* hGraph_RunClu = theAnaClu.resume();
188 konec 1.4 theAnaTimingL1.resume(theHistos);
189 konec 1.8 theAnaMenu.resume(theHistos);
190 konec 1.12 theAnaEvent.resume(theHistos);
191 konec 1.1
192     theAnaSynch.endJob();
193    
194     std::string histoFile = theConfig.getParameter<std::string>("histoFileName");
195     TFile f(histoFile.c_str(),"RECREATE");
196     theHistos.Write();
197     hGraph_DetEff->Write("hGraph_DetEff");
198 konec 1.2 hGraph_RunClu->Write("hGraph_RunClu");
199 konec 1.1 f.Close();
200     std::cout <<"END"<<std::endl;
201     }