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

virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool) override
 Retrieve all the data.
const DataMap getData (const xAOD::CaloClusterContainer *)
 Retrieve basic parameters, mainly four-vectors.
virtual std::string dataTypeName () const override
 Return the name of the data type.
virtual StatusCode initialize () override
 Default AthAlgTool methods.

Private Attributes

SG::ReadHandleKey< xAOD::CaloClusterContainerm_sgKeyFavourite
Gaudi::Property< std::vector< std::string > > m_otherKeys
Gaudi::Property< bool > m_doWriteHLT

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 Function Documentation

◆ dataTypeName()

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

Return the name of the data type.

Definition at line 45 of file CaloClusterRetriever.h.

45{ return "Cluster"; };

◆ 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 103 of file CaloClusterRetriever.cxx.

103 {
104
105 ATH_MSG_DEBUG( "getData()" );
106
108
109 DataVect phi; phi.reserve(ccc->size());
110 DataVect eta; eta.reserve(ccc->size());
111 DataVect et; et.reserve(ccc->size());
112 DataVect idVec; idVec.reserve(ccc->size());
113 DataVect numCellsVec; numCellsVec.reserve(ccc->size());
114 DataVect cells; cells.reserve( ccc->size() );
115
116 int noClu = ccc->size();
117 int noCells = 0;
118
119 int id = 0;
120 for (const auto cluster : *ccc) {
121 phi.emplace_back(cluster->phi());
122 eta.emplace_back(cluster->eta());
123 et.emplace_back(cluster->et()*(1./GeV));
124 idVec.emplace_back( ++id );
125
126 int numCells = cluster->size();
127 numCellsVec.emplace_back( numCells );
128 noCells += numCells;
129
130 for (const auto cell : *cluster) {
131 cells.push_back(cell->ID().get_compact());
132 }
133 }
134
135 std::string tagCells;
136 if(noClu){
137 tagCells = "cells multiple=\"" +DataType(noCells/(noClu*1.0)).toString()+"\"";
138 }else{
139 tagCells = "cells multiple=\"1.0\"";
140 }
141
142 // Start with mandatory entries
143 const auto nEntries = phi.size();
144 DataMap["phi"] = std::move(phi);
145 DataMap["eta"] = std::move(eta);
146 DataMap["et"] = std::move(et);
147 DataMap[tagCells] = std::move(cells);
148 DataMap["numCells"] = std::move(numCellsVec);
149 DataMap["id"] = std::move(idVec);
150
151 //Be verbose
152 ATH_MSG_DEBUG( dataTypeName() << " , collection: " << dataTypeName()
153 << " retrieved with " << nEntries << " entries" );
154
155 //All collections retrieved okay
156 return DataMap;
157
158 } // 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 override
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 ( )
overridevirtual

Default AthAlgTool methods.

Definition at line 13 of file CaloClusterRetriever.cxx.

