ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXML::TruthMuonTrackRetriever Class Reference

Retrieves the muons information from the TrackRecordCollection. More...

#include <TruthMuonTrackRetriever.h>

Inheritance diagram for JiveXML::TruthMuonTrackRetriever:
Collaboration diagram for JiveXML::TruthMuonTrackRetriever:

Public Member Functions

 TruthMuonTrackRetriever (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool)
 Retrieve all the data.
virtual std::string dataTypeName () const
 Return the name of the data type.
StatusCode initialize ()
 Default AthAlgTool methods.

Private Attributes

const std::string m_typeName
 The data type that is generated by this retriever.
std::vector< std::string > m_TrackRecCollNames
 A list of StoreGate names to probe in this order for the muon record collecton.

Detailed Description

Retrieves the muons information from the TrackRecordCollection.

  • Properties
    • TrackRecCollNames = ["MuonEntryLayer","MuonEntryRecord"] :
  • Retrieved Data
    • code : the PDG ID of the particle
    • id : the particle barcode
    • pt : transverse momentum
    • eta, phi : \(\eta\) and \(\phi\) of the momentum vector
    • rhoVertex,phiVertex,zVertex : position of the production vertex in \(\rho\), \(\phi\) and \(z\)

Definition at line 33 of file TruthMuonTrackRetriever.h.

Constructor & Destructor Documentation

◆ TruthMuonTrackRetriever()

JiveXML::TruthMuonTrackRetriever::TruthMuonTrackRetriever ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard Constructor.

This is the standard AthAlgTool constructor.

Parameters
typeAlgTool type name
nameAlgTool instance name
parentAlgTools parent owning this tool

Definition at line 26 of file TruthMuonTrackRetriever.cxx.

26 :
27 base_class(type, name, parent),
28 m_typeName("SMTr") {
29 //Fill the list with the names of track record collections to try
30 m_TrackRecCollNames.push_back("MuonEntryLayer");
31 m_TrackRecCollNames.push_back("MuonEntryRecord");
32
33 //Declare the properties
34 declareProperty("TrackRecCollNames",m_TrackRecCollNames,"List of track records collections to try in this order - only one is retrieved");
35
36 }
const std::string m_typeName
The data type that is generated by this retriever.
std::vector< std::string > m_TrackRecCollNames
A list of StoreGate names to probe in this order for the muon record collecton.

Member Function Documentation

◆ dataTypeName()

virtual std::string JiveXML::TruthMuonTrackRetriever::dataTypeName ( ) const
inlinevirtual

Return the name of the data type.

Definition at line 44 of file TruthMuonTrackRetriever.h.

44{ return m_typeName; };

◆ initialize()

StatusCode JiveXML::TruthMuonTrackRetriever::initialize ( )

Default AthAlgTool methods.

Initialize before event loop.

Definition at line 42 of file TruthMuonTrackRetriever.cxx.

42 {
43
44 //Nothing to be done here
45 return StatusCode::SUCCESS;
46 }

◆ retrieve()

StatusCode JiveXML::TruthMuonTrackRetriever::retrieve ( ToolHandle< IFormatTool > & FormatTool)
virtual

Retrieve all the data.

Loop over all true particles, find the muons and get their basic parameters.

Parameters
FormatToolthe tool that will create formated output from the DataMap

Definition at line 52 of file TruthMuonTrackRetriever.cxx.

