AliPhysics  608b256 (608b256)
TLinearBinning.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <cfloat>
16 #include <vector>
17 #include <TArrayD.h>
18 #include <TLinearBinning.h>
19 #include <TMath.h>
20 
21 ClassImp(TLinearBinning)
22 
24  TBinning(),
25  fNbins(0),
26  fMinimum(0),
27  fMaximum(0),
28  fLimitsSet(kFALSE)
29 {
30 
31 }
32 
34  TBinning(),
35  fNbins(nbins),
36  fMinimum(min),
37  fMaximum(max),
38  fLimitsSet(kTRUE)
39 {
40 
41 }
42 
43 void TLinearBinning::CreateBinEdges(TArrayD &binedges) const {
44  if(!fLimitsSet){
45  throw LimitsNotSetException();
46  }
47  double binwidth = (fMaximum - fMinimum) / fNbins;
48 
49  std::vector<double> tmpedges;
50  double currentmin = fMinimum;
51  tmpedges.push_back(currentmin);
52  while((currentmin < fMaximum) && (TMath::Abs(currentmin - fMaximum) > DBL_EPSILON)){
53  currentmin += binwidth;
54  tmpedges.push_back(currentmin);
55  }
56 
57  binedges.Set(tmpedges.size());
58  int bincounter = 0;
59  for(auto binedge : tmpedges) binedges[bincounter++] = binedge;
60 }
61 
63  return new TLinearBinning(*this);
64 }
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
virtual void CreateBinEdges(TArrayD &binedges) const
Interface for binnings used by the histogram handler.
Definition: TBinning.h:23
int Int_t
Definition: External.C:63
Double_t fMinimum
Minimum of the binning.
Exception indicating that the limits are not set.
const Int_t nbins
Int_t fNbins
Number of bins.
Bool_t fLimitsSet
Switch indicating that the binning is initialized.
virtual TBinning * MakeCopy() const
Double_t fMaximum
Maximum of the binning.