ATLAS Offline Software
LArCosmicsMonAlg.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 //
7 // NAME: LArCosmicsMonAlg.cxx
8 // PACKAGE: LArMonitoring
9 //
10 // AUTHOR: Margherita Spalla (Migrated from original tool by Jessica Leveque)
11 //
12 // Class for monitoring : Detector Timing
13 // Cosmics Signal Reconstruction
14 // Development towards LAr Data Quality Flags
15 //
16 // ********************************************************************
17 
18 #include "LArCosmicsMonAlg.h"
19 
21 
22 #include <algorithm>
23 
24 
25 
26 /*---------------------------------------------------------*/
27 LArCosmicsMonAlg::LArCosmicsMonAlg(const std::string& name, ISvcLocator* pSvcLocator )
28  : AthMonitorAlgorithm(name, pSvcLocator),
29  m_LArOnlineIDHelper(0),
30  m_LArEM_IDHelper(0),
31  m_LArHEC_IDHelper(0),
32  m_LArFCAL_IDHelper(0) {}
33 
34 /*---------------------------------------------------------*/
36 {
37 }
38 
39 /*---------------------------------------------------------*/
42 {
43  ATH_MSG_INFO( "Initialize LArCosmicsMonAlg" );
44 
45 
47  if ( detStore()->retrieve( m_LArOnlineIDHelper, "LArOnlineID" ).isSuccess() ) {
48  ATH_MSG_DEBUG("connected non-tool: LArOnlineID" );
49  } else {
50  ATH_MSG_FATAL( "unable to connect non-tool: LArOnlineID" );
51  return StatusCode::FAILURE;
52  }
53 
54 
55  // Retrieve ID helpers
56  if ( detStore()->retrieve( m_LArEM_IDHelper, "LArEM_ID" ).isSuccess() ) ATH_MSG_DEBUG("connected non-tool: LArEM_ID" );
57  else {
58  ATH_MSG_FATAL( "unable to connect non-tool: LArEM_ID" );
59  return StatusCode::FAILURE;
60  }
61 
62  if ( detStore()->retrieve( m_LArHEC_IDHelper, "LArHEC_ID" ).isSuccess() ) ATH_MSG_DEBUG("connected non-tool: LArHEC_ID" );
63  else {
64  ATH_MSG_FATAL( "unable to connect non-tool: LArHEC_ID" );
65  return StatusCode::FAILURE;
66  }
67 
68  if ( detStore()->retrieve( m_LArFCAL_IDHelper, "LArFCAL_ID" ).isSuccess() ) ATH_MSG_DEBUG("connected non-tool: LArFCAL_ID" );
69  else {
70  ATH_MSG_FATAL( "unable to connect non-tool: LArFCAL_ID" );
71  return StatusCode::FAILURE;
72  }
73 
77 
79  ATH_CHECK(m_bcContKey.initialize());
82 
84 }
85 
86 /*---------------------------------------------------------*/
88 LArCosmicsMonAlg::fillHistograms(const EventContext& ctx) const {
89  ATH_MSG_DEBUG( "in fillHists()" );
90 
91 
92  //monitored variables
93  auto mon_eta_EM = Monitored::Scalar<float>("mon_eta_EM",0);
94  auto mon_eta_HEC = Monitored::Scalar<float>("mon_eta_HEC",0);
95  auto mon_eta_FCal = Monitored::Scalar<float>("mon_eta_FCal",0);
96  auto mon_phi = Monitored::Scalar<float>("mon_phi",0);
97 
98 
99 
101  // Work with the LArDigits //
103 
104  //retrieve pedestal
106  const ILArPedestal* pedestals=*pedestalHdl;
107 
108  //retrieve cabling
110  const LArOnOffIdMapping* cabling=*cablingHdl;
111 
112  //retrieve BadChannel info:
114  const LArBadChannelCont* bcCont{*bcContHdl};
115 
116 
119  ATH_CHECK(caloMgrHandle.isValid());
120  const CaloDetDescrManager* ddman = *caloMgrHandle;
121 
122 
123  //get digit container
125 
127  LArDigitContainer::const_iterator itDig = pLArDigitContainer->begin();
128  LArDigitContainer::const_iterator itDig_e= pLArDigitContainer->end();
129  const LArDigit* pLArDigit;
130 
131 
132  for ( ; itDig!=itDig_e;++itDig) {
133  pLArDigit = *itDig;
134  HWIdentifier id = pLArDigit->hardwareID();
135  Identifier offlineID = cabling->cnvToIdentifier(id);
136 
137  // Skip disconnected channels
138  if(!cabling->isOnlineConnected(id)) continue;
139 
140  // Get Physical Coordinates
141  float eta=0;
142  float phi=0;
143  const CaloDetDescrElement* caloDetElement = ddman->get_element(offlineID);
144  if(caloDetElement == 0 ){
145  ATH_MSG_ERROR( "Cannot retrieve (eta,phi) coordinates" );
146  continue;
147  }else{
148  eta = caloDetElement->eta_raw();
149  phi = caloDetElement->phi_raw();
150  }
151 
152  // Fix phi range in HEC
154 
155  // Retrieve pedestals
156  CaloGain::CaloGain gain = pLArDigit->gain();
157  float pedestal = pedestals->pedestal(id,gain);
158 
159  // Skip channel with no pedestal ref in db
160  if(pedestal <= (1.0+LArElecCalib::ERRORCODE)) continue;
161 
162  // Remove problematic channels
163  if (m_bcMask.cellShouldBeMasked(bcCont,id)) continue;
164 
165  //
166  // HEC
167  //
168 
170 
171  int sampling = m_LArHEC_IDHelper->sampling(offlineID);
172  const std::vector < short >& samples = pLArDigit->samples();
173 
174  // Look for Muons Candidates in sampling 1
175  if(sampling != 1) continue;
176 
177  // Get highest energy sample
178  float sample_max = * std::max_element(samples.begin(), samples.end());
179  sample_max = sample_max-pedestal;
180 
181  // If energy above threshold, we found a muon in the HEC
182  if((sample_max) > m_muonADCthreshold_HEC){
183  mon_eta_HEC=eta;
184  mon_phi=phi;
185  fill(m_CosmicsMonGroupName,mon_eta_HEC,mon_phi);
186  }
187 
188  } // End HEC
189 
190 
191  //
192  // FCAL - Fill coverage / conditions / pedestal maps
193  //
194 
196 
197  int sampling = m_LArFCAL_IDHelper->module(offlineID);;
198  const std::vector < short > samples = pLArDigit->samples();
199 
200  // Look for Muons Candidates in sampling 2
201  if(sampling != 2) continue;
202 
203  // Get highest energy sample
204  float sample_max = * std::max_element(samples.begin(), samples.end());
205  sample_max = sample_max-pedestal;
206 
207  // If energy above threshold, we found a muon in the FCAL
208  if( (sample_max) > m_muonADCthreshold_FCAL){
209  mon_eta_FCal=eta;
210  mon_phi=phi;
211  fill(m_CosmicsMonGroupName,mon_eta_FCal,mon_phi);
212  }
213 
214  }//end FCAL
215 
216  //
217  // ECAL
218  //
220 
221  int sampling = m_LArEM_IDHelper->sampling(offlineID);
222  const std::vector < short > samples = pLArDigit->samples();
223 
224  // Look for Muons Candidates in second sampling
225  if(sampling != 2) continue;
226 
227  // Get highest energy sample
228  float sample_max = * std::max_element(samples.begin(), samples.end());
229  sample_max = sample_max-pedestal;
230 
231  // If energy above threshold, we found a muon in the barrel
232  if( m_LArEM_IDHelper->is_em_barrel(offlineID) && (sample_max) > m_muonADCthreshold_EM_barrel ){
233  mon_eta_EM=eta;
234  mon_phi=phi;
235  fill(m_CosmicsMonGroupName,mon_eta_EM,mon_phi);
236  }
237 
238  // If energy above threshold, we found a muon in the endcap
239  if(m_LArEM_IDHelper->is_em_endcap(offlineID) && (sample_max) > m_muonADCthreshold_EM_endcap ){
240  mon_eta_EM=eta;
241  mon_phi=phi;
242  fill(m_CosmicsMonGroupName,mon_eta_EM,mon_phi);
243  }
244 
245  } // end EM
246 
247  }// end of LArDigits loop
248 
249  return StatusCode::SUCCESS;
250 }
251 
252 
253 
254 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ILArPedestal::pedestal
virtual float pedestal(const HWIdentifier &id, int gain) const =0
LArCosmicsMonAlg::m_LArOnlineIDHelper
const LArOnlineID * m_LArOnlineIDHelper
Definition: LArCosmicsMonAlg.h:61
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArCosmicsMonAlg::LArCosmicsMonAlg
LArCosmicsMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCosmicsMonAlg.cxx:27
LArCosmicsMonAlg::m_LArDigitContainerKey
SG::ReadHandleKey< LArDigitContainer > m_LArDigitContainerKey
Handle to digits.
Definition: LArCosmicsMonAlg.h:68
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArCosmicsMonAlg::m_bcContKey
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Definition: LArCosmicsMonAlg.h:78
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ILArPedestal
Definition: ILArPedestal.h:12
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArDigit::samples
const std::vector< short > & samples() const
Definition: LArDigit.h:78
LArDigit::hardwareID
const HWIdentifier & hardwareID() const
Definition: LArDigit.h:66
LArCosmicsMonAlg::m_muonADCthreshold_EM_barrel
Gaudi::Property< float > m_muonADCthreshold_EM_barrel
Definition: LArCosmicsMonAlg.h:84
LArBadChannelMask::buildBitMask
StatusCode buildBitMask(const std::vector< std::string > &problemsToMask, MsgStream &msg)
Definition: LArBadChannelMask.cxx:10
LArFCAL_Base_ID::module
int module(const Identifier id) const
module [1,3]
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
LArCosmicsMonAlg::~LArCosmicsMonAlg
virtual ~LArCosmicsMonAlg()
Default destructor.
Definition: LArCosmicsMonAlg.cxx:35
HWIdentifier
Definition: HWIdentifier.h:13
LArBadChannelMask::cellShouldBeMasked
bool cellShouldBeMasked(const LArBadChannelCont *bcCont, const HWIdentifier &hardwareId) const
Definition: LArBadChannelMask.h:42
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
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
LArOnlineID_Base::isFCALchannel
bool isFCALchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1653
LArOnlineID::isEMECchannel
bool isEMECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:763
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCosmicsMonAlg.h
LArDigit
Liquid Argon digit base class.
Definition: LArDigit.h:25
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
LArCosmicsMonAlg::m_muonADCthreshold_FCAL
Gaudi::Property< float > m_muonADCthreshold_FCAL
Definition: LArCosmicsMonAlg.h:87
LArCosmicsMonAlg::initialize
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
Definition: LArCosmicsMonAlg.cxx:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArCosmicsMonAlg::m_bcMask
LArBadChannelMask m_bcMask
Handle to bad-channel mask.
Definition: LArCosmicsMonAlg.h:77
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.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArCosmicsMonAlg::m_muonADCthreshold_EM_endcap
Gaudi::Property< float > m_muonADCthreshold_EM_endcap
Definition: LArCosmicsMonAlg.h:85
LArCosmicsMonAlg::m_muonADCthreshold_HEC
Gaudi::Property< float > m_muonADCthreshold_HEC
Definition: LArCosmicsMonAlg.h:86
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID_Base::isEMBchannel
bool isEMBchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1648
LArCosmicsMonAlg::m_problemsToMask
Gaudi::Property< std::vector< std::string > > m_problemsToMask
Definition: LArCosmicsMonAlg.h:79
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArCosmicsMonAlg::m_larPedestalKey
SG::ReadCondHandleKey< ILArPedestal > m_larPedestalKey
Handle to pedestal.
Definition: LArCosmicsMonAlg.h:71
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
LArCosmicsMonAlg::m_LArHEC_IDHelper
const LArHEC_ID * m_LArHEC_IDHelper
Definition: LArCosmicsMonAlg.h:63
LArDigit::gain
CaloGain::CaloGain gain() const
Definition: LArDigit.h:72
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
LArHEC_Base_ID::sampling
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArCosmicsMonAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArCosmicsMonAlg.h:81
LArCosmicsMonAlg::m_CosmicsMonGroupName
Gaudi::Property< std::string > m_CosmicsMonGroupName
Definition: LArCosmicsMonAlg.h:89
LArCosmicsMonAlg::m_LArFCAL_IDHelper
const LArFCAL_ID * m_LArFCAL_IDHelper
Definition: LArCosmicsMonAlg.h:64
LArElecCalib::ERRORCODE
@ ERRORCODE
Definition: LArCalibErrorCode.h:17
LArOnlineID::isHECchannel
bool isHECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:723
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
LArCosmicsMonAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCosmicsMonAlg.h:74
LArCosmicsMonAlg::m_LArEM_IDHelper
const LArEM_ID * m_LArEM_IDHelper
Definition: LArCosmicsMonAlg.h:62
LArCosmicsMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
Called each event.
Definition: LArCosmicsMonAlg.cxx:88
LArEM_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14