ATLAS Offline Software
LArConditionsTestAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
16 
19 
22 #include "LArElecCalib/ILArOFC.h"
23 
25 
27 
29 // CONSTRUCTOR:
31 
32 LArConditionsTestAlg::LArConditionsTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
33  AthAlgorithm(name,pSvcLocator),
34  m_onlineID(0),
35  m_testCondObjs(false),
36  m_readCondObjs(false),
37  m_writeCondObjs(false),
38  m_writeCorrections(false),
39  m_applyCorrections(false),
40  m_testReadDB(false),
41  m_TB(false),
42  m_tbin(0)
43 {
44  // switch for testing Filling IOV.
45  declareProperty("TestCondObjs", m_testCondObjs);
46  declareProperty("ReadCondObjs", m_readCondObjs);
47  declareProperty("WriteCondObjs", m_writeCondObjs);
48  declareProperty("WriteCorrections", m_writeCorrections);
49  declareProperty("ApplyCorrections", m_applyCorrections);
50  declareProperty("TestReadDBDirect", m_testReadDB) ;
51  declareProperty("Testbeam", m_TB) ;
52  declareProperty("Tbin", m_tbin) ;
53 }
54 
56 // DESTRUCTOR:
58 
60 { }
61 
63 // INITIALIZE:
65 
67 {
68  ATH_MSG_DEBUG ( " TestCondObjs flag = " << m_testCondObjs );
69  ATH_MSG_DEBUG ( " ReadCondObjs flag = " << m_readCondObjs );
70  ATH_MSG_DEBUG ( " WriteCondObjs flag = " << m_writeCondObjs );
71  ATH_MSG_DEBUG ( " WriteCorrections flag = " << m_writeCorrections );
72  ATH_MSG_DEBUG ( " ApplyCorrections flag = " << m_applyCorrections );
73  ATH_MSG_DEBUG ( " TestReadDBDirect flag = " << m_testReadDB );
74  ATH_MSG_DEBUG ( " Testbeam flag = " << m_TB );
75 
77 
78  const CaloCell_ID* calocell_id = nullptr;
79  ATH_CHECK( detStore()->retrieve(calocell_id) );
80 
81  ATH_MSG_DEBUG ( "initialize done" );
82  return StatusCode::SUCCESS;
83 }
84 
86 // EXECUTE:
88 
90 {
91  ATH_MSG_DEBUG ( " retrieve DataHandle<ILArRamp> in execute " );
92 
93  if(m_testCondObjs){
94 
95  // create cache
97 // StatusCode sc = testDbObjectRead();
98 // if(sc.isFailure()) {
99 // log << MSG::ERROR << "Failed testDbObjectRead " << endmsg;
100 // return StatusCode::FAILURE;
101 // }
102 
103  }
104 
105 
106 // if(m_testCondObject){
107 // std::string key = "LArRamp";
108 // const ILArRamp* ramp = 0 ;
109 // detStore()->retrieve(ramp, key);
110 // if(!ramp) {
111 // log<< MSG::ERROR<<" Failed to get LArRamp in execute " << endmsg;
112 // return StatusCode::FAILURE ;
113 // }
114 // }
115 
116  if(m_TB){
117  const ILArOFC* ofc = nullptr;
118  ATH_CHECK( detStore()->retrieve(ofc, "LArOFC") );
119 
120  const ILArRamp* ramp = nullptr;
121  ATH_CHECK( detStore()->retrieve(ramp, "LArRamp") );
122  }
123 
124  return StatusCode::SUCCESS;
125 }
126 
127 
129 // FINALIZE:
130 // Note that it is NOT NECESSARY to run the finalize of individual
131 // sub-algorithms. The framework takes care of it.
133 
135 {
137  return StatusCode::SUCCESS;
138 }
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
142 
145 {
146  // StatusCode sc;
147  ATH_MSG_INFO ("in createCompareObjects()" );
148 
149  // Create set of ids, LArRampComplete::LArCondObj
150 
151  std::vector<HWIdentifier>::const_iterator chanIt = m_onlineID->channel_begin();
152  std::vector<HWIdentifier>::const_iterator chanEnd = m_onlineID->channel_end();
153  int ichan = -1;
154  int icorr = 0;
155  float vramp = 0;
156  int gain = 0;
157  for (; chanIt != chanEnd; ++chanIt, ++ichan) {
158  // add channels with downscale factor
159  if (ichan % 1000 != 5) continue;
160 
161  // Create ramp with 3 vRamp elements
162  LArRampPTmp ramp((*chanIt), gain);
163  ramp.m_vRamp.push_back(vramp);
164  vramp += 1.0;
165  ramp.m_vRamp.push_back(vramp);
166  vramp += 1.0;
167  ramp.m_vRamp.push_back(vramp);
168  vramp += 1.0;
169  // add to cache
170  m_rampCache.push_back(ramp);
171 
172  // Change gain each time
173  gain = (gain == 2) ? 0 : gain + 1;
174 
176  // Create downscaled corrections
177  ++icorr;
178  if (icorr % 10 != 5) continue;
179  // Just change sign of ramp values
180  for (unsigned int i = 0; i < 3; ++i)ramp.m_vRamp[i] = -ramp.m_vRamp[i];
181  m_rampCorrections.push_back(ramp);
182  }
183  }
184 
185  // Print out cache and corrections
186  for (unsigned int i = 0; i < m_rampCache.size(); ++i) {
187  ATH_MSG_DEBUG ("Cache: chan, gain, ramps "
188  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
189  << m_rampCache[i].m_gain << " "
190  << m_rampCache[i].m_vRamp[0] << " "
191  << m_rampCache[i].m_vRamp[1] << " "
192  << m_rampCache[i].m_vRamp[2] << " " );
193  }
194  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
195  ATH_MSG_DEBUG ("Corrections: chan, gain, ramps "
196  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
197  << m_rampCorrections[i].m_gain << " "
198  << m_rampCorrections[i].m_vRamp[0] << " "
199  << m_rampCorrections[i].m_vRamp[1] << " "
200  << m_rampCorrections[i].m_vRamp[2] << " " );
201  }
202 
203  ATH_MSG_DEBUG ( "End of create comparison objects " );
204  return StatusCode::SUCCESS;
205 }
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
208 
209 inline bool operator == (const LArRampComplete::LArCondObj& r1, const LArRampPTmp& r2)
210 {
211  // Comparison of two LArRampComplete::LArCondObj objects
212  if (r1.m_vRamp.size() != r2.m_vRamp.size()) return (false);
213  for (unsigned int i = 0; i < r1.m_vRamp.size(); ++i) {
214  if (r1.m_vRamp[i] != r2.m_vRamp[i]) return (false);
215  }
216  return (true);
217 }
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
220 
221 inline bool CorrectionCompare (const LArRampComplete::LArCondObj& r1, const LArRampPTmp& r2)
222 {
223  // Comparison of two LArRampComplete::LArCondObj objects
224  if (r1.m_vRamp.size() != r2.m_vRamp.size()) return (false);
225  for (unsigned int i = 0; i < r1.m_vRamp.size(); ++i) {
226  if (r1.m_vRamp[i] != -r2.m_vRamp[i]) return (false);
227  }
228  return (true);
229 }
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
232 
233 inline bool operator != (const LArRampComplete::LArCondObj& r1, const LArRampPTmp& r2)
234 {
235  if(r1 == r2)return (false);
236  return (true);
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
241 
244 {
245  ATH_MSG_INFO ("in testCondObjects()" );
246 
247  static std::atomic<bool> first = true;
248  if (!first) {
249  ATH_MSG_INFO ("Multiple entries - returning" );
250  return StatusCode::SUCCESS;
251  }
252  first = false;
253 
254  typedef LArRampMC::CONTAINER CONTAINER;
255  typedef CONTAINER::chan_const_iterator chan_const_iterator;
256  typedef CONTAINER::iov_const_iterator iov_const_iterator;
257 
260 
261  const LArRampMC* ramps = 0;
262 
263  // Create SingleGroup
264  if (m_readCondObjs) {
265  const ILArRamp* iramps = 0;
266  ATH_CHECK( detStore()->retrieve(iramps, "/LArCalorimeter/LArTests/LArRampsSingleGroup") );
267  ATH_MSG_INFO ( "Retrieved ramps for LArRampsSingleGroup " );
268  ramps = dynamic_cast<const LArRampMC*>(iramps);
269  if (!ramps) {
270  ATH_MSG_ERROR ("Could not dynamic cast ILArRamp to LArRampMC" );
271  return( StatusCode::FAILURE);
272  }
273  }
274  else {
275  LArRampMC* ramps_rw = new LArRampMC;
276  ramps = ramps_rw;
277  ATH_MSG_INFO ( "Created ramps for LArRampsSingleGroup " );
278  ramps_rw->setGroupingType(LArConditionsContainerBase::SingleGroup);
279  ATH_CHECK( ramps_rw->initialize() );
280  }
281 
282  ATH_CHECK( testEachCondObject(ramps) );
283  ATH_MSG_INFO ( "Succeeded SingleGroup test " );
284 
285  if (!m_readCondObjs) {
286  // Save in DetectorStore
287  ATH_CHECK( detStore()->record(ramps, "/LArCalorimeter/LArTests/LArRampsSingleGroup") );
288  const ILArRamp* iramps = 0;
289  ATH_CHECK( detStore()->symLink(ramps, iramps) );
290 
292  if (ramps) {
293  ATH_MSG_DEBUG ( "Total number of conditions objects"
294  << ramps->totalNumberOfConditions() );
295  }
296  if (!m_writeCondObjs) {
297  // Remove conditions objects if not writing out
298  LArRampMC* ramps_rw = const_cast<LArRampMC*>(ramps);
299  if (!ramps_rw) {
300  ATH_MSG_ERROR ( "Could not const cast to LArRampMC " );
301  return StatusCode::FAILURE;
302  }
303  ramps_rw->removeConditions();
304  ATH_MSG_DEBUG ( "Removed conditions objects" );
305  }
306  ATH_MSG_DEBUG ( "Total number of conditions objects "
307  << ramps->totalNumberOfConditions() );
308  ATH_MSG_DEBUG ( "Total number of correction objects"
309  << ramps->totalNumberOfCorrections() );
310  }
311 
312  // Create SubDetectorGrouping
313  if (m_readCondObjs) {
314  const ILArRamp* iramps = 0;
315  ATH_CHECK( detStore()->retrieve(iramps, "/LArCalorimeter/LArTests/LArRampsSubDetectorGrouping") );
316  ATH_MSG_INFO ( "Retrieved ramps for LArRampsSubDetectorGrouping " );
317  ramps = dynamic_cast<const LArRampMC*>(iramps);
318  if (!ramps) {
319  ATH_MSG_ERROR ("Could not dynamic cast ILArRamp to LArRampMC" );
320  return( StatusCode::FAILURE);
321  }
322  }
323  else {
324  LArRampMC* ramps_rw = new LArRampMC;
325  ramps = ramps_rw;
326  //ramps_rw->setGroupingType(LArConditionsContainerBase::SubDetectorGrouping);
327  ATH_CHECK( ramps_rw->initialize() );
328  }
329 
330  ATH_CHECK( testEachCondObject(ramps) );
331  ATH_MSG_INFO ( "Succeeded SubDetectorGrouping test " );
332 
333  if (!m_readCondObjs) {
334  // Save in DetectorStore
335  ATH_CHECK( detStore()->record(ramps, "/LArCalorimeter/LArTests/LArRampsSubDetectorGrouping") );
336  const ILArRamp* iramps = 0;
337  ATH_CHECK( detStore()->symLink(ramps, iramps) );
339  if (ramps) {
340  ATH_MSG_DEBUG ( "Total number of conditions objects"
341  << ramps->totalNumberOfConditions() );
342  }
343  if (!m_writeCondObjs) {
344  // Remove conditions objects if not writing out
345  LArRampMC* ramps_rw = const_cast<LArRampMC*>(ramps);
346  if (!ramps_rw) {
347  ATH_MSG_ERROR ( "Could not const cast to LArRampMC " );
348  return StatusCode::FAILURE;
349  }
350  ramps_rw->removeConditions();
351  ATH_MSG_DEBUG ( "Removed conditions objects" );
352  }
353  ATH_MSG_DEBUG ( "Total number of conditions objects "
354  << ramps->totalNumberOfConditions() );
355  ATH_MSG_DEBUG ( "Total number of correction objects"
356  << ramps->totalNumberOfConditions() );
357  }
358 
359  // Create FeedThroughGrouping
360  if (m_readCondObjs) {
361  const ILArRamp* iramps = 0;
362  ATH_CHECK( detStore()->retrieve(iramps, "/LArCalorimeter/LArTests/LArRampsFeedThroughGrouping") );
363  ATH_MSG_INFO ( "Retrieved ramps for LArRampsFeedThroughGrouping " );
364  ramps = dynamic_cast<const LArRampMC*>(iramps);
365  if (!ramps) {
366  ATH_MSG_ERROR ("Could not dynamic cast ILArRamp to LArRampMC" );
367  return( StatusCode::FAILURE);
368  }
369  }
370  else {
371  LArRampMC* ramps_rw = new LArRampMC;
372  ramps = ramps_rw;
373  ramps_rw->setGroupingType(LArConditionsContainerBase::FeedThroughGrouping);
374  ATH_CHECK( ramps_rw->initialize() );
375  }
376 
377  ATH_CHECK( testEachCondObject(ramps) );
378  ATH_MSG_INFO ( "Succeeded FeedThroughGrouping test " );
379 
380  if (!m_readCondObjs) {
381  // Save in DetectorStore
382  ATH_CHECK( detStore()->record(ramps, "/LArCalorimeter/LArTests/LArRampsFeedThroughGrouping") );
383  const ILArRamp* iramps = 0;
384  ATH_CHECK( detStore()->symLink(ramps, iramps) );
386  if (ramps) {
387  ATH_MSG_DEBUG ( "Total number of conditions objects"
388  << ramps->totalNumberOfConditions() );
389  }
390  if (!m_writeCondObjs) {
391  // Remove conditions objects if not writing out
392  LArRampMC* ramps_rw = const_cast<LArRampMC*>(ramps);
393  if (!ramps_rw) {
394  ATH_MSG_ERROR ( "Could not const cast to LArRampMC " );
395  return StatusCode::FAILURE;
396  }
397  ramps_rw->removeConditions();
398  ATH_MSG_DEBUG ( "Removed conditions objects" );
399  }
400  ATH_MSG_DEBUG ( "Total number of conditions objects "
401  << ramps->totalNumberOfConditions() );
402  ATH_MSG_DEBUG ( "Total number of correction objects"
403  << ramps->totalNumberOfCorrections() );
404  }
405 
406  ATH_MSG_DEBUG ( "Statistics for LArRampsFeedThroughGrouping " );
407  ATH_MSG_DEBUG ( "Number of channels, iovs "
408  << ramps->chan_size() << " " << ramps->iov_size() );
409 
410  iov_const_iterator iovIt = ramps->iov_begin();
411  iov_const_iterator iovEnd = ramps->iov_end ();
412  msg() << MSG::DEBUG << "IOVs found: ";
413  for (; iovIt != iovEnd; ++iovIt) {
414  msg() << MSG::DEBUG << (*iovIt) << ", ";
415  }
416  msg() << MSG::DEBUG << endmsg;
417 
418  chan_const_iterator chIt = ramps->chan_begin();
419  chan_const_iterator chEnd = ramps->chan_end ();
420  for (; chIt != chEnd; ++chIt) {
421  ATH_MSG_DEBUG ( "Channel: " << (*chIt)
422  << " number of conditions: " << ramps->conditionsPerChannel((*chIt)) );
423  }
424 
425  for (unsigned int i = 0; i < ramps->nGroups(); ++i) {
426  ATH_MSG_DEBUG ( "Group: " << i
427  << " number of conditions: " << ramps->conditionsPerGroup(i) );
428  }
429  ATH_MSG_DEBUG ("");
430 
431  for (unsigned int i = 0; i < ramps->nGains(); ++i) {
432  ATH_MSG_DEBUG ( "Gain: " << i
433  << " number of conditions: " << ramps->conditionsPerGain(i) );
434  }
435  ATH_MSG_DEBUG ( "Total number of conditions objects "
436  << ramps->totalNumberOfConditions() );
437  ATH_MSG_DEBUG ( "Total number of correction objects "
438  << ramps->totalNumberOfCorrections() );
439 
440 
441  ATH_MSG_DEBUG ( "End of testCondObjects " );
442 
443  return StatusCode::SUCCESS;
444 }
445 
446 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
447 
449 LArConditionsTestAlg::testEachCondObject ATLAS_NOT_THREAD_SAFE (const LArRampMC* ramps)
450 {
451  ATH_MSG_INFO ("in testEachCondObject()" );
452  bool error = false;
453 
454  typedef LArRampMC::CONTAINER CONTAINER;
455  //typedef CONTAINER::ConstCorrectionIt ConstCorrectionIt;
456 
457  // Cast into r/w for tests
458  LArRampMC* ramps_rw = const_cast<LArRampMC*>(ramps);
459  if (!ramps_rw) {
460  ATH_MSG_ERROR ( "Could not const cast to LArRampMC " );
461  return StatusCode::FAILURE;
462  }
463 
464  if (ramps_rw->correctionsApplied())
465  ATH_CHECK(ramps_rw->undoCorrections());
466 
467  if (!m_readCondObjs) {
468  if (m_writeCondObjs) {
469 
470  for (unsigned int i = 0; i < m_rampCache.size(); ++i) {
471  ATH_MSG_DEBUG ("setPdata for chan, chan id, gain " << i << " "
472  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
473  << m_rampCache[i].m_gain << " " );
474 
475  // Must copy LArRampPTmp into a LArRampComplete::LArCondObj
477  ramp.m_vRamp = m_rampCache[i].m_vRamp;
478 
479  ramps_rw->setPdata(m_rampCache[i].m_channelID,
480  ramp,
481  m_rampCache[i].m_gain);
482  }
483  }
484 
485  ATH_MSG_DEBUG ( "Finished conditions, now write corrections " );
486 
487  if (m_writeCorrections) {
488  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
489 
490  ATH_MSG_DEBUG ("insert corr for chan, chan id, gain " << i << " "
491  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
492  << m_rampCorrections[i].m_gain << " " );
493 
494  // Must copy LArRampPTmp into a LArRampComplete::LArCondObj
496  ramp.m_vRamp = m_rampCorrections[i].m_vRamp;
497 
498  ATH_CHECK( ramps_rw->insertCorrection(m_rampCorrections[i].m_channelID,
499  ramp,
500  m_rampCorrections[i].m_gain) );
501  }
502  }
503  }
504 
505  ATH_MSG_DEBUG ("Number of channels, iovs "
506  << ramps->chan_size() << " " << ramps->iov_size() );
507 
508  CONTAINER::chan_const_iterator chanIt1 = ramps->chan_begin();
509  CONTAINER::chan_const_iterator endChan1 = ramps->chan_end ();
510  for (unsigned int i = 0; chanIt1 != endChan1; ++chanIt1, ++i) {
511  const CONTAINER::Subset* subset = ramps->at(i);
512  ATH_MSG_DEBUG ( "Index " << i
513  << " channel " << subset->channel()
514  << " gain " << subset->gain()
515  << " groupingType " << subset->groupingType()
516  << " subsetSize " << subset->subsetSize()
517  << " correctionVecSize " << subset->correctionVecSize() );
518  if ((*chanIt1) != subset->channel()) {
519  ATH_MSG_ERROR ( "Channel numbers not the same for MultChanColl and subset: "
520  << i
521  << " multchan " << (*chanIt1)
522  << " subset " << subset->channel() );
523  error = true;
524  }
525  }
526 
527  ATH_MSG_DEBUG ("Number of channels, iovs, subsets "
528  << ramps->chan_size() << " "
529  << ramps->iov_size() << " "
530  << ramps->size() << " " );
531 
532  ATH_MSG_DEBUG ("Compare LArRampMC with cache " );
533  // Now loop over ramps and compare with cache
534  for (unsigned int i = 0; i < m_rampCache.size(); ++i) {
535 
536  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCache[i].m_channelID,
537  m_rampCache[i].m_gain);
538  unsigned int coolChannel = ramps->coolChannel(m_rampCache[i].m_channelID,
539  m_rampCache[i].m_gain);
540 
541  if (!rampP.isEmpty()) {
542  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
543  << coolChannel << " "
544  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
545  << m_rampCache[i].m_gain << " "
546  << rampP.m_vRamp[0] << " "
547  << rampP.m_vRamp[1] << " "
548  << rampP.m_vRamp[2] << " " );
549  }
550  else {
551  ATH_MSG_DEBUG ("New : isEmpty " );
552  }
553  ATH_MSG_DEBUG ("Cache: cool chan, chan id, gain, ramps "
554  << coolChannel << " "
555  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
556  << m_rampCache[i].m_gain << " "
557  << m_rampCache[i].m_vRamp[0] << " "
558  << m_rampCache[i].m_vRamp[1] << " "
559  << m_rampCache[i].m_vRamp[2] << " "
560  << " Compare = " << (rampP == m_rampCache[i]) );
561  if (rampP != m_rampCache[i] && !rampP.isEmpty()) {
562  ATH_MSG_ERROR ("LArRampMC and cache NOT equal" );
563  error = true;
564  }
565  }
566 
567 
568  // Now loop over ramps using generic iterator and compare with cache
569  ATH_MSG_DEBUG ("Compare LArRampMC with cache using iterator " );
570  CONTAINER::ConstConditionsMapIterator rampIt;
571  CONTAINER::ConstConditionsMapIterator rampEnd;
572  for (unsigned int gain = 0; gain < 3; ++gain) {
573  rampIt = ramps->begin(gain);
574  rampEnd = ramps->end (gain);
575  for (unsigned int i = 0; i < m_rampCache.size(); ++i) {
576  // cache is not in order for gains, select the current gain
577  if (gain != m_rampCache[i].m_gain) continue;
579  HWIdentifier rampId;
580  while(rampIt != rampEnd) {
581  rampP = *rampIt;
582  rampId = rampIt.channelId();
583  ++rampIt;
584  if (!rampP.isEmpty()) break; // break out for first non-empty ramp
585  }
586  unsigned int coolChannel = ramps->coolChannel(m_rampCache[i].m_channelID,
587  m_rampCache[i].m_gain);
588  if (!rampP.isEmpty()) {
589  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
590  << coolChannel << " "
591  << m_onlineID->show_to_string(rampId) << " "
592  << m_rampCache[i].m_gain << " "
593  << rampP.m_vRamp[0] << " "
594  << rampP.m_vRamp[1] << " "
595  << rampP.m_vRamp[2] << " " );
596  }
597  else {
598  ATH_MSG_DEBUG ("New : isEmpty " );
599  }
600  ATH_MSG_DEBUG ("Cache: cool chan, chan id, gain, ramps "
601  << coolChannel << " "
602  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
603  << m_rampCache[i].m_gain << " "
604  << m_rampCache[i].m_vRamp[0] << " "
605  << m_rampCache[i].m_vRamp[1] << " "
606  << m_rampCache[i].m_vRamp[2] << " "
607  << " Compare = " << (rampP == m_rampCache[i]) );
608  if (rampP != m_rampCache[i] && !rampP.isEmpty()) {
609  ATH_MSG_ERROR ("LArRampMC and cache NOT equal" );
610  error = true;
611  }
612  }
613  }
614 
615 
616 
617  // Now loop over ramps in pieces using the selector on febids to
618  // iterate and compare with cache
619  ATH_MSG_DEBUG ("Compare LArRampMC with cache using iterator and febid selection " );
620  // Loop over cache and divide the febids into three sets, where
621  // each set is an array of size 3 for the separate gains
622  std::vector<unsigned int> ids1[3];
623  std::vector<unsigned int> ids2[3];
624  std::vector<unsigned int> ids3[3];
625  for (unsigned int i = 0; i < m_rampCache.size(); ++i) {
626  if (i < m_rampCache.size()/3) {
627  unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
628  ids1[m_rampCache[i].m_gain].push_back(id);
629  }
630  else if (i < 2*m_rampCache.size()/3) {
631  unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
632  ids2[m_rampCache[i].m_gain].push_back(id);
633  }
634  else {
635  unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
636  ids3[m_rampCache[i].m_gain].push_back(id);
637  }
638  }
639 
640  for (unsigned int gain = 0; gain < 3; ++gain) {
641  for (unsigned int febSet = 0; febSet < 3; ++febSet) {
642  unsigned int i0 = 0;
643  unsigned int iend = m_rampCache.size()/3;
644  if (febSet < m_rampCache.size()/3) {
645  rampIt = ramps->begin(gain, ids1[gain]);
646  msg() << MSG::DEBUG <<"FebID vec 1 : ";
647  for (unsigned int i = 0; i < ids1[gain].size(); ++i) {
648  msg() << MSG::DEBUG << m_onlineID->show_to_string(HWIdentifier(ids1[gain][i]))
649  << " ";
650  }
651  msg() << MSG::DEBUG << endmsg;
652  }
653  else if (febSet < 2*m_rampCache.size()/3) {
654  rampIt = ramps->begin(gain, ids2[gain]);
655  i0 = m_rampCache.size()/3 + 1;
656  iend = 2*m_rampCache.size()/3;
657  msg() << MSG::DEBUG <<"FebID vec 2 : ";
658  for (unsigned int i = 0; i < ids2[gain].size(); ++i) {
659  msg() << MSG::DEBUG << m_onlineID->show_to_string(HWIdentifier(ids2[gain][i]))
660  << " ";
661  }
662  msg() << MSG::DEBUG << endmsg;
663  }
664  else {
665  rampIt = ramps->begin(gain, ids3[gain]);
666  i0 = 2*m_rampCache.size()/3 + 1;
667  iend = m_rampCache.size();
668  msg() << MSG::DEBUG <<"FebID vec 3 : ";
669  for (unsigned int i = 0; i < ids3[gain].size(); ++i) {
670  msg() << MSG::DEBUG << m_onlineID->show_to_string(HWIdentifier(ids3[gain][i]))
671  << " ";
672  }
673  msg() << MSG::DEBUG << endmsg;
674  }
675 
676  rampEnd = ramps->end (gain);
677  ATH_MSG_DEBUG ("After ramps->end " );
678  for (unsigned int i = i0; i < iend; ++i) {
679  // cache is not in order for gains, select the current gain
680  if (gain != m_rampCache[i].m_gain) continue;
682  HWIdentifier rampId;
683 
684  ATH_MSG_DEBUG ("Looking for "
685  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) );
686 
687  // Skip the empty channels
688  while(rampIt != rampEnd) {
689  rampP = *rampIt;
690  rampId = rampIt.channelId();
691  ++rampIt;
692  if (!rampP.isEmpty()) break; // break out for first non-empty ramp
693  }
694  unsigned int coolChannel = ramps->coolChannel(m_rampCache[i].m_channelID,
695  m_rampCache[i].m_gain);
696  if (!rampP.isEmpty()) {
697  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
698  << coolChannel << " "
699  << m_onlineID->show_to_string(rampId) << " "
700  << m_rampCache[i].m_gain << " "
701  << rampP.m_vRamp[0] << " "
702  << rampP.m_vRamp[1] << " "
703  << rampP.m_vRamp[2] << " " );
704  }
705  else {
706  ATH_MSG_DEBUG ("New : isEmpty " );
707  }
708  ATH_MSG_DEBUG ("Cache: cool chan, chan id, gain, ramps "
709  << coolChannel << " "
710  << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
711  << m_rampCache[i].m_gain << " "
712  << m_rampCache[i].m_vRamp[0] << " "
713  << m_rampCache[i].m_vRamp[1] << " "
714  << m_rampCache[i].m_vRamp[2] << " "
715  << " Compare = " << (rampP == m_rampCache[i]) );
716  if (rampP != m_rampCache[i] && !rampP.isEmpty()) {
717  ATH_MSG_ERROR ("LArRampMC and cache NOT equal" );
718  error = true;
719  }
720  }
721  }
722  }
723 
724  ATH_MSG_DEBUG ("Compare LArRampMC with corrections " );
725 
726  if (m_applyCorrections) {
727  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
728  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCorrections[i].m_channelID,
729  m_rampCorrections[i].m_gain);
730  unsigned int coolChannel = ramps->coolChannel(m_rampCorrections[i].m_channelID,
731  m_rampCorrections[i].m_gain);
732  if (!rampP.isEmpty()) {
733  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
734  << coolChannel << " "
735  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
736  << m_rampCorrections[i].m_gain << " "
737  << rampP.m_vRamp[0] << " "
738  << rampP.m_vRamp[1] << " "
739  << rampP.m_vRamp[2] << " " );
740  }
741  else {
742  ATH_MSG_DEBUG ("New : isEmpty " );
743  }
744 
745  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
746  << coolChannel << " "
747  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
748  << m_rampCorrections[i].m_gain << " "
749  << m_rampCorrections[i].m_vRamp[0] << " "
750  << m_rampCorrections[i].m_vRamp[1] << " "
751  << m_rampCorrections[i].m_vRamp[2] << " "
752  << " Compare = " << (CorrectionCompare(rampP, m_rampCorrections[i])) );
753  if (!CorrectionCompare(rampP, m_rampCorrections[i]) && !rampP.isEmpty()) {
754 
755  ATH_MSG_ERROR ("Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
756  error = true;
757  }
758  }
759 
760 
761  ATH_MSG_DEBUG ("Apply corrections and compare LArRampMC with corrections " );
762  ATH_CHECK( ramps_rw->applyCorrections() );
763  ATH_MSG_DEBUG ("Corrections applied: " << ramps->correctionsApplied() );
764 
765  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
766  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCorrections[i].m_channelID,
767  m_rampCorrections[i].m_gain);
768  unsigned int coolChannel = ramps->coolChannel(m_rampCorrections[i].m_channelID,
769  m_rampCorrections[i].m_gain);
770  if (!rampP.isEmpty()) {
771  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
772  << coolChannel << " "
773  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
774  << m_rampCorrections[i].m_gain << " "
775  << rampP.m_vRamp[0] << " "
776  << rampP.m_vRamp[1] << " "
777  << rampP.m_vRamp[2] << " " );
778  }
779  else {
780  ATH_MSG_DEBUG ("New : isEmpty " );
781  }
782  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
783  << coolChannel << " "
784  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
785  << m_rampCorrections[i].m_gain << " "
786  << m_rampCorrections[i].m_vRamp[0] << " "
787  << m_rampCorrections[i].m_vRamp[1] << " "
788  << m_rampCorrections[i].m_vRamp[2] << " "
789  << " Compare = " << (rampP == m_rampCorrections[i]) );
790  if (rampP != m_rampCorrections[i] && !rampP.isEmpty()) {
791  ATH_MSG_ERROR ("After correction: LArRampMC and correction NOT equal" );
792  error = true;
793  }
794  }
795 
796  ATH_MSG_DEBUG ("Undo corrections and compare LArRampMC with corrections " );
797  ATH_CHECK( ramps_rw->undoCorrections() );
798  ATH_MSG_DEBUG ("Corrections applied: " << ramps->correctionsApplied() );
799 
800  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
801  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCorrections[i].m_channelID,
802  m_rampCorrections[i].m_gain);
803  unsigned int coolChannel = ramps->coolChannel(m_rampCorrections[i].m_channelID,
804  m_rampCorrections[i].m_gain);
805  if (!rampP.isEmpty()) {
806  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
807  << coolChannel << " "
808  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
809  << m_rampCorrections[i].m_gain << " "
810  << rampP.m_vRamp[0] << " "
811  << rampP.m_vRamp[1] << " "
812  << rampP.m_vRamp[2] << " " );
813  }
814  else {
815  ATH_MSG_DEBUG ("New : isEmpty " );
816  }
817  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
818  << coolChannel << " "
819  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
820  << m_rampCorrections[i].m_gain << " "
821  << m_rampCorrections[i].m_vRamp[0] << " "
822  << m_rampCorrections[i].m_vRamp[1] << " "
823  << m_rampCorrections[i].m_vRamp[2] << " "
824  << " Compare = " << (CorrectionCompare(rampP, m_rampCorrections[i])) );
825  if (!CorrectionCompare(rampP, m_rampCorrections[i]) && !rampP.isEmpty()) {
826 
827  ATH_MSG_ERROR ("After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
828  error = true;
829  }
830  }
831 
832  ATH_MSG_DEBUG ("2nd Apply corrections and compare LArRampMC with corrections " );
833  ATH_CHECK( ramps_rw->applyCorrections() );
834  ATH_MSG_DEBUG ("Corrections applied: " << ramps->correctionsApplied() );
835 
836  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
837  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCorrections[i].m_channelID,
838  m_rampCorrections[i].m_gain);
839  unsigned int coolChannel = ramps->coolChannel(m_rampCorrections[i].m_channelID,
840  m_rampCorrections[i].m_gain);
841  if (!rampP.isEmpty()) {
842  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
843  << coolChannel << " "
844  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
845  << m_rampCorrections[i].m_gain << " "
846  << rampP.m_vRamp[0] << " "
847  << rampP.m_vRamp[1] << " "
848  << rampP.m_vRamp[2] << " " );
849  }
850  else {
851  ATH_MSG_DEBUG ("New : isEmpty " );
852  }
853  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
854  << coolChannel << " "
855  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
856  << m_rampCorrections[i].m_gain << " "
857  << m_rampCorrections[i].m_vRamp[0] << " "
858  << m_rampCorrections[i].m_vRamp[1] << " "
859  << m_rampCorrections[i].m_vRamp[2] << " "
860  << " Compare = " << (rampP == m_rampCorrections[i]) );
861  if (rampP != m_rampCorrections[i] && !rampP.isEmpty()) {
862  ATH_MSG_ERROR ("After correction: LArRampMC and correction NOT equal" );
863  error = true;
864  }
865  }
866 
867  ATH_MSG_DEBUG ("2nd Undo corrections and compare LArRampMC with corrections " );
868  ATH_CHECK( ramps_rw->undoCorrections() );
869  ATH_MSG_DEBUG ("Corrections applied: " << ramps->correctionsApplied() );
870 
871  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
872  LArRampComplete::LArCondObj rampP = ramps->get(m_rampCorrections[i].m_channelID,
873  m_rampCorrections[i].m_gain);
874  unsigned int coolChannel = ramps->coolChannel(m_rampCorrections[i].m_channelID,
875  m_rampCorrections[i].m_gain);
876  if (!rampP.isEmpty()) {
877  ATH_MSG_DEBUG ("New : cool chan, chan id, gain, ramps "
878  << coolChannel << " "
879  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
880  << m_rampCorrections[i].m_gain << " "
881  << rampP.m_vRamp[0] << " "
882  << rampP.m_vRamp[1] << " "
883  << rampP.m_vRamp[2] << " " );
884  }
885  else {
886  ATH_MSG_DEBUG ("New : isEmpty " );
887  }
888  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
889  << coolChannel << " "
890  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
891  << m_rampCorrections[i].m_gain << " "
892  << m_rampCorrections[i].m_vRamp[0] << " "
893  << m_rampCorrections[i].m_vRamp[1] << " "
894  << m_rampCorrections[i].m_vRamp[2] << " "
895  << " Compare = " << (CorrectionCompare(rampP, m_rampCorrections[i])) );
896  if (!CorrectionCompare(rampP, m_rampCorrections[i]) && !rampP.isEmpty()) {
897 
898  ATH_MSG_ERROR ("After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
899  error = true;
900  }
901  }
902  }
903 
904 
905  /*
906  log << MSG::DEBUG <<"Find each correction "
907  << endmsg;
908 
909  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
910  HWIdentifier id = m_rampCorrections[i].m_channelID;
911  unsigned int gain = m_rampCorrections[i].m_gain;
912 
913  ConstCorrectionIt it = ramps->findCorrection(id, gain);
914  // May not have any corrections
915  if (it != ramps->correctionsEnd(gain)) {
916 
917  unsigned int coolChannel = ramps->coolChannel(id, gain);
918  HWIdentifier id1((*it).first);
919  LArRampComplete::LArCondObj rampP = (*it).second;
920  if (id != id1 || rampP != m_rampCorrections[i]) {
921  log << MSG::ERROR <<"Correction retrieved with findCorrection does not match: "
922  << " i = " << i << endmsg;
923  error = true;
924  log << MSG::DEBUG <<"New : cool chan, chan id, gain, ramps "
925  << coolChannel << " "
926  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
927  << m_rampCorrections[i].m_gain << " "
928  << rampP.m_vRamp[0] << " "
929  << rampP.m_vRamp[1] << " "
930  << rampP.m_vRamp[2] << " "
931  << endmsg;
932  log << MSG::DEBUG <<"Corrections: cool chan, chan id, gain, ramps "
933  << coolChannel << " "
934  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
935  << m_rampCorrections[i].m_gain << " "
936  << m_rampCorrections[i].m_vRamp[0] << " "
937  << m_rampCorrections[i].m_vRamp[1] << " "
938  << m_rampCorrections[i].m_vRamp[2] << " "
939  << " Compare = " << (rampP == m_rampCorrections[i])
940  << endmsg;
941  }
942  }
943  else {
944  log << MSG::DEBUG <<"No corrections found "
945  << endmsg;
946  }
947  }
948  log << MSG::DEBUG <<"End - Find each correction "
949  << endmsg;
950 
951 
952  // Count the number of corrections per gain
953  unsigned int gains[3] = {0,0,0};
954  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
955  unsigned int gain = m_rampCorrections[i].m_gain;
956  gains[gain]++;
957  }
958  for (unsigned int i = 0; i < 3; ++i) {
959  if (gains[i] != ramps->correctionsSize(i)) {
960  log << MSG::ERROR <<"Number of corrections not same as number inserted: "
961  << gains[i] << " "
962  << ramps->correctionsSize(i) << " gain " << i
963  << endmsg;
964  error = true;
965  }
966 
967  // Check that each correction is the same using container iterator
968  unsigned int nit = 0;
969  ConstCorrectionIt it = ramps->correctionsBegin(i);
970  ConstCorrectionIt end = ramps->correctionsEnd(i);
971  unsigned int icorr = 0;
972  for (; it != end && icorr < m_rampCorrections.size(); ++it, ++nit, ++icorr) {
973  while (m_rampCorrections[icorr].m_gain != i) ++icorr;
974  HWIdentifier id = m_rampCorrections[icorr].m_channelID;
975  unsigned int gain = m_rampCorrections[icorr].m_gain;
976  unsigned int coolChannel = ramps->coolChannel(id, gain);
977  HWIdentifier id1((*it).first);
978  LArRampComplete::LArCondObj rampP = (*it).second;
979  if (id != id1 || rampP != m_rampCorrections[icorr]) {
980  log << MSG::ERROR <<"Correction retrieved with iterator does not match: "
981  << " gain = " << i
982  << " icorr = " << icorr
983  << " nit = " << nit
984  << endmsg;
985  error = true;
986  log << MSG::DEBUG <<"New : cool chan, chan id, gain, ramps "
987  << coolChannel << " "
988  << m_onlineID->show_to_string(m_rampCorrections[icorr].m_channelID) << " "
989  << m_rampCorrections[icorr].m_gain << " "
990  << rampP.m_vRamp[0] << " "
991  << rampP.m_vRamp[1] << " "
992  << rampP.m_vRamp[2] << " "
993  << endmsg;
994  log << MSG::DEBUG <<"Corrections: cool chan, chan id, gain, ramps "
995  << coolChannel << " "
996  << m_onlineID->show_to_string(m_rampCorrections[icorr].m_channelID) << " "
997  << m_rampCorrections[icorr].m_gain << " "
998  << m_rampCorrections[icorr].m_vRamp[0] << " "
999  << m_rampCorrections[icorr].m_vRamp[1] << " "
1000  << m_rampCorrections[icorr].m_vRamp[2] << " "
1001  << " Compare = " << (rampP == m_rampCorrections[icorr])
1002  << endmsg;
1003  }
1004  }
1005  }
1006 
1007  removed.
1008  */
1009 
1010  ATH_MSG_DEBUG ("Number of channels, iovs "
1011  << ramps->chan_size() << " " << ramps->iov_size() );
1012 
1013  std::set<unsigned int> channelNumbers;
1014  CONTAINER::chan_const_iterator chanIt = ramps->chan_begin();
1015  CONTAINER::chan_const_iterator endChan = ramps->chan_end ();
1016  for (unsigned int i = 0; chanIt != endChan; ++chanIt, ++i) {
1017  const CONTAINER::Subset* subset = ramps->at(i);
1018  ATH_MSG_DEBUG ( "Index " << i
1019  << " channel " << subset->channel()
1020  << " gain " << subset->gain()
1021  << " groupingType " << subset->groupingType()
1022  << " subsetSize " << subset->subsetSize()
1023  << " correctionVecSize " << subset->correctionVecSize() );
1024  if ((*chanIt) != subset->channel()) {
1025  ATH_MSG_ERROR ( "Channel numbers not the same for MultChanColl and subset: "
1026  << i
1027  << " multchan " << (*chanIt)
1028  << " subset " << subset->channel() );
1029  error = true;
1030  }
1031  if (!(channelNumbers.insert(subset->channel()).second)) {
1032  ATH_MSG_ERROR ( "Duplicate channel number - Index " << i
1033  << " channel " << subset->channel() );
1034  error = true;
1035  }
1036  }
1037  ATH_MSG_DEBUG ( "Channel numbers size " << channelNumbers.size()
1038  << " ramps size " << ramps->chan_size() );
1039 
1040  if (error) {
1041  ATH_MSG_ERROR ("Failing check of LArRamp - see above" );
1042  return (StatusCode::FAILURE);
1043  }
1044 
1045  ATH_MSG_DEBUG ( "End of testEachCondObject " );
1046  return StatusCode::SUCCESS;
1047 }
1048 
1049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1050 
1051 StatusCode
1053 {
1054 
1056  typedef ChanSet::ConstChannelIt ConstChannelIt;
1057 
1058  ATH_MSG_INFO ("in testChannelSet" );
1059 
1060  ChanSet chanSet;
1061 
1062  // corrections not always available:
1064  // add corrections to channel set
1065  for (unsigned int i = 0; i < m_rampCorrections.size(); ++i) {
1066  // Must copy LArRampPTmp into a LArRampComplete::LArCondObj
1068  ramp.m_vRamp = m_rampCorrections[i].m_vRamp;
1069  chanSet.insert(m_rampCorrections[i].m_channelID.get_identifier32().get_compact(), ramp);
1070  }
1071  // Now loop over corrections and check that they agree
1072  bool error = false;
1073  if (m_rampCorrections.size() != chanSet.size()) {
1074  ATH_MSG_ERROR ("Corrections not the same size as channel set: "
1075  << m_rampCorrections.size() << " " << chanSet.size() );
1076  return (StatusCode::FAILURE);
1077  }
1078  else {
1079  ATH_MSG_DEBUG ("Sizes OK: " << chanSet.size() );
1080  }
1081 
1082  ConstChannelIt it = chanSet.begin();
1083  ConstChannelIt itEnd = chanSet.end();
1084 
1085 
1086  unsigned int i = 0;
1087  for (; it != itEnd; ++it, ++i) {
1088 
1089  HWIdentifier id = m_rampCorrections[i].m_channelID;
1090  HWIdentifier id1((*it).first);
1091  LArRampComplete::LArCondObj rampP = (*it).second;
1092  if (id != id1 || rampP != m_rampCorrections[i]) {
1093  ATH_MSG_ERROR ("Correction retrieved with iterator does not match: "
1094  << " i = " << i );
1095  error = true;
1096  }
1097  ATH_MSG_DEBUG ("New : chan id, gain, ramps "
1098  << m_onlineID->show_to_string(id1) << " "
1099  << m_rampCorrections[i].m_gain << " "
1100  << rampP.m_vRamp[0] << " "
1101  << rampP.m_vRamp[1] << " "
1102  << rampP.m_vRamp[2] << " "
1103  );
1104  ATH_MSG_DEBUG ("Corrections: chan id, gain, ramps "
1105  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
1106  << m_rampCorrections[i].m_gain << " "
1107  << m_rampCorrections[i].m_vRamp[0] << " "
1108  << m_rampCorrections[i].m_vRamp[1] << " "
1109  << m_rampCorrections[i].m_vRamp[2] << " "
1110  << " Compare = " << (rampP == m_rampCorrections[i])
1111  );
1112  }
1113  if (!error) {
1114  ATH_MSG_DEBUG ("Iteration check OK " );
1115  }
1116 
1117  i = 0;
1118  for (; i < m_rampCorrections.size(); ++i) {
1119 
1120  unsigned int id = m_rampCorrections[i].m_channelID.get_identifier32().get_compact();
1121  it = chanSet.find(id);
1122  if (it == itEnd) {
1123  ATH_MSG_ERROR ("Could not find correction: "
1124  << " i = " << i );
1125  error = true;
1126  ATH_MSG_DEBUG ("Corrections: cool chan, chan id, gain, ramps "
1127  << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
1128  << m_rampCorrections[i].m_gain << " "
1129  << m_rampCorrections[i].m_vRamp[0] << " "
1130  << m_rampCorrections[i].m_vRamp[1] << " "
1131  << m_rampCorrections[i].m_vRamp[2] << " "
1132  );
1133  }
1134  }
1135  if (!error) {
1136  ATH_MSG_DEBUG ("Find check OK " );
1137  }
1138 
1139  if (error) {
1140  ATH_MSG_ERROR ("Failing check of channel set - see above" );
1141  return (StatusCode::FAILURE);
1142  }
1143  }
1144 
1145  return StatusCode::SUCCESS;
1146 
1147 }
1148 
1149 
1151 {
1152 
1153  typedef LArRampMC::CONTAINER CONTAINER;
1154  typedef CONTAINER::Subset Subset;
1155 
1156  const LArRampMC* ramp = 0 ;
1157  ATH_CHECK( detStore()->retrieve(ramp, "LArRamp") );
1158 
1159  ATH_MSG_DEBUG ( " Found LArRampMC, key LArRamp." );
1160 
1161  // Print out channels
1162  ATH_MSG_DEBUG ( " Number of channels " << ramp->chan_size() );
1163 
1164  // Print out first 10 elements of each gain for subset
1165  CONTAINER::chan_const_iterator chanIt = ramp->chan_begin();
1166  CONTAINER::chan_const_iterator endChan = ramp->chan_end ();
1167  for (unsigned int i = 0; chanIt != endChan; ++chanIt, ++i) {
1168  unsigned int coolChan = *chanIt;
1169  const Subset* subset = ramp->at(i);
1170 
1171  ATH_MSG_DEBUG ( " Channel " << coolChan << " "
1172  << " Subset size " << subset->subsetSize()
1173  << " gain, channel, grouping type " << subset->gain() << " "
1174  << MSG::hex << subset->channel() << " " << MSG::dec
1175  << subset->groupingType() << " "
1176  );
1177 
1178  Subset::ConstSubsetIt first = subset->subsetBegin();
1179  Subset::ConstSubsetIt last = subset->subsetEnd();
1180  //for (int i = 0; i < 10 && first != last; ++i, ++first) {
1181  for (; first != last; ++first) {
1182 
1183  // select non-zero subsets
1184  if ((*first).second.size()) {
1185 
1186  ATH_MSG_DEBUG ( " FEB id "
1187  << m_onlineID->show_to_string(HWIdentifier((*first).first)) << " "
1188  );
1189  for (unsigned int k = 0; k < 5; ++k) {
1190  msg() << MSG::DEBUG << " vramp " ;
1191 // << m_onlineID->show_to_string((*first).second[k].m_channelID) << " "
1192 // << (*first).second[k].m_gain << " ";
1193  for (unsigned int j = 0; j < (*first).second[k].m_vRamp.size(); ++j) {
1194  msg() << MSG::DEBUG << (*first).second[k].m_vRamp[j] << " ";
1195  }
1196  msg() << MSG::DEBUG << endmsg;
1197  }
1198 
1199  }
1200 
1201  }
1202  }
1203 
1204 
1205  /*
1206 
1207  // Print out first 10 elements of each gain for corrections
1208  for (unsigned int gain = 0; gain < 3; ++gain) {
1209  log << MSG::DEBUG << " Gain, size "
1210  << gain << " "
1211  << ramp->correctionsSize(gain) << endmsg;
1212  CONTAINER::ConstCorrectionIt first = ramp->correctionsBegin(gain);
1213  CONTAINER::ConstCorrectionIt last = ramp->correctionsEnd(gain);
1214  for (int i = 0; i < 10 && first != last; ++i, ++first) {
1215  log << MSG::DEBUG << " id, vramp "
1216  << m_onlineID->show_to_string(HWIdentifier((*first).first)) << " ";
1217 // << m_onlineID->show_to_string((*first).second.m_channelID) << " "
1218 // << (*first).second.m_gain << " ";
1219  for (unsigned int j = 0; j < (*first).second.m_vRamp.size(); ++j) {
1220  log << MSG::DEBUG << (*first).second.m_vRamp[j] << " ";
1221  }
1222  log << MSG::DEBUG << endmsg;
1223  }
1224  }
1225 
1226  */
1227 
1228  return StatusCode::SUCCESS;
1229 
1230 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArConditionsTestAlg::m_tbin
int m_tbin
Definition: LArConditionsTestAlg.h:71
LArConditionsContainer::applyCorrections
StatusCode applyCorrections()
apply correction set
LArConditionsContainer::setPdata
void setPdata(const HWIdentifier id, const T &payload, unsigned int gain=0)
put payload in persistent data
LArRampP1::isEmpty
bool isEmpty() const
Definition: LArRampP1.h:29
LArConditionsContainer::removeConditions
void removeConditions()
Remove conditions leaving the corrections - may be needed to only write out the corrections when both...
LArConditionsContainer::iov_end
iov_const_iterator iov_end() const
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArConditionsContainerBase::SingleGroup
@ SingleGroup
Definition: LArConditionsContainerBase.h:46
LArConditionsTestAlg::m_rampCache
std::vector< LArRampPTmp > m_rampCache
Definition: LArConditionsTestAlg.h:60
LArRampMC
Implementation of the interface ILArRamp for MC Derives from LArRampComplete, and implements the phi-...
Definition: LArRampMC.h:22
LArConditionsContainer::undoCorrections
StatusCode undoCorrections()
undo corrections that have been already applied
LArConditionsTestAlg::m_TB
BooleanProperty m_TB
Definition: LArConditionsTestAlg.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArConditionsTestAlg::m_writeCorrections
BooleanProperty m_writeCorrections
Definition: LArConditionsTestAlg.h:67
LArConditionsContainer::chan_begin
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators - from MultChanCollection.
LArConditionsTestAlg::testChannelSet
StatusCode testChannelSet()
Definition: LArConditionsTestAlg.cxx:1052
LArRampP1
Persistent data for LArRamp Copied from LAr.
Definition: LArRampP1.h:24
LArConditionsTestAlg::m_testReadDB
BooleanProperty m_testReadDB
Definition: LArConditionsTestAlg.h:69
LArConditionsContainer::insertCorrection
StatusCode insertCorrection(HWIdentifier id, const T &cond, unsigned int gain, bool corrChannel=true)
access to corrections -
LArRampPTmp::m_vRamp
std::vector< float > m_vRamp
Definition: LArRampPTmp.h:32
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ATLAS_NOT_THREAD_SAFE
StatusCode LArConditionsTestAlg::testEachCondObject ATLAS_NOT_THREAD_SAFE(const LArRampMC *ramps)
Definition: LArConditionsTestAlg.cxx:449
ILArOFC.h
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::channel_end
id_iterator channel_end() const
Definition: LArOnlineID_Base.cxx:1927
LArConditionsContainer::iov_begin
iov_const_iterator iov_begin() const
Access to IOVs via iterators - from MultChanCollection.
LArConditionsContainer::conditionsPerGain
unsigned int conditionsPerGain(unsigned int gain) const
Statistics: number of conditions per gain.
LArConditionsContainer::nGains
unsigned int nGains() const
Number of gain values.
ReadCondHandle.h
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArRampP1::m_vRamp
std::vector< float > m_vRamp
Definition: LArRampP1.h:30
LArConditionsContainer::coolChannel
unsigned int coolChannel(const HWIdentifier id, unsigned int gain=0) const
Return the COOL channel number for a given online id and gain.
LArConditionsContainer< LArRampP1 >
LArConditionsTestAlg::m_rampCorrections
std::vector< LArRampPTmp > m_rampCorrections
Definition: LArConditionsTestAlg.h:61
LArConditionsTestAlg::m_readCondObjs
BooleanProperty m_readCondObjs
Definition: LArConditionsTestAlg.h:65
LArRampMC::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
Definition: LArRampMC.cxx:10
LArConditionsContainer::totalNumberOfConditions
unsigned int totalNumberOfConditions() const
Statistics: total number of conditions.
LArConditionsTestAlg::createCompareObjects
StatusCode createCompareObjects()
Definition: LArConditionsTestAlg.cxx:144
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArConditionsContainer::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArConditionsTestAlg.h
This file contains an algorithm for testing lar conditions data access.
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArRampMC.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArConditionsContainer::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
ILArRamp
Definition: ILArRamp.h:12
LArConditionsTestAlg::m_applyCorrections
BooleanProperty m_applyCorrections
Definition: LArConditionsTestAlg.h:68
LArConditionsContainer::iov_size
iov_size_type iov_size() const
number of IOVs - from MultChanCollection
operator==
bool operator==(const LArRampComplete::LArCondObj &r1, const LArRampPTmp &r2)
Definition: LArConditionsTestAlg.cxx:209
LArConditionsChannelSet
template class for use for I/O of conditions data correction sets
Definition: LArConditionsChannelSet.h:37
LArConditionsChannelSet.h
This file defines the template class used for I/O of conditions data.
LArConditionsContainer::conditionsPerGroup
unsigned int conditionsPerGroup(unsigned int group) const
Statistics: number of conditions per group.
LArConditionsTestAlg::~LArConditionsTestAlg
virtual ~LArConditionsTestAlg()
Definition: LArConditionsTestAlg.cxx:59
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
LArConditionsContainer::chan_end
chan_const_iterator chan_end() const
AthAlgorithm
Definition: AthAlgorithm.h:47
ILArOFC
Definition: ILArOFC.h:14
LArConditionsContainer::totalNumberOfCorrections
unsigned int totalNumberOfCorrections() const
Statistics: total number of corrections.
LArConditionsContainer::chan_size
chan_size_type chan_size() const
number of channels - from MultChanCollection
LArConditionsContainer::nGroups
unsigned int nGroups() const
Number of groups - minimum is 2 (1 correction group, 1 FEB ID group)
LArRampPTmp
Persistent data for LArRamp Copied from LAr.
Definition: LArRampPTmp.h:24
defineDB.ichan
int ichan
Definition: JetTagCalibration/share/defineDB.py:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LArConditionsTestAlg::LArConditionsTestAlg
LArConditionsTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArConditionsTestAlg.cxx:32
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
LArConditionsTestAlg::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArConditionsTestAlg.h:63
LArConditionsTestAlg::initialize
virtual StatusCode initialize() override
Definition: LArConditionsTestAlg.cxx:66
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArConditionsContainer::conditionsPerChannel
unsigned int conditionsPerChannel(unsigned int coolChannel) const
Statistics: number of conditions per COOL channel.
LArConditionsContainer::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
LArConditionsTestAlg::m_writeCondObjs
BooleanProperty m_writeCondObjs
Definition: LArConditionsTestAlg.h:66
LArConditionsTestAlg::testCondObjects
StatusCode testCondObjects()
Definition: LArConditionsTestAlg.cxx:243
LArConditionsTestAlg::finalize
virtual StatusCode finalize() override
Definition: LArConditionsTestAlg.cxx:134
LArConditionsTestAlg::execute
virtual StatusCode execute() override
Definition: LArConditionsTestAlg.cxx:89
LArConditionsTestAlg::m_testCondObjs
BooleanProperty m_testCondObjs
Definition: LArConditionsTestAlg.h:64
operator!=
bool operator!=(const LArRampComplete::LArCondObj &r1, const LArRampPTmp &r2)
Definition: LArConditionsTestAlg.cxx:233
error
Definition: IImpactPoint3dEstimator.h:70
ReadOfcFromCool.ofc
ofc
Definition: ReadOfcFromCool.py:110
LArConditionsContainerBase::FeedThroughGrouping
@ FeedThroughGrouping
Definition: LArConditionsContainerBase.h:48
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LArOnlineID_Base::channel_begin
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
Definition: LArOnlineID_Base.cxx:1922
LArConditionsTestAlg::testDbObjectRead
StatusCode testDbObjectRead()
Definition: LArConditionsTestAlg.cxx:1150
fitman.k
k
Definition: fitman.py:528
LArOnlineID.h
CorrectionCompare
bool CorrectionCompare(const LArRampComplete::LArCondObj &r1, const LArRampPTmp &r2)
Definition: LArConditionsTestAlg.cxx:221
LArConditionsContainer::correctionsApplied
bool correctionsApplied() const
Have corrections been applied?