Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooLinTransBinning.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooLinTransBinning.cxx
19\class RooLinTransBinning
20\ingroup Roofitcore
21
22Special binning implementation for RooLinearVar
23that transforms the binning of the RooLinearVar input variable in the same
24way that RooLinearVar does
25**/
26
27#include "RooLinTransBinning.h"
28
29#include <stdexcept>
30
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// Constructor with a given input binning and the slope and offset to be applied to
36/// construct the linear transformation
37
38RooLinTransBinning::RooLinTransBinning(const RooAbsBinning& input, double slope, double offset, const char* name) :
40{
41 updateInput(input,slope,offset) ;
42}
43
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Copy constructor
48
50 : RooAbsBinning(name), _slope(other._slope), _offset(other._offset), _input(other._input)
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55
56void RooLinTransBinning::setRange(double /*xlo*/, double /*xhi*/)
57{
58 // Change limits -- not implemented
59}
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Return array of bin boundaries
64
66{
67 const int n = numBoundaries();
68 // Return array with boundary values
69 _array.resize(n);
70
71 const double* inputArray = _input->array() ;
72
73 if (_slope>0) {
74 for (int i=0; i < n; i++) {
75 _array[i] = trans(inputArray[i]) ;
76 }
77 } else {
78 for (int i=0; i < n; i++) {
79 _array[i] = trans(inputArray[n-i-1]) ;
80 }
81 }
82
83 return _array.data();
84}
85
86
87
88////////////////////////////////////////////////////////////////////////////////
89/// Update the slope and offset parameters and the pointer to the input binning
90
92{
93 _input = const_cast<RooAbsBinning*>(&input);
94 _slope = slope ;
95 _offset = offset ;
96}
97
98
99void RooLinTransBinning::binNumbers(double const * x, int * bins, std::size_t n, int coef) const
100{
101 // We are not allowed to modify the input array, so we can't apply the
102 // transformation in-place and then call _input->binNumbers() without
103 // allocating additional memory. That's why we fall back to binNumber() for
104 // now. The RooLinTransBinning is only ever used in the RooLinearVar, so if
105 // this ever becomes a bottleneck this could be optimized.
106 for(std::size_t i = 0; i < n; ++i) {
107 bins[i] += coef * _input->binNumber(invTrans(x[i]));
108 }
109}
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
char name[80]
Definition TGX11.cxx:110
Abstract base class for RooRealVar binning definitions.
int binNumber(double x) const
Returns the bin number corresponding to the value x.
virtual double * array() const =0
Special binning implementation for RooLinearVar that transforms the binning of the RooLinearVar input...
RooAbsBinning * _input
Input binning.
void updateInput(const RooAbsBinning &input, double slope=1.0, double offset=0.0)
Update the slope and offset parameters and the pointer to the input binning.
Int_t numBoundaries() const override
std::vector< double > _array
! Array of transformed bin boundaries
double trans(double x) const
void binNumbers(double const *x, int *bins, std::size_t n, int coef) const override
Compute the bin indices for multiple values of x.
double * array() const override
Return array of bin boundaries.
void setRange(double xlo, double xhi) override
double _offset
Offset of transformation.
RooLinTransBinning(const char *name=nullptr)
double invTrans(double x) const
double _slope
Slope of transformation.
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16