ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterSort.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4// ClusterSort.cxx
5// TopoCore
6// Created by Joerg Stelzer on 11/10/12.
7// algorithm to create sorted lists for clusters, et order applied
8//
13#include <algorithm>
14
15REGISTER_ALG_TCS(ClusterSort)
16
17bool SortByEtLargest(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
18{
19 return tob1->Et() > tob2->Et();
20}
21
22
23// constructor
25 defineParameter( "InputWidth", 120 ); // for FW
26 defineParameter( "InputWidth1stStage", 30 ); // for FW
27 defineParameter( "OutputWidth", 6);
28 defineParameter( "IsoMask", 0);
29 defineParameter( "MinEta", 0);
30 defineParameter( "MaxEta", 63);
31 defineParameter( "DoIsoCut", 1);
32}
33
34
35// destructor
37
38
41 m_numberOfClusters = parameter("OutputWidth").value();
42 m_iso = parameter("IsoMask").value();
43 m_minEta = parameter("MinEta").value();
44 m_maxEta = parameter("MaxEta").value();
45 m_doIsoCut = parameter( "DoIsoCut").value();
47}
48
49
52
53 const ClusterTOBArray & clusters = dynamic_cast<const ClusterTOBArray&>(input);
54
55 // fill output array with GenericTOB buildt from clusters
56 for(ClusterTOBArray::const_iterator cl = clusters.begin(); cl!= clusters.end(); ++cl ) {
57 const GenericTOB gtob(**cl);
58
59 if (parType_t(std::abs((*cl)-> eta())) < m_minEta) continue;
60 if (parType_t(std::abs((*cl)-> eta())) > m_maxEta) continue;
61 // isolation cut
62 if (m_iso != 0 ) {
63 unsigned int isobit(0x1 << (m_iso-1));
64 if(m_doIsoCut && ((parType_t((*cl)->isolation()) & isobit) != isobit)) continue;
65 }
66
67 output.push_back( gtob );
68 }
69
70 // sort
71 output.sort(SortByEtLargest);
72
73
74 // keep only max number of clusters
75 int par = m_numberOfClusters;
76 unsigned int maxNumberOfClusters = std::clamp(par, 0, std::abs(par));
77 if(maxNumberOfClusters>0) {
78 while( output.size()> maxNumberOfClusters ) {
79 output.pop_back();
80 }
81 }
83}
84
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar eta() const
pseudorapidity method
bool SortByEtLargest(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output)
virtual ~ClusterSort()
parType_t m_iso
Definition ClusterSort.h:35
parType_t m_minEta
Definition ClusterSort.h:33
virtual TCS::StatusCode initialize()
parType_t m_doIsoCut
Definition ClusterSort.h:36
ClusterSort(const std::string &name)
parType_t m_maxEta
Definition ClusterSort.h:34
parType_t m_numberOfClusters
Definition ClusterSort.h:32
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
SortingAlg(const std::string &name)
Definition SortingAlg.h:21
uint32_t parType_t
Definition Parameter.h:22