ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterSortingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4// ClusterSortingAlg.cxx
5// TopoCore
6// Created by V Sorin, Joerg Stelzer .
7// algorithm to make list of cluster, pt order applied
8//
13#include <algorithm>
14
15REGISTER_ALG_TCS(ClusterSortingAlg)
16
17bool SortByEtLargestFirst(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
18{
19 return tob1->Et() > tob2->Et();
20}
21
23{
24 return tob1->Et() < tob2->Et();
25}
26
27// constructor
29 defineParameter( "NumberOfClusters", 0 );
30 defineParameter( "ReverseOrder", 0 );
31 defineParameter( "MinIsolation", 0);
32 defineParameter( "MinEta", 0 );
33 defineParameter( "MaxEta", 49);
34}
35
36
37// destructor
39
42
43 const ClusterTOBArray & clusters = dynamic_cast<const ClusterTOBArray&>(input);
44
45 // fill output array with GenericTOB buildt from clusters
46 for(ClusterTOBArray::const_iterator cl = clusters.begin(); cl!= clusters.end(); ++cl ) {
47 const GenericTOB gtob(**cl);
48
49 if (parType_t(std::abs((*cl)-> eta())) < parameter("MinEta").value()) continue;
50 if (parType_t(std::abs((*cl)-> eta())) > parameter("MaxEta").value()) continue;
51
52 // isolation cut
53 if(parType_t((*cl)->isolation()) < parameter("MinIsolation").value()) continue;
54
55 output.push_back( gtob );
56 }
57
58 // sort, possibly in reversed order
59 int reverseOrder = parameter("ReverseOrder").value();
60 if(reverseOrder==1) {
61 output.sort(SortByEtSmallestFirst);
62 } else {
63 output.sort(SortByEtLargestFirst);
64 }
65
66 // keep only max number of clusters
67 int par = parameter("NumberOfClusters").value();
68 unsigned int maxNumberOfClusters = std::clamp(par, 0, std::abs(par));
69 if(maxNumberOfClusters>0) {
70 while( output.size()> maxNumberOfClusters ) {
71 output.pop_back();
72 }
73 }
75}
76
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar eta() const
pseudorapidity method
bool SortByEtSmallestFirst(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
bool SortByEtLargestFirst(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output)
ClusterSortingAlg(const std::string &name)
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void defineParameter(const std::string &name, TCS::parType_t value)
data_t::const_iterator const_iterator
unsigned int Et() const
Definition GenericTOB.h:113
SortingAlg(const std::string &name)
Definition SortingAlg.h:21
uint32_t parType_t
Definition Parameter.h:22