ATLAS Offline Software
LArAutoCorrDecoderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 ) {
16  ATH_CHECK( detStore()->retrieve(ll, "LArOnline_SuperCellID") );
17  m_onlineID = (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 = (const LArOnlineID_Base*)ll;
24  ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
25  }
26 
27 
28  if (!m_isSC && m_alwaysHighGain)
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 
36 const 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 
45 const 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 
93 const 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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArAutoCorrDecoderTool::m_decodemode
Gaudi::Property< unsigned > m_decodemode
Definition: LArAutoCorrDecoderTool.h:47
LArAutoCorrDecoderTool::m_onlineID
const LArOnlineID_Base * m_onlineID
Definition: LArAutoCorrDecoderTool.h:55
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArAutoCorrDecoderTool::m_alwaysHighGain
Gaudi::Property< bool > m_alwaysHighGain
Definition: LArAutoCorrDecoderTool.h:48
HWIdentifier
Definition: HWIdentifier.h:13
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
LArAutoCorrDecoderTool::ACDiagonal
const Eigen::MatrixXd ACDiagonal(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition: LArAutoCorrDecoderTool.cxx:45
ILArAutoCorr::autoCorr
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
ILArAutoCorr
This class defines the interface for accessing AutoCorrelation parameters for each channel @stereotyp...
Definition: ILArAutoCorr.h:29
LArAutoCorrDecoderTool::initialize
virtual StatusCode initialize()
Definition: LArAutoCorrDecoderTool.cxx:10
LArAutoCorrDecoderTool::m_keyAutoCorr
Gaudi::Property< std::string > m_keyAutoCorr
Definition: LArAutoCorrDecoderTool.h:50
LArAutoCorrDecoderTool::ACPhysics
const Eigen::MatrixXd ACPhysics(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition: LArAutoCorrDecoderTool.cxx:93
LArOnlineID_Base::isFCALchannel
bool isFCALchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1657
LArAutoCorrDecoderTool.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArOnlineID_Base::isHECchannel
virtual bool isHECchannel(const HWIdentifier id) const =0
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArAutoCorrDecoderTool::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArAutoCorrDecoderTool.h:49
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LArOnlineID
Definition: LArOnlineID.h:20
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArAutoCorrDecoderTool::~LArAutoCorrDecoderTool
virtual ~LArAutoCorrDecoderTool()
LArAutoCorrDecoderTool::AutoCorr
const Eigen::MatrixXd AutoCorr(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition: LArAutoCorrDecoderTool.cxx:36
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:218
fitman.k
k
Definition: fitman.py:528
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
DiTauMassTools::TauTypes::ll
@ ll
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:49