ATLAS Offline Software
Loading...
Searching...
No Matches
LArAutoCorrDecoderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
11{
12 ATH_MSG_DEBUG("LArAutoCorrDecoderTool initialize() begin");
13
14 if ( m_isSC ) {
15 const LArOnline_SuperCellID* ll;
16 ATH_CHECK( detStore()->retrieve(ll, "LArOnline_SuperCellID") );
17 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
18 ATH_MSG_DEBUG("Found the LArOnlineID helper");
19
20 } else { // m_isSC
21 const LArOnlineID* ll;
22 ATH_CHECK( detStore()->retrieve(ll, "LArOnlineID") );
23 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
24 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
25 }
26
27
29 ATH_MSG_INFO( "Will always return HIGH gain autocorrelation matrix for EM calo, MEDIUM for HEC and FCAL" );
30
31 ATH_MSG_DEBUG("LArAutoCorrDecoderTool initialize() end");
32 return StatusCode::SUCCESS;
33}
34
35
36const Eigen::MatrixXd LArAutoCorrDecoderTool::AutoCorr( const HWIdentifier& CellID, int gain, unsigned nSamples=5 ) const
37{
38 if (m_decodemode==1u)
39 return ACPhysics(CellID,gain,nSamples);
40 else
41 return ACDiagonal(CellID,gain,nSamples);
42}
43
44
45const Eigen::MatrixXd LArAutoCorrDecoderTool::ACDiagonal( const HWIdentifier& CellID, int gain, unsigned nSamples=5 ) const {
46
47 if (!m_isSC && m_alwaysHighGain) {
48 if (m_onlineID->isFCALchannel(CellID) ||m_onlineID->isHECchannel(CellID))
49 gain=1;
50 else
51 gain=0;
52 }
53
54 Eigen::MatrixXd AutoCorrMatrix=Eigen::MatrixXd::Zero(nSamples,nSamples);
55
56 const ILArAutoCorr* autoCorr=nullptr;
57 detStore()->retrieve(autoCorr,m_keyAutoCorr).ignore();
58
59
60 if ( autoCorr ) { // LArAutoCorrComplete is loaded in DetStore
61
62 ILArAutoCorr::AutoCorrRef_t dbcorr = autoCorr->autoCorr(CellID,gain);
63
64 if ( dbcorr.size()== 0 ) { // empty AutoCorr for given channel
65 ATH_MSG_WARNING( "Empty AutoCorr vector for channel " << m_onlineID->channel_name(CellID) << " in Gain = " << gain);
66 nSamples=0;
67 }
68 else if (dbcorr.size() < nSamples-1 ) {
69 ATH_MSG_WARNING( "Not enough samples in AutoCorr vector for channel " << m_onlineID->channel_name(CellID) << " in Gain = " << gain);
70 nSamples=1+dbcorr.size(); //The remaining values of the eigen matrix are left to 0.0
71 }
72
73 // fill diagonal matrix with vector
74 for (unsigned i=0;i<nSamples;i++) {
75 AutoCorrMatrix(i,i)= 1 ;
76 for (unsigned j=i+1;j<nSamples;j++) {
77 AutoCorrMatrix(i,j) = AutoCorrMatrix(j,i) = dbcorr[j-i-1];
78 }
79 }
80 }//else if m_autoCorr
81 else { // no LArAutoCorrComplete loaded in DetStore (e.g. DB problem) :-(
82 ATH_MSG_WARNING( "No valid AutoCorr object loaded from DetStore" );
83 }
84
85 ATH_MSG_DEBUG("AutoCorr Diagonal matrix for channel " << m_onlineID->channel_name(CellID)
86 << " in Gain = " << gain
87 << ":\n" << AutoCorrMatrix);
88
89 return AutoCorrMatrix;
90
91}
92
93const Eigen::MatrixXd LArAutoCorrDecoderTool::ACPhysics( const HWIdentifier& CellID, int gain, unsigned nSamples=5 ) const {
94
95
96 if (!m_isSC && m_alwaysHighGain) {
97 if (m_onlineID->isFCALchannel(CellID) ||m_onlineID->isHECchannel(CellID))
98 gain=1;
99 else
100 gain=0;
101 }
102
103 Eigen::MatrixXd AutoCorrMatrix=Eigen::MatrixXd::Identity(nSamples,nSamples);
104
105 const ILArAutoCorr* autoCorr=nullptr;
106 detStore()->retrieve(autoCorr,m_keyAutoCorr).ignore();
107
108 if ( autoCorr ) { // LArAutoCorrComplete is loaded in DetStore
109
110 ILArAutoCorr::AutoCorrRef_t corrdb = autoCorr->autoCorr(CellID,gain);
111
112 if ( corrdb.size()== 0 ) { // empty AutoCorr for given channel
113 ATH_MSG_WARNING( "Empty AutoCorr vector for channel " << m_onlineID->channel_name(CellID) << " in Gain = " << gain);
114 nSamples=0; //return all-zero matrix
115 }
116 else if ( corrdb.size() < nSamples*(nSamples+1)/2 ) {
117 ATH_MSG_WARNING( "Not enough samples in AutoCorr vector for channel " << m_onlineID->channel_name(CellID)
118 << "in Gain = " << gain << " for AC Physics mode");
119 nSamples=0;//return all-zero matrix
120 }
121
122 // Corr size could be bigger, then it's asked now, need remapping:
123 const unsigned int nsamples_AC = (-1+((int)(sqrt(1+8*corrdb.size()))))/2;
124 unsigned int k=0;
125 for (unsigned i=0;i<nSamples;i++) {
126 for (unsigned j=i;j<nSamples;j++,k++) {
127 if (i<=j) {
128 AutoCorrMatrix(i,j) = AutoCorrMatrix(j,i)= corrdb[k];
129 }
130 }
131 k+=nsamples_AC-nSamples;
132 }
133 } //end if m_autoCorr
134 else { // no LArAutoCorrComplete loaded in DetStore (e.g. DB problem) :-(
135 ATH_MSG_WARNING( "No valid AutoCorr object loaded from DetStore" );
136 }
137
138 ATH_MSG_DEBUG("AutoCorr Physics matrix for channel " << m_onlineID->channel_name(CellID)
139 << " in Gain = " << gain
140 << ":\n" << AutoCorrMatrix);
141 return AutoCorrMatrix;
142
143}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
This class defines the interface for accessing AutoCorrelation parameters for each channel @stereotyp...
LArVectorProxy AutoCorrRef_t
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
const Eigen::MatrixXd ACDiagonal(const HWIdentifier &CellID, int gain, unsigned nSamples) const
const LArOnlineID_Base * m_onlineID
virtual StatusCode initialize()
virtual ~LArAutoCorrDecoderTool()
const Eigen::MatrixXd AutoCorr(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Gaudi::Property< std::string > m_keyAutoCorr
Gaudi::Property< unsigned > m_decodemode
Gaudi::Property< bool > m_alwaysHighGain
const Eigen::MatrixXd ACPhysics(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Gaudi::Property< bool > m_isSC
Helper for the Liquid Argon Calorimeter cell identifiers.