ATLAS Offline Software
Loading...
Searching...
No Matches
CompositeParticleRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9#include "CLHEP/Units/SystemOfUnits.h"
10#include <cmath> //std::abs
11
12namespace JiveXML {
13
20 CompositeParticleRetriever::CompositeParticleRetriever(const std::string& type,const std::string& name,const IInterface* parent):
21 AthAlgTool(type,name,parent),
22 m_typeName("CompositeParticle"){
23 //Only declare the interface
24 declareInterface<IDataRetriever>(this);
25 declareProperty("StoreGateKey", m_sgKey = "AllObjects",
26 "Collection to be first in output, shown in Atlantis without switching");
27 }
28
33 StatusCode CompositeParticleRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
34 ATH_MSG_DEBUG("in retrieveAll()" );
36 const CompositeParticleContainer* compPart{};
37 //obtain the default collection first
38 ATH_MSG_DEBUG( "Trying to retrieve " << dataTypeName() << " (" << m_sgKey << ")");
39 StatusCode sc = evtStore()->retrieve(compPart, m_sgKey);
40 if (sc.isFailure() ) {
41 ATH_MSG_WARNING( "Collection " << m_sgKey << " not found in SG " );
42 }else{
43 DataMap data = getData(compPart);
44 if ( FormatTool->AddToEvent(dataTypeName(), m_sgKey, &data).isFailure()){
45 ATH_MSG_WARNING( "Collection " << m_sgKey << " not found in SG " );
46 }else{
47 ATH_MSG_DEBUG( dataTypeName() << " (" << m_sgKey << ") CompositeParticle retrieved" );
48 }
49 }
50 //obtain all other collections from StoreGate
51 if (( evtStore()->retrieve(iterator, end)).isFailure()){
52 ATH_MSG_WARNING( "Unable to retrieve iterator for Jet collection" );
53 }
54 for (; iterator!=end; ++iterator) {
55 if (iterator.key()!=m_sgKey) {
56 ATH_MSG_DEBUG( "Trying to retrieve all " << dataTypeName() << " (" << iterator.key() << ")" );
58 if ( FormatTool->AddToEvent(dataTypeName(), iterator.key(), &data).isFailure()){
59 ATH_MSG_WARNING( "Collection " << iterator.key() << " not found in SG " );
60 }else{
61 ATH_MSG_DEBUG( dataTypeName() << " (" << iterator.key() << ") CompositeParticle retrieved");
62 }
63 }
64 }
65 //All collections retrieved okay
66 return StatusCode::SUCCESS;
67 }
68
69
75 ATH_MSG_DEBUG( "retrieve()");
77 const auto nParticles = cpcont->size();
78 DataVect phi; phi.reserve(nParticles);
79 DataVect eta; eta.reserve(nParticles);
80 DataVect et; et.reserve(nParticles);
81 DataVect mass; mass.reserve(nParticles);
82 DataVect energy; energy.reserve(nParticles);
83 DataVect px; px.reserve(nParticles);
84 DataVect py; py.reserve(nParticles);
85 DataVect pz; pz.reserve(nParticles);
86 DataVect pdgId; pdgId.reserve(nParticles);
87 DataVect typeEV; typeEV.reserve(nParticles);
88 DataVect charge; charge.reserve(nParticles);
89 DataVect dataType; dataType.reserve(nParticles);
90 DataVect label; label.reserve(nParticles);
91
93 CompositeParticleContainer::const_iterator compPartItrE = cpcont->end();
94
95 std::string typeLabel = "n_a"; // same as in TruthParticleRetriever
96 int pdgId2 = 0;
97 for (; compPartItr != compPartItrE; ++compPartItr) {
98 const auto & pCompPart = *compPartItr;
99 phi.emplace_back(pCompPart->phi());
100 eta.emplace_back(pCompPart->eta());
101 et.emplace_back(pCompPart->et()/CLHEP::GeV);
102 mass.emplace_back(pCompPart->m()/CLHEP::GeV);
103 energy.emplace_back( pCompPart->e()/CLHEP::GeV );
104 px.emplace_back( pCompPart->px()/CLHEP::GeV );
105 py.emplace_back( pCompPart->py()/CLHEP::GeV );
106 pz.emplace_back( pCompPart->pz()/CLHEP::GeV );
107
108 charge.emplace_back( pCompPart->charge() );
109 dataType.emplace_back( pCompPart->dataType() );
110 pdgId2 = pCompPart->pdgId();
111 pdgId.emplace_back(pdgId2);
112 const auto absId = std::abs(pdgId2);
113 switch (absId){
114 case 11:
115 typeLabel = "EV_Electron";
116 break;
117 case 12:
118 typeLabel = "EV_NeutrinoElectron";
119 break;
120 case 13:
121 typeLabel = "EV_Muon";
122 break;
123 case 14:
124 typeLabel = "EV_NeutrinoMuon";
125 break;
126 case 15:
127 typeLabel = "EV_Tau";
128 break;
129 case 16:
130 typeLabel = "EV_NeutrinoTau";
131 break;
132 case 6:
133 typeLabel = "EV_Top";
134 break;
135 case 5:
136 typeLabel = "EV_Bottom";
137 break;
138 case 22:
139 typeLabel = "EV_Photon";
140 break;
141 case 23:
142 typeLabel = "EV_Z0";
143 break;
144 case 24:
145 typeLabel = ( pdgId2 == 24) ? "EV_Wplus": "EV_Wminus";
146 break;
147 default:
148 typeLabel = "n_a";
149 break;
150 }
151
152 typeEV.emplace_back(typeLabel);
153 label.emplace_back( "none" );
154 }
155 // four-vectors
156 const auto nEntries = phi.size();
157 DataMap["phi"] = std::move(phi);
158 DataMap["eta"] = std::move(eta);
159 DataMap["et"] = std::move(et);
160 DataMap["energy"] = std::move(energy);
161 DataMap["mass"] = std::move(mass);
162 DataMap["px"] = std::move(px);
163 DataMap["py"] = std::move(py);
164 DataMap["pz"] = std::move(pz);
165 DataMap["pdgId"] = std::move(pdgId);
166 DataMap["typeEV"] = std::move(typeEV);
167 DataMap["charge"] = std::move(charge);
168 DataMap["dataType"] = std::move(dataType);
169 DataMap["label"] = std::move(label);
170
171 ATH_MSG_DEBUG( " retrieved with " << nEntries << " entries");
172
173
174 //All collections retrieved okay
175 return DataMap;
176
177 } // retrieve
178
179 //--------------------------------------------------------------------------
180
181} // JiveXML namespace
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t sc
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
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.
size_type size() const noexcept
Returns the number of elements in the collection.
const std::string m_typeName
The data type that is generated by this retriever.
const DataMap getData(const CompositeParticleContainer *)
Retrieve basic parameters, mainly four-vectors, for each collection.
virtual std::string dataTypeName() const
Return the name of the data type.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
CompositeParticleRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
a const_iterator facade to DataHandle.
Definition SGIterator.h:164
std::string label(const std::string &format, int i)
Definition label.h:19
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
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
Extra patterns decribing particle interation process.