Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22Abstract base class for RooStudyManager modules
23
24**/
25
26#include "Riostream.h"
27
28#include "RooAbsStudy.h"
29#include "RooMsgService.h"
30#include "RooDataSet.h"
31#include "TList.h"
32
33using std::endl;
34
36
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor
40
41RooAbsStudy::RooAbsStudy(const char *name, const char *title) : TNamed(name, title) {}
42
43////////////////////////////////////////////////////////////////////////////////
44/// Copy constructor
45
47 : TNamed(other),
48 _storeDetails(other._storeDetails),
49 _summaryData(other._summaryData),
50 _ownDetailData(other._ownDetailData)
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Destructor
56
58{
59 if (_summaryData) delete _summaryData ;
62 delete _detailData ;
63 }
64}
65
66
67
68
69////////////////////////////////////////////////////////////////////////////////
70
71void RooAbsStudy::registerSummaryOutput(const RooArgSet& allVars, const RooArgSet& varsWithError, const RooArgSet& varsWithAsymError)
72{
73 if (_summaryData) {
74 coutW(ObjectHandling) << "RooAbsStudy::registerSummaryOutput(" << GetName() << ") WARNING summary output already registered" << endl ;
75 return ;
76 }
77
78 std::string name = std::string(GetName()) + "_summary_data";
79 std::string title = std::string(GetTitle()) + " Summary Data";
80 _summaryData = new RooDataSet(name,title,allVars,RooFit::StoreError(varsWithError),RooFit::StoreAsymError(varsWithAsymError)) ;
81}
82
83
84////////////////////////////////////////////////////////////////////////////////
85
87{
88 if (!_summaryData) {
89 coutE(ObjectHandling) << "RooAbsStudy::storeSummaryOutput(" << GetName() << ") ERROR: no summary output data configuration registered" << endl ;
90 return ;
91 }
92 _summaryData->add(vars) ;
93}
94
95
96
97////////////////////////////////////////////////////////////////////////////////
98
99void RooAbsStudy::storeDetailedOutput(std::unique_ptr<TNamed> object)
100{
101 if (!_storeDetails) return;
102
103 if (!_detailData) {
105 _detailData->SetName(TString::Format("%s_detailed_data_list",GetName())) ;
106 //cout << "RooAbsStudy::ctor() detailData name = " << _detailData->GetName() << endl ;
107 }
108
109 object->SetName(TString::Format("%s_detailed_data_%d",GetName(),_detailData->GetSize())) ;
110 //cout << "storing detailed data with name " << object.GetName() << endl ;
111 _detailData->Add(object.release());
112}
113
114
115
116////////////////////////////////////////////////////////////////////////////////
117
119{
120 if (!chunkList) return ;
121
122 for(TObject * obj : *chunkList) {
123
124 //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") processing object " << obj->GetName() << endl ;
125
126 RooDataSet* data = dynamic_cast<RooDataSet*>(obj) ;
127 if (data) {
128 if (TString(data->GetName()).BeginsWith(Form("%s_summary_data",GetName()))) {
129 //cout << "RooAbsStudy::aggregateSummaryOutput(" << GetName() << ") found summary block " << data->GetName() << endl ;
130 if (!_summaryData) {
131 _summaryData = static_cast<RooDataSet*>(data->Clone(Form("%s_summary_data",GetName()))) ;
132 } else {
134 }
135 }
136 }
137
138 if (auto dlist = dynamic_cast<RooLinkedList*>(obj)) {
139 if (TString(dlist->GetName()).BeginsWith(Form("%s_detailed_data",GetName()))) {
140 for(auto * dobj : static_range_cast<TNamed*>(*dlist)) storeDetailedOutput(std::unique_ptr<TNamed>{dobj}) ;
141 }
142 }
143 }
144}
#define coutW(a)
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
Abstract base class for RooStudyManager modules.
Definition RooAbsStudy.h:33
void storeDetailedOutput(bool flag)
Definition RooAbsStudy.h:47
~RooAbsStudy() override
Destructor.
void storeSummaryOutput(const RooArgSet &vars)
bool _ownDetailData
Definition RooAbsStudy.h:70
void aggregateSummaryOutput(TList *chunkList)
RooDataSet * _summaryData
!
Definition RooAbsStudy.h:68
void registerSummaryOutput(const RooArgSet &allVars, const RooArgSet &varsWithError=RooArgSet(), const RooArgSet &varsWithAsymError=RooArgSet())
RooAbsStudy()=default
bool _storeDetails
Definition RooAbsStudy.h:67
RooLinkedList * _detailData
!
Definition RooAbsStudy.h:69
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Container class to hold unbinned data.
Definition RooDataSet.h:57
void append(RooDataSet &data)
Add all data points of given data set to this data set.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
Int_t GetSize() const
void SetName(const char *name)
void Delete(Option_t *o=nullptr) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
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:2378
RooCmdArg StoreAsymError(const RooArgSet &aset)
RooCmdArg StoreError(const RooArgSet &aset)