ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterRemoveDuplicates.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 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 declareProperty ("deta_cut", m_deta_cut = 0.05 );
37 declareProperty ("dphi_cut", m_dphi_cut = 0.05 );
38}
39
40StatusCode
41CaloClusterRemoveDuplicates::execute(const EventContext& /*ctx*/,
42 xAOD::CaloClusterContainer* clusColl) const
43{
44
45 ATH_MSG_DEBUG( "Executing CaloClusterRemoveDuplicates" << endmsg);
46
47 using clus_iterator = xAOD::CaloClusterContainer::iterator;
48 clus_iterator iter1 = clusColl->begin();
49
50 ATH_MSG_DEBUG( "Collection has before dup rem size: " << clusColl->size() << endmsg);
51 for( ;iter1!=clusColl->end(); ) {
52 int comparison = 0;
53
54 clus_iterator iter2 = iter1;
55 for( iter2++ ; iter2!=clusColl->end() ; ){
56 // Compare cluster pairs
57 comparison = compare( (*iter1) , (*iter2) );
58
59 if( comparison == 1 ){
60 break; // Want to delete 1, break out of loop over 2nd list and delete below
61 }
62 else if( comparison == 2 ){
63 //std::cout << "about to delete 2" << std::endl;
64 // Want to delete 2, delete here and continue through 2nd list
65 iter2 = clusColl->erase(iter2);
66 }
67 else{
68 // No match, keep going through 2nd list
69 iter2++;
70 }
71 }
72
73 if( comparison == 1){
74 //std::cout << "about to delete 1" << std::endl;
75 // Want to delete 1, delete here and continue through 1st list
76 iter1 = clusColl->erase(iter1);
77 }
78 else{
79 // Did not need to delete 1, continue going through 1st list
80 ++iter1;
81 }
82 }
83 ATH_MSG_DEBUG( "Collection has after dup rem size: " << clusColl->size() << endmsg);
84
85 return StatusCode::SUCCESS;
86}
87
88
90 xAOD::CaloCluster* clus2 ) const
91{
92
93 double deta = fabs ( clus1->eta() - clus2->eta() );
94 double dphi = fabs ( clus1->phi() - clus2->phi() );
95
96 // Check for special equivalence by 2pi case
97 if( fabs( dphi - 6.283185 ) < m_dphi_cut ) dphi = dphi - 6.283185;
98
99 if( deta <= m_deta_cut && dphi <= m_dphi_cut ){
100
101 if( clus2->et() > clus1->et() ){ // Cluster 2 has greater E, request to eliminate Cluster 1
102 return 1;
103 }
104 else if( clus1->et() >= clus2->et() ){ // Cluster 1 has greater E, request to eliminate Cluster 2
105 return 2;
106 }
107 }
108
109 return 0 ; // No Match
110
111}
#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:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.