Logo ROOT   6.14/05
Reference Guide
RooAbsCategory.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 RooAbsCategory.cxx
19 \class RooAbsCategory
20 \ingroup Roofitcore
21 
22 RooAbsCategory is the common abstract base class for objects that
23 represent a discrete value with a finite number of states. Each
24 state consist of a label/index pair, which is stored in a
25 RooCatType object.
26 
27 Implementation of RooAbsCategory may be derived, there no interface
28 is provided to modify the contents, nor a public interface to define states.
29 **/
30 
31 #include "RooFit.h"
32 
33 #include "Riostream.h"
34 #include "Riostream.h"
35 #include <stdlib.h>
36 #include "TString.h"
37 #include "TH1.h"
38 #include "TTree.h"
39 #include "TLeaf.h"
40 #include "RooAbsCategory.h"
41 #include "RooArgSet.h"
42 #include "Roo1DTable.h"
43 #include "RooCategory.h"
44 #include "RooMsgService.h"
45 #include "RooVectorDataStore.h"
46 
47 using namespace std;
48 
50 ;
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Constructor
55 
56 RooAbsCategory::RooAbsCategory(const char *name, const char *title) :
57  RooAbsArg(name,title), _value("NULL",0), _treeVar(kFALSE)
58 {
60  setValueDirty() ;
61  setShapeDirty() ;
62 }
63 
64 
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Copy constructor, copies the registered category states from the original.
68 
70  RooAbsArg(other,name), _value(other._value), _treeVar(other._treeVar)
71 {
73 
74  other._typeIter->Reset() ;
75  TObject* obj ;
76  while ((obj=other._typeIter->Next())) {
77  _types.Add(obj->Clone()) ;
78  }
79 
80  setValueDirty() ;
81  setShapeDirty() ;
82 }
83 
84 
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Destructor
88 
90 {
91  // We own the contents of _types
92  delete _typeIter ;
93  _types.Delete() ;
94 }
95 
96 
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Return index number of current state
100 
102 {
103  if (isValueDirty() || isShapeDirty()) {
104  _value = traceEval() ;
105 
106  clearValueDirty() ;
107  clearShapeDirty() ;
108  }
109 
110  return _value.getVal() ;
111 }
112 
113 
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Return label string of current state
117 
118 const char* RooAbsCategory::getLabel() const
119 {
120  if (isValueDirty() || isShapeDirty()) {
121  _value = traceEval() ;
122 
123  clearValueDirty() ;
124  clearShapeDirty() ;
125  }
126 
127  const char* ret = _value.GetName() ;
128  // If label is not set, do it now on the fly
129  if (ret==0) {
131  }
132  return _value.GetName() ;
133 }
134 
135 
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Recalculate current value and check validity of new result.
139 
141 {
142  RooCatType value = evaluate() ;
143 
144  // Standard tracing code goes here
145  if (!isValid(value)) {
146  }
147 
148  // Call optional subclass tracing code
149  traceEvalHook(value) ;
150 
151  return value ;
152 }
153 
154 
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// Return iterator over all defined states
158 
160 {
161  return _types.MakeIterator() ;
162 }
163 
164 
165 ////////////////////////////////////////////////////////////////////////////////
166 /// Equality operator with a integer (compares with state index number)
167 
169 {
170  return (index==getIndex()) ;
171 }
172 
173 
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 /// Equality operator with a string (compares with state label string)
177 
178 Bool_t RooAbsCategory::operator==(const char* label) const
179 {
180  return !TString(label).CompareTo(getLabel()) ;
181 }
182 
183 
184 
185 ////////////////////////////////////////////////////////////////////////////////
186 /// Equality operator with another RooAbsArg. Only functional
187 /// is also a RooAbsCategory, will return true if index is the same
188 
190 {
191  const RooAbsCategory* otherCat = dynamic_cast<const RooAbsCategory*>(&other) ;
192  return otherCat ? operator==(otherCat->getIndex()) : kFALSE ;
193 }
194 
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 
198 Bool_t RooAbsCategory::isIdentical(const RooAbsArg& other, Bool_t assumeSameType)
199 {
200  if (!assumeSameType) {
201  const RooAbsCategory* otherCat = dynamic_cast<const RooAbsCategory*>(&other) ;
202  return otherCat ? operator==(otherCat->getIndex()) : kFALSE ;
203  } else {
204  return getIndex()==((RooAbsCategory&)other).getIndex() ;
205  }
206 }
207 
208 
209 
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Check if state with given index is defined
213 
215 {
216  return lookupType(index,kFALSE)?kTRUE:kFALSE ;
217 }
218 
219 
220 
221 ////////////////////////////////////////////////////////////////////////////////
222 /// Check if state with given name is defined
223 
224 Bool_t RooAbsCategory::isValidLabel(const char* label) const
225 {
226  return lookupType(label)?kTRUE:kFALSE ;
227 }
228 
229 
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// Define a new state with given name. The lowest available
233 /// integer number is assigned as index value
234 
235 const RooCatType* RooAbsCategory::defineType(const char* label)
236 {
237  // Find lowest unused index
238  Int_t index(-1) ;
239  while(lookupType(++index,kFALSE)) ;
240 
241  // Assign this index to given label
242  return defineType(label,index) ;
243 }
244 
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Internal version of defineType that does not check if type
248 /// already exists
249 
250 const RooCatType* RooAbsCategory::defineTypeUnchecked(const char* label, Int_t index)
251 {
253  RooCatType *newType = new RooCatType(label,index) ;
254  _types.Add(newType) ;
255 
256  if (first) _value = RooCatType(label,index) ;
257  setShapeDirty() ;
258 
259  return newType ;
260 }
261 
262 
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 /// Define new state with given name and index number.
266 
267 const RooCatType* RooAbsCategory::defineType(const char* label, Int_t index)
268 {
269  if (isValidIndex(index)) {
270  coutE(InputArguments) << "RooAbsCategory::defineType(" << GetName() << "): index "
271  << index << " already assigned" << endl ;
272  return 0 ;
273  }
274 
275  if (isValidLabel(label)) {
276  coutE(InputArguments) << "RooAbsCategory::defineType(" << GetName() << "): label "
277  << label << " already assigned or not allowed" << endl ;
278  return 0 ;
279  }
280 
281  return defineTypeUnchecked(label,index) ;
282 }
283 
284 
285 
286 ////////////////////////////////////////////////////////////////////////////////
287 /// Delete all currently defined states
288 
290 {
291  _types.Delete() ;
292  _value = RooCatType("",0) ;
293  setShapeDirty() ;
294 }
295 
296 
297 
298 ////////////////////////////////////////////////////////////////////////////////
299 /// Find our type that matches the specified type, or return 0 for no match.
300 
301 const RooCatType* RooAbsCategory::lookupType(const RooCatType &other, Bool_t printError) const
302 {
303  RooCatType* type ;
304  _typeIter->Reset() ;
305  while((type=(RooCatType*)_typeIter->Next())){
306  if((*type) == other) return type; // delegate comparison to RooCatType
307  }
308 
309  if (printError) {
310  coutE(InputArguments) << ClassName() << "::" << GetName() << ":lookupType: no match for ";
311  if (dologE(InputArguments)) {
313  }
314  }
315  return 0 ;
316 }
317 
318 
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Find our type corresponding to the specified index, or return 0 for no match.
322 
323 const RooCatType* RooAbsCategory::lookupType(Int_t index, Bool_t printError) const
324 {
325  RooCatType* type ;
326  _typeIter->Reset() ;
327  while((type=(RooCatType*)_typeIter->Next())){
328  if((*type) == index) return type; // delegate comparison to RooCatType
329  }
330  if (printError) {
331  coutE(InputArguments) << ClassName() << "::" << GetName() << ":lookupType: no match for index "
332  << index << endl;
333  }
334  return 0 ;
335 }
336 
337 
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 /// Find our type corresponding to the specified label, or return 0 for no match.
341 
342 const RooCatType* RooAbsCategory::lookupType(const char* label, Bool_t printError) const
343 {
344  RooCatType* type ;
345  _typeIter->Reset() ;
346  while((type=(RooCatType*)_typeIter->Next())){
347  if((*type) == label) return type; // delegate comparison to RooCatType
348  }
349 
350  // Try if label represents integer number
351  char* endptr ;
352  Int_t idx=strtol(label,&endptr,10) ;
353  if (endptr==label+strlen(label)) {
354  _typeIter->Reset() ;
355  while((type=(RooCatType*)_typeIter->Next())){
356  if((*type) == idx) return type; // delegate comparison to RooCatType
357  }
358  }
359 
360  if (printError) {
361  coutE(InputArguments) << ClassName() << "::" << GetName() << ":lookupType: no match for label "
362  << label << endl;
363  }
364  return 0 ;
365 }
366 
367 
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Check if current value is a valid state
371 
373 {
374  return isValid(_value) ;
375 }
376 
377 
378 
379 ////////////////////////////////////////////////////////////////////////////////
380 /// Check if given state is defined for this object
381 
383 {
384  return isValidIndex(value.getVal()) ;
385 }
386 
387 
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 /// Create a table matching the shape of this category
391 
392 Roo1DTable* RooAbsCategory::createTable(const char *label) const
393 {
394  return new Roo1DTable(GetName(),label,*this) ;
395 }
396 
397 
398 
399 ////////////////////////////////////////////////////////////////////////////////
400 /// Read object contents from stream (dummy for now)
401 
403 {
404  return kFALSE ;
405 }
406 
407 
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// Write object contents to ostream
411 
412 void RooAbsCategory::writeToStream(ostream& os, Bool_t compact) const
413 {
414  if (compact) {
415  os << getLabel() ;
416  } else {
417  os << getLabel() ;
418  }
419 }
420 
421 
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 /// Print value (label name)
425 
426 void RooAbsCategory::printValue(ostream& os) const
427 {
428  os << getLabel() << "(idx = " << getIndex() << ")" << endl ;
429 }
430 
431 
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Print info about this object to the specified stream. In addition to the info
435 /// from RooAbsArg::printStream() we add:
436 ///
437 /// Shape : label, index, defined types
438 
439 void RooAbsCategory::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
440 {
441  RooAbsArg::printMultiline(os,contents,verbose,indent);
442 
443  os << indent << "--- RooAbsCategory ---" << endl;
444  if (_types.GetEntries()==0) {
445  os << indent << " ** No values defined **" << endl;
446  return;
447  }
448  os << indent << " Value is \"" << getLabel() << "\" (" << getIndex() << ")" << endl;
449  os << indent << " Has the following possible values:" << endl;
450  indent.Append(" ");
451  RooCatType *type;
452  _typeIter->Reset() ;
453  while((type=(RooCatType*)_typeIter->Next())) {
454  os << indent;
455  type->printStream(os,kName|kValue,kSingleLine,indent);
456  }
457 }
458 
459 
460 
461 ////////////////////////////////////////////////////////////////////////////////
462 /// Attach the category index and label to as branches to the given vector store
463 
465 {
466  RooVectorDataStore::CatVector* cv = vstore.addCategory(this) ;
467  cv->setBuffer(&_value) ;
468 }
469 
470 
471 
472 
473 ////////////////////////////////////////////////////////////////////////////////
474 /// Attach the category index and label to as branches to the given
475 /// TTree. The index field will be attached as integer with name
476 /// <name>_idx, the label field will be attached as char[] with label
477 /// <name>_lbl.
478 
479 void RooAbsCategory::attachToTree(TTree& t, Int_t bufSize)
480 {
481  // First check if there is an integer branch matching the category name
482  TString cleanName(cleanBranchName()) ;
483  TBranch* branch = t.GetBranch(cleanName) ;
484  if (branch) {
485 
486  TString typeName(((TLeaf*)branch->GetListOfLeaves()->At(0))->GetTypeName()) ;
487  if (!typeName.CompareTo("Int_t")) {
488  // Imported TTree: attach only index field as branch
489 
490  coutI(DataHandling) << "RooAbsCategory::attachToTree(" << GetName() << ") TTree branch " << GetName()
491  << " will be interpreted as category index" << endl ;
492 
493  t.SetBranchAddress(cleanName,&((Int_t&)_value._value)) ;
494  setAttribute("INTIDXONLY_TREE_BRANCH",kTRUE) ;
495  _treeVar = kTRUE ;
496  return ;
497  } else if (!typeName.CompareTo("UChar_t")) {
498  coutI(DataHandling) << "RooAbsReal::attachToTree(" << GetName() << ") TTree UChar_t branch " << GetName()
499  << " will be interpreted as category index" << endl ;
500  t.SetBranchAddress(cleanName,&_byteValue) ;
501  setAttribute("UCHARIDXONLY_TREE_BRANCH",kTRUE) ;
502  _treeVar = kTRUE ;
503  return ;
504  }
505 
506  if (branch->GetCompressionLevel()<0) {
507  cxcoutD(DataHandling) << "RooAbsCategory::attachToTree(" << GetName() << ") Fixing compression level of branch " << GetName() << endl ;
508  branch->SetCompressionLevel(1) ;
509  }
510  }
511 
512  // Native TTree: attach both index and label of category as branches
513  TString idxName(cleanName) ;
514  TString lblName(cleanName) ;
515  idxName.Append("_idx") ;
516  lblName.Append("_lbl") ;
517 
518  // First determine if branch is taken
519  if ((branch = t.GetBranch(idxName))) {
520 
521  t.SetBranchAddress(idxName,&((Int_t&)_value._value)) ;
522  if (branch->GetCompressionLevel()<0) {
523  cxcoutD(Contents) << "RooAbsCategory::attachToTree(" << GetName() << ") Fixing compression level of branch " << idxName << endl ;
524  branch->SetCompressionLevel(1) ;
525  }
526 
527  } else {
528  TString format(idxName);
529  format.Append("/I");
530  void* ptr = &(_value._value) ;
531  branch = t.Branch(idxName, ptr, (const Text_t*)format, bufSize);
532  branch->SetCompressionLevel(1) ;
533  }
534 
535  // First determine if branch is taken
536  if ((branch = t.GetBranch(lblName))) {
537 
538  t.SetBranchAddress(lblName,_value._label) ;
539  if (branch->GetCompressionLevel()<0) {
540  cxcoutD(DataHandling) << "RooAbsCategory::attachToTree(" << GetName() << ") Fixing compression level of branch " << lblName << endl ;
541  branch->SetCompressionLevel(1) ;
542  }
543 
544  } else {
545  TString format(lblName);
546  format.Append("/C");
547  void* ptr = _value._label ;
548  branch = t.Branch(lblName, ptr, (const Text_t*)format, bufSize);
549  branch->SetCompressionLevel(1) ;
550  }
551 
552 }
553 
554 
555 
556 ////////////////////////////////////////////////////////////////////////////////
557 /// Fill tree branches associated with current object with current value
558 
560 {
561  TString idxName(GetName()) ;
562  TString lblName(GetName()) ;
563  idxName.Append("_idx") ;
564  lblName.Append("_lbl") ;
565 
566  // First determine if branch is taken
567  TBranch* idxBranch = t.GetBranch(idxName) ;
568  TBranch* lblBranch = t.GetBranch(lblName) ;
569  if (!idxBranch||!lblBranch) {
570  coutF(DataHandling) << "RooAbsCategory::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree" << endl ;
571  assert(0) ;
572  }
573 
574  idxBranch->Fill() ;
575  lblBranch->Fill() ;
576 }
577 
578 
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// (De)activate associate tree branch
582 
584 {
585  TBranch* branch = t.GetBranch(Form("%s_idx",GetName())) ;
586  if (branch) {
587  t.SetBranchStatus(Form("%s_idx",GetName()),active?1:0) ;
588  t.SetBranchStatus(Form("%s_lbl",GetName()),active?1:0) ;
589  }
590 }
591 
592 
593 
594 ////////////////////////////////////////////////////////////////////////////////
595 /// Explicitly synchronize RooAbsCategory internal cache
596 
598 {
599  getIndex() ;
600 }
601 
602 
603 
604 ////////////////////////////////////////////////////////////////////////////////
605 /// Copy the cached value from given source and raise dirty flag.
606 /// It is the callers responsability to ensure that the sources
607 /// cache is clean(valid) before this function is called, e.g. by
608 /// calling syncCache() on the source.
609 
610 void RooAbsCategory::copyCache(const RooAbsArg* source, Bool_t /*valueOnly*/, Bool_t setValDirty)
611 {
612  RooAbsCategory* other = static_cast<RooAbsCategory*>(const_cast<RooAbsArg*>(source)) ;
613 
614  if (!_treeVar) {
615  _value = other->_value ;
616  } else {
617  if (source->getAttribute("INTIDXONLY_TREE_BRANCH")) {
618  // Lookup cat state from other-index because label is missing
619  const RooCatType* type = lookupType(other->_value._value) ;
620  if (type) {
621  _value = *type ;
622  } else {
623  coutE(DataHandling) << "RooAbsCategory::copyCache(" << GetName()
624  << ") ERROR: index of source arg " << source->GetName()
625  << " is invalid (" << other->_value._value
626  << "), value not updated" << endl ;
627  }
628  } if (source->getAttribute("UCHARIDXONLY_TREE_BRANCH")) {
629  // Lookup cat state from other-index because label is missing
630  Int_t tmp = other->_byteValue ;
631  const RooCatType* type = lookupType(tmp) ;
632  if (type) {
633  _value = *type ;
634  } else {
635  coutE(DataHandling) << "RooAbsCategory::copyCache(" << GetName()
636  << ") ERROR: index of source arg " << source->GetName()
637  << " is invalid (" << tmp
638  << "), value not updated" << endl ;
639  }
640  }
641  }
642 
643  if (setValDirty) {
644  setValueDirty() ;
645  }
646 }
647 
648 
649 
650 ////////////////////////////////////////////////////////////////////////////////
651 /// Return state definition of ordinal nth defined state,
652 /// needed by the generator mechanism.
653 
654 const RooCatType* RooAbsCategory::getOrdinal(UInt_t n, const char* /*rangeName*/) const
655 {
656  return (const RooCatType*)_types.At(n);
657 }
658 
659 
660 
661 ////////////////////////////////////////////////////////////////////////////////
662 /// Create a RooCategory fundamental object with our properties.
663 
664 RooAbsArg *RooAbsCategory::createFundamental(const char* newname) const
665 {
666  // Add and precalculate new category column
667  RooCategory *fund= new RooCategory(newname?newname:GetName(),GetTitle()) ;
668 
669  // Copy states
670  TIterator* tIter = typeIterator() ;
671  RooCatType* type ;
672  while ((type=(RooCatType*)tIter->Next())) {
673  ((RooAbsCategory*)fund)->defineType(type->GetName(),type->getVal()) ;
674  }
675  delete tIter;
676 
677  return fund;
678 }
679 
680 
681 
682 ////////////////////////////////////////////////////////////////////////////////
683 /// Determine if category has 2 or 3 states with index values -1,0,1
684 
686 {
687  if (numTypes()>3||numTypes()<2) return kFALSE ;
688  if (mustHaveZero&&numTypes()!=3) return kFALSE ;
689 
690  Bool_t ret(kTRUE) ;
691  TIterator* tIter = typeIterator() ;
692  RooCatType* type ;
693  while((type=(RooCatType*)tIter->Next())) {
694  if (abs(type->getVal())>1) ret=kFALSE ;
695  }
696 
697  delete tIter ;
698  return ret ;
699 }
CatVector * addCategory(RooAbsCategory *cat)
void clearValueDirty() const
Definition: RooAbsArg.h:449
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:240
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:32
#define coutE(a)
Definition: RooMsgService.h:34
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValueDirty=kTRUE)
Copy the cached value from given source and raise dirty flag.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer, which is interpreted as an OR of &#39;enum ContentsOptions&#39; values and in the style given by &#39;enum StyleOption&#39;.
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from stream (dummy for now)
virtual void setTreeBranchStatus(TTree &t, Bool_t active)
(De)activate associate tree branch
virtual void Reset()=0
void setBuffer(RooCatType *newBuf)
Bool_t isValidLabel(const char *label) const
Check if state with given name is defined.
Int_t GetCompressionLevel() const
Definition: TBranch.h:259
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to ostream.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:355
#define coutI(a)
Definition: RooMsgService.h:31
#define cxcoutD(a)
Definition: RooMsgService.h:79
RooCatType _value
Transient cache for byte values from tree branches.
const RooCatType * getOrdinal(UInt_t n, const char *rangeName=0) const
Return state definition of ordinal nth defined state, needed by the generator mechanism.
virtual void attachToVStore(RooVectorDataStore &vstore)
Attach the category index and label to as branches to the given vector store.
void SetCompressionLevel(Int_t level=1)
Set compression level.
Definition: TBranch.cxx:2359
void clearTypes()
Delete all currently defined states.
Roo1DTable * createTable(const char *label) const
Create a table matching the shape of this category.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t operator==(Int_t index) const
Equality operator with a integer (compares with state index number)
virtual Int_t getIndex() const
Return index number of current state.
STL namespace.
virtual RooCatType evaluate() const =0
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
virtual void syncCache(const RooArgSet *set=0)
Explicitly synchronize RooAbsCategory internal cache.
Iterator abstract base class.
Definition: TIterator.h:30
void setValueDirty() const
Definition: RooAbsArg.h:441
virtual Bool_t isValid() const
Check if current value is a valid state.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Int_t numTypes(const char *=0) const
virtual void printValue(std::ostream &os) const
Print value (label name)
RooVectorDataStore is the abstract base class for data collection that use a TTree as internal storag...
char _label[256]
Definition: RooCatType.h:103
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
Definition: RooCatType.h:22
Int_t Fill()
Definition: TBranch.h:162
const RooCatType * defineType(const char *label)
Define a new state with given name.
Bool_t isSignType(Bool_t mustHaveZero=kFALSE) const
Determine if category has 2 or 3 states with index values -1,0,1.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Definition: RooAbsArg.cxx:263
Int_t _value
Definition: RooCatType.h:102
virtual Bool_t isIdentical(const RooAbsArg &other, Bool_t assumeSameType=kFALSE)
#define ccoutE(a)
Definition: RooMsgService.h:41
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
Definition: RooAbsArg.cxx:1863
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Attach the category index and label to as branches to the given TTree.
TIterator * typeIterator() const
Return iterator over all defined states.
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatType.h:44
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multi-line detailed printing.
Definition: RooAbsArg.cxx:1376
Bool_t isValidIndex(Int_t index) const
Check if state with given index is defined.
virtual const char * getLabel() const
Return label string of current state.
RooCatType traceEval() const
Recalculate current value and check validity of new result.
RooAbsArg * createFundamental(const char *newname=0) const
Create a RooCategory fundamental object with our properties.
#define coutF(a)
Definition: RooMsgService.h:35
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
virtual ~RooAbsCategory()
Destructor.
const Bool_t kFALSE
Definition: RtypesCore.h:88
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns an array iterator.
Definition: TObjArray.cxx:633
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
int type
Definition: TGX11.cxx:120
virtual Bool_t traceEvalHook(RooCatType) const
TObjArray * GetListOfLeaves()
Definition: TBranch.h:202
virtual void SetName(const Text_t *name)
Constructor with name argument.
Definition: RooCatType.cxx:46
Bool_t isValueDirty() const
Definition: RooAbsArg.h:336
TIterator * _typeIter
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:144
virtual void fillTreeBranch(TTree &t)
Fill tree branches associated with current object with current value.
void setShapeDirty() const
Definition: RooAbsArg.h:442
Int_t getVal() const
Definition: RooCatType.h:79
virtual TObject * Next()=0
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
TObjArray _types
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:522
char Text_t
Definition: RtypesCore.h:58
void Add(TObject *obj)
Definition: TObjArray.h:73
Definition: first.py:1
Bool_t isShapeDirty() const
Definition: RooAbsArg.h:331
#define dologE(a)
Definition: RooMsgService.h:67
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
A TTree is a list of TBranches.
Definition: TBranch.h:62
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
Roo1DTable implements a one-dimensional table.
Definition: Roo1DTable.h:24
const RooCatType * defineTypeUnchecked(const char *label, Int_t index)
Internal version of defineType that does not check if type already exists.
char name[80]
Definition: TGX11.cxx:109
void clearShapeDirty() const
Definition: RooAbsArg.h:452
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48