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