ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
22 RooAbsStudy 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 
37 using namespace std ;
38 
40  ;
41 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Constructor
45 
46 RooAbsStudy::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 
55 RooAbsStudy::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 ;
68  if (_ownDetailData && _detailData) {
69  _detailData->Delete() ;
70  delete _detailData ;
71  }
72 }
73 
74 
75 
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 
79 void 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) {
112  _detailData = new RooLinkedList ;
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 }
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:87
#define coutE(a)
Definition: RooMsgService.h:35
RooLinkedList * _detailData
Definition: RooAbsStudy.h:69
void storeSummaryOutput(const RooArgSet &vars)
Definition: RooAbsStudy.cxx:94
ClassImp(RooAbsStudy)
Basic string class.
Definition: TString.h:137
#define coutW(a)
Definition: RooMsgService.h:34
RooDataSet * _summaryData
Definition: RooAbsStudy.h:68
void SetName(const char *name)
Definition: RooLinkedList.h:88
Iterator abstract base class.
Definition: TIterator.h:32
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:2321
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
RooCmdArg StoreError(const RooArgSet &aset)
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
Bool_t _ownDetailData
Definition: RooAbsStudy.h:70
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
A doubly linked list.
Definition: TList.h:47
RooAbsStudy is an abstract base class for RooStudyManager modules.
Definition: RooAbsStudy.h:33
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
return
Definition: TBase64.cxx:62
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
char * Form(const char *fmt,...)
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
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
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements...
void registerSummaryOutput(const RooArgSet &allVars, const RooArgSet &varsWithError=RooArgSet(), const RooArgSet &varsWithAsymError=RooArgSet())
Definition: RooAbsStudy.cxx:79
RooCmdArg StoreAsymError(const RooArgSet &aset)
void append(RooDataSet &data)
Add all data points of given data set to this data set.
void aggregateSummaryOutput(TList *chunkList)
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual TObject * Next()=0
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:604
Int_t GetSize() const
Definition: RooLinkedList.h:60
virtual ~RooAbsStudy()
Destructor.
Definition: RooAbsStudy.cxx:65
Bool_t _storeDetails
Definition: RooAbsStudy.h:67
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
void storeDetailedOutput(Bool_t flag)
Definition: RooAbsStudy.h:47
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooDataSet.h:64