Logo ROOT  
Reference Guide
RooCategory.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 \class RooCategory
19 \ingroup Roofitcore
20 
21 RooCategory is an object to represent discrete states.
22 States have names and index numbers, and the index numbers can be written into datasets and
23 used in calculations.
24 A category is "fundamental", i.e., its value doesn't depend on the value of other objects.
25 (Objects in datasets cannot depend on other objects' values, they need to be self-consistent.)
26 
27 A category object can be used to *e.g.* conduct a simultaneous fit of
28 the same observable in multiple categories.
29 
30 ### Setting up a category
31 1. A category can be set up like this:
32 ~~~{.cpp}
33 RooCategory myCat("myCat", "Lepton multiplicity category", {
34  {"0Lep", 0},
35  {"1Lep", 1},
36  {"2Lep", 2},
37  {"3Lep", 3}
38 });
39 ~~~
40 2. Like this:
41 ~~~{.cpp}
42 RooCategory myCat("myCat", "Asymmetry");
43 myCat["left"] = -1;
44 myCat["right"] = 1;
45 ~~~
46 3. Or like this:
47 ~~~{.cpp}
48 RooCategory myCat("myCat", "Asymmetry");
49 myCat.defineType("left", -1);
50 myCat.defineType("right", 1);
51 ~~~
52 Inspect the pairs of state names and state numbers like this:
53 ~~~{.cpp}
54 for (const auto& nameIdx : myCat) {
55  std::cout << nameIdx.first << " --> " << nameIdx.second << std::endl;
56 }
57 ~~~
58 
59 ### Changing category states
60 Category states can be modified either by using the index state (faster) or state names.
61 For example:
62 ~~~{.cpp}
63 myCat.setIndex(5);
64 myCat.setLabel("left");
65 for (const auto& otherNameIdx : otherCat) {
66  myCat.setIndex(otherNameIdx);
67 }
68 ~~~
69 
70 Also refer to \ref tutorial_roofit, especially rf404_categories.C for an introduction, and to rf405_realtocatfuncs.C and rf406_cattocatfuncs.C
71 for advanced uses of categories.
72 **/
73 
74 #include "RooCategory.h"
75 
76 #include "RooFit.h"
77 #include "RooArgSet.h"
78 #include "RooStreamParser.h"
79 #include "RooMsgService.h"
80 #include "RooTrace.h"
81 #include "RooHelpers.h"
84 
85 #include "TBuffer.h"
86 #include "TString.h"
87 #include "ROOT/RMakeUnique.hxx"
88 #include "TList.h"
89 
90 #include <iostream>
91 #include <cstdlib>
92 
93 using namespace std;
94 
96 
97 std::map<std::string, std::weak_ptr<RooCategory::RangeMap_t>> RooCategory::_uuidToSharedRangeIOHelper; // Helper for restoring shared properties
98 std::map<std::string, std::weak_ptr<RooCategory::RangeMap_t>> RooCategory::_sharedRangeIOHelper;
99 
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 
104 {
105  TRACE_CREATE
106 }
107 
108 
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Constructor. Types must be defined using defineType() before variable can be used
112 RooCategory::RooCategory(const char *name, const char *title) :
113  RooAbsCategoryLValue(name,title),
114  _ranges(new RangeMap_t())
115 {
116  setValueDirty() ;
117  setShapeDirty() ;
118  TRACE_CREATE
119 }
120 
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Create a new category and define allowed states.
124 /// \param[in] name Name used to refer to this object.
125 /// \param[in] title Title for e.g. plotting.
126 /// \param[in] allowedStates Map of allowed states. Pass e.g. `{ {"0Lep", 0}, {"1Lep:, 1} }`
127 RooCategory::RooCategory(const char* name, const char* title, const std::map<std::string, int>& allowedStates) :
128  RooAbsCategoryLValue(name,title),
129  _ranges(new RangeMap_t())
130 {
131  defineTypes(allowedStates);
132 }
133 
134 
135 
136 ////////////////////////////////////////////////////////////////////////////////
137 /// Copy constructor
138 
139 RooCategory::RooCategory(const RooCategory& other, const char* name) :
140  RooAbsCategoryLValue(other, name),
141  _ranges(other._ranges)
142 {
143  TRACE_CREATE
144 }
145 
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Destructor
149 
151 {
153 }
154 
155 
156 
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 /// Set value by specifying the index code of the desired state.
160 /// If printError is set, a message will be printed if
161 /// the specified index does not represent a valid state.
162 /// \return bool signalling if an error occurred.
164 {
165  if (!hasIndex(index)) {
166  if (printError) {
167  coutE(InputArguments) << "RooCategory: Trying to set invalid state " << index << " for category " << GetName() << std::endl;
168  }
169  return true;
170  }
171 
172  _currentIndex = index;
173  setValueDirty();
174 
175  return false;
176 }
177 
178 
179 
180 ////////////////////////////////////////////////////////////////////////////////
181 /// Set value by specifying the name of the desired state.
182 /// If printError is set, a message will be printed if
183 /// the specified label does not represent a valid state.
184 /// \return false on success.
185 Bool_t RooCategory::setLabel(const char* label, Bool_t printError)
186 {
187  const auto item = stateNames().find(label);
188  if (item != stateNames().end()) {
189  _currentIndex = item->second;
190  setValueDirty();
191  return false;
192  }
193 
194  if (printError) {
195  coutE(InputArguments) << "Trying to set invalid state label '" << label << "' for category " << GetName() << std::endl;
196  }
197 
198  return true;
199 }
200 
201 
202 
203 ////////////////////////////////////////////////////////////////////////////////
204 /// Define a state with given name.
205 /// The lowest available positive integer is assigned as index. Category
206 /// state labels may not contain semicolons.
207 /// \return True in case of an error.
208 bool RooCategory::defineType(const std::string& label)
209 {
210  if (label.find(';') != std::string::npos) {
211  coutE(InputArguments) << "RooCategory::defineType(" << GetName()
212  << "): semicolons not allowed in label name" << endl ;
213  return true;
214  }
215 
216  return RooAbsCategory::defineState(label) == invalidCategory();
217 }
218 
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Define a state with given name and index. Category
222 /// state labels may not contain semicolons.
223 /// \return True in case of error.
224 bool RooCategory::defineType(const std::string& label, Int_t index)
225 {
226  if (label.find(';') != std::string::npos) {
227  coutE(InputArguments) << "RooCategory::defineType(" << GetName()
228  << "): semicolons not allowed in label name" << endl ;
229  return true;
230  }
231 
232  return RooAbsCategory::defineState(label, index) == invalidCategory();
233 }
234 
235 
236 ////////////////////////////////////////////////////////////////////////////////
237 /// Define multiple states in a single call. Use like:
238 /// ```
239 /// myCat.defineTypes({ {"0Lep", 0}, {"1Lep", 1}, {"2Lep", 2}, {"3Lep", 3} });
240 /// ```
241 /// Note: When labels or indices are defined multiple times, an error message is printed,
242 /// and the corresponding state is ignored.
243 void RooCategory::defineTypes(const std::map<std::string, int>& allowedStates) {
244  for (const auto& nameAndIdx : allowedStates) {
245  defineType(nameAndIdx.first, nameAndIdx.second);
246  }
247 }
248 
249 
250 ////////////////////////////////////////////////////////////////////////////////
251 /// Access a named state. If a state with this name doesn't exist yet, the state is
252 /// assigned the next available positive integer.
253 /// \param[in] stateName Name of the state to be accessed.
254 /// \return Reference to the category index. If no state exists, it will be created on the fly.
255 RooAbsCategory::value_type& RooCategory::operator[](const std::string& stateName) {
256  setShapeDirty();
257  if (stateNames().count(stateName) == 0) {
258  _insertionOrder.push_back(stateName);
259  return stateNames()[stateName] = nextAvailableStateIndex();
260 
261  }
262 
263  return stateNames()[stateName];
264 }
265 
266 
267 ////////////////////////////////////////////////////////////////////////////////
268 /// Return a reference to the map of state names to index states.
269 /// This can be used to manipulate the category.
270 /// \note Calling this function will **always** trigger recomputations of
271 /// of **everything** that depends on this category, since in case the map gets
272 /// manipulated, names or indices might change. Also, the order that states have
273 /// been inserted in gets lost. This changes what is returned by getOrdinal().
274 std::map<std::string, RooAbsCategory::value_type>& RooCategory::states() {
275  auto& theStates = stateNames();
276  setValueDirty();
277  setShapeDirty();
278  _insertionOrder.clear();
279  return theStates;
280 }
281 
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 /// Read object contents from given stream
285 
287 {
288  // Read single token
289  RooStreamParser parser(is) ;
290  TString token = parser.readToken() ;
291 
292  return setLabel(token,verbose) ;
293 }
294 
295 
296 
297 ////////////////////////////////////////////////////////////////////////////////
298 /// compact only at the moment
299 
300 void RooCategory::writeToStream(ostream& os, Bool_t compact) const
301 {
302  if (compact) {
303  os << getCurrentIndex() ;
304  } else {
305  os << getCurrentLabel() ;
306  }
307 }
308 
309 
310 ////////////////////////////////////////////////////////////////////////////////
311 /// Clear the named range.
312 /// \note This affects **all** copies of this category, because they are sharing
313 /// range definitions. This ensures that categories inside a dataset and their
314 /// counterparts on the outside will both see a modification of the range.
315 void RooCategory::clearRange(const char* name, Bool_t silent)
316 {
317  std::map<std::string, std::vector<value_type>>::iterator item = _ranges->find(name);
318  if (item == _ranges->end()) {
319  if (!silent)
320  coutE(InputArguments) << "RooCategory::clearRange(" << GetName() << ") ERROR: must specify valid range name" << endl ;
321  return;
322  }
323 
324  _ranges->erase(item);
325 }
326 
327 
328 ////////////////////////////////////////////////////////////////////////////////
329 
330 void RooCategory::setRange(const char* name, const char* stateNameList)
331 {
333  addToRange(name,stateNameList) ;
334 }
335 
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Add the given state to the given range.
339 /// \note This creates or accesses a **shared** map with allowed ranges. All copies of this
340 /// category will share this range such that a category inside a dataset and its
341 /// counterpart on the outside will both see a modification of the range.
343  auto item = _ranges->find(name);
344  if (item == _ranges->end()) {
345  if (!name) {
346  coutE(Contents) << "RooCategory::addToRange(" << GetName()
347  << "): Need valid range name." << std::endl;
348  return;
349  }
350 
351  item = _ranges->emplace(name, std::vector<value_type>()).first;
352  coutI(Contents) << "RooCategory::setRange(" << GetName()
353  << ") new range named '" << name << "' created for state " << stateIndex << endl ;
354  }
355 
356  item->second.push_back(stateIndex);
357 }
358 
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 /// Add the list of state names to the given range. State names can be separated
362 /// with ','.
363 /// \note This creates or accesses a **shared** map with allowed ranges. All copies of this
364 /// category will share this range such that a category inside a dataset and its
365 /// counterpart on the outside will both see a modification of the range.
366 void RooCategory::addToRange(const char* name, const char* stateNameList)
367 {
368  if (!stateNameList) {
369  coutE(InputArguments) << "RooCategory::setRange(" << GetName() << ") ERROR: must specify valid name and state name list" << endl ;
370  return;
371  }
372 
373  // Parse list of state names, verify that each is valid and add them to the list
374  for (const auto& token : RooHelpers::tokenise(stateNameList, ",")) {
375  const value_type idx = lookupIndex(token);
376  if (idx != invalidCategory().second) {
377  addToRange(name, idx);
378  } else {
379  coutW(InputArguments) << "RooCategory::setRange(" << GetName() << ") WARNING: Ignoring invalid state name '"
380  << token << "' in state name list" << endl ;
381  }
382  }
383 }
384 
385 
386 ////////////////////////////////////////////////////////////////////////////////
387 /// Check if the state is in the given range.
388 /// If no range is specified either as argument or if no range has been defined for this category
389 /// (*i.e.*, the default range is meant), all category states count as being in range.
390 bool RooCategory::isStateInRange(const char* rangeName, RooAbsCategory::value_type stateIndex) const {
391  if (rangeName == nullptr || _ranges->empty())
392  return true;
393 
394  const auto item = _ranges->find(rangeName);
395  if (item == _ranges->end())
396  return false;
397 
398  const std::vector<value_type>& vec = item->second;
399  return std::find(vec.begin(), vec.end(), stateIndex) != vec.end();
400 }
401 
402 
403 ////////////////////////////////////////////////////////////////////////////////
404 /// Check if the state is in the given range.
405 /// If no range is specified (*i.e.*, the default range), all category states count as being in range.
406 /// This overload requires a name lookup. Recommend to use the category index with
407 /// RooCategory::isStateInRange(const char*, RooAbsCategory::value_type) const.
408 bool RooCategory::isStateInRange(const char* rangeName, const char* stateName) const
409 {
410  // Check that both input arguments are not null pointers
411  if (!rangeName) {
412  return true;
413  }
414 
415  if (!stateName) {
416  coutE(InputArguments) << "RooCategory::isStateInRange(" << GetName() << ") ERROR: must specify valid state name" << endl ;
417  return false;
418  }
419 
420  return isStateInRange(rangeName, lookupIndex(stateName));
421 }
422 
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 
426 void RooCategory::Streamer(TBuffer &R__b)
427 {
428  UInt_t R__s, R__c;
429  if (R__b.IsReading()) {
430 
431  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
432 
433  if (R__v==1) {
434  RooAbsCategoryLValue::Streamer(R__b);
435 
436  // In v1, properties were a direct pointer:
437  RooCategorySharedProperties* props = nullptr;
438  R__b >> props;
440  // props was allocated by I/O system, we cannot delete here in case it gets reused
441 
442  } else if (R__v == 2) {
443  RooAbsCategoryLValue::Streamer(R__b);
444 
445  // In v2, properties were written directly into the class buffer
446  auto props = std::make_unique<RooCategorySharedProperties>();
447  props->Streamer(R__b);
448  installLegacySharedProp(props.get());
449 
450  } else {
451  // Starting at v3, ranges are shared using a shared pointer, which cannot be read by ROOT's I/O.
452  // Instead, ranges are written as a normal pointer, and here we restore the sharing.
453  R__b.ReadClassBuffer(RooCategory::Class(), this, R__v, R__s, R__c);
454  installSharedRange(std::unique_ptr<RangeMap_t>(_rangesPointerForIO));
455  _rangesPointerForIO = nullptr;
456  }
457 
458  R__b.CheckByteCount(R__s, R__c, RooCategory::IsA());
459 
460  } else {
461  // Since we cannot write shared pointers yet, assign the shared ranges to a normal pointer,
462  // write, and restore.
463  if (_ranges)
465 
466  R__b.WriteClassBuffer(RooCategory::Class(), this);
467  _rangesPointerForIO = nullptr;
468  }
469 }
470 
471 
472 /// When reading old versions of the class, we get instances of shared properties.
473 /// Since these only contain ranges with numbers, just convert to vectors of numbers.
475  if (props == nullptr || (*props == RooCategorySharedProperties("00000000-0000-0000-0000-000000000000")))
476  return;
477 
478  auto& weakPtr = _uuidToSharedRangeIOHelper[props->asString().Data()];
479  if (auto existingObject = weakPtr.lock()) {
480  // We know this range, start sharing
481  _ranges = std::move(existingObject);
482  } else {
483  // This range is unknown, make a new object
484  _ranges = std::make_shared<std::map<std::string, std::vector<value_type>>>();
485  auto& rangesMap = *_ranges;
486 
487  // Copy the data:
488  std::unique_ptr<TIterator> iter(props->_altRanges.MakeIterator());
489  while (TList* olist = (TList*)iter->Next()) {
490  std::vector<value_type>& vec = rangesMap[olist->GetName()];
491 
492 
493  std::unique_ptr<TIterator> citer(olist->MakeIterator());
494  while (RooCatType* ctype = (RooCatType*)citer->Next()) {
495  vec.push_back(ctype->getVal());
496  }
497  }
498 
499  // Register the shared_ptr for future sharing
500  weakPtr = _ranges;
501  }
502 }
503 
504 
505 /// In current versions of the class, a map with ranges can be shared between instances.
506 /// If an instance with the same name alreday uses the same map, the instances will start sharing.
507 /// Otherwise, this instance will be registered, and future copies being read will share with this
508 /// one.
509 void RooCategory::installSharedRange(std::unique_ptr<RangeMap_t>&& rangeMap) {
510  if (rangeMap == nullptr)
511  return;
512 
513  auto checkRangeMapsEqual = [](const RooCategory::RangeMap_t& a, const RooCategory::RangeMap_t& b) {
514  if (&a == &b)
515  return true;
516 
517  if (a.size() != b.size())
518  return false;
519 
520  auto vecsEqual = [](const std::vector<RooAbsCategory::value_type>& aa, const std::vector<RooAbsCategory::value_type>& bb) {
521  return aa.size() == bb.size() && std::equal(aa.begin(), aa.end(), bb.begin());
522  };
523 
524  for (const auto& itemA : a) {
525  const auto itemB = b.find(itemA.first);
526  if (itemB == b.end())
527  return false;
528 
529  if (!vecsEqual(itemA.second, itemB->second))
530  return false;
531  }
532 
533  return true;
534  };
535 
536 
537  auto& weakPtr = _sharedRangeIOHelper[GetName()];
538  auto existingMap = weakPtr.lock();
539  if (existingMap && checkRangeMapsEqual(*rangeMap, *existingMap)) {
540  // We know this map, use the shared one.
541  _ranges = std::move(existingMap);
542  if (rangeMap.get() == existingMap.get()) {
543  // This happens when ROOT's IO has written the same pointer twice. We cannot delete now.
544  (void) rangeMap.release(); // clang-tidy is normally right that this leaks. Here, we need to leave the result unused, though.
545  }
546  } else {
547  // We don't know this map. Register for sharing.
548  _ranges = std::move(rangeMap);
549  weakPtr = _ranges;
550  }
551 }
RooStreamParser.h
RooCategory::~RooCategory
virtual ~RooCategory()
Destructor.
Definition: RooCategory.cxx:150
RooLinkedList::MakeIterator
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
Definition: RooLinkedList.cxx:747
RooHelpers.h
RooSharedProperties::asString
TString asString() const
Definition: RooSharedProperties.h:56
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
Version_t
short Version_t
Definition: RtypesCore.h:65
RooMsgService.h
RooCategory::setRange
void setRange(const char *rangeName, const char *stateNameList)
Definition: RooCategory.cxx:330
RooFit.h
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:68
RooArgSet.h
RooCategory::defineTypes
void defineTypes(const std::map< std::string, int > &allowedStates)
Define multiple states in a single call.
Definition: RooCategory.cxx:243
TString::Data
const char * Data() const
Definition: TString.h:369
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
RooCategory::RooCategory
RooCategory()
Definition: RooCategory.cxx:103
RooCategory::installLegacySharedProp
void installLegacySharedProp(const RooCategorySharedProperties *sp)
When reading old versions of the class, we get instances of shared properties.
Definition: RooCategory.cxx:474
TBuffer::ReadClassBuffer
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
RooCategorySharedProperties
Definition: RooCategorySharedProperties.h:22
RooCategory::RangeMap_t
std::map< std::string, std::vector< value_type > > RangeMap_t
Definition: RooCategory.h:131
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooCategory::operator[]
value_type & operator[](const std::string &stateName)
Access a named state.
Definition: RooCategory.cxx:255
coutW
#define coutW(a)
Definition: RooMsgService.h:32
RooCategory::clearRange
void clearRange(const char *name, Bool_t silent)
Clear the named range.
Definition: RooCategory.cxx:315
RooAbsCategory::invalidCategory
static const decltype(_stateNames) ::value_type & invalidCategory()
Is this category attached to a tree?
RooCategory::installSharedRange
void installSharedRange(std::unique_ptr< RangeMap_t > &&rangeMap)
In current versions of the class, a map with ranges can be shared between instances.
Definition: RooCategory.cxx:509
RooAbsCategory::defineState
virtual const std::map< std::string, RooAbsCategory::value_type >::value_type & defineState(const std::string &label)
Define a new state with given label.
Definition: RooAbsCategory.cxx:213
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
coutI
#define coutI(a)
Definition: RooMsgService.h:30
TList.h
TBuffer
Definition: TBuffer.h:43
RooStreamParser::readToken
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
Definition: RooStreamParser.cxx:129
TBuffer::CheckByteCount
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
TString
Definition: TString.h:136
RooAbsCategory::getCurrentLabel
virtual const char * getCurrentLabel() const
Return label string of current state.
Definition: RooAbsCategory.cxx:130
b
#define b(i)
Definition: RSha256.hxx:118
TString.h
RooCategory::defineType
bool defineType(const std::string &label)
Define a state with given name.
Definition: RooCategory.cxx:208
RooCategorySharedProperties::_altRanges
RooLinkedList _altRanges
Definition: RooCategorySharedProperties.h:50
bool
RooCategorySharedProperties.h
RooTrace.h
RooAbsCategory::end
std::map< std::string, value_type >::const_iterator end() const
Iterator for category state names. Points to pairs of index and name.
Definition: RooAbsCategory.h:104
RooAbsCategory::hasIndex
bool hasIndex(value_type index) const
Check if a state with index index exists.
Definition: RooAbsCategory.cxx:188
RooStreamParser
Definition: RooStreamParser.h:21
RooCategory::setLabel
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Definition: RooCategory.cxx:185
TBuffer.h
TRACE_DESTROY
#define TRACE_DESTROY
Definition: RooTrace.h:24
RooCategory::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact) const override
compact only at the moment
Definition: RooCategory.cxx:300
RooAbsCategory::nextAvailableStateIndex
value_type nextAvailableStateIndex() const
Definition: RooAbsCategory.cxx:684
a
auto * a
Definition: textangle.C:12
TBuffer::WriteClassBuffer
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
RooCategory::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE) override
Read object contents from given stream.
Definition: RooCategory.cxx:286
RooAbsCategory::_currentIndex
value_type _currentIndex
Definition: RooAbsCategory.h:219
RooCategory::states
std::map< std::string, RooAbsCategory::value_type > & states()
Return a reference to the map of state names to index states.
Definition: RooCategory.cxx:274
TRACE_CREATE
#define TRACE_CREATE
Definition: RooTrace.h:23
RooCategory.h
RooCategory::_ranges
std::shared_ptr< RangeMap_t > _ranges
Map range names to allowed category states.
Definition: RooCategory.h:134
TBuffer::ReadVersion
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
void
typedef void((*Func_t)())
unsigned int
RooHelpers::tokenise
std::vector< std::string > tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken=true)
Tokenise the string by splitting at the characters in delims.
Definition: RooHelpers.cxx:74
RooAbsCategory::_insertionOrder
std::vector< std::string > _insertionOrder
Map state names to index numbers. Make sure state names are updated in recomputeShape().
Definition: RooAbsCategory.h:221
RooCategory::addToRange
void addToRange(const char *rangeName, RooAbsCategory::value_type stateIndex)
Add the given state to the given range.
Definition: RooCategory.cxx:342
TBuffer::IsReading
Bool_t IsReading() const
Definition: TBuffer.h:86
RooCategory::_uuidToSharedRangeIOHelper
static std::map< std::string, std::weak_ptr< RangeMap_t > > _uuidToSharedRangeIOHelper
Definition: RooCategory.h:140
RooAbsArg::setShapeDirty
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
Definition: RooAbsArg.h:510
RooCategory::_rangesPointerForIO
RangeMap_t * _rangesPointerForIO
Definition: RooCategory.h:135
RooCategory
Definition: RooCategory.h:27
RooAbsCategory::lookupIndex
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
Definition: RooAbsCategory.cxx:283
name
char name[80]
Definition: TGX11.cxx:110
RooCategory::isStateInRange
Bool_t isStateInRange(const char *rangeName, RooAbsCategory::value_type stateIndex) const
Check if the state is in the given range.
Definition: RooCategory.cxx:390
RooAbsCategory::stateNames
const std::map< std::string, value_type > & stateNames() const
Access the map of state names to index numbers.
Definition: RooAbsCategory.h:162
RooCatType
Definition: RooCatTypeLegacy.h:23
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsArg::setValueDirty
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:505
RMakeUnique.hxx
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
RooAbsCategoryLValue
Definition: RooAbsCategoryLValue.h:25
RooCatTypeLegacy.h
Class
void Class()
Definition: Class.C:29
RooCategory::getCurrentIndex
virtual value_type getCurrentIndex() const override final
Return current index.
Definition: RooCategory.h:39
RooFit::Contents
@ Contents
Definition: RooGlobalFunc.h:69
TGeant4Unit::second
static constexpr double second
Definition: TGeant4SystemOfUnits.h:157
TList
Definition: TList.h:44
RooCategory::_sharedRangeIOHelper
static std::map< std::string, std::weak_ptr< RangeMap_t > > _sharedRangeIOHelper
Definition: RooCategory.h:142
int