ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Digitization
MCTruthSimAlgs
src
MergeTrackRecordCollTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MergeTrackRecordCollTool.h
"
6
7
#include "
AthenaKernel/errorcheck.h
"
8
9
MergeTrackRecordCollTool::MergeTrackRecordCollTool
(
const
std::string&
type
,
10
const
std::string& name,
11
const
IInterface* parent) :
12
PileUpToolBase
(
type
, name, parent)
13
{
14
}
15
16
StatusCode
MergeTrackRecordCollTool::initialize
()
17
{
18
ATH_MSG_DEBUG
(
"initialize()"
);
19
ATH_CHECK
(
m_pMergeSvc
.retrieve() );
20
ATH_CHECK
(
m_outputKey
.initialize() );
21
return
StatusCode::SUCCESS;
22
}
23
24
StatusCode
MergeTrackRecordCollTool::prepareEvent
(
const
EventContext&
/*ctx*/
,
unsigned
int
nInputEvents)
25
{
26
ATH_MSG_DEBUG
(
"Calling prepareEvent()"
);
27
ATH_MSG_DEBUG
(
"prepareEvent: there are "
<< nInputEvents <<
" subevents in this event."
);
28
m_firstSubEvent
=
true
;
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
MergeTrackRecordCollTool::processBunchXing
(
int
bunchXing,
33
SubEventIterator
bSubEvents,
34
SubEventIterator
eSubEvents)
35
{
36
ATH_MSG_VERBOSE
(
"processBunchXing()"
);
37
//We are only interested in the TrackRecordCollection for the original event
38
if
(
m_firstSubEvent
&& bunchXing==0) {
39
if
(bSubEvents != eSubEvents) {
40
const
TrackRecordCollection
* oldColl(
nullptr
);
41
if
(
m_pMergeSvc
->retrieveSingleSubEvtData(
m_trRecCollKey
.value(), oldColl,
42
bunchXing, bSubEvents).isSuccess()) {
43
SG::WriteHandle<TrackRecordCollection>
outputCollection(
m_outputKey
);
44
ATH_CHECK
(outputCollection.record(std::make_unique<TrackRecordCollection>()));
45
if
(!outputCollection.isValid()) {
46
ATH_MSG_ERROR
(
"Could not record output TrackRecordCollection "
<< outputCollection.name() <<
" to store "
<< outputCollection.store());
47
return
StatusCode::FAILURE;
48
}
49
50
for
(
const
auto
& trcit : *oldColl) {
51
outputCollection->push_back(
TrackRecord
(trcit) );
52
}
53
ATH_MSG_DEBUG
(
"processBunchXing: copied original event TrackRecordCollection"
);
54
m_firstSubEvent
=
false
;
55
}
56
else
{
57
ATH_MSG_ERROR
(
"processBunchXing: TimedTruthList is empty"
);
58
}
59
}
60
else
{
61
ATH_MSG_ERROR
(
"processBunchXing: Can not find TimedTruthList"
);
62
}
63
}
64
65
return
StatusCode::SUCCESS;
66
}
67
68
StatusCode
MergeTrackRecordCollTool::mergeEvent
(
const
EventContext&
/*ctx*/
)
69
{
70
//Nothing to do here;
71
return
StatusCode::SUCCESS;
72
}
73
74
bool
MergeTrackRecordCollTool::toProcess
(
int
bunchXing)
const
75
{
76
//We are only interested in the TrackRecordCollection for the original event
77
//which should be in BC 0 !
78
return
(bunchXing==0);
79
}
80
81
StatusCode
MergeTrackRecordCollTool::processAllSubEvents
(
const
EventContext& ctx)
82
{
83
ATH_MSG_VERBOSE
(
"processAllSubEvents()"
);
84
85
typedef
PileUpMergeSvc::TimedList<TrackRecordCollection>::type
TimedTruthList;
86
TimedTruthList truthList;
87
if
( (
m_pMergeSvc
->retrieveSubEvtsData(
m_trRecCollKey
.value(), truthList)).isSuccess() ) {
88
if
(truthList.begin() != truthList.end()) {
89
//FIXME we are forced to do a deep copy
90
const
TrackRecordCollection
&oldColl=*(truthList.begin())->second;
91
92
SG::WriteHandle<TrackRecordCollection>
outputCollection(
m_outputKey
, ctx);
93
ATH_CHECK
(outputCollection.record(std::make_unique<TrackRecordCollection>()));
94
if
(!outputCollection.isValid()) {
95
ATH_MSG_ERROR
(
"Could not record output TrackRecordCollection "
<< outputCollection.name() <<
" to store "
<< outputCollection.store());
96
return
StatusCode::FAILURE;
97
}
98
99
for
(
const
auto
& trcit : oldColl) {
100
outputCollection->push_back(
TrackRecord
(trcit) );
101
}
102
103
ATH_MSG_DEBUG
(
"processAllSubEvents: copied original event TrackRecordCollection"
);
104
}
105
else
{
106
ATH_MSG_ERROR
(
"processAllSubEvents: TimedTruthList is empty"
);
107
}
108
}
109
else
{
110
ATH_MSG_ERROR
(
"processAllSubEvents: Can not find TimedTruthList"
);
111
}
112
return
StatusCode::SUCCESS;
113
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition
IPileUpTool.h:22
MergeTrackRecordCollTool.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
MergeTrackRecordCollTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Propagate the TrackRecordCollections to the output StoreGate.
Definition
MergeTrackRecordCollTool.cxx:81
MergeTrackRecordCollTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
called for each active bunch-crossing to process current SubEvents bunchXing is in ns
Definition
MergeTrackRecordCollTool.cxx:32
MergeTrackRecordCollTool::mergeEvent
virtual StatusCode mergeEvent(const EventContext &ctx) override final
called at the end of the subevts loop.
Definition
MergeTrackRecordCollTool.cxx:68
MergeTrackRecordCollTool::m_outputKey
SG::WriteHandleKey< TrackRecordCollection > m_outputKey
Definition
MergeTrackRecordCollTool.h:52
MergeTrackRecordCollTool::initialize
virtual StatusCode initialize() override final
Initialize tool.
Definition
MergeTrackRecordCollTool.cxx:16
MergeTrackRecordCollTool::m_pMergeSvc
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
Definition
MergeTrackRecordCollTool.h:50
MergeTrackRecordCollTool::m_trRecCollKey
StringProperty m_trRecCollKey
Definition
MergeTrackRecordCollTool.h:51
MergeTrackRecordCollTool::MergeTrackRecordCollTool
MergeTrackRecordCollTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
MergeTrackRecordCollTool.cxx:9
MergeTrackRecordCollTool::m_firstSubEvent
bool m_firstSubEvent
Definition
MergeTrackRecordCollTool.h:53
MergeTrackRecordCollTool::prepareEvent
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int nInputEvents) override final
called before the subevts loop.
Definition
MergeTrackRecordCollTool.cxx:24
MergeTrackRecordCollTool::toProcess
virtual bool toProcess(int bunchXing) const override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
Definition
MergeTrackRecordCollTool.cxx:74
PileUpToolBase::PileUpToolBase
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
PileUpToolBase.cxx:7
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
TrackRecord
Definition
TrackRecord.h:12
type
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition
PileUpMergeSvc.h:73
Generated on
for ATLAS Offline Software by
1.17.0