ATLAS Offline Software
LArHVCorrectionMonAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ********************************************************************
6 // NAME: LArHVCorrectionMonAlg.cxx
7 // PACKAGE: LArMonitoring
8 //
9 // AUTHOR: Pavol Strizenec, based on tool by Jessica Leveque
10 //
11 // Class for monitoring offline HV corrections based in DCS infos
12 // ********************************************************************
13 
14 #include "LArHVCorrectionMonAlg.h"
15 
16 /*---------------------------------------------------------*/
17 LArHVCorrectionMonAlg::LArHVCorrectionMonAlg(const std::string& name, ISvcLocator* pSvcLocator)
18  : AthMonitorAlgorithm(name, pSvcLocator),
19  m_LArOnlineIDHelper(0),
20  m_caloIdMgr(0)
21 { }
22 
23 /*---------------------------------------------------------*/
25 {
26 
27  ATH_MSG_INFO( "Initialize LArHVCorrectionMonAlg" );
28 
29  ATH_CHECK( detStore()->retrieve(m_LArOnlineIDHelper, "LArOnlineID") );
30 
31  // Retrieve ID helpers
32  const CaloCell_ID* idHelper = nullptr;
33  ATH_CHECK( detStore()->retrieve( idHelper, "CaloCell_ID" ) );
34 
36 
39 
41 
42  ATH_MSG_DEBUG( "Successful Initialize LArHVCorrection " );
44 }
45 
46 /*---------------------------------------------------------*/
47 StatusCode LArHVCorrectionMonAlg::fillHistograms(const EventContext& ctx) const
48 {
49  ATH_MSG_DEBUG( "in fillHists()" );
50 
51 
52 
54  ATH_CHECK(caloMgrHandle.isValid());
55  const CaloDetDescrManager* ddman = *caloMgrHandle;
56 
57  // Retrieve event information
58  int lumi_block = ctx.eventID().lumi_block();
59 
60  // Counter for deviating channels in each partition
61  float nonNominal[] = {0.,0.,0.,0.,0.,0.,0.,0.};
62 
66 
67  std::vector<HWIdentifier>::const_iterator idptr = m_LArOnlineIDHelper->channel_begin();
68  std::vector<HWIdentifier>::const_iterator idEndptr = m_LArOnlineIDHelper->channel_end();
69  for (;idptr != idEndptr; ++idptr) {
70  HWIdentifier id = *idptr;
71  Identifier offlineID = larCabling->cnvToIdentifier(id);
72 
73  // Skip disconnected channels
74  if(!larCabling->isOnlineConnected(id)) continue;
75 
76  // Get Physical Coordinates
77  float etaChan = 0; float phiChan = 0.;
78  const CaloDetDescrElement* caloDetElement = ddman->get_element(offlineID);
79  if(caloDetElement == 0 ){
80  ATH_MSG_ERROR( "Cannot retrieve (eta,phi) coordinates for raw channels" );
81  continue;
82  }else{
83  etaChan = caloDetElement->eta_raw();
84  phiChan = caloDetElement->phi_raw();
85  }
86 
87  // Fix phi range in HEC
88  if (m_LArOnlineIDHelper->isHECchannel(id)) phiChan = CaloPhiRange::fix(phiChan);
89 
90  // Retrieve HV correction info
91  float hvdev = 0;
92  float hvonline = onlineScaleCorr->HVScaleCorr(id);
93  if (hvonline<=0) continue; //No valid online correction
94  // Correction in scaleCorr has already been divided by hvonline.
95  float hvcorr = scaleCorr->HVScaleCorr(id) * hvonline;
96  if (hvcorr>hvonline) hvdev = hvonline-hvcorr; //Monitor only channels that get a higher correction from DCS (eg are at a lower voltage).
97 
98  if (fabs(hvdev/hvonline)> m_threshold){
99  // A-Side
100  if(etaChan >= 0){
102  nonNominal[0]++;
103  ATH_MSG_VERBOSE( "hvdev EMBA" << hvdev );
104  auto meta = Monitored::Scalar<float>("etaEMBA",etaChan);
105  auto mphi = Monitored::Scalar<float>("phiEMBA",phiChan);
106  auto hvmon = Monitored::Scalar<float>("hvcorrEMBA",hvdev);
107  fill(m_MonGroupName,meta,mphi,hvmon);
108  }
110  nonNominal[1]++;
111  ATH_MSG_VERBOSE( "hvdev EMECA" << hvdev );
112  auto meta = Monitored::Scalar<float>("etaEMECA",etaChan);
113  auto mphi = Monitored::Scalar<float>("phiEMECA",phiChan);
114  auto hvmon = Monitored::Scalar<float>("hvcorrEMECA",hvdev);
115  fill(m_MonGroupName,meta,mphi,hvmon);
116  }
118  nonNominal[2]++;
119  ATH_MSG_VERBOSE( "hvdev HECA" << hvdev );
120  auto meta = Monitored::Scalar<float>("etaHECA",etaChan);
121  auto mphi = Monitored::Scalar<float>("phiHECA",phiChan);
122  auto hvmon = Monitored::Scalar<float>("hvcorrHECA",hvdev);
123  fill(m_MonGroupName,meta,mphi,hvmon);
124  }
126  nonNominal[3]++;
127  ATH_MSG_VERBOSE( "hvdev FCALA" << hvdev );
128  auto meta = Monitored::Scalar<float>("etaFCALA",etaChan);
129  auto mphi = Monitored::Scalar<float>("phiFCALA",phiChan);
130  auto hvmon = Monitored::Scalar<float>("hvcorrFCALA",hvdev);
131  fill(m_MonGroupName,meta,mphi,hvmon);
132  }
133 
134  // C-side
135  } else {
137  nonNominal[4]++;
138  ATH_MSG_VERBOSE( "hvdev EMBC" << hvdev );
139  auto meta = Monitored::Scalar<float>("etaEMBC",etaChan);
140  auto mphi = Monitored::Scalar<float>("phiEMBC",phiChan);
141  auto hvmon = Monitored::Scalar<float>("hvcorrEMBC",hvdev);
142  fill(m_MonGroupName,meta,mphi,hvmon);
143  }
145  nonNominal[5]++;
146  ATH_MSG_VERBOSE( "hvdev EMECC" << hvdev );
147  auto meta = Monitored::Scalar<float>("etaEMECC",etaChan);
148  auto mphi = Monitored::Scalar<float>("phiEMECC",phiChan);
149  auto hvmon = Monitored::Scalar<float>("hvcorrEMECC",hvdev);
150  fill(m_MonGroupName,meta,mphi,hvmon);
151  }
153  nonNominal[6]++;
154  ATH_MSG_VERBOSE( "hvdev HECC" << hvdev );
155  auto meta = Monitored::Scalar<float>("etaHECC",etaChan);
156  auto mphi = Monitored::Scalar<float>("phiHECC",phiChan);
157  auto hvmon = Monitored::Scalar<float>("hvcorrHECC",hvdev);
158  fill(m_MonGroupName,meta,mphi,hvmon);
159  }
161  nonNominal[7]++;
162  ATH_MSG_VERBOSE( "hvdev FCALC" << hvdev );
163  auto meta = Monitored::Scalar<float>("etaFCALC",etaChan);
164  auto mphi = Monitored::Scalar<float>("phiFCALC",phiChan);
165  auto hvmon = Monitored::Scalar<float>("hvcorrFCALC",hvdev);
166  fill(m_MonGroupName,meta,mphi,hvmon);
167  }
168  }
169  }
170  }// end Channels Loop
171 
172  // Fill number of problematic cell per LUMI_BLOCK
173  auto monLB = Monitored::Scalar<int>("LB",lumi_block);
174  auto nnEMBA = Monitored::Scalar<int>("nonnominalEMBA",nonNominal[0]);
175  auto nnEMECA = Monitored::Scalar<int>("nonnominalEMECA",nonNominal[1]);
176  auto nnHECA = Monitored::Scalar<int>("nonnominalHECA",nonNominal[2]);
177  auto nnFCALA = Monitored::Scalar<int>("nonnominalFCALA",nonNominal[3]);
178  auto nnEMBC = Monitored::Scalar<int>("nonnominalEMBC",nonNominal[4]);
179  auto nnEMECC = Monitored::Scalar<int>("nonnominalEMECC",nonNominal[5]);
180  auto nnHECC = Monitored::Scalar<int>("nonnominalHECC",nonNominal[6]);
181  auto nnFCALC = Monitored::Scalar<int>("nonnominalFCALC",nonNominal[7]);
182  fill(m_MonGroupName,monLB,nnEMBA,nnEMBC,nnEMECA,nnEMECC,nnHECA,nnFCALA,nnHECC,nnFCALC);
183 
184 
185  return StatusCode::SUCCESS;
186 }
187 
188 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArHVCorrectionMonAlg::LArHVCorrectionMonAlg
LArHVCorrectionMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArHVCorrectionMonAlg.cxx:17
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArHVCorrectionMonAlg::initialize
virtual StatusCode initialize() override final
Overwrite dummy method from AlgTool.
Definition: LArHVCorrectionMonAlg.cxx:24
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
LArHVCorrectionMonAlg::m_onlineScaleCorrKey
SG::ReadCondHandleKey< ILArHVScaleCorr > m_onlineScaleCorrKey
Definition: LArHVCorrectionMonAlg.h:63
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::channel_end
id_iterator channel_end() const
Definition: LArOnlineID_Base.cxx:1931
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArHVCorrectionMonAlg::m_scaleCorrKey
SG::ReadCondHandleKey< ILArHVScaleCorr > m_scaleCorrKey
Definition: LArHVCorrectionMonAlg.h:62
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
LArHVCorrectionMonAlg.h
LArOnlineID_Base::isFCALchannel
bool isFCALchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1657
LArOnlineID::isEMECchannel
bool isEMECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:774
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
LArHVCorrectionMonAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArHVCorrectionMonAlg.h:64
LArHVCorrectionMonAlg::m_threshold
Gaudi::Property< float > m_threshold
Definition: LArHVCorrectionMonAlg.h:56
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
LArHVCorrectionMonAlg::m_MonGroupName
Gaudi::Property< std::string > m_MonGroupName
Definition: LArHVCorrectionMonAlg.h:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArHVCorrectionMonAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArHVCorrectionMonAlg.h:61
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID_Base::isEMBchannel
bool isEMBchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1652
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
LArHVCorrectionMonAlg::m_LArOnlineIDHelper
const LArOnlineID * m_LArOnlineIDHelper
Definition: LArHVCorrectionMonAlg.h:70
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
LArHVCorrectionMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override final
Called each event.
Definition: LArHVCorrectionMonAlg.cxx:47
ILArHVScaleCorr::HVScaleCorr
virtual const float & HVScaleCorr(const HWIdentifier &id) const =0
LArOnlineID::isHECchannel
bool isHECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:734
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
LArOnlineID_Base::channel_begin
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
Definition: LArOnlineID_Base.cxx:1926
LArOnOffIdMapping::isOnlineConnected
bool isOnlineConnected(const HWIdentifier &sid) const
Test whether a HWIdentifier is connected of not (inline)
Definition: LArOnOffIdMapping.h:121
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352