Loading [MathJax]/extensions/tex2jax.js
ROOT  6.06/09
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 //
19 // BEGIN_HTML
20 // RooAbsStudy is an abstract base class for RooStudyManager modules
21 //
22 // END_HTML
23 //
24 
25 
26 
27 #include "RooFit.h"
28 #include "Riostream.h"
29 
30 #include "RooAbsStudy.h"
31 #include "RooMsgService.h"
32 #include "RooDataSet.h"
33 #include "TList.h"
34 #include "TClass.h"
35 
36 using namespace std ;
37 
39  ;
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Constructor
44 
45 RooAbsStudy::RooAbsStudy(const char* name, const char* title) : TNamed(name,title), _storeDetails(0), _summaryData(0), _detailData(0), _ownDetailData(kTRUE)
46 {
47 }
48 
49 
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Copy constructor
53 
54 RooAbsStudy::RooAbsStudy(const RooAbsStudy& other) : TNamed(other), _storeDetails(other._storeDetails), _summaryData(other._summaryData),
55  _detailData(0), _ownDetailData(other._ownDetailData)
56 {
57 }
58 
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Destructor
63 
65 {
66  if (_summaryData) delete _summaryData ;
67  if (_ownDetailData && _detailData) {
68  _detailData->Delete() ;
69  delete _detailData ;
70  }
71 }
72 
73 
74 
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 
78 void RooAbsStudy::registerSummaryOutput(const RooArgSet& allVars, const RooArgSet& varsWithError, const RooArgSet& varsWithAsymError)
79 {
80  if (_summaryData) {
81  coutW(ObjectHandling) << "RooAbsStudy::registerSummaryOutput(" << GetName() << ") WARNING summary output already registered" << endl ;
82  return ;
83  }
84 
85  string name = Form("%s_summary_data",GetName()) ;
86  string title = Form("%s Summary Data",GetTitle()) ;
87  _summaryData = new RooDataSet(name.c_str(),title.c_str(),allVars,RooFit::StoreError(varsWithError),RooFit::StoreAsymError(varsWithAsymError)) ;
88 }
89 
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 
94 {
95  if (!_summaryData) {
96  coutE(ObjectHandling) << "RooAbsStudy::storeSummaryOutput(" << GetName() << ") ERROR: no summary output data configuration registered" << endl ;
97  return ;
98  }
99  _summaryData->add(vars) ;
100 }
101 
102 
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 
107 {
108  if (_storeDetails) {
109 
110  if (!_detailData) {
111  _detailData = new RooLinkedList ;
112  _detailData->SetName(TString::Format("%s_detailed_data_list",GetName())) ;
113  //cout << "RooAbsStudy::ctor() detailData name = " << _detailData->GetName() << endl ;
114  }
115 
116  object.SetName(TString::Format("%s_detailed_data_%d",GetName(),_detailData->GetSize())) ;
117  //cout << "storing detailed data with name " << object.GetName() << endl ;
118  _detailData->Add(&object) ;
119  } else {
120  delete &object ;
121  }
122 }
123 
124 
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 
129 {
130  if (!chunkList) return ;
131 
132  TIterator* iter = chunkList->MakeIterator() ;
133  TObject* obj ;
134  while((obj=iter->Next())) {
135 
136  //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") processing object " << obj->GetName() << endl ;
137 
138  RooDataSet* data = dynamic_cast<RooDataSet*>(obj) ;
139  if (data) {
140  if (TString(data->GetName()).BeginsWith(Form("%s_summary_data",GetName()))) {
141  //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found summary block " << data->GetName() << endl ;
142  if (!_summaryData) {
143  _summaryData = (RooDataSet*) data->Clone(Form("%s_summary_data",GetName())) ;
144  } else {
145  _summaryData->append(*data) ;
146  }
147  }
148  }
149 
150  RooLinkedList* dlist = dynamic_cast<RooLinkedList*>(obj) ;
151  if (dlist) {
152  if (TString(dlist->GetName()).BeginsWith(Form("%s_detailed_data",GetName()))) {
153  //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found detail block " <<dlist->GetName() << " with " << dlist->GetSize() << " entries" << endl ;
154  TIterator* diter = dlist->MakeIterator() ;
155  TNamed* dobj ;
156  while((dobj=(TNamed*)diter->Next())) {
157  storeDetailedOutput(*dobj) ;
158  }
159  delete diter ;
160  }
161  }
162  }
163 }
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:93
ClassImp(RooAbsStudy)
Basic string class.
Definition: TString.h:137
STL namespace.
#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:2334
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
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
return
Definition: TBase64.cxx:62
char * Form(const char *fmt,...)
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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...
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:78
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:603
Int_t GetSize() const
Definition: RooLinkedList.h:60
virtual ~RooAbsStudy()
Destructor.
Definition: RooAbsStudy.cxx:64
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