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

Retrieves the McEventCollection or the TrackRecordCollection in simulated cosmics. More...

#include <TruthTrackRetriever.h>

Inheritance diagram for JiveXML::TruthTrackRetriever:
Collaboration diagram for JiveXML::TruthTrackRetriever:

Public Member Functions

 TruthTrackRetriever (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::string m_McEvtCollName
 Storegate key for the McEventCollection (different between RDO/ESD and AOD).
double m_MinPtCut
 Minimum pT for a particle to get accepted.
double m_MinRhoCut
 Minium radius of the end-vertex for the particle to get accepted.

Detailed Description

Retrieves the McEventCollection or the TrackRecordCollection in simulated cosmics.

  • Properties
    • StoreGateKey = TruthEvent : Storegate key for the McEventCollection (different between RDO/ESD and AOD).
  • UnstableMinPtCut = 100*MeV Minimum pT for a particle to get accepted.
  • UnstableMinRhoCut = 40*mm Minium radius of the end-vertex for the particle to get accepted.
  • 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\)
    • rhoEndVertex,phiEndVertex,zEndVertex : position of the end-vertex in \(\rho\), \(\phi\) and \(z\)

Definition at line 40 of file TruthTrackRetriever.h.

Constructor & Destructor Documentation

◆ TruthTrackRetriever()

