ATLAS Offline Software
Loading...
Searching...
No Matches
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//
13#include <algorithm>
14
15REGISTER_ALG_TCS(MuonSort)
16
17bool 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
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
62TCS::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
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
Scalar eta() const
pseudorapidity method
if(febId1==febId2)
bool SortByEtLargestM(TCS::GenericTOB *tob1, TCS::GenericTOB *tob2)
Definition MuonSort.cxx:17
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
void defineParameter(const std::string &name, TCS::parType_t value)
data_t::const_iterator const_iterator
parType_t m_InnerCoinCut
Definition MuonSort.h:37
MuonSort(const std::string &name)
Definition MuonSort.cxx:33
parType_t m_FullStationCut
Definition MuonSort.h:38
parType_t m_maxEta
Definition MuonSort.h:36
virtual TCS::StatusCode initialize() override
Definition MuonSort.cxx:50
virtual TCS::StatusCode sort(const InputTOBArray &input, TOBArray &output) override final
Definition MuonSort.cxx:62
parType_t m_GoodMFieldCut
Definition MuonSort.h:39
parType_t m_minEta
Definition MuonSort.h:35
parType_t m_numberOfMuons
Definition MuonSort.h:34
virtual ~MuonSort()
Definition MuonSort.cxx:46
SortingAlg(const std::string &name)
Definition SortingAlg.h:21
uint32_t parType_t
Definition Parameter.h:22