ATLAS Offline Software
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 
12 namespace 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
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:23
MuonHough::MuonLayerHoughSelector::m_cutValues
std::vector< std::pair< int, float > > m_cutValues
Definition: MuonLayerHoughSelector.h:31
MuonHough
Definition: MuonLayerHoughTool.h:41
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
MuonHough::MuonLayerHoughSelector::getMinCutValue
float getMinCutValue() const
Definition: MuonLayerHoughSelector.cxx:35
MuonHough::MuonLayerHoughSelector::passesCutValue
bool passesCutValue(float testValue, float position) const
Definition: MuonLayerHoughSelector.cxx:43
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
a
TList * a
Definition: liststreamerinfos.cxx:10
MuonHough::MuonLayerHoughSelector::~MuonLayerHoughSelector
virtual ~MuonLayerHoughSelector()
Destructor.
MuonHough::valPair
std::pair< int, float > valPair
Definition: MuonLayerHoughSelector.cxx:14
MuonHough::MuonLayerHoughSelector::MuonLayerHoughSelector
MuonLayerHoughSelector()=default
Default constructor.
MuonLayerHoughSelector.h
MuonHough::MuonLayerHoughSelector::getCutValue
float getCutValue(float pos) const
Getter Methods.
Definition: MuonLayerHoughSelector.cxx:27