ATLAS Offline Software
Loading...
Searching...
No Matches
PFClusterSelectorTool Class Reference

#include <PFClusterSelectorTool.h>

Inheritance diagram for PFClusterSelectorTool:
Collaboration diagram for PFClusterSelectorTool:

Public Member Functions

 PFClusterSelectorTool (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor.
 ~PFClusterSelectorTool ()
 Default destructor.
StatusCode initialize ()
 Gaudi AthAlgorithm hooks.
StatusCode execute (eflowRecClusterContainer &theEFlowRecClusterContainer, xAOD::CaloClusterContainer &theCaloClusterContainer) const
StatusCode finalize ()

Private Member Functions

void retrieveLCCalCellWeight (const double &energy, const unsigned &index, std::map< IdentifierHash, double > &cellsWeight, const xAOD::CaloClusterContainer &caloCalClustersContainer, const CaloDetDescrManager &calo_dd_man) const
 for EM mode, LC weight for cells are retrieved before doing any subtraction; they will be used after subtraction

Private Attributes

SG::ReadHandleKey< xAOD::CaloClusterContainerm_caloClustersReadHandleKey
 ReadHandleKey for the CaloClusterContainer to be used as input.
SG::ReadHandleKey< xAOD::CaloClusterContainerm_caloCalClustersReadHandleKey
 ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as input.
SG::ReadDecorHandleKey< xAOD::CaloClusterContainerm_caloClusterReadDecorHandleKeyNLeadingTruthParticles {this,"CaloClusterReadDecorHandleKey_NLeadingTruthParticles",""}
 Read handle key to decorate CaloCluster with threeN leading truth particle uniqueID and energy.
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey
 ReadCondHandleKey for CaloDetDescrManager.

Detailed Description

Definition at line 16 of file PFClusterSelectorTool.h.

Constructor & Destructor Documentation

◆ PFClusterSelectorTool()

PFClusterSelectorTool::PFClusterSelectorTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Default constructor.

Definition at line 10 of file PFClusterSelectorTool.cxx.

10 :
11 base_class(type, name, parent)
12{
13}

◆ ~PFClusterSelectorTool()

PFClusterSelectorTool::~PFClusterSelectorTool ( )
inline

Default destructor.

Definition at line 22 of file PFClusterSelectorTool.h.

22{};

Member Function Documentation

◆ execute()

StatusCode PFClusterSelectorTool::execute ( eflowRecClusterContainer & theEFlowRecClusterContainer,
xAOD::CaloClusterContainer & theCaloClusterContainer ) const

Definition at line 32 of file PFClusterSelectorTool.cxx.

35{
36
37 SG::ReadHandle<xAOD::CaloClusterContainer> caloClustersReadHandle(m_caloClustersReadHandleKey);
38
39 /* Verify the read handle has a valid pointer, and if not return */
40 if (!caloClustersReadHandle.isValid()){
41 ATH_MSG_WARNING(" Invalid ReadHandle for xAOD::CaloCluster with key: " << caloClustersReadHandle.key());
42 return StatusCode::SUCCESS;
43 }
44
45 const xAOD::CaloClusterContainer* calclusters = nullptr;
46 if (!m_caloCalClustersReadHandleKey.key().empty()) {
47 SG::ReadHandle<xAOD::CaloClusterContainer> caloCalClustersReadHandle(m_caloCalClustersReadHandleKey);
48 calclusters = caloCalClustersReadHandle.get();
49 }
50
51 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey};
52 ATH_CHECK(caloMgrHandle.isValid());
53
54 /* Fill the vector of eflowRecClusters */
55 unsigned int nClusters = caloClustersReadHandle->size();
56 for (unsigned int iCluster = 0; iCluster < nClusters; ++iCluster) {
57 /* Create the eflowRecCluster and put it in the container */
58 std::unique_ptr<eflowRecCluster> thisEFRecCluster = std::make_unique<eflowRecCluster>(ElementLink<xAOD::CaloClusterContainer>(*caloClustersReadHandle, iCluster), theCaloClusterContainer);
59
60 if (calclusters){
61 std::map<IdentifierHash,double> cellsWeightMap;
62 retrieveLCCalCellWeight(caloClustersReadHandle->at(iCluster)->e(), iCluster, cellsWeightMap, *calclusters,**caloMgrHandle);
63
64 thisEFRecCluster->setCellsWeight(std::move(cellsWeightMap));
65 }
66
68
69 std::string decorHandleName = m_caloClusterReadDecorHandleKeyNLeadingTruthParticles.key();
70 std::string::size_type pos = decorHandleName.find(".");
71 std::string decorName = decorHandleName.substr(pos+1);
72
74 accessor(*theCaloClusterContainer[iCluster]) = accessor(*caloClustersReadHandle->at(iCluster));
75 }
76
77 thisEFRecCluster->setClusterId(iCluster);
78 theEFlowRecClusterContainer.push_back(std::move(thisEFRecCluster));
79 }
80
81 return StatusCode::SUCCESS;
82}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
const T * get(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
ReadCondHandleKey for CaloDetDescrManager.
void retrieveLCCalCellWeight(const double &energy, const unsigned &index, std::map< IdentifierHash, double > &cellsWeight, const xAOD::CaloClusterContainer &caloCalClustersContainer, const CaloDetDescrManager &calo_dd_man) const
for EM mode, LC weight for cells are retrieved before doing any subtraction; they will be used after ...
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloCalClustersReadHandleKey
ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as input.
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_caloClusterReadDecorHandleKeyNLeadingTruthParticles
Read handle key to decorate CaloCluster with threeN leading truth particle uniqueID and energy.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersReadHandleKey
ReadHandleKey for the CaloClusterContainer to be used as input.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.

◆ finalize()

StatusCode PFClusterSelectorTool::finalize ( )

Definition at line 84 of file PFClusterSelectorTool.cxx.

84 {
85 return StatusCode::SUCCESS;
86}

◆ initialize()

StatusCode PFClusterSelectorTool::initialize ( )

Gaudi AthAlgorithm hooks.

Definition at line 15 of file PFClusterSelectorTool.cxx.

15 {
16
18 if(!m_caloCalClustersReadHandleKey.key().empty()) {
20 }
21
24 }
25
26 ATH_CHECK(m_caloMgrKey.initialize());
27
28 return StatusCode::SUCCESS;
29}

