ATLAS Offline Software
Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "WriteData.h"
12 
13 // the user data-class defintions
15 #include "StoreGate/WriteHandle.h"
16 
17 using namespace AthPoolEx;
18 
19 //___________________________________________________________________________
20 WriteData::WriteData(const std::string& name, ISvcLocator* pSvcLocator)
21  : AthReentrantAlgorithm(name, pSvcLocator)
22 {
23 }
24 //___________________________________________________________________________
26 }
27 //___________________________________________________________________________
29  ATH_MSG_INFO("in initialize()");
32  return StatusCode::SUCCESS;
33 }
34 //___________________________________________________________________________
35 StatusCode WriteData::execute (const EventContext& ctx) const {
36  ATH_MSG_DEBUG("in execute()");
37 
38  int eventNumber = ctx.eventID().event_number();
39  int runNumber = ctx.eventID().run_number();
40  ATH_MSG_INFO("EventInfo event: " << eventNumber << " run: " << runNumber);
41 
43  ATH_CHECK( hits.record( std::make_unique<ExampleHitContainer>() ) );
44  for (int i = 0; i < 10; i++) {
45  auto hitObj = std::make_unique<ExampleHit>();
46  hitObj->setX(1.2346 + eventNumber * 100 + 3.21 * i);
47  hitObj->setY(-2.346 + runNumber * 100 - 5.6789 * i);
48  hitObj->setZ(34.567 - eventNumber * 100 + 87.6 / (i + 0.456));
49  hitObj->setDetector("DummyHitDetector");
50  hits->push_back(std::move (hitObj));
51  }
52 
53  if (eventNumber == 14) {
54  ATH_MSG_INFO("Now creating ExampleHit alias for event: " << eventNumber);
55  ATH_CHECK( hits.alias (m_aliasKey) );
56  }
57  ATH_MSG_INFO("registered all data");
58  return StatusCode::SUCCESS;
59 }
60 //___________________________________________________________________________
62  ATH_MSG_INFO("in finalize()");
63  return StatusCode::SUCCESS;
64 }
AthPoolEx::WriteData::m_aliasKey
SG::WriteHandleKey< ExampleHitContainer > m_aliasKey
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.h:37
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthPoolEx::WriteData::~WriteData
virtual ~WriteData()
Destructor.
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx:25
AthPoolEx::WriteData::finalize
virtual StatusCode finalize() override
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx:61
AthPoolEx::WriteData::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx:35
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthPoolEx::WriteData::m_exampleHitKey
SG::WriteHandleKey< ExampleHitContainer > m_exampleHitKey
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.h:36
WriteHandle.h
Handle class for recording to StoreGate.
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
AthPoolEx::WriteData::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx:28
AthPoolEx
Definition: PassNoneFilter.h:16
ExampleHitContainer.h
This file contains the class definition for the ExampleHitContainer class.
AthPoolEx::WriteData::WriteData
WriteData(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/WriteData.cxx:20
WriteData.h
This file contains the class definition for the WriteData class.