ATLAS Offline Software
jTauSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 // jTauSort.cxx
5 // TopoCore
6 // algorithm to make sorted jTaus lists
7 //
9 #include "L1TopoEvent/TOBArray.h"
11 #include "L1TopoEvent/GenericTOB.h"
13 #include <algorithm>
14 
15 REGISTER_ALG_TCS(jTauSort)
16 
17 bool SortByEtLargestjTau(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
18 {
19  return tob1->Et() > tob2->Et();
20 }
21 
22 
23 // constructor
24 TCS::jTauSort::jTauSort(const std::string & name) :
26 {
27  defineParameter( "InputWidth", 120); // for fw
28  defineParameter( "OutputWidth", 6 );
29  defineParameter( "MinEta", 0 );
30  defineParameter( "MaxEta", 196 );
31  defineParameter( "Isolation", 1024);
32  defineParameter( "passIsolation", false);
33 }
34 
35 
37 {}
38 
39 
42 
43  m_numberOfjTaus = parameter("OutputWidth").value();
44  m_minEta = parameter("MinEta").value();
45  m_maxEta = parameter("MaxEta").value();
46  m_iso = parameter("Isolation").value();
47  m_passIsolation = parameter("passIsolation").value();
48 
50 }
51 
52 
55 
56  const jTauTOBArray & jtaus = dynamic_cast<const jTauTOBArray&>(input);
57 
58  // loop over input TOBs && fill output array with GenericTOBs builds from jTaus
59  for(jTauTOBArray::const_iterator jtau = jtaus.begin(); jtau != jtaus.end(); ++jtau ) {
60  if ( parType_t(std::abs((*jtau)-> eta())) < m_minEta ) continue;
61  if ( parType_t(std::abs((*jtau)-> eta())) > m_maxEta ) continue;
62  if (! ( m_passIsolation || checkIsolation(*jtau) ) ) continue;
63  output.push_back( GenericTOB(**jtau) );
64  }
65 
66  // sort
68 
69  // keep only max number of jTaus
70  int par = m_numberOfjTaus;
71  unsigned int maxNumberOfJTaus = std::clamp(par, 0, std::abs(par));
72  if(maxNumberOfJTaus>0) {
73  while( output.size()> maxNumberOfJTaus ) {
74  if (output.size() == (maxNumberOfJTaus+1)) {
75  bool isAmbiguous = output[maxNumberOfJTaus-1].Et() == output[maxNumberOfJTaus].Et();
76  if (isAmbiguous) { output.setAmbiguityFlag(true); }
77  }
78  output.pop_back();
79  }
80  }
82 }
83 
84 
85 bool
87  if(m_passIsolation) return true;
88  return jtau->EtIso()*1024 < jtau->Et()*m_iso;
89 }
90 
91 
92 
93 
TCS::jTauTOBArray
Definition: jTauTOBArray.h:19
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition: Parameter.h:22
TCS::DataArrayImpl< jTauTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
SortByEtLargestjTau
bool SortByEtLargestjTau(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition: jTauSort.cxx:17
TCS::jTauTOB::EtIso
unsigned int EtIso() const
Definition: jTauTOB.h:40
TCS::jTauTOB::Et
unsigned int Et() const
Definition: jTauTOB.h:32
TCS::DataArrayImpl::end
iterator end()
Definition: DataArrayImpl.h:43
TCS::jTauSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition: jTauSort.cxx:54
TCS::jTauSort::initialize
virtual TCS::StatusCode initialize() override
Definition: jTauSort.cxx:41
jTauMultiplicity.h
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::jTauTOB
Definition: jTauTOB.h:16
TOBArray.h
TCS::TOBArray
Definition: TOBArray.h:24
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:221
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TCS::SortingAlg
Definition: SortingAlg.h:18
TCS::jTauSort::jTauSort
jTauSort(const std::string &name)
Definition: jTauSort.cxx:24
GenericTOB.h
TCS::DataArrayImpl::begin
iterator begin()
Definition: DataArrayImpl.h:40
TCS::jTauSort::checkIsolation
bool checkIsolation(const TCS::jTauTOB *jtau) const
Definition: jTauSort.cxx:86
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::jTauSort::~jTauSort
virtual ~jTauSort()
Definition: jTauSort.cxx:36
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
jTauTOBArray.h
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
jTauSort.h