Logo ROOT  
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
22RooAbsCategory is the base class for objects that represent a discrete value with a finite number of states.
23
24Each state is denoted by an integer and a name. Both can be used to retrieve and
25set states, but referring to states by index is more efficient. Conversion between
26index and name can be done using lookupName() or lookupIndex().
27It is possible to iterate through all defined states using begin() and end().
28
29For category classes deriving from RooAbsCategory, states can only be evaluated, *i.e.*, queried.
30Refer to RooAbsCategoryLValue and its derived classes for categories where states can also be set. The
31simplest category class whose states can be set, queried and saved in a dataset, refer to RooCategory.
32
33### Interface change in ROOT-6.22
34Category data were based in the class RooCatType, holding an index state and a category name truncated to 256
35characters. This wastes 64 bytes of storage space per entry, and prevents fast retrieval of category data.
36Since ROOT-6.22, categories are only represented by an integer. RooAbsCategory::lookupName() can be used to
37retrieve the corresponding state name. There is no limit for the length of the state name.
38
39To not break old code, the old RooCatType interfaces are still available. Whenever possible,
40the following replacements should be used:
41- lookupType() \f$ \rightarrow \f$ lookupName() / lookupIndex()
42- typeIterator() \f$ \rightarrow \f$ range-based for loop / begin() / end()
43- isValid(const RooCatType&) \f$ \rightarrow \f$ hasIndex() / hasLabel()
44**/
45
46#include "RooAbsCategory.h"
47
48#include "RooArgSet.h"
49#include "Roo1DTable.h"
50#include "RooCategory.h"
51#include "RooMsgService.h"
52#include "RooVectorDataStore.h"
54#include "TreeReadBuffer.h"
55
56#include "Compression.h"
57#include "TString.h"
58#include "TTree.h"
59#include "TLeaf.h"
60#include "TBranch.h"
61
62#include <functional>
63#include <memory>
64
65using namespace std;
66
68
69/// A category state to signify an invalid category. The category name is empty,
70/// the index is the minimal int.
72 static const decltype(RooAbsCategory::_stateNames)::value_type invalid{"", std::numeric_limits<value_type>::min()};
73 return invalid;
74}
75
76
78
79
80////////////////////////////////////////////////////////////////////////////////
81/// Constructor
82
83RooAbsCategory::RooAbsCategory(const char *name, const char *title) :
84 RooAbsArg(name,title), _currentIndex(0)
85{
88}
89
90
91
92////////////////////////////////////////////////////////////////////////////////
93/// Copy constructor, copies the registered category states from the original.
94
96 RooAbsArg(other,name), _currentIndex(other._currentIndex),
97 _stateNames(other._stateNames),
98 _insertionOrder(other._insertionOrder)
99{
100 setValueDirty() ;
101 setShapeDirty() ;
102}
103
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// Destructor
108
110{
111
112}
113
114
115
116////////////////////////////////////////////////////////////////////////////////
117/// Return index number of current state
118
120{
121 if (isValueDirty() || isShapeDirty()) {
123
125 }
126
127 return _currentIndex;
128}
129
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Return label string of current state.
134
136{
137 const auto index = getCurrentIndex();
138 for (const auto& item : stateNames()) {
139 if (item.second == index)
140 return item.first.c_str();
141 }
142
143 return "";
144}
145
146
147////////////////////////////////////////////////////////////////////////////////
148/// Equality operator with a integer (compares with state index number)
149
151{
152 return (index==getCurrentIndex()) ;
153}
154
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Equality operator with a string (compares with state label string)
159
160bool RooAbsCategory::operator==(const char* label) const
161{
162 return strcmp(label, getCurrentLabel()) == 0;
163}
164
165
166
167////////////////////////////////////////////////////////////////////////////////
168/// Equality operator with another RooAbsArg. Only functional
169/// is also a RooAbsCategory, will return true if index is the same
170
171bool RooAbsCategory::operator==(const RooAbsArg& other) const
172{
173 const RooAbsCategory* otherCat = dynamic_cast<const RooAbsCategory*>(&other) ;
174 return otherCat ? operator==(otherCat->getCurrentIndex()) : false ;
175}
176
177
178////////////////////////////////////////////////////////////////////////////////
179
180bool RooAbsCategory::isIdentical(const RooAbsArg& other, bool assumeSameType) const
181{
182 if (!assumeSameType) {
183 const RooAbsCategory* otherCat = dynamic_cast<const RooAbsCategory*>(&other) ;
184 return otherCat ? operator==(otherCat->getCurrentIndex()) : false ;
185 } else {
186 return getCurrentIndex() == static_cast<const RooAbsCategory&>(other).getCurrentIndex();
187 }
188}
189
190
191////////////////////////////////////////////////////////////////////////////////
192/// Check if a state with index `index` exists.
194{
195 for (const auto& item : stateNames()) {
196 if (item.second == index)
197 return true;
198 }
199
200 return false;
201}
202
203
204////////////////////////////////////////////////////////////////////////////////
205/// Look up the name corresponding to the given index.
206const std::string& RooAbsCategory::lookupName(value_type index) const {
207 for (const auto& item : stateNames()) {
208 if (item.second == index)
209 return item.first;
210 }
211
212 return invalidCategory().first;
213}
214
215////////////////////////////////////////////////////////////////////////////////
216/// Define a new state with given label. The next available
217/// integer is assigned as index value.
218const std::map<std::string, RooAbsCategory::value_type>::value_type& RooAbsCategory::defineState(const std::string& label)
219{
220 return defineState(label, nextAvailableStateIndex());
221}
222
223
224////////////////////////////////////////////////////////////////////////////////
225/// Internal version of defineState() that does not check if type
226/// already exists
228{
229 _stateNames.emplace(label, index);
230 _insertionOrder.push_back(label);
231
232 if (_stateNames.size() == 1)
234
236}
237
238
239
240////////////////////////////////////////////////////////////////////////////////
241/// Define new state with given name and index number.
242
243const std::map<std::string, RooAbsCategory::value_type>::value_type& RooAbsCategory::defineState(const std::string& label, RooAbsCategory::value_type index)
244{
245 auto& theStateNames = stateNames();
246
247 if (hasIndex(index)) {
248 coutE(InputArguments) << "RooAbsCategory::" << __func__ << "(" << GetName() << "): index "
249 << index << " already assigned" << endl ;
250 return invalidCategory();
251 }
252
253 if (hasLabel(label)) {
254 coutE(InputArguments) << "RooAbsCategory::" << __func__ << "(" << GetName() << "): label "
255 << label << " already assigned or not allowed" << endl ;
256 return invalidCategory();
257 }
258
259 const auto result = theStateNames.emplace(label, index);
260 _insertionOrder.push_back(label);
261
262 if (theStateNames.size() == 1)
264
266
267 return *(result.first);
268}
269
270
271
272////////////////////////////////////////////////////////////////////////////////
273/// Delete all currently defined states
274
276{
277 _stateNames.clear();
278 _insertionOrder.clear();
280 setShapeDirty() ;
281}
282
283
284////////////////////////////////////////////////////////////////////////////////
285/// Find the index number corresponding to the state name.
286/// \see hasLabel() for checking if a given label has been defined.
287/// \return Index of the category or std::numeric_limits<int>::min() on failure.
288RooAbsCategory::value_type RooAbsCategory::lookupIndex(const std::string& stateName) const {
289 const auto item = stateNames().find(stateName);
290 if (item != stateNames().end()) {
291 return item->second;
292 }
293
294 return invalidCategory().second;
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Find our type that matches the specified type, or return 0 for no match.
299/// \deprecated RooCatType is not used, any more. This function will create one and let it leak.
300/// Use lookupIndex() (preferred) or lookupName() instead.
301const RooCatType* RooAbsCategory::lookupType(const RooCatType &other, bool printError) const
302{
303 return lookupType(other.getVal(), printError);
304}
305
306
307
308////////////////////////////////////////////////////////////////////////////////
309/// Find our type corresponding to the specified index, or return nullptr for no match.
310/// \deprecated RooCatType is not used, any more. This function will create one and let it leak.
311/// Use lookupIndex() (preferred) or lookupName() instead.
313{
314 for (const auto& item : stateNames())
315 if (item.second == index) {
317 }
318
319 if (printError) {
320 coutE(InputArguments) << ClassName() << "::" << GetName() << ":lookupType: no match for index "
321 << index << endl;
322 }
323
324 return nullptr;
325}
326
327
328
329////////////////////////////////////////////////////////////////////////////////
330/// Find our type corresponding to the specified label, or return 0 for no match.
331/// \deprecated RooCatType is not used, any more. This function will create one and let it leak.
332/// Use lookupIndex() (preferred) or lookupName() instead.
333const RooCatType* RooAbsCategory::lookupType(const char* label, bool printError) const
334{
335 for (const auto& type : stateNames()) {
336 if(type.first == label)
337 return retrieveLegacyState(type.second);
338 }
339
340 // Try if label represents integer number
341 char* endptr ;
342 RooAbsCategory::value_type idx=strtol(label,&endptr,10) ;
343 if (endptr==label+strlen(label)) {
344 return lookupType(idx);
345 }
346
347 if (printError) {
348 coutE(InputArguments) << ClassName() << "::" << GetName() << ":lookupType: no match for label "
349 << label << endl;
350 }
351 return nullptr;
352}
353
354
355////////////////////////////////////////////////////////////////////////////////
356/// Check if given state is defined for this object
357
359{
360 return hasIndex(value.getVal()) ;
361}
362
363
364
365////////////////////////////////////////////////////////////////////////////////
366/// Create a table matching the shape of this category
367
369{
370 return new Roo1DTable(GetName(),label,*this) ;
371}
372
373
374
375////////////////////////////////////////////////////////////////////////////////
376/// Read object contents from stream (dummy for now)
377
378bool RooAbsCategory::readFromStream(istream&, bool, bool)
379{
380 return false ;
381}
382
383
384
385////////////////////////////////////////////////////////////////////////////////
386/// Write object contents to ostream
387
388void RooAbsCategory::writeToStream(ostream& os, bool /* compact */) const
389{
390 os << getCurrentLabel() ;
391}
392
393
394
395////////////////////////////////////////////////////////////////////////////////
396/// Print value (label name)
397
398void RooAbsCategory::printValue(ostream& os) const
399{
400 os << getCurrentLabel() << "(idx = " << getCurrentIndex() << ")" << endl ;
401}
402
403
404
405////////////////////////////////////////////////////////////////////////////////
406/// Print info about this object to the specified stream. In addition to the info
407/// from RooAbsArg::printStream() we add:
408///
409/// Shape : label, index, defined types
410
411void RooAbsCategory::printMultiline(ostream& os, Int_t contents, bool verbose, TString indent) const
412{
414
415 os << indent << "--- RooAbsCategory ---" << endl;
416 if (stateNames().empty()) {
417 os << indent << " ** No values defined **" << endl;
418 return;
419 }
420 os << indent << " Value = " << getCurrentIndex() << " \"" << getCurrentLabel() << ')' << endl;
421 os << indent << " Possible states:" << endl;
422 indent.Append(" ");
423 for (const auto& type : stateNames()) {
424 os << indent << type.first << '\t' << type.second << "\n";
425 }
426}
427
428
429
430////////////////////////////////////////////////////////////////////////////////
431/// Attach the category index and label to as branches to the given vector store
432
434{
435 RooVectorDataStore::CatVector* cv = vstore.addCategory(this) ;
437}
438
439
440
441
442////////////////////////////////////////////////////////////////////////////////
443/// Attach the category index and label as branches to the given
444/// TTree. The index field will be attached as integer with name
445/// `<name>_idx`. If a branch `<name>` exists, it attaches to this branch.
447{
448 // First check if there is an integer branch matching the category name
449 TString cleanName(cleanBranchName()) ;
450 TBranch* branch = tree.GetBranch(cleanName) ;
451 if (!branch) {
452 cleanName += "_idx";
453 branch = tree.GetBranch(cleanName);
454 }
455
456 if (branch) {
457 TLeaf* leaf = (TLeaf*)branch->GetListOfLeaves()->At(0) ;
458
459 // Check that leaf is _not_ an array
460 Int_t dummy ;
461 TLeaf* counterLeaf = leaf->GetLeafCounter(dummy) ;
462 if (counterLeaf) {
463 coutE(Eval) << "RooAbsCategory::attachToTree(" << GetName() << ") ERROR: TTree branch " << GetName()
464 << " is an array and cannot be attached to a RooAbsCategory" << endl ;
465 return ;
466 }
467
468 TString typeName(leaf->GetTypeName()) ;
469
470
471 // For different type names, store a function to attach
472 std::map<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>> typeMap {
473 {"Float_t", [&](){ return createTreeReadBuffer<Float_t >(cleanName, tree); }},
474 {"Double_t", [&](){ return createTreeReadBuffer<Double_t >(cleanName, tree); }},
475 {"UChar_t", [&](){ return createTreeReadBuffer<UChar_t >(cleanName, tree); }},
476 {"Boolt_", [&](){ return createTreeReadBuffer<Bool_t >(cleanName, tree); }},
477 {"Char_t", [&](){ return createTreeReadBuffer<Char_t >(cleanName, tree); }},
478 {"UInt_t", [&](){ return createTreeReadBuffer<UInt_t >(cleanName, tree); }},
479 {"Long64_t", [&](){ return createTreeReadBuffer<Long64_t >(cleanName, tree); }},
480 {"ULong64_t", [&](){ return createTreeReadBuffer<ULong64_t>(cleanName, tree); }},
481 {"Short_t", [&](){ return createTreeReadBuffer<Short_t >(cleanName, tree); }},
482 {"UShort_t", [&](){ return createTreeReadBuffer<UShort_t >(cleanName, tree); }},
483 };
484
485 auto typeDetails = typeMap.find(typeName.Data());
486 if (typeDetails != typeMap.end()) {
487 coutI(DataHandling) << "RooAbsCategory::attachToTree(" << GetName() << ") TTree " << typeName << " branch \"" << cleanName
488 << "\" will be converted to int." << endl ;
489 _treeReadBuffer = typeDetails->second();
490 } else {
491 _treeReadBuffer = nullptr;
492
493 if (!typeName.CompareTo("Int_t")) {
494 tree.SetBranchAddress(cleanName, &_currentIndex);
495 }
496 else {
497 coutE(InputArguments) << "RooAbsCategory::attachToTree(" << GetName() << ") data type " << typeName << " is not supported." << endl ;
498 }
499 }
500 } else {
501 TString format(cleanName);
502 format.Append("/I");
503 void* ptr = &_currentIndex;
504 tree.Branch(cleanName, ptr, (const Text_t*)format, bufSize);
505 }
506}
507
508
509
510////////////////////////////////////////////////////////////////////////////////
511/// Fill tree branches associated with current object with current value
512
514{
515 TString idxName(GetName()) ;
516 idxName.Append("_idx") ;
517
518 // First determine if branch is taken
519 TBranch* idxBranch = t.GetBranch(idxName) ;
520 if (!idxBranch) {
521 coutF(DataHandling) << "RooAbsCategory::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree" << endl ;
522 throw std::runtime_error("RooAbsCategory::fillTreeBranch(): Category is not attached to a tree.");
523 }
524
525 idxBranch->Fill() ;
526}
527
528
529
530////////////////////////////////////////////////////////////////////////////////
531/// (De)activate associate tree branch
532
534{
535 TBranch* branch = t.GetBranch(Form("%s_idx",GetName())) ;
536 if (branch) {
537 t.SetBranchStatus(Form("%s_idx",GetName()),active?1:0) ;
538 }
539}
540
541
542
543////////////////////////////////////////////////////////////////////////////////
544/// Explicitly synchronize RooAbsCategory internal cache
545
547{
549}
550
551
552
553////////////////////////////////////////////////////////////////////////////////
554/// Copy the cached value from given source and raise dirty flag.
555/// It is the callers responsibility to ensure that the sources
556/// cache is clean(valid) before this function is called, e.g. by
557/// calling syncCache() on the source.
558
559void RooAbsCategory::copyCache(const RooAbsArg *source, bool /*valueOnly*/, bool setValDirty)
560{
561 auto other = static_cast<const RooAbsCategory*>(source);
562 assert(dynamic_cast<const RooAbsCategory*>(source));
563
564 value_type tmp = other->_treeReadBuffer ? *other->_treeReadBuffer : other->_currentIndex;
565 // Lookup cat state from other-index because label is missing
566 if (hasIndex(tmp)) {
567 _currentIndex = tmp;
568 if (setValDirty) {
570 }
571 } else {
572 coutE(DataHandling) << "RooAbsCategory::copyCache(" << GetName() << ") ERROR: index of source arg "
573 << source->GetName() << " is invalid (" << other->_currentIndex
574 << "), value not updated" << endl;
575 }
576}
577
578
579////////////////////////////////////////////////////////////////////////////////
580/// Overwrite the value stored in this object's cache.
581/// This can be used to fake a computation that resulted in `value`.
582/// \param[in] value Value to write. The argument is reinterpreted as a category state.
583/// If such a state does not exist, this will create undefined behaviour.
584/// \param[in] notifyClients If true, notify users of this object that its value changed.
585/// This is the default.
586void RooAbsCategory::setCachedValue(double value, bool notifyClients) {
587 _currentIndex = static_cast<value_type>(value);
588
589 if (notifyClients) {
591 _valueDirty = false;
592 }
593}
594
595
596////////////////////////////////////////////////////////////////////////////////
597/// Return name and index of the `n`th defined state. When states are defined using
598/// defineType() or operator[], the order of insertion is tracked, to mimic the behaviour
599/// before modernising the category classes.
600/// When directly manipulating the map with state names using states(), the order of insertion
601/// is not known, so alphabetical ordering as usual for std::map is used. The latter is faster.
602/// \param[in] n Number of state to be retrieved.
603/// \return A pair with name and index.
604const std::map<std::string, RooAbsCategory::value_type>::value_type& RooAbsCategory::getOrdinal(unsigned int n) const {
605 // Retrieve state names, trigger possible recomputation
606 auto& theStateNames = stateNames();
607
608 if (n >= theStateNames.size())
609 return invalidCategory();
610
611 if (theStateNames.size() != _insertionOrder.size())
612 return *std::next(theStateNames.begin(), n);
613
614 const auto item = theStateNames.find(_insertionOrder[n]);
615 if (item != theStateNames.end())
616 return *item;
617
618 return invalidCategory();
619}
620
621
622////////////////////////////////////////////////////////////////////////////////
623/// Return ordinal number of the current state.
625 // Retrieve state names, trigger possible recomputation
626 auto& theStateNames = stateNames();
627
628 // If we don't have the full history of inserted state names, have to go by map ordering:
629 if (theStateNames.size() != _insertionOrder.size()) {
630 const auto currentIndex = getCurrentIndex();
631 for (auto it = theStateNames.begin(); it != theStateNames.end(); ++it) {
632 if (it->second == currentIndex)
633 return std::distance(theStateNames.begin(), it);
634 }
635 }
636
637 // With full insertion history, find index of current label:
638 auto item = std::find(_insertionOrder.begin(), _insertionOrder.end(), getCurrentLabel());
639 assert(item != _insertionOrder.end());
640
641 return item - _insertionOrder.begin();
642}
643
644
645////////////////////////////////////////////////////////////////////////////////
646/// Create a RooCategory fundamental object with our properties.
647
649{
650 // Add and precalculate new category column
651 RooCategory *fund= new RooCategory(newname?newname:GetName(),GetTitle()) ;
652
653 // Copy states
654 for (const auto& type : stateNames()) {
655 fund->defineStateUnchecked(type.first, type.second);
656 }
657
658 return fund;
659}
660
661
662
663////////////////////////////////////////////////////////////////////////////////
664/// Determine if category has 2 or 3 states with index values -1,0,1
665
666bool RooAbsCategory::isSignType(bool mustHaveZero) const
667{
668 const auto& theStateNames = stateNames();
669
670 if (theStateNames.size() > 3 || theStateNames.size() < 2) return false;
671 if (mustHaveZero && theStateNames.size() != 3) return false;
672
673 for (const auto& type : theStateNames) {
674 if (abs(type.second)>1)
675 return false;
676 }
677
678 return true;
679}
680
681/// \deprecated Use begin() and end() instead.
682/// \note Using this iterator creates useless RooCatType instances, which will leak
683/// unless deleted by the user.
686}
687
688const RooCatType* RooAbsCategory::defineType(const char* label) {
689 defineState(label);
690 return retrieveLegacyState(stateNames()[label]);
691}
692
693const RooCatType* RooAbsCategory::defineType(const char* label, int index) {
694 defineState(label, index);
696}
697
701}
702
703/// Return the legacy RooCatType corresponding to `index`. If it doesn't exist, create one.
705 auto result = _legacyStates.find(index);
706 if (result == _legacyStates.end()) {
707 result = _legacyStates.emplace(index,
708 std::unique_ptr<RooCatType>(new RooCatType(lookupName(index).c_str(), index))).first;
709 }
710
711 return result->second.get();
712}
713
714
716 const auto& theStateNames = stateNames();
717
718 if (theStateNames.empty())
719 return 0;
720
721 return 1 + std::max_element(theStateNames.begin(), theStateNames.end(),
722 [](const std::map<std::string, value_type>::value_type& left,
723 const std::map<std::string, value_type>::value_type& right) {
724 return left.second < right.second; })->second;
725}
#define coutI(a)
Definition: RooMsgService.h:34
#define coutF(a)
Definition: RooMsgService.h:38
#define coutE(a)
Definition: RooMsgService.h:37
char Text_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:375
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition: TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2447
Roo1DTable implements a one-dimensional table.
Definition: Roo1DTable.h:23
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:77
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
Definition: RooAbsArg.h:518
bool isShapeDirty() const
Definition: RooAbsArg.h:439
void clearValueDirty() const
Definition: RooAbsArg.h:622
bool _valueDirty
Definition: RooAbsArg.h:731
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:513
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Implement multi-line detailed printing.
Definition: RooAbsArg.cxx:1499
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:1988
bool isValueDirty() const
Definition: RooAbsArg.h:444
A space to attach TBranches.
virtual value_type getCurrentIndex() const
Return index number of current state.
void setCachedValue(double value, bool notifyClients=true) final
Overwrite the value stored in this object's cache.
unsigned int getCurrentOrdinalNumber() const
Return ordinal number of the current state.
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
const std::string & lookupName(value_type index) const
Get the name corresponding to the given index.
TIterator * typeIterator() const
bool operator==(value_type index) const
Equality operator with a integer (compares with state index number)
RooCatType * retrieveLegacyState(value_type index) const
Return the legacy RooCatType corresponding to index. If it doesn't exist, create one.
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValueDirty=true) override
Copy the cached value from given source and raise dirty flag.
value_type _currentIndex
Current category state.
Roo1DTable * createTable(const char *label) const
Create a table matching the shape of this category.
void defineStateUnchecked(const std::string &label, value_type index)
Internal version of defineState() that does not check if type already exists.
const RooCatType * defineTypeUnchecked(const char *label, value_type index)
void setTreeBranchStatus(TTree &t, bool active) override
(De)activate associate tree branch
const RooCatType * lookupType(value_type index, bool printError=false) const
Find our type corresponding to the specified index, or return nullptr for no match.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to ostream.
value_type nextAvailableStateIndex() const
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from stream (dummy for now)
bool isSignType(bool mustHaveZero=false) const
Determine if category has 2 or 3 states with index values -1,0,1.
std::map< std::string, value_type >::const_iterator end() const
Iterator for category state names. Points to pairs of index and name.
virtual const std::map< std::string, RooAbsCategory::value_type >::value_type & defineState(const std::string &label)
Define a new state with given label.
virtual value_type evaluate() const =0
Evaluate the category state and return.
const std::map< std::string, value_type >::value_type & getOrdinal(unsigned int n) const
Return name and index of the nth defined state.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
std::map< value_type, std::unique_ptr< RooCatType, std::function< void(RooCatType *)> > > _legacyStates
! Map holding pointers to RooCatType instances. Only for legacy interface. Don't use if possible.
bool isIdentical(const RooAbsArg &other, bool assumeSameType=false) const override
~RooAbsCategory() override
Destructor.
std::vector< std::string > _insertionOrder
Keeps track in which order state numbers have been inserted. Make sure this is updated in recomputeSh...
std::map< std::string, value_type > _stateNames
Map state names to index numbers. Make sure state names are updated in recomputeShape().
bool isValid() const override
WVE (08/21/01) Probably obsolete now.
const RooCatType * defineType(const char *label)
RooAbsArg * createFundamental(const char *newname=0) const override
Create a RooCategory fundamental object with our properties.
const std::map< std::string, value_type > & stateNames() const
Access the map of state names to index numbers.
bool hasIndex(value_type index) const
Check if a state with index index exists.
void attachToVStore(RooVectorDataStore &vstore) override
Attach the category index and label to as branches to the given vector store.
static const decltype(_stateNames) ::value_type & invalidCategory()
A category state to signify an invalid category.
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
std::unique_ptr< TreeReadBuffer > _treeReadBuffer
void attachToTree(TTree &t, Int_t bufSize=32000) override
Attach the category index and label as branches to the given TTree.
void fillTreeBranch(TTree &t) override
Fill tree branches associated with current object with current value.
void syncCache(const RooArgSet *set=0) override
Explicitly synchronize RooAbsCategory internal cache.
void clearTypes()
Delete all currently defined states.
void printValue(std::ostream &os) const override
Print value (label name)
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
Int_t getVal() const
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:28
void setBuffer(RooAbsCategory::value_type *newBuf)
RooVectorDataStore uses std::vectors to store data columns.
CatVector * addCategory(RooAbsCategory *cat)
A TTree is a list of TBranches.
Definition: TBranch.h:89
TObjArray * GetListOfLeaves()
Definition: TBranch.h:243
Int_t Fill()
Definition: TBranch.h:201
Iterator abstract base class.
Definition: TIterator.h:30
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:57
virtual const char * GetTypeName() const
Definition: TLeaf.h:139
virtual TLeaf * GetLeafCounter(Int_t &countval) const
Return a pointer to the counter of this leaf (if any) or store the number of elements that the leaf c...
Definition: TLeaf.cxx:249
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
TObject * At(Int_t idx) const override
Definition: TObjArray.h:164
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
Basic string class.
Definition: TString.h:136
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:442
const char * Data() const
Definition: TString.h:369
TString & Append(const char *cs)
Definition: TString.h:564
A TTree represents a columnar dataset.
Definition: TTree.h:79
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:5256
virtual void SetBranchStatus(const char *bname, Bool_t status=1, UInt_t *found=0)
Set branch status to Process or DoNotProcess.
Definition: TTree.cxx:8491
RVec< PromoteType< T > > abs(const RVec< T > &v)
Definition: RVec.hxx:1739
const Int_t n
Definition: legend1.C:16
@ DataHandling
Definition: RooGlobalFunc.h:65
@ InputArguments
Definition: RooGlobalFunc.h:64
Definition: tree.py:1