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