ATLAS Offline Software
LArCondDataTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
17 
18 #include "StoreGate/StoreGateSvc.h"
19 
21 
22 #include "GaudiKernel/MsgStream.h"
23 #include "Gaudi/Property.h"
24 #include "GaudiKernel/ListItem.h"
25 
26 #include "LArElecCalib/ILArShape.h"
27 #include "LArElecCalib/ILArNoise.h"
28 #include "LArElecCalib/ILArRamp.h"
29 #include "LArElecCalib/ILArDAC2uA.h"
30 #include "LArElecCalib/ILAruA2MeV.h"
33 #include "LArElecCalib/ILArfSampl.h"
35 #include "LArElecCalib/ILArOFC.h"
36 
39 
40 
42 // CONSTRUCTOR:
44 
45 LArCondDataTest::LArCondDataTest(const std::string& name, ISvcLocator* pSvcLocator) :
46  AthAlgorithm(name,pSvcLocator),
47  m_onlineID(0),
48  m_emid(0),
49  m_tbin(0),m_fixShape(false)
50 
51 {
52  // switch for testing Filling IOV.
53  declareProperty("Tbin", m_tbin) ;
54  declareProperty("FixShape", m_fixShape) ;
55 }
56 
58 // DESTRUCTOR:
60 
62 { }
63 
65 // INITIALIZE:
67 
69 {
75 
76  ATH_MSG_DEBUG ( "initialize done" );
77  return StatusCode::SUCCESS;
78 }
79 
81 // EXECUTE:
83 
85 {
86  ATH_MSG_DEBUG(" LArCondDataTest::execute() ");
87 
89  const LArOnOffIdMapping* cabling{*cablingHdl};
90  if(!cabling){
91  ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
92  return StatusCode::FAILURE;
93  }
95  const LArCalibLineMapping *clCont {*clHdl};
96  if(!clCont){
97  ATH_MSG_ERROR("Do not have calib mapping object " << m_CLKey.key() );
98  return StatusCode::FAILURE;
99  }
101  const LArFebRodMapping *rodCont {*rodHdl};
102  if(!rodCont){
103  ATH_MSG_ERROR("Do not have ROD mapping object " << m_RodKey.key() );
104  return StatusCode::FAILURE;
105  }
106 
107  const std::vector<HWIdentifier>& roms = rodCont->getLArRoModIDvec();
108  ATH_MSG_DEBUG ( " Number of LArReadoutModuleIDs= " << roms.size() );
109 
110  std::vector<HWIdentifier>::const_iterator it = m_onlineID->channel_begin();
111  std::vector<HWIdentifier>::const_iterator it_end = m_onlineID->channel_end();
112 
113  int ntot = it_end-it;
114  ATH_MSG_DEBUG( " Total number of online channels from LArOnlineID "
115  <<ntot );
116 
117  int nch = 0;
118  int nconnected = 0;
119  int nerr=0;
120 
121  int n_err_uA2MeV=0;
122  int n_err_DAC2uA=0;
123 
124 
125  const ILArShape* pShape=0;
126  StatusCode sc = detStore()->retrieve(pShape);
127  if (!sc.isSuccess() ){
128  ATH_MSG_ERROR (" Failed to retrieve ILArShape from DetStore");
129  }
130 
131 
132  const ILArNoise* pNoise=0;
133  sc = detStore()->retrieve(pNoise);
134  if (!sc.isSuccess() ){
135  ATH_MSG_ERROR (" Failed to retrieve ILArNoise from DetStore");
136  }
137 
138 
139  const ILArRamp* pRamp=0;
140  sc = detStore()->retrieve(pRamp);
141  if (!sc.isSuccess() ){
142  ATH_MSG_ERROR (" Failed to retrieve ILArRamp from DetStore");
143  }
144 
145  const ILArDAC2uA* pDAC2uA=0;
146  sc = detStore()->retrieve(pDAC2uA);
147  if (!sc.isSuccess() ){
148  ATH_MSG_ERROR (" Failed to retrieve ILArDAC2uA from DetStore");
149  }
150 
151  const ILAruA2MeV* puA2MeV=0;
152  sc = detStore()->retrieve(puA2MeV);
153  if (!sc.isSuccess() ){
154  ATH_MSG_ERROR (" Failed to retrieve ILAruA2MeV from DetStore");
155  }
156 
157  const ILArAutoCorr* pAutoCorr=0;
158  sc = detStore()->retrieve(pAutoCorr);
159  if (!sc.isSuccess() ){
160  ATH_MSG_ERROR (" Failed to retrieve ILArAutoCorr from DetStore");
161  }
162 
163  const ILArPedestal* pPedestal=0;
164  sc = detStore()->retrieve(pPedestal);
165  if (!sc.isSuccess() ){
166  ATH_MSG_ERROR (" Failed to retrieve ILArPedestal from DetStore");
167  }
168 
169  const ILArfSampl* pfSampl=0;
170  sc = detStore()->retrieve(pfSampl);
171  if (!sc.isSuccess() ){
172  ATH_MSG_ERROR (" Failed to retrieve ILArfSampl from DetStore");
173  }
174 
175 
176  const ILArMinBias* pMinBias=0;
177  sc = detStore()->retrieve(pMinBias);
178  if (!sc.isSuccess() ){
179  ATH_MSG_ERROR (" Failed to retrieve ILArMinBias from DetStore");
180  }
181 
182 
183  for(;it!=it_end;++it) {
184  HWIdentifier sid = *it;
185  try {
186 
187  if(! cabling->isOnlineConnected(sid))
188  continue;
189 
190  if(m_onlineID->barrel_ec(sid)==1)
191  {// endcap
192  if(m_onlineID->feedthrough(sid)==6)
193  { // fcal
194  ATH_MSG_DEBUG( " FCAL sid "<<sid);
195  m_emid->print(sid);
196  }
197  }
198 
199  ++nconnected;
200  Identifier id = cabling->cnvToIdentifier(sid);
201  HWIdentifier sid2 =cabling->createSignalChannelID(id);
202  ++nch ;
203  if( sid !=sid2 ) {
204  ATH_MSG_ERROR( " HWIdentifier mismatch, sid "
205  <<" "<<sid<<" "<<m_onlineID->show_to_string(sid)
206  <<" offline id = "<< id <<" "<<m_onlineID->show_to_string(id)
207  <<" sid2 = "<< sid2 <<" "<<m_onlineID->show_to_string(sid2)
208  );
209  ++nerr;
210  }
211  else { // good identifier, test conditions objects
212 
213  // check Calibration Slot and Channel
214  const std::vector<HWIdentifier>&
215  calib = clCont->calibSlotLine(sid) ;
216  if(calib.size()==0) {
217  ATH_MSG_ERROR( " No calibration for this channel,hdw id="
218  <<sid.get_compact() );
219  }
220  else {
221  ATH_MSG_VERBOSE( " Calib ID ="<<m_onlineID->show_to_string(calib[0]) );
222  }
223 
224  const ILArRamp::RampRef_t v = pRamp->ADC2DAC(sid, 0 );
225 
226  if(v.size()!=3) {
227  ATH_MSG_ERROR( " Failed to find ramp, hdw id = "
228  <<sid.get_compact() <<" "<< id.get_compact() );
229  m_emid->print(id);
230  }
231 
232  float f = puA2MeV->UA2MEV( sid ) ;
233  if(f == ILAruA2MeV::ERRORCODE)
234  {
235  ATH_MSG_ERROR( " Failed to find uA2MeV, hdw id = "
236  <<sid.get_compact() );
237  ++n_err_uA2MeV;
238  }
239  f = pDAC2uA->DAC2UA( sid ) ;
240  if(f == ILArDAC2uA::ERRORCODE)
241  {
242  ATH_MSG_ERROR( " Failed to find DAC2uA, hdw id = "
243  <<sid.get_compact() );
244  ++n_err_DAC2uA;
245  }
246  f = pNoise->noise( sid , 0 ) ;
247  if( f == ILArNoise::ERRORCODE )
248  {
249  ATH_MSG_ERROR( " Failed to find Noise, hdw id = "
250  <<sid.get_compact() );
251  }
252 
253  ILArAutoCorr::AutoCorrRef_t v2 = pAutoCorr->autoCorr(sid, 0 );
254  if(v2.size()!=4) {
255  ATH_MSG_ERROR( " Failed to find AutoCorr, hdw id = "
256  <<sid.get_compact() );
257  }
258 
259 
260  ILArShape::ShapeRef_t vShape=pShape->Shape(sid, 0,m_tbin);
261  ILArShape::ShapeRef_t vShapeDer=pShape->ShapeDer(sid, 0,m_tbin );
262  if(vShape.size() ==0 || vShapeDer.size() == 0 ) {
263  ATH_MSG_ERROR( " Failed to get Shape or ShapeDer, hdw id = "
264  <<sid.get_compact() << " size = " << vShape.size() << " " << vShapeDer.size());
265  } else
266  {
267  if (msgLvl(MSG::VERBOSE)) {
268  msg()<<MSG::VERBOSE<< " hdw id "<<sid.get_compact() <<endmsg;
269  msg()<<MSG::VERBOSE<<" Shape= " ;
270  for (unsigned int i=0; i < vShape.size(); ++i){
271  msg()<<" " << vShape[i] ;
272  }
273  msg()<<endmsg;
274  msg()<<MSG::VERBOSE<<" ShapeDer=" ;
275  for (unsigned int i=0; i < vShapeDer.size(); ++i){
276  msg()<<" " << vShapeDer[i] ;
277  }
278  msg()<<endmsg;
279  }
280  }
281 
282 
283  // pedestal
284  float vPed = pPedestal->pedestal( sid,0 ) ;
285  if(vPed <= (1.0+LArElecCalib::ERRORCODE)) {
286  ATH_MSG_ERROR( " Failed to find pedestal, hdw id = "
287  <<sid.get_compact() );
288  }
289 
290  // fSampl
291  float fs = pfSampl->FSAMPL( sid ) ;
292  ATH_MSG_VERBOSE( " fsample and hdw id ="<<fs<<" " <<sid.get_compact() );
293 
294  if( fs==ILArfSampl::ERRORCODE ) {
295  ATH_MSG_ERROR( " Failed to find fSampl, hdw id = "
296  <<sid.get_compact() );
297  }
298 
299  // MinBias
300  float mbs = pMinBias->minBiasRMS( sid ) ;
301  if( mbs== ILArMinBias::ERRORCODE) {
302  ATH_MSG_ERROR( " Failed to find MinBias, hdw id = "
303  <<sid.get_compact() );
304  }
305 
306  }
307  }
308  catch (LArID_Exception& except) {
309  // this is allowed.
310  std::string err = m_onlineID->print_to_string(sid);
311  ATH_MSG_VERBOSE( (std::string)except << sid.get_identifier32().get_compact());
312  ATH_MSG_VERBOSE( err );
313  }
314  }
315  ATH_MSG_DEBUG (" Number of Connected Channel ID = " <<nconnected );
316  ATH_MSG_DEBUG (" Number of Valid Channel ID = " <<nch );
317  if(nerr>0) ATH_MSG_ERROR (" Number channels with incorrect mapping= " <<nerr );
318 
319  if (n_err_uA2MeV!=0)
320  ATH_MSG_DEBUG (" Number of channels without uA2MeV "<<n_err_uA2MeV);
321  if (n_err_DAC2uA!=0)
322  ATH_MSG_DEBUG (" Number of channels without DAC2uA"<<n_err_DAC2uA);
323 
324  return StatusCode::SUCCESS;
325 }
326 
327 
329 // FINALIZE:
330 // Note that it is NOT NECESSARY to run the finalize of individual
331 // sub-algorithms. The framework takes care of it.
333 
335 {
336  ATH_MSG_DEBUG ( " finalize ");
337 
338  if(!m_fixShape)
339  return StatusCode::SUCCESS;
340 
341  return StatusCode::SUCCESS;
342 
343 }
344 
345 
346 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArFebRodMapping
Definition: LArFebRodMapping.h:17
ILArPedestal::pedestal
virtual float pedestal(const HWIdentifier &id, int gain) const =0
ILArDAC2uA.h
ILArDAC2uA::DAC2UA
virtual const float & DAC2UA(const HWIdentifier &id) const =0
access to DAC2UA conversion factor index by Identifier, and gain setting
ILAruA2MeV.h
ILArMinBias.h
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
ILArNoise.h
ILAruA2MeV::UA2MEV
virtual const float & UA2MEV(const HWIdentifier &id) const =0
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ILAruA2MeV
Definition: ILAruA2MeV.h:13
ILArPedestal
Definition: ILArPedestal.h:12
LArCalibLineMapping
Definition: LArCalibLineMapping.h:17
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
ILArShape::ShapeDer
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
LArCondDataTest::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArCondDataTest.h:52
LArCondDataTest::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition: LArCondDataTest.h:50
ILArDAC2uA
Definition: ILArDAC2uA.h:13
ILArOFC.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArCondDataTest::m_RodKey
SG::ReadCondHandleKey< LArFebRodMapping > m_RodKey
Definition: LArCondDataTest.h:51
LArCondDataTest::finalize
StatusCode finalize()
Definition: LArCondDataTest.cxx:334
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1942
LArOnlineID_Base::channel_end
id_iterator channel_end() const
Definition: LArOnlineID_Base.cxx:1931
ILArAutoCorr::autoCorr
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ILArNoise
Definition: ILArNoise.h:12
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
ILArAutoCorr
This class defines the interface for accessing AutoCorrelation parameters for each channel @stereotyp...
Definition: ILArAutoCorr.h:29
LArCondDataTest::m_emid
const LArOnlineID * m_emid
Definition: LArCondDataTest.h:53
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArRampMC.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
ILArRamp
Definition: ILArRamp.h:12
ILArfSampl::FSAMPL
virtual const float & FSAMPL(const HWIdentifier &id) const =0
ILArNoise::noise
virtual const float & noise(const HWIdentifier &id, int gain) const =0
ILArMinBias::ERRORCODE
@ ERRORCODE
Definition: ILArMinBias.h:30
LArConditionsChannelSet.h
This file defines the template class used for I/O of conditions data.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ILArMinBias
Definition: ILArMinBias.h:13
AthAlgorithm
Definition: AthAlgorithm.h:47
LArCondDataTest::~LArCondDataTest
~LArCondDataTest()
Definition: LArCondDataTest.cxx:61
LArCondDataTest::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCondDataTest.h:49
ILArRamp::ADC2DAC
virtual RampRef_t ADC2DAC(const HWIdentifier &id, int gain) const =0
LArCondDataTest::execute
StatusCode execute()
Definition: LArCondDataTest.cxx:84
ILArShape.h
AtlasDetectorID::print_to_string
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:655
LArCondDataTest::m_tbin
int m_tbin
Definition: LArCondDataTest.h:54
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ILArfSampl::ERRORCODE
@ ERRORCODE
Definition: ILArfSampl.h:39
LArCondDataTest::LArCondDataTest
LArCondDataTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCondDataTest.cxx:45
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArCondDataTest::initialize
StatusCode initialize()
Definition: LArCondDataTest.cxx:68
ILArDAC2uA::ERRORCODE
@ ERRORCODE
Definition: ILArDAC2uA.h:37
AtlasDetectorID::print
void print(Identifier id, const IdContext *context=0) const
Expanded print out of any identifier.
Definition: AtlasDetectorID.cxx:648
LArCondDataTest::m_fixShape
bool m_fixShape
Definition: LArCondDataTest.h:55
PlotSFuncertainty.calib
calib
Definition: PlotSFuncertainty.py:110
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:157
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1948
ILArRamp.h
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
LArCondDataTest.h
This file contains an algorithm for testing lar conditions data access.
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
ILArPedestal.h
ILArNoise::ERRORCODE
@ ERRORCODE
Definition: ILArNoise.h:39
ILArMinBias::minBiasRMS
virtual const float & minBiasRMS(const HWIdentifier &id) const =0
access to RMS of E in minimum bias events index by Identifier
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
ILArAutoCorr.h
LArElecCalib::ERRORCODE
@ ERRORCODE
Definition: LArCalibErrorCode.h:17
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
ILArShape
Definition: ILArShape.h:13
StoreGateSvc.h
LArOnlineID_Base::channel_begin
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
Definition: LArOnlineID_Base.cxx:1926
LArID_Exception
Exception class for LAr Identifiers.
Definition: LArID_Exception.h:20
ILArfSampl.h
ILAruA2MeV::ERRORCODE
@ ERRORCODE
Definition: ILAruA2MeV.h:35
LArOnlineID.h
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
ILArfSampl
Definition: ILArfSampl.h:14
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
ILArShape::Shape
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0