Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooAbsBinning.h,v 1.13 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_ABS_BINNING
0017 #define ROO_ABS_BINNING
0018 
0019 #include "Rtypes.h"
0020 #include "RooPrintable.h"
0021 #include "TNamed.h"
0022 class RooAbsRealLValue ;
0023 class RooAbsReal ;
0024 
0025 class RooAbsBinning : public TNamed, public RooPrintable {
0026 public:
0027 
0028   RooAbsBinning(const char* name=nullptr) : TNamed{name, name} {}
0029   RooAbsBinning(const RooAbsBinning& other, const char* name=nullptr) : TNamed(name,name), RooPrintable(other) {
0030     // Copy constructor
0031   }
0032   TObject* Clone(const char* newname=nullptr) const override { return clone(newname) ; }
0033   virtual RooAbsBinning* clone(const char* name=nullptr) const = 0 ;
0034 
0035   /// Return number of bins.
0036   Int_t numBins() const {
0037     return numBoundaries()-1 ;
0038   }
0039   virtual Int_t numBoundaries() const = 0 ;
0040 
0041   /// Compute the bin indices for multiple values of `x`.
0042   ///
0043   /// For each element in the input, the corresponding output element will be
0044   /// increased by `coef * binIdx`. This is useful for aggregating
0045   /// multi-dimensional bin indices inplace.
0046   ///
0047   /// param[in] x The read-only input array of values of `x`.
0048   /// param[out] bins The output array. Note that the initial values don't get
0049   ///                 replaced! The result is added to the array elements.
0050   /// param[in] n The size of the input and output arrays.
0051   /// param[in] coef The multiplication factor that is applied to all calculated bin indices.
0052   virtual void binNumbers(double const * x, int * bins, std::size_t n, int coef=1) const = 0 ;
0053 
0054   /// Returns the bin number corresponding to the value `x`.
0055   ///
0056   /// \note This `inline` function is implemented by calling the vectorized
0057   ///       function `RooAbsBinning::binNumbers()`. If you want to calculate
0058   ///       the bin indices for multiple values, use that one for better
0059   ///       performance.
0060   inline int binNumber(double x) const {
0061     int out = 0.0;
0062     binNumbers(&x, &out, 1);
0063     return out;
0064   }
0065 
0066   virtual double binCenter(Int_t bin) const = 0 ;
0067   virtual double binWidth(Int_t bin) const = 0 ;
0068   virtual double binLow(Int_t bin) const = 0 ;
0069   virtual double binHigh(Int_t bin) const = 0 ;
0070   virtual bool isUniform() const { return false ; }
0071 
0072   virtual void setRange(double xlo, double xhi) = 0 ;
0073   /// Change lower bound to xlo.
0074   virtual void setMin(double xlo) {
0075     setRange(xlo,highBound()) ;
0076   }
0077   /// Change upper bound to xhi.
0078   virtual void setMax(double xhi) {
0079     setRange(lowBound(),xhi) ;
0080   }
0081 
0082   virtual double lowBound() const = 0 ;
0083   virtual double highBound() const = 0 ;
0084   virtual double averageBinWidth() const = 0 ;
0085 
0086 
0087   virtual double* array() const = 0 ;
0088 
0089   inline void Print(Option_t *options= nullptr) const override {
0090     // Printing interface
0091     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0092   }
0093 
0094   void printName(std::ostream& os) const override ;
0095   void printTitle(std::ostream& os) const override ;
0096   void printClassName(std::ostream& os) const override ;
0097   void printArgs(std::ostream& os) const override ;
0098   void printValue(std::ostream& os) const override ;
0099 
0100   /// Interface function. If true, min/max of binning is parameterized by external RooAbsReals.
0101   /// Default to `false`, unless overridden by a sub class.
0102   virtual bool isParameterized() const {
0103     return false ;
0104   }
0105   /// Return pointer to RooAbsReal parameterized lower bound, if any.
0106   virtual RooAbsReal* lowBoundFunc() const {
0107     return nullptr ;
0108   }
0109   /// Return pointer to RooAbsReal parameterized upper bound, if any.
0110   virtual RooAbsReal* highBoundFunc() const {
0111     return nullptr ;
0112   }
0113   /// If true (default), the range definition can be shared across clones of a RooRealVar.
0114   virtual bool isShareable() const {
0115     return true ;
0116   }
0117   /// Hook interface function to execute code upon insertion into a RooAbsRealLValue.
0118   virtual void insertHook(RooAbsRealLValue&) const {  }
0119   /// Hook interface function to execute code upon removal from a RooAbsRealLValue.
0120   virtual void removeHook(RooAbsRealLValue&) const {  }
0121 
0122 
0123 protected:
0124 
0125   ClassDefOverride(RooAbsBinning,2) // Abstract base class for binning specification
0126 };
0127 
0128 #endif