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