14 {
15
16 ATH_MSG_DEBUG("Initialising Tool");
17
18 ATH_CHECK(m_sgKeyFavourite.initialize());
19
20 return StatusCode::SUCCESS;
21 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_sgKeyFavourite

◆ retrieve()

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

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

Definition at line 28 of file CaloClusterRetriever.cxx.

28 {
29
30 ATH_MSG_DEBUG( "in retrieveAll()" );
31
32 //obtain the default collection first
33 ATH_MSG_DEBUG( "Trying to retrieve " << dataTypeName() << " (" << m_sgKeyFavourite.key() << ")" );
34
35 SG::ReadHandle<xAOD::CaloClusterContainer> ccc_primary(m_sgKeyFavourite);
36 if (ccc_primary.isValid()) {
37 DataMap data = getData(&(*ccc_primary));
38 if (FormatTool->AddToEvent(dataTypeName(), m_sgKeyFavourite.key() + "_ESD", &data).isFailure()) {
39 ATH_MSG_WARNING("Failed to retrieve favourite Collection " << m_sgKeyFavourite.key() );
40 }
41 else {
42 ATH_MSG_DEBUG(dataTypeName() << " (" << m_sgKeyFavourite.key() << ") CaloCluster retrieved");
43 }
44 }
45 else{
46 ATH_MSG_WARNING("Favourite Collection " << m_sgKeyFavourite.key() << " not found in SG ");
47 }
48
49 if ( m_otherKeys.empty() ) {
50 //obtain all other collections from StoreGate
51 std::vector<std::string> allkeys;
52 evtStore()->keys(static_cast<CLID>( ClassID_traits<xAOD::CaloClusterContainer>::ID() ), allkeys);
53 for (const auto& key : allkeys) {
54 if (key!=m_sgKeyFavourite.key()) {
55 ATH_MSG_DEBUG( "Trying to retrieve all " << dataTypeName() << " (" << key << ")" );
56 SG::ReadHandle<xAOD::CaloClusterContainer> containerRH(key);
57 if (!containerRH.isValid()) {
58 ATH_MSG_DEBUG( "Unable to retrieve CaloCluster collection " << key );
59 } else {
60 std::string::size_type position = key.find("HLTAutoKey",0);
61 if ( m_doWriteHLT ){ position = 99; } // override SG key find
62 if ( position != 0 ){ // SG key doesn't contain HLTAutoKey
63 DataMap data = getData(&*containerRH);
64 if ( FormatTool->AddToEvent(dataTypeName(), containerRH.key()+"_ESD", &data).isFailure()){
65 ATH_MSG_WARNING( "Collection " << containerRH.key() << " not found in SG " );
66 }else{
67 ATH_MSG_DEBUG( dataTypeName() << " (" << containerRH.key() << ") CaloCluster retrieved" );
68 }
69 }
70 }
71 }
72 }
73 }else {
74 //obtain all collections with keys provided by user: m_otherKeys
75 for (const auto& key : m_otherKeys) {
76 if (key!=m_sgKeyFavourite.key()) {
77 ATH_MSG_DEBUG( "Trying to retrieve selected " << dataTypeName() << " (" << key << ")" );
78 SG::ReadHandle<xAOD::CaloClusterContainer> containerRH(key);
79 if (!containerRH.isValid()) {
80 ATH_MSG_DEBUG( "Unable to retrieve CaloCluster collection " << key );
81 } else {
82 DataMap data = getData(&*containerRH);
83 if ( FormatTool->AddToEvent(dataTypeName(), containerRH.key()+"_ESD", &data).isFailure()){
84 ATH_MSG_WARNING( "Collection " << containerRH.key() << " not found in SG " );
85 }else{
86 ATH_MSG_DEBUG( dataTypeName() << " (" << containerRH.key() << ") retrieved" );
87 }
88 }
89 }
90 }
91 }
92 //All collections retrieved okay
93 return StatusCode::SUCCESS;
94 }
#define ATH_MSG_WARNING(x)
uint32_t CLID
The Class ID type.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Property< std::vector< std::string > > m_otherKeys
Gaudi::Property< bool > m_doWriteHLT
const DataMap getData(const xAOD::CaloClusterContainer *)
Retrieve basic parameters, mainly four-vectors.
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.

Member Data Documentation

◆ m_doWriteHLT

Gaudi::Property<bool> JiveXML::CaloClusterRetriever::m_doWriteHLT
private
Initial value:
{this
, "DoWriteHLT", false, "Ignore HLTAutokey object by default"}

Definition at line 55 of file CaloClusterRetriever.h.

55 {this
56 , "DoWriteHLT", false, "Ignore HLTAutokey object by default"};

◆ m_otherKeys

Gaudi::Property<std::vector<std::string> > JiveXML::CaloClusterRetriever::m_otherKeys
private
Initial value:
{this
, "OtherClusterCollections", {}, "Other collections to be retrieved. If list left empty, all available retrieved"}

Definition at line 53 of file CaloClusterRetriever.h.

53 {this
54 , "OtherClusterCollections", {}, "Other collections to be retrieved. If list left empty, all available retrieved"};

◆ m_sgKeyFavourite

SG::ReadHandleKey<xAOD::CaloClusterContainer> JiveXML::CaloClusterRetriever::m_sgKeyFavourite
private
Initial value:
{this
, "FavouriteClusterCollection", "egammaClusters", "Collection to be first in output, shown in Atlantis without switching"}

Definition at line 51 of file CaloClusterRetriever.h.

51 {this
52 , "FavouriteClusterCollection", "egammaClusters", "Collection to be first in output, shown in Atlantis without switching"};

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