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
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor with a given input binning and the slope and offset to be applied to
35/// construct the linear transformation
36
42
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Copy constructor
47
49 : RooAbsBinning(name), _slope(other._slope), _offset(other._offset), _input(other._input)
50{
51}
52
53////////////////////////////////////////////////////////////////////////////////
54
55void RooLinTransBinning::setRange(double /*xlo*/, double /*xhi*/)
56{
57 // Change limits -- not implemented
58}
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Return array of bin boundaries
63
65{
66 const int n = numBoundaries();
67 // Return array with boundary values
68 _array.resize(n);
69
70 const double* inputArray = _input->array() ;
71
72 if (_slope>0) {
73 for (int i=0; i < n; i++) {
74 _array[i] = trans(inputArray[i]) ;
75 }
76 } else {
77 for (int i=0; i < n; i++) {
78 _array[i] = trans(inputArray[n-i-1]) ;
79 }
80 }
81
82 return _array.data();
83}
84
85
86
87////////////////////////////////////////////////////////////////////////////////
88/// Update the slope and offset parameters and the pointer to the input binning
89
91{
92 _input = const_cast<RooAbsBinning*>(&input);
93 _slope = slope ;
94 _offset = offset ;
95}
96
97
98void RooLinTransBinning::binNumbers(double const * x, int * bins, std::size_t n, int coef) const
99{
100 // We are not allowed to modify the input array, so we can't apply the
101 // transformation in-place and then call _input->binNumbers() without
102 // allocating additional memory. That's why we fall back to binNumber() for
103 // now. The RooLinTransBinning is only ever used in the RooLinearVar, so if
104 // this ever becomes a bottleneck this could be optimized.
105 for(std::size_t i = 0; i < n; ++i) {
106 bins[i] += coef * _input->binNumber(invTrans(x[i]));
107 }
108}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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