Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRangeBoolean.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 RooRangeBoolean.cxx
19\class RooRangeBoolean
20\ingroup Roofitcore
21
22Returns `1.0` if variable is within given a range and `0.0` otherwise.
23**/
24
25#include "RooRangeBoolean.h"
26#include "RooAbsReal.h"
27
28////////////////////////////////////////////////////////////////////////////////
29
30RooRangeBoolean::RooRangeBoolean(const char* name, const char* title, RooAbsRealLValue& x, const char* rangeName) :
31 RooAbsReal(name, title),
32 _x("x", "Dependent", this, x),
33 _rangeName(rangeName)
34{
35}
36
37
38
39////////////////////////////////////////////////////////////////////////////////
40/// Copy constructor
41
44 _x("x", this, other._x),
45 _rangeName(other._rangeName)
46{
47}
48
49
50////////////////////////////////////////////////////////////////////////////////
51/// Return 1 if x is in range, zero otherwise.
52
54{
55 double xmin = (static_cast<RooAbsRealLValue const&>(_x.arg())).getMin(_rangeName.Data()) ;
56 double xmax = (static_cast<RooAbsRealLValue const&>(_x.arg())).getMax(_rangeName.Data()) ;
57
58 double ret = (_x >= xmin && _x < xmax) ? 1.0 : 0.0 ;
59 return ret ;
60}
61
62
63
64////////////////////////////////////////////////////////////////////////////////
65
66std::list<double>* RooRangeBoolean::plotSamplingHint(RooAbsRealLValue& obs, double /*xlo*/, double /*xhi*/) const
67{
68 if (std::string(obs.GetName())!=_x.arg().GetName()) {
69 return nullptr ;
70 }
71
72 std::list<double>* hint = new std::list<double> ;
73 hint->push_back((static_cast<RooAbsRealLValue const&>(_x.arg())).getMin(_rangeName.Data())-1e-6) ;
74 hint->push_back((static_cast<RooAbsRealLValue const&>(_x.arg())).getMin(_rangeName.Data())+1e-6) ;
75 hint->push_back((static_cast<RooAbsRealLValue const&>(_x.arg())).getMax(_rangeName.Data())-1e-6) ;
76 hint->push_back((static_cast<RooAbsRealLValue const&>(_x.arg())).getMax(_rangeName.Data())+1e-6) ;
77 return hint ;
78}
79
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:142
float xmin
float xmax
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
Returns 1.0 if variable is within given a range and 0.0 otherwise.
RooRealProxy _x
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
RooRangeBoolean()=default
double evaluate() const override
Return 1 if x is in range, zero otherwise.
const T & arg() const
Return reference to object held in proxy.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * Data() const
Definition TString.h:386
Double_t x[n]
Definition legend1.C:17