Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:19

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooBinning.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_BINNING
0017 #define ROO_BINNING
0018 
0019 #include "Rtypes.h"
0020 #include "RooAbsBinning.h"
0021 #include "RooNumber.h"
0022 #include <vector>
0023 class RooAbsPdf;
0024 class RooRealVar;
0025 
0026 
0027 class RooBinning : public RooAbsBinning {
0028 public:
0029 
0030   RooBinning(double xlo = -RooNumber::infinity(), double xhi = RooNumber::infinity(), const char* name = nullptr);
0031   RooBinning(Int_t nBins, double xlo, double xhi, const char* name = nullptr);
0032   RooBinning(Int_t nBins, const double* boundaries, const char* name = nullptr);
0033   RooBinning(const RooBinning& other, const char* name = nullptr);
0034   RooAbsBinning* clone(const char* name = nullptr) const override { return new RooBinning(*this,name?name:GetName()); }
0035   ~RooBinning() override;
0036 
0037   /// Return the number boundaries
0038   Int_t numBoundaries() const override {
0039     return _nbins+1;
0040   }
0041   void binNumbers(double const * x, int * bins, std::size_t n, int coef) const override;
0042   virtual double nearestBoundary(double x) const;
0043 
0044   void setRange(double xlo, double xhi) override;
0045 
0046   /// Return the lower bound value
0047   double lowBound() const override {
0048     return _xlo;
0049   }
0050 
0051   /// Return the upper bound value
0052   double highBound() const override {
0053     return _xhi;
0054   }
0055 
0056   /// Return the average bin width
0057   double averageBinWidth() const override {
0058     return (highBound() - lowBound()) / numBins();
0059   }
0060   double* array() const override;
0061 
0062   double binCenter(Int_t bin) const override;
0063   double binWidth(Int_t bin) const override;
0064   double binLow(Int_t bin) const override;
0065   double binHigh(Int_t bin) const override;
0066 
0067   bool addBoundary(double boundary);
0068   void addBoundaryPair(double boundary, double mirrorPoint = 0);
0069   void addUniform(Int_t nBins, double xlo, double xhi);
0070   bool removeBoundary(double boundary);
0071 
0072 protected:
0073 
0074   bool binEdges(Int_t bin, double& xlo, double& xhi) const;
0075   void updateBinCount();
0076 
0077   double _xlo = 0.0;          ///< Lower bound
0078   double _xhi = 0.0;          ///< Upper bound
0079   bool _ownBoundLo = true;     ///< Does the lower bound coincide with a bin boundary
0080   bool _ownBoundHi = true;     ///< Does the upper bound coincide with a bin boundary
0081   Int_t _nbins;           ///< Number of bins
0082 
0083   std::vector<double> _boundaries; ///< Boundaries
0084   mutable double* _array = nullptr;          ///<! Array of boundaries
0085   mutable Int_t _blo = 0.0;                ///<! bin number for _xlo
0086 
0087   ClassDefOverride(RooBinning,3) // Generic binning specification
0088 };
0089 
0090 #endif