Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooConstVar.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooConstVar.h,v 1.9 2007/05/11 09:11:30 verkerke Exp $
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#ifndef ROO_CONST_VAR
17#define ROO_CONST_VAR
18
19#include "RooAbsReal.h"
20
21class RooArgSet ;
22
23class RooConstVar final : public RooAbsReal {
24public:
25 // Constructors, assignment etc
27 RooConstVar(const char *name, const char *title, double value);
28 RooConstVar(const RooConstVar& other, const char* name=nullptr);
29 TObject* clone(const char* newname) const override { return new RooConstVar(*this,newname); }
30 ~RooConstVar() override = default;
31
32 /// Return (constant) value.
33 double getValV(const RooArgSet*) const override {
34 return _value;
35 }
36
37 void writeToStream(std::ostream& os, bool compact) const override ;
38
39 /// Returns false, as the value of the constant doesn't depend on other objects.
40 bool isDerived() const override {
41 return false;
42 }
43
44 /// Change the value of this constant.
45 /// On purpose, this is not `setVal`, as this could be confused with the `setVal`
46 /// that is available for variables. Constants, however, should remain mostly constant.
47 /// This function is e.g. useful when reading the constant from a file.
48 void changeVal(double value) {
49 _value = value;
50 }
51
52 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
53
54protected:
55
56 double evaluate() const override {
57 return _value;
58 }
59
60 ClassDefOverride(RooConstVar,2) // Constant RooAbsReal value object
61};
62
63#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double _value
Cache for current value of object.
Definition RooAbsReal.h:543
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooConstVar represent a constant real-valued object.
Definition RooConstVar.h:23
bool isDerived() const override
Returns false, as the value of the constant doesn't depend on other objects.
Definition RooConstVar.h:40
~RooConstVar() override=default
double getValV(const RooArgSet *) const override
Return (constant) value.
Definition RooConstVar.h:33
TObject * clone(const char *newname) const override
Definition RooConstVar.h:29
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to stream.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition RooConstVar.h:56
void changeVal(double value)
Change the value of this constant.
Definition RooConstVar.h:48
A class to maintain the context for squashing of RooFit models into code.
Mother of all ROOT objects.
Definition TObject.h:41