#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <stdlib.h>
#include <stdio.h>
#include "TString.h"
#include "RooThresholdCategory.h"
#include "RooStreamParser.h"
#include "RooThreshEntry.h"
#include "RooMsgService.h"
ClassImp(RooThresholdCategory)
RooThresholdCategory::RooThresholdCategory(const char *name, const char *title, RooAbsReal& inputVar,
const char* defOut, Int_t defIdx) :
RooAbsCategory(name, title), _inputVar("inputVar","Input category",this,inputVar)
{
_defCat = (RooCatType*) defineType(defOut,defIdx) ;
_threshIter = _threshList.MakeIterator() ;
}
RooThresholdCategory::RooThresholdCategory(const RooThresholdCategory& other, const char *name) :
RooAbsCategory(other,name), _inputVar("inputVar",this,other._inputVar)
{
_defCat = (RooCatType*) lookupType(other._defCat->GetName()) ;
other._threshIter->Reset() ;
RooThreshEntry* te ;
while((te=(RooThreshEntry*)other._threshIter->Next())) {
_threshList.Add(new RooThreshEntry(*te)) ;
}
_threshIter = _threshList.MakeIterator() ;
}
RooThresholdCategory::~RooThresholdCategory()
{
_threshList.Delete() ;
delete _threshIter ;
}
Bool_t RooThresholdCategory::addThreshold(Double_t upperLimit, const char* catName, Int_t catIdx)
{
_threshIter->Reset() ;
RooThreshEntry* te ;
while ((te=(RooThreshEntry*)_threshIter->Next())) {
if (te->thresh() == upperLimit) {
coutW(InputArguments) << "RooThresholdCategory::addThreshold(" << GetName()
<< ") threshold at " << upperLimit << " already defined" << endl ;
return kTRUE ;
}
}
const RooCatType* type = lookupType(catName,kFALSE) ;
if (!type) {
if (catIdx==-99999) {
type=defineType(catName) ;
} else {
type=defineType(catName,catIdx) ;
}
}
te = new RooThreshEntry(upperLimit,*type) ;
_threshList.Add(te) ;
return kFALSE ;
}
RooCatType
RooThresholdCategory::evaluate() const
{
_threshIter->Reset() ;
RooThreshEntry* te ;
while((te=(RooThreshEntry*)_threshIter->Next())) {
if (_inputVar<te->thresh()) return te->cat() ;
}
return *_defCat ;
}
void RooThresholdCategory::writeToStream(ostream& os, Bool_t compact) const
{
if (compact) {
os << getLabel() ;
} else {
_threshIter->Reset() ;
RooThreshEntry* te ;
while((te=(RooThreshEntry*)_threshIter->Next())) {
os << te->cat().GetName() << ":<" << te->thresh() << " " ;
}
os << _defCat->GetName() << ":*" ;
}
}
void RooThresholdCategory::printToStream(ostream& os, PrintOption opt, TString indent) const
{
RooAbsCategory::printToStream(os,opt,indent);
if (opt > Standard) {
os << indent << "--- RooThresholdCategory ---" << endl
<< indent << " Maps from " ;
_inputVar.arg().printToStream(os,Standard);
os << indent << " Threshold list" << endl ;
_threshIter->Reset() ;
RooThreshEntry* te ;
while((te=(RooThreshEntry*)_threshIter->Next())) {
os << indent << " input < " << te->thresh() << " --> " ;
te->cat().printToStream(os,OneLine) ;
}
os << indent << " Default value is ";
_defCat->printToStream(os,OneLine);
}
}
Last update: Thu Jan 17 08:46:04 2008
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.