408{
411
413
414
415
417 if (!ramps_rw) {
419 return StatusCode::FAILURE;
420 }
421
424
425 if (!m_readCondObjs) {
426 if (m_writeCondObjs) {
427
428 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
429 ATH_MSG_DEBUG (
"setPdata for chan, chan id, gain " << i <<
" "
430 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
431 << m_rampCache[i].m_gain << " " );
432
433
435 ramp.
m_vRamp = m_rampCache[
i].m_vRamp;
436
437 ramps_rw->
setPdata(m_rampCache[i].m_channelID,
438 ramp,
439 m_rampCache[i].m_gain);
440 }
441 }
442
443 ATH_MSG_DEBUG (
"Finished conditions, now write corrections " );
444
445 if (m_writeCorrections) {
446 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
447
448 ATH_MSG_DEBUG (
"insert corr for chan, chan id, gain " << i <<
" "
449 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
450 << m_rampCorrections[i].m_gain << " " );
451
452
454 ramp.
m_vRamp = m_rampCorrections[
i].m_vRamp;
455
457 ramp,
458 m_rampCorrections[i].m_gain) );
459 }
460 }
461 }
462
465
466 CONTAINER::chan_const_iterator chanIt1 = ramps->
chan_begin();
467 CONTAINER::chan_const_iterator endChan1 = ramps->
chan_end ();
468 for (
unsigned int i = 0; chanIt1 != endChan1; ++chanIt1, ++
i) {
469 const CONTAINER::Subset* subset = ramps->
at(i);
471 << " channel " << subset->channel()
472 << " gain " << subset->gain()
473 << " groupingType " << subset->groupingType()
474 << " subsetSize " << subset->subsetSize()
475 << " correctionVecSize " << subset->correctionVecSize() );
476 if ((*chanIt1) != subset->channel()) {
477 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
478 << i
479 << " multchan " << (*chanIt1)
480 << " subset " << subset->channel() );
482 }
483 }
484
488 << ramps->
size() <<
" " );
489
491
492 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
493
495 m_rampCache[i].m_gain);
496 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
497 m_rampCache[i].m_gain);
498
501 << coolChannel << " "
502 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
503 << m_rampCache[i].m_gain << " "
507 }
508 else {
510 }
512 << coolChannel << " "
513 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
514 << m_rampCache[i].m_gain << " "
515 << m_rampCache[i].m_vRamp[0] << " "
516 << m_rampCache[i].m_vRamp[1] << " "
517 << m_rampCache[i].m_vRamp[2] << " "
518 << " Compare = " << (rampP == m_rampCache[i]) );
519 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
522 }
523 }
524
525
526
527 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator " );
528 CONTAINER::ConstConditionsMapIterator rampIt;
529 CONTAINER::ConstConditionsMapIterator rampEnd;
530 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
531 rampIt = ramps->
begin(gain);
532 rampEnd = ramps->
end (gain);
533 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
534
535 if (gain != m_rampCache[i].m_gain) continue;
538 while(rampIt != rampEnd) {
539 rampP = *rampIt;
540 rampId = rampIt.channelId();
541 ++rampIt;
543 }
544 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
545 m_rampCache[i].m_gain);
548 << coolChannel << " "
549 << m_onlineID->show_to_string(rampId) << " "
550 << m_rampCache[i].m_gain << " "
554 }
555 else {
557 }
559 << coolChannel << " "
560 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
561 << m_rampCache[i].m_gain << " "
562 << m_rampCache[i].m_vRamp[0] << " "
563 << m_rampCache[i].m_vRamp[1] << " "
564 << m_rampCache[i].m_vRamp[2] << " "
565 << " Compare = " << (rampP == m_rampCache[i]) );
566 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
569 }
570 }
571 }
572
573
574
575
576
577 ATH_MSG_DEBUG (
"Compare LArRampMC with cache using iterator and febid selection " );
578
579
580 std::vector<unsigned int> ids1[3];
581 std::vector<unsigned int> ids2[3];
582 std::vector<unsigned int> ids3[3];
583 for (
unsigned int i = 0;
i < m_rampCache.size(); ++
i) {
584 if (i < m_rampCache.size()/3) {
585 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
586 ids1[m_rampCache[
i].m_gain].push_back(
id);
587 }
588 else if (i < 2*m_rampCache.size()/3) {
589 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
590 ids2[m_rampCache[
i].m_gain].push_back(
id);
591 }
592 else {
593 unsigned int id = m_onlineID->feb_Id(m_rampCache[i].m_channelID).get_identifier32().get_compact();
594 ids3[m_rampCache[
i].m_gain].push_back(
id);
595 }
596 }
597
598 for (
unsigned int gain = 0;
gain < 3; ++
gain) {
599 for (unsigned int febSet = 0; febSet < 3; ++febSet) {
600 unsigned int i0 = 0;
601 unsigned int iend = m_rampCache.size()/3;
602 if (febSet < m_rampCache.size()/3) {
603 rampIt = ramps->
begin(gain, ids1[gain]);
604 msg() << MSG::DEBUG <<
"FebID vec 1 : ";
605 for (
unsigned int i = 0;
i < ids1[
gain].size(); ++
i) {
606 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids1[gain][i]))
607 << " ";
608 }
610 }
611 else if (febSet < 2*m_rampCache.size()/3) {
612 rampIt = ramps->
begin(gain, ids2[gain]);
613 i0 = m_rampCache.size()/3 + 1;
614 iend = 2*m_rampCache.size()/3;
615 msg() << MSG::DEBUG <<
"FebID vec 2 : ";
616 for (
unsigned int i = 0;
i < ids2[
gain].size(); ++
i) {
617 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids2[gain][i]))
618 << " ";
619 }
621 }
622 else {
623 rampIt = ramps->
begin(gain, ids3[gain]);
624 i0 = 2*m_rampCache.size()/3 + 1;
625 iend = m_rampCache.size();
626 msg() << MSG::DEBUG <<
"FebID vec 3 : ";
627 for (
unsigned int i = 0;
i < ids3[
gain].size(); ++
i) {
628 msg() << MSG::DEBUG << m_onlineID->show_to_string(
HWIdentifier(ids3[gain][i]))
629 << " ";
630 }
632 }
633
634 rampEnd = ramps->
end (gain);
636 for (
unsigned int i = i0;
i < iend; ++
i) {
637
638 if (gain != m_rampCache[i].m_gain) continue;
641
643 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) );
644
645
646 while(rampIt != rampEnd) {
647 rampP = *rampIt;
648 rampId = rampIt.channelId();
649 ++rampIt;
651 }
652 unsigned int coolChannel = ramps->
coolChannel(m_rampCache[i].m_channelID,
653 m_rampCache[i].m_gain);
656 << coolChannel << " "
657 << m_onlineID->show_to_string(rampId) << " "
658 << m_rampCache[i].m_gain << " "
662 }
663 else {
665 }
667 << coolChannel << " "
668 << m_onlineID->show_to_string(m_rampCache[i].m_channelID) << " "
669 << m_rampCache[i].m_gain << " "
670 << m_rampCache[i].m_vRamp[0] << " "
671 << m_rampCache[i].m_vRamp[1] << " "
672 << m_rampCache[i].m_vRamp[2] << " "
673 << " Compare = " << (rampP == m_rampCache[i]) );
674 if (rampP != m_rampCache[i] && !rampP.
isEmpty()) {
677 }
678 }
679 }
680 }
681
683
684 if (m_applyCorrections) {
685 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
687 m_rampCorrections[i].m_gain);
688 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
689 m_rampCorrections[i].m_gain);
692 << coolChannel << " "
693 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
694 << m_rampCorrections[i].m_gain << " "
698 }
699 else {
701 }
702
703 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
704 << coolChannel << " "
705 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
706 << m_rampCorrections[i].m_gain << " "
707 << m_rampCorrections[i].m_vRamp[0] << " "
708 << m_rampCorrections[i].m_vRamp[1] << " "
709 << m_rampCorrections[i].m_vRamp[2] << " "
712
713 ATH_MSG_ERROR (
"Before correction: LArRampMC and correction DO NOT compare - should have opposite signs for rampes" );
715 }
716 }
717
718
719 ATH_MSG_DEBUG (
"Apply corrections and compare LArRampMC with corrections " );
722
723 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
725 m_rampCorrections[i].m_gain);
726 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
727 m_rampCorrections[i].m_gain);
730 << coolChannel << " "
731 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
732 << m_rampCorrections[i].m_gain << " "
736 }
737 else {
739 }
740 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
741 << coolChannel << " "
742 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
743 << m_rampCorrections[i].m_gain << " "
744 << m_rampCorrections[i].m_vRamp[0] << " "
745 << m_rampCorrections[i].m_vRamp[1] << " "
746 << m_rampCorrections[i].m_vRamp[2] << " "
747 << " Compare = " << (rampP == m_rampCorrections[i]) );
748 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
749 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
751 }
752 }
753
754 ATH_MSG_DEBUG (
"Undo corrections and compare LArRampMC with corrections " );
757
758 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
760 m_rampCorrections[i].m_gain);
761 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
762 m_rampCorrections[i].m_gain);
765 << coolChannel << " "
766 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
767 << m_rampCorrections[i].m_gain << " "
771 }
772 else {
774 }
775 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
776 << coolChannel << " "
777 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
778 << m_rampCorrections[i].m_gain << " "
779 << m_rampCorrections[i].m_vRamp[0] << " "
780 << m_rampCorrections[i].m_vRamp[1] << " "
781 << m_rampCorrections[i].m_vRamp[2] << " "
784
785 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
787 }
788 }
789
790 ATH_MSG_DEBUG (
"2nd Apply corrections and compare LArRampMC with corrections " );
793
794 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
796 m_rampCorrections[i].m_gain);
797 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
798 m_rampCorrections[i].m_gain);
801 << coolChannel << " "
802 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
803 << m_rampCorrections[i].m_gain << " "
807 }
808 else {
810 }
811 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
812 << coolChannel << " "
813 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
814 << m_rampCorrections[i].m_gain << " "
815 << m_rampCorrections[i].m_vRamp[0] << " "
816 << m_rampCorrections[i].m_vRamp[1] << " "
817 << m_rampCorrections[i].m_vRamp[2] << " "
818 << " Compare = " << (rampP == m_rampCorrections[i]) );
819 if (rampP != m_rampCorrections[i] && !rampP.
isEmpty()) {
820 ATH_MSG_ERROR (
"After correction: LArRampMC and correction NOT equal" );
822 }
823 }
824
825 ATH_MSG_DEBUG (
"2nd Undo corrections and compare LArRampMC with corrections " );
828
829 for (
unsigned int i = 0;
i < m_rampCorrections.size(); ++
i) {
831 m_rampCorrections[i].m_gain);
832 unsigned int coolChannel = ramps->
coolChannel(m_rampCorrections[i].m_channelID,
833 m_rampCorrections[i].m_gain);
836 << coolChannel << " "
837 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
838 << m_rampCorrections[i].m_gain << " "
842 }
843 else {
845 }
846 ATH_MSG_DEBUG (
"Corrections: cool chan, chan id, gain, ramps "
847 << coolChannel << " "
848 << m_onlineID->show_to_string(m_rampCorrections[i].m_channelID) << " "
849 << m_rampCorrections[i].m_gain << " "
850 << m_rampCorrections[i].m_vRamp[0] << " "
851 << m_rampCorrections[i].m_vRamp[1] << " "
852 << m_rampCorrections[i].m_vRamp[2] << " "
855
856 ATH_MSG_ERROR (
"After undo: LArRampMC and correction DO NOT compare - should have opposite signs for ramps" );
858 }
859 }
860 }
861
862
863
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
970
971 std::set<unsigned int> channelNumbers;
972 CONTAINER::chan_const_iterator chanIt = ramps->
chan_begin();
973 CONTAINER::chan_const_iterator endChan = ramps->
chan_end ();
974 for (
unsigned int i = 0; chanIt != endChan; ++chanIt, ++
i) {
975 const CONTAINER::Subset* subset = ramps->
at(i);
977 << " channel " << subset->channel()
978 << " gain " << subset->gain()
979 << " groupingType " << subset->groupingType()
980 << " subsetSize " << subset->subsetSize()
981 << " correctionVecSize " << subset->correctionVecSize() );
982 if ((*chanIt) != subset->channel()) {
983 ATH_MSG_ERROR (
"Channel numbers not the same for MultChanColl and subset: "
984 << i
985 << " multchan " << (*chanIt)
986 << " subset " << subset->channel() );
988 }
989 if (!(channelNumbers.insert(subset->channel()).second)) {
991 << " channel " << subset->channel() );
993 }
994 }
995 ATH_MSG_DEBUG (
"Channel numbers size " << channelNumbers.size()
996 <<
" ramps size " << ramps->
chan_size() );
997
1000 return (StatusCode::FAILURE);
1001 }
1002
1004 return StatusCode::SUCCESS;
1005}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
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