Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
41 ClassImp(RooAbsHiddenReal);
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 
72 RooAbsHiddenReal::RooAbsHiddenReal(const RooAbsHiddenReal& other, const char* name) :
73  RooAbsReal(other, name),
74  _state("state",this,other._state)
75 {
76 }
77 
78 
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Destructor
82 
83 RooAbsHiddenReal::~RooAbsHiddenReal()
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 
134 RooAbsCategory& RooAbsHiddenReal::dummyBlindState() const
135 {
136  if (!_dummyBlindState) {
137  _dummyBlindState = new RooCategory("dummyBlindState","dummy blinding state") ;
138  _dummyBlindState->defineType("Normal",0) ;
139  _dummyBlindState->defineType("Blind",1) ;
140  _dummyBlindState->setIndex(1) ;
141  }
142  return *_dummyBlindState ;
143 }
144 
145