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
281
282
283
284
285
286
287
288
289
290
291
292
293
|
// -*- C++ -*-
//
// Package: Ecal
// Class: GetLaserData
//
/**\class GetLaserData GetLaserData.cc CondTools/Ecal/src/EcalGetLaserData.cc
Description: Gets Ecal Laser values from DB
*/
//
// Original Author: Vladlen Timciuc
// Created: Wed Jul 4 13:55:56 CEST 2007
// $Id: EcalGetLaserData.cc,v 1.5 2009/12/21 14:22:03 ebecheva Exp $
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EventSetupRecordKey.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/IOVSyncValue.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatios.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
#include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
#include "OnlineDB/Oracle/interface/Oracle.h"
#include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "CondTools/Ecal/interface/EcalGetLaserData.h"
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
EcalGetLaserData::EcalGetLaserData(const edm::ParameterSet& iConfig)
: // m_timetype(iConfig.getParameter<std::string>("timetype")),
m_cacheIDs(),
m_records(),
ecalLaserAPDPNRatiosToken_(esConsumes()),
ecalLaserAPDPNRatiosRefToken_(esConsumes()),
ecalLaserAlphasToken_(esConsumes()) {
//m_firstRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("firstRun").c_str());
//m_lastRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("lastRun").c_str());
std::string container;
std::string record;
typedef std::vector<edm::ParameterSet> Parameters;
Parameters toGet = iConfig.getParameter<Parameters>("toGet");
for (const auto& iparam : toGet) {
container = iparam.getParameter<std::string>("container");
record = iparam.getParameter<std::string>("record");
m_cacheIDs.emplace(container, 0);
m_records.emplace(container, record);
} //now do what ever initialization is needed
}
EcalGetLaserData::~EcalGetLaserData() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
//
// member functions
//
// ------------ method called to for each event ------------
void EcalGetLaserData::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
using namespace edm;
// loop on offline DB conditions to be transferred as from config file
for (const auto& irec : m_records) {
const std::string& container = irec.first;
//record = irec.second;
if (container == "EcalLaserAPDPNRatios") {
// get from offline DB the last valid laser set
const EcalLaserAPDPNRatios* laserapdpnrRatios = &evtSetup.getData(ecalLaserAPDPNRatiosToken_);
// this is the offline object
EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp;
EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair;
const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = laserapdpnrRatios->getLaserMap();
const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = laserapdpnrRatios->getTimeMap();
// loop through ecal barrel
for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
if (iEta == 0)
continue;
for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
EBDetId ebdetid(iEta, iPhi);
int hi = ebdetid.hashedIndex();
if (hi < static_cast<int>(laserRatiosMap.size())) {
apdpnpair = laserRatiosMap[hi];
edm::LogInfo("EcalGetLaserData") << "A sample value of APDPN pair EB : " << hi << " : " << apdpnpair.p1
<< " , " << apdpnpair.p2 << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
}
}
}
// loop through ecal endcap
for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
if (!EEDetId::validDetId(iX, iY, 1))
continue;
EEDetId eedetidpos(iX, iY, 1);
int hi = eedetidpos.hashedIndex();
if (hi < static_cast<int>(laserRatiosMap.size())) {
apdpnpair = laserRatiosMap[hi];
edm::LogInfo("EcalGetLaserData") << "A sample value of APDPN pair EE+ : " << hi << " : " << apdpnpair.p1
<< " , " << apdpnpair.p2 << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
}
if (!EEDetId::validDetId(iX, iY, -1))
continue;
EEDetId eedetidneg(iX, iY, 1);
hi = eedetidneg.hashedIndex();
if (hi < static_cast<int>(laserRatiosMap.size())) {
apdpnpair = laserRatiosMap[hi];
edm::LogInfo("EcalGetLaserData") << "A sample value of APDPN pair EE- : " << hi << " : " << apdpnpair.p1
<< " , " << apdpnpair.p2 << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
}
}
}
for (int i = 0; i < 92; i++) {
timestamp = laserTimeMap[i];
edm::LogInfo("EcalGetLaserData") << "A value of timestamp pair : " << i << " " << timestamp.t1.value() << " , "
<< timestamp.t2.value() << std::endl;
}
edm::LogInfo("EcalGetLaserData") << ".. just retrieved the last valid record from DB " << std::endl;
} else if (container == "EcalLaserAPDPNRatiosRef") {
// get from offline DB the last valid laser set
EcalLaserAPDPNref apdpnref;
const EcalLaserAPDPNRatiosRefMap& laserRefMap = (&evtSetup.getData(ecalLaserAPDPNRatiosRefToken_))->getMap();
// first barrel
for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
if (iEta == 0)
continue;
for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
EBDetId ebdetid(iEta, iPhi);
int hi = ebdetid.hashedIndex();
if (hi < static_cast<int>(laserRefMap.size())) {
apdpnref = laserRefMap[hi];
edm::LogInfo("EcalGetLaserData")
<< "A sample value of APDPN Reference value EB : " << hi << " : " << apdpnref << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
}
}
}
// now for endcap
for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
if (!EEDetId::validDetId(iX, iY, 1))
continue;
EEDetId eedetidpos(iX, iY, 1);
int hi = eedetidpos.hashedIndex();
if (hi < static_cast<int>(laserRefMap.size())) {
apdpnref = laserRefMap[hi];
edm::LogInfo("EcalGetLaserData")
<< "A sample value of APDPN Reference value EE+ : " << hi << " : " << apdpnref << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
}
if (!EEDetId::validDetId(iX, iY, -1))
continue;
EEDetId eedetidneg(iX, iY, -1);
hi = eedetidneg.hashedIndex();
if (hi < static_cast<int>(laserRefMap.size())) {
apdpnref = laserRefMap[hi];
edm::LogInfo("EcalGetLaserData")
<< "A sample value of APDPN Reference value EE- : " << hi << " : " << apdpnref << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
}
}
}
edm::LogInfo("EcalGetLaserData") << "... just retrieved the last valid record from DB " << std::endl;
} else if (container == "EcalLaserAlphas") {
// get from offline DB the last valid laser set
// this is the offline object
EcalLaserAlpha alpha;
const EcalLaserAlphaMap& laserAlphaMap = (&evtSetup.getData(ecalLaserAlphasToken_))->getMap(); // map of apdpns
// first barrel
for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
if (iEta == 0)
continue;
for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
EBDetId ebdetid(iEta, iPhi);
int hi = ebdetid.hashedIndex();
if (hi < static_cast<int>(laserAlphaMap.size())) {
alpha = laserAlphaMap[hi];
edm::LogInfo("EcalGetLaserData")
<< " A sample value of Alpha value EB : " << hi << " : " << alpha << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
}
}
}
// next endcap
for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
if (!EEDetId::validDetId(iX, iY, 1))
continue;
EEDetId eedetidpos(iX, iY, 1);
int hi = eedetidpos.hashedIndex();
if (hi < static_cast<int>(laserAlphaMap.size())) {
alpha = laserAlphaMap[hi];
edm::LogInfo("EcalGetLaserData")
<< " A sample value of Alpha value EE+ : " << hi << " : " << alpha << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
}
if (!EEDetId::validDetId(iX, iY, -1))
continue;
EEDetId eedetidneg(iX, iY, -1);
hi = eedetidneg.hashedIndex();
if (hi < static_cast<int>(laserAlphaMap.size())) {
alpha = laserAlphaMap[hi];
edm::LogInfo("EcalGetLaserData")
<< " A sample value of Alpha value EE- : " << hi << " : " << alpha << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
}
}
}
edm::LogInfo("EcalGetLaserData") << "... just retrieved the last valid record from DB " << std::endl;
} else {
edm::LogError("EcalGetLaserData") << "Cannot retrieve for container: " << container << std::endl;
}
}
}
// ------------ method called once each job just before starting event loop ------------
void EcalGetLaserData::beginJob() {}
// ------------ method called once each job just after ending the event loop ------------
void EcalGetLaserData::endJob() {}
|