1 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
2 |
yilmaz |
1.1 |
#include <memory>
|
3 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
4 |
|
|
#include "TTree.h"
|
5 |
|
|
//---------------------------------------------------------------------------
|
6 |
yilmaz |
1.1 |
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
7 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
8 |
yilmaz |
1.3 |
#include "FWCore/ServiceRegistry/interface/Service.h"
|
9 |
|
|
#include "CommonTools/UtilAlgos/interface/TFileService.h"
|
10 |
|
|
//---------------------------------------------------------------------------
|
11 |
yilmaz |
1.1 |
#include "FWCore/Framework/interface/Event.h"
|
12 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
13 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
14 |
yilmaz |
1.1 |
#include "DataFormats/METReco/interface/HcalNoiseSummary.h"
|
15 |
yilmaz |
1.3 |
#include "DataFormats/METReco/interface/HcalNoiseRBX.h"
|
16 |
|
|
#include "RecoMET/METAlgorithms/interface/HcalHPDRBXMap.h"
|
17 |
|
|
//---------------------------------------------------------------------------
|
18 |
yilmaz |
1.1 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
19 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
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 |
yilmaz |
1.1 |
};
|
72 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
73 |
yilmaz |
1.1 |
HiHcalAnalyzer::HiHcalAnalyzer(const edm::ParameterSet& iConfig)
|
74 |
|
|
{
|
75 |
yilmaz |
1.3 |
NoiseSummaryTag = iConfig.getUntrackedParameter<edm::InputTag>("NoiseSummaryTag");
|
76 |
|
|
NoiseRBXTag = iConfig.getUntrackedParameter<edm::InputTag>("NoiseRBXTag");
|
77 |
yilmaz |
1.1 |
}
|
78 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
79 |
yilmaz |
1.1 |
HiHcalAnalyzer::~HiHcalAnalyzer()
|
80 |
|
|
{
|
81 |
|
|
}
|
82 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
83 |
|
|
void HiHcalAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
84 |
yilmaz |
1.1 |
{
|
85 |
|
|
using namespace edm;
|
86 |
yilmaz |
1.3 |
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 |
yilmaz |
1.1 |
|
157 |
yilmaz |
1.3 |
// Finally fill the tree
|
158 |
|
|
OutputTree->Fill();
|
159 |
yilmaz |
1.1 |
}
|
160 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
161 |
|
|
void HiHcalAnalyzer::beginJob()
|
162 |
yilmaz |
1.1 |
{
|
163 |
yilmaz |
1.3 |
OutputTree = FileService->make<TTree>("hbhenoise", "v1");
|
164 |
yilmaz |
1.1 |
|
165 |
yilmaz |
1.3 |
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 |
yilmaz |
1.1 |
|
198 |
|
|
}
|
199 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
200 |
|
|
void HiHcalAnalyzer::endJob()
|
201 |
yilmaz |
1.1 |
{
|
202 |
|
|
}
|
203 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
204 |
|
|
void HiHcalAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
|
205 |
yilmaz |
1.1 |
{
|
206 |
|
|
}
|
207 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
208 |
|
|
void HiHcalAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
|
209 |
yilmaz |
1.1 |
{
|
210 |
|
|
}
|
211 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
212 |
|
|
void HiHcalAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
|
213 |
yilmaz |
1.1 |
{
|
214 |
|
|
}
|
215 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
216 |
|
|
void HiHcalAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
|
217 |
yilmaz |
1.1 |
{
|
218 |
|
|
}
|
219 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
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 |
yilmaz |
1.1 |
// 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 |
yilmaz |
1.3 |
//---------------------------------------------------------------------------
|
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 |
yilmaz |
1.1 |
//define this as a plug-in
|
269 |
|
|
DEFINE_FWK_MODULE(HiHcalAnalyzer);
|