/*****************************************************************************
 * 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
// RooRangeBoolean
// END_HTML
//

#include "RooFit.h"

#include "Riostream.h"
#include "Riostream.h"
#include <math.h>
#include "TMath.h"

#include "RooRangeBoolean.h"
#include "RooAbsReal.h"
#include "RooRealVar.h"
#include "RooArgList.h"
#include "RooMsgService.h"
#include "TMath.h"

using namespace std;

ClassImp(RooRangeBoolean)
;


//_____________________________________________________________________________
RooRangeBoolean::RooRangeBoolean()
{
  // Default constructor
}


//_____________________________________________________________________________
RooRangeBoolean::RooRangeBoolean(const char* name, const char* title, RooAbsRealLValue& x, const char* rangeName) :
  RooAbsReal(name, title),
  _x("x", "Dependent", this, x),
  _rangeName(rangeName)
{
}



//_____________________________________________________________________________
RooRangeBoolean::RooRangeBoolean(const RooRangeBoolean& other, const char* name) :
  RooAbsReal(other, name), 
  _x("x", this, other._x),
  _rangeName(other._rangeName)
{
  // Copy constructor
}




//_____________________________________________________________________________
RooRangeBoolean::~RooRangeBoolean() 
{
  // Destructor
}




//_____________________________________________________________________________
Double_t RooRangeBoolean::evaluate() const 
{
  // Return 1 if x is in range, zero otherwis
  Double_t xmin = ((RooAbsRealLValue&)_x.arg()).getMin(_rangeName.Data()) ;
  Double_t xmax = ((RooAbsRealLValue&)_x.arg()).getMax(_rangeName.Data()) ;
  
  Double_t ret = (_x >= xmin && _x < xmax) ? 1.0 : 0.0 ;
  return ret ;
}



//_____________________________________________________________________________
std::list<Double_t>* RooRangeBoolean::plotSamplingHint(RooAbsRealLValue& obs, Double_t /*xlo*/, Double_t /*xhi*/) const 
{
  if (string(obs.GetName())!=_x.arg().GetName()) {
    return 0 ;
  }

  list<Double_t>* hint = new list<Double_t> ;
  hint->push_back(((RooAbsRealLValue&)_x.arg()).getMin(_rangeName.Data())-1e-6) ;
  hint->push_back(((RooAbsRealLValue&)_x.arg()).getMin(_rangeName.Data())+1e-6) ;
  hint->push_back(((RooAbsRealLValue&)_x.arg()).getMax(_rangeName.Data())-1e-6) ;  
  hint->push_back(((RooAbsRealLValue&)_x.arg()).getMax(_rangeName.Data())+1e-6) ;  
  return hint ;
}

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