Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooLinTransBinning.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooLinTransBinning.h,v 1.9 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_LIN_TRANS_BINNING
0017 #define ROO_LIN_TRANS_BINNING
0018 
0019 #include "Rtypes.h"
0020 #include "RooAbsBinning.h"
0021 
0022 class RooLinTransBinning : public RooAbsBinning {
0023 public:
0024 
0025   RooLinTransBinning(const char* name=nullptr) : RooAbsBinning(name) { }
0026   RooLinTransBinning(const RooAbsBinning& input, double slope=1.0, double offset=0.0, const char* name=nullptr);
0027   RooLinTransBinning(const RooLinTransBinning&, const char* name=nullptr);
0028   RooAbsBinning* clone(const char* name=nullptr) const override { return new RooLinTransBinning(*this,name) ; }
0029 
0030   Int_t numBoundaries() const override { return _input->numBoundaries() ; }
0031   void binNumbers(double const * x, int * bins, std::size_t n, int coef) const override;
0032   double binCenter(Int_t bin) const override { return trans(_input->binCenter(binTrans(bin))) ; }
0033   double binWidth(Int_t bin) const override { return _slope*_input->binWidth(binTrans(bin)) ; }
0034   double binLow(Int_t bin) const override { if (_slope>0) return trans(_input->binLow(binTrans(bin))) ; else return trans(_input->binHigh(binTrans(bin))) ; }
0035   double binHigh(Int_t bin) const override { if (_slope>0) return trans(_input->binHigh(binTrans(bin))) ; else return trans(_input->binLow(binTrans(bin))) ; }
0036 
0037   void setRange(double xlo, double xhi) override ;
0038   void setMin(double xlo) override { setRange(xlo,highBound()) ; }
0039   void setMax(double xhi) override { setRange(lowBound(),xhi) ; }
0040 
0041   double lowBound() const override { if (_slope>0) return trans(_input->lowBound()) ; else return trans(_input->highBound()) ; }
0042   double highBound() const override { if (_slope>0) return trans(_input->highBound()) ; else return trans(_input->lowBound()) ; }
0043   double averageBinWidth() const override { return _slope*_input->averageBinWidth() ; }
0044 
0045   double* array() const override ;
0046 
0047   void updateInput(const RooAbsBinning& input, double slope=1.0, double offset=0.0) ;
0048 
0049 protected:
0050 
0051   inline Int_t binTrans(Int_t bin) const { if (_slope>0) return bin ; else return numBins()-bin-1 ; }
0052   inline double trans(double x) const { return x*_slope + _offset ; }
0053   inline double invTrans(double x) const { if (_slope==0.0) return 0.0 ; return (x-_offset)/_slope ; }
0054 
0055   double _slope{0.};   ///< Slope of transformation
0056   double _offset{0.};  ///< Offset of transformation
0057   RooAbsBinning* _input{nullptr};    ///< Input binning
0058   mutable std::vector<double> _array; ///<! Array of transformed bin boundaries
0059 
0060   ClassDefOverride(RooLinTransBinning,1) // Linear transformation of binning specification
0061 };
0062 
0063 #endif