ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
TruthJiveXML
src
TruthMuonTrackRetriever.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
#include "
TruthMuonTrackRetriever.h
"
6
7
#include "
AtlasHepMC/GenParticle.h
"
8
#include "
TrackRecord/TrackRecord.h
"
9
#include "
TrackRecord/TrackRecordCollection.h
"
10
#include "CLHEP/Geometry/Point3D.h"
11
#include "CLHEP/Geometry/Vector3D.h"
12
#include "CLHEP/Units/SystemOfUnits.h"
13
#include "
TruthUtils/MagicNumbers.h
"
14
15
16
namespace
JiveXML
{
17
24
TruthMuonTrackRetriever::TruthMuonTrackRetriever
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent):
25
base_class(
type
, name, parent),
26
m_typeName
(
"SMTr"
) {
27
//Fill the list with the names of track record collections to try
28
m_TrackRecCollNames
.push_back(
"MuonEntryLayer"
);
29
m_TrackRecCollNames
.push_back(
"MuonEntryRecord"
);
30
31
//Declare the properties
32
declareProperty(
"TrackRecCollNames"
,
m_TrackRecCollNames
,
"List of track records collections to try in this order - only one is retrieved"
);
33
34
}
35
36
40
StatusCode
TruthMuonTrackRetriever::initialize
(){
41
42
//Nothing to be done here
43
return
StatusCode::SUCCESS;
44
}
45
50
StatusCode
TruthMuonTrackRetriever::retrieve
(ToolHandle<IFormatTool> &FormatTool) {
51
52
ATH_MSG_DEBUG
(
"Retrieving "
<<
dataTypeName
() );
53
54
//Try to retrieve the track record collection
55
const
TrackRecordCollection
* TrackRecordColl = NULL ;
56
//Loop over all the collections and try a retrieve (more efficenct than
57
//contain-retrieve combination)
58
for
(
const
auto
& CollNameItr :
m_TrackRecCollNames
) {
59
//be verbose
60
ATH_MSG_DEBUG
(
"Trying to retrieve "
<< CollNameItr );
61
//try to retrieve
62
if
( !evtStore()->
contains<TrackRecordCollection>
( CollNameItr )){
continue
; }
// skip if not in SG
63
if
(evtStore()->
retrieve
(TrackRecordColl, CollNameItr).isSuccess()) break ;
64
}
65
66
//If we didnt' get any, return
67
if
(TrackRecordColl == NULL ) {
68
ATH_MSG_WARNING
(
"Unable to retrieve any track collection from "
<<
m_TrackRecCollNames
);
69
return
StatusCode::RECOVERABLE;
70
}
71
72
//Reserve space for the output
73
DataVect
pt; pt.reserve(TrackRecordColl->
size
());
74
DataVect
phi
;
phi
.reserve(TrackRecordColl->
size
());
75
DataVect
eta
;
eta
.reserve(TrackRecordColl->
size
());
76
DataVect
rhoVertex; rhoVertex.reserve(TrackRecordColl->
size
());
77
DataVect
phiVertex; phiVertex.reserve(TrackRecordColl->
size
());
78
DataVect
zVertex; zVertex.reserve(TrackRecordColl->
size
());
79
DataVect
code; code.reserve(TrackRecordColl->
size
());
80
DataVect
id;
id
.reserve(TrackRecordColl->
size
());
81
82
//Now loop over the collection and retrieve data
83
for
(
const
auto
& record : *TrackRecordColl ) {
84
85
//Get the pdg code
86
int
pdgCode = record.GetPDGCode();
87
88
//Only accept muons
89
if
(abs(pdgCode) != 13) {
90
ATH_MSG_DEBUG
(
"Reject non-muon track with PDG ID "
<< pdgCode );
91
continue
;
92
}
93
94
//Get vertex and momentum
95
HepGeom::Point3D<double> vertex = record.GetPosition();
96
HepGeom::Vector3D<double> momentum = record.GetMomentum();
97
98
//And store output
99
pt.emplace_back( momentum.perp()/CLHEP::GeV );
100
phi
.emplace_back( momentum.phi() < 0 ? momentum.phi() + 2*
M_PI
: momentum.phi() );
101
eta
.emplace_back( momentum.pseudoRapidity() );
102
rhoVertex.emplace_back( vertex.perp()*CLHEP::mm/CLHEP::cm );
103
phiVertex.emplace_back( vertex.phi() < 0 ? vertex.phi() + 2*
M_PI
: vertex.phi() );
104
zVertex.emplace_back( vertex.z()*CLHEP::mm/CLHEP::cm );
105
code.emplace_back( pdgCode );
106
id
.emplace_back(
HepMC::barcode
(record) );
// FIXME barcode-based
107
}
108
109
//Finall add everything to the datamap
110
DataMap
dataMap;
111
const
auto
nEntries = pt.size();
112
dataMap[
"pt"
] = std::move(pt);
113
dataMap[
"phi"
] = std::move(
phi
);
114
dataMap[
"eta"
] = std::move(
eta
);
115
dataMap[
"rhoVertex"
] = std::move(rhoVertex);
116
dataMap[
"phiVertex"
] = std::move(phiVertex);
117
dataMap[
"zVertex"
] = std::move(zVertex);
118
dataMap[
"code"
] = std::move(code);
119
dataMap[
"id"
] = std::move(
id
);
120
121
//some summary
122
ATH_MSG_DEBUG
(
dataTypeName
() <<
": "
<< nEntries );
123
124
//forward data to formating tool
125
//return FormatTool->AddToEvent(dataTypeName(), (*CollNameItr), &dataMap);
128
std::string emptyStr=
""
;
129
return
FormatTool->AddToEvent(
dataTypeName
(), emptyStr, &dataMap);
130
}
131
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
GenParticle.h
MagicNumbers.h
TrackRecordCollection.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
TrackRecord.h
TruthMuonTrackRetriever.h
AtlasHitsVector::size
size_type size() const
Definition
AtlasHitsVector.h:142
JiveXML::TruthMuonTrackRetriever::initialize
StatusCode initialize()
Default AthAlgTool methods.
Definition
TruthMuonTrackRetriever.cxx:40
JiveXML::TruthMuonTrackRetriever::m_typeName
const std::string m_typeName
The data type that is generated by this retriever.
Definition
TruthMuonTrackRetriever.h:51
JiveXML::TruthMuonTrackRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition
TruthMuonTrackRetriever.h:44
JiveXML::TruthMuonTrackRetriever::TruthMuonTrackRetriever
TruthMuonTrackRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition
TruthMuonTrackRetriever.cxx:24
JiveXML::TruthMuonTrackRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition
TruthMuonTrackRetriever.cxx:50
JiveXML::TruthMuonTrackRetriever::m_TrackRecCollNames
std::vector< std::string > m_TrackRecCollNames
A list of StoreGate names to probe in this order for the muon record collecton.
Definition
TruthMuonTrackRetriever.h:54
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition
BadLArRetriever.cxx:22
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition
DataType.h:59
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition
DataType.h:58
type
Generated on
for ATLAS Offline Software by
1.17.0