/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id$
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// RooLinTransBinning is a special binning implementation for RooLinearVar
// that transforms the binning of the RooLinearVar input variable in the same
// way that RooLinearVar does
// END_HTML
//


#include "RooFit.h"

#include "RooLinTransBinning.h"
#include "RooLinTransBinning.h"

using namespace std;

ClassImp(RooLinTransBinning) 
;



//_____________________________________________________________________________
RooLinTransBinning::RooLinTransBinning(const RooAbsBinning& input, Double_t slope, Double_t offset, const char* name) :
  RooAbsBinning(name),
  _array(0) 
{
  // Constructor with a given input binning and the slope and offset to be applied to
  // construct the linear transformation

  updateInput(input,slope,offset) ;
}



//_____________________________________________________________________________
RooLinTransBinning::RooLinTransBinning(const RooLinTransBinning& other, const char* name) :
  RooAbsBinning(name),
  _array(0)
{
  // Copy constructor

  _input = other._input ;
  _slope = other._slope ;
  _offset = other._offset ;    
}



//_____________________________________________________________________________
RooLinTransBinning::~RooLinTransBinning() 
{
  // Destructor 

  if (_array) delete[] _array ;
}



//_____________________________________________________________________________
void RooLinTransBinning::setRange(Double_t /*xlo*/, Double_t /*xhi*/) 
{

  // Change limits -- not implemented
}


//_____________________________________________________________________________
Double_t* RooLinTransBinning::array() const 
{
  // Return array of bin boundaries

  Int_t n = numBoundaries() ;
  // Return array with boundary values
  if (_array) delete[] _array ;
  _array = new Double_t[n] ;

  Double_t* inputArray = _input->array() ;

  Int_t i ;
  if (_slope>0) {
    for (i=0 ; i<n ; i++) {
      _array[i] = trans(inputArray[i]) ;
    }
  } else {
    for (i=0 ; i<n ; i++) {
      _array[i] = trans(inputArray[n-i-1]) ;
    }
  }
  return _array ;

}



//_____________________________________________________________________________
void RooLinTransBinning::updateInput(const RooAbsBinning& input, Double_t slope, Double_t offset)
{
  // Update the slope and offset parameters and the pointer to the input binning

  _input = (RooAbsBinning*) &input ;
  _slope = slope ;
  _offset = offset ;
}

 RooLinTransBinning.cxx:1
 RooLinTransBinning.cxx:2
 RooLinTransBinning.cxx:3
 RooLinTransBinning.cxx:4
 RooLinTransBinning.cxx:5
 RooLinTransBinning.cxx:6
 RooLinTransBinning.cxx:7
 RooLinTransBinning.cxx:8
 RooLinTransBinning.cxx:9
 RooLinTransBinning.cxx:10
 RooLinTransBinning.cxx:11
 RooLinTransBinning.cxx:12
 RooLinTransBinning.cxx:13
 RooLinTransBinning.cxx:14
 RooLinTransBinning.cxx:15
 RooLinTransBinning.cxx:16
 RooLinTransBinning.cxx:17
 RooLinTransBinning.cxx:18
 RooLinTransBinning.cxx:19
 RooLinTransBinning.cxx:20
 RooLinTransBinning.cxx:21
 RooLinTransBinning.cxx:22
 RooLinTransBinning.cxx:23
 RooLinTransBinning.cxx:24
 RooLinTransBinning.cxx:25
 RooLinTransBinning.cxx:26
 RooLinTransBinning.cxx:27
 RooLinTransBinning.cxx:28
 RooLinTransBinning.cxx:29
 RooLinTransBinning.cxx:30
 RooLinTransBinning.cxx:31
 RooLinTransBinning.cxx:32
 RooLinTransBinning.cxx:33
 RooLinTransBinning.cxx:34
 RooLinTransBinning.cxx:35
 RooLinTransBinning.cxx:36
 RooLinTransBinning.cxx:37
 RooLinTransBinning.cxx:38
 RooLinTransBinning.cxx:39
 RooLinTransBinning.cxx:40
 RooLinTransBinning.cxx:41
 RooLinTransBinning.cxx:42
 RooLinTransBinning.cxx:43
 RooLinTransBinning.cxx:44
 RooLinTransBinning.cxx:45
 RooLinTransBinning.cxx:46
 RooLinTransBinning.cxx:47
 RooLinTransBinning.cxx:48
 RooLinTransBinning.cxx:49
 RooLinTransBinning.cxx:50
 RooLinTransBinning.cxx:51
 RooLinTransBinning.cxx:52
 RooLinTransBinning.cxx:53
 RooLinTransBinning.cxx:54
 RooLinTransBinning.cxx:55
 RooLinTransBinning.cxx:56
 RooLinTransBinning.cxx:57
 RooLinTransBinning.cxx:58
 RooLinTransBinning.cxx:59
 RooLinTransBinning.cxx:60
 RooLinTransBinning.cxx:61
 RooLinTransBinning.cxx:62
 RooLinTransBinning.cxx:63
 RooLinTransBinning.cxx:64
 RooLinTransBinning.cxx:65
 RooLinTransBinning.cxx:66
 RooLinTransBinning.cxx:67
 RooLinTransBinning.cxx:68
 RooLinTransBinning.cxx:69
 RooLinTransBinning.cxx:70
 RooLinTransBinning.cxx:71
 RooLinTransBinning.cxx:72
 RooLinTransBinning.cxx:73
 RooLinTransBinning.cxx:74
 RooLinTransBinning.cxx:75
 RooLinTransBinning.cxx:76
 RooLinTransBinning.cxx:77
 RooLinTransBinning.cxx:78
 RooLinTransBinning.cxx:79
 RooLinTransBinning.cxx:80
 RooLinTransBinning.cxx:81
 RooLinTransBinning.cxx:82
 RooLinTransBinning.cxx:83
 RooLinTransBinning.cxx:84
 RooLinTransBinning.cxx:85
 RooLinTransBinning.cxx:86
 RooLinTransBinning.cxx:87
 RooLinTransBinning.cxx:88
 RooLinTransBinning.cxx:89
 RooLinTransBinning.cxx:90
 RooLinTransBinning.cxx:91
 RooLinTransBinning.cxx:92
 RooLinTransBinning.cxx:93
 RooLinTransBinning.cxx:94
 RooLinTransBinning.cxx:95
 RooLinTransBinning.cxx:96
 RooLinTransBinning.cxx:97
 RooLinTransBinning.cxx:98
 RooLinTransBinning.cxx:99
 RooLinTransBinning.cxx:100
 RooLinTransBinning.cxx:101
 RooLinTransBinning.cxx:102
 RooLinTransBinning.cxx:103
 RooLinTransBinning.cxx:104
 RooLinTransBinning.cxx:105
 RooLinTransBinning.cxx:106
 RooLinTransBinning.cxx:107
 RooLinTransBinning.cxx:108
 RooLinTransBinning.cxx:109
 RooLinTransBinning.cxx:110
 RooLinTransBinning.cxx:111
 RooLinTransBinning.cxx:112
 RooLinTransBinning.cxx:113
 RooLinTransBinning.cxx:114
 RooLinTransBinning.cxx:115
 RooLinTransBinning.cxx:116
 RooLinTransBinning.cxx:117
 RooLinTransBinning.cxx:118
 RooLinTransBinning.cxx:119
 RooLinTransBinning.cxx:120
 RooLinTransBinning.cxx:121