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