LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
HeatMap.cxx
Go to the documentation of this file.
2 
3 #include "TH2.h"
4 
5 namespace quad {
6  // -------------------------------------------------------------------------
7  HeatMap::HeatMap(int _Nz, double _minz, double _maxz, int _Nx, double _minx, double _maxx)
8  : minz(_minz), minx(_minx), maxz(_maxz), maxx(_maxx), Nx(_Nx), Nz(_Nz), map(Nz * Nx, 0)
9  {}
10 
11  // -------------------------------------------------------------------------
12  std::unique_ptr<TH2F> HeatMap::AsTH2() const
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  }
33 }
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
HeatMap(int _Nz, double _minz, double _maxz, int _Nx, double _minx, double _maxx)
Definition: HeatMap.cxx:7
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