36 m_testCondObjs(false),
37 m_readCondObjs(false),
38 m_writeCondObjs(false),
39 m_writeCorrections(false),
40 m_applyCorrections(false),
89 return StatusCode::SUCCESS;
98 ATH_MSG_DEBUG (
" retrieve DataHandle<ILArRamp> in execute " );
141 return StatusCode::SUCCESS;
155 return StatusCode::SUCCESS;
175 for (; chanIt != chanEnd; ++chanIt, ++
ichan) {
177 if (
ichan % 1000 != 5)
continue;
196 if (icorr % 10 != 5)
continue;
222 return StatusCode::SUCCESS;
230 if (r1.m_vRamp.size() != r2.m_vRamp.size())
return (
false);
231 for (
unsigned int i = 0;
i < r1.m_vRamp.size(); ++
i) {
232 if (r1.m_vRamp[
i] != r2.m_vRamp[
i])
return (
false);
242 if (r1.m_vRamp.size() != r2.m_vRamp.size())
return (
false);
243 for (
unsigned int i = 0;
i < r1.m_vRamp.size(); ++
i) {
244 if (r1.m_vRamp[
i] != -r2.m_vRamp[
i])
return (
false);
253 if(r1 == r2)
return (
false);
265 static std::atomic<bool>
first =
true;
268 return StatusCode::SUCCESS;
273 typedef CONTAINER::chan_const_iterator chan_const_iterator;
274 typedef CONTAINER::iov_const_iterator iov_const_iterator;
285 ATH_MSG_INFO (
"Retrieved ramps for LArRampsSingleGroup " );
286 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
288 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
289 return( StatusCode::FAILURE);
295 ATH_MSG_INFO (
"Created ramps for LArRampsSingleGroup " );
305 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsSingleGroup") );
319 return StatusCode::FAILURE;
334 ATH_MSG_INFO (
"Retrieved ramps for LArRampsSubDetectorGrouping " );
335 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
337 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
338 return( StatusCode::FAILURE);
353 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsSubDetectorGrouping") );
366 return StatusCode::FAILURE;
381 ATH_MSG_INFO (
"Retrieved ramps for LArRampsFeedThroughGrouping " );
382 ramps =
dynamic_cast<const LArRampMC*
>(iramps);
384 ATH_MSG_ERROR (
"Could not dynamic cast ILArRamp to LArRampMC" );
385 return( StatusCode::FAILURE);
400 ATH_CHECK(
detStore()->record(ramps,
"/LArCalorimeter/LArTests/LArRampsFeedThroughGrouping") );
413 return StatusCode::FAILURE;
424 ATH_MSG_DEBUG (
"Statistics for LArRampsFeedThroughGrouping " );
428 iov_const_iterator iovIt = ramps->
iov_begin();
429 iov_const_iterator iovEnd = ramps->
iov_end ();
431 for (; iovIt != iovEnd; ++iovIt) {
436 chan_const_iterator chIt = ramps->
chan_begin();
437 chan_const_iterator chEnd = ramps->
chan_end ();
438 for (; chIt != chEnd; ++chIt) {
443 for (
unsigned int i = 0;
i < ramps->
nGroups(); ++
i) {
449 for (
unsigned int i = 0;
i < ramps->
nGains(); ++
i) {
461 return StatusCode::SUCCESS;
479 return StatusCode::FAILURE;
485 if (!m_readCondObjs) {
486 if (m_writeCondObjs) {
488 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
490 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
491 << m_rampCache[
i].m_gain <<
" " );
495 ramp.
m_vRamp = m_rampCache[
i].m_vRamp;
497 ramps_rw->
setPdata(m_rampCache[
i].m_channelID,
499 m_rampCache[
i].m_gain);
503 ATH_MSG_DEBUG (
"Finished conditions, now write corrections " );
505 if (m_writeCorrections) {
506 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
509 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
510 << m_rampCorrections[
i].m_gain <<
" " );
514 ramp.
m_vRamp = m_rampCorrections[
i].m_vRamp;
518 m_rampCorrections[
i].m_gain) );
526 CONTAINER::chan_const_iterator chanIt1 = ramps->
chan_begin();
527 CONTAINER::chan_const_iterator endChan1 = ramps->
chan_end ();
528 for (
unsigned int i = 0; chanIt1 != endChan1; ++chanIt1, ++
i) {
529 const CONTAINER::Subset* subset = ramps->at(
i);
531 <<
" channel " << subset->channel()
532 <<
" gain " << subset->gain()
533 <<
" groupingType " << subset->groupingType()
534 <<
" subsetSize " << subset->subsetSize()
535 <<
" correctionVecSize " << subset->correctionVecSize() );
536 if ((*chanIt1) != subset->channel()) {
537 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
539 <<
" multchan " << (*chanIt1)
540 <<
" subset " << subset->channel() );
548 << ramps->size() <<
" " );
552 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
555 m_rampCache[
i].m_gain);
556 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
557 m_rampCache[
i].m_gain);
561 << coolChannel <<
" "
562 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
563 << m_rampCache[
i].m_gain <<
" "
572 << coolChannel <<
" "
573 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
574 << m_rampCache[
i].m_gain <<
" "
575 << m_rampCache[
i].m_vRamp[0] <<
" "
576 << m_rampCache[
i].m_vRamp[1] <<
" "
577 << m_rampCache[
i].m_vRamp[2] <<
" "
578 <<
" Compare = " << (rampP == m_rampCache[
i]) );
579 if (rampP != m_rampCache[
i] && !rampP.
isEmpty()) {
587 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator " );
588 CONTAINER::ConstConditionsMapIterator rampIt;
589 CONTAINER::ConstConditionsMapIterator rampEnd;
593 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
595 if (
gain != m_rampCache[
i].m_gain)
continue;
598 while(rampIt != rampEnd) {
600 rampId = rampIt.channelId();
604 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
605 m_rampCache[
i].m_gain);
608 << coolChannel <<
" "
609 << m_onlineID->show_to_string(rampId) <<
" "
610 << m_rampCache[
i].m_gain <<
" "
619 << coolChannel <<
" "
620 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
621 << m_rampCache[
i].m_gain <<
" "
622 << m_rampCache[
i].m_vRamp[0] <<
" "
623 << m_rampCache[
i].m_vRamp[1] <<
" "
624 << m_rampCache[
i].m_vRamp[2] <<
" "
625 <<
" Compare = " << (rampP == m_rampCache[
i]) );
626 if (rampP != m_rampCache[
i] && !rampP.
isEmpty()) {
637 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator and febid selection " );
640 std::vector<unsigned int> ids1[3];
641 std::vector<unsigned int> ids2[3];
642 std::vector<unsigned int> ids3[3];
643 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
644 if (
i < m_rampCache.size()/3) {
645 unsigned int id = m_onlineID->feb_Id(m_rampCache[
i].m_channelID).get_identifier32().get_compact();
646 ids1[m_rampCache[
i].m_gain].push_back(
id);
648 else if (
i < 2*m_rampCache.size()/3) {
649 unsigned int id = m_onlineID->feb_Id(m_rampCache[
i].m_channelID).get_identifier32().get_compact();
650 ids2[m_rampCache[
i].m_gain].push_back(
id);
653 unsigned int id = m_onlineID->feb_Id(m_rampCache[
i].m_channelID).get_identifier32().get_compact();
654 ids3[m_rampCache[
i].m_gain].push_back(
id);
659 for (
unsigned int febSet = 0; febSet < 3; ++febSet) {
661 unsigned int iend = m_rampCache.size()/3;
662 if (febSet < m_rampCache.size()/3) {
665 for (
unsigned int i = 0;
i < ids1[
gain].size(); ++
i) {
671 else if (febSet < 2*m_rampCache.size()/3) {
673 i0 = m_rampCache.size()/3 + 1;
674 iend = 2*m_rampCache.size()/3;
676 for (
unsigned int i = 0;
i < ids2[
gain].size(); ++
i) {
684 i0 = 2*m_rampCache.size()/3 + 1;
685 iend = m_rampCache.size();
687 for (
unsigned int i = 0;
i < ids3[
gain].size(); ++
i) {
696 for (
unsigned int i = i0;
i < iend; ++
i) {
698 if (
gain != m_rampCache[
i].m_gain)
continue;
703 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) );
706 while(rampIt != rampEnd) {
708 rampId = rampIt.channelId();
712 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[
i].m_channelID,
713 m_rampCache[
i].m_gain);
716 << coolChannel <<
" "
717 << m_onlineID->show_to_string(rampId) <<
" "
718 << m_rampCache[
i].m_gain <<
" "
727 << coolChannel <<
" "
728 << m_onlineID->show_to_string(m_rampCache[
i].m_channelID) <<
" "
729 << m_rampCache[
i].m_gain <<
" "
730 << m_rampCache[
i].m_vRamp[0] <<
" "
731 << m_rampCache[
i].m_vRamp[1] <<
" "
732 << m_rampCache[
i].m_vRamp[2] <<
" "
733 <<
" Compare = " << (rampP == m_rampCache[
i]) );
734 if (rampP != m_rampCache[
i] && !rampP.
isEmpty()) {
744 if (m_applyCorrections) {
745 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
747 m_rampCorrections[
i].m_gain);
748 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
749 m_rampCorrections[
i].m_gain);
752 << coolChannel <<
" "
753 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
754 << m_rampCorrections[
i].m_gain <<
" "
763 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
764 << coolChannel <<
" "
765 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
766 << m_rampCorrections[
i].m_gain <<
" "
767 << m_rampCorrections[
i].m_vRamp[0] <<
" "
768 << m_rampCorrections[
i].m_vRamp[1] <<
" "
769 << m_rampCorrections[
i].m_vRamp[2] <<
" "
773 ATH_MSG_ERROR (
"Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
779 ATH_MSG_DEBUG (
"Apply corrections and compare LArRampMC with corrections " );
783 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
785 m_rampCorrections[
i].m_gain);
786 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
787 m_rampCorrections[
i].m_gain);
790 << coolChannel <<
" "
791 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
792 << m_rampCorrections[
i].m_gain <<
" "
800 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
801 << coolChannel <<
" "
802 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
803 << m_rampCorrections[
i].m_gain <<
" "
804 << m_rampCorrections[
i].m_vRamp[0] <<
" "
805 << m_rampCorrections[
i].m_vRamp[1] <<
" "
806 << m_rampCorrections[
i].m_vRamp[2] <<
" "
807 <<
" Compare = " << (rampP == m_rampCorrections[
i]) );
808 if (rampP != m_rampCorrections[
i] && !rampP.
isEmpty()) {
809 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
814 ATH_MSG_DEBUG (
"Undo corrections and compare LArRampMC with corrections " );
818 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
820 m_rampCorrections[
i].m_gain);
821 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
822 m_rampCorrections[
i].m_gain);
825 << coolChannel <<
" "
826 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
827 << m_rampCorrections[
i].m_gain <<
" "
835 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
836 << coolChannel <<
" "
837 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
838 << m_rampCorrections[
i].m_gain <<
" "
839 << m_rampCorrections[
i].m_vRamp[0] <<
" "
840 << m_rampCorrections[
i].m_vRamp[1] <<
" "
841 << m_rampCorrections[
i].m_vRamp[2] <<
" "
845 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
850 ATH_MSG_DEBUG (
"2nd Apply corrections and compare LArRampMC with corrections " );
854 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
856 m_rampCorrections[
i].m_gain);
857 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
858 m_rampCorrections[
i].m_gain);
861 << coolChannel <<
" "
862 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
863 << m_rampCorrections[
i].m_gain <<
" "
871 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
872 << coolChannel <<
" "
873 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
874 << m_rampCorrections[
i].m_gain <<
" "
875 << m_rampCorrections[
i].m_vRamp[0] <<
" "
876 << m_rampCorrections[
i].m_vRamp[1] <<
" "
877 << m_rampCorrections[
i].m_vRamp[2] <<
" "
878 <<
" Compare = " << (rampP == m_rampCorrections[
i]) );
879 if (rampP != m_rampCorrections[
i] && !rampP.
isEmpty()) {
880 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
885 ATH_MSG_DEBUG (
"2nd Undo corrections and compare LArRampMC with corrections " );
889 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
891 m_rampCorrections[
i].m_gain);
892 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[
i].m_channelID,
893 m_rampCorrections[
i].m_gain);
896 << coolChannel <<
" "
897 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
898 << m_rampCorrections[
i].m_gain <<
" "
906 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
907 << coolChannel <<
" "
908 << m_onlineID->show_to_string(m_rampCorrections[
i].m_channelID) <<
" "
909 << m_rampCorrections[
i].m_gain <<
" "
910 << m_rampCorrections[
i].m_vRamp[0] <<
" "
911 << m_rampCorrections[
i].m_vRamp[1] <<
" "
912 << m_rampCorrections[
i].m_vRamp[2] <<
" "
916 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
1031 std::set<unsigned int> channelNumbers;
1032 CONTAINER::chan_const_iterator chanIt = ramps->
chan_begin();
1033 CONTAINER::chan_const_iterator endChan = ramps->
chan_end ();
1034 for (
unsigned int i = 0; chanIt != endChan; ++chanIt, ++
i) {
1035 const CONTAINER::Subset* subset = ramps->at(
i);
1037 <<
" channel " << subset->channel()
1038 <<
" gain " << subset->gain()
1039 <<
" groupingType " << subset->groupingType()
1040 <<
" subsetSize " << subset->subsetSize()
1041 <<
" correctionVecSize " << subset->correctionVecSize() );
1042 if ((*chanIt) != subset->channel()) {
1043 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
1045 <<
" multchan " << (*chanIt)
1046 <<
" subset " << subset->channel() );
1049 if (!(channelNumbers.insert(subset->channel()).second)) {
1051 <<
" channel " << subset->channel() );
1055 ATH_MSG_DEBUG (
"Channel numbers size " << channelNumbers.size()
1056 <<
" ramps size " << ramps->
chan_size() );
1060 return (StatusCode::FAILURE);
1064 return StatusCode::SUCCESS;
1074 typedef ChanSet::ConstChannelIt ConstChannelIt;
1087 chanSet.insert(
m_rampCorrections[
i].m_channelID.get_identifier32().get_compact(), ramp);
1092 ATH_MSG_ERROR (
"Corrections not the same size as channel set: "
1094 return (StatusCode::FAILURE);
1100 ConstChannelIt
it = chanSet.begin();
1101 ConstChannelIt itEnd = chanSet.end();
1105 for (;
it != itEnd; ++
it, ++
i) {
1111 ATH_MSG_ERROR (
"Correction retrieved with iterator does not match: "
1139 it = chanSet.find(
id);
1144 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
1158 ATH_MSG_ERROR (
"Failing check of channel set - see above" );
1159 return (StatusCode::FAILURE);
1163 return StatusCode::SUCCESS;
1173 return StatusCode::SUCCESS;
1182 return StatusCode::SUCCESS;
1191 return StatusCode::SUCCESS;
1209 return StatusCode::SUCCESS;
1218 return StatusCode::SUCCESS;
1223 IToolSvc* toolSvc =
nullptr;
1224 ATH_CHECK( service(
"ToolSvc", toolSvc) );
1272 return StatusCode::SUCCESS;
1282 typedef CONTAINER::Subset Subset;
1293 CONTAINER::chan_const_iterator chanIt = ramp->
chan_begin();
1294 CONTAINER::chan_const_iterator endChan = ramp->
chan_end ();
1295 for (
unsigned int i = 0; chanIt != endChan; ++chanIt, ++
i) {
1296 unsigned int coolChan = *chanIt;
1297 const Subset* subset = ramp->at(
i);
1300 <<
" Subset size " << subset->subsetSize()
1301 <<
" gain, channel, grouping type " << subset->gain() <<
" "
1302 << MSG::hex << subset->channel() <<
" " << MSG::dec
1303 << subset->groupingType() <<
" "
1306 Subset::ConstSubsetIt
first = subset->subsetBegin();
1307 Subset::ConstSubsetIt last = subset->subsetEnd();
1312 if ((*first).second.size()) {
1317 for (
unsigned int k = 0;
k < 5; ++
k) {
1321 for (
unsigned int j = 0; j < (*first).second[
k].m_vRamp.size(); ++j) {
1356 return StatusCode::SUCCESS;
1410 return StatusCode::SUCCESS;