JiveXML::TruthTrackRetriever::TruthTrackRetriever ( 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 24 of file TruthTrackRetriever.cxx.

24 :
25 base_class(type,name,parent),
26 m_typeName("STr")
27 {
28 declareProperty("StoreGateKey", m_McEvtCollName = "TruthEvent", "Name of the McEventCollection");
29 declareProperty("UnstableMinPtCut", m_MinPtCut = 100*Gaudi::Units::MeV, "Minimum pT for an unstable particle to get accepted");
30 declareProperty("UnstableMinRhoCut", m_MinRhoCut = 40*Gaudi::Units::mm, "Minium radius of the end-vertex for unstable particle to get accepted");
31
32 }
std::string m_McEvtCollName
Storegate key for the McEventCollection (different between RDO/ESD and AOD).
double m_MinRhoCut
Minium radius of the end-vertex for the particle to get accepted.
double m_MinPtCut
Minimum pT for a particle to get accepted.
const std::string m_typeName
The data type that is generated by this retriever.

Member Function Documentation

◆ dataTypeName()

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

Return the name of the data type.

Definition at line 51 of file TruthTrackRetriever.h.

51{ return m_typeName; };

◆ initialize()

StatusCode JiveXML::TruthTrackRetriever::initialize ( )

Default AthAlgTool methods.

Initialize before event loop.

Definition at line 37 of file TruthTrackRetriever.cxx.

37 {
38 //Nothing to do here
39 return StatusCode::SUCCESS;
40 }

◆ retrieve()

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

Retrieve all the data.

Loop over all true particles and get their basic parameters.

Parameters
FormatToolthe tool that will create formated output from the DataMap

Definition at line 46 of file TruthTrackRetriever.cxx.

46 {
47
48 //be verbose
49 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
50
51 //Retrieve the collection
52 const McEventCollection* McEvtColl = NULL;
53 if ( !evtStore()->contains<McEventCollection>( m_McEvtCollName )){
54 ATH_MSG_DEBUG( "Could not find McEventCollection " << m_McEvtCollName );
55 return StatusCode::SUCCESS;
56 }
57 if( evtStore()->retrieve(McEvtColl, m_McEvtCollName).isFailure() ){
58 ATH_MSG_DEBUG( "Could not retrieve McEventCollection " << m_McEvtCollName );
59 return StatusCode::SUCCESS;
60 }
61
62 // Calculate the size
63 long NParticles=0;
64 McEventCollection::const_iterator McEvtCollItr = McEvtColl->begin();
65 for ( ; McEvtCollItr != McEvtColl->end(); ++McEvtCollItr)
66 NParticles += (*McEvtCollItr)->particles_size();
67
68 //Show in verbose mode
69 ATH_MSG_DEBUG( "Total number of particles in McEventCollection \"" << m_McEvtCollName << "\" is " << NParticles );
70
71 //Reserve space for the output data
72 DataVect pt; pt.reserve(NParticles);
73 DataVect phi; phi.reserve(NParticles);
74 DataVect eta; eta.reserve(NParticles);
75 DataVect rhoVertex; rhoVertex.reserve(NParticles);
76 DataVect phiVertex; phiVertex.reserve(NParticles);
77 DataVect zVertex; zVertex.reserve(NParticles);
78 DataVect code; code.reserve(NParticles);
79 DataVect id; id.reserve(NParticles);
80 DataVect rhoEndVertex; rhoEndVertex.reserve(NParticles);
81 DataVect phiEndVertex; phiEndVertex.reserve(NParticles);
82 DataVect zEndVertex; zEndVertex.reserve(NParticles);
83
84
85 //Now loop events and retrieve
86 for ( McEvtCollItr = McEvtColl->begin(); McEvtCollItr != McEvtColl->end(); ++McEvtCollItr){
87
88 //Loop over particles in the event
89 const auto &barcodes = (*McEvtCollItr)->attribute<HepMC::GenEventBarcodes> (HepMCStr::barcodes);
90 std::map<int,int> id_to_barcode_map;
91 if (barcodes) id_to_barcode_map = barcodes->id_to_barcode_map();
92 for (const auto& particle: *(*McEvtCollItr) ) {
93
94 //Additional cuts for decaying particles
95 if ( particle->end_vertex() ) {
96 //Reject particles that fail the pt cut
97 if ( particle->momentum().perp() < m_MinPtCut) continue ;
98 //Reject particles that fail the minimum end-vertex cut
99 if (particle->end_vertex()->position().perp() < m_MinRhoCut ) continue ;
100 }
101
102 //Get basic parameters (eta, phi, pt, ...)
103 pt.emplace_back(particle->momentum().perp()/Gaudi::Units::GeV);
104 float thePhi = particle->momentum().phi();
105 phi.emplace_back( (thePhi<0) ? thePhi+=2*M_PI : thePhi );
106 eta.emplace_back( particle->momentum().pseudoRapidity() );
107 code.emplace_back( particle->pdg_id() );
108 id.emplace_back( id_to_barcode_map.at(particle->id() ));
109
110 // Get the vertex information
111 const auto& vertexprod = particle->production_vertex();
112 if (vertexprod) {
113 const auto& pos=vertexprod->position();
114 rhoVertex.emplace_back( std::sqrt(pos.x()*pos.x()+pos.y()*pos.y()+pos.z()*pos.z())*Gaudi::Units::mm/Gaudi::Units::cm );
115 float vtxPhi = pos.phi();
116 phiVertex.emplace_back( (vtxPhi<0)? vtxPhi+=2*M_PI : vtxPhi );
117 zVertex.emplace_back( pos.z()*Gaudi::Units::mm/Gaudi::Units::cm );
118 } else {
119 rhoVertex.emplace_back( 0. );
120 phiVertex.emplace_back( 0. );
121 zVertex.emplace_back( 0. );
122 }
123 //Do the same for the end vertex
124 const auto& vertexend = particle->end_vertex();
125 if ( vertexend ) {
126 const auto& pos=vertexend->position();
127 rhoEndVertex.emplace_back(std::sqrt(pos.x()*pos.x()+pos.y()*pos.y()+pos.z()*pos.z())*Gaudi::Units::mm/Gaudi::Units::cm);
128 float vtxPhi = pos.phi();
129 phiEndVertex.emplace_back( (vtxPhi<0)? vtxPhi+=2*M_PI : vtxPhi );
130 zEndVertex.emplace_back(pos.z()*Gaudi::Units::mm/Gaudi::Units::cm);
131 } else {
132 rhoEndVertex.emplace_back( 0. );
133 phiEndVertex.emplace_back( 0. );
134 zEndVertex.emplace_back( 0. );
135 }
136 }
137 }
138
139 DataMap myDataMap;
140 const auto nEntries = pt.size();
141 myDataMap["pt"] = std::move(pt);
142 myDataMap["phi"] = std::move(phi);
143 myDataMap["eta"] = std::move(eta);
144 myDataMap["code"] = std::move(code);
145 myDataMap["id"] = std::move(id);
146 myDataMap["rhoVertex"] = std::move(rhoVertex);
147 myDataMap["phiVertex"] = std::move(phiVertex);
148 myDataMap["zVertex"] = std::move(zVertex);
149 myDataMap["rhoEndVertex"] = std::move(rhoEndVertex);
150 myDataMap["phiEndVertex"] = std::move(phiEndVertex);
151 myDataMap["zEndVertex"] = std::move(zEndVertex);
152
153 //Be verbose
154 ATH_MSG_DEBUG( dataTypeName() << ": "<< nEntries );
155
156 //forward data to formating tool
157 return FormatTool->AddToEvent(dataTypeName(), m_McEvtCollName, &myDataMap);
158 }
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual std::string dataTypeName() const
Return the name of the data type.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
const std::string barcodes
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
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

Member Data Documentation

◆ m_McEvtCollName

std::string JiveXML::TruthTrackRetriever::m_McEvtCollName
private

Storegate key for the McEventCollection (different between RDO/ESD and AOD).

Definition at line 61 of file TruthTrackRetriever.h.

◆ m_MinPtCut

double JiveXML::TruthTrackRetriever::m_MinPtCut
private

Minimum pT for a particle to get accepted.

Definition at line 63 of file TruthTrackRetriever.h.

◆ m_MinRhoCut

double JiveXML::TruthTrackRetriever::m_MinRhoCut
private

Minium radius of the end-vertex for the particle to get accepted.

Definition at line 65 of file TruthTrackRetriever.h.

◆ m_typeName

const std::string JiveXML::TruthTrackRetriever::m_typeName
private

The data type that is generated by this retriever.

Definition at line 58 of file TruthTrackRetriever.h.


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