44using std::string, std::endl, std::ios, std::list, std::ofstream;
67 std::unique_ptr<TFile>
f{
TFile::Open(studyPackFileName,
"READ")};
98 coutP(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") opening PROOF session" << endl ;
99 void*
p =
reinterpret_cast<void*
>(
gROOT->ProcessLineFast(
Form(
"TProof::Open(\"%s\")",proofHost)));
103 coutE(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") ERROR initializing proof, aborting" << endl ;
109 gROOT->ProcessLineFast(
Form(
"((TProof*)0x%zx)->SetProgressDialog(0) ;",
reinterpret_cast<size_t>(
p))) ;
113 coutP(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") sending work package to PROOF servers" << endl ;
114 gROOT->ProcessLineFast(
Form(
"((TProof*)0x%zx)->AddInput((TObject*)0x%zx) ;",
reinterpret_cast<size_t>(
p),
reinterpret_cast<size_t>(
_pkg)) ) ;
117 coutP(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") starting PROOF processing of " << nExperiments <<
" experiments" << endl ;
119 gROOT->ProcessLineFast(
Form(
"((TProof*)0x%zx)->Process(\"RooProofDriverSelector\",%d) ;",
reinterpret_cast<size_t>(
p),nExperiments)) ;
122 coutP(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") aggregating results data" << endl ;
123 TList* olist =
reinterpret_cast<TList*
>(
gROOT->ProcessLineFast(
Form(
"((TProof*)0x%zx)->GetOutputList()",
reinterpret_cast<size_t>(
p))));
127 coutP(Generation) <<
"RooStudyManager::runProof(" <<
GetName() <<
") cleaning up input list" << endl ;
128 gROOT->ProcessLineFast(
Form(
"((TProof*)0x%zx)->GetInputList()->Remove((TObject*)0x%zx) ;",
reinterpret_cast<size_t>(
p),
reinterpret_cast<size_t>(
_pkg)) ) ;
142 if (
gROOT->GetListOfProofs()->LastIndex() != -1 &&
gROOT->ProcessLineFast(
"gProof;"))
145 gROOT->ProcessLineFast(
"gProof->CloseProgressDialog() ;") ;
149 if (
gROOT->GetListOfProofs()->LastIndex() != -1 &&
gROOT->ProcessLineFast(
"gProof;")) {
150 gROOT->ProcessLineFast(
"delete gProof ;") ;
153 ooccoutI(
nullptr,Generation) <<
"RooStudyManager: No global Proof objects. No connections closed." << endl ;
163 TFile f(
Form(
"study_data_%s.root",studyName),
"RECREATE") ;
170 ofstream bdr(
Form(
"study_driver_%s.sh",studyName)) ;
171 bdr <<
"#!/bin/sh" << endl
172 <<
Form(
"if [ ! -f study_data_%s.root ] ; then",studyName) << endl
173 <<
"uudecode <<EOR" << endl ;
177 gSystem->
Exec(
Form(
"cat study_data_%s.root | uuencode -m study_data_%s.root >> study_driver_%s.sh",studyName,studyName,studyName)) ;
180 ofstream bdr2 (
Form(
"study_driver_%s.sh",studyName),ios::app) ;
181 bdr2 <<
"EOR" << endl
183 <<
"root -l -b <<EOR" << endl
184 <<
Form(
"RooStudyPackage::processFile(\"%s\",%d) ;",studyName,nExpPerJob) << endl
190 coutI(DataHandling) <<
"RooStudyManager::prepareBatchInput batch driver file is '" <<
Form(
"study_driver_%s.sh",studyName) <<
"," << endl
191 <<
" input data files is embedded in driver script" << endl ;
195 ofstream bdr(
Form(
"study_driver_%s.sh",studyName)) ;
196 bdr <<
"#!/bin/sh" << endl
197 <<
"root -l -b <<EOR" << endl
198 <<
Form(
"RooStudyPackage::processFile(\"%s\",%d) ;",studyName,nExpPerJob) << endl
202 coutI(DataHandling) <<
"RooStudyManager::prepareBatchInput batch driver file is '" <<
Form(
"study_driver_%s.sh",studyName) <<
"," << endl
203 <<
" input data file is " <<
Form(
"study_data_%s.root",studyName) << endl ;
220 for (list<string>::iterator iter = flist.begin() ; iter!=flist.end() ; ++iter) {
221 coutP(DataHandling) <<
"RooStudyManager::processBatchOutput() now reading file " << *iter << endl ;
224 for(
auto * key : static_range_cast<TKey*>(*
f.GetListOfKeys())) {
225 TObject * obj =
f.Get(key->GetName()) ;
239 (*iter)->aggregateSummaryOutput(olist) ;
259 Int_t dotslashpos = -1;
263 dotslashpos = next_dot;
264 next_dot = basename.
Index(
".root",dotslashpos+1);
266 if (basename[dotslashpos+5]!=
'/') {
274 if (dotslashpos>=0) {
276 behind_dot_root = basename(dotslashpos+6,basename.
Length()-dotslashpos+6);
278 basename.
Remove(dotslashpos+5);
284 directory = basename(0,slashpos);
285 basename.
Remove(0,slashpos+1);
290 TString expand_directory = directory;
300 if (!strcmp(file,
".") || !strcmp(file,
".."))
continue;
302 if ( (basename!=file) && s.
Index(re) ==
kNPOS)
continue;
310 while ((obj =
static_cast<TObjString*
>(next()))) {
312 if (behind_dot_root.
Length() != 0) {
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
Abstract base class for RooStudyManager modules.
Utility class to manage studies that consist of repeated applications of generate-and-fit operations ...
void runProof(Int_t nExperiments, const char *proofHost="", bool showGui=true)
Open PROOF-Lite session.
void expandWildCardSpec(const char *spec, std::list< std::string > &result)
case with one single file
void run(Int_t nExperiments)
void processBatchOutput(const char *filePat)
void addStudy(RooAbsStudy &study)
static void closeProof(Option_t *option="s")
"Option_t *option" takes the parameters forwarded to gProof->Close(option).
void prepareBatchInput(const char *studyName, Int_t nExpPerJob, bool unifiedInput)
RooStudyManager(RooWorkspace &w)
void aggregateData(TList *olist)
Utility class to manage studies that consist of repeated applications of generate-and-fit operations ...
void driver(Int_t nExperiments)
void addStudy(RooAbsStudy &study)
std::list< RooAbsStudy * > & studies()
Persistable container for RooFit projects.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
const char * GetName() const override
Returns name of object.
Collectable string class.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void Delete(Option_t *option="")
Delete this object.
Regular expression class.
const char * Data() const
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
virtual const char * WorkingDirectory()
Return working directory.
virtual int Unlink(const char *name)
Unlink, i.e.