52 {
53
54 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
55
56 //Try to retrieve the track record collection
57 const TrackRecordCollection* TrackRecordColl = NULL ;
58 //Loop over all the collections and try a retrieve (more efficenct than
59 //contain-retrieve combination)
60 for (const auto & CollNameItr : m_TrackRecCollNames ) {
61 //be verbose
62 ATH_MSG_DEBUG( "Trying to retrieve " << CollNameItr );
63 //try to retrieve
64 if ( !evtStore()->contains<TrackRecordCollection>( CollNameItr )){ continue; } // skip if not in SG
65 if (evtStore()->retrieve(TrackRecordColl, CollNameItr).isSuccess()) break ;
66 }
67
68 //If we didnt' get any, return
69 if (TrackRecordColl == NULL ) {
70 ATH_MSG_WARNING( "Unable to retrieve any track collection from " << m_TrackRecCollNames );
71 return StatusCode::RECOVERABLE;
72 }
73
74 //Reserve space for the output
75 DataVect pt; pt.reserve(TrackRecordColl->size());
76 DataVect phi; phi.reserve(TrackRecordColl->size());
77 DataVect eta; eta.reserve(TrackRecordColl->size());
78 DataVect rhoVertex; rhoVertex.reserve(TrackRecordColl->size());
79 DataVect phiVertex; phiVertex.reserve(TrackRecordColl->size());
80 DataVect zVertex; zVertex.reserve(TrackRecordColl->size());
81 DataVect code; code.reserve(TrackRecordColl->size());
82 DataVect id; id.reserve(TrackRecordColl->size());
83
84 //Now loop over the collection and retrieve data
85 for (const auto & record : *TrackRecordColl ) {
86
87 //Get the pdg code
88 int pdgCode = record.GetPDGCode();
89
90 //Only accept muons
91 if (abs(pdgCode) != 13) {
92 ATH_MSG_DEBUG( "Reject non-muon track with PDG ID " << pdgCode );
93 continue;
94 }
95
96 //Get vertex and momentum
97 HepGeom::Point3D<double> vertex = record.GetPosition();
98 HepGeom::Vector3D<double> momentum = record.GetMomentum();
99
100 //And store output
101 pt.emplace_back( momentum.perp()/CLHEP::GeV );
102 phi.emplace_back( momentum.phi() < 0 ? momentum.phi() + 2*M_PI : momentum.phi() );
103 eta.emplace_back( momentum.pseudoRapidity() );
104 rhoVertex.emplace_back( vertex.perp()*CLHEP::mm/CLHEP::cm );
105 phiVertex.emplace_back( vertex.phi() < 0 ? vertex.phi() + 2*M_PI : vertex.phi() );
106 zVertex.emplace_back( vertex.z()*CLHEP::mm/CLHEP::cm );
107 code.emplace_back( pdgCode );
108 id.emplace_back( HepMC::barcode(record) ); // FIXME barcode-based
109 }
110
111 //Finall add everything to the datamap
113 const auto nEntries = pt.size();
114 dataMap["pt"] = std::move(pt);
115 dataMap["phi"] = std::move(phi);
116 dataMap["eta"] = std::move(eta);
117 dataMap["rhoVertex"] = std::move(rhoVertex);
118 dataMap["phiVertex"] = std::move(phiVertex);
119 dataMap["zVertex"] = std::move(zVertex);
120 dataMap["code"] = std::move(code);
121 dataMap["id"] = std::move(id);
122
123 //some summary
124 ATH_MSG_DEBUG( dataTypeName() << ": "<< nEntries );
125
126 //forward data to formating tool
127 //return FormatTool->AddToEvent(dataTypeName(), (*CollNameItr), &dataMap);
130 std::string emptyStr="";
131 return FormatTool->AddToEvent(dataTypeName(), emptyStr, &dataMap);
132 }
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AtlasHitsVector< TrackRecord > TrackRecordCollection
size_type size() const
virtual std::string dataTypeName() const
Return the name of the data type.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
int barcode(const T *p)
Definition Barcode.h:15
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58

Member Data Documentation

◆ m_TrackRecCollNames

std::vector<std::string> JiveXML::TruthMuonTrackRetriever::m_TrackRecCollNames
private

A list of StoreGate names to probe in this order for the muon record collecton.

Definition at line 54 of file TruthMuonTrackRetriever.h.

◆ m_typeName

const std::string JiveXML::TruthMuonTrackRetriever::m_typeName
private

The data type that is generated by this retriever.

Definition at line 51 of file TruthMuonTrackRetriever.h.


The documentation for this class was generated from the following files: