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
22RooLinTransBinning is a special 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
31using namespace std;
32
34;
35
36
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor with a given input binning and the slope and offset to be applied to
40/// construct the linear transformation
41
42RooLinTransBinning::RooLinTransBinning(const RooAbsBinning& input, double slope, double offset, const char* name) :
44{
45 updateInput(input,slope,offset) ;
46}
47
48
49
50////////////////////////////////////////////////////////////////////////////////
51/// Copy constructor
52
55{
56 _input = other._input ;
57 _slope = other._slope ;
58 _offset = other._offset ;
59}
60
61
62
63////////////////////////////////////////////////////////////////////////////////
64/// Destructor
65
67{
68 if (_array) delete[] _array ;
69}
70
71
72
73////////////////////////////////////////////////////////////////////////////////
74
75void RooLinTransBinning::setRange(double /*xlo*/, double /*xhi*/)
76{
77 // Change limits -- not implemented
78}
79
80
81////////////////////////////////////////////////////////////////////////////////
82/// Return array of bin boundaries
83
85{
86 const int n = numBoundaries();
87 // Return array with boundary values
88 if (_array) delete[] _array ;
89 _array = new double[n] ;
90
91 const double* inputArray = _input->array() ;
92
93 if (_slope>0) {
94 for (int i=0; i < n; i++) {
95 _array[i] = trans(inputArray[i]) ;
96 }
97 } else {
98 for (int i=0; i < n; i++) {
99 _array[i] = trans(inputArray[n-i-1]) ;
100 }
101 }
102
103 return _array;
104}
105
106
107
108////////////////////////////////////////////////////////////////////////////////
109/// Update the slope and offset parameters and the pointer to the input binning
110
112{
114 _slope = slope ;
115 _offset = offset ;
116}
117
118
119void RooLinTransBinning::binNumbers(double const * x, int * bins, std::size_t n, int coef) const
120{
121 // We are not allowed to modify the input array, so we can't apply the
122 // transformation in-place and then call _input->binNumbers() without
123 // allocating additional memory. That's why we fall back to binNumber() for
124 // now. The RooLinTransBinning is only ever used in the RooLinearVar, so if
125 // this ever becomes a bottleneck this could be optimized.
126 for(std::size_t i = 0; i < n; ++i) {
127 bins[i] += coef * _input->binNumber(invTrans(x[i]));
128 }
129}
#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
RooAbsBinning is the 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
RooLinTransBinning is a special binning implementation for RooLinearVar that transforms the binning o...
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
double trans(double x) const
~RooLinTransBinning() override
Destructor.
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.
double * _array
! Array of transformed 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