ATLAS Offline Software
Loading...
Searching...
No Matches
JetSortingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4// JetSortingAlg.cxx
5// TopoCore
6// Created by Joerg Stelzer on 11/10/12.
7
12#include <algorithm>
13
14REGISTER_ALG_TCS(JetSortingAlg)
15
16bool SortByEtLargestFirst2(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
17{
18 return tob1->Et() > tob2->Et();
19}
20
22{
23 return tob1->Et() < tob2->Et();
24}
25
26// constructor
29{
30 defineParameter( "NumberOfJets", 0 );
31 defineParameter( "ReverseOrder", 0 );
32 defineParameter( "JetSize", 0 );
33 defineParameter( "MinEta", 0 );
34 defineParameter( "MaxEta", 49);
36}
37
38
41
42
43
44
45
46
49 const JetTOBArray & jets = dynamic_cast<const JetTOBArray&>(input);
50 // because hw seems to be using different notation, for now 2 means 8x8 or JS1, and 1 JS2 a 4x4
51 m_jetsize = parameter("JetSize").value()==2?JetTOB::JS1:JetTOB::JS2;
52
53 // fill output array with GenericTOBs builds from jets
54 for(JetTOBArray::const_iterator cl = jets.begin(); cl!= jets.end(); ++cl ) {
55 if (parType_t(std::abs((*cl)-> eta())) < parameter("MinEta").value()) continue;
56 if (parType_t(std::abs((*cl)-> eta())) > parameter("MaxEta").value()) continue;
57 output.push_back( GenericTOB(**cl, m_jetsize) );
58 }
59
60 // sort, possibly in reversed order
61 int reverseOrder = parameter("ReverseOrder").value();
62 if(reverseOrder==1) {
63 output.sort(SortByEtSmallestFirst2);
64 } else {
65 output.sort(SortByEtLargestFirst2);
66 }
67
68 // keep only max number of jets
69 int par = parameter("NumberOfJets").value();
70 unsigned int maxNumberOfJets = std::clamp(par, 0, std::abs(par));
71 if(maxNumberOfJets>0) {
72 while( output.size()> maxNumberOfJets ) {
73 output.pop_back();
74 }
75 }
77}
78
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar eta() const
pseudorapidity method
bool SortByEtSmallestFirst2(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
bool SortByEtLargestFirst2(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
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
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output)
JetTOB::JetSize m_jetsize
JetSortingAlg(const std::string &name)
SortingAlg(const std::string &name)
Definition SortingAlg.h:21
uint32_t parType_t
Definition Parameter.h:22