forked from sPHENIX-Collaboration/coresoftware
/
QAHistManagerDef.cc
72 lines (58 loc) · 1.56 KB
/
QAHistManagerDef.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// $Id: $
/*!
* \file QAHistManagerDef.h
* \brief
* \author Jin Huang <jhuang@bnl.gov>
* \version $Revision: $
* \date $Date: $
*/
#include "QAHistManagerDef.h"
#include <fun4all/Fun4AllHistoManager.h>
#include <fun4all/Fun4AllServer.h>
#include <TAxis.h>
#include <cassert>
#include <cmath>
#include <iosfwd> // for std
#include <vector>
namespace QAHistManagerDef
{
//! Get a pointer to the default hist manager for QA modules
Fun4AllHistoManager *
getHistoManager()
{
Fun4AllServer *se = Fun4AllServer::instance();
Fun4AllHistoManager *hm = se->getHistoManager(HistoManagerName);
if (not hm)
{
// std::cout
// << "QAHistManagerDef::get_HistoManager - Making Fun4AllHistoManager EMCalAna_HISTOS"
// << std::endl;
hm = new Fun4AllHistoManager(HistoManagerName);
se->registerHistoManager(hm);
}
assert(hm);
return hm;
}
//! Save hist to root files
void saveQARootFile(const std::string &file_name)
{
getHistoManager()->dumpHistos(file_name);
}
//! utility function to
void useLogBins(TAxis *axis)
{
assert(axis);
assert(axis->GetXmin() > 0);
assert(axis->GetXmax() > 0);
const int bins = axis->GetNbins();
Axis_t from = log10(axis->GetXmin());
Axis_t to = log10(axis->GetXmax());
Axis_t width = (to - from) / bins;
std::vector<Axis_t> new_bins(bins + 1);
for (int i = 0; i <= bins; i++)
{
new_bins[i] = pow(10, from + i * width);
}
axis->Set(bins, new_bins.data());
}
} // namespace QAHistManagerDef