ATLAS Offline Software
MuonSpectrometer
MuonTruthAlgs
src
MuonDetailedTrackTruthMaker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 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
//================================================================
14
MuonDetailedTrackTruthMaker::MuonDetailedTrackTruthMaker
(
const
std::string&
name
, ISvcLocator* pSvcLocator) :
15
AthReentrantAlgorithm
(
name
, pSvcLocator) {}
16
17
// Initialize method
18
// -----------------------------------------------------------------------------------------------------
19
StatusCode
MuonDetailedTrackTruthMaker::initialize
() {
20
ATH_MSG_DEBUG
(
"MuonDetailedTrackTruthMaker::initialize()"
);
21
22
if
(
m_PRD_TruthNames
.empty()) {
23
ATH_MSG_FATAL
(
"No PRD truth collections have been configured for processing"
);
24
return
StatusCode::FAILURE;
25
}
26
//----------------
27
ATH_CHECK
(
m_truthTool
.retrieve());
28
ATH_MSG_DEBUG
(
"Retrieved tool "
<<
m_truthTool
);
29
30
m_detailedTrackTruthNames
.resize(
m_trackCollectionNames
.size());
31
for
(
unsigned
int
i
= 0;
i
<
m_trackCollectionNames
.size();
i
++) {
32
m_detailedTrackTruthNames
.at(
i
)=
m_trackCollectionNames
.at(
i
).key() +
"DetailedTruth"
;;
33
ATH_MSG_INFO
(
"process "
<<
m_trackCollectionNames
.at(
i
).key() <<
" for detailed truth collection "
34
<<
m_detailedTrackTruthNames
.at(
i
).key());
35
}
36
37
ATH_CHECK
(
m_trackCollectionNames
.initialize());
38
ATH_CHECK
(
m_PRD_TruthNames
.initialize());
39
ATH_CHECK
(
m_detailedTrackTruthNames
.initialize());
40
41
//----------------
42
return
StatusCode::SUCCESS;
43
}
44
45
// -----------------------------------------------------------------------------------------------------
46
StatusCode
MuonDetailedTrackTruthMaker::execute
(
const
EventContext& ctx)
const
{
47
ATH_MSG_DEBUG
(
"MuonDetailedTrackTruthMaker::execute()"
);
48
49
//----------------------------------------------------------------
50
// Retrieve prep raw data truth
51
std::vector<const PRD_MultiTruthCollection*> prdCollectionVector;
52
for
(
SG::ReadHandle<PRD_MultiTruthCollection>
&
col
:
m_PRD_TruthNames
.makeHandles(ctx)) {
53
if
(!
col
.isPresent())
continue
;
54
if
(!
col
.isValid()) {
55
ATH_MSG_WARNING
(
"invalid PRD_MultiTruthCollection "
<<
col
.name());
56
return
StatusCode::FAILURE;
57
}
58
prdCollectionVector.push_back(
col
.cptr());
59
}
60
61
//----------------------------------------------------------------
62
// Retrieve track collections
63
64
int
i
= 0;
65
for
(
SG::ReadHandle<TrackCollection>
& tcol :
m_trackCollectionNames
.makeHandles(ctx)) {
66
if
(!tcol.isValid()) {
67
ATH_MSG_WARNING
(
"invalid TrackCollection "
<< tcol.name());
68
return
StatusCode::FAILURE;
69
}
70
if
(!tcol.isPresent())
continue
;
71
72
//----------------------------------------------------------------
73
// Produce and store the output.
74
75
SG::WriteHandle<DetailedTrackTruthCollection>
dttc(
m_detailedTrackTruthNames
.at(
i
), ctx);
76
ATH_CHECK
(dttc.
record
(std::make_unique<DetailedTrackTruthCollection>()));
77
dttc->
setTrackCollection
(tcol.cptr());
78
m_truthTool
->buildDetailedTrackTruth(dttc.
ptr
(), *(tcol.cptr()), prdCollectionVector, ctx);
79
i
++;
80
}
81
return
StatusCode::SUCCESS;
82
}
MuonDetailedTrackTruthMaker::m_PRD_TruthNames
SG::ReadHandleKeyArray< PRD_MultiTruthCollection > m_PRD_TruthNames
Definition:
MuonDetailedTrackTruthMaker.h:35
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition:
AthMsgStreamMacros.h:34
MuonDetailedTrackTruthMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition:
MuonDetailedTrackTruthMaker.cxx:46
MuonDetailedTrackTruthMaker::MuonDetailedTrackTruthMaker
MuonDetailedTrackTruthMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
MuonDetailedTrackTruthMaker.cxx:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
SG::ReadHandle
Definition:
StoreGate/StoreGate/ReadHandle.h:70
MuonDetailedTrackTruthMaker::initialize
virtual StatusCode initialize() override
Definition:
MuonDetailedTrackTruthMaker.cxx:19
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition:
AthReentrantAlgorithm.h:83
MuonDetailedTrackTruthMaker::m_detailedTrackTruthNames
SG::WriteHandleKeyArray< DetailedTrackTruthCollection > m_detailedTrackTruthNames
Definition:
MuonDetailedTrackTruthMaker.h:42
MuonDetailedTrackTruthMaker::m_trackCollectionNames
SG::ReadHandleKeyArray< TrackCollection > m_trackCollectionNames
Definition:
MuonDetailedTrackTruthMaker.h:38
lumiFormat.i
int i
Definition:
lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
MuonDetailedTrackTruthMaker.h
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:228
DetailedTrackTruthCollection::setTrackCollection
void setTrackCollection(const DataLink< TrackCollection > tracks)
Definition:
DetailedTrackTruthCollection.h:26
MuonDetailedTrackTruthMaker::m_truthTool
ToolHandle< Trk::IDetailedTrackTruthBuilder > m_truthTool
Definition:
MuonDetailedTrackTruthMaker.h:45
query_example.col
col
Definition:
query_example.py:7
SG::WriteHandle
Definition:
StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
Generated on Fri Jan 10 2025 21:14:44 for ATLAS Offline Software by
1.8.18