ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonTruthAlgs
src
MuonDetailedTrackTruthMaker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Algorithm producing truth info for PrepRawData, keeping all MC particles contributed to a PRD.
6
// A. Gaponenko, 2006
7
8
#include "
MuonTruthAlgs/MuonDetailedTrackTruthMaker.h
"
9
10
#include <iterator>
11
#include <vector>
12
13
StatusCode
MuonDetailedTrackTruthMaker::initialize
() {
14
ATH_MSG_DEBUG
(
"MuonDetailedTrackTruthMaker::initialize()"
);
15
16
if
(
m_PRD_TruthNames
.empty()) {
17
ATH_MSG_FATAL
(
"No PRD truth collections have been configured for processing"
);
18
return
StatusCode::FAILURE;
19
}
20
//----------------
21
ATH_CHECK
(
m_truthTool
.retrieve());
22
ATH_MSG_DEBUG
(
"Retrieved tool "
<<
m_truthTool
);
23
24
m_detailedTrackTruthNames
.resize(
m_trackCollectionNames
.size());
25
for
(
unsigned
int
i = 0; i <
m_trackCollectionNames
.size(); i++) {
26
m_detailedTrackTruthNames
.at(i)=
m_trackCollectionNames
.at(i).key() +
"DetailedTruth"
;;
27
ATH_MSG_INFO
(
"process "
<<
m_trackCollectionNames
.at(i).key() <<
" for detailed truth collection "
28
<<
m_detailedTrackTruthNames
.at(i).key());
29
}
30
31
ATH_CHECK
(
m_trackCollectionNames
.initialize());
32
ATH_CHECK
(
m_PRD_TruthNames
.initialize());
33
ATH_CHECK
(
m_detailedTrackTruthNames
.initialize());
34
35
//----------------
36
return
StatusCode::SUCCESS;
37
}
38
39
// -----------------------------------------------------------------------------------------------------
40
StatusCode
MuonDetailedTrackTruthMaker::execute
(
const
EventContext& ctx)
const
{
41
ATH_MSG_DEBUG
(
"MuonDetailedTrackTruthMaker::execute()"
);
42
43
//----------------------------------------------------------------
44
// Retrieve prep raw data truth
45
std::vector<const PRD_MultiTruthCollection*> prdCollectionVector;
46
for
(
const
auto
& truthKey :
m_PRD_TruthNames
){
47
prdCollectionVector.emplace_back(
nullptr
);
48
ATH_CHECK
(
SG::get
(prdCollectionVector.back(), truthKey, ctx));
49
}
50
51
ATH_MSG_DEBUG
(
"Loaded in total "
<<prdCollectionVector.size()<<
" prd truth collections"
);
52
//----------------------------------------------------------------
53
// Retrieve track collections
54
55
int
i = 0;
56
for
(
const
auto
& trkKey :
m_trackCollectionNames
) {
57
const
TrackCollection
* tcol{
nullptr
};
58
ATH_CHECK
(
SG::get
(tcol, trkKey, ctx));
59
60
//----------------------------------------------------------------
61
// Produce and store the output.
62
63
SG::WriteHandle
dttc(
m_detailedTrackTruthNames
.at(i), ctx);
64
ATH_MSG_DEBUG
(
"Write detailed collection "
<<
m_detailedTrackTruthNames
.at(i).fullKey());
65
ATH_CHECK
(dttc.
record
(std::make_unique<DetailedTrackTruthCollection>()));
66
dttc->setTrackCollection(tcol);
67
m_truthTool
->buildDetailedTrackTruth(dttc.
ptr
(), *tcol, prdCollectionVector, ctx);
68
i++;
69
}
70
return
StatusCode::SUCCESS;
71
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MuonDetailedTrackTruthMaker.h
TrackCollection
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Definition
TrackCollection.h:19
MuonDetailedTrackTruthMaker::m_detailedTrackTruthNames
SG::WriteHandleKeyArray< DetailedTrackTruthCollection > m_detailedTrackTruthNames
Definition
MuonDetailedTrackTruthMaker.h:42
MuonDetailedTrackTruthMaker::m_truthTool
ToolHandle< Trk::IDetailedTrackTruthBuilder > m_truthTool
Definition
MuonDetailedTrackTruthMaker.h:45
MuonDetailedTrackTruthMaker::initialize
virtual StatusCode initialize() override
Definition
MuonDetailedTrackTruthMaker.cxx:13
MuonDetailedTrackTruthMaker::m_PRD_TruthNames
SG::ReadHandleKeyArray< PRD_MultiTruthCollection > m_PRD_TruthNames
Definition
MuonDetailedTrackTruthMaker.h:35
MuonDetailedTrackTruthMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
MuonDetailedTrackTruthMaker.cxx:40
MuonDetailedTrackTruthMaker::m_trackCollectionNames
SG::ReadHandleKeyArray< TrackCollection > m_trackCollectionNames
Definition
MuonDetailedTrackTruthMaker.h:38
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0