ATLAS Offline Software
Loading...
Searching...
No Matches
GenBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/DataSvc.h"
8#include <fstream>
9
10
11GenBase::GenBase(const std::string& name, ISvcLocator* pSvcLocator)
12 : AthAlgorithm(name, pSvcLocator)
13{
14}
15
16
17StatusCode GenBase::initialize() {
18 ATH_CHECK( m_mcevents_const.initialize() );
20
21 // Get the particle property service
22 ATH_CHECK(m_ppSvc.retrieve());
23 return StatusCode::SUCCESS;
24}
25
26
29 // Make a new MC event collection if necessary
30 McEventCollection* mcevents = nullptr;
31 if (!evtStore()->contains<McEventCollection>(m_mcEventKey) && m_mkMcEvent) {
32 ATH_MSG_DEBUG("Creating new McEventCollection in the event store");
33 mcevents = new McEventCollection();
34 if (evtStore()->record(mcevents, m_mcEventKey).isFailure())
35 ATH_MSG_ERROR("Failed to record a new McEventCollection");
36 }
37 else {
38 const McEventCollection* mecc = 0;
39
40 if (evtStore()->retrieve (mecc, m_mcEventKey).isFailure())
41 ATH_MSG_ERROR("Failed to retrieve McEventCollection");
42
43 mcevents = const_cast<McEventCollection*> (&(*mecc));
44 }
45
46 return mcevents;
47}
48
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
McEventCollection *GenBase::events ATLAS_NOT_CONST_THREAD_SAFE()
Access the current event's McEventCollection.
Definition GenBase.cxx:28
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
std::string m_mcEventKey
StoreGate key for the MC event collection (defaults to GEN_EVENT)
Definition GenBase.h:136
virtual StatusCode initialize() override
Definition GenBase.cxx:17
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
Definition GenBase.h:144
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:147
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114