47 Roo1DTable::Roo1DTable(
const char *name,
const char *title,
const RooAbsCategory& cat) :
48 RooTable(name,title), _total(0), _nOverflow(0)
52 TIterator* tIter = cat.typeIterator() ;
54 while (((type = (RooCatType*)tIter->Next()))) {
55 _types.Add(
new RooCatType(*type)) ;
62 for (
int i=0 ; i<nbin ; i++) _count[i] = 0 ;
70 Roo1DTable::Roo1DTable(
const Roo1DTable& other) :
71 RooTable(other), _count(other._count), _total(other._total), _nOverflow(other._nOverflow)
76 for (i=0 ; i<other._types.GetEntries() ; i++) {
77 _types.Add(
new RooCatType(*(RooCatType*)other._types.At(i))) ;
87 Roo1DTable::~Roo1DTable()
101 void Roo1DTable::fill(RooAbsCategory& cat, Double_t weight)
103 if (weight==0) return ;
108 for (
int i=0 ; i<_types.GetEntries() ; i++) {
109 RooCatType* entry = (RooCatType*) _types.At(i) ;
110 if (cat.getIndex()==entry->getVal()) {
111 _count[i] += weight ; ;
118 _nOverflow += weight ;
127 void Roo1DTable::printName(ostream& os)
const
137 void Roo1DTable::printTitle(ostream& os)
const
147 void Roo1DTable::printClassName(ostream& os)
const
149 os << IsA()->GetName() ;
157 void Roo1DTable::printValue(ostream& os)
const
160 for (Int_t i=0 ; i<_types.GetEntries() ; i++) {
161 RooCatType* entry = (RooCatType*) _types.At(i) ;
166 os << entry->GetName() <<
"=" << _count[i] ;
178 Int_t Roo1DTable::defaultPrintContents(Option_t* )
const
180 return kName|kClassName|kValue|kArgs ;
188 void Roo1DTable::printMultiline(ostream& os, Int_t , Bool_t verbose, TString indent)
const
190 os << indent << endl ;
191 os << indent <<
" Table " << GetName() <<
" : " << GetTitle() << endl ;
194 Int_t labelWidth(0) ;
195 Double_t maxCount(1) ;
198 for (i=0 ; i<_types.GetEntries() ; i++) {
199 RooCatType* entry = (RooCatType*) _types.At(i) ;
203 Int_t lwidth = strlen(entry->GetName());
204 labelWidth = lwidth > labelWidth ? lwidth : labelWidth;
205 maxCount=_count[i]>maxCount?_count[i]:maxCount ;
209 labelWidth=labelWidth>8?labelWidth:8 ;
210 maxCount=maxCount>_nOverflow?maxCount:_nOverflow ;
214 Int_t countWidth=((Int_t)log10(maxCount))+1 ;
215 os << indent <<
" +-" << setw(labelWidth) << setfill(
'-') <<
"-" <<
"-+-" << setw(countWidth) <<
"-" <<
"-+" << endl ;
219 for (i=0 ; i<_types.GetEntries() ; i++) {
220 RooCatType* entry = (RooCatType*) _types.At(i) ;
221 if (_count[i]>0 || verbose) {
222 os <<
" | " << setw(labelWidth) << entry->GetName() <<
" | " << setw(countWidth) << _count[i] <<
" |" << endl ;
228 os << indent <<
" +-" << setw(labelWidth) << setfill(
'-') <<
"-" <<
"-+-" << setw(countWidth) <<
"-" <<
"-+" << endl ;
229 os << indent <<
" | " <<
"Overflow" <<
" | " << setw(countWidth) << _nOverflow <<
" |" << endl ;
233 os << indent <<
" +-" << setw(labelWidth) << setfill(
'-') <<
"-" <<
"-+-" << setw(countWidth) <<
"-" <<
"-+" << endl ;
235 os << indent << endl ;
244 Double_t Roo1DTable::get(
const char* label, Bool_t silent)
const
247 TObject* cat = _types.FindObject(label) ;
250 coutE(InputArguments) <<
"Roo1DTable::get: ERROR: no such entry: " << label << endl ;
254 return _count[_types.IndexOf(cat)] ;
263 Double_t Roo1DTable::get(
const int index, Bool_t silent)
const
265 const RooCatType* cat = 0;
267 for (; i < _types.GetEntries(); ++i) {
268 cat =
static_cast<const RooCatType*
>(_types[i]);
269 if (cat->getVal() == index) {
277 coutE(InputArguments) <<
"Roo1DTable::get: ERROR: no such entry: " << index << endl ;
289 Double_t Roo1DTable::getOverflow()
const
301 Double_t Roo1DTable::getFrac(
const char* label, Bool_t silent)
const
304 return get(label,silent) / _total ;
306 if (!silent) coutW(Contents) <<
"Roo1DTable::getFrac: WARNING table empty, returning 0" << endl ;
318 Double_t Roo1DTable::getFrac(
const int index, Bool_t silent)
const
321 return get(index, silent) / _total ;
323 if (!silent) coutW(Contents) <<
"Roo1DTable::getFrac: WARNING table empty, returning 0" << endl ;
333 Bool_t Roo1DTable::isIdentical(
const RooTable& other)
335 const Roo1DTable* other1d = &
dynamic_cast<const Roo1DTable&
>(other) ;
342 for (i=0 ; i<_types.GetEntries() ; i++) {
344 if (_count[i] != other1d->_count[i]) {