ATLAS Offline Software
MuonPhiLayerHough.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONPHILAYERHOUGH_H
6 #define MUONPHILAYERHOUGH_H
7 
8 #include <cmath>
9 #include <iostream>
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "MuonLayerHough/Hit.h"
15 
16 class TH1;
17 
18 namespace MuonHough {
19 
20  using PhiHitVec = std::vector<std::shared_ptr<MuonHough::PhiHit>>;
21 
23  struct Maximum {
24  Maximum() = default;
25 
26  float max{0.};
27  float pos{0.};
28 
29  int binpos{-1};
30  int binposmin{-1};
31  int binposmax{-1};
32 
33  int sector{-1};
34 
36 
37  const MuonPhiLayerHough* hough{nullptr};
38  };
39 
40  MuonPhiLayerHough(int nbins, float rangemin, float rangemax, Muon::MuonStationIndex::DetectorRegionIndex region_);
42 
43  void reset() const;
44  void setDebug(bool d) { m_debug = d; }
45 
46  bool findMaximum(Maximum& maximum, float maxval) const;
47  void associateHitsToMaximum(Maximum& maximum, const PhiHitVec& hits) const;
48 
49  std::pair<int, int> range(float /*r*/, float phi1, float phi2) const {
50  float phimin = std::min(phi1, phi2);
51  float phimax = std::max(phi1, phi2);
52  int bphimin = (phimin - m_rangemin) * m_invbinsize;
53  int bphimax = (phimax - m_rangemin) * m_invbinsize;
54  // add neighbouring bin
55  if ((m_rangemin + m_binsize * bphimin - phimin) * m_invbinsize > 0) bphimin -= 1;
56  if ((m_rangemin + m_binsize * bphimax - phimax) * m_invbinsize < 0) bphimax += 1;
57  return std::make_pair(bphimin, bphimax);
58  }
59 
60  void fillLayer(const PhiHitVec& hits, bool substract = false) const;
61  void fillLayer2(const PhiHitVec& hits, bool substract = false) const;
62 
63  float maximum(float r, float phimin, float phimax, int& posbin) const {
64  unsigned int max = 0;
65  posbin = -1;
66 
67  std::pair<int, int> minMax = range(r, phimin, phimax);
68  for (int n = minMax.first; n <= minMax.second; ++n) {
69  if (max < m_histo[n]) {
70  max = m_histo[n];
71  posbin = n;
72  }
73  }
74  if (max > 100000) {
75  std::cout << " maximum too large " << max * 0.001 << " min " << minMax.first << " max " << minMax.second << " nbins "
76  << m_nbins << " phimin " << phimin << " phimax " << phimax << std::endl;
77  for (int n = minMax.first; n <= minMax.second; ++n) { std::cout << " bin " << n << " val " << m_histo[n] << std::endl; }
78  }
79 
80  return 0.001 * max;
81  }
82 
83  std::vector<TH1*> rootHistos(const std::string& prefix, const float* phimin = 0, const float* phimax = 0) const;
84 
85  float m_binsize{0.};
86  float m_invbinsize{0.};
87  float m_rangemin{0.};
88  float m_rangemax{0.};
89 
91  int m_nbins;
92  bool m_debug{false};
93  std::unique_ptr<unsigned int[]> m_histo;
94 
95  private:
96  // fake copy constructor and assignment operator
99  };
100 
101 } // namespace MuonHough
102 #endif
beamspotman.r
def r
Definition: beamspotman.py:676
MuonHough::MuonPhiLayerHough::maximum
float maximum(float r, float phimin, float phimax, int &posbin) const
Definition: MuonPhiLayerHough.h:63
MuonHough::PhiHitVec
std::vector< std::shared_ptr< MuonHough::PhiHit > > PhiHitVec
Definition: MuonPhiLayerHough.h:20
MuonHough::MuonPhiLayerHough::Maximum::pos
float pos
Definition: MuonPhiLayerHough.h:27
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonHough::MuonPhiLayerHough::m_rangemax
float m_rangemax
Definition: MuonPhiLayerHough.h:88
MuonHough::MuonPhiLayerHough::reset
void reset() const
Definition: MuonPhiLayerHough.cxx:27
MuonHough::MuonPhiLayerHough::m_region
Muon::MuonStationIndex::DetectorRegionIndex m_region
Definition: MuonPhiLayerHough.h:90
MuonHough::MuonPhiLayerHough::fillLayer
void fillLayer(const PhiHitVec &hits, bool substract=false) const
Definition: MuonPhiLayerHough.cxx:94
MuonHough::MuonPhiLayerHough::rootHistos
std::vector< TH1 * > rootHistos(const std::string &prefix, const float *phimin=0, const float *phimax=0) const
Definition: MuonPhiLayerHough.cxx:177
MuonHough::MuonPhiLayerHough::m_histo
std::unique_ptr< unsigned int[]> m_histo
Definition: MuonPhiLayerHough.h:93
hist_file_dump.d
d
Definition: hist_file_dump.py:137
MuonHough::MuonPhiLayerHough::Maximum::hough
const MuonPhiLayerHough * hough
Definition: MuonPhiLayerHough.h:37
MuonHough::MuonPhiLayerHough::Maximum::binposmax
int binposmax
Definition: MuonPhiLayerHough.h:31
MuonHough::MuonPhiLayerHough::fillLayer2
void fillLayer2(const PhiHitVec &hits, bool substract=false) const
Definition: MuonPhiLayerHough.cxx:29
MuonHough::MuonPhiLayerHough::m_debug
bool m_debug
Definition: MuonPhiLayerHough.h:92
MuonHough::MuonPhiLayerHough::associateHitsToMaximum
void associateHitsToMaximum(Maximum &maximum, const PhiHitVec &hits) const
Definition: MuonPhiLayerHough.cxx:246
MuonHough::MuonPhiLayerHough::Maximum::binposmin
int binposmin
Definition: MuonPhiLayerHough.h:30
MuonHough::MuonPhiLayerHough::range
std::pair< int, int > range(float, float phi1, float phi2) const
Definition: MuonPhiLayerHough.h:49
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
Hit.h
MuonHough::MuonPhiLayerHough
Definition: MuonPhiLayerHough.h:22
MuonHough::MuonPhiLayerHough::m_invbinsize
float m_invbinsize
Definition: MuonPhiLayerHough.h:86
beamspotman.n
n
Definition: beamspotman.py:731
MuonHough::MuonPhiLayerHough::Maximum
Definition: MuonPhiLayerHough.h:23
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
MuonHough
Definition: MuonLayerHoughTool.h:42
MuonHough::MuonPhiLayerHough::Maximum::hits
PhiHitVec hits
Definition: MuonPhiLayerHough.h:35
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
MuonHough::MuonPhiLayerHough::operator=
MuonPhiLayerHough & operator=(const MuonPhiLayerHough &right)
MuonHough::MuonPhiLayerHough::MuonPhiLayerHough
MuonPhiLayerHough(int nbins, float rangemin, float rangemax, Muon::MuonStationIndex::DetectorRegionIndex region_)
Definition: MuonPhiLayerHough.cxx:15
MuonHough::MuonPhiLayerHough::~MuonPhiLayerHough
~MuonPhiLayerHough()
MuonHough::MuonPhiLayerHough::Maximum::max
float max
Definition: MuonPhiLayerHough.h:26
min
#define min(a, b)
Definition: cfImp.cxx:40
Muon::MuonStationIndex::DetectorRegionIndex
DetectorRegionIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:47
MuonHough::MuonPhiLayerHough::Maximum::sector
int sector
Definition: MuonPhiLayerHough.h:33
MuonHough::MuonPhiLayerHough::Maximum::binpos
int binpos
Definition: MuonPhiLayerHough.h:29
MuonHough::MuonPhiLayerHough::m_nbins
int m_nbins
Definition: MuonPhiLayerHough.h:91
MuonHough::MuonPhiLayerHough::MuonPhiLayerHough
MuonPhiLayerHough(const MuonPhiLayerHough &)
TH1
Definition: rootspy.cxx:268
MuonHough::MuonPhiLayerHough::m_rangemin
float m_rangemin
Definition: MuonPhiLayerHough.h:87
MuonHough::MuonPhiLayerHough::Maximum::Maximum
Maximum()=default
MuonHough::MuonPhiLayerHough::setDebug
void setDebug(bool d)
Definition: MuonPhiLayerHough.h:44
MuonHough::MuonPhiLayerHough::m_binsize
float m_binsize
Definition: MuonPhiLayerHough.h:85
MuonHough::MuonPhiLayerHough::findMaximum
bool findMaximum(Maximum &maximum, float maxval) const
Definition: MuonPhiLayerHough.cxx:190