Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MuonSort.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 // MuonSort.cxx
5 // TopoCore
6 // Created by Joerg Stelzer on 11/10/12.
7 // algorithm to create sorted lists for muons, et order applied
8 //
10 #include "L1TopoEvent/TOBArray.h"
12 #include "L1TopoEvent/GenericTOB.h"
13 #include <algorithm>
14 
15 REGISTER_ALG_TCS(MuonSort)
16 
17 bool SortByEtLargestM(TCS::GenericTOB* tob1, TCS::GenericTOB* tob2)
18 {
19  //Order the TOBs according to Et (high to low), then (in case of equal ET) side (first A, then C). Further ambiguity resolution depends on details of MUCTPI and are currently not taken into account (to be seen if necessary).
20 
21  //highest priority: ET
22  if (tob1->Et() > tob2->Et()) return true;
23  if (tob1->Et() < tob2->Et()) return false;
24  //second criterion: A side before C side (here: emulated via signed eta coordinate)
25  if (tob1->eta() > tob2->eta()) return true;
26  if (tob1->eta() < tob2->eta()) return false; //explicitly indicate tob1 < tob2 in case additional criteria are added
27  return false;
28 
29 }
30 
31 
32 // constructor
33 TCS::MuonSort::MuonSort(const std::string & name) : SortingAlg(name) {
34  defineParameter( "InputWidth", 32 ); // for FW
35  defineParameter( "InputWidth1stStage", 16 ); // for FW
36  defineParameter( "OutputWidth", 6 );
37  defineParameter( "MinEta", 0 );
38  defineParameter( "MaxEta", 196 );
39  defineParameter( "InnerCoinCut", 0 );
40  defineParameter( "FullStationCut", 0 );
41  defineParameter( "GoodMFieldCut", 0 );
42 }
43 
44 
45 // destructor
47 
48 
51  m_numberOfMuons = parameter("OutputWidth").value();
52  m_minEta = parameter("MinEta").value();
53  m_maxEta = parameter("MaxEta").value();
54  m_InnerCoinCut = parameter("InnerCoinCut").value();
55  m_FullStationCut = parameter("FullStationCut").value();
56  m_GoodMFieldCut = parameter("GoodMFieldCut").value();
58 }
59 
60 
62 TCS::MuonSort::sort(const InputTOBArray & input, TOBArray & output) {
63 
64  const MuonTOBArray & muons = dynamic_cast<const MuonTOBArray&>(input);
65 
66  // fill output array with GenericTOB built from muons
67  for(MuonTOBArray::const_iterator muon = muons.begin(); muon!= muons.end(); ++muon ) {
68 
69  if (parType_t(std::abs((*muon)-> eta())) < m_minEta) continue;
70  if (parType_t(std::abs((*muon)-> eta())) > m_maxEta) continue;
71 
72  // Apply flag selection only for TGC muons. The flag selection is applied only if the corresponding parameter from the menu is 1.
73  if ( parType_t((*muon)->isTGC()) )
74  {
75  if(m_InnerCoinCut == 1 && ( ! ((int)parType_t((*muon)->innerCoin()) == (int)m_InnerCoinCut ) ) ) continue;
76  if(m_FullStationCut == 1 && ( ! ((int)parType_t((*muon)->bw2or3()) == (int)m_FullStationCut ) ) ) continue;
77  if(m_GoodMFieldCut == 1 && ( ! ((int)parType_t((*muon)->goodMF()) == (int)m_GoodMFieldCut ) ) ) continue;
78  }
79 
80  const GenericTOB gtob(**muon);
81  output.push_back( gtob );
82  }
83 
84  // sort
85  output.sort(SortByEtLargestM);
86 
87 
88  // keep only max number of muons
89  int par = m_numberOfMuons;
90  unsigned int maxNumberOfMuons = std::clamp(par, 0, std::abs(par));
91  if(maxNumberOfMuons>0) {
92  while( output.size()> maxNumberOfMuons ) {
93  if (output.size() == (maxNumberOfMuons+1)) {
94  bool isAmbiguous = output[maxNumberOfMuons-1].EtDouble() == output[maxNumberOfMuons].EtDouble();
95  if (isAmbiguous) { output.setAmbiguityFlag(true); }
96  }
97  output.pop_back();
98  }
99  }
101 }
102 
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< MuonTOB >::const_iterator
data_t::const_iterator const_iterator
Definition: DataArrayImpl.h:18
TCS::MuonSort::MuonSort
MuonSort(const std::string &name)
Definition: MuonSort.cxx:33
TCS::MuonSort::sort
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition: MuonSort.cxx:62
TCS::DataArrayImpl::end
iterator end()
Definition: DataArrayImpl.h:43
MuonSort.h
TCS::ConfigurableAlg::defineParameter
void defineParameter(const std::string &name, TCS::parType_t value)
Definition: ConfigurableAlg.cxx:201
TCS::InputTOBArray
Definition: InputTOBArray.h:15
SortByEtLargestM
bool SortByEtLargestM(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition: MuonSort.cxx:17
TCS::MuonTOBArray
Definition: MuonTOBArray.h:19
TOBArray.h
TCS::TOBArray
Definition: TOBArray.h:24
TCS::MuonSort::initialize
virtual TCS::StatusCode initialize() override
Definition: MuonSort.cxx:50
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:240
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TCS::MuonSort::~MuonSort
virtual ~MuonSort()
Definition: MuonSort.cxx:46
TCS::SortingAlg
Definition: SortingAlg.h:18
GenericTOB.h
TCS::DataArrayImpl::begin
iterator begin()
Definition: DataArrayImpl.h:40
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
MuonTOBArray.h