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 std::ostream, std::istream, std::endl;
37
39
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor
45
46RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, const char* unit)
47 : RooAbsReal(name,title,unit),
48 _state("state","Blinding state",this,dummyBlindState())
49{
50}
51
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// Constructor
56
57RooAbsHiddenReal::RooAbsHiddenReal(const char *name, const char *title, RooAbsCategory& blindState, const char* unit)
58 : RooAbsReal(name,title,unit),
59 _state("state","Blinding state",this,blindState)
60{
61}
62
63
64
65////////////////////////////////////////////////////////////////////////////////
66/// Copy constructor
67
69 RooAbsReal(other, name),
70 _state("state",this,other._state)
71{
72}
73
74
75////////////////////////////////////////////////////////////////////////////////
76/// Special version of printValue that doesn't reveal the objects value
77
78void RooAbsHiddenReal::printValue(ostream& os) const
79{
80 os << "(hidden)" ;
81}
82
83
84
85////////////////////////////////////////////////////////////////////////////////
86/// Special version of readFromStream that disallows reading from stream
87
88bool RooAbsHiddenReal::readFromStream(istream& is, bool compact, bool verbose)
89{
90 if (isHidden()) {
91 // No-op version of readFromStream
92 coutE(InputArguments) << "RooAbsHiddenReal::readFromStream(" << GetName() << "): not allowed" << endl ;
93 return true ;
94 } else {
95 return readFromStream(is,compact,verbose) ;
96 }
97}
98
99
100
101////////////////////////////////////////////////////////////////////////////////
102/// Special version of writeToStream that disallows reading from stream
103
104void RooAbsHiddenReal::writeToStream(ostream& os, bool compact) const
105{
106 if (isHidden()) {
107 // No-op version of writeToStream
108 coutE(InputArguments) << "RooAbsHiddenReal::writeToStream(" << GetName() << "): not allowed" << endl ;
109 } else {
110 RooAbsReal::writeToStream(os,compact) ;
111 }
112}
113
114
115
116////////////////////////////////////////////////////////////////////////////////
117/// Return reference to internal dummy RooCategory implementation
118/// blinding state switch
119
121{
122 if (!_dummyBlindState) {
123 _dummyBlindState = new RooCategory("dummyBlindState","dummy blinding state") ;
124 _dummyBlindState->defineType("Normal",0) ;
125 _dummyBlindState->defineType("Blind",1) ;
127 }
128 return *_dummyBlindState ;
129}
130
131
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:382
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.
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