414{
417
419
420
421
423 if (!ramps_rw) {
425 return StatusCode::FAILURE;
426 }
427
430
431 if (!m_readCondObjs) {
432 if (m_writeCondObjs) {
433
434 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
435 ATH_MSG_DEBUG (
"setPdata for chan, chan id, gain " << i <<
" "
436 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
437 << m_rampCache[i].m_gain << " " );
438
439
441 ramp.
m_vRamp = m_rampCache[
i].m_vRamp;
442
443 ramps_rw->
setPdata(m_rampCache[i].m_channelID,
444 ramp,
445 m_rampCache[i].m_gain);
446 }
447 }
448
449 ATH_MSG_DEBUG (
"Finished conditions, now write corrections " );
450
451 if (m_writeCorrections) {
452 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
453
454 ATH_MSG_DEBUG (
"insert corr for chan, chan id, gain " << i <<
" "
455 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
456 << m_rampCorrections[i].m_gain << " " );
457
458
460 ramp.
m_vRamp = m_rampCorrections[
i].m_vRamp;
461
463 ramp,
464 m_rampCorrections[i].m_gain) );
465 }
466 }
467 }
468
471
472 CONTAINER::chan_const_iterator chanIt1 = ramps->
chan_begin();
473 CONTAINER::chan_const_iterator endChan1 = ramps->
chan_end ();
474 for (
unsigned int i = 0; chanIt1 != endChan1; ++chanIt1, ++
i) {
475 const CONTAINER::Subset* subset = ramps->
at(i);
477 << " channel " << subset->channel()
478 << " gain " << subset->gain()
479 << " groupingType " << subset->groupingType()
480 << " subsetSize " << subset->subsetSize()
481 << " correctionVecSize " << subset->correctionVecSize() );
482 if ((*chanIt1) != subset->channel()) {
483 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
484 << i
485 << " multchan " << (*chanIt1)
486 << " subset " << subset->channel() );
488 }
489 }
490
494 << ramps->
size() <<
" " );
495
497
498 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
499
501 m_rampCache[i].m_gain);
502 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
503 m_rampCache[i].m_gain);
504
507 << coolChannel << " "
508 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
509 << m_rampCache[i].m_gain << " "
513 }
514 else {
516 }
518 << coolChannel << " "
519 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
520 << m_rampCache[i].m_gain << " "
521 << m_rampCache[i].m_vRamp[0] << " "
522 << m_rampCache[i].m_vRamp[1] << " "
523 << m_rampCache[i].m_vRamp[2] << " "
524 << " Compare = " << (rampP == m_rampCache[i]) );
525 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
528 }
529 }
530
531
532
533 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator " );
534 CONTAINER::ConstConditionsMapIterator rampIt;
535 CONTAINER::ConstConditionsMapIterator rampEnd;
536 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
537 rampIt = ramps->
begin(gain);
538 rampEnd = ramps->
end (gain);
539 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
540
541 if (gain != m_rampCache[i].m_gain) continue;
544 while(rampIt != rampEnd) {
545 rampP = *rampIt;
546 rampId = rampIt.channelId();
547 ++rampIt;
549 }
550 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
551 m_rampCache[i].m_gain);
554 << coolChannel << " "
555 << m_onlineID->show_to_string(rampId) << " "
556 << m_rampCache[i].m_gain << " "
560 }
561 else {
563 }
565 << coolChannel << " "
566 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
567 << m_rampCache[i].m_gain << " "
568 << m_rampCache[i].m_vRamp[0] << " "
569 << m_rampCache[i].m_vRamp[1] << " "
570 << m_rampCache[i].m_vRamp[2] << " "
571 << " Compare = " << (rampP == m_rampCache[i]) );
572 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
575 }
576 }
577 }
578
579
580
581
582
583 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator and febid selection " );
584
585
586 std::vector<unsigned int> ids1[3];
587 std::vector<unsigned int> ids2[3];
588 std::vector<unsigned int> ids3[3];
589 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
590 if (i < m_rampCache.size()/3) {
591 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
592 ids1[m_rampCache[
i].m_gain].push_back(
id);
593 }
594 else if (i < 2*m_rampCache.size()/3) {
595 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
596 ids2[m_rampCache[
i].m_gain].push_back(
id);
597 }
598 else {
599 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
600 ids3[m_rampCache[
i].m_gain].push_back(
id);
601 }
602 }
603
604 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
605 for (unsigned int febSet = 0; febSet < 3; ++febSet) {
606 unsigned int i0 = 0;
607 unsigned int iend = m_rampCache.size()/3;
608 if (febSet < m_rampCache.size()/3) {
609 rampIt = ramps->
begin(gain, ids1[gain]);
610 msg() << MSG::DEBUG <<
"FebID vec 1 : ";
611 for (
unsigned int i = 0;
i < ids1[
gain].size(); ++
i) {
612 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids1[gain][i]))
613 << " ";
614 }
616 }
617 else if (febSet < 2*m_rampCache.size()/3) {
618 rampIt = ramps->
begin(gain, ids2[gain]);
619 i0 = m_rampCache.size()/3 + 1;
620 iend = 2*m_rampCache.size()/3;
621 msg() << MSG::DEBUG <<
"FebID vec 2 : ";
622 for (
unsigned int i = 0;
i < ids2[
gain].size(); ++
i) {
623 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids2[gain][i]))
624 << " ";
625 }
627 }
628 else {
629 rampIt = ramps->
begin(gain, ids3[gain]);
630 i0 = 2*m_rampCache.size()/3 + 1;
631 iend = m_rampCache.size();
632 msg() << MSG::DEBUG <<
"FebID vec 3 : ";
633 for (
unsigned int i = 0;
i < ids3[
gain].size(); ++
i) {
634 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids3[gain][i]))
635 << " ";
636 }
638 }
639
640 rampEnd = ramps->
end (gain);
642 for (
unsigned int i = i0;
i < iend; ++
i) {
643
644 if (gain != m_rampCache[i].m_gain) continue;
647
649 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) );
650
651
652 while(rampIt != rampEnd) {
653 rampP = *rampIt;
654 rampId = rampIt.channelId();
655 ++rampIt;
657 }
658 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
659 m_rampCache[i].m_gain);
662 << coolChannel << " "
663 << m_onlineID->show_to_string(rampId) << " "
664 << m_rampCache[i].m_gain << " "
668 }
669 else {
671 }
673 << coolChannel << " "
674 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
675 << m_rampCache[i].m_gain << " "
676 << m_rampCache[i].m_vRamp[0] << " "
677 << m_rampCache[i].m_vRamp[1] << " "
678 << m_rampCache[i].m_vRamp[2] << " "
679 << " Compare = " << (rampP == m_rampCache[i]) );
680 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
683 }
684 }
685 }
686 }
687
689
690 if (m_applyCorrections) {
691 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
693 m_rampCorrections[i].m_gain);
694 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
695 m_rampCorrections[i].m_gain);
698 << coolChannel << " "
699 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
700 << m_rampCorrections[i].m_gain << " "
704 }
705 else {
707 }
708
709 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
710 << coolChannel << " "
711 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
712 << m_rampCorrections[i].m_gain << " "
713 << m_rampCorrections[i].m_vRamp[0] << " "
714 << m_rampCorrections[i].m_vRamp[1] << " "
715 << m_rampCorrections[i].m_vRamp[2] << " "
718
719 ATH_MSG_ERROR (
"Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
721 }
722 }
723
724
725 ATH_MSG_DEBUG (
"Apply corrections and compare LArRampMC with corrections " );
728
729 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
731 m_rampCorrections[i].m_gain);
732 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
733 m_rampCorrections[i].m_gain);
736 << coolChannel << " "
737 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
738 << m_rampCorrections[i].m_gain << " "
742 }
743 else {
745 }
746 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
747 << coolChannel << " "
748 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
749 << m_rampCorrections[i].m_gain << " "
750 << m_rampCorrections[i].m_vRamp[0] << " "
751 << m_rampCorrections[i].m_vRamp[1] << " "
752 << m_rampCorrections[i].m_vRamp[2] << " "
753 << " Compare = " << (rampP == m_rampCorrections[i]) );
754 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
755 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
757 }
758 }
759
760 ATH_MSG_DEBUG (
"Undo corrections and compare LArRampMC with corrections " );
763
764 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
766 m_rampCorrections[i].m_gain);
767 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
768 m_rampCorrections[i].m_gain);
771 << coolChannel << " "
772 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
773 << m_rampCorrections[i].m_gain << " "
777 }
778 else {
780 }
781 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
782 << coolChannel << " "
783 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
784 << m_rampCorrections[i].m_gain << " "
785 << m_rampCorrections[i].m_vRamp[0] << " "
786 << m_rampCorrections[i].m_vRamp[1] << " "
787 << m_rampCorrections[i].m_vRamp[2] << " "
790
791 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
793 }
794 }
795
796 ATH_MSG_DEBUG (
"2nd Apply corrections and compare LArRampMC with corrections " );
799
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 << " "
813 }
814 else {
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 = " << (rampP == m_rampCorrections[i]) );
825 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
826 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
828 }
829 }
830
831 ATH_MSG_DEBUG (
"2nd Undo corrections and compare LArRampMC with corrections " );
834
835 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
837 m_rampCorrections[i].m_gain);
838 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
839 m_rampCorrections[i].m_gain);
842 << coolChannel << " "
843 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
844 << m_rampCorrections[i].m_gain << " "
848 }
849 else {
851 }
852 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
853 << coolChannel << " "
854 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
855 << m_rampCorrections[i].m_gain << " "
856 << m_rampCorrections[i].m_vRamp[0] << " "
857 << m_rampCorrections[i].m_vRamp[1] << " "
858 << m_rampCorrections[i].m_vRamp[2] << " "
861
862 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
864 }
865 }
866 }
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
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
976
977 std::set<unsigned int> channelNumbers;
978 CONTAINER::chan_const_iterator chanIt = ramps->
chan_begin();
979 CONTAINER::chan_const_iterator endChan = ramps->
chan_end ();
980 for (
unsigned int i = 0; chanIt != endChan; ++chanIt, ++
i) {
981 const CONTAINER::Subset* subset = ramps->
at(i);
983 << " channel " << subset->channel()
984 << " gain " << subset->gain()
985 << " groupingType " << subset->groupingType()
986 << " subsetSize " << subset->subsetSize()
987 << " correctionVecSize " << subset->correctionVecSize() );
988 if ((*chanIt) != subset->channel()) {
989 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
990 << i
991 << " multchan " << (*chanIt)
992 << " subset " << subset->channel() );
994 }
995 if (!(channelNumbers.insert(subset->channel()).second)) {
997 << " channel " << subset->channel() );
999 }
1000 }
1001 ATH_MSG_DEBUG (
"Channel numbers size " << channelNumbers.size()
1002 <<
" ramps size " << ramps->
chan_size() );
1003
1006 return (StatusCode::FAILURE);
1007 }
1008
1010 return StatusCode::SUCCESS;
1011}
#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