ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AthPoolEx::ReadMeta Class Reference

This class provides an example for reading in file meta data objects from Pool. More...

#include <ReadMeta.h>

Inheritance diagram for AthPoolEx::ReadMeta:
Collaboration diagram for AthPoolEx::ReadMeta:

Public Member Functions

 ReadMeta (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Service Constructor. More...
 
virtual ~ReadMeta ()
 Destructor. More...
 
virtual StatusCode initialize () override
 Gaudi AlgTool Interface method implementations: More...
 
virtual StatusCode beginInputFile (const SG::SourceID &) override
 Function called when a new input file is opened. More...
 
virtual StatusCode endInputFile (const SG::SourceID &) override
 Function called when the currently open input file got completely processed. More...
 
virtual StatusCode metaDataStop () override
 Function writing the collected metadata to the output. More...
 
virtual void handle (const Incident &incident) override
 Incident service handle listening for BeginInputFile and EndInputFile. More...
 

Private Attributes

ServiceHandle< StoreGateSvcm_pMetaDataStore
 
ServiceHandle< StoreGateSvcm_pInputStore
 

Detailed Description

This class provides an example for reading in file meta data objects from Pool.

Definition at line 25 of file ReadMeta.h.

Constructor & Destructor Documentation

◆ ReadMeta()

ReadMeta::ReadMeta ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Standard Service Constructor.

Definition at line 23 of file ReadMeta.cxx.

23  :
24  base_class(type, name, parent),
25  m_pMetaDataStore ("StoreGateSvc/MetaDataStore", name),
26  m_pInputStore ("StoreGateSvc/InputMetaDataStore", name) {
27 }

◆ ~ReadMeta()

ReadMeta::~ReadMeta ( )
virtual

Destructor.

Definition at line 29 of file ReadMeta.cxx.

29  {
30 }

Member Function Documentation

◆ beginInputFile()

StatusCode ReadMeta::beginInputFile ( const SG::SourceID )
overridevirtual

Function called when a new input file is opened.

Definition at line 57 of file ReadMeta.cxx.

58 {
59  ATH_MSG_DEBUG("saw BeginInputFile incident.");
60  if (m_pInputStore->contains<ExampleHitContainer>("PedestalWriteData")) {
61  std::list<SG::ObjectWithVersion<ExampleHitContainer> > allVersions;
62  if (m_pInputStore->retrieveAllVersions(allVersions, "PedestalWriteData").isFailure()) {
63  ATH_MSG_ERROR("Could not retrieve all versions for PedestalWriteData");
64  return StatusCode::FAILURE;
65  }
66  //const ExampleHitContainer* ep;
67  ExampleHitContainer* ep_out = 0;
68  for (SG::ObjectWithVersion<ExampleHitContainer>& obj : allVersions) {
69  const ExampleHitContainer* ep = obj.dataObject.cptr();
70  if (!m_pMetaDataStore->contains<ExampleHitContainer>("PedestalWriteData")) {
71  ep_out = new ExampleHitContainer();
72  const ExampleHit* entry = *ep->begin();
73  ExampleHit* entry_out = new ExampleHit();
74  entry_out->setX(entry->getX());
75  entry_out->setY(entry->getY());
76  entry_out->setZ(entry->getZ());
77  entry_out->setDetector(entry->getDetector());
78  ep_out->push_back(entry_out);
79  if (m_pMetaDataStore->record(ep_out, "PedestalWriteData").isFailure()) {
80  ATH_MSG_ERROR("Could not record DataObject: PedestalWriteData");
81  return StatusCode::FAILURE;
82  }
83  } else {
84  if (m_pMetaDataStore->retrieve(ep_out, "PedestalWriteData").isFailure()) {
85  ATH_MSG_ERROR("Could not find DataObject in output: PedestalWriteData");
86  return StatusCode::FAILURE;
87  }
88  const ExampleHit* entry = *ep->begin();
89  ExampleHit* entry_out = *ep_out->begin();
90  int weight = entry->getDetector().size() - 2;
91  int weight_out = entry_out->getDetector().size() - 2;
92  entry_out->setX((entry->getX() * weight + entry_out->getX() * weight_out) / (weight + weight_out));
93  entry_out->setY((entry->getY() * weight + entry_out->getY() * weight_out) / (weight + weight_out));
94  entry_out->setZ((entry->getZ() * weight + entry_out->getZ() * weight_out) / (weight + weight_out));
95  entry_out->setDetector(entry->getDetector().substr(0, entry->getDetector().size() - 1) + entry_out->getDetector().substr(1));
96  }
97  }
98  if (ep_out != 0) {
99  for (const ExampleHit* obj : *ep_out) {
100  ATH_MSG_INFO("Pedestal x = " << obj->getX() << " y = " << obj->getY() << " z = " << obj->getZ() << " string = " << obj->getDetector());
101  }
102  }
103  }
104 
105  return StatusCode::SUCCESS;
106 }

◆ endInputFile()

virtual StatusCode AthPoolEx::ReadMeta::endInputFile ( const SG::SourceID )
inlineoverridevirtual

Function called when the currently open input file got completely processed.

Definition at line 41 of file ReadMeta.h.

41 {return StatusCode::SUCCESS;}

◆ handle()

void ReadMeta::handle ( const Incident &  incident)
overridevirtual

Incident service handle listening for BeginInputFile and EndInputFile.

Definition at line 47 of file ReadMeta.cxx.

47  {
48  ATH_MSG_DEBUG("handle() " << inc.type());
49  const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
50  if (fileInc == 0) {
51  ATH_MSG_ERROR(" Unable to get FileName from BeginInputFile/EndInputFile incident");
52  return;
53  }
54  ATH_MSG_DEBUG("handle() " << inc.type() << " for " << fileInc->fileName());
55 }

◆ initialize()

StatusCode ReadMeta::initialize ( )
overridevirtual

Gaudi AlgTool Interface method implementations:

Definition at line 32 of file ReadMeta.cxx.

32  {
33  ATH_MSG_INFO("in initialize()");
34 
35  // locate the DetectorStore and initialize our local ptr
36  ATH_CHECK( m_pMetaDataStore.retrieve() );
37  ATH_CHECK( m_pInputStore.retrieve() );
38 
39  // Set to be listener for end of event
40  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", this->name());
41  ATH_CHECK( incSvc.retrieve() );
42  incSvc->addListener(this, "BeginInputFile", 60); // pri has to be < 100 to be after MetaDataSvc.
43  incSvc->addListener(this, "EndInputFile", 50); // pri has to be > 10 to be before MetaDataSvc.
44  return StatusCode::SUCCESS;
45 }

◆ metaDataStop()

virtual StatusCode AthPoolEx::ReadMeta::metaDataStop ( )
inlineoverridevirtual

Function writing the collected metadata to the output.

Definition at line 44 of file ReadMeta.h.

44 {return StatusCode::SUCCESS;}

Member Data Documentation

◆ m_pInputStore

ServiceHandle<StoreGateSvc> AthPoolEx::ReadMeta::m_pInputStore
private

Definition at line 51 of file ReadMeta.h.

◆ m_pMetaDataStore

ServiceHandle<StoreGateSvc> AthPoolEx::ReadMeta::m_pMetaDataStore
private

Definition at line 50 of file ReadMeta.h.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ExampleHit::setY
void setY(double y)
Set the Y coordinate.
Definition: ExampleHit.h:51
AthPoolEx::ReadMeta::m_pMetaDataStore
ServiceHandle< StoreGateSvc > m_pMetaDataStore
Definition: ReadMeta.h:50
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ExampleHit::getY
double getY() const
Definition: ExampleHit.h:37
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ExampleHit::getX
double getX() const
Definition: ExampleHit.h:34
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ExampleHit
This class provides a dummy hit data object for AthenaPool.
Definition: ExampleHit.h:24
ExampleHit::getZ
double getZ() const
Definition: ExampleHit.h:40
ExampleHit::setX
void setX(double x)
Set the X coordinate.
Definition: ExampleHit.h:47
ExampleHit::getDetector
const std::string & getDetector() const
Definition: ExampleHit.h:43
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
AthPoolEx::ReadMeta::m_pInputStore
ServiceHandle< StoreGateSvc > m_pInputStore
Definition: ReadMeta.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition: SGVersionedKey.h:17
python.PyAthena.obj
obj
Definition: PyAthena.py:132
ExampleHitContainer
This class provides a data vector for ExampleHit objects in AthenaPool.
Definition: ExampleHitContainer.h:20
ExampleHit::setZ
void setZ(double z)
Set the Z coordinate.
Definition: ExampleHit.h:55
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ServiceHandle< IIncidentSvc >
ExampleHit::setDetector
void setDetector(const std::string &detector)
Set the detector string.
Definition: ExampleHit.h:59