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 // system include files
19 #include <memory>
20 
21 // user include files
22 
25 
28 
31 
33 
35 
37 
41 
43 
44 //
45 // constants, enums and typedefs
46 //
47 
48 //
49 // static data member definitions
50 //
51 
52 //
53 // constructors and destructor
54 //
56  : // m_timetype(iConfig.getParameter<std::string>("timetype")),
57  m_cacheIDs(),
58  m_records() {
59  std::string container;
62 
63  //m_firstRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("firstRun").c_str());
64  //m_lastRun=(unsigned long long)atoi( iConfig.getParameter<std::string>("lastRun").c_str());
65 
66  typedef std::vector<edm::ParameterSet> Parameters;
67  Parameters toGet = iConfig.getParameter<Parameters>("toGet");
68  for (Parameters::iterator i = toGet.begin(); i != toGet.end(); ++i) {
69  container = i->getParameter<std::string>("container");
70  record = i->getParameter<std::string>("record");
71  m_cacheIDs.insert(std::make_pair(container, 0));
72  m_records.insert(std::make_pair(container, record));
73 
74  } //now do what ever initialization is needed
75 }
76 
78  // do anything here that needs to be done at desctruction time
79  // (e.g. close files, deallocate resources etc.)
80 }
81 
82 //
83 // member functions
84 //
85 
86 // ------------ method called to for each event ------------
87 void EcalGetLaserData::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
88  using namespace edm;
89 
90  // loop on offline DB conditions to be transferred as from config file
91  std::string container;
93  typedef std::map<std::string, std::string>::const_iterator recordIter;
94  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
95  container = (*i).first;
96  record = (*i).second;
97 
98  std::string recordName = m_records[container];
99 
100  if (container == "EcalLaserAPDPNRatios") {
101  // get from offline DB the last valid laser set
103  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);
104 
105  // this is the offline object
108 
109  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = handle.product()->getLaserMap();
110  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = handle.product()->getTimeMap();
111 
112  // loop through ecal barrel
113  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
114  if (iEta == 0)
115  continue;
116  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
117  EBDetId ebdetid(iEta, iPhi);
118  int hi = ebdetid.hashedIndex();
119 
120  if (hi < static_cast<int>(laserRatiosMap.size())) {
121  apdpnpair = laserRatiosMap[hi];
122  std::cout << "A sample value of APDPN pair EB : " << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2
123  << std::endl;
124  } else {
125  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
126  }
127  }
128  }
129 
130  // loop through ecal endcap
131  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
132  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
133  if (!EEDetId::validDetId(iX, iY, 1))
134  continue;
135 
136  EEDetId eedetidpos(iX, iY, 1);
137  int hi = eedetidpos.hashedIndex();
138 
139  if (hi < static_cast<int>(laserRatiosMap.size())) {
140  apdpnpair = laserRatiosMap[hi];
141  std::cout << "A sample value of APDPN pair EE+ : " << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2
142  << std::endl;
143  } else {
144  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
145  }
146 
147  if (!EEDetId::validDetId(iX, iY, -1))
148  continue;
149  EEDetId eedetidneg(iX, iY, 1);
150  hi = eedetidneg.hashedIndex();
151 
152  if (hi < static_cast<int>(laserRatiosMap.size())) {
153  apdpnpair = laserRatiosMap[hi];
154  std::cout << "A sample value of APDPN pair EE- : " << hi << " : " << apdpnpair.p1 << " , " << apdpnpair.p2
155  << std::endl;
156  } else {
157  edm::LogError("EcalGetLaserData") << "error with laserRatiosMap!" << std::endl;
158  }
159  }
160  }
161 
162  for (int i = 0; i < 92; i++) {
163  timestamp = laserTimeMap[i];
164  std::cout << "A value of timestamp pair : " << i << " " << timestamp.t1.value() << " , " << timestamp.t2.value()
165  << std::endl;
166  }
167 
168  std::cout << ".. just retrieved the last valid record from DB " << std::endl;
169 
170  } else if (container == "EcalLaserAPDPNRatiosRef") {
171  // get from offline DB the last valid laser set
174 
175  EcalLaserAPDPNref apdpnref;
176  const EcalLaserAPDPNRatiosRefMap& laserRefMap = handle.product()->getMap();
177 
178  // first barrel
179  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
180  if (iEta == 0)
181  continue;
182  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
183  EBDetId ebdetid(iEta, iPhi);
184  int hi = ebdetid.hashedIndex();
185 
186  if (hi < static_cast<int>(laserRefMap.size())) {
187  apdpnref = laserRefMap[hi];
188  std::cout << "A sample value of APDPN Reference value EB : " << hi << " : " << apdpnref << std::endl;
189  } else {
190  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
191  }
192  }
193  }
194 
195  // now for endcap
196  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
197  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
198  if (!EEDetId::validDetId(iX, iY, 1))
199  continue;
200 
201  EEDetId eedetidpos(iX, iY, 1);
202  int hi = eedetidpos.hashedIndex();
203 
204  if (hi < static_cast<int>(laserRefMap.size())) {
205  apdpnref = laserRefMap[hi];
206  std::cout << "A sample value of APDPN Reference value EE+ : " << hi << " : " << apdpnref << std::endl;
207 
208  } else {
209  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
210  }
211 
212  if (!EEDetId::validDetId(iX, iY, -1))
213  continue;
214  EEDetId eedetidneg(iX, iY, -1);
215  hi = eedetidneg.hashedIndex();
216 
217  if (hi < static_cast<int>(laserRefMap.size())) {
218  apdpnref = laserRefMap[hi];
219  std::cout << "A sample value of APDPN Reference value EE- : " << hi << " : " << apdpnref << std::endl;
220  } else {
221  edm::LogError("EcalGetLaserData") << "error with laserRefMap!" << std::endl;
222  }
223  }
224  }
225 
226  std::cout << "... just retrieved the last valid record from DB " << std::endl;
227 
228  } else if (container == "EcalLaserAlphas") {
229  // get from offline DB the last valid laser set
231  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
232 
233  // this is the offline object
235  const EcalLaserAlphaMap& laserAlphaMap = handle.product()->getMap(); // map of apdpns
236 
237  // first barrel
238  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
239  if (iEta == 0)
240  continue;
241  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
242  EBDetId ebdetid(iEta, iPhi);
243  int hi = ebdetid.hashedIndex();
244 
245  if (hi < static_cast<int>(laserAlphaMap.size())) {
246  alpha = laserAlphaMap[hi];
247  std::cout << " A sample value of Alpha value EB : " << hi << " : " << alpha << std::endl;
248  } else {
249  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
250  }
251  }
252  }
253 
254  // next endcap
255  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
256  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
257  if (!EEDetId::validDetId(iX, iY, 1))
258  continue;
259 
260  EEDetId eedetidpos(iX, iY, 1);
261  int hi = eedetidpos.hashedIndex();
262 
263  if (hi < static_cast<int>(laserAlphaMap.size())) {
264  alpha = laserAlphaMap[hi];
265  std::cout << " A sample value of Alpha value EE+ : " << hi << " : " << alpha << std::endl;
266  } else {
267  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
268  }
269 
270  if (!EEDetId::validDetId(iX, iY, -1))
271  continue;
272  EEDetId eedetidneg(iX, iY, -1);
273  hi = eedetidneg.hashedIndex();
274 
275  if (hi < static_cast<int>(laserAlphaMap.size())) {
276  alpha = laserAlphaMap[hi];
277  std::cout << " A sample value of Alpha value EE- : " << hi << " : " << alpha << std::endl;
278  } else {
279  edm::LogError("EcalGetLaserData") << "error with laserAlphaMap!" << std::endl;
280  }
281  }
282  }
283 
284  std::cout << "... just retrieved the last valid record from DB " << std::endl;
285 
286  } else {
287  edm::LogError("EcalGetLaserData") << "Cannot retrieve for container: " << container << std::endl;
288  }
289  }
290 }
291 
292 // ------------ method called once each job just before starting event loop ------------
294 
295 // ------------ method called once each job just after ending the event loop ------------
EBDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
DBConfiguration_cff.toGet
toGet
Definition: DBConfiguration_cff.py:10
EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1
float p1
Definition: EcalLaserAPDPNRatios.h:18
EcalGetLaserData::m_cacheIDs
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalGetLaserData.h:44
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
EcalLaserAPDPNRatiosRcd
Definition: EcalLaserAPDPNRatiosRcd.h:24
ESHandle.h
patZpeak.handle
handle
Definition: patZpeak.py:23
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
align_cfg.recordName
recordName
Definition: align_cfg.py:66
EcalGetLaserData::beginJob
void beginJob() override
Definition: EcalGetLaserData.cc:293
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
EcalLaserAlpha
float EcalLaserAlpha
Definition: EcalLaserAlphas.h:10
EEDetId::IX_MIN
static const int IX_MIN
Definition: EEDetId.h:290
EDAnalyzer.h
EcalCondObjectContainer::size
size_t size() const
Definition: EcalCondObjectContainer.h:82
EEDetId::IY_MIN
static const int IY_MIN
Definition: EEDetId.h:294
EcalCondObjectContainer< EcalLaserAPDPNpair >
EcalLaserAPDPNRatiosRefRcd
Definition: EcalLaserAPDPNRatiosRefRcd.h:24
MakerMacros.h
cond::timestamp
Definition: Time.h:19
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
Service.h
edm::ESHandle
Definition: DTSurvey.h:22
EBDetId::MAX_IPHI
static const int MAX_IPHI
Definition: EBDetId.h:137
EEDetId::IY_MAX
static const int IY_MAX
Definition: EEDetId.h:302
EEDetId
Definition: EEDetId.h:14
EcalLaserAPDPNref
float EcalLaserAPDPNref
Definition: EcalLaserAPDPNRatiosRef.h:11
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalGetLaserData::EcalGetLaserData
EcalGetLaserData(const edm::ParameterSet &iConfig)
Definition: EcalGetLaserData.cc:55
EcalLaserAPDPNRatios::EcalLaserAPDPNpair
Definition: EcalLaserAPDPNRatios.h:16
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
EcalGetLaserData::~EcalGetLaserData
~EcalGetLaserData() override
Definition: EcalGetLaserData.cc:77
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
EEDetId::IX_MAX
static const int IX_MAX
Definition: EEDetId.h:298
EcalGetLaserData::m_records
std::map< std::string, std::string > m_records
Definition: EcalGetLaserData.h:45
EcalLaserAlphasRcd
Definition: EcalLaserAlphasRcd.h:24
edm::EventSetup
Definition: EventSetup.h:57
EcalGetLaserData::endJob
void endJob() override
Definition: EcalGetLaserData.cc:296
EcalLaserAPDPNRatios::EcalLaserTimeStampMap
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
Definition: EcalLaserAPDPNRatios.h:34
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition: HiEvtPlaneList.h:38
Frameworkfwd.h
EcalGetLaserData::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: EcalGetLaserData.cc:87
EventSetup.h
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
ParameterSet.h
EventSetupRecordKey.h
EcalGetLaserData.h
edm::Event
Definition: Event.h:73
Parameters
vector< ParameterSet > Parameters
Definition: HLTMuonPlotter.cc:25
EcalLaserAPDPNRatios::EcalLaserTimeStamp
Definition: EcalLaserAPDPNRatios.h:24
EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2
float p2
Definition: EcalLaserAPDPNRatios.h:19
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136
EBDetId::MIN_IPHI
static const int MIN_IPHI
Definition: EBDetId.h:135