ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/HiHcalAnalyzer.cc
Revision: 1.3
Committed: Wed Jan 16 16:33:22 2013 UTC (12 years, 3 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
CVS Tags: HiForest_V02_85, HiForest_V02_84, HiForest_V02_83, HiForest_V02_82, HiForest_V02_81, HiForest_V02_80, HiForest_V02_79, HiForest_V02_78, HiForest_V02_77, HiForest_V02_76, HiForest_V02_75, HiForest_V02_74, HiForest_V02_73, HiForest_V02_72, HiForest_V02_71, HiForest_V02_70, HiForest_V02_69, HiForest_V02_68, HiForest_V02_67, HiForest_V02_66, HiForest_V02_65, HiForest_V02_64, HiForest_V02_63, HiForest_V02_62, HiForest_V02_61, HiForest_V02_60, HiForest_V02_59, HiForest_V02_58, HiForest_V02_57, HiForest_V02_56, HiForest_V02_55, HiForest_V02_54, HiForest_V02_53, HiForest_V02_52, HiForest_V02_51, HiForest_V02_50, HiForest_V02_49, HiForest_V02_48, HiForest_V02_47, HiForest_V02_46, HiForest_V02_45, HiForest_V02_44, HiForest_V02_43, HiForest_V02_42, HiForest_V02_41, HiForest_V02_40, HiForest_V02_39, HiForest_V02_38, HiForest_V02_37, HiForest_V02_36, HiForest_V02_35, HEAD
Changes since 1.2: +230 -246 lines
Error occurred while calculating annotation data.
Log Message:
Hcal noise

File Contents

# Content
1 //---------------------------------------------------------------------------
2 #include <memory>
3 //---------------------------------------------------------------------------
4 #include "TTree.h"
5 //---------------------------------------------------------------------------
6 #include "FWCore/Framework/interface/Frameworkfwd.h"
7 #include "FWCore/Framework/interface/EDAnalyzer.h"
8 #include "FWCore/ServiceRegistry/interface/Service.h"
9 #include "CommonTools/UtilAlgos/interface/TFileService.h"
10 //---------------------------------------------------------------------------
11 #include "FWCore/Framework/interface/Event.h"
12 #include "FWCore/Framework/interface/MakerMacros.h"
13 //---------------------------------------------------------------------------
14 #include "DataFormats/METReco/interface/HcalNoiseSummary.h"
15 #include "DataFormats/METReco/interface/HcalNoiseRBX.h"
16 #include "RecoMET/METAlgorithms/interface/HcalHPDRBXMap.h"
17 //---------------------------------------------------------------------------
18 #include "FWCore/ParameterSet/interface/ParameterSet.h"
19 //---------------------------------------------------------------------------
20 class HiHcalAnalyzer : public edm::EDAnalyzer
21 {
22 public:
23 explicit HiHcalAnalyzer(const edm::ParameterSet&);
24 ~HiHcalAnalyzer();
25
26 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
27
28 private:
29 virtual void beginJob();
30 virtual void analyze(const edm::Event&, const edm::EventSetup&);
31 virtual void endJob();
32
33 virtual void beginRun(edm::Run const&, edm::EventSetup const&);
34 virtual void endRun(edm::Run const&, edm::EventSetup const&);
35 virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
36 virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
37
38 private:
39 edm::Service<TFileService> FileService;
40
41 private:
42 void CleanUp();
43
44 private:
45 edm::InputTag NoiseSummaryTag;
46 edm::InputTag NoiseRBXTag;
47
48 private:
49 TTree *OutputTree;
50
51 int RunNumber;
52 long long EventNumber;
53 int LumiSection;
54 int Bunch;
55 int Orbit;
56 long long Time;
57
58 int FilterStatus;
59 int MaxZeros, MaxHPDHits, MaxHPDNoOtherHits, MaxRBXHits;
60 int IsolatedCount, FlatNoiseCount, SpikeNoiseCount;
61 double IsolatedSumE, FlatNoiseSumE, SpikeNoiseSumE;
62 double IsolatedSumET, FlatNoiseSumET, SpikeNoiseSumET;
63 bool HasBadTS4TS5;
64 double TotalCalibCharge;
65 double MinE2E10, MaxE2E10;
66
67 double RBXEnergy[72], RBXEnergy15[72];
68 int RBXHitCount[72];
69 double RBXR45[72];
70 double RBXCharge[72][10];
71 };
72 //---------------------------------------------------------------------------
73 HiHcalAnalyzer::HiHcalAnalyzer(const edm::ParameterSet& iConfig)
74 {
75 NoiseSummaryTag = iConfig.getUntrackedParameter<edm::InputTag>("NoiseSummaryTag");
76 NoiseRBXTag = iConfig.getUntrackedParameter<edm::InputTag>("NoiseRBXTag");
77 }
78 //---------------------------------------------------------------------------
79 HiHcalAnalyzer::~HiHcalAnalyzer()
80 {
81 }
82 //---------------------------------------------------------------------------
83 void HiHcalAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
84 {
85 using namespace edm;
86 using namespace reco;
87
88 // Clean-up variables
89 CleanUp();
90
91 // Basic event coordinates
92 RunNumber = iEvent.id().run();
93 EventNumber = iEvent.id().event();
94 LumiSection = iEvent.luminosityBlock();
95 Bunch = iEvent.bunchCrossing();
96 Orbit = iEvent.orbitNumber();
97 Time = iEvent.time().value();
98
99 // Get stuff
100 Handle<HcalNoiseSummary> hSummary;
101 iEvent.getByLabel(NoiseSummaryTag, hSummary);
102
103 Handle<HcalNoiseRBXCollection> hRBX;
104 iEvent.getByLabel(NoiseRBXTag, hRBX);
105
106 // Check if the stuff we get is good. If not...
107 if(hSummary.isValid() == false || hRBX.isValid() == false)
108 {
109 // ...then we barf at user about bad file, but we still fill in a filler entry in the tree
110 edm::LogError("DataNotFound") << "Hcal noise summary information is invalid for "
111 "run " << RunNumber << " event " << EventNumber << " LS " << LumiSection;
112 OutputTree->Fill();
113 return;
114 }
115
116 // Dump information out of the summary object
117 FilterStatus = hSummary->noiseFilterStatus();
118 MaxZeros = hSummary->maxZeros();
119 MaxHPDHits = hSummary->maxHPDHits();
120 MaxHPDNoOtherHits = hSummary->maxHPDNoOtherHits();
121 MaxRBXHits = hSummary->maxRBXHits();
122 IsolatedCount = hSummary->numIsolatedNoiseChannels();
123 IsolatedSumE = hSummary->isolatedNoiseSumE();
124 IsolatedSumET = hSummary->isolatedNoiseSumEt();
125 FlatNoiseCount = hSummary->numFlatNoiseChannels();
126 FlatNoiseSumE = hSummary->flatNoiseSumE();
127 FlatNoiseSumET = hSummary->flatNoiseSumEt();
128 SpikeNoiseCount = hSummary->numSpikeNoiseChannels();
129 SpikeNoiseSumE = hSummary->spikeNoiseSumE();
130 SpikeNoiseSumET = hSummary->spikeNoiseSumEt();
131 HasBadTS4TS5 = hSummary->HasBadRBXTS4TS5();
132 TotalCalibCharge = hSummary->GetTotalCalibCharge();
133 MinE2E10 = hSummary->minE2Over10TS();
134 MaxE2E10 = hSummary->maxE2Over10TS();
135
136 // Dump information out of the RBX array
137 for(int iRBX = 0; iRBX < (int)hRBX->size(); iRBX++)
138 {
139 int ID = (*hRBX)[iRBX].idnumber();
140 if(ID >= 72) // WTF!
141 continue;
142
143 RBXEnergy[ID] = (*hRBX)[iRBX].recHitEnergy();
144 RBXEnergy15[ID] = (*hRBX)[iRBX].recHitEnergy(1.5);
145 RBXHitCount[ID] = (*hRBX)[iRBX].numRecHits(1.5);
146
147 std::vector<float> allcharge = (*hRBX)[iRBX].allCharge();
148 for(int iTS = 0; iTS < 10 && iTS < (int)allcharge.size(); iTS++)
149 RBXCharge[ID][iTS] = allcharge[iTS];
150
151 if(RBXCharge[ID][4] + RBXCharge[ID][5] > 1)
152 RBXR45[ID] = (RBXCharge[ID][4] - RBXCharge[ID][5]) / (RBXCharge[ID][4] + RBXCharge[ID][5]);
153 else
154 RBXR45[ID] = -9999;
155 }
156
157 // Finally fill the tree
158 OutputTree->Fill();
159 }
160 //---------------------------------------------------------------------------
161 void HiHcalAnalyzer::beginJob()
162 {
163 OutputTree = FileService->make<TTree>("hbhenoise", "v1");
164
165 OutputTree->Branch("run", &RunNumber, "run/I");
166 OutputTree->Branch("event", &EventNumber, "event/LL");
167 OutputTree->Branch("luminosityBlock", &LumiSection, "luminosityBlock/I");
168 OutputTree->Branch("bunchCrossing", &Bunch, "bunchCrossing/I");
169 OutputTree->Branch("orbit", &Orbit, "orbit/I");
170 OutputTree->Branch("time", &Time, "time/LL");
171
172
173 OutputTree->Branch("FilterStatus", &FilterStatus, "FilterStatus/I");
174 OutputTree->Branch("MaxZeros", &MaxZeros, "MaxZeros/I");
175 OutputTree->Branch("MaxHPDHits", &MaxHPDHits, "MaxHPDHits/I");
176 OutputTree->Branch("MaxHPDNoOtherHits", &MaxHPDNoOtherHits, "MaxHPDNoOtherHits/I");
177 OutputTree->Branch("MaxRBXHits", &MaxRBXHits, "MaxRBXHits/I");
178 OutputTree->Branch("IsolatedCount", &IsolatedCount, "IsolatedCount/I");
179 OutputTree->Branch("IsolatedSumE", &IsolatedSumE, "IsolatedSumE/D");
180 OutputTree->Branch("IsolatedSumET", &IsolatedSumET, "IsolatedSumET/D");
181 OutputTree->Branch("FlatNoiseCount", &FlatNoiseCount, "FlatNoiseCount/I");
182 OutputTree->Branch("FlatNoiseSumE", &FlatNoiseSumE, "FlatNoiseSumE/D");
183 OutputTree->Branch("FlatNoiseSumET", &FlatNoiseSumET, "FlatNoiseSumET/D");
184 OutputTree->Branch("SpikeNoiseCount", &SpikeNoiseCount, "SpikeNoiseCount/I");
185 OutputTree->Branch("SpikeNoiseSumE", &SpikeNoiseSumE, "SpikeNoiseSumE/D");
186 OutputTree->Branch("SpikeNoiseSumET", &SpikeNoiseSumET, "SpikeNoiseSumET/D");
187 OutputTree->Branch("HasBadTS4TS5", &HasBadTS4TS5, "HasBadTS4TS5/O");
188 OutputTree->Branch("TotalCalibCharge", &TotalCalibCharge, "TotalCalibCharge/D");
189 OutputTree->Branch("MinE2E10", &MinE2E10, "MinE2E10/D");
190 OutputTree->Branch("MaxE2E10", &MaxE2E10, "MaxE2E10/D");
191
192 OutputTree->Branch("RBXEnergy", RBXEnergy, "RBXEnergy[72]/D");
193 OutputTree->Branch("RBXEnergy15", RBXEnergy15, "RBXEnergy15[72]/D");
194 OutputTree->Branch("RBXHitCount", RBXHitCount, "RBXHitCount[72]/I");
195 OutputTree->Branch("RBXR45", RBXR45, "RBXR45[72]/D");
196 OutputTree->Branch("RBXCharge", RBXCharge, "RBXCharge[72][10]/D");
197
198 }
199 //---------------------------------------------------------------------------
200 void HiHcalAnalyzer::endJob()
201 {
202 }
203 //---------------------------------------------------------------------------
204 void HiHcalAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
205 {
206 }
207 //---------------------------------------------------------------------------
208 void HiHcalAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
209 {
210 }
211 //---------------------------------------------------------------------------
212 void HiHcalAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
213 {
214 }
215 //---------------------------------------------------------------------------
216 void HiHcalAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
217 {
218 }
219 //---------------------------------------------------------------------------
220 void HiHcalAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
221 {
222 // The following says we do not know what parameters are allowed so do no validation
223 // Please change this to state exactly what you do use, even if it is no parameters
224 edm::ParameterSetDescription desc;
225 desc.setUnknown();
226 descriptions.addDefault(desc);
227 }
228 //---------------------------------------------------------------------------
229 void HiHcalAnalyzer::CleanUp()
230 {
231 RunNumber = -1;
232 EventNumber = -1;
233 LumiSection = -1;
234 Bunch = -1;
235 Orbit = -1;
236 Time = -1;
237
238 FilterStatus = -1;
239 MaxZeros = -1;
240 MaxHPDHits = -1;
241 MaxHPDNoOtherHits = -1;
242 MaxRBXHits = -1;
243 IsolatedCount = -1;
244 FlatNoiseCount = -1;
245 SpikeNoiseCount = -1;
246 IsolatedSumE = -1;
247 FlatNoiseSumE = -1;
248 SpikeNoiseSumE = -1;
249 IsolatedSumET = -1;
250 FlatNoiseSumET = -1;
251 SpikeNoiseSumET = -1;
252 HasBadTS4TS5 = false;
253 TotalCalibCharge = -1;
254 MinE2E10 = -1;
255 MaxE2E10 = -1;
256
257 for(int iID = 0; iID < 72; iID++)
258 {
259 RBXEnergy[iID] = -1;
260 RBXEnergy15[iID] = -1;
261 RBXHitCount[iID] = -1;
262 RBXR45[iID] = 9999;
263 for(int iTS = 0; iTS < 10; iTS++)
264 RBXCharge[iID][iTS] = -1;
265 }
266 }
267 //---------------------------------------------------------------------------
268 //define this as a plug-in
269 DEFINE_FWK_MODULE(HiHcalAnalyzer);