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 
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  TIter 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  TIter diter = dlist->MakeIterator() ;
156  TNamed* dobj ;
157  while((dobj=(TNamed*)diter.Next())) {
158  storeDetailedOutput(*dobj) ;
159  }
160  }
161  }
162  }
163 }
RooLinkedList::MakeIterator
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
Definition: RooLinkedList.cxx:731
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooMsgService.h
RooAbsStudy::_summaryData
RooDataSet * _summaryData
Definition: RooAbsStudy.h:68
RooFit.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
RooAbsStudy::storeSummaryOutput
void storeSummaryOutput(const RooArgSet &vars)
Definition: RooAbsStudy.cxx:94
RooLinkedList::GetSize
Int_t GetSize() const
Definition: RooLinkedList.h:62
coutE
#define coutE(a)
Definition: RooMsgService.h:33
coutW
#define coutW(a)
Definition: RooMsgService.h:32
RooLinkedList::GetName
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:91
TClass.h
TList.h
RooDataSet::append
void append(RooDataSet &data)
Add all data points of given data set to this data set.
Definition: RooDataSet.cxx:1360
TString::Format
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:2333
TString
Basic string class.
Definition: TString.h:136
RooDataSet.h
RooAbsStudy::_ownDetailData
Bool_t _ownDetailData
Definition: RooAbsStudy.h:70
RooLinkedList::SetName
void SetName(const char *name)
Definition: RooLinkedList.h:92
object
RooFit::StoreError
RooCmdArg StoreError(const RooArgSet &aset)
Definition: RooGlobalFunc.cxx:140
TList::MakeIterator
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:722
RooDataSet::add
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.
Definition: RooDataSet.cxx:1156
RooAbsStudy.h
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
RooAbsStudy::RooAbsStudy
RooAbsStudy()
Definition: RooAbsStudy.h:36
RooAbsStudy::registerSummaryOutput
void registerSummaryOutput(const RooArgSet &allVars, const RooArgSet &varsWithError=RooArgSet(), const RooArgSet &varsWithAsymError=RooArgSet())
Definition: RooAbsStudy.cxx:79
RooLinkedList
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:37
ROOT::TMetaUtils::BeginsWith
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
Definition: TClingUtils.cxx:5075
TString::BeginsWith
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
RooLinkedList::Add
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:64
RooFit::ObjectHandling
@ ObjectHandling
Definition: RooGlobalFunc.h:61
RooFit::StoreAsymError
RooCmdArg StoreAsymError(const RooArgSet &aset)
Definition: RooGlobalFunc.cxx:142
TIter::Next
TObject * Next()
Definition: TCollection.h:249
RooAbsStudy::~RooAbsStudy
virtual ~RooAbsStudy()
Destructor.
Definition: RooAbsStudy.cxx:65
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsStudy::storeDetailedOutput
void storeDetailedOutput(Bool_t flag)
Definition: RooAbsStudy.h:47
name
char name[80]
Definition: TGX11.cxx:110
TIter
Definition: TCollection.h:233
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooDataSet::Clone
virtual TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition: RooDataSet.h:68
RooAbsStudy::_storeDetails
Bool_t _storeDetails
Definition: RooAbsStudy.h:67
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooAbsStudy::aggregateSummaryOutput
void aggregateSummaryOutput(TList *chunkList)
Definition: RooAbsStudy.cxx:129
Riostream.h
RooAbsStudy::_detailData
RooLinkedList * _detailData
Definition: RooAbsStudy.h:69
RooLinkedList::Delete
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
Definition: RooLinkedList.cxx:575
TList
A doubly linked list.
Definition: TList.h:44
RooAbsStudy
RooAbsStudy is an abstract base class for RooStudyManager modules.
Definition: RooAbsStudy.h:33
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33