CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
CombDataSetFactory Class Reference

#include <CombDataSetFactory.h>

Inheritance diagram for CombDataSetFactory:

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 ()
 
 CombDataSetFactory (const RooArgSet &vars, RooCategory &cat)
 
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.

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

Definition at line 6 of file CombDataSetFactory.cc.

6  :
7  vars_(vars), cat_(&cat), weight_(0)
8 {
9  if (vars_.contains(cat)) vars_.remove(cat);
10 }
ClassDef(CombDataSetFactory, 1) private RooCategory * cat_
CombDataSetFactory::~CombDataSetFactory ( )

Definition at line 12 of file CombDataSetFactory.cc.

12 {}

Member Function Documentation

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

Definition at line 29 of file CombDataSetFactory.cc.

References diffTwoXMLs::label, mapUB_, and runtimedef::set().

29  {
30  mapUB_[label] = set;
31 }
std::map< std::string, RooDataSet * > mapUB_
void set(const std::string &name, int value)
set the flag, with a run-time name
void CombDataSetFactory::addSetAny ( const char *  label,
RooDataHist *  set 
)

Definition at line 18 of file CombDataSetFactory.cc.

References data, i, diffTwoXMLs::label, mapUB_, n, and weight_.

18  {
19  if (weight_ == 0) weight_ = new RooRealVar("_weight_","",1);
20  RooDataSet *data = new RooDataSet(TString(set->GetName())+"_unbin", "", RooArgSet(*set->get(), *weight_), "_weight_");
21  for (int i = 0, n = set->numEntries(); i < n; ++i) {
22  const RooArgSet *entry = set->get(i);
23  data->add(*entry, set->weight());
24  }
25  mapUB_[label] = data;
26 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, RooDataSet * > mapUB_
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void set(const std::string &name, int value)
set the flag, with a run-time name
void CombDataSetFactory::addSetBin ( const char *  label,
RooDataHist *  set 
)

Definition at line 14 of file CombDataSetFactory.cc.

References diffTwoXMLs::label, map_, and runtimedef::set().

14  {
15  map_[label] = set;
16 }
std::map< std::string, RooDataHist * > map_
void set(const std::string &name, int value)
set the flag, with a run-time name
RooDataHist * CombDataSetFactory::done ( const char *  name,
const char *  title 
)

Definition at line 34 of file CombDataSetFactory.cc.

References cat_, and map_.

34  {
35  return new RooDataHist(name,title,vars_,*cat_,map_);
36  map_.clear();
37 }
std::map< std::string, RooDataHist * > map_
ClassDef(CombDataSetFactory, 1) private RooCategory * cat_
RooDataSet * CombDataSetFactory::doneUnbinned ( const char *  name,
const char *  title 
)

Definition at line 39 of file CombDataSetFactory.cc.

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

39  {
40  using namespace RooFit;
41  RooDataSet *ret = 0;
42  if (weight_) {
43 #if 0 // This works most of the time, but sometimes weights end up wrong.
44  // I don't knopw why the @$^#&^# this happens, but it nevertheless
45  // means that I can't use the constructor with the map directly
46  //
47  for (std::map<std::string, RooDataSet *>::iterator it = mapUB_.begin(), ed = mapUB_.end(); it != ed; ++it) {
48  RooDataSet *data = it->second;
49  if (!data->isWeighted()) {
50  weight_->setVal(1.0);
51  data->addColumn(*weight_);
52  it->second = new RooDataSet(data->GetName(), data->GetTitle(), data, *data->get(), /*cut=*/(char*)0, weight_->GetName());
53  }
54  //std::cout << "\n\n\n========== DATASET " << it->first << " =============" << std::endl;
55  //utils::printRDH(it->second);
56  }
57  RooArgSet varsPlusWeight(vars_); varsPlusWeight.add(*weight_);
58  ret = new RooDataSet(name,title,varsPlusWeight,Index(*cat_),Import(mapUB_),WeightVar(*weight_));
59  //std::cout << "\n\n\n========== COMBINED DATASET =============" << std::endl;
60  //utils::printRDH(ret);
61 #else
62  RooArgSet varsPlusCat(vars_); varsPlusCat.add(*cat_);
63  RooArgSet varsPlusWeight(varsPlusCat); varsPlusWeight.add(*weight_);
64  ret = new RooDataSet(name,title,varsPlusWeight,WeightVar(*weight_));
65  for (std::map<std::string, RooDataSet *>::iterator it = mapUB_.begin(), ed = mapUB_.end(); it != ed; ++it) {
66  //std::cout << "\n\n\n========== DATASET " << it->first << " =============" << std::endl;
67  //utils::printRDH(it->second);
68  cat_->setLabel(it->first.c_str());
69  RooDataSet *data = it->second;
70  for (unsigned int i = 0, n = data->numEntries(); i < n; ++i) {
71  varsPlusCat = *data->get(i);
72  ret->add(varsPlusCat, data->weight());
73  }
74  }
75  //std::cout << "\n\n\n========== COMBINED DATASET =============" << std::endl;
76  //utils::printRDH(ret);
77 #endif
78  } else {
79  ret = new RooDataSet(name,title,vars_,Index(*cat_),Import(mapUB_));
80  }
81  mapUB_.clear();
82  return ret;
83 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, RooDataSet * > mapUB_
ClassDef(CombDataSetFactory, 1) private RooCategory * cat_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

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().

RooRealVar* CombDataSetFactory::weight_

Definition at line 39 of file CombDataSetFactory.h.

Referenced by addSetAny(), and doneUnbinned().