ATLAS Offline Software
jEmSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 // jEmSort.cxx
5 // TopoCore
6 // algorithm to make sorted jEms lists
7 //
9 #include "L1TopoEvent/TOBArray.h"
11 #include "L1TopoEvent/GenericTOB.h"
12 #include <algorithm>
13 
14 REGISTER_ALG_TCS(jEmSort)
15 
16 bool SortByEtLargestjEm(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
17 {
18  return tob1->Et() > tob2->Et();
19 }
20 
21 // constructor
22 TCS::jEmSort::jEmSort(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  defineParameter( "IsoMin", 0 );
31  defineParameter( "Frac1Min", 0 );
32  defineParameter( "Frac2Min", 0 );
33 }
34 
35 
37 {}
38 
39 
40 
43  m_numberOfJets = parameter("OutputWidth").value();
44  m_minEta = parameter("MinEta").value();
45  m_maxEta = parameter("MaxEta").value();
46  m_iso = parameter("IsoMin").value();
47  m_frac1 = parameter("Frac1Min").value();
48  m_frac2 = parameter("Frac2Min").value();
50 }
51 
52 
55 
56  const jEmTOBArray & jets = dynamic_cast<const jEmTOBArray&>(input);
57 
58  // fill output array with GenericTOBs builds from jets
59  for(jEmTOBArray::const_iterator jet = jets.begin(); jet!= jets.end(); ++jet ) {
60  // Isolation cuts
61  if ( !isocut(m_iso, (*jet)-> isolation()) ) continue;
62  if ( !isocut(m_frac1, (*jet)-> frac1()) ) continue;
63  if ( !isocut(m_frac2, (*jet)-> frac2()) ) continue;
64  // Eta cut
65  if ( parType_t(std::abs((*jet)-> eta())) < m_minEta ) continue;
66  if ( parType_t(std::abs((*jet)-> eta())) > m_maxEta ) continue;
67 
68  output.push_back( GenericTOB(**jet) );
69  }
70 
71  // sort
73 
74  // keep only max number of jets
75  int par = m_numberOfJets;
76  unsigned int maxNumberOfJets = std::clamp(par, 0, std::abs(par));
77  if(maxNumberOfJets>0) {
78  while( output.size()> maxNumberOfJets ) {
79  if (output.size() == (maxNumberOfJets+1)) {
80  bool isAmbiguous = output[maxNumberOfJets-1].EtDouble() == output[maxNumberOfJets].EtDouble();
81  if (isAmbiguous) { output.setAmbiguityFlag(true); }
82  }
83  output.pop_back();
84  }
85  }
87 }
88 
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::jEmSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition: jEmSort.cxx:54
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
TCS::DataArrayImpl< jEmTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
jEmSort.h
SortByEtLargestjEm
bool SortByEtLargestjEm(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition: jEmSort.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::jEmSort::~jEmSort
virtual ~jEmSort()
Definition: jEmSort.cxx:36
TOBArray.h
TCS::jEmSort::jEmSort
jEmSort(const std::string &name)
Definition: jEmSort.cxx:22
TCS::TOBArray
Definition: TOBArray.h:24
jEmTOBArray.h
TCS::jEmSort::initialize
virtual TCS::StatusCode initialize() override
Definition: jEmSort.cxx:42
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:228
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TCS::SortingAlg
Definition: SortingAlg.h:18
GenericTOB.h
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
TCS::jEmTOBArray
Definition: jEmTOBArray.h:19
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
GlobalSim::isocut
bool isocut(const std::string &threshold, const unsigned int bit)
Definition: isocut.cxx:10
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15