◆ retrieveLCCalCellWeight()

void PFClusterSelectorTool::retrieveLCCalCellWeight ( const double & energy,
const unsigned & index,
std::map< IdentifierHash, double > & cellsWeight,
const xAOD::CaloClusterContainer & caloCalClustersContainer,
const CaloDetDescrManager & calo_dd_man ) const
private

for EM mode, LC weight for cells are retrieved before doing any subtraction; they will be used after subtraction

Definition at line 89 of file PFClusterSelectorTool.cxx.

95{
96 /* match CaloCluster with CaloCalCluster to obtain cell weight */
97 /* first try the position at 'index'. If we are lucky, the loop can be
98 * avoided. */
99 /* Note the read handle has been tested to be valid prior to the call of this
100 * function */
101 const xAOD::CaloCluster* matchedCalCluster = caloCalClustersContainer.at(index);
102 if (matchedCalCluster){
103 if (!(fabs(energy - matchedCalCluster->rawE()) < 0.001)) {
104 matchedCalCluster = nullptr;
105 for (const auto *iCalCalCluster : caloCalClustersContainer) {
106 matchedCalCluster = iCalCalCluster;
107 if (fabs(energy - matchedCalCluster->rawE()) < 0.001) {
108 break;
109 }
110 }
111 if (!matchedCalCluster) ATH_MSG_WARNING("Invalid pointer to matched cluster - failed to find cluster match");
112 }
113 if (not matchedCalCluster){
114 throw std::runtime_error("matchedCluster is a null pointer in PFClusterSelectorTool::retrieveLCCalCellWeight");
115 }
116 /* obtain cell index and cell weight */
117 const CaloCell_ID* calo_id = calo_dd_man.getCaloCell_ID();
118 xAOD::CaloCluster::const_cell_iterator itCell = matchedCalCluster->cell_begin();
119 xAOD::CaloCluster::const_cell_iterator endCell = matchedCalCluster->cell_end();
120 for (; itCell != endCell; ++itCell) {
121 const CaloCell* pCell = *itCell;
122 Identifier myId = pCell->ID();
123 IdentifierHash myHashId = calo_id->calo_cell_hash(myId);
124 cellsWeight[myHashId] = itCell.weight();
125 }
126 } else ATH_MSG_WARNING("Invalid pointer to matched cluster - could not look up local hadron cell weights");
127}
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
const T * at(size_type n) const
Access an element, as an rvalue.
flt_t rawE() const
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

Member Data Documentation

◆ m_caloCalClustersReadHandleKey

SG::ReadHandleKey<xAOD::CaloClusterContainer> PFClusterSelectorTool::m_caloCalClustersReadHandleKey
private
Initial value:
{
this,
"calClustersName",
"CaloCalTopoClusters",
"ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as "
"input"
}

ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as input.

Definition at line 50 of file PFClusterSelectorTool.h.

50 {
51 this,
52 "calClustersName",
53 "CaloCalTopoClusters",
54 "ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as "
55 "input"
56 };

◆ m_caloClusterReadDecorHandleKeyNLeadingTruthParticles

SG::ReadDecorHandleKey<xAOD::CaloClusterContainer> PFClusterSelectorTool::m_caloClusterReadDecorHandleKeyNLeadingTruthParticles {this,"CaloClusterReadDecorHandleKey_NLeadingTruthParticles",""}
private

Read handle key to decorate CaloCluster with threeN leading truth particle uniqueID and energy.

Definition at line 59 of file PFClusterSelectorTool.h.

59{this,"CaloClusterReadDecorHandleKey_NLeadingTruthParticles",""};

◆ m_caloClustersReadHandleKey

SG::ReadHandleKey<xAOD::CaloClusterContainer> PFClusterSelectorTool::m_caloClustersReadHandleKey
private
Initial value:
{
this,
"clustersName",
"CaloTopoClusters",
"ReadHandleKey for the CaloClusterContainer to be used as input"
}

ReadHandleKey for the CaloClusterContainer to be used as input.

Definition at line 41 of file PFClusterSelectorTool.h.

41 {
42 this,
43 "clustersName",
44 "CaloTopoClusters",
45 "ReadHandleKey for the CaloClusterContainer to be used as input"
46 };

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> PFClusterSelectorTool::m_caloMgrKey
private
Initial value:
{
this,
"CaloDetDescrManager",
"CaloDetDescrManager",
"SG Key for CaloDetDescrManager in the Condition Store"
}

ReadCondHandleKey for CaloDetDescrManager.

Definition at line 62 of file PFClusterSelectorTool.h.

62 {
63 this,
64 "CaloDetDescrManager",
65 "CaloDetDescrManager",
66 "SG Key for CaloDetDescrManager in the Condition Store"
67 };

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