ATLAS Offline Software
Loading...
Searching...
No Matches
WriteCond.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include "WriteCond.h"
12
13// the user data-class definitions
16
17using namespace AthPoolEx;
18
19//___________________________________________________________________________
20WriteCond::WriteCond(const std::string& name, ISvcLocator* pSvcLocator)
21 : AthReentrantAlgorithm(name, pSvcLocator)
22{
23}
24//___________________________________________________________________________
26 ATH_MSG_INFO("in initialize()");
27
28 auto pPedestal = std::make_unique<ExampleHitContainer>();
29 auto pEntry = std::make_unique<ExampleHit>();
30 pEntry->setDetector("<");
31 pPedestal->push_back(std::move(pEntry));
32
33 ATH_CHECK( detStore()->record(std::move(pPedestal), m_conditionName) );
34
35 ATH_CHECK( m_exampleHitKey.initialize() );
36 return StatusCode::SUCCESS;
37}
38//___________________________________________________________________________
39StatusCode WriteCond::execute (const EventContext& ctx) const {
40 ATH_MSG_DEBUG("in execute()");
41
43 ExampleHitContainer* ep = nullptr;
44 ATH_CHECK( detStore()->retrieve(ep, m_conditionName) );
45 ExampleHit* pEntry = *ep->begin();
46 for (const ExampleHit* hit : *hits) {
47 ATH_MSG_INFO("Hit x = " << hit->getX() << " y = " << hit->getY() << " z = " << hit->getZ() << " detector = " << hit->getDetector());
48 pEntry->setX(pEntry->getX() + m_offset + hit->getX() * (1.0 + m_weight));
49 pEntry->setY(pEntry->getY() + m_offset + hit->getY() * (1.0 + m_weight));
50 pEntry->setZ(pEntry->getZ() + m_offset + hit->getZ() * (1.0 + m_weight));
51 pEntry->setDetector(pEntry->getDetector() + ".");
52 }
53 pEntry->setDetector(pEntry->getDetector() + "o");
54
55 ATH_MSG_INFO("registered all data");
56 return StatusCode::SUCCESS;
57}
58//___________________________________________________________________________
59StatusCode WriteCond::stop() {
60 ExampleHitContainer* ep = nullptr;
61 ATH_CHECK( detStore()->retrieve(ep, m_conditionName) );
62 ExampleHit* pEntry = *ep->begin();
63 pEntry->setDetector(pEntry->getDetector() + ">");
64 ATH_MSG_INFO("in finalize()");
65 ATH_MSG_INFO("Pedestal x = " << pEntry->getX() << " y = " << pEntry->getY() << " z = " << pEntry->getZ() << " string = " << pEntry->getDetector());
66 return StatusCode::SUCCESS;
67}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This file contains the class definition for the ExampleHitContainer class.
Handle class for reading from StoreGate.
This file contains the class definition for the WriteCond class.
const ServiceHandle< StoreGateSvc > & detStore() const
Gaudi::Property< double > m_offset
Definition WriteCond.h:38
virtual StatusCode stop() override final
Definition WriteCond.cxx:59
Gaudi::Property< double > m_weight
Definition WriteCond.h:37
WriteCond(const std::string &name, ISvcLocator *pSvcLocator)
Definition WriteCond.cxx:20
virtual StatusCode execute(const EventContext &ctx) const override final
Definition WriteCond.cxx:39
SG::ReadHandleKey< ExampleHitContainer > m_exampleHitKey
Definition WriteCond.h:40
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations:
Definition WriteCond.cxx:25
Gaudi::Property< std::string > m_conditionName
Definition WriteCond.h:36
An algorithm that can be simultaneously executed in multiple threads.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This class provides a data vector for ExampleHit objects in AthenaPool.
This class provides a dummy hit data object for AthenaPool.
Definition ExampleHit.h:24
void setZ(double z)
Set the Z coordinate.
Definition ExampleHit.h:55
void setX(double x)
Set the X coordinate.
Definition ExampleHit.h:47
double getZ() const
Definition ExampleHit.h:40
void setDetector(const std::string &detector)
Set the detector string.
Definition ExampleHit.h:59
double getX() const
Definition ExampleHit.h:34
void setY(double y)
Set the Y coordinate.
Definition ExampleHit.h:51
double getY() const
Definition ExampleHit.h:37
const std::string & getDetector() const
Definition ExampleHit.h:43