ATLAS Offline Software
eEmSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 // eEmSort.cxx
5 // TopoCore
6 // algorithm to create sorted lists for eEMs, et order applied
7 //
9 #include "L1TopoEvent/TOBArray.h"
11 #include "L1TopoEvent/GenericTOB.h"
12 #include <algorithm>
13 
14 REGISTER_ALG_TCS(eEmSort)
15 
16 bool SortByEtLargesteEm(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
17 {
18  return tob1->Et() > tob2->Et();
19 }
20 
21 // constructor
22 TCS::eEmSort::eEmSort(const std::string & name) : SortingAlg(name) {
23  defineParameter( "InputWidth", 120 ); // for FW
24  defineParameter( "InputWidth1stStage", 30 ); // for FW
25  defineParameter( "OutputWidth", 6 );
26  defineParameter( "REtaMin", 0 );
27  defineParameter( "RHadMin", 0 );
28  defineParameter( "WsTotMin", 0 );
29  defineParameter( "MinEta", 0 );
30  defineParameter( "MaxEta", 196 );
31 }
32 
33 
34 // destructor
36 
37 
40  m_numberOfeEms = parameter("OutputWidth").value();
41  m_minREta = parameter("REtaMin").value();
42  m_minRHad = parameter("RHadMin").value();
43  m_minWsTot = parameter("WsTotMin").value();
45 }
46 
47 
50 
51  const eEmTOBArray & eems = dynamic_cast<const eEmTOBArray&>(input);
52 
53  // fill output array with GenericTOB buildt from eEms
54  for(eEmTOBArray::const_iterator eem = eems.begin(); eem!= eems.end(); ++eem ) {
55 
56  // isolation cut
57  if ( !isocut(m_minREta, (*eem)-> Reta()) ) {continue;}
58  if ( !isocut(m_minRHad, (*eem)-> Rhad()) ) {continue;}
59  if ( !isocut(m_minWsTot, (*eem)-> Wstot()) ) {continue;}
60 
61  const GenericTOB gtob(**eem);
62  output.push_back( gtob );
63  }
64 
65  // sort
67 
68 
69  // keep only max number of eEms
70  int par = m_numberOfeEms;
71  unsigned int maxNumberOfeEms = std::clamp(par, 0, std::abs(par));
72  if(maxNumberOfeEms>0) {
73  while( output.size()> maxNumberOfeEms ) {
74  if (output.size() == (maxNumberOfeEms+1)) {
75  bool isAmbiguous = output[maxNumberOfeEms-1].EtDouble() == output[maxNumberOfeEms].EtDouble();
76  if (isAmbiguous) { output.setAmbiguityFlag(true); }
77  }
78  output.pop_back();
79  }
80  }
82 }
83 
TCS::eEmSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition: eEmSort.cxx:49
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::DataArrayImpl< eEmTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
xAOD::EgammaParameters::Reta
@ Reta
e237/e277
Definition: EgammaEnums.h:154
TCS::eEmSort::initialize
virtual TCS::StatusCode initialize() override
Definition: eEmSort.cxx:39
TCS::eEmTOBArray
Definition: L1Topo/L1TopoEvent/L1TopoEvent/eEmTOBArray.h:14
TCS::DataArrayImpl::end
iterator end()
Definition: DataArrayImpl.h:43
eEmSort.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
TOBArray.h
eEmTOBArray.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
GenericTOB.h
TCS::DataArrayImpl::begin
iterator begin()
Definition: DataArrayImpl.h:40
TCS::eEmSort::~eEmSort
virtual ~eEmSort()
Definition: eEmSort.cxx:35
SortByEtLargesteEm
bool SortByEtLargesteEm(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition: eEmSort.cxx:16
TCS::eEmSort::eEmSort
eEmSort(const std::string &name)
Definition: eEmSort.cxx:22
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
xAOD::EgammaParameters::Rhad
@ Rhad
ethad/et
Definition: EgammaEnums.h:160
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