ATLAS Offline Software
Loading...
Searching...
No Matches
MuonLayerHoughSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <algorithm>
8#include <cmath>
9#include <iostream>
10#include <utility>
11
12namespace MuonHough {
13
14 using valPair = std::pair<int, float>;
15
16 MuonLayerHoughSelector::MuonLayerHoughSelector(std::vector<std::pair<int, float>> cutValues)
17 : m_cutValues (std::move (cutValues))
18 {
19 auto comp = [](const valPair& a, const valPair& b) -> bool { return a.first < b.first; };
20 std::sort(m_cutValues.begin(), m_cutValues.end(), comp);
21
22 if (getMinCutValue() < 0) std::cout << std::endl << "MuonLayerHoughSelector: Negative cuts found!!!" << std::endl;
23 }
24
26
27 float MuonLayerHoughSelector::getCutValue(float position) const {
28 const float pos = std::abs(position);
29 for (const auto& cut : m_cutValues) {
30 if (cut.first < pos) return cut.second; // notice the array is already sorted
31 }
32 return m_cutValues.back().second;
33 }
34
36 if (m_cutValues.empty()) {
37 std::cout << "MuonLayerHoughSelector: cutValues not available, returning invalid value";
38 return -999;
39 }
40 return m_cutValues[0].second;
41 }
42
43 bool MuonLayerHoughSelector::passesCutValue(float testValue, float position) const { return testValue > getCutValue(position); }
44
45} // namespace MuonHough
static Double_t a
float getCutValue(float pos) const
Getter Methods.
virtual ~MuonLayerHoughSelector()
Destructor.
std::vector< std::pair< int, float > > m_cutValues
bool passesCutValue(float testValue, float position) const
MuonLayerHoughSelector()=default
Default constructor.
std::pair< int, float > valPair
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.