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