37 ATH_MSG_ERROR(
"Empty name provided for TopoCluster collection nothing to "
38 "work with -- aborting");
39 return StatusCode::FAILURE;
44 return StatusCode::SUCCESS;
51 return StatusCode::SUCCESS;
64 return StatusCode::SUCCESS;
77 if (*tcItr && *rcItr && (*tcItr == *rcItr)) {
79 sharedE += tcItr->e();
86 ATH_MSG_VERBOSE(
"Reference cluster and target cluster share " << nSharedCells <<
" cells, " << sharedE <<
" / " << totalE <<
" MeV");
89 return totalE<1
e-9 ? 0. : sharedE/totalE;
103 const std::vector<const xAOD::CaloCluster*>& testClusters,
104 std::vector<const xAOD::CaloCluster*>& matchedClusters)
const
107 matchedClusters.clear();
109 for(
const auto& testCluster : testClusters) {
110 if(
clustersAreMatched(refCluster, *testCluster)) matchedClusters.push_back(testCluster);
112 return !matchedClusters.empty();
119 std::vector<const xAOD::CaloCluster*>& matchedClusters,
121 bool useLeadingCellEtaPhi)
const
123 float refEta(0.), refPhi(0.);
124 if(useLeadingCellEtaPhi) {
128 if(refItr->e() > leadcellE) leadcell = *refItr;
131 refEta = leadcell->
eta();
132 refPhi = leadcell->
phi();
135 refEta = refCluster.
eta();
136 refPhi = refCluster.
phi();
141 const std::vector<const xAOD::CaloCluster*> testClusters =
151 const std::vector<const xAOD::CaloCluster*>& testClusters,
152 std::vector<std::pair<const xAOD::CaloCluster*, float> >& matchedClustersAndE)
const
155 matchedClustersAndE.clear();
157 for(
const auto& testCluster : testClusters) {
160 matchedClustersAndE.emplace_back(testCluster,sharedEfrac);
163 return !matchedClustersAndE.empty();
170 std::vector<std::pair<const xAOD::CaloCluster*, float> >& matchedClustersAndE,
172 bool useLeadingCellEtaPhi)
const
174 float refEta(0.), refPhi(0.);
175 if(useLeadingCellEtaPhi) {
179 if(refItr->e() > leadcellE) leadcell = *refItr;
182 refEta = leadcell->
eta();
183 refPhi = leadcell->
phi();
186 refEta = refCluster.
eta();
187 refPhi = refCluster.
phi();
192 const std::vector<const xAOD::CaloCluster*> testClusters =
203 const std::vector<const xAOD::CaloCluster*>& testClusters,
204 bool (*gtrthan)(
const std::pair<const xAOD::CaloCluster*,float>& pair1,
205 const std::pair<const xAOD::CaloCluster*,float>& pair2))
const
207 std::vector<std::pair<const CaloCluster*,float> > matchedClustersAndE;
208 std::vector<ElementLink<CaloClusterContainer> > tcLinks;
209 std::vector<float> tcSharedE;
210 if(!testClusters.empty()) {
213 std::sort(matchedClustersAndE.begin(),matchedClustersAndE.end(),gtrthan);
214 for(
const auto& tcAndE : matchedClustersAndE) {
215 tcLinks.emplace_back(*pClCont,tcAndE.first->index());
216 tcSharedE.push_back(tcAndE.second);
221 elementLinkDec(refCluster) = std::move(tcLinks);
222 ATH_MSG_VERBOSE(
"Decorate cluster " << refCluster.
index() <<
" with " << elementLinkDec(refCluster).size() <<
" tc links");
224 return StatusCode::SUCCESS;
234 bool useLeadingCellEtaPhi,
235 bool (*gtrthan)(
const std::pair<const xAOD::CaloCluster*,float>& pair1,
236 const std::pair<const xAOD::CaloCluster*,float>& pair2))
const
238 std::vector<std::pair<const CaloCluster*,float> > matchedClustersAndE;
239 std::vector<ElementLink<CaloClusterContainer> > tcLinks;
240 std::vector<float> tcSharedE;
242 if(
getMatchedClusters(refCluster, matchedClustersAndE, tcmap, useLeadingCellEtaPhi)) {
244 std::sort(matchedClustersAndE.begin(),matchedClustersAndE.end(),gtrthan);
245 for(
const auto& tcAndE : matchedClustersAndE) {
246 tcLinks.emplace_back(*pClCont,tcAndE.first->index());
247 tcSharedE.push_back(tcAndE.second);
251 elementLinkDec(refCluster) = std::move(tcLinks);
252 ATH_MSG_VERBOSE(
"Decorate cluster " << refCluster.
index() <<
" with " << elementLinkDec(refCluster).size() <<
" tc links");
254 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle class for adding a decoration to an object.
Data object for each calorimeter readout cell.
virtual double phi() const override final
get phi (through CaloDetDescrElement)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
size_t index() const
Return the index of this element within its container.
const_pointer_type cptr()
Dereference the pointer.
StatusCode SetTopoClusters(const xAOD::CaloClusterContainer *)
std::vector< const xAOD::CaloCluster * > RetrieveTopoClusters(double eta, double phi, double Pt) const
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
const_cell_iterator cell_end() const
virtual double phi() const
The azimuthal angle ( ) of the particle.
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
virtual FourMom_t p4() const
The full 4-momentum of the particle.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.