ATLAS Offline Software
LArAutoCorr2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
11 LArAutoCorr2Ntuple::LArAutoCorr2Ntuple(const std::string& name, ISvcLocator* pSvcLocator)
12  : LArCond2NtupleBase(name, pSvcLocator)
13 {
14  declareProperty("Nsamples", m_nsamples=32);
15 
16  m_ntTitle="AutoCorrelation";
17  m_ntpath="/NTUPLES/FILE1/AUTOCORR";
18 
19 }
20 
24 }
25 
27 = default;
28 
30 
31  ATH_MSG_INFO( "LArAutoCorr2Ntuple in stop " << m_nt);
32 
33  StatusCode sc;
34  NTuple::Array<float> cov;
35  NTuple::Item<long> gain, cellIndex;
36  sc=m_nt->addItem("gain",gain,0,3);
37  if (sc!=StatusCode::SUCCESS) {
38  ATH_MSG_ERROR( "addItem 'gain' failed" );
39  return StatusCode::FAILURE;
40  }
41 
42  sc=m_nt->addItem("cellIndex",cellIndex,0,200000);
43  if (sc!=StatusCode::SUCCESS) {
44  ATH_MSG_ERROR( "addItem 'cellIndex' failed" );
45  return StatusCode::FAILURE;
46  }
47 
48  sc=m_nt->addItem("covr",m_nsamples-1,cov);
49  if (sc!=StatusCode::SUCCESS) {
50  ATH_MSG_ERROR( "addItem 'covr' failed" );
51  return StatusCode::FAILURE;
52  }
53 
54  ATH_MSG_DEBUG( "LArAutoCorr2Ntuple reading container " << m_objKey.key());
55  // For compatibility with existing configurations, look in the detector
56  // store first, then in conditions.
57  const ILArAutoCorr* larAutoCorr=nullptr;
58  larAutoCorr = detStore()->tryConstRetrieve<ILArAutoCorr>(m_objKey.key());
59  if(!larAutoCorr) {
60  ATH_MSG_DEBUG( "No ILArAutoCorr found, trying LArAutoCorrComplete " << m_objKey.key());
61  const LArAutoCorrComplete *larComplete =
62  detStore()->tryConstRetrieve<LArAutoCorrComplete>(m_objKey.key());
63  if(larComplete) {
64  larAutoCorr = larComplete;
65  } else {
66  ATH_MSG_DEBUG( "LArAutoCorr2Ntuple reading conditions" );
68  larAutoCorr = *acHdl;
69  }
70  }
71  if(larAutoCorr==nullptr){
72  ATH_MSG_ERROR( "Unable to retrieve ILArAutoCorr with key " << m_objKey.key() << " neither from DetectorStore neither from conditions" );
73  return StatusCode::FAILURE;
74  }
75 
76  unsigned cellCounter=0;
77  unsigned cellZeroCounter=0;
78  for ( unsigned igain=CaloGain::LARHIGHGAIN;
80  for (HWIdentifier hwid : m_onlineId->channel_range()) {
81  ILArAutoCorr::AutoCorrRef_t corr=larAutoCorr->autoCorr(hwid,igain);
82 
83  if (corr.size()>0) {
84  fillFromIdentifier(hwid);
85  gain = igain;
86  cellIndex = cellCounter;
87  for(unsigned i=0;i<m_nsamples-1 && i<corr.size();i++)
88  cov[i] = corr[i];
89 
90  sc = ntupleSvc()->writeRecord(m_nt);
91  if (sc!=StatusCode::SUCCESS) {
92  ATH_MSG_ERROR( "writeRecord failed" );
93  return StatusCode::FAILURE;
94  }
95  cellCounter++;
96  } else { ++cellZeroCounter;}//end if size>0
97  }//end if loop over cells
98  }//end if loop over gains
99 
100  ATH_MSG_INFO( "LArAutoCorr2Ntuple has finished, " << cellCounter << "records written, " << cellZeroCounter << " zero length vectors" );
101  return StatusCode::SUCCESS;
102 }// end finalize-method.
103 
LArAutoCorr2Ntuple::m_nsamples
unsigned m_nsamples
Definition: LArAutoCorr2Ntuple.h:48
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArAutoCorr2Ntuple::stop
virtual StatusCode stop()
Definition: LArAutoCorr2Ntuple.cxx:29
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition: LArCond2NtupleBase.cxx:33
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
ILArAutoCorr::autoCorr
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
LArAutoCorrComplete
This class implements the ILArAutoCorr interface.
Definition: LArAutoCorrComplete.h:26
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnlineID_Base::channel_range
id_range channel_range() const
Definition: LArOnlineID_Base.cxx:1932
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArAutoCorr2Ntuple::initialize
virtual StatusCode initialize()
Definition: LArAutoCorr2Ntuple.cxx:21
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
LArAutoCorr2Ntuple::LArAutoCorr2Ntuple
LArAutoCorr2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArAutoCorr2Ntuple.cxx:11
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArAutoCorr2Ntuple::m_objKey
SG::ReadCondHandleKey< ILArAutoCorr > m_objKey
Definition: LArAutoCorr2Ntuple.h:45
LArAutoCorrComplete.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition: LArCond2NtupleBase.h:85
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArAutoCorr2Ntuple.h
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
LArAutoCorr2Ntuple::~LArAutoCorr2Ntuple
~LArAutoCorr2Ntuple()
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
StoreGateSvc.h
LArOnlineID.h
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38