Logo ROOT  
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 "RooAbsHiddenReal.h"
35 #include "RooCategory.h"
36 #include "RooMsgService.h"
37 
38 using namespace std;
39 
41 ;
42 
44 
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Constructor
48 
49 RooAbsHiddenReal::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 
60 RooAbsHiddenReal::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 
91 void 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 
117 void 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 
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooMsgService.h
RooFit.h
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:68
RooArgSet.h
RooAbsReal::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream (dummy for now)
Definition: RooAbsReal.cxx:457
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
RooAbsHiddenReal::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Special version of readFromStream that disallows reading from stream.
Definition: RooAbsHiddenReal.cxx:101
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooCategory::setIndex
virtual Bool_t setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
Definition: RooCategory.cxx:163
RooAbsReal
Definition: RooAbsReal.h:61
RooCategory::defineType
bool defineType(const std::string &label)
Define a state with given name.
Definition: RooCategory.cxx:208
bool
RooAbsCategory
Definition: RooAbsCategory.h:38
RooAbsHiddenReal::dummyBlindState
RooAbsCategory & dummyBlindState() const
Return reference to internal dummy RooCategory implementation blinding state switch.
Definition: RooAbsHiddenReal.cxx:133
RooAbsHiddenReal::_dummyBlindState
static RooCategory * _dummyBlindState
Definition: RooAbsHiddenReal.h:63
RooCategory.h
RooAbsHiddenReal
Definition: RooAbsHiddenReal.h:25
RooAbsHiddenReal::RooAbsHiddenReal
RooAbsHiddenReal()
Definition: RooAbsHiddenReal.h:28
RooAbsHiddenReal::isHidden
Bool_t isHidden() const
Definition: RooAbsHiddenReal.h:43
RooAbsHiddenReal::~RooAbsHiddenReal
virtual ~RooAbsHiddenReal()
Destructor.
Definition: RooAbsHiddenReal.cxx:82
RooAbsHiddenReal::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Special version of writeToStream that disallows reading from stream.
Definition: RooAbsHiddenReal.cxx:117
RooCategory
Definition: RooCategory.h:27
name
char name[80]
Definition: TGX11.cxx:110
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
RooAbsHiddenReal::printValue
virtual void printValue(std::ostream &stream) const
Special version of printValue that doesn't reveal the objects value.
Definition: RooAbsHiddenReal.cxx:91
Riostream.h
RooAbsHiddenReal.h