Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:32:49

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