ROOT  6.06/09
Reference Guide
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 //
19 // BEGIN_HTML
20 // RooLinTransBinning is a special binning implementation for RooLinearVar
21 // that transforms the binning of the RooLinearVar input variable in the same
22 // way that RooLinearVar does
23 // END_HTML
24 //
25 
26 
27 #include "RooFit.h"
28 
29 #include "RooLinTransBinning.h"
30 #include "RooLinTransBinning.h"
31 
32 using namespace std;
33 
35 ;
36 
37 
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Constructor with a given input binning and the slope and offset to be applied to
41 /// construct the linear transformation
42 
43 RooLinTransBinning::RooLinTransBinning(const RooAbsBinning& input, Double_t slope, Double_t offset, const char* name) :
44  RooAbsBinning(name),
45  _array(0)
46 {
47  updateInput(input,slope,offset) ;
48 }
49 
50 
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Copy constructor
54 
56  RooAbsBinning(name),
57  _array(0)
58 {
59  _input = other._input ;
60  _slope = other._slope ;
61  _offset = other._offset ;
62 }
63 
64 
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Destructor
68 
70 {
71  if (_array) delete[] _array ;
72 }
73 
74 
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 
79 {
80  // Change limits -- not implemented
81 }
82 
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Return array of bin boundaries
86 
88 {
89  Int_t n = numBoundaries() ;
90  // Return array with boundary values
91  if (_array) delete[] _array ;
92  _array = new Double_t[n] ;
93 
94  Double_t* inputArray = _input->array() ;
95 
96  Int_t i ;
97  if (_slope>0) {
98  for (i=0 ; i<n ; i++) {
99  _array[i] = trans(inputArray[i]) ;
100  }
101  } else {
102  for (i=0 ; i<n ; i++) {
103  _array[i] = trans(inputArray[n-i-1]) ;
104  }
105  }
106  return _array ;
107 
108 }
109 
110 
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// Update the slope and offset parameters and the pointer to the input binning
114 
116 {
117  _input = (RooAbsBinning*) &input ;
118  _slope = slope ;
119  _offset = offset ;
120 }
121 
virtual Int_t numBoundaries() const
void updateInput(const RooAbsBinning &input, Double_t slope=1.0, Double_t offset=0.0)
Update the slope and offset parameters and the pointer to the input binning.
int Int_t
Definition: RtypesCore.h:41
Double_t trans(Double_t x) const
STL namespace.
RooAbsBinning * _input
ClassImp(RooLinTransBinning)
RooLinTransBinning(const char *name=0)
virtual ~RooLinTransBinning()
Destructor.
double Double_t
Definition: RtypesCore.h:55
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual void setRange(Double_t xlo, Double_t xhi)
virtual Double_t * array() const
Return array of bin boundaries.
virtual Double_t * array() const =0
const Int_t n
Definition: legend1.C:16