ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
AthenaPoolExample
AthenaPoolExampleAlgorithms
src
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
14
#include "
AthenaPoolExampleData/ExampleHitContainer.h
"
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
}
24
//___________________________________________________________________________
25
StatusCode
WriteCond::initialize
() {
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
//___________________________________________________________________________
39
StatusCode
WriteCond::execute
(
const
EventContext& ctx)
const
{
40
ATH_MSG_DEBUG
(
"in execute()"
);
41
42
SG::ReadHandle<ExampleHitContainer>
hits (
m_exampleHitKey
, ctx);
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
//___________________________________________________________________________
59
StatusCode
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ExampleHitContainer.h
This file contains the class definition for the ExampleHitContainer class.
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
ReadHandle.h
Handle class for reading from StoreGate.
WriteCond.h
This file contains the class definition for the WriteCond class.
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthPoolEx::WriteCond::m_offset
Gaudi::Property< double > m_offset
Definition
WriteCond.h:38
AthPoolEx::WriteCond::stop
virtual StatusCode stop() override final
Definition
WriteCond.cxx:59
AthPoolEx::WriteCond::m_weight
Gaudi::Property< double > m_weight
Definition
WriteCond.h:37
AthPoolEx::WriteCond::WriteCond
WriteCond(const std::string &name, ISvcLocator *pSvcLocator)
Definition
WriteCond.cxx:20
AthPoolEx::WriteCond::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
WriteCond.cxx:39
AthPoolEx::WriteCond::m_exampleHitKey
SG::ReadHandleKey< ExampleHitContainer > m_exampleHitKey
Definition
WriteCond.h:40
AthPoolEx::WriteCond::initialize
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations:
Definition
WriteCond.cxx:25
AthPoolEx::WriteCond::m_conditionName
Gaudi::Property< std::string > m_conditionName
Definition
WriteCond.h:36
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ExampleHitContainer
This class provides a data vector for ExampleHit objects in AthenaPool.
Definition
ExampleHitContainer.h:20
ExampleHit
This class provides a dummy hit data object for AthenaPool.
Definition
ExampleHit.h:24
ExampleHit::setZ
void setZ(double z)
Set the Z coordinate.
Definition
ExampleHit.h:55
ExampleHit::setX
void setX(double x)
Set the X coordinate.
Definition
ExampleHit.h:47
ExampleHit::getZ
double getZ() const
Definition
ExampleHit.h:40
ExampleHit::setDetector
void setDetector(const std::string &detector)
Set the detector string.
Definition
ExampleHit.h:59
ExampleHit::getX
double getX() const
Definition
ExampleHit.h:34
ExampleHit::setY
void setY(double y)
Set the Y coordinate.
Definition
ExampleHit.h:51
ExampleHit::getY
double getY() const
Definition
ExampleHit.h:37
ExampleHit::getDetector
const std::string & getDetector() const
Definition
ExampleHit.h:43
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
AthPoolEx
Definition
PassNoneFilter.h:16
Generated on
for ATLAS Offline Software by
1.17.0