ATLAS Offline Software
CaloCondBlob2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 
13 CaloCondBlob2Ntuple::CaloCondBlob2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
14  LArCond2NtupleBase(name, pSvcLocator) {
15  declareProperty("Folder",m_folder);
16 
17  m_ntTitle="CaloCondBlob";
18  m_ntpath="/NTUPLES/FILE1/CaloCondBlob";
19 
20 
21 }
22 
24 = default;
25 
27  StatusCode sc;
28 
29 // NTuple::Array<float> values;
30 // NTuple::Item<long> nValues;
31 
32 // sc=m_nt->addItem("nvalues",nValues,0,1000);
33 // if (sc!=StatusCode::SUCCESS)
34 // {ATH_MSG_ERROR( "addItem 'nvalues' failed" );
35 // return StatusCode::FAILURE;
36 // }
37 
38 // sc=m_nt->addItem("values",nValues,values);
39 // if (sc!=StatusCode::SUCCESS)
40 // {ATH_MSG_ERROR( "addItem 'values' failed" );
41 // return StatusCode::FAILURE;
42 // }
43 
44 
45  NTuple::Item<float> value;
46  sc=m_nt->addItem("value",value,0,100);
47  if (sc!=StatusCode::SUCCESS) {
48  ATH_MSG_ERROR( "addItem 'values' failed" );
49  return StatusCode::FAILURE;
50  }
51 
52  const AthenaAttributeList* attrList=nullptr;
53  sc=detStore()->retrieve(attrList,m_folder);
54  if (sc.isFailure()) {
55  ATH_MSG_ERROR( "Failed to retrieve AthenaAttributeList with key " << m_folder );
56  return sc;
57  }
58 
59  const coral::Blob& blob = (*attrList)["CaloCondBlob16M"].data<coral::Blob>();
60  if (blob.size()<3) {
61  ATH_MSG_INFO("Found empty blob, nothing to do");
62  return StatusCode::SUCCESS;
63  }
64 
65  std::unique_ptr<const CaloCondBlobFlt> condBlob (CaloCondBlobFlt::getInstance(blob));
66  ATH_MSG_INFO("Database folder has values for " << condBlob->getNChans() << " channels and " << condBlob->getNGains() << " gains.");
67 
68 
69  const CaloCell_ID* caloCellId;
70  sc = m_detStore->retrieve(caloCellId,"CaloCell_ID");
71  if (sc.isFailure()) {
72  ATH_MSG_ERROR( "Could not get CaloCellID helper !" );
73  return StatusCode::FAILURE;
74  }
75 
77  const LArOnOffIdMapping* cabling=*cablingHdl;
78  if(!cabling) {
79  ATH_MSG_WARNING( "Do not have cabling object LArOnOffIdMapping" );
80  return StatusCode::FAILURE;
81  }
82 
83  const unsigned nChans=condBlob->getNChans();
84  //const usnigend nGains=condBlob->getNGains();
85 
86 
87  for(unsigned h=0;h<nChans;++h) {
88  //add here loop over gains
89  //const Identifier id=caloCellId->cell_id(h);
90  const HWIdentifier hwid=cabling->createSignalChannelIDFromHash(h);
91  fillFromIdentifier(hwid);
92  value= condBlob->getData(h,0,0);
93 
94  sc=ntupleSvc()->writeRecord(m_nt);
95  if (sc!=StatusCode::SUCCESS) {
96  ATH_MSG_ERROR( "writeRecord failed" );
97  return StatusCode::FAILURE;
98  }
99  }//end loop over hash ids
100 
101  ATH_MSG_INFO( "CaloCondBlob2Ntuple has finished." );
102  return StatusCode::SUCCESS;
103 }// end finalize-method.
CaloCondBlob2Ntuple::stop
StatusCode stop()
Definition: CaloCondBlob2Ntuple.cxx:26
CaloCondBlob2Ntuple.h
CaloCondBlobDat::getData
T getData(const unsigned int channel, const unsigned int adc, const unsigned int idx) const
Returns a single T belonging to a channel/gain.
Definition: CaloCondBlobDat.h:134
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCondBlob2Ntuple::m_folder
std::string m_folder
Definition: CaloCondBlob2Ntuple.h:21
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
CaloCondBlob2Ntuple::~CaloCondBlob2Ntuple
~CaloCondBlob2Ntuple()
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
athena.value
value
Definition: athena.py:124
HWIdentifier
Definition: HWIdentifier.h:13
AthenaAttributeList.h
LArCond2NtupleBase
Definition: LArCond2NtupleBase.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
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
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCond2NtupleBase::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCond2NtupleBase.h:89
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:97
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition: LArCond2NtupleBase.h:68
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
CaloCondBlob2Ntuple::CaloCondBlob2Ntuple
CaloCondBlob2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloCondBlob2Ntuple.cxx:13
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
CaloCondBlobBase::getNGains
uint32_t getNGains() const
Returns the number of gains stored for each channel.
Definition: CaloCondBlobBase.h:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition: LArCond2NtupleBase.h:65
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition: LArCond2NtupleBase.cxx:288
CaloCondBlobFlt.h
h
CaloCondBlobFlt::getInstance
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
Definition: CaloCondBlobFlt.cxx:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCond2NtupleBase::m_detStore
StoreGateSvc * m_detStore
Definition: LArCond2NtupleBase.h:81
CaloGain.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
StoreGateSvc.h
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
LArOnlineID.h
CaloCondBlobBase::getNChans
uint32_t getNChans() const
Returns the number of channels stored in the BLOB.
Definition: CaloCondBlobBase.h:231
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20