ATLAS Offline Software
jJetSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 // jJetSort.cxx
5 // TopoCore
6 // algorithm to make sorted jJets lists
7 //
9 #include "L1TopoEvent/TOBArray.h"
11 #include "L1TopoEvent/GenericTOB.h"
12 #include <algorithm>
13 
14 REGISTER_ALG_TCS(jJetSort)
15 
16 bool SortByEtLargestjJet(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
17 {
18  return tob1->Et() > tob2->Et();
19 }
20 
21 // constructor
22 TCS::jJetSort::jJetSort(const std::string & name) :
24 {
25  defineParameter( "InputWidth", 64 ); // for FW
26  defineParameter( "InputWidth1stStage", 16 ); // for FW
27  defineParameter( "OutputWidth", 10 );
28  defineParameter( "MinEta", 0 );
29  defineParameter( "MaxEta", 196 );
30 }
31 
32 
34 {}
35 
36 
37 
40  m_numberOfJets = parameter("OutputWidth").value();
41  m_minEta = parameter("MinEta").value();
42  m_maxEta = parameter("MaxEta").value();
44 }
45 
46 
49 
50  const jJetTOBArray & jets = dynamic_cast<const jJetTOBArray&>(input);
51 
52  // fill output array with GenericTOBs builds from jets
53  for(jJetTOBArray::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
61 
62  // keep only max number of jets
63  int par = m_numberOfJets;
64  unsigned int maxNumberOfJets = std::clamp(par, 0, std::abs(par));
65  if(maxNumberOfJets>0) {
66  while( output.size()> maxNumberOfJets ) {
67  if (output.size() == (maxNumberOfJets+1)) {
68  bool isAmbiguous = output[maxNumberOfJets-1].EtDouble() == output[maxNumberOfJets].EtDouble();
69  if (isAmbiguous) { output.setAmbiguityFlag(true); }
70  }
71  output.pop_back();
72  }
73  }
75 }
76 
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
jJetSort.h
TCS::DataArrayImpl< jJetTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
TCS::jJetSort::jJetSort
jJetSort(const std::string &name)
Definition: jJetSort.cxx:22
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
jJetTOBArray.h
SortByEtLargestjJet
bool SortByEtLargestjJet(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition: jJetSort.cxx:16
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::InputTOBArray
Definition: InputTOBArray.h:15
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::jJetSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition: jJetSort.cxx:48
TOBArray.h
TCS::TOBArray
Definition: TOBArray.h:24
TCS::jJetTOBArray
Definition: L1Topo/L1TopoEvent/L1TopoEvent/jJetTOBArray.h:19
merge.output
output
Definition: merge.py:17
TCS::GenericTOB
Definition: GenericTOB.h:35
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition: AlgFactory.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TCS::SortingAlg
Definition: SortingAlg.h:18
GenericTOB.h
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::jJetSort::~jJetSort
virtual ~jJetSort()
Definition: jJetSort.cxx:33
TCS::jJetSort::initialize
virtual TCS::StatusCode initialize() override
Definition: jJetSort.cxx:39
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15