ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
 ~PFClusterSelectorTool ()
 Default destructor. More...
 
StatusCode initialize ()
 Gaudi AthAlgorithm hooks. More...
 
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 More...
 

Private Attributes

SG::ReadHandleKey< xAOD::CaloClusterContainerm_caloClustersReadHandleKey
 ReadHandleKey for the CaloClusterContainer to be used as input. More...
 
SG::ReadHandleKey< xAOD::CaloClusterContainerm_caloCalClustersReadHandleKey
 ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as input. More...
 
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey
 ReadCondHandleKey for CaloDetDescrManager. More...
 

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 27 of file PFClusterSelectorTool.cxx.

30 {
31 
33 
34  /* Verify the read handle has a valid pointer, and if not return */
35  if (!caloClustersReadHandle.isValid()){
36  ATH_MSG_WARNING(" Invalid ReadHandle for xAOD::CaloCluster with key: " << caloClustersReadHandle.key());
37  return StatusCode::SUCCESS;
38  }
39 
40  const xAOD::CaloClusterContainer* calclusters = nullptr;
41  if (!m_caloCalClustersReadHandleKey.key().empty()) {
43  calclusters = caloCalClustersReadHandle.get();
44  }
45 
47  ATH_CHECK(caloMgrHandle.isValid());
48 
49  /* Fill the vector of eflowRecClusters */
50  unsigned int nClusters = caloClustersReadHandle->size();
51  for (unsigned int iCluster = 0; iCluster < nClusters; ++iCluster) {
52  /* Create the eflowRecCluster and put it in the container */
53  std::unique_ptr<eflowRecCluster> thisEFRecCluster = std::make_unique<eflowRecCluster>(ElementLink<xAOD::CaloClusterContainer>(*caloClustersReadHandle, iCluster), theCaloClusterContainer);
54 
55  if (calclusters){
56  std::map<IdentifierHash,double> cellsWeightMap;
57  retrieveLCCalCellWeight(caloClustersReadHandle->at(iCluster)->e(), iCluster, cellsWeightMap, *calclusters,**caloMgrHandle);
58 
59  thisEFRecCluster->setCellsWeight(std::move(cellsWeightMap));
60  }
61 
62  thisEFRecCluster->setClusterId(iCluster);
63  theEFlowRecClusterContainer.push_back(std::move(thisEFRecCluster));
64  }
65 
66  return StatusCode::SUCCESS;
67 }

◆ finalize()

StatusCode PFClusterSelectorTool::finalize ( )

Definition at line 69 of file PFClusterSelectorTool.cxx.

69  {
70  return StatusCode::SUCCESS;
71 }

◆ initialize()

StatusCode PFClusterSelectorTool::initialize ( )

Gaudi AthAlgorithm hooks.

Definition at line 15 of file PFClusterSelectorTool.cxx.

15  {
16 
18  if(!m_caloCalClustersReadHandleKey.key().empty()) {
20  }
22 
23  return StatusCode::SUCCESS;
24 }

◆ 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 74 of file PFClusterSelectorTool.cxx.

80 {
81  /* match CaloCluster with CaloCalCluster to obtain cell weight */
82  /* first try the position at 'index'. If we are lucky, the loop can be
83  * avoided. */
84  /* Note the read handle has been tested to be valid prior to the call of this
85  * function */
86  const xAOD::CaloCluster* matchedCalCluster = caloCalClustersContainer.at(index);
87  if (matchedCalCluster){
88  if (!(fabs(energy - matchedCalCluster->rawE()) < 0.001)) {
89  matchedCalCluster = nullptr;
90  for (const auto *iCalCalCluster : caloCalClustersContainer) {
91  matchedCalCluster = iCalCalCluster;
92  if (fabs(energy - matchedCalCluster->rawE()) < 0.001) {
93  break;
94  }
95  }
96  if (!matchedCalCluster) ATH_MSG_WARNING("Invalid pointer to matched cluster - failed to find cluster match");
97  }
98  if (not matchedCalCluster){
99  throw std::runtime_error("matchedCluster is a null pointer in PFClusterSelectorTool::retrieveLCCalCellWeight");
100  }
101  /* obtain cell index and cell weight */
102  const CaloCell_ID* calo_id = calo_dd_man.getCaloCell_ID();
103  xAOD::CaloCluster::const_cell_iterator itCell = matchedCalCluster->cell_begin();
104  xAOD::CaloCluster::const_cell_iterator endCell = matchedCalCluster->cell_end();
105  for (; itCell != endCell; ++itCell) {
106  const CaloCell* pCell = *itCell;
107  Identifier myId = pCell->ID();
108  IdentifierHash myHashId = calo_id->calo_cell_hash(myId);
109  cellsWeight[myHashId] = itCell.weight();
110  }
111  } else ATH_MSG_WARNING("Invalid pointer to matched cluster - could not look up local hadron cell weights");
112 }

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.

◆ 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.

◆ 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 59 of file PFClusterSelectorTool.h.


The documentation for this class was generated from the following files:
xAOD::CaloCluster_v1::rawE
flt_t rawE() const
PFClusterSelectorTool::m_caloClustersReadHandleKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersReadHandleKey
ReadHandleKey for the CaloClusterContainer to be used as input.
Definition: PFClusterSelectorTool.h:41
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
test_pyathena.parent
parent
Definition: test_pyathena.py:15
eflowRecCluster::setCellsWeight
void setCellsWeight(std::map< IdentifierHash, double > &&cellsWeight)
Definition: eflowRecCluster.h:81
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PFClusterSelectorTool::retrieveLCCalCellWeight
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 ...
Definition: PFClusterSelectorTool.cxx:74
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:279
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloDetDescrManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
Definition: CaloDetDescrManager.cxx:1590
PFClusterSelectorTool::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
ReadCondHandleKey for CaloDetDescrManager.
Definition: PFClusterSelectorTool.h:59
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
PFClusterSelectorTool::m_caloCalClustersReadHandleKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloCalClustersReadHandleKey
ReadHandleKey for the CaloClusterContainer, at LC scale, to be used as input.
Definition: PFClusterSelectorTool.h:50
IdentifierHash
Definition: IdentifierHash.h:38
eflowRecCluster::setClusterId
void setClusterId(int clusterId)
Definition: eflowRecCluster.h:80