ATLAS Offline Software
CompositeParticleRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 // for associations:
11 //#include "Particle/TrackParticleContainer.h"
12 //#include "CaloEvent/CaloClusterContainer.h"
13 
14 #include "CLHEP/Units/SystemOfUnits.h"
15 
16 namespace JiveXML {
17 
24  CompositeParticleRetriever::CompositeParticleRetriever(const std::string& type,const std::string& name,const IInterface* parent):
26  m_typeName("CompositeParticle")
27  {
28 
29  //Only declare the interface
30  declareInterface<IDataRetriever>(this);
31 
32  declareProperty("StoreGateKey", m_sgKey = "AllObjects",
33  "Collection to be first in output, shown in Atlantis without switching");
34  }
35 
40  StatusCode CompositeParticleRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
41 
42  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "in retrieveAll()" << endmsg;
43 
45  const CompositeParticleContainer* compPart;
46 
47  //obtain the default collection first
48  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trying to retrieve " << dataTypeName() << " (" << m_sgKey << ")" << endmsg;
49  StatusCode sc = evtStore()->retrieve(compPart, m_sgKey);
50  if (sc.isFailure() ) {
51  if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << m_sgKey << " not found in SG " << endmsg;
52  }else{
53  DataMap data = getData(compPart);
54  if ( FormatTool->AddToEvent(dataTypeName(), m_sgKey, &data).isFailure()){
55  if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << m_sgKey << " not found in SG " << endmsg;
56  }else{
57  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << " (" << m_sgKey << ") CompositeParticle retrieved" << endmsg;
58  }
59  }
60 
61  //obtain all other collections from StoreGate
62  if (( evtStore()->retrieve(iterator, end)).isFailure()){
63  if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Unable to retrieve iterator for Jet collection" << endmsg;
64 // return StatusCode::WARNING;
65  }
66 
67  for (; iterator!=end; ++iterator) {
68  if (iterator.key()!=m_sgKey) {
69  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trying to retrieve all " << dataTypeName() << " (" << iterator.key() << ")" << endmsg;
71  if ( FormatTool->AddToEvent(dataTypeName(), iterator.key(), &data).isFailure()){
72  if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "Collection " << iterator.key() << " not found in SG " << endmsg;
73  }else{
74  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << " (" << iterator.key() << ") CompositeParticle retrieved" << endmsg;
75  }
76  }
77  }
78  //All collections retrieved okay
79  return StatusCode::SUCCESS;
80  }
81 
82 
88 
89  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "retrieve()" << endmsg;
90 
92 
93  DataVect phi; phi.reserve(cpcont->size());
94  DataVect eta; eta.reserve(cpcont->size());
95  DataVect et; et.reserve(cpcont->size());
96  DataVect mass; mass.reserve(cpcont->size());
97  DataVect energy; energy.reserve(cpcont->size());
98  DataVect px; px.reserve(cpcont->size());
99  DataVect py; py.reserve(cpcont->size());
100  DataVect pz; pz.reserve(cpcont->size());
101  DataVect pdgId; pdgId.reserve(cpcont->size());
102  DataVect typeEV; typeEV.reserve(cpcont->size());
103  DataVect charge; charge.reserve(cpcont->size());
104  DataVect dataType; dataType.reserve(cpcont->size());
105  DataVect label; label.reserve(cpcont->size());
106 
107  //planned, not working yet:
108 // DataVect childID; childID.reserve(cpcont->size());
109 // DataVect motherID; motherID.reserve(cpcont->size());
110 
111  // for associations. Just placeholder here, for full implementation
112  // see MuonRetriever.
113 // DataVect clusterKeyVec; clusterKeyVec.reserve(cpcont->size());
114 // DataVect clusterIndexVec; clusterIndexVec.reserve(cpcont->size());
115 // DataVect clusterKeyVec; clusterKeyVec.reserve(cpcont->size());
116 // DataVect clusterIndexVec; clusterIndexVec.reserve(cpcont->size());
117 
118  CompositeParticleContainer::const_iterator compPartItr = cpcont->begin();
119  CompositeParticleContainer::const_iterator compPartItrE = cpcont->end();
120 
121  std::string typeLabel = "n_a"; // same as in TruthParticleRetriever
122  int pdgId2 = 0;
123  for (; compPartItr != compPartItrE; ++compPartItr) {
124  phi.push_back(DataType((*compPartItr)->phi()));
125  eta.push_back(DataType((*compPartItr)->eta()));
126  et.push_back(DataType((*compPartItr)->et()/CLHEP::GeV));
127  mass.push_back(DataType((*compPartItr)->m()/CLHEP::GeV));
128  energy.push_back( DataType((*compPartItr)->e()/CLHEP::GeV ) );
129  px.push_back( DataType((*compPartItr)->px()/CLHEP::GeV ) );
130  py.push_back( DataType((*compPartItr)->py()/CLHEP::GeV ) );
131  pz.push_back( DataType((*compPartItr)->pz()/CLHEP::GeV ) );
132 
133  charge.push_back( DataType( (*compPartItr)->charge() ));
134  dataType.push_back( DataType( (*compPartItr)->dataType() ));
135  typeLabel = "n_a";
136  pdgId2 = (*compPartItr)->pdgId();
137  pdgId.push_back( DataType( pdgId2 ));
138  if( abs(pdgId2) == 11) typeLabel = "EV_Electron";
139  if( abs(pdgId2) == 12) typeLabel = "EV_NeutrinoElectron";
140  if( abs(pdgId2) == 13) typeLabel = "EV_Muon";
141  if( abs(pdgId2) == 14) typeLabel = "EV_NeutrinoMuon";
142  if( abs(pdgId2) == 15) typeLabel = "EV_Tau";
143  if( abs(pdgId2) == 16) typeLabel = "EV_NeutrinoTau";
144  if( abs(pdgId2) == 6) typeLabel = "EV_Top";
145  if( abs(pdgId2) == 5) typeLabel = "EV_Bottom";
146  if( abs(pdgId2) == 22) typeLabel = "EV_Photon";
147  if( abs(pdgId2) == 23) typeLabel = "EV_Z0";
148  if( pdgId2 == 24) typeLabel = "EV_Wplus";
149  if( pdgId2 == -24) typeLabel = "EV_Wminus";
150  typeEV.push_back( DataType( typeLabel ));
151  label.push_back( DataType( "none" ) );
152 
153 // childID.push_back( DataType( "none" ) ); // placeholders
154 // motherID.push_back( DataType( "none" ) );
155  }
156  // four-vectors
157  DataMap["phi"] = phi;
158  DataMap["eta"] = eta;
159  DataMap["et"] = et;
160  DataMap["energy"] = energy;
161  DataMap["mass"] = mass;
162  DataMap["px"] = px;
163  DataMap["py"] = py;
164  DataMap["pz"] = pz;
165  DataMap["pdgId"] = pdgId;
166  DataMap["typeEV"] = typeEV;
167  DataMap["charge"] = charge;
168  DataMap["dataType"] = dataType;
169  DataMap["label"] = label;
170 
171 // DataMap["childID"] = childID;
172 // DataMap["motherID"] = motherID;
173 
174  if (msgLvl(MSG::DEBUG)) {
175  msg(MSG::DEBUG) << dataTypeName() << " retrieved with " << phi.size() << " entries"<< endmsg;
176  }
177 
178  //All collections retrieved okay
179  return DataMap;
180 
181  } // retrieve
182 
183  //--------------------------------------------------------------------------
184 
185 } // 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.
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:40
test_pyathena.px
px
Definition: test_pyathena.py:18
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
downloadSingle.dataType
string dataType
Definition: downloadSingle.py:18
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
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:24
PowhegPy8EG_H2a.pdgId
dictionary pdgId
Definition: PowhegPy8EG_H2a.py:128
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
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
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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:21
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
charge
double charge(const T &p)
Definition: AtlasPID.h:494
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:87
CompositeParticle.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
AthAlgTool
Definition: AthAlgTool.h:26
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ConstIterator
Definition: SGIterator.h:163
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