ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterRemoveDuplicates.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// include header files
8#include "CaloEvent/CaloClusterContainer.h"
9#include "CaloDetDescr/CaloDetDescrElement.h"
12#include "GaudiKernel/MsgStream.h"
14
15/********************************************************************
16
17NAME: CaloClusterRemoveDuplicates.cxx
18
19AUTHORS: M. Cooke
20CREATED: May 2008
21
22PURPOSE: Remove duplicate clusters (pathology under investigation)
23
24********************************************************************/
25
26
27// -------------------------------------------------------------
28// Constructor
29// -------------------------------------------------------------
30
32 const std::string& name,
33 const IInterface* parent)
34 : AthAlgTool(type, name, parent)
35{
36}
37
38StatusCode
39CaloClusterRemoveDuplicates::execute(const EventContext& /*ctx*/,
40 xAOD::CaloClusterContainer* clusColl) const
41{
42
43 ATH_MSG_DEBUG( "Executing CaloClusterRemoveDuplicates" << endmsg);
44
45 using clus_iterator = xAOD::CaloClusterContainer::iterator;
46 clus_iterator iter1 = clusColl->begin();
47
48 ATH_MSG_DEBUG( "Collection has before dup rem size: " << clusColl->size() << endmsg);
49 for( ;iter1!=clusColl->end(); ) {
50 int comparison = 0;
51
52 clus_iterator iter2 = iter1;
53 for( iter2++ ; iter2!=clusColl->end() ; ){
54 // Compare cluster pairs
55 comparison = compare( (*iter1) , (*iter2) );
56
57 if( comparison == 1 ){
58 break; // Want to delete 1, break out of loop over 2nd list and delete below
59 }
60 else if( comparison == 2 ){
61 //std::cout << "about to delete 2" << std::endl;
62 // Want to delete 2, delete here and continue through 2nd list
63 iter2 = clusColl->erase(iter2);
64 }
65 else{
66 // No match, keep going through 2nd list
67 iter2++;
68 }
69 }
70
71 if( comparison == 1){
72 //std::cout << "about to delete 1" << std::endl;
73 // Want to delete 1, delete here and continue through 1st list
74 iter1 = clusColl->erase(iter1);
75 }
76 else{
77 // Did not need to delete 1, continue going through 1st list
78 ++iter1;
79 }
80 }
81 ATH_MSG_DEBUG( "Collection has after dup rem size: " << clusColl->size() << endmsg);
82
83 return StatusCode::SUCCESS;
84}
85
86
88 xAOD::CaloCluster* clus2 ) const
89{
90
91 double deta = fabs ( clus1->eta() - clus2->eta() );
92 double dphi = fabs ( clus1->phi() - clus2->phi() );
93
94 // Check for special equivalence by 2pi case
95 if( fabs( dphi - 6.283185 ) < m_dphi_cut ) dphi = dphi - 6.283185;
96
97 if( deta <= m_deta_cut && dphi <= m_dphi_cut ){
98
99 if( clus2->et() > clus1->et() ){ // Cluster 2 has greater E, request to eliminate Cluster 1
100 return 1;
101 }
102 else if( clus1->et() >= clus2->et() ){ // Cluster 1 has greater E, request to eliminate Cluster 2
103 return 2;
104 }
105 }
106
107 return 0 ; // No Match
108
109}
#define endmsg
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
An STL vector of pointers that by default owns its pointed-to elements.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
int compare(xAOD::CaloCluster *clus1, xAOD::CaloCluster *clus2) const
StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *clusColl) const override
Execute on an entire collection of clusters.
CaloClusterRemoveDuplicates(const std::string &type, const std::string &name, const IInterface *parent)
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.