Logo ROOT   6.12/07
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 \file RooAbsHiddenReal.cxx
19 \class RooAbsHiddenReal
20 \ingroup Roofitcore
21 
22 RooAbsHiddenReal is a base class for objects that want to hide
23 their return value from interactive use, e.g. for implementations
24 of parameter unblinding functions. This class overrides all
25 printing methods with versions that do not reveal the objects value
26 and 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 "RooArgSet.h"
35 #include "RooAbsHiddenReal.h"
36 #include "RooCategory.h"
37 #include "RooMsgService.h"
38 
39 using namespace std;
40 
42 ;
43 
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 
102 Bool_t RooAbsHiddenReal::readFromStream(istream& is, Bool_t compact, Bool_t verbose)
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 
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
#define coutE(a)
Definition: RooMsgService.h:34
virtual ~RooAbsHiddenReal()
Destructor.
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.
Bool_t isHidden() const
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Special version of writeToStream that disallows reading from stream.
virtual void printValue(std::ostream &stream) const
Special version of printValue that doesn&#39;t reveal the objects value.
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Special version of readFromStream that disallows reading from stream.
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
#define ClassImp(name)
Definition: Rtypes.h:359
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
RooAbsHiddenReal is a base class for objects that want to hide their return value from interactive us...
RooCategoryProxy _state
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
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: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
RooAbsCategory & dummyBlindState() const
Return reference to internal dummy RooCategory implementation blinding state switch.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream (dummy for now)
Definition: RooAbsReal.cxx:403