Logo ROOT   6.12/07
Reference Guide
RooFormula.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooFormula.h,v 1.34 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_FORMULA
17 #define ROO_FORMULA
18 
19 #include "Rtypes.h"
20 #include "v5/TFormula.h"
21 #include "RooAbsReal.h"
22 #include "RooArgSet.h"
23 #include "RooPrintable.h"
24 #include "RooLinkedList.h"
25 #include <vector>
26 
27 class RooFormula : public ROOT::v5::TFormula, public RooPrintable {
28 public:
29  // Constructors etc.
30  RooFormula() ;
31  RooFormula(const char* name, const char* formula, const RooArgList& varList);
32  RooFormula(const RooFormula& other, const char* name=0) ;
33  virtual TObject* Clone(const char* newName=0) const { return new RooFormula(*this,newName) ; }
34  virtual ~RooFormula();
35 
36  // Dependent management
37  RooArgSet& actualDependents() const ;
38  Bool_t changeDependents(const RooAbsCollection& newDeps, Bool_t mustReplaceAll, Bool_t nameChange) ;
39 
40  inline RooAbsArg* getParameter(const char* name) const {
41  // Return pointer to parameter with given name
42  return (RooAbsArg*) _useList.FindObject(name) ;
43  }
44  inline RooAbsArg* getParameter(Int_t index) const {
45  // Return pointer to parameter at given index
46  return (RooAbsArg*) _origList.At(index) ;
47  }
48 
49  // Function value accessor
50  inline Bool_t ok() { return _isOK ; }
51  Double_t eval(const RooArgSet* nset=0) ;
52 
53  // Debugging
54  void dump() ;
55  Bool_t reCompile(const char* newFormula) ;
56 
57 
58  virtual void printValue(std::ostream& os) const ;
59  virtual void printName(std::ostream& os) const ;
60  virtual void printTitle(std::ostream& os) const ;
61  virtual void printClassName(std::ostream& os) const ;
62  virtual void printArgs(std::ostream& os) const ;
63  void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
64 
65  inline virtual void Print(Option_t *options= 0) const {
66  // Printing interface (human readable)
68  }
69 
70 protected:
71 
72  RooFormula& operator=(const RooFormula& other) ;
73  void initCopy(const RooFormula& other) ;
74 
75  // Interface to ROOT::v5::TFormula engine
76  Int_t DefinedVariable(TString &name, int& action) ; // ROOT 4
77  Int_t DefinedVariable(TString &name) ; // ROOT 3
79 
81  mutable Bool_t _isOK ; // Is internal state OK?
82  RooLinkedList _origList ; //! Original list of dependents
83  std::vector<Bool_t> _useIsCat;//! Is given slot in _useList a category?
84  RooLinkedList _useList ; //! List of actual dependents
85  mutable RooArgSet _actual; //! Set of actual dependents
86  RooLinkedList _labelList ; // List of label names for category objects
87  mutable Bool_t _compiled ; // Flag set if formula is compiled
88 
89  ClassDef(RooFormula,1) // ROOT::v5::TFormula derived class interfacing with RooAbsArg objects
90 };
91 
92 #endif
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer, which is interpreted as an OR of &#39;enum ContentsOptions&#39; values and in the style given by &#39;enum StyleOption&#39;.
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
Definition: RooFormula.h:33
Bool_t ok()
Definition: RooFormula.h:50
RooLinkedList _origList
Definition: RooFormula.h:82
const char Option_t
Definition: RtypesCore.h:62
Bool_t reCompile(const char *newFormula)
Recompile formula with new expression.
Definition: RooFormula.cxx:111
RooFormula & operator=(const RooFormula &other)
RooArgSet * _nset
Definition: RooFormula.h:80
virtual void printName(std::ostream &os) const
Print name of formula.
Definition: RooFormula.cxx:435
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
RooAbsArg * getParameter(Int_t index) const
Definition: RooFormula.h:44
RooArgSet & actualDependents() const
Return list of RooAbsArg dependents that is actually used by formula expression.
Definition: RooFormula.cxx:142
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void printClassName(std::ostream &os) const
Print class name of formula.
Definition: RooFormula.cxx:453
RooPlotable is a &#39;mix-in&#39; base class that define the standard RooFit plotting and printing methods...
Definition: RooPrintable.h:25
Bool_t _compiled
Definition: RooFormula.h:87
Bool_t _isOK
Definition: RooFormula.h:81
RooLinkedList _labelList
Set of actual dependents.
Definition: RooFormula.h:86
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Printing interface.
Definition: RooFormula.cxx:414
std::vector< Bool_t > _useIsCat
Original list of dependents.
Definition: RooFormula.h:83
RooFormula an implementation of ROOT::v5::TFormula that interfaces it to RooAbsArg value objects...
Definition: RooFormula.h:27
Double_t eval(const RooArgSet *nset=0)
Evaluate ROOT::v5::TFormula using given normalization set to be used as observables definition passed...
Definition: RooFormula.cxx:234
Int_t DefinedVariable(TString &name, int &action)
Interface to ROOT::v5::TFormula.
Definition: RooFormula.cxx:295
RooLinkedList _useList
Is given slot in _useList a category?
Definition: RooFormula.h:84
Double_t DefinedValue(Int_t code)
Interface to ROOT::v5::TFormula, return value defined by object with id &#39;code&#39; Object ids are mapped ...
Definition: RooFormula.cxx:260
RooAbsArg * getParameter(const char *name) const
Definition: RooFormula.h:40
virtual void printArgs(std::ostream &os) const
Print arguments of formula, i.e. dependents that are actually used.
Definition: RooFormula.cxx:462
TObject * At(Int_t index) const
Return object stored in sequential position given by index.
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
const Bool_t kFALSE
Definition: RtypesCore.h:88
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
RooFormula()
Default constructor coverity[UNINIT_CTOR].
Definition: RooFormula.cxx:55
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
double Double_t
Definition: RtypesCore.h:55
The FORMULA class (ROOT version 5)
Definition: TFormula.h:65
void initCopy(const RooFormula &other)
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects...
virtual void printTitle(std::ostream &os) const
Print title of formula.
Definition: RooFormula.cxx:444
virtual ~RooFormula()
Destructor.
Definition: RooFormula.cxx:132
RooArgSet _actual
List of actual dependents.
Definition: RooFormula.h:85
Bool_t changeDependents(const RooAbsCollection &newDeps, Bool_t mustReplaceAll, Bool_t nameChange)
Change used variables to those with the same name in given list If mustReplaceAll is true and error i...
Definition: RooFormula.cxx:191
virtual void Print(Option_t *options=0) const
Dump this formula with its attributes.
Definition: RooFormula.h:65
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
void dump()
DEBUG: Dump state information.
Definition: RooFormula.cxx:166
char name[80]
Definition: TGX11.cxx:109
virtual void printValue(std::ostream &os) const
Print value of formula.
Definition: RooFormula.cxx:426