35 m_testCondObjs(false),
36 m_readCondObjs(false),
37 m_writeCondObjs(false),
38 m_writeCorrections(false),
39 m_applyCorrections(false),
82 return StatusCode::SUCCESS;
91 ATH_MSG_DEBUG (
" retrieve DataHandle<ILArRamp> in execute " );
124 return StatusCode::SUCCESS;
137 return StatusCode::SUCCESS;
157 for (; chanIt != chanEnd; ++chanIt, ++
ichan) {
159 if (
ichan % 1000 != 5)
continue;
178 if (icorr % 10 != 5)
continue;
204 return StatusCode::SUCCESS;
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);
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);
235 if(r1 == r2)
return (
false);
247 static std::atomic<bool>
first =
true;
250 return StatusCode::SUCCESS;
255 typedef CONTAINER::chan_const_iterator chan_const_iterator;
256 typedef CONTAINER::iov_const_iterator iov_const_iterator;
267 ATH_MSG_INFO (
"Retrieved ramps for LArRampsSingleGroup " );
268 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
270 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
271 return( StatusCode::FAILURE);
277 ATH_MSG_INFO (
"Created ramps for LArRampsSingleGroup " );
287 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsSingleGroup") );
301 return StatusCode::FAILURE;
316 ATH_MSG_INFO (
"Retrieved ramps for LArRampsSubDetectorGrouping " );
317 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
319 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
320 return( StatusCode::FAILURE);
335 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsSubDetectorGrouping") );
348 return StatusCode::FAILURE;
363 ATH_MSG_INFO (
"Retrieved ramps for LArRampsFeedThroughGrouping " );
364 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
366 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
367 return( StatusCode::FAILURE);
382 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsFeedThroughGrouping") );
395 return StatusCode::FAILURE;
406 ATH_MSG_DEBUG (
"Statistics for LArRampsFeedThroughGrouping " );
410 iov_const_iterator iovIt = ramps->
iov_begin();
411 iov_const_iterator iovEnd = ramps->
iov_end ();
413 for (; iovIt != iovEnd; ++iovIt) {
418 chan_const_iterator chIt = ramps->
chan_begin();
419 chan_const_iterator chEnd = ramps->
chan_end ();
420 for (; chIt != chEnd; ++chIt) {
425 for (
unsigned int i = 0;
i < ramps->
nGroups(); ++
i) {
431 for (
unsigned int i = 0;
i < ramps->
nGains(); ++
i) {
443 return StatusCode::SUCCESS;
461 return StatusCode::FAILURE;
467 if (!m_readCondObjs) {
468 if (m_writeCondObjs) {
470 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
472 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
473 << m_rampCache[
i].m_gain <<
" " );
477 ramp.
m_vRamp = m_rampCache[
i].m_vRamp;
479 ramps_rw->
setPdata(m_rampCache[
i].m_channelID,
481 m_rampCache[
i].m_gain);
485 ATH_MSG_DEBUG (
"Finished conditions, now write corrections " );
487 if (m_writeCorrections) {
488 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
491 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
492 << m_rampCorrections[
i].m_gain <<
" " );
496 ramp.
m_vRamp = m_rampCorrections[
i].m_vRamp;
500 m_rampCorrections[
i].m_gain) );
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);
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: "
521 <<
" multchan " << (*chanIt1)
522 <<
" subset " << subset->channel() );
530 << ramps->size() <<
" " );
534 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
537 m_rampCache[
i].m_gain);
538 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
539 m_rampCache[
i].m_gain);
543 << coolChannel <<
" "
544 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
545 << m_rampCache[
i].m_gain <<
" "
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()) {
569 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator " );
570 CONTAINER::ConstConditionsMapIterator rampIt;
571 CONTAINER::ConstConditionsMapIterator rampEnd;
575 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
577 if (
gain != m_rampCache[
i].m_gain)
continue;
580 while(rampIt != rampEnd) {
582 rampId = rampIt.channelId();
586 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
587 m_rampCache[
i].m_gain);
590 << coolChannel <<
" "
591 << m_onlineID->show_to_string(rampId) <<
" "
592 << m_rampCache[
i].m_gain <<
" "
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()) {
619 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator and febid selection " );
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);
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);
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);
641 for (
unsigned int febSet = 0; febSet < 3; ++febSet) {
643 unsigned int iend = m_rampCache.size()/3;
644 if (febSet < m_rampCache.size()/3) {
647 for (
unsigned int i = 0;
i < ids1[
gain].size(); ++
i) {
653 else if (febSet < 2*m_rampCache.size()/3) {
655 i0 = m_rampCache.size()/3 + 1;
656 iend = 2*m_rampCache.size()/3;
658 for (
unsigned int i = 0;
i < ids2[
gain].size(); ++
i) {
666 i0 = 2*m_rampCache.size()/3 + 1;
667 iend = m_rampCache.size();
669 for (
unsigned int i = 0;
i < ids3[
gain].size(); ++
i) {
678 for (
unsigned int i = i0;
i < iend; ++
i) {
680 if (
gain != m_rampCache[
i].m_gain)
continue;
685 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) );
688 while(rampIt != rampEnd) {
690 rampId = rampIt.channelId();
694 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
695 m_rampCache[
i].m_gain);
698 << coolChannel <<
" "
699 << m_onlineID->show_to_string(rampId) <<
" "
700 << m_rampCache[
i].m_gain <<
" "
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()) {
726 if (m_applyCorrections) {
727 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
729 m_rampCorrections[
i].m_gain);
730 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
731 m_rampCorrections[
i].m_gain);
734 << coolChannel <<
" "
735 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
736 << m_rampCorrections[
i].m_gain <<
" "
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] <<
" "
755 ATH_MSG_ERROR (
"Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
761 ATH_MSG_DEBUG (
"Apply corrections and compare LArRampMC with corrections " );
765 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
767 m_rampCorrections[
i].m_gain);
768 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
769 m_rampCorrections[
i].m_gain);
772 << coolChannel <<
" "
773 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
774 << m_rampCorrections[
i].m_gain <<
" "
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" );
796 ATH_MSG_DEBUG (
"Undo corrections and compare LArRampMC with corrections " );
800 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
802 m_rampCorrections[
i].m_gain);
803 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
804 m_rampCorrections[
i].m_gain);
807 << coolChannel <<
" "
808 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
809 << m_rampCorrections[
i].m_gain <<
" "
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] <<
" "
827 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
832 ATH_MSG_DEBUG (
"2nd Apply corrections and compare LArRampMC with corrections " );
836 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
838 m_rampCorrections[
i].m_gain);
839 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
840 m_rampCorrections[
i].m_gain);
843 << coolChannel <<
" "
844 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
845 << m_rampCorrections[
i].m_gain <<
" "
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" );
867 ATH_MSG_DEBUG (
"2nd Undo corrections and compare LArRampMC with corrections " );
871 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
873 m_rampCorrections[
i].m_gain);
874 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
875 m_rampCorrections[
i].m_gain);
878 << coolChannel <<
" "
879 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
880 << m_rampCorrections[
i].m_gain <<
" "
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] <<
" "
898 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
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);
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: "
1027 <<
" multchan " << (*chanIt)
1028 <<
" subset " << subset->channel() );
1031 if (!(channelNumbers.insert(subset->channel()).second)) {
1033 <<
" channel " << subset->channel() );
1037 ATH_MSG_DEBUG (
"Channel numbers size " << channelNumbers.size()
1038 <<
" ramps size " << ramps->
chan_size() );
1042 return (StatusCode::FAILURE);
1046 return StatusCode::SUCCESS;
1056 typedef ChanSet::ConstChannelIt ConstChannelIt;
1069 chanSet.insert(
m_rampCorrections[
i].m_channelID.get_identifier32().get_compact(), ramp);
1074 ATH_MSG_ERROR (
"Corrections not the same size as channel set: "
1076 return (StatusCode::FAILURE);
1082 ConstChannelIt
it = chanSet.begin();
1083 ConstChannelIt itEnd = chanSet.end();
1087 for (;
it != itEnd; ++
it, ++
i) {
1093 ATH_MSG_ERROR (
"Correction retrieved with iterator does not match: "
1121 it = chanSet.find(
id);
1126 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
1140 ATH_MSG_ERROR (
"Failing check of channel set - see above" );
1141 return (StatusCode::FAILURE);
1145 return StatusCode::SUCCESS;
1154 typedef CONTAINER::Subset 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);
1172 <<
" Subset size " << subset->subsetSize()
1173 <<
" gain, channel, grouping type " << subset->gain() <<
" "
1174 << MSG::hex << subset->channel() <<
" " << MSG::dec
1175 << subset->groupingType() <<
" "
1178 Subset::ConstSubsetIt
first = subset->subsetBegin();
1179 Subset::ConstSubsetIt last = subset->subsetEnd();
1184 if ((*first).second.size()) {
1189 for (
unsigned int k = 0;
k < 5; ++
k) {
1193 for (
unsigned int j = 0; j < (*first).second[
k].m_vRamp.size(); ++j) {
1228 return StatusCode::SUCCESS;