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 
22 RooConstVar represent a constant real-valued object
23 **/
24 
25 #include "RooConstVar.h"
26 #include "RunContext.h"
27 
28 using namespace std;
29 
31 
32 
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Constructor with value
36 RooConstVar::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
48 RooConstVar::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 
69 void RooConstVar::writeToStream(ostream& os, Bool_t /*compact*/) const
70 {
71  os << _value ;
72 }
73 
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooConstVar
RooConstVar represent a constant real-valued object.
Definition: RooConstVar.h:26
RooConstVar::RooConstVar
RooConstVar()
Definition: RooConstVar.h:29
RooAbsArg::_fast
Bool_t _fast
Definition: RooAbsArg.h:680
bool
RooConstVar::getValues
RooSpan< const double > getValues(RooBatchCompute::RunContext &evalData, const RooArgSet *) const
Return batch with 1 constant element.
Definition: RooConstVar.cxx:57
RooAbsReal::_value
Double_t _value
Definition: RooAbsReal.h:477
RooConstVar.h
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsArg::setAttribute
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
name
char name[80]
Definition: TGX11.cxx:110
RunContext.h
RooConstVar::writeToStream
void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream.
Definition: RooConstVar.cxx:69
RooBatchCompute::RunContext::spans
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
RooBatchCompute::RunContext
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31
RooSpan
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33