ATLAS Offline Software
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
7 #include "CaloEvent/CaloCell.h"
8 #include "CaloEvent/CaloClusterContainer.h"
9 #include "CaloDetDescr/CaloDetDescrElement.h"
12 #include "GaudiKernel/MsgStream.h"
14 
15 /********************************************************************
16 
17 NAME: CaloClusterRemoveDuplicates.cxx
18 
19 AUTHORS: M. Cooke
20 CREATED: May 2008
21 
22 PURPOSE: Remove duplicate clusters (pathology under investigation)
23 
24 ********************************************************************/
25 
26 
27 // -------------------------------------------------------------
28 // Constructor
29 // -------------------------------------------------------------
30 
32  const std::string& name,
33  const IInterface* parent)
35 {
36  declareProperty ("deta_cut", m_deta_cut = 0.05 );
37  declareProperty ("dphi_cut", m_dphi_cut = 0.05 );
38 }
39 
41 CaloClusterRemoveDuplicates::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 }
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
DataVector::iterator
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition: DataVector.h:841
CaloClusterRemoveDuplicates.h
CaloClusterRemoveDuplicates::execute
StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *clusColl) const override
Execute on an entire collection of clusters.
Definition: CaloClusterRemoveDuplicates.cxx:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCell.h
xAOD::CaloCluster_v1::et
double et() const
Definition: CaloCluster_v1.h:856
CaloClusterRemoveDuplicates::compare
int compare(xAOD::CaloCluster *clus1, xAOD::CaloCluster *clus2) const
Definition: CaloClusterRemoveDuplicates.cxx:89
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloCell_ID.h
CaloClusterRemoveDuplicates::m_dphi_cut
float m_dphi_cut
Definition: CaloClusterRemoveDuplicates.h:61
CaloClusterRemoveDuplicates::m_deta_cut
float m_deta_cut
Definition: CaloClusterRemoveDuplicates.h:60
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CaloClusterRemoveDuplicates::CaloClusterRemoveDuplicates
CaloClusterRemoveDuplicates()
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::erase
iterator erase(iterator position)
Remove element at a given position.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.