Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsHiddenReal.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 RooAbsHiddenReal.cxx
19\class RooAbsHiddenReal
20\ingroup Roofitcore
21
22Base class for objects that want to hide
23their return value from interactive use, e.g. for implementations
24of parameter unblinding functions. This class overrides all
25printing methods with versions that do not reveal the objects value
26and it has a protected version of getVal()
27**/
28
29#include "Riostream.h"
30
31#include "RooArgSet.h"
32#include "RooAbsHiddenReal.h"
33#include "RooCategory.h"
34#include "RooMsgService.h"
35
36using namespace std;
37
39;
40
42
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor
46
47RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, const char* unit)
48 : RooAbsReal(name,title,unit),
49 _state("state","Blinding state",this,dummyBlindState())
50{
51}
52
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Constructor
57
58RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, RooAbsCategory& blindState, const char* unit)
59 : RooAbsReal(name,title,unit),
60 _state("state","Blinding state",this,blindState)
61{
62}
63
64
65
66////////////////////////////////////////////////////////////////////////////////
67/// Copy constructor
68
70 RooAbsReal(other, name),
71 _state("state",this,other._state)
72{
73}
74
75
76
77////////////////////////////////////////////////////////////////////////////////
78/// Destructor
79
81{
82}
83
84
85
86////////////////////////////////////////////////////////////////////////////////
87/// Special version of printValue that doesn't reveal the objects value
88
89void RooAbsHiddenReal::printValue(ostream& os) const
90{
91 os << "(hidden)" ;
92}
93
94
95
96////////////////////////////////////////////////////////////////////////////////
97/// Special version of readFromStream that disallows reading from stream
98
99bool RooAbsHiddenReal::readFromStream(istream& is, bool compact, bool verbose)
100{
101 if (isHidden()) {
102 // No-op version of readFromStream
103 coutE(InputArguments) << "RooAbsHiddenReal::readFromStream(" << GetName() << "): not allowed" << endl ;
104 return true ;
105 } else {
106 return readFromStream(is,compact,verbose) ;
107 }
108}
109
110
111
112////////////////////////////////////////////////////////////////////////////////
113/// Special version of writeToStream that disallows reading from stream
114
115void RooAbsHiddenReal::writeToStream(ostream& os, bool compact) const
116{
117 if (isHidden()) {
118 // No-op version of writeToStream
119 coutE(InputArguments) << "RooAbsHiddenReal::writeToStream(" << GetName() << "): not allowed" << endl ;
120 } else {
121 RooAbsReal::writeToStream(os,compact) ;
122 }
123}
124
125
126
127////////////////////////////////////////////////////////////////////////////////
128/// Return reference to internal dummy RooCategory implementation
129/// blinding state switch
130
132{
133 if (!_dummyBlindState) {
134 _dummyBlindState = new RooCategory("dummyBlindState","dummy blinding state") ;
135 _dummyBlindState->defineType("Normal",0) ;
136 _dummyBlindState->defineType("Blind",1) ;
138 }
139 return *_dummyBlindState ;
140}
141
142
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:377
char name[80]
Definition TGX11.cxx:110
A space to attach TBranches.
Base class for objects that want to hide their return value from interactive use, e....
RooAbsCategory & dummyBlindState() const
Return reference to internal dummy RooCategory implementation blinding state switch.
void writeToStream(std::ostream &os, bool compact) const override
Special version of writeToStream that disallows reading from stream.
static RooCategory * _dummyBlindState
bool isHidden() const
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Special version of readFromStream that disallows reading from stream.
~RooAbsHiddenReal() override
Destructor.
void printValue(std::ostream &stream) const override
Special version of printValue that doesn't reveal the objects value.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to stream (dummy for now)
Object to represent discrete states.
Definition RooCategory.h:28
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
bool defineType(const std::string &label)
Define a state with given name.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47