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
22RooAbsHiddenReal is a base 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 "RooFit.h"
30
31#include "Riostream.h"
32
33#include "RooArgSet.h"
34#include "RooAbsHiddenReal.h"
35#include "RooCategory.h"
36#include "RooMsgService.h"
37
38using namespace std;
39
41;
42
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Constructor
48
49RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, const char* unit)
50 : RooAbsReal(name,title,unit),
51 _state("state","Blinding state",this,dummyBlindState())
52{
53}
54
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Constructor
59
60RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, RooAbsCategory& blindState, const char* unit)
61 : RooAbsReal(name,title,unit),
62 _state("state","Blinding state",this,blindState)
63{
64}
65
66
67
68////////////////////////////////////////////////////////////////////////////////
69/// Copy constructor
70
72 RooAbsReal(other, name),
73 _state("state",this,other._state)
74{
75}
76
77
78
79////////////////////////////////////////////////////////////////////////////////
80/// Destructor
81
83{
84}
85
86
87
88////////////////////////////////////////////////////////////////////////////////
89/// Special version of printValue that doesn't reveal the objects value
90
91void RooAbsHiddenReal::printValue(ostream& os) const
92{
93 os << "(hidden)" ;
94}
95
96
97
98////////////////////////////////////////////////////////////////////////////////
99/// Special version of readFromStream that disallows reading from stream
100
102{
103 if (isHidden()) {
104 // No-op version of readFromStream
105 coutE(InputArguments) << "RooAbsHiddenReal::readFromStream(" << GetName() << "): not allowed" << endl ;
106 return kTRUE ;
107 } else {
108 return readFromStream(is,compact,verbose) ;
109 }
110}
111
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Special version of writeToStream that disallows reading from stream
116
117void RooAbsHiddenReal::writeToStream(ostream& os, Bool_t compact) const
118{
119 if (isHidden()) {
120 // No-op version of writeToStream
121 coutE(InputArguments) << "RooAbsHiddenReal::writeToStream(" << GetName() << "): not allowed" << endl ;
122 } else {
123 RooAbsReal::writeToStream(os,compact) ;
124 }
125}
126
127
128
129////////////////////////////////////////////////////////////////////////////////
130/// Return reference to internal dummy RooCategory implementation
131/// blinding state switch
132
134{
135 if (!_dummyBlindState) {
136 _dummyBlindState = new RooCategory("dummyBlindState","dummy blinding state") ;
137 _dummyBlindState->defineType("Normal",0) ;
138 _dummyBlindState->defineType("Blind",1) ;
140 }
141 return *_dummyBlindState ;
142}
143
144
#define coutE(a)
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
RooAbsHiddenReal is a base class for objects that want to hide their return value from interactive us...
RooAbsCategory & dummyBlindState() const
Return reference to internal dummy RooCategory implementation blinding state switch.
virtual void printValue(std::ostream &stream) const
Special version of printValue that doesn't reveal the objects value.
virtual ~RooAbsHiddenReal()
Destructor.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Special version of writeToStream that disallows reading from stream.
Bool_t isHidden() const
static RooCategory * _dummyBlindState
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Special version of readFromStream that disallows reading from stream.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:61
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream (dummy for now)
RooCategory is an object to represent discrete states.
Definition RooCategory.h:27
bool defineType(const std::string &label)
Define a state with given name.
virtual Bool_t setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47