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