LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
HeatMap.h
Go to the documentation of this file.
1 #ifndef LARRECO_QUADVTX_HEATMAP_H
2 #define LARRECO_QUADVTX_HEATMAP_H
3 
4 #include <memory>
5 #include <vector>
6 
7 class TH2F;
8 
9 namespace quad {
10  class HeatMap {
11  public:
12  HeatMap(int _Nz, double _minz, double _maxz, int _Nx, double _minx, double _maxx);
13 
14  std::unique_ptr<TH2F> AsTH2() const;
15 
16  double ZBinCenter(int iz) const { return minz + (iz + .5) * (maxz - minz) / Nz; }
17  double XBinCenter(int ix) const { return minx + (ix + .5) * (maxx - minx) / Nx; }
18  int ZToBin(double z) const { return fast_floor((z - minz) / (maxz - minz) * Nz); }
19  int XToBin(double x) const { return fast_floor((x - minx) / (maxx - minx) * Nx); }
20 
21  const double minz, minx, maxz, maxx;
22  const int Nx, Nz;
23 
24  std::vector<float> map;
25 
26  private:
27  // The rounding functions in std:: are surprisingly slow
28  inline int fast_floor(double x) const { return int(x + 100000) - 100000; }
29  };
30 }
31 
32 #endif
Float_t x
Definition: compare.C:6
int XToBin(double x) const
Definition: HeatMap.h:19
const double minz
Definition: HeatMap.h:21
Double_t z
Definition: plot.C:276
int ZToBin(double z) const
Definition: HeatMap.h:18
const double minx
Definition: HeatMap.h:21
const int Nx
Definition: HeatMap.h:22
double ZBinCenter(int iz) const
Definition: HeatMap.h:16
const double maxx
Definition: HeatMap.h:21
HeatMap(int _Nz, double _minz, double _maxz, int _Nx, double _minx, double _maxx)
Definition: HeatMap.cxx:7
int fast_floor(double x) const
Definition: HeatMap.h:28
double XBinCenter(int ix) const
Definition: HeatMap.h:17
const int Nz
Definition: HeatMap.h:22
std::unique_ptr< TH2F > AsTH2() const
Definition: HeatMap.cxx:12
const double maxz
Definition: HeatMap.h:21
std::vector< float > map
Definition: HeatMap.h:24