DAS  3.0
Das Analysis System
ExtractBinning.h
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cstdlib>
3 #include <functional>
4 #include <vector>
5 
7 
8 #include <TAxis.h>
9 #include <TH3.h>
10 #include <TString.h>
11 
12 using namespace std;
13 
14 namespace DAS::Normalisation {
17 
18 vector<double> extractBinning(const unique_ptr<TH1> &h3D, const TString &axis)
19 {
20  const TAxis *naxis = nullptr;
21  if (axis == "X") naxis = h3D->GetXaxis();
22  else if (axis == "Y") naxis = h3D->GetYaxis();
23  else if (axis == "Z") naxis = h3D->GetZaxis();
24 
25  int ndiv = naxis->GetNbins();
26  vector<double> binning(ndiv+1);
27  naxis->GetLowEdge(&binning[0]);
28  binning[ndiv] = naxis->GetBinUpEdge(ndiv);
29 
30  return binning;
31 }
32 } // end of DAS::Normalisation namespace
toolbox.h
DAS::Normalisation::extractBinning
vector< double > extractBinning(const unique_ptr< TH1 > &h3D, const TString &axis)
Extract the axis binning from a TH1 obgect and return it in a vector.
Definition: ExtractBinning.h:18
DAS::Normalisation
Definition: getHLTJetResponse.cc:34