ATLAS Offline Software
Loading...
Searching...
No Matches
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/*---------------------------------------------------------*/
27LArCosmicsMonAlg::LArCosmicsMonAlg(const std::string& name, ISvcLocator* pSvcLocator )
28 : AthMonitorAlgorithm(name, pSvcLocator),
33
34/*---------------------------------------------------------*/
38
39/*---------------------------------------------------------*/
40StatusCode
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
74 ATH_CHECK(m_cablingKey.initialize());
75 ATH_CHECK(m_larPedestalKey.initialize());
77
79 ATH_CHECK(m_bcContKey.initialize());
80 ATH_CHECK(m_caloMgrKey.initialize());
81 ATH_CHECK(m_bcMask.buildBitMask(m_problemsToMask,msg()));
82
84}
85
86/*---------------------------------------------------------*/
87StatusCode
88LArCosmicsMonAlg::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
153 if (m_LArOnlineIDHelper->isHECchannel(id)) phi = CaloPhiRange::fix(phi);
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
169 if(m_LArOnlineIDHelper->isHECchannel(id)){
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
195 if(m_LArOnlineIDHelper->isFCALchannel(id)){
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 //
219 if(m_LArOnlineIDHelper->isEMECchannel(id) || m_LArOnlineIDHelper->isEMBchannel(id) ){
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
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
static double fix(double phi)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual float pedestal(const HWIdentifier &id, int gain) const =0
LArBadChannelMask m_bcMask
Handle to bad-channel mask.
const LArFCAL_ID * m_LArFCAL_IDHelper
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
const LArOnlineID * m_LArOnlineIDHelper
virtual ~LArCosmicsMonAlg()
Default destructor.
LArCosmicsMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< LArDigitContainer > m_LArDigitContainerKey
Handle to digits.
const LArHEC_ID * m_LArHEC_IDHelper
Gaudi::Property< std::vector< std::string > > m_problemsToMask
virtual StatusCode fillHistograms(const EventContext &ctx) const override
Called each event.
const LArEM_ID * m_LArEM_IDHelper
Gaudi::Property< float > m_muonADCthreshold_EM_endcap
Gaudi::Property< float > m_muonADCthreshold_EM_barrel
Gaudi::Property< float > m_muonADCthreshold_FCAL
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadCondHandleKey< ILArPedestal > m_larPedestalKey
Handle to pedestal.
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Gaudi::Property< std::string > m_CosmicsMonGroupName
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Gaudi::Property< float > m_muonADCthreshold_HEC
Liquid Argon digit base class.
Definition LArDigit.h:25
CaloGain::CaloGain gain() const
Definition LArDigit.h:72
const HWIdentifier & hardwareID() const
Definition LArDigit.h:66
const std::vector< short > & samples() const
Definition LArDigit.h:78
Declare a monitored scalar variable.
void fill(H5::Group &out_file, size_t iterations)