432{
435
437
438
439
441 if (!ramps_rw) {
443 return StatusCode::FAILURE;
444 }
445
448
449 if (!m_readCondObjs) {
450 if (m_writeCondObjs) {
451
452 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
453 ATH_MSG_DEBUG (
"setPdata for chan, chan id, gain " << i <<
" "
454 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
455 << m_rampCache[i].m_gain << " " );
456
457
459 ramp.
m_vRamp = m_rampCache[
i].m_vRamp;
460
461 ramps_rw->
setPdata(m_rampCache[i].m_channelID,
462 ramp,
463 m_rampCache[i].m_gain);
464 }
465 }
466
467 ATH_MSG_DEBUG (
"Finished conditions, now write corrections " );
468
469 if (m_writeCorrections) {
470 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
471
472 ATH_MSG_DEBUG (
"insert corr for chan, chan id, gain " << i <<
" "
473 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
474 << m_rampCorrections[i].m_gain << " " );
475
476
478 ramp.
m_vRamp = m_rampCorrections[
i].m_vRamp;
479
481 ramp,
482 m_rampCorrections[i].m_gain) );
483 }
484 }
485 }
486
489
490 CONTAINER::chan_const_iterator chanIt1 = ramps->
chan_begin();
491 CONTAINER::chan_const_iterator endChan1 = ramps->
chan_end ();
492 for (
unsigned int i = 0; chanIt1 != endChan1; ++chanIt1, ++
i) {
493 const CONTAINER::Subset* subset = ramps->
at(i);
495 << " channel " << subset->channel()
496 << " gain " << subset->gain()
497 << " groupingType " << subset->groupingType()
498 << " subsetSize " << subset->subsetSize()
499 << " correctionVecSize " << subset->correctionVecSize() );
500 if ((*chanIt1) != subset->channel()) {
501 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
502 << i
503 << " multchan " << (*chanIt1)
504 << " subset " << subset->channel() );
506 }
507 }
508
512 << ramps->
size() <<
" " );
513
515
516 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
517
519 m_rampCache[i].m_gain);
520 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
521 m_rampCache[i].m_gain);
522
525 << coolChannel << " "
526 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
527 << m_rampCache[i].m_gain << " "
531 }
532 else {
534 }
536 << coolChannel << " "
537 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
538 << m_rampCache[i].m_gain << " "
539 << m_rampCache[i].m_vRamp[0] << " "
540 << m_rampCache[i].m_vRamp[1] << " "
541 << m_rampCache[i].m_vRamp[2] << " "
542 << " Compare = " << (rampP == m_rampCache[i]) );
543 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
546 }
547 }
548
549
550
551 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator " );
552 CONTAINER::ConstConditionsMapIterator rampIt;
553 CONTAINER::ConstConditionsMapIterator rampEnd;
554 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
555 rampIt = ramps->
begin(gain);
556 rampEnd = ramps->
end (gain);
557 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
558
559 if (gain != m_rampCache[i].m_gain) continue;
562 while(rampIt != rampEnd) {
563 rampP = *rampIt;
564 rampId = rampIt.channelId();
565 ++rampIt;
567 }
568 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
569 m_rampCache[i].m_gain);
572 << coolChannel << " "
573 << m_onlineID->show_to_string(rampId) << " "
574 << m_rampCache[i].m_gain << " "
578 }
579 else {
581 }
583 << coolChannel << " "
584 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
585 << m_rampCache[i].m_gain << " "
586 << m_rampCache[i].m_vRamp[0] << " "
587 << m_rampCache[i].m_vRamp[1] << " "
588 << m_rampCache[i].m_vRamp[2] << " "
589 << " Compare = " << (rampP == m_rampCache[i]) );
590 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
593 }
594 }
595 }
596
597
598
599
600
601 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator and febid selection " );
602
603
604 std::vector<unsigned int> ids1[3];
605 std::vector<unsigned int> ids2[3];
606 std::vector<unsigned int> ids3[3];
607 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
608 if (i < m_rampCache.size()/3) {
609 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
610 ids1[m_rampCache[
i].m_gain].push_back(
id);
611 }
612 else if (i < 2*m_rampCache.size()/3) {
613 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
614 ids2[m_rampCache[
i].m_gain].push_back(
id);
615 }
616 else {
617 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
618 ids3[m_rampCache[
i].m_gain].push_back(
id);
619 }
620 }
621
622 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
623 for (unsigned int febSet = 0; febSet < 3; ++febSet) {
624 unsigned int i0 = 0;
625 unsigned int iend = m_rampCache.size()/3;
626 if (febSet < m_rampCache.size()/3) {
627 rampIt = ramps->
begin(gain, ids1[gain]);
628 msg() << MSG::DEBUG <<
"FebID vec 1 : ";
629 for (
unsigned int i = 0;
i < ids1[
gain].size(); ++
i) {
630 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids1[gain][i]))
631 << " ";
632 }
634 }
635 else if (febSet < 2*m_rampCache.size()/3) {
636 rampIt = ramps->
begin(gain, ids2[gain]);
637 i0 = m_rampCache.size()/3 + 1;
638 iend = 2*m_rampCache.size()/3;
639 msg() << MSG::DEBUG <<
"FebID vec 2 : ";
640 for (
unsigned int i = 0;
i < ids2[
gain].size(); ++
i) {
641 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids2[gain][i]))
642 << " ";
643 }
645 }
646 else {
647 rampIt = ramps->
begin(gain, ids3[gain]);
648 i0 = 2*m_rampCache.size()/3 + 1;
649 iend = m_rampCache.size();
650 msg() << MSG::DEBUG <<
"FebID vec 3 : ";
651 for (
unsigned int i = 0;
i < ids3[
gain].size(); ++
i) {
652 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids3[gain][i]))
653 << " ";
654 }
656 }
657
658 rampEnd = ramps->
end (gain);
660 for (
unsigned int i = i0;
i < iend; ++
i) {
661
662 if (gain != m_rampCache[i].m_gain) continue;
665
667 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) );
668
669
670 while(rampIt != rampEnd) {
671 rampP = *rampIt;
672 rampId = rampIt.channelId();
673 ++rampIt;
675 }
676 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
677 m_rampCache[i].m_gain);
680 << coolChannel << " "
681 << m_onlineID->show_to_string(rampId) << " "
682 << m_rampCache[i].m_gain << " "
686 }
687 else {
689 }
691 << coolChannel << " "
692 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
693 << m_rampCache[i].m_gain << " "
694 << m_rampCache[i].m_vRamp[0] << " "
695 << m_rampCache[i].m_vRamp[1] << " "
696 << m_rampCache[i].m_vRamp[2] << " "
697 << " Compare = " << (rampP == m_rampCache[i]) );
698 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
701 }
702 }
703 }
704 }
705
707
708 if (m_applyCorrections) {
709 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
711 m_rampCorrections[i].m_gain);
712 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
713 m_rampCorrections[i].m_gain);
716 << coolChannel << " "
717 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
718 << m_rampCorrections[i].m_gain << " "
722 }
723 else {
725 }
726
727 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
728 << coolChannel << " "
729 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
730 << m_rampCorrections[i].m_gain << " "
731 << m_rampCorrections[i].m_vRamp[0] << " "
732 << m_rampCorrections[i].m_vRamp[1] << " "
733 << m_rampCorrections[i].m_vRamp[2] << " "
736
737 ATH_MSG_ERROR (
"Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
739 }
740 }
741
742
743 ATH_MSG_DEBUG (
"Apply corrections and compare LArRampMC with corrections " );
746
747 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
749 m_rampCorrections[i].m_gain);
750 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
751 m_rampCorrections[i].m_gain);
754 << coolChannel << " "
755 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
756 << m_rampCorrections[i].m_gain << " "
760 }
761 else {
763 }
764 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
765 << coolChannel << " "
766 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
767 << m_rampCorrections[i].m_gain << " "
768 << m_rampCorrections[i].m_vRamp[0] << " "
769 << m_rampCorrections[i].m_vRamp[1] << " "
770 << m_rampCorrections[i].m_vRamp[2] << " "
771 << " Compare = " << (rampP == m_rampCorrections[i]) );
772 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
773 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
775 }
776 }
777
778 ATH_MSG_DEBUG (
"Undo corrections and compare LArRampMC with corrections " );
781
782 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
784 m_rampCorrections[i].m_gain);
785 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
786 m_rampCorrections[i].m_gain);
789 << coolChannel << " "
790 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
791 << m_rampCorrections[i].m_gain << " "
795 }
796 else {
798 }
799 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
800 << coolChannel << " "
801 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
802 << m_rampCorrections[i].m_gain << " "
803 << m_rampCorrections[i].m_vRamp[0] << " "
804 << m_rampCorrections[i].m_vRamp[1] << " "
805 << m_rampCorrections[i].m_vRamp[2] << " "
808
809 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
811 }
812 }
813
814 ATH_MSG_DEBUG (
"2nd Apply corrections and compare LArRampMC with corrections " );
817
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 << " "
831 }
832 else {
834 }
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] << " "
842 << " Compare = " << (rampP == m_rampCorrections[i]) );
843 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
844 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
846 }
847 }
848
849 ATH_MSG_DEBUG (
"2nd Undo corrections and compare LArRampMC with corrections " );
852
853 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
855 m_rampCorrections[i].m_gain);
856 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
857 m_rampCorrections[i].m_gain);
860 << coolChannel << " "
861 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
862 << m_rampCorrections[i].m_gain << " "
866 }
867 else {
869 }
870 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
871 << coolChannel << " "
872 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
873 << m_rampCorrections[i].m_gain << " "
874 << m_rampCorrections[i].m_vRamp[0] << " "
875 << m_rampCorrections[i].m_vRamp[1] << " "
876 << m_rampCorrections[i].m_vRamp[2] << " "
879
880 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
882 }
883 }
884 }
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
994
995 std::set<unsigned int> channelNumbers;
996 CONTAINER::chan_const_iterator chanIt = ramps->
chan_begin();
997 CONTAINER::chan_const_iterator endChan = ramps->
chan_end ();
998 for (
unsigned int i = 0; chanIt != endChan; ++chanIt, ++
i) {
999 const CONTAINER::Subset* subset = ramps->
at(i);
1001 << " channel " << subset->channel()
1002 << " gain " << subset->gain()
1003 << " groupingType " << subset->groupingType()
1004 << " subsetSize " << subset->subsetSize()
1005 << " correctionVecSize " << subset->correctionVecSize() );
1006 if ((*chanIt) != subset->channel()) {
1007 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
1008 << i
1009 << " multchan " << (*chanIt)
1010 << " subset " << subset->channel() );
1012 }
1013 if (!(channelNumbers.insert(subset->channel()).second)) {
1015 << " channel " << subset->channel() );
1017 }
1018 }
1019 ATH_MSG_DEBUG (
"Channel numbers size " << channelNumbers.size()
1020 <<
" ramps size " << ramps->
chan_size() );
1021
1024 return (StatusCode::FAILURE);
1025 }
1026
1028 return StatusCode::SUCCESS;
1029}
#define ATH_CHECK
Evaluate an expression and check for errors.
bool CorrectionCompare(const LArRampComplete::LArCondObj &r1, const LArRampPTmp &r2)
const T * at(size_type n) const
size_type size() const noexcept
StatusCode insertCorrection(HWIdentifier id, const T &cond, unsigned int gain, bool corrChannel=true)
access to corrections -
bool correctionsApplied() const
Have corrections been applied?
void setPdata(const HWIdentifier id, const T &payload, unsigned int gain=0)
put payload in persistent data
unsigned int coolChannel(const HWIdentifier id, unsigned int gain=0) const
Return the COOL channel number for a given online id and gain.
StatusCode applyCorrections()
apply correction set
StatusCode undoCorrections()
undo corrections that have been already applied
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators - from MultChanCollection.
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
chan_size_type chan_size() const
number of channels - from MultChanCollection
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
iov_size_type iov_size() const
number of IOVs - from MultChanCollection
chan_const_iterator chan_end() const
Implementation of the interface ILArRamp for MC Derives from LArRampComplete, and implements the phi-...
LArRampComplete::CONTAINER CONTAINER
std::vector< float > m_vRamp