1 |
rkogler |
1.1 |
#include <cmath>
|
2 |
|
|
#include "include/BaseHists.h"
|
3 |
|
|
|
4 |
|
|
BaseHists::BaseHists(const char* name)
|
5 |
|
|
{
|
6 |
|
|
// named constructor
|
7 |
|
|
m_name = name;
|
8 |
|
|
SetLogName("BaseHists_" + m_name);
|
9 |
|
|
}
|
10 |
|
|
|
11 |
|
|
BaseHists::~BaseHists()
|
12 |
|
|
{
|
13 |
|
|
// default destructor, does nothing
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
void BaseHists::WriteObj( const TObject& obj ) throw( SError ) {
|
17 |
|
|
|
18 |
|
|
SCycleBaseHist::WriteObj( obj, m_name.Data() );
|
19 |
|
|
return;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
TH1* BaseHists::Hist( const char* name ) {
|
24 |
|
|
|
25 |
|
|
TH1* his = SCycleBaseHist::Hist( name, m_name.Data() );
|
26 |
|
|
return his;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
double* BaseHists::MakeLogBinning(int n_bins, double xmin, double xmax)
|
32 |
|
|
{
|
33 |
|
|
// return pointer to an array of bins in logscale
|
34 |
|
|
// usage: Double_t* ptbins = MakeLogBinning(50,100,2000.);
|
35 |
|
|
// ... TH1F("Pt","Jet PT", 50, ptbins);
|
36 |
|
|
|
37 |
|
|
double *binning = new double[n_bins+1];
|
38 |
|
|
|
39 |
|
|
double delta_x_log = (log(xmax)-log(xmin))/n_bins;
|
40 |
|
|
|
41 |
|
|
binning[0]=xmin;
|
42 |
|
|
// put equidistant binwidth on a logarithmic scale
|
43 |
|
|
for(int i=1;i<=n_bins;++i){
|
44 |
|
|
binning[i] = exp(log(binning[i-1])+ delta_x_log);
|
45 |
|
|
}
|
46 |
|
|
return binning;
|
47 |
|
|
}
|