Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 
39 ClassImp(RooAbsStudy);
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 
65 RooAbsStudy::~RooAbsStudy()
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 
94 void RooAbsStudy::storeSummaryOutput(const RooArgSet& vars)
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 
107 void RooAbsStudy::storeDetailedOutput(TNamed& object)
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 
129 void RooAbsStudy::aggregateSummaryOutput(TList* chunkList)
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 }