// RooAbsStudy is an abstract base class for RooStudyManager modules
//
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "RooAbsStudy.h"
#include "RooMsgService.h"
#include "RooDataSet.h"
#include "TList.h"
#include "TClass.h"
using namespace std ;
ClassImp(RooAbsStudy)
;
RooAbsStudy::RooAbsStudy(const char* name, const char* title) : TNamed(name,title), _storeDetails(0), _summaryData(0), _detailData(0), _ownDetailData(kTRUE)
{
}
RooAbsStudy::RooAbsStudy(const RooAbsStudy& other) : TNamed(other), _storeDetails(other._storeDetails), _summaryData(other._summaryData),
_detailData(0), _ownDetailData(other._ownDetailData)
{
}
RooAbsStudy::~RooAbsStudy()
{
if (_summaryData) delete _summaryData ;
if (_ownDetailData && _detailData) {
_detailData->Delete() ;
delete _detailData ;
}
}
void RooAbsStudy::registerSummaryOutput(const RooArgSet& allVars, const RooArgSet& varsWithError, const RooArgSet& varsWithAsymError)
{
if (_summaryData) {
coutW(ObjectHandling) << "RooAbsStudy::registerSummaryOutput(" << GetName() << ") WARNING summary output already registered" << endl ;
return ;
}
string name = Form("%s_summary_data",GetName()) ;
string title = Form("%s Summary Data",GetTitle()) ;
_summaryData = new RooDataSet(name.c_str(),title.c_str(),allVars,RooFit::StoreError(varsWithError),RooFit::StoreAsymError(varsWithAsymError)) ;
}
void RooAbsStudy::storeSummaryOutput(const RooArgSet& vars)
{
if (!_summaryData) {
coutE(ObjectHandling) << "RooAbsStudy::storeSummaryOutput(" << GetName() << ") ERROR: no summary output data configuration registered" << endl ;
return ;
}
_summaryData->add(vars) ;
}
void RooAbsStudy::storeDetailedOutput(TNamed& object)
{
if (_storeDetails) {
if (!_detailData) {
_detailData = new RooLinkedList ;
_detailData->SetName(Form("%s_detailed_data",GetName())) ;
}
object.SetName(Form("%s_detailed_data_%d",GetName(),_detailData->GetSize())) ;
_detailData->Add(&object) ;
} else {
delete &object ;
}
}
void RooAbsStudy::aggregateSummaryOutput(TList* chunkList)
{
if (!chunkList) return ;
TIterator* iter = chunkList->MakeIterator() ;
TObject* obj ;
while((obj=iter->Next())) {
RooDataSet* data = dynamic_cast<RooDataSet*>(obj) ;
if (data) {
if (TString(data->GetName()).BeginsWith(Form("%s_summary_data",GetName()))) {
if (!_summaryData) {
_summaryData = (RooDataSet*) data->Clone(Form("%s_summary_data",GetName())) ;
} else {
_summaryData->append(*data) ;
}
}
}
RooLinkedList* dlist = dynamic_cast<RooLinkedList*>(obj) ;
if (dlist) {
if (TString(dlist->GetName()).BeginsWith(Form("%s_detailed_data",GetName()))) {
TIterator* diter = dlist->MakeIterator() ;
TNamed* dobj ;
while((dobj=(TNamed*)diter->Next())) {
storeDetailedOutput(*dobj) ;
}
delete diter ;
}
}
}
}