Logo ROOT  
Reference Guide
RooAbsStudy.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooAbsStudy.cxx
19\class RooAbsStudy
20\ingroup Roofitcore
21
22RooAbsStudy is an abstract base class for RooStudyManager modules
23
24**/
25
26
27
28#include "RooFit.h"
29#include "Riostream.h"
30
31#include "RooAbsStudy.h"
32#include "RooMsgService.h"
33#include "RooDataSet.h"
34#include "TList.h"
35#include "TClass.h"
36
37using namespace std ;
38
40 ;
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor
45
46RooAbsStudy::RooAbsStudy(const char* name, const char* title) : TNamed(name,title), _storeDetails(0), _summaryData(0), _detailData(0), _ownDetailData(kTRUE)
47{
48}
49
50
51
52////////////////////////////////////////////////////////////////////////////////
53/// Copy constructor
54
55RooAbsStudy::RooAbsStudy(const RooAbsStudy& other) : TNamed(other), _storeDetails(other._storeDetails), _summaryData(other._summaryData),
56 _detailData(0), _ownDetailData(other._ownDetailData)
57{
58}
59
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Destructor
64
66{
67 if (_summaryData) delete _summaryData ;
70 delete _detailData ;
71 }
72}
73
74
75
76
77////////////////////////////////////////////////////////////////////////////////
78
79void RooAbsStudy::registerSummaryOutput(const RooArgSet& allVars, const RooArgSet& varsWithError, const RooArgSet& varsWithAsymError)
80{
81 if (_summaryData) {
82 coutW(ObjectHandling) << "RooAbsStudy::registerSummaryOutput(" << GetName() << ") WARNING summary output already registered" << endl ;
83 return ;
84 }
85
86 string name = Form("%s_summary_data",GetName()) ;
87 string title = Form("%s Summary Data",GetTitle()) ;
88 _summaryData = new RooDataSet(name.c_str(),title.c_str(),allVars,RooFit::StoreError(varsWithError),RooFit::StoreAsymError(varsWithAsymError)) ;
89}
90
91
92////////////////////////////////////////////////////////////////////////////////
93
95{
96 if (!_summaryData) {
97 coutE(ObjectHandling) << "RooAbsStudy::storeSummaryOutput(" << GetName() << ") ERROR: no summary output data configuration registered" << endl ;
98 return ;
99 }
100 _summaryData->add(vars) ;
101}
102
103
104
105////////////////////////////////////////////////////////////////////////////////
106
108{
109 if (_storeDetails) {
110
111 if (!_detailData) {
113 _detailData->SetName(TString::Format("%s_detailed_data_list",GetName())) ;
114 //cout << "RooAbsStudy::ctor() detailData name = " << _detailData->GetName() << endl ;
115 }
116
117 object.SetName(TString::Format("%s_detailed_data_%d",GetName(),_detailData->GetSize())) ;
118 //cout << "storing detailed data with name " << object.GetName() << endl ;
119 _detailData->Add(&object) ;
120 } else {
121 delete &object ;
122 }
123}
124
125
126
127////////////////////////////////////////////////////////////////////////////////
128
130{
131 if (!chunkList) return ;
132
133 TIterator* iter = chunkList->MakeIterator() ;
134 TObject* obj ;
135 while((obj=iter->Next())) {
136
137 //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") processing object " << obj->GetName() << endl ;
138
139 RooDataSet* data = dynamic_cast<RooDataSet*>(obj) ;
140 if (data) {
141 if (TString(data->GetName()).BeginsWith(Form("%s_summary_data",GetName()))) {
142 //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found summary block " << data->GetName() << endl ;
143 if (!_summaryData) {
144 _summaryData = (RooDataSet*) data->Clone(Form("%s_summary_data",GetName())) ;
145 } else {
146 _summaryData->append(*data) ;
147 }
148 }
149 }
150
151 RooLinkedList* dlist = dynamic_cast<RooLinkedList*>(obj) ;
152 if (dlist) {
153 if (TString(dlist->GetName()).BeginsWith(Form("%s_detailed_data",GetName()))) {
154 //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found detail block " <<dlist->GetName() << " with " << dlist->GetSize() << " entries" << endl ;
155 TIterator* diter = dlist->MakeIterator() ;
156 TNamed* dobj ;
157 while((dobj=(TNamed*)diter->Next())) {
158 storeDetailedOutput(*dobj) ;
159 }
160 delete diter ;
161 }
162 }
163 }
164}
#define coutW(a)
Definition: RooMsgService.h:32
#define coutE(a)
Definition: RooMsgService.h:33
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
char name[80]
Definition: TGX11.cxx:109
char * Form(const char *fmt,...)
RooAbsStudy is an abstract base class for RooStudyManager modules.
Definition: RooAbsStudy.h:33
void storeSummaryOutput(const RooArgSet &vars)
Definition: RooAbsStudy.cxx:94
void storeDetailedOutput(Bool_t flag)
Definition: RooAbsStudy.h:47
virtual ~RooAbsStudy()
Destructor.
Definition: RooAbsStudy.cxx:65
void aggregateSummaryOutput(TList *chunkList)
Bool_t _storeDetails
Definition: RooAbsStudy.h:67
RooDataSet * _summaryData
Definition: RooAbsStudy.h:68
Bool_t _ownDetailData
Definition: RooAbsStudy.h:70
void registerSummaryOutput(const RooArgSet &allVars, const RooArgSet &varsWithError=RooArgSet(), const RooArgSet &varsWithAsymError=RooArgSet())
Definition: RooAbsStudy.cxx:79
RooLinkedList * _detailData
Definition: RooAbsStudy.h:69
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
virtual TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition: RooDataSet.h:68
void append(RooDataSet &data)
Add all data points of given data set to this data set.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
Int_t GetSize() const
Definition: RooLinkedList.h:60
void SetName(const char *name)
Definition: RooLinkedList.h:90
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:89
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
A doubly linked list.
Definition: TList.h:44
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:721
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
RooCmdArg StoreAsymError(const RooArgSet &aset)
RooCmdArg StoreError(const RooArgSet &aset)
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
@ ObjectHandling
Definition: RooGlobalFunc.h:68