72#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
176 TNamed(other), _uuid(other._uuid), _classes(other._classes,this), _dir(nullptr), _factory(nullptr), _doExport(
kFALSE), _openTrans(
kFALSE)
184 while((data2=iter->
Next())) {
200 for (map<string,RooArgSet>::const_iterator iter3 = other.
_namedSets.begin() ; iter3 != other.
_namedSets.end() ; ++iter3) {
210 while((gobj=iter4->
Next())) {
262 if (tokens.size() != 3) {
263 std::ostringstream stream;
264 for (
const auto& token : tokens) {
265 stream <<
"\n\t" << token;
267 coutE(
InputArguments) <<
"RooWorkspace(" <<
GetName() <<
") ERROR in file specification, expecting 'filename:wsname:objname', but '" << fileSpec <<
"' given."
268 <<
"\nTokens read are:" << stream.str() << endl;
272 const std::string& filename = tokens[0];
273 const std::string& wsname = tokens[1];
274 const std::string& objname = tokens[2];
287 <<
" or object is not a RooWorkspace" << endl ;
294 Bool_t ret =
import(*warg,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) ;
300 Bool_t ret =
import(*wdata,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) ;
306 <<
" in workspace " << wsname <<
" in file " << filename << endl ;
323 while((oneArg=(
RooAbsArg*)iter->Next())) {
324 ret |=
import(*oneArg,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) ;
376 pc.defineString(
"conflictSuffix",
"RenameConflictNodes",0) ;
377 pc.defineInt(
"renameConflictOrig",
"RenameConflictNodes",0,0) ;
378 pc.defineString(
"allSuffix",
"RenameAllNodes",0) ;
379 pc.defineString(
"allVarsSuffix",
"RenameAllVariables",0) ;
380 pc.defineString(
"allVarsExcept",
"RenameAllVariables",1) ;
381 pc.defineString(
"varChangeIn",
"RenameVar",0,
"",
kTRUE) ;
382 pc.defineString(
"varChangeOut",
"RenameVar",1,
"",
kTRUE) ;
383 pc.defineString(
"factoryTag",
"FactoryTag",0) ;
384 pc.defineInt(
"useExistingNodes",
"RecycleConflictNodes",0,0) ;
385 pc.defineInt(
"silence",
"Silence",0,0) ;
386 pc.defineInt(
"noRecursion",
"NoRecursion",0,0) ;
387 pc.defineMutex(
"RenameConflictNodes",
"RenameAllNodes") ;
388 pc.defineMutex(
"RenameConflictNodes",
"RecycleConflictNodes") ;
389 pc.defineMutex(
"RenameAllNodes",
"RecycleConflictNodes") ;
390 pc.defineMutex(
"RenameVariable",
"RenameAllVariables") ;
399 const char* suffixC =
pc.getString(
"conflictSuffix") ;
400 const char* suffixA =
pc.getString(
"allSuffix") ;
401 const char* suffixV =
pc.getString(
"allVarsSuffix") ;
402 const char* exceptVars =
pc.getString(
"allVarsExcept") ;
403 const char* varChangeIn =
pc.getString(
"varChangeIn") ;
404 const char* varChangeOut =
pc.getString(
"varChangeOut") ;
405 Bool_t renameConflictOrig =
pc.getInt(
"renameConflictOrig") ;
406 Int_t useExistingNodes =
pc.getInt(
"useExistingNodes") ;
407 Int_t silence =
pc.getInt(
"silence") ;
408 Int_t noRecursion =
pc.getInt(
"noRecursion") ;
412 if (suffixC && strlen(suffixC)==0) suffixC = 0 ;
413 if (suffixA && strlen(suffixA)==0) suffixA = 0 ;
416 const char* suffix = suffixA ? suffixA : suffixC ;
419 map<string,string> varMap ;
420 if (strlen(varChangeIn)>0) {
425 for (
unsigned int i=0; i < tokIn.size(); ++i) {
426 varMap.insert(std::make_pair(tokIn[i], tokOut[i]));
429 assert(tokIn.size() == tokOut.size());
434 std::set<string> exceptVarNames ;
435 if (exceptVars && strlen(exceptVars)) {
437 exceptVarNames.insert(toks.begin(), toks.end());
440 if (suffixV != 0 && strlen(suffixV)>0) {
445 if (exceptVarNames.find(
v->GetName())==exceptVarNames.end()) {
446 varMap[
v->GetName()] =
Form(
"%s_%s",
v->GetName(),suffixV) ;
459 Bool_t factoryMatch = (tagIn && tagWs && !strcmp(tagIn,tagWs)) ;
461 ((
RooAbsArg&)inArg).setAttribute(
"RooWorkspace::Recycle") ;
464 if (!suffix && wsarg && !useExistingNodes && !(inArg.
isFundamental() && varMap[inArg.
GetName()]!=
"")) {
468 <<
": another instance with same name already in the workspace and no conflict resolution protocol specified" << endl ;
477 coutI(
ObjectHandling) <<
"RooWorkSpace::import(" <<
GetName() <<
") Recycling existing object " << inArg.
GetName() <<
" created with identical factory specification" << endl ;
485 branchSet.
add(inArg) ;
493 if (wsbranch && wsbranch!=branch && !branch->
getAttribute(
"RooWorkspace::Recycle") && !useExistingNodes) {
494 conflictNodes.
add(*branch) ;
500 if (conflictNodes.
getSize()>0 && !suffix && !useExistingNodes) {
502 << conflictNodes <<
" already in the workspace and no conflict resolution protocol specified" << endl ;
513 conflictNodes.
add(branchSet) ;
517 string topName2 = cloneTop->
GetName() ;
518 if (!renameConflictOrig) {
524 string origName = cnode2->
GetName() ;
527 string tag =
Form(
"ORIGNAME:%s",origName.c_str()) ;
530 string tag2 =
Form(
"%s",origName.c_str()) ;
535 if (cnode2==cloneTop) {
541 <<
") Resolving name conflict in workspace by changing name of imported node "
542 << origName <<
" to " << cnode2->
GetName() << endl ;
553 string origName = cnode->
GetName() ;
568 string newname =
Form(
"%s_%s_%d",cnode->
GetName(),suffix,
n) ;
570 wsnode->
SetName(newname.c_str()) ;
579 <<
") Resolving name conflict in workspace by changing name of original node "
580 << origName <<
" to " << wsnode->
GetName() << endl ;
584 << origName <<
" to be renamed, but didn't find it..." << endl ;
593 if (strlen(varChangeIn)>0 || (suffixV && strlen(suffixV)>0)) {
600 if (varMap.find(cnode->
GetName())!=varMap.end()) {
601 string origName = cnode->
GetName() ;
603 string tag =
Form(
"ORIGNAME:%s",origName.c_str()) ;
606 string tag2 =
Form(
"%s",origName.c_str()) ;
612 << origName <<
" to " << cnode->
GetName() <<
" on request" << endl ;
615 if (cnode==cloneTop) {
636 conflictNodes2.
add(*branch2) ;
642 if (conflictNodes2.
getSize()) {
644 << conflictNodes2 <<
" cause naming conflict after conflict resolution protocol was executed" << endl ;
656 <<
" has an error in importing in one or more of its auxiliary objects, aborting" << endl ;
671 << node->IsA()->
GetName() <<
"::" << node->
GetName() <<
", reading of workspace will require external definition of class" << endl ;
685 if (!silence && useExistingNodes) {
687 <<
"::" << node->
GetName() <<
" for import of " << cloneTop2->IsA()->
GetName() <<
"::"
688 << cloneTop2->
GetName() << endl ;
729 if (recycledNodes.
getSize()>0) {
777 pc.defineString(
"dsetName",
"Rename",0,
"") ;
778 pc.defineString(
"varChangeIn",
"RenameVar",0,
"",
kTRUE) ;
779 pc.defineString(
"varChangeOut",
"RenameVar",1,
"",
kTRUE) ;
780 pc.defineInt(
"embedded",
"Embedded",0,0) ;
789 const char* dsetName =
pc.getString(
"dsetName") ;
790 const char* varChangeIn =
pc.getString(
"varChangeIn") ;
791 const char* varChangeOut =
pc.getString(
"varChangeOut") ;
792 Bool_t embedded =
pc.getInt(
"embedded") ;
795 if (dsetName && strlen(dsetName)==0) {
802 if (dsetName && dataList.
FindObject(dsetName)) {
803 coutE(
ObjectHandling) <<
"RooWorkspace::import(" <<
GetName() <<
") ERROR dataset with name " << dsetName <<
" already exists in workspace, import aborted" << endl ;
807 coutE(
ObjectHandling) <<
"RooWorkspace::import(" <<
GetName() <<
") ERROR dataset with name " << inData.
GetName() <<
" already exists in workspace, import aborted" << endl ;
822 if (strlen(varChangeIn)>0) {
826 for (
unsigned int i=0; i < tokIn.size(); ++i) {
827 coutI(
ObjectHandling) <<
"RooWorkSpace::import(" <<
GetName() <<
") changing name of dataset observable " << tokIn[i] <<
" to " << tokOut[i] << endl ;
844 dataList.
Add(clone) ;
854 while ((carg=iter2.
next())) {
890 <<
"\" is not in workspace and importMissing option is disabled" << endl ;
916 <<
") WARNING redefining previously defined named set " <<
name << endl;
943 if (!
arg(token.c_str())) {
945 <<
"\" is not in workspace" << endl ;
948 wsargs.
add(*
arg(token.c_str())) ;
972 if (!
arg(token.c_str())) {
974 <<
"\" is not in workspace" << endl ;
977 wsargs.
add(*
arg(token.c_str())) ;
995 return (i!=
_namedSets.end()) ? &(i->second) : 0 ;
1009 <<
" does not exist" << endl ;
1016 <<
" already exists" << endl ;
1040 <<
" does not exist" << endl ;
1157 TString className = carg->IsA()->
GetName() ;
1160 << carg->IsA()->
GetName() <<
"::" << carg->
GetName() <<
", reading of workspace will require external definition of class" << endl ;
1198 delete actualParams ;
1203 *snapshot = params ;
1234 *actualParams = *snap ;
1235 delete actualParams ;
1359 coutE(
InputArguments) <<
" RooWorkspace::argSet(" <<
GetName() <<
") no RooAbsArg named \"" << token <<
"\" in workspace" << endl ;
1536 list<RooAbsData*> ret ;
1540 ret.push_back(dat) ;
1552 list<RooAbsData*> ret ;
1556 ret.push_back(dat) ;
1569 list<TObject*> ret ;
1578 ret.push_back(gobj) ;
1611 if (mapEntry && strlen(mapEntry)>0) {
1621 if (implfile.empty() || declfile.empty()) {
1623 << tc->
GetName() <<
" through ROOT TClass interface, unable to import code" << endl ;
1629 if (TString(implfile.c_str()).Index(rootsys)>=0) {
1633 const char* implpath=0 ;
1640 << tc->
GetName() <<
" : it cannot be persisted because it doesn't have a default constructor. Please fix " << endl ;
1647 char* declpath = 0 ;
1673 << tc->
GetName() <<
" because header file " << declfile <<
" is not found in current directory nor in $ROOTSYS" ;
1688 <<
"path using RooWorkspace::addClassDeclDir(const char* dir)" << endl ;
1719 << tc->
GetName() <<
" because implementation file " << implfile <<
" is not found in current directory nor in $ROOTSYS" ;
1734 <<
"path using RooWorkspace::addClassImplDir(const char* dir)" << endl ;
1755 int dotpos2 = strrchr(declfilename.c_str(),
'.') - declfilename.c_str() ;
1756 string declfilebase = declfilename.substr(0,dotpos2) ;
1757 string declfileext = declfilename.substr(dotpos2+1) ;
1759 list<string> extraHeaders ;
1762 if (
_fmap.find(declfilebase) ==
_fmap.end()) {
1765 fstream fdecl(declpath?declpath:declfile.c_str()) ;
1770 <<
") ERROR opening declaration file " << declfile << endl ;
1775 <<
") importing code of class " << tc->
GetName()
1776 <<
" from " << (implpath?implpath:implfile.c_str())
1777 <<
" and " << (declpath?declpath:declfile.c_str()) << endl ;
1782 while(fdecl.getline(buf,1023)) {
1786 char* extincfile = 0 ;
1789 if (strstr(buf,
"#include")) {
1792 strlcpy(tmp, buf, 64000);
1793 Bool_t stdinclude = strchr(buf,
'<');
1794 strtok(tmp,
" <\"");
1795 char *incfile = strtok(0,
" <>\"");
1800 hpath +=
"/include/";
1804 <<
") scheduling include file " << incfile <<
" for import" << endl;
1805 extraHeaders.push_back(incfile);
1806 extincfile = incfile;
1807 processedInclude =
kTRUE;
1812 if (processedInclude) {
1813 decl +=
"// external include file below retrieved from workspace code storage\n" ;
1814 decl +=
Form(
"#include \"%s\"\n",extincfile) ;
1822 fstream fimpl(implpath?implpath:implfile.c_str()) ;
1827 <<
") ERROR opening implementation file " << implfile << endl ;
1834 while(fimpl.getline(buf,1023)) {
1840 char* extincfile = 0 ;
1843 if (strstr(buf,
"#include")) {
1846 strlcpy(tmp, buf, 64000);
1847 Bool_t stdinclude = strchr(buf,
'<');
1848 strtok(tmp,
" <\"");
1849 char *incfile = strtok(0,
" <>\"");
1851 if (strstr(incfile, declfilename.c_str())) {
1852 foundSelfInclude =
kTRUE;
1855 if (!stdinclude && !foundSelfInclude) {
1858 hpath +=
"/include/";
1863 <<
") scheduling include file " << incfile <<
" for import" << endl;
1864 extraHeaders.push_back(incfile);
1865 extincfile = incfile;
1866 processedInclude =
kTRUE;
1873 if (foundSelfInclude) {
1876 impl +=
"// class declaration include file below retrieved from workspace code storage\n" ;
1877 impl +=
Form(
"#include \"%s.%s\"\n",declfilebase.c_str(),declfileext.c_str()) ;
1878 }
else if (processedInclude) {
1879 impl +=
"// external include file below retrieved from workspace code storage\n" ;
1880 impl +=
Form(
"#include \"%s\"\n",extincfile) ;
1888 _fmap[declfilebase]._hfile = decl ;
1889 _fmap[declfilebase]._cxxfile = impl ;
1890 _fmap[declfilebase]._hext = declfileext ;
1893 for (list<string>::iterator ehiter = extraHeaders.begin() ; ehiter != extraHeaders.end() ; ++ehiter ) {
1897 eh.
_hname = ehiter->c_str() ;
1898 fstream fehdr(ehiter->c_str()) ;
1901 while(fehdr.getline(buf2,1023)) {
1904 if (strstr(buf2,
"#include")) {
1907 strlcpy(tmp, buf2, 64000);
1908 Bool_t stdinclude = strchr(buf,
'<');
1909 strtok(tmp,
" <\"");
1910 char *incfile = strtok(0,
" <>\"");
1915 hpath +=
"/include/";
1919 <<
") scheduling recursive include file " << incfile <<
" for import"
1921 extraHeaders.push_back(incfile);
1929 eh.
_hfile = ehimpl.c_str();
1931 _ehmap[ehiter->c_str()] = eh;
1939 <<
") code of class " << tc->
GetName()
1940 <<
" was already imported from " << (implpath?implpath:implfile.c_str())
1941 <<
" and " << (declpath?declpath:declfile.c_str()) << endl ;
1952 TString baseNameList ;
1956 list<TClass*> bases ;
1958 if (baseNameList.Length()>0) {
1959 baseNameList +=
"," ;
1971 list<TClass*>::iterator biter = bases.begin() ;
1972 while(biter!=bases.end()) {
2004 TString title=
Form(
"TDirectory representation of RooWorkspace %s",
GetName()) ;
2031 if (oldObj && !replaceExisting) {
2033 <<
object.GetName() <<
" is already in workspace and replaceExisting flag is set to false" << endl ;
2039 object.IsA()->SetDirectoryAutoAdd(0);
2050 object.IsA()->SetDirectoryAutoAdd(func);
2072 if (oldObj && !replaceExisting) {
2074 <<
object.GetName() <<
" is already in workspace and replaceExisting flag is set to false" << endl ;
2128 if (ret)
return ret ;
2132 if (ret)
return ret ;
2149 if (!gobj)
return 0 ;
2174 TFile
f(fileName,recreate?
"RECREATE":
"UPDATE") ;
2189 cxcoutD(
ObjectHandling) <<
"INFO: Creating RooFactoryWSTool associated with this workspace" << endl ;
2190 _factory = make_unique<RooFactoryWSTool>(*
this);
2215 if (TString(opts).Contains(
"t")) {
2218 if (TString(opts).Contains(
"v")) {
2222 cout << endl <<
"RooWorkspace(" <<
GetName() <<
") " <<
GetTitle() <<
" contents" << endl << endl ;
2255 funcSet.
add(*parg) ;
2263 catfuncSet.
add(*parg) ;
2271 convResoSet.
add(*parg) ;
2273 resoSet.
add(*parg) ;
2286 funcSet.
add(*parg) ;
2291 catfuncSet.
add(*parg) ;
2312 cout <<
"variables" << endl ;
2313 cout <<
"---------" << endl ;
2314 cout << varSet << endl ;
2319 cout <<
"p.d.f.s" << endl ;
2320 cout <<
"-------" << endl ;
2336 cout <<
"analytical resolution models" << endl ;
2337 cout <<
"----------------------------" << endl ;
2354 cout <<
"functions" << endl ;
2355 cout <<
"--------" << endl ;
2370 cout <<
"category functions" << endl ;
2371 cout <<
"------------------" << endl ;
2386 cout <<
"datasets" << endl ;
2387 cout <<
"--------" << endl ;
2391 cout << data2->IsA()->
GetName() <<
"::" << data2->
GetName() << *data2->
get() << endl ;
2398 cout <<
"embedded datasets (in pdfs and functions)" << endl ;
2399 cout <<
"-----------------------------------------" << endl ;
2403 cout << data2->IsA()->
GetName() <<
"::" << data2->
GetName() << *data2->
get() << endl ;
2410 cout <<
"parameter snapshots" << endl ;
2411 cout <<
"-------------------" << endl ;
2415 cout << snap->
GetName() <<
" = (" ;
2421 cout <<
a->GetName() <<
"=" ;
2422 a->printValue(cout) ;
2423 if (
a->isConstant()) {
2427 cout <<
")" << endl ;
2436 cout <<
"named sets" << endl ;
2437 cout <<
"----------" << endl ;
2438 for (map<string,RooArgSet>::const_iterator it =
_namedSets.begin() ; it !=
_namedSets.end() ; ++it) {
2439 if (verbose || !TString(it->first.c_str()).BeginsWith(
"CACHE_")) {
2440 cout << it->first <<
":" << it->second << endl;
2449 cout <<
"generic objects" << endl ;
2450 cout <<
"---------------" << endl ;
2455 cout << ((
RooTObjWrap*)gobj)->obj()->IsA()->
GetName() <<
"::" << gobj->GetName() << endl ;
2457 cout << gobj->IsA()->
GetName() <<
"::" << gobj->
GetName() << endl ;
2466 cout <<
"study modules" << endl ;
2467 cout <<
"-------------" << endl ;
2471 cout << smobj->IsA()->
GetName() <<
"::" << smobj->
GetName() << endl ;
2479 cout <<
"embedded class code" << endl ;
2480 cout <<
"-------------------" << endl ;
2486 cout <<
"embedded precalculated expensive components" << endl ;
2487 cout <<
"-------------------------------------------" << endl ;
2503void RooWorkspace::CodeRepo::Streamer(
TBuffer &R__b)
2518 name.Streamer(R__b) ;
2519 _fmap[
name]._hext.Streamer(R__b) ;
2520 _fmap[
name]._hfile.Streamer(R__b) ;
2521 _fmap[
name]._cxxfile.Streamer(R__b) ;
2529 name.Streamer(R__b) ;
2530 _c2fmap[
name]._baseName.Streamer(R__b) ;
2531 _c2fmap[
name]._fileBase.Streamer(R__b) ;
2540 name.Streamer(R__b) ;
2541 _ehmap[
name]._hname.Streamer(R__b) ;
2542 _ehmap[
name]._hfile.Streamer(R__b) ;
2549 _compiledOK = !compileClasses() ;
2557 UInt_t count = _fmap.size() ;
2559 map<TString,ClassFiles>::iterator iter = _fmap.begin() ;
2560 while(iter!=_fmap.end()) {
2561 TString key_copy(iter->first) ;
2562 key_copy.Streamer(R__b) ;
2563 iter->second._hext.Streamer(R__b) ;
2564 iter->second._hfile.Streamer(R__b);
2565 iter->second._cxxfile.Streamer(R__b);
2571 count = _c2fmap.size() ;
2573 map<TString,ClassRelInfo>::iterator iter2 = _c2fmap.begin() ;
2574 while(iter2!=_c2fmap.end()) {
2575 TString key_copy(iter2->first) ;
2576 key_copy.Streamer(R__b) ;
2577 iter2->second._baseName.Streamer(R__b) ;
2578 iter2->second._fileBase.Streamer(R__b);
2583 count = _ehmap.size() ;
2585 map<TString,ExtraHeader>::iterator iter3 = _ehmap.begin() ;
2586 while(iter3!=_ehmap.end()) {
2587 TString key_copy(iter3->first) ;
2588 key_copy.Streamer(R__b) ;
2589 iter3->second._hname.Streamer(R__b) ;
2590 iter3->second._hfile.Streamer(R__b);
2608void RooWorkspace::Streamer(
TBuffer &R__b)
2617 while((node=fiter.
next())) {
2631 cout <<
"RooWorkspace::Streamer(" <<
GetName() <<
") " << node->IsA()->
GetName() <<
"::" << node->
GetName()
2643 map<RooAbsArg*,list<RooAbsArg*> > extClients, extValueClients, extShapeClients ;
2656 extClients[tmparg].push_back(client) ;
2668 <<
" has external value client link to " << vclient <<
" (" << vclient->
GetName() <<
") with ref count " << tmparg->
_clientListValue.
refCount(vclient) << endl ;
2671 extValueClients[tmparg].push_back(vclient) ;
2675 delete vclientIter ;
2683 <<
" has external shape client link to " << sclient <<
" (" << sclient->
GetName() <<
") with ref count " << tmparg->
_clientListShape.
refCount(sclient) << endl ;
2686 extShapeClients[tmparg].push_back(sclient) ;
2690 delete sclientIter ;
2700 for (map<
RooAbsArg*,list<RooAbsArg*> >::iterator iterx = extClients.begin() ; iterx!=extClients.end() ; ++iterx) {
2701 for (list<RooAbsArg*>::iterator citer = iterx->second.begin() ; citer!=iterx->second.end() ; ++citer) {
2702 iterx->first->_clientList.Add(*citer) ;
2706 for (map<
RooAbsArg*,list<RooAbsArg*> >::iterator iterx = extValueClients.begin() ; iterx!=extValueClients.end() ; ++iterx) {
2707 for (list<RooAbsArg*>::iterator citer = iterx->second.begin() ; citer!=iterx->second.end() ; ++citer) {
2708 iterx->first->_clientListValue.Add(*citer) ;
2712 for (map<
RooAbsArg*,list<RooAbsArg*> >::iterator iterx = extShapeClients.begin() ; iterx!=extShapeClients.end() ; ++iterx) {
2713 for (list<RooAbsArg*>::iterator citer = iterx->second.begin() ; citer!=iterx->second.end() ; ++citer) {
2714 iterx->first->_clientListShape.Add(*citer) ;
2730 map<TString,ClassRelInfo>::const_iterator iter = _c2fmap.begin() ;
2731 while(iter!=_c2fmap.end()) {
2735 ret += iter->first ;
2763 map<TString,ClassRelInfo>::iterator iter = _c2fmap.begin() ;
2764 while(iter!=_c2fmap.end()) {
2766 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() now processing class " << iter->first.Data() << endl ;
2771 << iter->first <<
" already in ROOT class table, skipping" << endl ;
2781 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() reusing code export directory " << dirName.c_str()
2782 <<
" to extract coded embedded in workspace" << endl ;
2785 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() creating code export directory " << dirName.c_str()
2786 <<
" to extract coded embedded in workspace" << endl ;
2788 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR creating code export directory " << dirName.c_str()
2789 <<
" to extract coded embedded in workspace" << endl ;
2798 if (!writeExtraHeaders) {
2799 writeExtraHeaders =
kTRUE ;
2801 map<TString,ExtraHeader>::iterator eiter = _ehmap.begin() ;
2802 while(eiter!=_ehmap.end()) {
2806 string fdname =
Form(
"%s/%s",dirName.c_str(),eiter->second._hname.Data()) ;
2807 ifstream ifdecl(fdname.c_str()) ;
2811 while (ifdecl.getline(buf, 64000)) {
2817 needEHWrite = (crcFile != crcWS);
2822 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting extra header file "
2828 ofstream fdecl(fdname.c_str());
2830 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR opening file " << fdname
2831 <<
" for writing" << endl;
2834 fdecl << eiter->second._hfile.Data();
2843 ClassFiles& cfinfo = _fmap[iter->second._fileBase] ;
2845 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() now processing file with base " << iter->second._fileBase << endl ;
2849 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() file with base name " << iter->second._fileBase
2850 <<
" has already been extracted, skipping to next class" << endl ;
2856 string fdname =
Form(
"%s/%s.%s",dirName.c_str(),iter->second._fileBase.Data(),cfinfo.
_hext.Data()) ;
2857 ifstream ifdecl(fdname.c_str()) ;
2861 while (ifdecl.getline(buf, 64000)) {
2867 needDeclWrite = (crcFile!=crcWS) ;
2871 if (needDeclWrite) {
2872 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting declaration code of class " << iter->first <<
", file " << fdname << endl ;
2873 ofstream fdecl(fdname.c_str()) ;
2876 << fdname <<
" for writing" << endl ;
2885 string finame =
Form(
"%s/%s.cxx",dirName.c_str(),iter->second._fileBase.Data()) ;
2886 ifstream ifimpl(finame.c_str()) ;
2890 while (ifimpl.getline(buf, 64000)) {
2896 needImplWrite = (crcFile!=crcWS) ;
2900 if (needImplWrite) {
2901 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting implementation code of class " << iter->first <<
", file " << finame << endl ;
2902 ofstream fimpl(finame.c_str()) ;
2905 << finame <<
" for writing" << endl ;
2914 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() marking code unit " << iter->second._fileBase <<
" as extracted" << endl ;
2917 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Compiling code unit " << iter->second._fileBase.Data() <<
" to define class " << iter->first << endl ;
2921 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR compiling class " << iter->first.Data() <<
", to fix this you can do the following: " << endl
2922 <<
" 1) Fix extracted source code files in directory " << dirName.c_str() <<
"/" << endl
2923 <<
" 2) In clean ROOT session compiled fixed classes by hand using '.x " << dirName.c_str() <<
"/ClassName.cxx+'" << endl
2924 <<
" 3) Reopen file with RooWorkspace with broken source code in UPDATE mode. Access RooWorkspace to force loading of class" << endl
2925 <<
" Broken instances in workspace will _not_ be compiled, instead precompiled fixed instances will be used." << endl
2926 <<
" 4) Reimport fixed code in workspace using 'RooWorkspace::importClassCode(\"*\",kTRUE)' method, Write() updated workspace to file and close file" << endl
2927 <<
" 5) Reopen file in clean ROOT session to confirm that problems are fixed" << endl ;
2944#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2956#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2963 coutE(
ObjectHandling) <<
"RooWorkspace::WSDir::Add(" <<
GetName() <<
") ERROR: Directory is read-only representation of a RooWorkspace, use RooWorkspace::import() to add objects" << endl ;
2965 InternalAppend(
obj) ;
2973#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2980 coutE(
ObjectHandling) <<
"RooWorkspace::WSDir::Add(" <<
GetName() <<
") ERROR: Directory is read-only representation of a RooWorkspace, use RooWorkspace::import() to add objects" << endl ;
2982 InternalAppend(
obj) ;
2996 coutE(
ObjectHandling) <<
"RooWorkspace::exportToCint(" <<
GetName() <<
") WARNING: repeated calls to exportToCint() have no effect" << endl ;
3004 if (!nsname) nsname =
GetName() ;
3008 <<
") INFO: references to all objects in this workspace will be created in CINT in 'namespace " <<
_exportNSName <<
"'" << endl ;
3013 while((wobj=iter->
Next())) {
3018 while((wobj=iter->
Next())) {
3043 cxcoutD(
ObjectHandling) <<
"RooWorkspace::exportObj(" <<
GetName() <<
") INFO: Workspace object name " << wobj->
GetName() <<
" is not a valid C++ identifier and is not exported to CINT" << endl ;
3049 gROOT->ProcessLine(cintExpr.c_str()) ;
3059 string oname(
name) ;
3060 if (isdigit(oname[0])) {
3063 for (
UInt_t i=0 ; i<oname.size() ; i++) {
3065 if (!isalnum(
c) && (
c!=
'_')) {
3081 while ((wobj = iter->
Next())) {
3097 if (removedObj ==
_dir)
_dir =
nullptr;
3109 c.second.RecursiveRemove(removedObj);
R__EXTERN TClassTable * gClassTable
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
RooExpensiveObjectCache & expensiveObjectCache() const
virtual Bool_t importWorkspaceHook(RooWorkspace &ws)
static UInt_t crc32(const char *data)
Bool_t redirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t isRecursionStep=kFALSE)
Iterator over _clientListValue.
RooRefCountList _clientListValue
RooRefCountList _clientListShape
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
static void ioStreamerPass2Finalize()
Method called by workspace container to finalize schema evolution issues that cannot be handled in a ...
void setWorkspace(RooWorkspace &ws)
void printComponentTree(const char *indent="", const char *namePat=0, Int_t nLevel=999)
Print tree structure of expression tree on given ostream, only branch nodes are printed.
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
virtual Bool_t isFundamental() const
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Bool_t hasClients() const
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual void ioStreamerPass2()
In which workspace do I live, if any.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
void SetName(const char *name)
Set the name of the TNamed.
RooRefCountList _clientList
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Bool_t containsInstance(const RooAbsArg &var) const
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooFIter fwdIterator() const
void sort(Bool_t ascend=kTRUE)
const char * GetName() const
Returns name of object.
void setName(const char *name)
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
void setHashTableSize(Int_t i)
TIterator * createIterator(Bool_t dir=kIterForward) const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Bool_t changeObservableName(const char *from, const char *to)
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
const char * sealNotice() const
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooAbsStudy is an abstract base class for RooStudyManager modules.
TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
RooCategory represents a fundamental (non-derived) discrete value object.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
RooExpensiveObjectCache is a singleton class that serves as repository for objects that are expensive...
void importCacheObjects(RooExpensiveObjectCache &other, const char *ownerName, Bool_t verbose=kFALSE)
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
TObject * find(const char *name) const
Return pointer to object with given name in collection.
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual void Add(TObject *arg)
Bool_t Replace(const TObject *oldArg, const TObject *newArg)
Replace object 'oldArg' in collection with new object 'newArg'.
virtual Bool_t Remove(TObject *arg)
Remove object from collection.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
static Bool_t setAddDirectoryStatus(Bool_t flag)
RooRealVar represents a fundamental (non-derived) real valued object.
Int_t refCount(TObject *obj)
Return reference count associated with 'obj'.
virtual Bool_t Remove(TObject *obj)
Remove object from list and if reference count reaches zero delete object itself as well.
RooInt is a minimal implementation of a TNamed holding a TObject.
void setOwning(Bool_t flag)
An interface to set and retrieve a workspace.
virtual void ReplaceWS(RooWorkspace *ws)=0
Set the workspace irrespective of what the previous workspace is.
Bool_t autoImportClass(TClass *tc, Bool_t doReplace=kFALSE)
Import code of class 'tc' into the repository.
std::map< TString, ExtraHeader > _ehmap
std::string listOfClassNames() const
Return STL string with last of class names contained in the code repository.
std::map< TString, ClassRelInfo > _c2fmap
Bool_t compileClasses()
For all classes in the workspace for which no class definition is found in the ROOT class table extra...
std::map< TString, ClassFiles > _fmap
virtual void Add(TObject *)
Overload TDirectory interface method to prohibit insertion of objects in read-only directory workspac...
void InternalAppend(TObject *obj)
Internal access to TDirectory append method.
virtual void Append(TObject *)
Overload TDirectory interface method to prohibit insertion of objects in read-only directory workspac...
The RooWorkspace is a persistable container for RooFit projects.
Bool_t makeDir()
Create transient TDirectory representation of this workspace.
RooExpensiveObjectCache _eocache
Transient ROOT directory representation of workspace.
RooLinkedList _genObjects
void exportToCint(const char *namespaceName=0)
Activate export of workspace symbols to CINT in a namespace with given name.
std::string _exportNSName
Export contents of workspace to CINT?
static std::list< std::string > _classDeclDirList
const RooArgSet * getSnapshot(const char *name) const
Return the RooArgSet containgin a snapshot of variables contained in the workspace.
Bool_t extendSet(const char *name, const char *newContents)
Define a named set in the work space through a comma separated list of names of objects already in th...
static void addClassDeclImportDir(const char *dir)
Add 'dir' to search path for class declaration (header) files, when attempting to import class code w...
Bool_t defineSetInternal(const char *name, const RooArgSet &aset)
void unExport()
Delete exported reference in CINT namespace.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
RooAbsData * embeddedData(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
static void addClassImplImportDir(const char *dir)
Add 'dir' to search path for class implementation (.cxx) files, when attempting to import class code ...
TObject * genobj(const char *name) const
Return generic object with given name.
std::map< std::string, RooArgSet > _namedSets
Bool_t _openTrans
Name of CINT namespace to which contents are exported.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
void clearStudies()
Remove all RooStudyManager modules.
RooAbsArg * fundArg(const char *name) const
Return fundamental (i.e.
RooArgSet argSet(const char *nameList) const
Return set of RooAbsArgs matching to given list of names.
std::unique_ptr< RooFactoryWSTool > _factory
RooArgSet allVars() const
Return set with all variable objects.
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
RooArgSet allCats() const
Return set with all category objects.
Bool_t commitTransaction()
Bool_t startTransaction()
Open an import transaction operations.
RooAbsReal * function(const char *name) const
Retrieve function (RooAbsReal) with given name. Note that all RooAbsPdfs are also RooAbsReals....
RooArgSet allResolutionModels() const
Return set with all resolution model objects.
Bool_t importClassCode(const char *pat="*", Bool_t doReplace=kFALSE)
Inport code of all classes in the workspace that have a class name that matches pattern 'pat' and whi...
RooCategory * cat(const char *name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
Bool_t renameSet(const char *name, const char *newName)
Rename set to a new name.
RooAbsArg * arg(const char *name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
std::list< RooAbsData * > allEmbeddedData() const
Return list of all dataset in the workspace.
void Print(Option_t *opts=0) const
Print contents of the workspace.
RooArgSet allPdfs() const
Return set with all probability density function objects.
Bool_t addStudy(RooAbsStudy &study)
Insert RooStudyManager module.
Bool_t writeToFile(const char *fileName, Bool_t recreate=kTRUE)
Save this current workspace into given file.
std::list< TObject * > allGenericObjects() const
Return list of all generic objects in the workspace.
static void setClassFileExportDir(const char *dir=0)
Specify the name of the directory in which embedded source code is unpacked and compiled.
Bool_t _doExport
Factory tool associated with workspace.
Bool_t removeSet(const char *name)
Remove a named set from the workspace.
static void autoImportClassCode(Bool_t flag)
If flag is true, source code of classes not the the ROOT distribution is automatically imported if on...
RooAbsCategory * catfunc(const char *name) const
Retrieve discrete function (RooAbsCategory) with given name. A null pointer is returned if not found.
RooArgSet allCatFunctions() const
Return set with all category function objects.
static std::string _classFileExportDir
static std::list< std::string > _classImplDirList
~RooWorkspace()
Workspace destructor.
Bool_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
RooWorkspace()
Default constructor.
Bool_t cd(const char *path=0)
Bool_t saveSnapshot(const char *name, const char *paramNames)
Save snapshot of values and attributes (including "Constant") of parameters 'params' If importValues ...
Bool_t loadSnapshot(const char *name)
Load the values and attributes of the parameters in the snapshot saved with the given name.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooArgSet allFunctions() const
Return set with all function objects.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooExpensiveObjectCache & expensiveObjectCache()
Bool_t isValidCPPID(const char *name)
Return true if given name is a valid C++ identifier name.
RooArgSet _sandboxNodes
Is there a transaction open?
Bool_t cancelTransaction()
Cancel an ongoing import transaction.
void exportObj(TObject *obj)
Export reference to given workspace object to CINT.
RooLinkedList _embeddedDataList
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
TIterator * componentIterator() const
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Each class (see TClass) has a linked list of its base class(es).
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
Buffer base class used for serializing objects.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
The ROOT global object gROOT contains a list of all defined classes.
Bool_t HasDefaultConstructor() const
const char * GetImplFileName() const
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
const char * GetDeclFileName() const
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Iterator abstract base class.
virtual TObject * Next()=0
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual const char * GetName() const
Returns name of object.
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Regular expression class.
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
virtual int MakeDirectory(const char *name)
Make a directory.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)
This method compiles and loads a shared library containing the code from the file "filename".
void(* DirAutoAdd_t)(void *, TDirectory *)
std::vector< std::string > tokenise(const std::string &str, const std::string &delims)
Tokenise the string by splitting at the characters in delims.
static constexpr double pc