// Class RooBinningCategory provides a real-to-category mapping defined
// by a series of thresholds.
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <stdlib.h>
#include <stdio.h>
#include "TString.h"
#include "RooBinningCategory.h"
#include "RooStreamParser.h"
#include "RooThreshEntry.h"
#include "RooMsgService.h"
ClassImp(RooBinningCategory)
RooBinningCategory::RooBinningCategory(const char *name, const char *title, RooAbsRealLValue& inputVar,
const char* binningName) :
RooAbsCategory(name, title), _inputVar("inputVar","Input category",this,inputVar), _bname(binningName)
{
initialize() ;
}
RooBinningCategory::RooBinningCategory(const RooBinningCategory& other, const char *name) :
RooAbsCategory(other,name), _inputVar("inputVar",this,other._inputVar), _bname(other._bname)
{
}
RooBinningCategory::~RooBinningCategory()
{
}
void RooBinningCategory::initialize()
{
Int_t nbins = ((RooAbsRealLValue&)_inputVar.arg()).getBinning(_bname.Length()>0?_bname.Data():0).numBins() ;
for (Int_t i=0 ; i<nbins ; i++) {
string name = (_bname.Length()>0) ? Form("%s_%s_bin%d",_inputVar.arg().GetName(),_bname.Data(),i)
: Form("%s_bin%d",_inputVar.arg().GetName(),i) ;
defineType(name.c_str(),i) ;
}
}
RooCatType RooBinningCategory::evaluate() const
{
Int_t ibin = ((RooAbsRealLValue&)_inputVar.arg()).getBin(_bname.Length()>0?_bname.Data():0) ;
const RooCatType* cat = lookupType(ibin) ;
if (!cat) {
string name = (_bname.Length()>0) ? Form("%s_%s_bin%d",_inputVar.arg().GetName(),_bname.Data(),ibin)
: Form("%s_bin%d",_inputVar.arg().GetName(),ibin) ;
cat = const_cast<RooBinningCategory*>(this)->defineType(name.c_str(),ibin) ;
}
return *cat ;
}
void RooBinningCategory::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent) const
{
RooAbsCategory::printMultiline(os,content,verbose,indent);
if (verbose) {
os << indent << "--- RooBinningCategory ---" << endl
<< indent << " Maps from " ;
_inputVar.arg().printStream(os,kName|kValue,kSingleLine);
}
}
Last change: Mon Aug 25 11:35:14 2008
Last generated: 2008-08-25 11:35
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.