Logo ROOT  
Reference Guide
RooConstVar.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 RooConstVar.cxx
19\class RooConstVar
20\ingroup Roofitcore
21
22RooConstVar represent a constant real-valued object
23**/
24
25#include "RooConstVar.h"
26#include "RunContext.h"
27
28using namespace std;
29
31
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// Constructor with value
36RooConstVar::RooConstVar(const char *name, const char *title, Double_t value) :
37 RooAbsReal(name,title)
38{
39 _fast = true;
40 _value = value;
41 setAttribute("Constant",kTRUE) ;
42}
43
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Copy constructor
48RooConstVar::RooConstVar(const RooConstVar& other, const char* name) :
49 RooAbsReal(other, name)
50{
51 _fast = true;
52}
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Return batch with 1 constant element.
58 auto item = evalData.spans.find(this);
59 if (item == evalData.spans.end()) {
60 return evalData.spans[this] = {&_value, 1};
61 }
62
63 return evalData.spans[this];
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Write object contents to stream
68
69void RooConstVar::writeToStream(ostream& os, Bool_t /*compact*/) const
70{
71 os << _value ;
72}
73
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
char name[80]
Definition: TGX11.cxx:110
Bool_t _fast
Definition: RooAbsArg.h:682
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:291
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
Double_t _value
Definition: RooAbsReal.h:477
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:35
RooConstVar represent a constant real-valued object.
Definition: RooConstVar.h:26
void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream.
Definition: RooConstVar.cxx:69
RooSpan< const double > getValues(RooBatchCompute::RunContext &evalData, const RooArgSet *) const
Return batch with 1 constant element.
Definition: RooConstVar.cxx:57
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31
std::unordered_map< const RooAbsReal *, RooSpan< const double > > spans
Once an object has computed its value(s), the span pointing to the results is registered here.
Definition: RunContext.h:52