ATLAS Offline Software
WriteCond.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "WriteCond.h"
12 
13 // the user data-class defintions
15 #include "StoreGate/ReadHandle.h"
16 
17 using namespace AthPoolEx;
18 
19 //___________________________________________________________________________
20 WriteCond::WriteCond(const std::string& name, ISvcLocator* pSvcLocator)
21  : AthReentrantAlgorithm(name, pSvcLocator)
22 {
23  declareProperty("ConditionName", m_conditionName = "PedestalWriteData");
24  declareProperty("Weight", m_weight = 0.0);
25  declareProperty("Offset", m_offset = 0.0);
26 }
27 //___________________________________________________________________________
29 }
30 //___________________________________________________________________________
32  ATH_MSG_INFO("in initialize()");
33 
34  ExampleHitContainer* pPedestal = new ExampleHitContainer();
35  ExampleHit* pEntry = new ExampleHit();
36  pEntry->setDetector("<");
37  pPedestal->push_back(pEntry);
38 
39  if (detStore()->record(pPedestal, m_conditionName).isFailure()) {
40  ATH_MSG_ERROR("could not register Pedestal Object");
41  return StatusCode::FAILURE;
42  }
43 
45  return StatusCode::SUCCESS;
46 }
47 //___________________________________________________________________________
48 StatusCode WriteCond::execute (const EventContext& ctx) const {
49  ATH_MSG_DEBUG("in execute()");
50 
52  ExampleHitContainer* ep = nullptr;
53  if (detStore()->retrieve(ep, m_conditionName).isFailure()) {
54  ATH_MSG_ERROR("Could not find ExampleHitContainer/" << m_conditionName);
55  return StatusCode::FAILURE;
56  }
57  ExampleHit* pEntry = *ep->begin();
58  for (const ExampleHit* hit : *hits) {
59  ATH_MSG_INFO("Hit x = " << hit->getX() << " y = " << hit->getY() << " z = " << hit->getZ() << " detector = " << hit->getDetector());
60  pEntry->setX(pEntry->getX() + m_offset + hit->getX() * (1.0 + m_weight));
61  pEntry->setY(pEntry->getY() + m_offset + hit->getY() * (1.0 + m_weight));
62  pEntry->setZ(pEntry->getZ() + m_offset + hit->getZ() * (1.0 + m_weight));
63  pEntry->setDetector(pEntry->getDetector() + ".");
64  }
65  pEntry->setDetector(pEntry->getDetector() + "o");
66 
67  ATH_MSG_INFO("registered all data");
68  return StatusCode::SUCCESS;
69 }
70 //___________________________________________________________________________
72  ExampleHitContainer* ep = nullptr;
73  if (detStore()->retrieve(ep, m_conditionName).isFailure()) {
74  ATH_MSG_ERROR("Could not find DataObject");
75  return StatusCode::FAILURE;
76  }
77  ExampleHit* pEntry = *ep->begin();
78  pEntry->setDetector(pEntry->getDetector() + ">");
79  ATH_MSG_INFO("in finalize()");
80  ATH_MSG_INFO("Pedestal x = " << pEntry->getX() << " y = " << pEntry->getY() << " z = " << pEntry->getZ() << " string = " << pEntry->getDetector());
81  return StatusCode::SUCCESS;
82 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AthPoolEx::WriteCond::WriteCond
WriteCond(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: WriteCond.cxx:20
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthPoolEx::WriteCond::m_conditionName
StringProperty m_conditionName
Definition: WriteCond.h:37
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ExampleHit::setY
void setY(double y)
Set the Y coordinate.
Definition: ExampleHit.h:51
AthPoolEx::WriteCond::m_offset
DoubleProperty m_offset
Definition: WriteCond.h:39
AthPoolEx::WriteCond::stop
virtual StatusCode stop() override
Definition: WriteCond.cxx:71
ExampleHit::getY
double getY() const
Definition: ExampleHit.h:37
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthPoolEx::WriteCond::m_weight
DoubleProperty m_weight
Definition: WriteCond.h:38
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
WriteCond.h
This file contains the class definition for the WriteCond class.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ExampleHit::getX
double getX() const
Definition: ExampleHit.h:34
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
AthPoolEx::WriteCond::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: WriteCond.cxx:31
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
AthPoolEx::WriteCond::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: WriteCond.cxx:48
AthPoolEx
Definition: PassNoneFilter.h:16
ExampleHitContainer.h
This file contains the class definition for the ExampleHitContainer class.
ReadHandle.h
Handle class for reading from StoreGate.
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.
AthPoolEx::WriteCond::~WriteCond
virtual ~WriteCond()
Destructor.
Definition: WriteCond.cxx:28
AthPoolEx::WriteCond::m_exampleHitKey
SG::ReadHandleKey< ExampleHitContainer > m_exampleHitKey
Definition: WriteCond.h:41
ExampleHit::setDetector
void setDetector(const std::string &detector)
Set the detector string.
Definition: ExampleHit.h:59