LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
quad::HeatMap Class Reference

#include "HeatMap.h"

Public Member Functions

 HeatMap (int _Nz, double _minz, double _maxz, int _Nx, double _minx, double _maxx)
 
std::unique_ptr< TH2F > AsTH2 () const
 
double ZBinCenter (int iz) const
 
double XBinCenter (int ix) const
 
int ZToBin (double z) const
 
int XToBin (double x) const
 

Public Attributes

const double minz
 
const double minx
 
const double maxz
 
const double maxx
 
const int Nx
 
const int Nz
 
std::vector< float > map
 

Private Member Functions

int fast_floor (double x) const
 

Detailed Description

Definition at line 10 of file HeatMap.h.

Constructor & Destructor Documentation

quad::HeatMap::HeatMap ( int  _Nz,
double  _minz,
double  _maxz,
int  _Nx,
double  _minx,
double  _maxx 
)

Definition at line 7 of file HeatMap.cxx.

8  : minz(_minz), minx(_minx), maxz(_maxz), maxx(_maxx), Nx(_Nx), Nz(_Nz), map(Nz * Nx, 0)
9  {}
const double minz
Definition: HeatMap.h:21
const double minx
Definition: HeatMap.h:21
const int Nx
Definition: HeatMap.h:22
const double maxx
Definition: HeatMap.h:21
const int Nz
Definition: HeatMap.h:22
const double maxz
Definition: HeatMap.h:21
std::vector< float > map
Definition: HeatMap.h:24

Member Function Documentation

std::unique_ptr< TH2F > quad::HeatMap::AsTH2 ( ) const

Definition at line 12 of file HeatMap.cxx.

References map, maxx, maxz, minx, minz, Nx, and Nz.

13  {
14  auto h = std::make_unique<TH2F>("", "", Nz, minz, maxz, Nx, minx, maxx);
15  for (unsigned int i = 0; i < map.size(); ++i) {
16  h->SetBinContent((i / Nx) + 1, (i % Nx) + 1, map[i]);
17  }
18 
19  double maxz = 0;
20  for (int i = 0; i < (h->GetNbinsX() + 2) * (h->GetNbinsY() + 2); ++i) {
21  maxz = std::max(maxz, h->GetBinContent(i));
22  }
23 
24  // Slim out bins with low population (reduces output file size)
25  for (int i = 0; i < (h->GetNbinsX() + 2) * (h->GetNbinsY() + 2); ++i) {
26  if (h->GetBinContent(i) < .05 * maxz) h->SetBinContent(i, 0);
27  }
28 
29  h->Sumw2(false); // Drop all the errors
30 
31  return h;
32  }
const double minz
Definition: HeatMap.h:21
const double minx
Definition: HeatMap.h:21
const int Nx
Definition: HeatMap.h:22
const double maxx
Definition: HeatMap.h:21
const int Nz
Definition: HeatMap.h:22
const double maxz
Definition: HeatMap.h:21
std::vector< float > map
Definition: HeatMap.h:24
int quad::HeatMap::fast_floor ( double  x) const
inlineprivate

Definition at line 28 of file HeatMap.h.

Referenced by XToBin(), and ZToBin().

28 { return int(x + 100000) - 100000; }
Float_t x
Definition: compare.C:6
double quad::HeatMap::XBinCenter ( int  ix) const
inline

Definition at line 17 of file HeatMap.h.

References maxx, minx, and Nx.

17 { return minx + (ix + .5) * (maxx - minx) / Nx; }
const double minx
Definition: HeatMap.h:21
const int Nx
Definition: HeatMap.h:22
const double maxx
Definition: HeatMap.h:21
int quad::HeatMap::XToBin ( double  x) const
inline

Definition at line 19 of file HeatMap.h.

References fast_floor(), maxx, minx, and Nx.

Referenced by quad::MapFromLines().

19 { return fast_floor((x - minx) / (maxx - minx) * Nx); }
Float_t x
Definition: compare.C:6
const double minx
Definition: HeatMap.h:21
const int Nx
Definition: HeatMap.h:22
const double maxx
Definition: HeatMap.h:21
int fast_floor(double x) const
Definition: HeatMap.h:28
double quad::HeatMap::ZBinCenter ( int  iz) const
inline

Definition at line 16 of file HeatMap.h.

References maxz, minz, and Nz.

16 { return minz + (iz + .5) * (maxz - minz) / Nz; }
const double minz
Definition: HeatMap.h:21
const int Nz
Definition: HeatMap.h:22
const double maxz
Definition: HeatMap.h:21
int quad::HeatMap::ZToBin ( double  z) const
inline

Definition at line 18 of file HeatMap.h.

References fast_floor(), maxz, minz, and Nz.

Referenced by quad::MapFromLines().

18 { return fast_floor((z - minz) / (maxz - minz) * Nz); }
const double minz
Definition: HeatMap.h:21
Double_t z
Definition: plot.C:276
int fast_floor(double x) const
Definition: HeatMap.h:28
const int Nz
Definition: HeatMap.h:22
const double maxz
Definition: HeatMap.h:21

Member Data Documentation

std::vector<float> quad::HeatMap::map

Definition at line 24 of file HeatMap.h.

Referenced by AsTH2(), and quad::MapFromLines().

const double quad::HeatMap::maxx

Definition at line 21 of file HeatMap.h.

Referenced by AsTH2(), XBinCenter(), and XToBin().

const double quad::HeatMap::maxz

Definition at line 21 of file HeatMap.h.

Referenced by AsTH2(), ZBinCenter(), and ZToBin().

const double quad::HeatMap::minx

Definition at line 21 of file HeatMap.h.

Referenced by AsTH2(), XBinCenter(), and XToBin().

const double quad::HeatMap::minz

Definition at line 21 of file HeatMap.h.

Referenced by AsTH2(), ZBinCenter(), and ZToBin().

const int quad::HeatMap::Nx

Definition at line 22 of file HeatMap.h.

Referenced by AsTH2(), quad::MapFromLines(), XBinCenter(), and XToBin().

const int quad::HeatMap::Nz

Definition at line 22 of file HeatMap.h.

Referenced by AsTH2(), ZBinCenter(), and ZToBin().


The documentation for this class was generated from the following files: