ATLAS Offline Software
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) or side (first A, then C) or octant index (low to high), geometry here /cvmfs/atlas.cern.ch/repo/sw/database/GroupData/TrigConfMuctpi/TestMioctGeometry2016.dat.
20  //Handling cases where two muon TOBs have pT>10
21  if( (tob1->Et() != tob2->Et()) && ((tob1->Et()<10) || (tob2->Et()<10)) ) return tob1->Et() > tob2->Et();
22  else if( tob1->etaDouble() != tob2->etaDouble() ) return tob1->etaDouble() > tob2->etaDouble();
23  else
24  {
25  if( tob1->phiDouble() * tob2->phiDouble() >=0. ) return tob1->phiDouble() < tob2->phiDouble();
26  else if( tob1->phiDouble() >=0. && tob2->phiDouble() <=0. ) return true;
27  else 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 
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
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 
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
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
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
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
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::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