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