ATLAS Offline Software
Loading...
Searching...
No Matches
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
16class TH1;
17
18namespace 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
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
#define max(a, b)
Definition cfImp.cxx:41
int r
Definition globals.cxx:22
std::vector< std::shared_ptr< MuonHough::PhiHit > > PhiHitVec
DetectorRegionIndex
enum to classify the different layers in the muon spectrometer
void fillLayer2(const PhiHitVec &hits, bool substract=false) const
MuonPhiLayerHough(int nbins, float rangemin, float rangemax, Muon::MuonStationIndex::DetectorRegionIndex region_)
void fillLayer(const PhiHitVec &hits, bool substract=false) const
float maximum(float r, float phimin, float phimax, int &posbin) const
MuonPhiLayerHough(const MuonPhiLayerHough &)
bool findMaximum(Maximum &maximum, float maxval) const
MuonPhiLayerHough & operator=(const MuonPhiLayerHough &right)
std::unique_ptr< unsigned int[]> m_histo
void associateHitsToMaximum(Maximum &maximum, const PhiHitVec &hits) const
Muon::MuonStationIndex::DetectorRegionIndex m_region
std::pair< int, int > range(float, float phi1, float phi2) const
std::vector< TH1 * > rootHistos(const std::string &prefix, const float *phimin=0, const float *phimax=0) const