Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooStringVar.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooStringVar.h,v 1.23 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_STRING_VAR
17#define ROO_STRING_VAR
18
19#include "RooAbsArg.h"
20
21#include <string>
22
23class RooStringVar final : public RooAbsArg {
24public:
25 // Constructors, assignment etc.
27 RooStringVar(const char *name, const char *title, const char* value, Int_t size=1024) ;
28 RooStringVar(const RooStringVar& other, const char* name=nullptr);
29 TObject* clone(const char* newname) const override { return new RooStringVar(*this,newname); }
30
31 // Parameter value and error accessors
32 virtual operator TString() {return TString(_string.c_str()); }
33 const char* getVal() const { clearValueDirty(); return _string.c_str(); }
34 void setVal(const char* newVal) { _string = newVal ? newVal : ""; setValueDirty(); }
35 virtual RooAbsArg& operator=(const char* newVal) { setVal(newVal); return *this; }
36
37 // We implement a fundamental type of AbsArg that can be stored in a dataset
38 bool isFundamental() const override { return true; }
39
40 // I/O streaming interface (machine readable)
41 bool readFromStream(std::istream& is, bool compact, bool verbose) override;
42 void writeToStream(std::ostream& os, bool /*compact*/) const override { os << _string; }
43
44 // Return value and unit accessors
45 bool operator==(const char* val) const { return _string == val; }
46 bool operator==(const RooAbsArg& other) const override {
47 auto otherStr = dynamic_cast<const RooStringVar*>(&other);
48 return otherStr && _string == otherStr->_string;
49 }
50 bool isIdentical(const RooAbsArg& other, bool /*assumeSameType*/) const override { return *this == other; }
51
52 // Printing interface (human readable)
53 void printValue(std::ostream& os) const override { os << _string; }
54
55
56 RooFit::OwningPtr<RooAbsArg> createFundamental(const char *newname = nullptr) const override
57 {
58 return RooFit::makeOwningPtr<RooAbsArg>(
59 std::make_unique<RooStringVar>(newname ? newname : GetName(), GetTitle(), "", 1));
60 }
61
62protected:
63 // Internal consistency checking (needed by RooDataSet)
64 bool isValid() const override { return true; }
65 virtual bool isValidString(const char*, bool /*printError=false*/) const { return true; }
66
67 void syncCache(const RooArgSet* /*nset*/ = nullptr) override { }
68 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDiry=true) override;
69 void attachToTree(TTree& t, Int_t bufSize=32000) override;
71 void fillTreeBranch(TTree& t) override;
72 void setTreeBranchStatus(TTree& t, bool active) override;
73
74private:
75 std::string _string;
76 std::string* _stringAddr; //! Required to connect to TTree branch
77 ClassDefOverride(RooStringVar,2) // String-valued variable
78};
79
80#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
void clearValueDirty() const
Definition RooAbsArg.h:576
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition RooAbsArg.h:462
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
A RooAbsArg implementing string values.
void printValue(std::ostream &os) const override
Interface to print value of object.
void syncCache(const RooArgSet *=nullptr) override
void writeToStream(std::ostream &os, bool) const override
void setTreeBranchStatus(TTree &t, bool active) override
(De)Activate associated tree branch
bool isValid() const override
WVE (08/21/01) Probably obsolete now.
void setVal(const char *newVal)
virtual RooAbsArg & operator=(const char *newVal)
const char * getVal() const
std::string * _stringAddr
void attachToTree(TTree &t, Int_t bufSize=32000) override
Attach object to a branch of given TTree.
bool operator==(const char *val) const
RooFit::OwningPtr< RooAbsArg > createFundamental(const char *newname=nullptr) const override
Create a fundamental-type object that stores our type of value.
bool operator==(const RooAbsArg &other) const override
TObject * clone(const char *newname) const override
bool isFundamental() const override
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDiry=true) override
Copy cache of another RooAbsArg to our cache.
bool readFromStream(std::istream &is, bool compact, bool verbose) override
Read object contents from given stream.
bool isIdentical(const RooAbsArg &other, bool) const override
virtual bool isValidString(const char *, bool) const
void fillTreeBranch(TTree &t) override
Fill tree branch associated with this object.
std::string _string
void attachToVStore(RooVectorDataStore &) override
Uses std::vector to store data columns.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
A TTree represents a columnar dataset.
Definition TTree.h:79
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35