RooLinTransBinning.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooLinTransBinning.h,v 1.9 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_LIN_TRANS_BINNING
00017 #define ROO_LIN_TRANS_BINNING
00018 
00019 #include "Rtypes.h"
00020 #include "RooAbsBinning.h"
00021 
00022 class RooLinTransBinning : public RooAbsBinning {
00023 public:
00024 
00025   RooLinTransBinning(const char* name=0) : RooAbsBinning(name) {
00026     // coverity[UNINIT_CTOR]
00027   } ; 
00028   RooLinTransBinning(const RooAbsBinning& input, Double_t slope=1.0, Double_t offset=0.0, const char* name=0) ;
00029   RooLinTransBinning(const RooLinTransBinning&, const char* name=0) ;
00030   virtual RooAbsBinning* clone(const char* name=0) const { return new RooLinTransBinning(*this,name) ; }
00031   virtual ~RooLinTransBinning() ;
00032 
00033   virtual Int_t numBoundaries() const { return _input->numBoundaries() ; }
00034   virtual Int_t binNumber(Double_t x) const { return _input->binNumber(invTrans(x)) ; }
00035   virtual Double_t binCenter(Int_t bin) const { return trans(_input->binCenter(binTrans(bin))) ; }
00036   virtual Double_t binWidth(Int_t bin) const { return _slope*_input->binWidth(binTrans(bin)) ; }
00037   virtual Double_t binLow(Int_t bin) const { if (_slope>0) return trans(_input->binLow(binTrans(bin))) ; else return trans(_input->binHigh(binTrans(bin))) ; }
00038   virtual Double_t binHigh(Int_t bin) const { if (_slope>0) return trans(_input->binHigh(binTrans(bin))) ; else return trans(_input->binLow(binTrans(bin))) ; }
00039 
00040   virtual void setRange(Double_t xlo, Double_t xhi) ;
00041   virtual void setMin(Double_t xlo) { setRange(xlo,highBound()) ; }
00042   virtual void setMax(Double_t xhi) { setRange(lowBound(),xhi) ; }
00043 
00044   virtual Double_t lowBound() const { if (_slope>0) return trans(_input->lowBound()) ; else return trans(_input->highBound()) ; }
00045   virtual Double_t highBound() const { if (_slope>0) return trans(_input->highBound()) ; else return trans(_input->lowBound()) ; }
00046   virtual Double_t averageBinWidth() const { return _slope*_input->averageBinWidth() ; }
00047 
00048   virtual Double_t* array() const ;
00049 
00050   void updateInput(const RooAbsBinning& input, Double_t slope=1.0, Double_t offset=0.0) ;
00051 
00052 protected:
00053     
00054   inline Int_t binTrans(Int_t bin) const { if (_slope>0) return bin ; else return numBins()-bin-1 ; }
00055   inline Double_t trans(Double_t x) const { return x*_slope + _offset ; }
00056   inline Double_t invTrans(Double_t x) const { if (_slope==0.) return 0 ; return (x-_offset)/_slope ; }
00057 
00058   Double_t _slope ;         // Slope of transformation
00059   Double_t _offset ;        // Offset of tranformation
00060   RooAbsBinning* _input ;   // Input binning
00061   mutable Double_t *_array ; //! Array of transformed bin boundaries
00062 
00063   ClassDef(RooLinTransBinning,1) // Linear transformation of binning specification
00064 };
00065 
00066 #endif

Generated on Tue Jul 5 14:26:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1