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