Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
12 namespace JiveXML {
13 
20  CompositeParticleRetriever::CompositeParticleRetriever(const std::string& type,const std::string& name,const IInterface* 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 
92  CompositeParticleContainer::const_iterator compPartItr = cpcont->begin();
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
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
et
Extra patterns decribing particle interation process.
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
JiveXML::CompositeParticleRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: CompositeParticleRetriever.cxx:33
test_pyathena.px
px
Definition: test_pyathena.py:18
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
downloadSingle.dataType
string dataType
Definition: downloadSingle.py:18
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
CompositeParticleContainer
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticleContainer.h:36
JiveXML::CompositeParticleRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: CompositeParticleRetriever.h:44
JiveXML::CompositeParticleRetriever::CompositeParticleRetriever
CompositeParticleRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: CompositeParticleRetriever.cxx:20
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
test_pyathena.parent
parent
Definition: test_pyathena.py:15
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
charge
double charge(const T &p)
Definition: AtlasPID.h:931
CompositeParticleContainer.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
JiveXML::CompositeParticleRetriever::getData
const DataMap getData(const CompositeParticleContainer *)
Retrieve basic parameters, mainly four-vectors, for each collection.
Definition: CompositeParticleRetriever.cxx:74
CompositeParticle.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ConstIterator
Definition: SGIterator.h:164
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
JiveXML::CompositeParticleRetriever::m_sgKey
std::string m_sgKey
Definition: CompositeParticleRetriever.h:50
CompositeParticleRetriever.h