ATLAS Offline Software
LArHVPathologyDbTool.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 #include "LArHVPathologyDbTool.h"
7 
9 #include "CoralBase/AttributeListException.h"
10 #include "CoralBase/Blob.h"
11 
12 #include "TBufferFile.h"
13 #include "TClass.h"
14 
15 
17  ,const std::string& name
18  ,const IInterface* parent)
20 {
21  declareInterface<ILArHVPathologyDbTool>(this);
22 }
23 
25 = default;
26 
28 {
29  return StatusCode::SUCCESS;
30 }
31 
33 {
34  return StatusCode::SUCCESS;
35 }
36 
39 {
40  AthenaAttributeList* attrList = newAttrList();
41 
42  (*attrList)["blobVersion"].data<unsigned int>()=(unsigned int)0;
43  coral::Blob& blob=(*attrList)["Constants"].data<coral::Blob>();
44 
45  TClass* klass = TClass::GetClass("LArHVPathologiesDb");
46  if (klass==nullptr) {
47  ATH_MSG_ERROR ( "Can't find TClass LArHVPathologiesDb" );
48  return nullptr;
49  }
50  else
51  ATH_MSG_DEBUG ( "Got TClass LArHVPathologiesDb" );
52 
53  TBufferFile buf(TBuffer::kWrite);
54 
55  if(buf.WriteObjectAny(&pathologyContainer, klass)!=1) {
56  ATH_MSG_ERROR ( "Failed to stream LArHVPathologiesDb" );
57  return nullptr;
58  }
59 
60  blob.resize(buf.Length());
61  void* adr = blob.startingAddress();
62  memcpy(adr,buf.Buffer(),buf.Length());
63  return attrList;
64 }
65 
66 
69 {
70  coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
71  spec->extend("blobVersion","unsigned int"); //Should allow schema evolution if needed
72  spec->extend("Constants","blob"); //Holds the container
73  return new AthenaAttributeList(*spec);
74 }
75 
76 
77 
79 {
80  try {
81  const unsigned blobVersion=attrList["blobVersion"].data<unsigned int>();
82  const coral::Blob& blob = attrList["Constants"].data<coral::Blob>();
83 
84  if (blobVersion!=0) {
85  ATH_MSG_ERROR ( "Can't interpret BLOB version " << blobVersion );
86  return nullptr;
87  }
88 
89  TClass* klass = TClass::GetClass("LArHVPathologiesDb");
90  if(klass==nullptr){
91  ATH_MSG_ERROR ( "Can't find TClass LArHVPathologiesDb" );
92  return nullptr;
93  }
94  else
95  ATH_MSG_DEBUG ( "Got TClass LArHVPathologiesDb" );
96 
97  void* data ATLAS_THREAD_SAFE = const_cast<void*> (blob.startingAddress());
98  TBufferFile buf(TBuffer::kRead, blob.size(), data, false);
99  LArHVPathologiesDb* container = (LArHVPathologiesDb*)buf.ReadObjectAny(klass);
100  return container;
101  }catch (coral::AttributeListException &e) {
102  ATH_MSG_ERROR ( e.what() );
103  }
104  return nullptr;
105 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LArHVPathologyDbTool::initialize
virtual StatusCode initialize() override
Definition: LArHVPathologyDbTool.cxx:27
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
AthenaAttributeList.h
LArHVPathologyDbTool::LArHVPathologyDbTool
LArHVPathologyDbTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArHVPathologyDbTool.cxx:16
LArHVPathologyDbTool::hvPathology2AttrList
virtual AthenaAttributeList * hvPathology2AttrList(const LArHVPathologiesDb &) const override
Transform LArCellHVPathologyDBContainer into Attribute List.
Definition: LArHVPathologyDbTool.cxx:38
klass
This class describe the base functionalities of a HypoTool used by the ComboAlg.
LArHVPathologiesDb.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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
LArHVPathologyDbTool::newAttrList
static AthenaAttributeList * newAttrList()
Definition: LArHVPathologyDbTool.cxx:68
WriteCalibToCool.blobVersion
blobVersion
Definition: WriteCalibToCool.py:82
LArHVPathologiesDb
Definition: LArHVPathologiesDb.h:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
LArHVPathologyDbTool::~LArHVPathologyDbTool
virtual ~LArHVPathologyDbTool()
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
AthAlgTool
Definition: AthAlgTool.h:26
LArHVPathologyDbTool::finalize
virtual StatusCode finalize() override
Definition: LArHVPathologyDbTool.cxx:32
LArHVPathologyDbTool::attrList2HvPathology
virtual LArHVPathologiesDb * attrList2HvPathology(const AthenaAttributeList &) const override
Transform Attribute List into LArDBCellHVPathologyDBContainer NB: clients must delete returned pointe...
Definition: LArHVPathologyDbTool.cxx:78
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
LArHVPathologyDbTool.h