ATLAS Offline Software
Loading...
Searching...
No Matches
gJetSort.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4// gJetSort.cxx
5// TopoCore
6// algorithm to make sorted gJets lists
7//
12#include <algorithm>
13
14REGISTER_ALG_TCS(gJetSort)
15
16bool SortByEtLargestgJet(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
17{
18 return tob1->Et() > tob2->Et();
19}
20
21
22// constructor
23TCS::gJetSort::gJetSort(const std::string & name) :
25{
26 defineParameter( "InputWidth", 64 ); // for FW
27 defineParameter( "InputWidth1stStage", 16 ); // for FW
28 defineParameter( "OutputWidth", 10 );
29 defineParameter( "MinEta", 0 );
30 defineParameter( "MaxEta", 196 );
31}
32
33
36
37
38
41 m_numberOfJets = parameter("OutputWidth").value();
42 m_minEta = parameter("MinEta").value();
43 m_maxEta = parameter("MaxEta").value();
45}
46
47
49TCS::gJetSort::sort(const InputTOBArray & input, TOBArray & output) {
50 const gJetTOBArray & jets = dynamic_cast<const gJetTOBArray&>(input);
51
52 // fill output array with GenericTOBs builds from jets
53 for(gJetTOBArray::const_iterator jet = jets.begin(); jet!= jets.end(); ++jet ) {
54 if ( parType_t(std::abs((*jet)-> eta())) < m_minEta) continue;
55 if ( parType_t(std::abs((*jet)-> eta())) > m_maxEta) continue;
56 output.push_back( GenericTOB(**jet) );
57 }
58
59 // sort
60 output.sort(SortByEtLargestgJet);
61
62
63 // keep only max number of jets
64 int par = m_numberOfJets;
65 unsigned int maxNumberOfJets = std::clamp(par, 0, std::abs(par));
66 if(maxNumberOfJets>0) {
67 while( output.size()> maxNumberOfJets ) {
68 if (output.size() == (maxNumberOfJets+1)) {
69 bool isAmbiguous = output[maxNumberOfJets-1].EtDouble() == output[maxNumberOfJets].EtDouble();
70 if (isAmbiguous) { output.setAmbiguityFlag(true); }
71 }
72 output.pop_back();
73 }
74 }
76}
77
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar eta() const
pseudorapidity method
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
parType_t m_maxEta
Definition gJetSort.h:33
virtual ~gJetSort()
Definition gJetSort.cxx:34
parType_t m_minEta
Definition gJetSort.h:32
gJetSort(const std::string &name)
Definition gJetSort.cxx:23
virtual TCS::StatusCode initialize() override
Definition gJetSort.cxx:40
parType_t m_numberOfJets
Definition gJetSort.h:31
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition gJetSort.cxx:49
bool SortByEtLargestgJet(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition gJetSort.cxx:16
uint32_t parType_t
Definition Parameter.h:22