CMS 3D CMS Logo

Public Member Functions | Public Attributes

CombDataSetFactory Class Reference

#include <CombDataSetFactory.h>

List of all members.

Public Member Functions

void addSetAny (const char *label, RooDataSet *set)
void addSetAny (const char *label, RooDataHist *set)
void addSetBin (const char *label, RooDataHist *set)
 CombDataSetFactory (const RooArgSet &vars, RooCategory &cat)
 CombDataSetFactory ()
RooDataHist * done (const char *name, const char *title)
RooDataSet * doneUnbinned (const char *name, const char *title)
 ~CombDataSetFactory ()

Public Attributes

ClassDef(CombDataSetFactory,
1) private RooCategory * 
cat_
std::map< std::string,
RooDataHist * > 
map_
std::map< std::string,
RooDataSet * > 
mapUB_
RooRealVar * weight_

Detailed Description

Definition at line 20 of file CombDataSetFactory.h.


Constructor & Destructor Documentation

CombDataSetFactory::CombDataSetFactory ( ) [inline]

Definition at line 23 of file CombDataSetFactory.h.

{}
CombDataSetFactory::CombDataSetFactory ( const RooArgSet &  vars,
RooCategory &  cat 
)

Definition at line 6 of file CombDataSetFactory.cc.

                                                                              :
    vars_(vars), cat_(&cat), weight_(0)
{
    if (vars_.contains(cat)) vars_.remove(cat);
}
CombDataSetFactory::~CombDataSetFactory ( )

Definition at line 12 of file CombDataSetFactory.cc.

{}

Member Function Documentation

void CombDataSetFactory::addSetAny ( const char *  label,
RooDataSet *  set 
)

Definition at line 29 of file CombDataSetFactory.cc.

References label, and mapUB_.

                                                                     {
    mapUB_[label] = set;
}
void CombDataSetFactory::addSetAny ( const char *  label,
RooDataHist *  set 
)

Definition at line 18 of file CombDataSetFactory.cc.

References AlCaHLTBitMon_QueryRunRegistry::data, i, label, mapUB_, n, runtimedef::set(), and weight_.

                                                                      {
    if (weight_ == 0) weight_ = new RooRealVar("_weight_","",1);
    RooDataSet *data = new RooDataSet(TString(set->GetName())+"_unbin", "", RooArgSet(*set->get(), *weight_), "_weight_");
    for (int i = 0, n = set->numEntries(); i < n; ++i) {
        const RooArgSet *entry = set->get(i);
        data->add(*entry, set->weight());
    }
    mapUB_[label] = data;
}
void CombDataSetFactory::addSetBin ( const char *  label,
RooDataHist *  set 
)

Definition at line 14 of file CombDataSetFactory.cc.

References label, and map_.

                                                                      {
    map_[label] = set;
}
RooDataHist * CombDataSetFactory::done ( const char *  name,
const char *  title 
)

Definition at line 34 of file CombDataSetFactory.cc.

References cat_, and map_.

                                                                         {
    return new RooDataHist(name,title,vars_,*cat_,map_);
    map_.clear();
}
RooDataSet * CombDataSetFactory::doneUnbinned ( const char *  name,
const char *  title 
)

Definition at line 39 of file CombDataSetFactory.cc.

References cat_, AlCaHLTBitMon_QueryRunRegistry::data, i, mapUB_, n, run_regression::ret, and weight_.

                                                                                {
    using namespace RooFit; 
    RooDataSet *ret = 0;
    if (weight_) {
#if 0   // This works most of the time, but sometimes weights end up wrong.
        // I don't knopw why the @$^#&^# this happens, but it nevertheless 
        // means that I can't use the constructor with the map directly
        //
        for (std::map<std::string, RooDataSet *>::iterator it = mapUB_.begin(), ed = mapUB_.end(); it != ed; ++it) {
            RooDataSet *data = it->second;
            if (!data->isWeighted()) {
                weight_->setVal(1.0);
                data->addColumn(*weight_);
                it->second = new RooDataSet(data->GetName(), data->GetTitle(), data, *data->get(), /*cut=*/(char*)0, weight_->GetName());
            }
            //std::cout << "\n\n\n========== DATASET " << it->first << " =============" << std::endl;
            //utils::printRDH(it->second);
        }
        RooArgSet varsPlusWeight(vars_); varsPlusWeight.add(*weight_);
        ret = new RooDataSet(name,title,varsPlusWeight,Index(*cat_),Import(mapUB_),WeightVar(*weight_));
        //std::cout << "\n\n\n========== COMBINED DATASET =============" << std::endl;
        //utils::printRDH(ret);
#else
        RooArgSet varsPlusCat(vars_); varsPlusCat.add(*cat_);
        RooArgSet varsPlusWeight(varsPlusCat); varsPlusWeight.add(*weight_);
        ret = new RooDataSet(name,title,varsPlusWeight,WeightVar(*weight_));
        for (std::map<std::string, RooDataSet *>::iterator it = mapUB_.begin(), ed = mapUB_.end(); it != ed; ++it) {
            //std::cout << "\n\n\n========== DATASET " << it->first << " =============" << std::endl;
            //utils::printRDH(it->second);
            cat_->setLabel(it->first.c_str());
            RooDataSet *data = it->second;
            for (unsigned int i = 0, n = data->numEntries(); i < n; ++i) {
                varsPlusCat = *data->get(i);
                ret->add(varsPlusCat, data->weight());
            }
        }
        //std::cout << "\n\n\n========== COMBINED DATASET =============" << std::endl;
        //utils::printRDH(ret);
#endif
    } else {
        ret = new RooDataSet(name,title,vars_,Index(*cat_),Import(mapUB_));
    }
    mapUB_.clear();
    return ret;
}

Member Data Documentation

ClassDef (CombDataSetFactory,1) private RooCategory* CombDataSetFactory::cat_

Definition at line 34 of file CombDataSetFactory.h.

Referenced by done(), and doneUnbinned().

std::map<std::string, RooDataHist *> CombDataSetFactory::map_

Definition at line 40 of file CombDataSetFactory.h.

Referenced by addSetBin(), and done().

std::map<std::string, RooDataSet *> CombDataSetFactory::mapUB_

Definition at line 41 of file CombDataSetFactory.h.

Referenced by addSetAny(), and doneUnbinned().

Definition at line 39 of file CombDataSetFactory.h.

Referenced by addSetAny(), and doneUnbinned().