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

Retrieves all Calo Cluster objects. More...

#include <CaloClusterRetriever.h>

Inheritance diagram for JiveXML::CaloClusterRetriever:
Collaboration diagram for JiveXML::CaloClusterRetriever:

Public Member Functions

 CaloClusterRetriever (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool)
 Retrieve all the data.
const DataMap getData (const xAOD::CaloClusterContainer *)
 Retrieve basic parameters, mainly four-vectors.
virtual std::string dataTypeName () const
 Return the name of the data type.
StatusCode initialize ()
 Default AthAlgTool methods.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Return the interface identifier.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::CaloClusterContainerm_sgKeyFavourite {this, "StoreGateKey", "egammaClusters", "Name of the CaloClusterContainer"}
std::vector< std::string > m_otherKeys
bool m_doWriteHLT
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Retrieves all Calo Cluster objects.

  • Properties
    • FavouriteJetCollection
    • OtherJetCollections
    • DoWriteHLT
  • Retrieved Data
    • Usual four-vector: phi, eta, et
    • id: counter on clusters
    • Cells: numCells: number of cells in each cluster, and cells: compact identifier code of each cell

Definition at line 35 of file CaloClusterRetriever.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CaloClusterRetriever()

JiveXML::CaloClusterRetriever::CaloClusterRetriever ( 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 19 of file CaloClusterRetriever.cxx.

19 :
20 AthAlgTool(type,name,parent),
21 m_sgKeyFavourite ("egammaClusters")
22 {
23 //Only declare the interface
24 declareInterface<IDataRetriever>(this);
25
26 declareProperty("FavouriteClusterCollection" ,m_sgKeyFavourite,
27 "Collection to be first in output, shown in Atlantis without switching");
28 declareProperty("OtherClusterCollections" ,m_otherKeys,
29 "Other collections to be retrieved. If list left empty, all available retrieved");
30 declareProperty("DoWriteHLT", m_doWriteHLT = false,"Ignore HLTAutokey object by default."); // ignore HLTAutoKey objects
31 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_sgKeyFavourite
std::vector< std::string > m_otherKeys

Member Function Documentation

◆ dataTypeName()

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

Return the name of the data type.

Implements JiveXML::IDataRetriever.

Definition at line 48 of file CaloClusterRetriever.h.

48{ return "Cluster"; };

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getData()

const DataMap JiveXML::CaloClusterRetriever::getData ( const xAOD::CaloClusterContainer * ccc)

Retrieve basic parameters, mainly four-vectors.

Clusters have no cells (trying to access them without back-navigation causes Athena crash).

Parameters
FormatToolthe tool that will create formated output from the DataMap

Definition at line 123 of file CaloClusterRetriever.cxx.

123 {
124
125 ATH_MSG_DEBUG( "getData()" );
126
128
129 DataVect phi; phi.reserve(ccc->size());
130 DataVect eta; eta.reserve(ccc->size());
131 DataVect et; et.reserve(ccc->size());
132 DataVect idVec; idVec.reserve(ccc->size());
133 DataVect numCellsVec; numCellsVec.reserve(ccc->size());
134 DataVect cells; cells.reserve( ccc->size() );
135
136 int noClu = ccc->size();
137 int noCells = 0;
138
139 int id = 0;
140 for (const auto cluster : *ccc) {
141 phi.emplace_back(cluster->phi());
142 eta.emplace_back(cluster->eta());
143 et.emplace_back(cluster->et()*(1./GeV));
144 idVec.emplace_back( ++id );
145
146 int numCells = cluster->size();
147 numCellsVec.emplace_back( numCells );
148 noCells += numCells;
149
150 for (const auto cell : *cluster) {
151 cells.push_back(cell->ID().get_compact());
152 }
153 }
154
155 std::string tagCells;
156 if(noClu){
157 tagCells = "cells multiple=\"" +DataType(noCells/(noClu*1.0)).toString()+"\"";
158 }else{
159 tagCells = "cells multiple=\"1.0\"";
160 }
161
162 // Start with mandatory entries
163 const auto nEntries = phi.size();
164 DataMap["phi"] = std::move(phi);
165 DataMap["eta"] = std::move(eta);
166 DataMap["et"] = std::move(et);
167 DataMap[tagCells] = std::move(cells);
168 DataMap["numCells"] = std::move(numCellsVec);
169 DataMap["id"] = std::move(idVec);
170
171 //Be verbose
172 ATH_MSG_DEBUG( dataTypeName() << " , collection: " << dataTypeName()
173 << " retrieved with " << nEntries << " entries" );
174
175 //All collections retrieved okay
176 return DataMap;
177
178 } // retrieve
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
float et(const xAOD::jFexSRJetRoI *j)
size_type size() const noexcept
Returns the number of elements in the collection.
virtual std::string dataTypeName() const
Return the name of the data type.
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

◆ initialize()

StatusCode JiveXML::CaloClusterRetriever::initialize ( )

Default AthAlgTool methods.

Definition at line 33 of file CaloClusterRetriever.cxx.

34 {
35
36 ATH_MSG_DEBUG("Initialising Tool");
37
38 ATH_CHECK(m_sgKeyFavourite.initialize());
39
40 return StatusCode::SUCCESS;
41 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & JiveXML::IDataRetriever::interfaceID ( )
inlinestaticinherited

Return the interface identifier.

Definition at line 40 of file IDataRetriever.h.

40{ return IID_IDataRetriever; }
static const InterfaceID IID_IDataRetriever("JiveXML::IDataRetriever", 3, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ retrieve()

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

Retrieve all the data.

For each cluster collections retrieve basic parameters.

'Favourite' cluster collection first, then 'Other' collections.

Parameters
FormatToolthe tool that will create formated output from the DataMap

Implements JiveXML::IDataRetriever.

Definition at line 48 of file CaloClusterRetriever.cxx.

48 {
49
50 ATH_MSG_DEBUG( "in retrieveAll()" );
51
52 //obtain the default collection first
53 ATH_MSG_DEBUG( "Trying to retrieve " << dataTypeName() << " (" << m_sgKeyFavourite.key() << ")" );
54
55 SG::ReadHandle<xAOD::CaloClusterContainer> ccc_primary(m_sgKeyFavourite);
56 if (ccc_primary.isValid()) {
57 DataMap data = getData(&(*ccc_primary));
58 if (FormatTool->AddToEvent(dataTypeName(), m_sgKeyFavourite.key() + "_ESD", &data).isFailure()) {
59 ATH_MSG_WARNING("Failed to retrieve favourite Collection " << m_sgKeyFavourite.key() );
60 }
61 else {
62 ATH_MSG_DEBUG(dataTypeName() << " (" << m_sgKeyFavourite.key() << ") CaloCluster retrieved");
63 }
64 }
65 else{
66 ATH_MSG_WARNING("Favourite Collection " << m_sgKeyFavourite.key() << " not found in SG ");
67 }
68
69 if ( m_otherKeys.empty() ) {
70 //obtain all other collections from StoreGate
71 std::vector<std::string> allkeys;
72 evtStore()->keys(static_cast<CLID>( ClassID_traits<xAOD::CaloClusterContainer>::ID() ), allkeys);
73 for (const auto& key : allkeys) {
74 if (key!=m_sgKeyFavourite.key()) {
75 ATH_MSG_DEBUG( "Trying to retrieve all " << dataTypeName() << " (" << key << ")" );
76 SG::ReadHandle<xAOD::CaloClusterContainer> containerRH(key);
77 if (!containerRH.isValid()) {
78 ATH_MSG_DEBUG( "Unable to retrieve CaloCluster collection " << key );
79 } else {
80 std::string::size_type position = key.find("HLTAutoKey",0);
81 if ( m_doWriteHLT ){ position = 99; } // override SG key find
82 if ( position != 0 ){ // SG key doesn't contain HLTAutoKey
83 DataMap data = getData(&*containerRH);
84 if ( FormatTool->AddToEvent(dataTypeName(), containerRH.key()+"_ESD", &data).isFailure()){
85 ATH_MSG_WARNING( "Collection " << containerRH.key() << " not found in SG " );
86 }else{
87 ATH_MSG_DEBUG( dataTypeName() << " (" << containerRH.key() << ") CaloCluster retrieved" );
88 }
89 }
90 }
91 }
92 }
93 }else {
94 //obtain all collections with keys provided by user: m_otherKeys
95 for (const auto& key : m_otherKeys) {
96 if (key!=m_sgKeyFavourite.key()) {
97 ATH_MSG_DEBUG( "Trying to retrieve selected " << dataTypeName() << " (" << key << ")" );
98 SG::ReadHandle<xAOD::CaloClusterContainer> containerRH(key);
99 if (!containerRH.isValid()) {
100 ATH_MSG_DEBUG( "Unable to retrieve CaloCluster collection " << key );
101 } else {
102 DataMap data = getData(&*containerRH);
103 if ( FormatTool->AddToEvent(dataTypeName(), containerRH.key()+"_ESD", &data).isFailure()){
104 ATH_MSG_WARNING( "Collection " << containerRH.key() << " not found in SG " );
105 }else{
106 ATH_MSG_DEBUG( dataTypeName() << " (" << containerRH.key() << ") retrieved" );
107 }
108 }
109 }
110 }
111 }
112 //All collections retrieved okay
113 return StatusCode::SUCCESS;
114 }
#define ATH_MSG_WARNING(x)
uint32_t CLID
The Class ID type.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
ServiceHandle< StoreGateSvc > & evtStore()
const DataMap getData(const xAOD::CaloClusterContainer *)
Retrieve basic parameters, mainly four-vectors.

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doWriteHLT

bool JiveXML::CaloClusterRetriever::m_doWriteHLT
private

Definition at line 56 of file CaloClusterRetriever.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_otherKeys

std::vector<std::string> JiveXML::CaloClusterRetriever::m_otherKeys
private

Definition at line 55 of file CaloClusterRetriever.h.

◆ m_sgKeyFavourite

SG::ReadHandleKey<xAOD::CaloClusterContainer> JiveXML::CaloClusterRetriever::m_sgKeyFavourite {this, "StoreGateKey", "egammaClusters", "Name of the CaloClusterContainer"}
private

Definition at line 54 of file CaloClusterRetriever.h.

54{this, "StoreGateKey", "egammaClusters", "Name of the CaloClusterContainer"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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