CMS 3D CMS Logo

EcalGetLaserData.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Ecal
4 // Class: GetLaserData
5 //
11 //
12 // Original Author: Vladlen Timciuc
13 // Created: Wed Jul 4 13:55:56 CEST 2007
14 // $Id: EcalGetLaserData.cc,v 1.5 2009/12/21 14:22:03 ebecheva Exp $
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 
26 
29 
32 
34 
36 
38 
42 
43 
45 
46 //
47 // constants, enums and typedefs
48 //
49 
50 //
51 // static data member definitions
52 //
53 
54 //
55 // constructors and destructor
56 //
58  // m_timetype(iConfig.getParameter<std::string>("timetype")),
59  m_cacheIDs(),
60  m_records()
61 {
62  std::string container;
65 
66  //m_firstRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("firstRun").c_str());
67  //m_lastRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("lastRun").c_str());
68 
69  typedef std::vector< edm::ParameterSet > Parameters;
70  Parameters toGet = iConfig.getParameter<Parameters>("toGet");
71  for(Parameters::iterator i = toGet.begin(); i != toGet.end(); ++i) {
72  container = i->getParameter<std::string>("container");
73  record = i->getParameter<std::string>("record");
74  m_cacheIDs.insert( std::make_pair(container, 0) );
75  m_records.insert( std::make_pair(container, record) );
76 
77  } //now do what ever initialization is needed
78 
79 }
80 
81 
83 {
84 
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87 
88 }
89 
90 
91 //
92 // member functions
93 //
94 
95 // ------------ method called to for each event ------------
96 void
98 {
99  using namespace edm;
100 
101  // loop on offline DB conditions to be transferred as from config file
102  std::string container;
104  typedef std::map<std::string, std::string>::const_iterator recordIter;
105  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
106  container = (*i).first;
107  record = (*i).second;
108 
109  std::string recordName = m_records[container];
110 
111 
112  if (container == "EcalLaserAPDPNRatios") {
113 
114  // get from offline DB the last valid laser set
116  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);
117 
118  // this is the offline object
121 
122  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = handle.product()->getLaserMap();
123  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = handle.product()->getTimeMap();
124 
125  // loop through ecal barrel
126  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
127  if(iEta==0) continue;
128  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
129 
130  EBDetId ebdetid(iEta,iPhi);
131  int hi = ebdetid.hashedIndex();
132 
133  if (hi<static_cast<int>(laserRatiosMap.size())) {
134  apdpnpair = laserRatiosMap[hi];
135  std::cout << "A sample value of APDPN pair EB : "
136  << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
137  } else {
138  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
139  }
140 
141  }
142  }
143 
144  // loop through ecal endcap
145  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
146  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
147 
148  if (!EEDetId::validDetId(iX,iY,1))
149  continue;
150 
151  EEDetId eedetidpos(iX,iY,1);
152  int hi = eedetidpos.hashedIndex();
153 
154  if (hi< static_cast<int>(laserRatiosMap.size())) {
155  apdpnpair = laserRatiosMap[hi];
156  std::cout << "A sample value of APDPN pair EE+ : "
157  << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
158  } else {
159  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
160  }
161 
162  if (!EEDetId::validDetId(iX,iY,-1))
163  continue;
164  EEDetId eedetidneg(iX,iY,1);
165  hi = eedetidneg.hashedIndex();
166 
167  if (hi< static_cast<int>(laserRatiosMap.size())) {
168  apdpnpair = laserRatiosMap[hi];
169  std::cout << "A sample value of APDPN pair EE- : "
170  << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
171  } else {
172  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
173  }
174  }
175  }
176 
177  for(int i=0; i<92; i++){
178  timestamp = laserTimeMap[i];
179  std::cout << "A value of timestamp pair : "
180  << i << " " << timestamp.t1.value() << " , " << timestamp.t2.value() << std::endl;
181  }
182 
183  std::cout <<".. just retrieved the last valid record from DB "<< std::endl;
184 
185  } else if(container == "EcalLaserAPDPNRatiosRef") {
186 
187  // get from offline DB the last valid laser set
189  evtSetup.get<EcalLaserAPDPNRatiosRefRcd>().get(handle);
190 
191  EcalLaserAPDPNref apdpnref;
192  const EcalLaserAPDPNRatiosRefMap& laserRefMap = handle.product()->getMap();
193 
194  // first barrel
195  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
196  if(iEta==0) continue;
197  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
198 
199  EBDetId ebdetid(iEta,iPhi);
200  int hi = ebdetid.hashedIndex();
201 
202  if (hi< static_cast<int>(laserRefMap.size())) {
203  apdpnref = laserRefMap[hi];
204  std::cout << "A sample value of APDPN Reference value EB : "
205  << hi << " : " << apdpnref << std::endl;
206  } else {
207  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
208  }
209  }
210  }
211 
212  // now for endcap
213  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
214  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
215 
216  if (!EEDetId::validDetId(iX,iY,1))
217  continue;
218 
219  EEDetId eedetidpos(iX,iY,1);
220  int hi = eedetidpos.hashedIndex();
221 
222  if (hi< static_cast<int>(laserRefMap.size())) {
223  apdpnref = laserRefMap[hi];
224  std::cout << "A sample value of APDPN Reference value EE+ : "
225  << hi << " : " << apdpnref << std::endl;
226 
227  } else {
228  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
229  }
230 
231  if (!EEDetId::validDetId(iX,iY,-1))
232  continue;
233  EEDetId eedetidneg(iX,iY,-1);
234  hi = eedetidneg.hashedIndex();
235 
236  if (hi< static_cast<int>(laserRefMap.size())) {
237  apdpnref = laserRefMap[hi];
238  std::cout << "A sample value of APDPN Reference value EE- : "
239  << hi << " : " << apdpnref << std::endl;
240  } else {
241  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
242  }
243  }
244  }
245 
246  std::cout << "... just retrieved the last valid record from DB "<< std::endl;
247 
248  } else if (container == "EcalLaserAlphas") {
249 
250  // get from offline DB the last valid laser set
252  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
253 
254  // this is the offline object
256  const EcalLaserAlphaMap& laserAlphaMap = handle.product()->getMap(); // map of apdpns
257 
258  // first barrel
259  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
260  if(iEta==0) continue;
261  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
262 
263  EBDetId ebdetid(iEta,iPhi);
264  int hi = ebdetid.hashedIndex();
265 
266  if (hi< static_cast<int>(laserAlphaMap.size())) {
267  alpha = laserAlphaMap[hi];
268  std::cout << " A sample value of Alpha value EB : " << hi << " : " << alpha << std::endl;
269  } else {
270  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
271  }
272  }
273  }
274 
275  // next endcap
276  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
277  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
278 
279  if (!EEDetId::validDetId(iX,iY,1))
280  continue;
281 
282  EEDetId eedetidpos(iX,iY,1);
283  int hi = eedetidpos.hashedIndex();
284 
285  if (hi< static_cast<int>(laserAlphaMap.size())) {
286  alpha = laserAlphaMap[hi];
287  std::cout << " A sample value of Alpha value EE+ : " << hi << " : " << alpha << std::endl;
288  } else {
289  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
290  }
291 
292 
293  if (!EEDetId::validDetId(iX,iY,-1))
294  continue;
295  EEDetId eedetidneg(iX,iY,-1);
296  hi = eedetidneg.hashedIndex();
297 
298  if (hi< static_cast<int>(laserAlphaMap.size())) {
299  alpha = laserAlphaMap[hi];
300  std::cout << " A sample value of Alpha value EE- : " << hi << " : " << alpha << std::endl;
301  } else {
302  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
303  }
304  }
305  }
306 
307  std::cout <<"... just retrieved the last valid record from DB "<< std::endl;
308 
309  } else {
310  edm::LogError("EcalGetLaserData") << "Cannot retrieve for container: "
311  << container << std::endl;
312  }
313 
314  }
315 
316 }
317 
318 
319 // ------------ method called once each job just before starting event loop ------------
320 void
322 {
323 }
324 
325 // ------------ method called once each job just after ending the event loop ------------
326 void
328 }
T getParameter(std::string const &) const
~EcalGetLaserData() override
float EcalLaserAlpha
float alpha
Definition: AMPTWrapper.h:95
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
static const int MIN_IPHI
Definition: EBDetId.h:142
std::map< std::string, std::string > m_records
EcalGetLaserData(const edm::ParameterSet &iConfig)
JetCorrectorParameters::Record record
Definition: classes.h:7
const self & getMap() const
void endJob() override
static const int IX_MIN
Definition: EEDetId.h:294
float EcalLaserAPDPNref
static const int IY_MIN
Definition: EEDetId.h:298
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
const EcalLaserAPDPNRatiosMap & getLaserMap() const
vector< ParameterSet > Parameters
std::map< std::string, unsigned long long > m_cacheIDs
void beginJob() override
static const int IX_MAX
Definition: EEDetId.h:302
int hashedIndex() const
Definition: EEDetId.h:182
static const int MAX_IPHI
Definition: EBDetId.h:144
const EcalLaserTimeStampMap & getTimeMap() const
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
HLT enums.
T get() const
Definition: EventSetup.h:68
static const int IY_MAX
Definition: EEDetId.h:306
T const * product() const
Definition: ESHandle.h:84
TimeValue_t value() const
Definition: Timestamp.h:56