Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooLinTransBinning.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooLinTransBinning.h,v 1.9 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_LIN_TRANS_BINNING
17 #define ROO_LIN_TRANS_BINNING
18 
19 #include "Rtypes.h"
20 #include "RooAbsBinning.h"
21 
22 class RooLinTransBinning : public RooAbsBinning {
23 public:
24 
25  RooLinTransBinning(const char* name=0) : RooAbsBinning(name) { }
26  RooLinTransBinning(const RooAbsBinning& input, Double_t slope=1.0, Double_t offset=0.0, const char* name=0);
27  RooLinTransBinning(const RooLinTransBinning&, const char* name=0);
28  virtual RooAbsBinning* clone(const char* name=0) const { return new RooLinTransBinning(*this,name) ; }
29  virtual ~RooLinTransBinning() ;
30 
31  virtual Int_t numBoundaries() const { return _input->numBoundaries() ; }
32  virtual Int_t binNumber(Double_t x) const { return _input->binNumber(invTrans(x)) ; }
33  virtual Double_t binCenter(Int_t bin) const { return trans(_input->binCenter(binTrans(bin))) ; }
34  virtual Double_t binWidth(Int_t bin) const { return _slope*_input->binWidth(binTrans(bin)) ; }
35  virtual Double_t binLow(Int_t bin) const { if (_slope>0) return trans(_input->binLow(binTrans(bin))) ; else return trans(_input->binHigh(binTrans(bin))) ; }
36  virtual Double_t binHigh(Int_t bin) const { if (_slope>0) return trans(_input->binHigh(binTrans(bin))) ; else return trans(_input->binLow(binTrans(bin))) ; }
37 
38  virtual void setRange(Double_t xlo, Double_t xhi) ;
39  virtual void setMin(Double_t xlo) { setRange(xlo,highBound()) ; }
40  virtual void setMax(Double_t xhi) { setRange(lowBound(),xhi) ; }
41 
42  virtual Double_t lowBound() const { if (_slope>0) return trans(_input->lowBound()) ; else return trans(_input->highBound()) ; }
43  virtual Double_t highBound() const { if (_slope>0) return trans(_input->highBound()) ; else return trans(_input->lowBound()) ; }
44  virtual Double_t averageBinWidth() const { return _slope*_input->averageBinWidth() ; }
45 
46  virtual Double_t* array() const ;
47 
48  void updateInput(const RooAbsBinning& input, Double_t slope=1.0, Double_t offset=0.0) ;
49 
50 protected:
51 
52  inline Int_t binTrans(Int_t bin) const { if (_slope>0) return bin ; else return numBins()-bin-1 ; }
53  inline Double_t trans(Double_t x) const { return x*_slope + _offset ; }
54  inline Double_t invTrans(Double_t x) const { if (_slope==0.) return 0 ; return (x-_offset)/_slope ; }
55 
56  Double_t _slope{0.}; // Slope of transformation
57  Double_t _offset{0.}; // Offset of transformation
58  RooAbsBinning* _input{nullptr}; // Input binning
59  mutable Double_t *_array{nullptr}; //! Array of transformed bin boundaries
60 
61  ClassDef(RooLinTransBinning,1) // Linear transformation of binning specification
62 };
63 
64 #endif