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) {
776 pc.defineString(
"dsetName",
"Rename",0,
"") ;
777 pc.defineString(
"varChangeIn",
"RenameVar",0,
"",
kTRUE) ;
778 pc.defineString(
"varChangeOut",
"RenameVar",1,
"",
kTRUE) ;
779 pc.defineInt(
"embedded",
"Embedded",0,0) ;
780 pc.defineInt(
"silence",
"Silence",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") ;
793 Int_t silence =
pc.getInt(
"silence") ;
799 if (dsetName && strlen(dsetName)==0) {
806 if (dsetName && dataList.
FindObject(dsetName)) {
807 coutE(
ObjectHandling) <<
"RooWorkspace::import(" <<
GetName() <<
") ERROR dataset with name " << dsetName <<
" already exists in workspace, import aborted" << endl ;
811 coutE(
ObjectHandling) <<
"RooWorkspace::import(" <<
GetName() <<
") ERROR dataset with name " << inData.
GetName() <<
" already exists in workspace, import aborted" << endl ;
827 if (strlen(varChangeIn)>0) {
831 for (
unsigned int i=0; i < tokIn.size(); ++i) {
833 coutI(
ObjectHandling) <<
"RooWorkSpace::import(" <<
GetName() <<
") changing name of dataset observable " << tokIn[i] <<
" to " << tokOut[i] << endl ;
850 dataList.
Add(clone) ;
860 while ((carg=iter2.
next())) {
896 <<
"\" is not in workspace and importMissing option is disabled" << endl ;
922 <<
") WARNING redefining previously defined named set " <<
name << endl;
949 if (!
arg(token.c_str())) {
951 <<
"\" is not in workspace" << endl ;
954 wsargs.
add(*
arg(token.c_str())) ;
978 if (!
arg(token.c_str())) {
980 <<
"\" is not in workspace" << endl ;
983 wsargs.
add(*
arg(token.c_str())) ;
1001 return (i!=
_namedSets.end()) ? &(i->second) : 0 ;
1015 <<
" does not exist" << endl ;
1022 <<
" already exists" << endl ;
1046 <<
" does not exist" << endl ;
1166 << carg->IsA()->
GetName() <<
"::" << carg->
GetName() <<
", reading of workspace will require external definition of class" << endl ;
1204 delete actualParams ;
1209 *snapshot = params ;
1240 *actualParams = *snap ;
1241 delete actualParams ;
1365 coutE(
InputArguments) <<
" RooWorkspace::argSet(" <<
GetName() <<
") no RooAbsArg named \"" << token <<
"\" in workspace" << endl ;
1542 list<RooAbsData*> ret ;
1546 ret.push_back(dat) ;
1558 list<RooAbsData*> ret ;
1562 ret.push_back(dat) ;
1575 list<TObject*> ret ;
1584 ret.push_back(gobj) ;
1617 if (mapEntry && strlen(mapEntry)>0) {
1627 if (implfile.empty() || declfile.empty()) {
1629 << tc->
GetName() <<
" through ROOT TClass interface, unable to import code" << endl ;
1639 const char* implpath=0 ;
1646 << tc->
GetName() <<
" : it cannot be persisted because it doesn't have a default constructor. Please fix " << endl ;
1653 char* declpath = 0 ;
1679 << tc->
GetName() <<
" because header file " << declfile <<
" is not found in current directory nor in $ROOTSYS" ;
1694 <<
"path using RooWorkspace::addClassDeclDir(const char* dir)" << endl ;
1725 << tc->
GetName() <<
" because implementation file " << implfile <<
" is not found in current directory nor in $ROOTSYS" ;
1740 <<
"path using RooWorkspace::addClassImplDir(const char* dir)" << endl ;
1761 int dotpos2 = strrchr(declfilename.c_str(),
'.') - declfilename.c_str() ;
1762 string declfilebase = declfilename.substr(0,dotpos2) ;
1763 string declfileext = declfilename.substr(dotpos2+1) ;
1765 list<string> extraHeaders ;
1768 if (
_fmap.find(declfilebase) ==
_fmap.end()) {
1771 fstream fdecl(declpath?declpath:declfile.c_str()) ;
1776 <<
") ERROR opening declaration file " << declfile << endl ;
1781 <<
") importing code of class " << tc->
GetName()
1782 <<
" from " << (implpath?implpath:implfile.c_str())
1783 <<
" and " << (declpath?declpath:declfile.c_str()) << endl ;
1788 while(fdecl.getline(buf,1023)) {
1792 char* extincfile = 0 ;
1795 if (strstr(buf,
"#include")) {
1798 strlcpy(tmp, buf, 64000);
1799 Bool_t stdinclude = strchr(buf,
'<');
1800 strtok(tmp,
" <\"");
1801 char *incfile = strtok(0,
" <>\"");
1806 hpath +=
"/include/";
1810 <<
") scheduling include file " << incfile <<
" for import" << endl;
1811 extraHeaders.push_back(incfile);
1812 extincfile = incfile;
1813 processedInclude =
kTRUE;
1818 if (processedInclude) {
1819 decl +=
"// external include file below retrieved from workspace code storage\n" ;
1820 decl +=
Form(
"#include \"%s\"\n",extincfile) ;
1828 fstream fimpl(implpath?implpath:implfile.c_str()) ;
1833 <<
") ERROR opening implementation file " << implfile << endl ;
1840 while(fimpl.getline(buf,1023)) {
1846 char* extincfile = 0 ;
1849 if (strstr(buf,
"#include")) {
1852 strlcpy(tmp, buf, 64000);
1853 Bool_t stdinclude = strchr(buf,
'<');
1854 strtok(tmp,
" <\"");
1855 char *incfile = strtok(0,
" <>\"");
1857 if (strstr(incfile, declfilename.c_str())) {
1858 foundSelfInclude =
kTRUE;
1861 if (!stdinclude && !foundSelfInclude) {
1864 hpath +=
"/include/";
1869 <<
") scheduling include file " << incfile <<
" for import" << endl;
1870 extraHeaders.push_back(incfile);
1871 extincfile = incfile;
1872 processedInclude =
kTRUE;
1879 if (foundSelfInclude) {
1882 impl +=
"// class declaration include file below retrieved from workspace code storage\n" ;
1883 impl +=
Form(
"#include \"%s.%s\"\n",declfilebase.c_str(),declfileext.c_str()) ;
1884 }
else if (processedInclude) {
1885 impl +=
"// external include file below retrieved from workspace code storage\n" ;
1886 impl +=
Form(
"#include \"%s\"\n",extincfile) ;
1894 _fmap[declfilebase]._hfile = decl ;
1895 _fmap[declfilebase]._cxxfile = impl ;
1896 _fmap[declfilebase]._hext = declfileext ;
1899 for (list<string>::iterator ehiter = extraHeaders.begin() ; ehiter != extraHeaders.end() ; ++ehiter ) {
1903 eh.
_hname = ehiter->c_str() ;
1904 fstream fehdr(ehiter->c_str()) ;
1907 while(fehdr.getline(buf2,1023)) {
1910 if (strstr(buf2,
"#include")) {
1913 strlcpy(tmp, buf2, 64000);
1914 Bool_t stdinclude = strchr(buf,
'<');
1915 strtok(tmp,
" <\"");
1916 char *incfile = strtok(0,
" <>\"");
1921 hpath +=
"/include/";
1925 <<
") scheduling recursive include file " << incfile <<
" for import"
1927 extraHeaders.push_back(incfile);
1935 eh.
_hfile = ehimpl.c_str();
1937 _ehmap[ehiter->c_str()] = eh;
1945 <<
") code of class " << tc->
GetName()
1946 <<
" was already imported from " << (implpath?implpath:implfile.c_str())
1947 <<
" and " << (declpath?declpath:declfile.c_str()) << endl ;
1962 list<TClass*> bases ;
1964 if (baseNameList.
Length()>0) {
1965 baseNameList +=
"," ;
1977 list<TClass*>::iterator biter = bases.begin() ;
1978 while(biter!=bases.end()) {
2037 if (oldObj && !replaceExisting) {
2039 <<
object.GetName() <<
" is already in workspace and replaceExisting flag is set to false" << endl ;
2045 object.IsA()->SetDirectoryAutoAdd(0);
2056 object.IsA()->SetDirectoryAutoAdd(func);
2078 if (oldObj && !replaceExisting) {
2080 <<
object.GetName() <<
" is already in workspace and replaceExisting flag is set to false" << endl ;
2134 if (ret)
return ret ;
2138 if (ret)
return ret ;
2155 if (!gobj)
return 0 ;
2180 TFile f(fileName,recreate?
"RECREATE":
"UPDATE") ;
2195 cxcoutD(
ObjectHandling) <<
"INFO: Creating RooFactoryWSTool associated with this workspace" << endl ;
2196 _factory = make_unique<RooFactoryWSTool>(*
this);
2221 if (
TString(opts).Contains(
"t")) {
2224 if (
TString(opts).Contains(
"v")) {
2228 cout << endl <<
"RooWorkspace(" <<
GetName() <<
") " <<
GetTitle() <<
" contents" << endl << endl ;
2261 funcSet.
add(*parg) ;
2269 catfuncSet.
add(*parg) ;
2277 convResoSet.
add(*parg) ;
2279 resoSet.
add(*parg) ;
2292 funcSet.
add(*parg) ;
2297 catfuncSet.
add(*parg) ;
2318 cout <<
"variables" << endl ;
2319 cout <<
"---------" << endl ;
2320 cout << varSet << endl ;
2325 cout <<
"p.d.f.s" << endl ;
2326 cout <<
"-------" << endl ;
2342 cout <<
"analytical resolution models" << endl ;
2343 cout <<
"----------------------------" << endl ;
2360 cout <<
"functions" << endl ;
2361 cout <<
"--------" << endl ;
2376 cout <<
"category functions" << endl ;
2377 cout <<
"------------------" << endl ;
2392 cout <<
"datasets" << endl ;
2393 cout <<
"--------" << endl ;
2397 cout << data2->IsA()->
GetName() <<
"::" << data2->
GetName() << *data2->
get() << endl ;
2404 cout <<
"embedded datasets (in pdfs and functions)" << endl ;
2405 cout <<
"-----------------------------------------" << endl ;
2409 cout << data2->IsA()->
GetName() <<
"::" << data2->
GetName() << *data2->
get() << endl ;
2416 cout <<
"parameter snapshots" << endl ;
2417 cout <<
"-------------------" << endl ;
2421 cout << snap->
GetName() <<
" = (" ;
2427 cout <<
a->GetName() <<
"=" ;
2428 a->printValue(cout) ;
2429 if (
a->isConstant()) {
2433 cout <<
")" << endl ;
2442 cout <<
"named sets" << endl ;
2443 cout <<
"----------" << endl ;
2444 for (map<string,RooArgSet>::const_iterator it =
_namedSets.begin() ; it !=
_namedSets.end() ; ++it) {
2446 cout << it->first <<
":" << it->second << endl;
2455 cout <<
"generic objects" << endl ;
2456 cout <<
"---------------" << endl ;
2461 cout << ((
RooTObjWrap*)gobj)->obj()->IsA()->
GetName() <<
"::" << gobj->GetName() << endl ;
2463 cout << gobj->IsA()->
GetName() <<
"::" << gobj->
GetName() << endl ;
2472 cout <<
"study modules" << endl ;
2473 cout <<
"-------------" << endl ;
2477 cout << smobj->IsA()->
GetName() <<
"::" << smobj->
GetName() << endl ;
2485 cout <<
"embedded class code" << endl ;
2486 cout <<
"-------------------" << endl ;
2492 cout <<
"embedded precalculated expensive components" << endl ;
2493 cout <<
"-------------------------------------------" << endl ;
2509void RooWorkspace::CodeRepo::Streamer(
TBuffer &R__b)
2524 name.Streamer(R__b) ;
2525 _fmap[
name]._hext.Streamer(R__b) ;
2526 _fmap[
name]._hfile.Streamer(R__b) ;
2527 _fmap[
name]._cxxfile.Streamer(R__b) ;
2535 name.Streamer(R__b) ;
2536 _c2fmap[
name]._baseName.Streamer(R__b) ;
2537 _c2fmap[
name]._fileBase.Streamer(R__b) ;
2546 name.Streamer(R__b) ;
2547 _ehmap[
name]._hname.Streamer(R__b) ;
2548 _ehmap[
name]._hfile.Streamer(R__b) ;
2555 _compiledOK = !compileClasses() ;
2563 UInt_t count = _fmap.size() ;
2565 map<TString,ClassFiles>::iterator iter = _fmap.begin() ;
2566 while(iter!=_fmap.end()) {
2567 TString key_copy(iter->first) ;
2568 key_copy.Streamer(R__b) ;
2569 iter->second._hext.Streamer(R__b) ;
2570 iter->second._hfile.Streamer(R__b);
2571 iter->second._cxxfile.Streamer(R__b);
2577 count = _c2fmap.size() ;
2579 map<TString,ClassRelInfo>::iterator iter2 = _c2fmap.begin() ;
2580 while(iter2!=_c2fmap.end()) {
2581 TString key_copy(iter2->first) ;
2582 key_copy.Streamer(R__b) ;
2583 iter2->second._baseName.Streamer(R__b) ;
2584 iter2->second._fileBase.Streamer(R__b);
2589 count = _ehmap.size() ;
2591 map<TString,ExtraHeader>::iterator iter3 = _ehmap.begin() ;
2592 while(iter3!=_ehmap.end()) {
2593 TString key_copy(iter3->first) ;
2594 key_copy.Streamer(R__b) ;
2595 iter3->second._hname.Streamer(R__b) ;
2596 iter3->second._hfile.Streamer(R__b);
2614void RooWorkspace::Streamer(
TBuffer &R__b)
2623 while((node=fiter.
next())) {
2637 cout <<
"RooWorkspace::Streamer(" <<
GetName() <<
") " << node->IsA()->
GetName() <<
"::" << node->
GetName()
2649 map<RooAbsArg*,vector<RooAbsArg *> > extClients, extValueClients, extShapeClients ;
2657 for (
auto client : clientsTmp) {
2661 auto& bufferVec = extClients[tmparg];
2663 bufferVec.insert(bufferVec.end(), refCount, client);
2670 for (
auto vclient : clientsTmp) {
2673 <<
" has external value client link to " << vclient <<
" (" << vclient->GetName() <<
") with ref count " << tmparg->
_clientListValue.
refCount(vclient) << endl ;
2676 auto& bufferVec = extValueClients[tmparg];
2678 bufferVec.insert(bufferVec.end(), refCount, vclient);
2685 for (
auto sclient : clientsTmp) {
2688 <<
" has external shape client link to " << sclient <<
" (" << sclient->GetName() <<
") with ref count " << tmparg->
_clientListShape.
refCount(sclient) << endl ;
2691 auto& bufferVec = extShapeClients[tmparg];
2693 bufferVec.insert(bufferVec.end(), refCount, sclient);
2706 for (
auto iterx : extClients) {
2707 for (
auto client : iterx.second) {
2708 iterx.first->_clientList.Add(client);
2712 for (
auto iterx : extValueClients) {
2713 for (
auto client : iterx.second) {
2714 iterx.first->_clientListValue.Add(client);
2718 for (
auto iterx : extShapeClients) {
2719 for (
auto client : iterx.second) {
2720 iterx.first->_clientListShape.Add(client);
2736 map<TString,ClassRelInfo>::const_iterator iter = _c2fmap.begin() ;
2737 while(iter!=_c2fmap.end()) {
2741 ret += iter->first ;
2769 map<TString,ClassRelInfo>::iterator iter = _c2fmap.begin() ;
2770 while(iter!=_c2fmap.end()) {
2772 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() now processing class " << iter->first.Data() << endl ;
2777 << iter->first <<
" already in ROOT class table, skipping" << endl ;
2787 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() reusing code export directory " << dirName.c_str()
2788 <<
" to extract coded embedded in workspace" << endl ;
2791 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() creating code export directory " << dirName.c_str()
2792 <<
" to extract coded embedded in workspace" << endl ;
2794 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR creating code export directory " << dirName.c_str()
2795 <<
" to extract coded embedded in workspace" << endl ;
2804 if (!writeExtraHeaders) {
2805 writeExtraHeaders =
kTRUE ;
2807 map<TString,ExtraHeader>::iterator eiter = _ehmap.begin() ;
2808 while(eiter!=_ehmap.end()) {
2812 string fdname =
Form(
"%s/%s",dirName.c_str(),eiter->second._hname.Data()) ;
2813 ifstream ifdecl(fdname.c_str()) ;
2817 while (ifdecl.getline(buf, 64000)) {
2823 needEHWrite = (crcFile != crcWS);
2828 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting extra header file "
2834 ofstream fdecl(fdname.c_str());
2836 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR opening file " << fdname
2837 <<
" for writing" << endl;
2840 fdecl << eiter->second._hfile.Data();
2849 ClassFiles& cfinfo = _fmap[iter->second._fileBase] ;
2851 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() now processing file with base " << iter->second._fileBase << endl ;
2855 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() file with base name " << iter->second._fileBase
2856 <<
" has already been extracted, skipping to next class" << endl ;
2862 string fdname =
Form(
"%s/%s.%s",dirName.c_str(),iter->second._fileBase.Data(),cfinfo.
_hext.
Data()) ;
2863 ifstream ifdecl(fdname.c_str()) ;
2867 while (ifdecl.getline(buf, 64000)) {
2873 needDeclWrite = (crcFile!=crcWS) ;
2877 if (needDeclWrite) {
2878 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting declaration code of class " << iter->first <<
", file " << fdname << endl ;
2879 ofstream fdecl(fdname.c_str()) ;
2882 << fdname <<
" for writing" << endl ;
2891 string finame =
Form(
"%s/%s.cxx",dirName.c_str(),iter->second._fileBase.Data()) ;
2892 ifstream ifimpl(finame.c_str()) ;
2896 while (ifimpl.getline(buf, 64000)) {
2902 needImplWrite = (crcFile!=crcWS) ;
2906 if (needImplWrite) {
2907 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Extracting implementation code of class " << iter->first <<
", file " << finame << endl ;
2908 ofstream fimpl(finame.c_str()) ;
2911 << finame <<
" for writing" << endl ;
2920 oocxcoutD(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() marking code unit " << iter->second._fileBase <<
" as extracted" << endl ;
2923 oocoutI(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() Compiling code unit " << iter->second._fileBase.Data() <<
" to define class " << iter->first << endl ;
2927 oocoutE(_wspace,
ObjectHandling) <<
"RooWorkspace::CodeRepo::compileClasses() ERROR compiling class " << iter->first.Data() <<
", to fix this you can do the following: " << endl
2928 <<
" 1) Fix extracted source code files in directory " << dirName.c_str() <<
"/" << endl
2929 <<
" 2) In clean ROOT session compiled fixed classes by hand using '.x " << dirName.c_str() <<
"/ClassName.cxx+'" << endl
2930 <<
" 3) Reopen file with RooWorkspace with broken source code in UPDATE mode. Access RooWorkspace to force loading of class" << endl
2931 <<
" Broken instances in workspace will _not_ be compiled, instead precompiled fixed instances will be used." << endl
2932 <<
" 4) Reimport fixed code in workspace using 'RooWorkspace::importClassCode(\"*\",kTRUE)' method, Write() updated workspace to file and close file" << endl
2933 <<
" 5) Reopen file in clean ROOT session to confirm that problems are fixed" << endl ;
2950#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2962#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2969 coutE(
ObjectHandling) <<
"RooWorkspace::WSDir::Add(" <<
GetName() <<
") ERROR: Directory is read-only representation of a RooWorkspace, use RooWorkspace::import() to add objects" << endl ;
2971 InternalAppend(
obj) ;
2979#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,02)
2986 coutE(
ObjectHandling) <<
"RooWorkspace::WSDir::Add(" <<
GetName() <<
") ERROR: Directory is read-only representation of a RooWorkspace, use RooWorkspace::import() to add objects" << endl ;
2988 InternalAppend(
obj) ;
3002 coutE(
ObjectHandling) <<
"RooWorkspace::exportToCint(" <<
GetName() <<
") WARNING: repeated calls to exportToCint() have no effect" << endl ;
3010 if (!nsname) nsname =
GetName() ;
3014 <<
") INFO: references to all objects in this workspace will be created in CINT in 'namespace " <<
_exportNSName <<
"'" << endl ;
3019 while((wobj=iter->
Next())) {
3024 while((wobj=iter->
Next())) {
3049 cxcoutD(
ObjectHandling) <<
"RooWorkspace::exportObj(" <<
GetName() <<
") INFO: Workspace object name " << wobj->
GetName() <<
" is not a valid C++ identifier and is not exported to CINT" << endl ;
3055 gROOT->ProcessLine(cintExpr.c_str()) ;
3065 string oname(
name) ;
3066 if (isdigit(oname[0])) {
3069 for (
UInt_t i=0 ; i<oname.size() ; i++) {
3071 if (!isalnum(
c) && (
c!=
'_')) {
3087 while ((wobj = iter->
Next())) {
3103 if (removedObj ==
_dir)
_dir =
nullptr;
3115 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)
Substitute our servers with those listed in newSet.
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
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
RefCountList_t _clientListValue
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.
RefCountList_t _clientListShape
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
RefCountList_t _clientList
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.
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
RooFIter fwdIterator() const R__SUGGEST_ALTERNATIVE("begin()
One-time forward iterator.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Bool_t containsInstance(const RooAbsArg &var) const
void setHashTableSize(Int_t)
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
const char * GetName() const
Returns name of object.
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
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.
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
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.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
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)
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
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 forward=kTRUE) const
Create a TIterator for 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.
std::size_t refCount(typename Container_t::const_iterator item) const
Return ref count of item that iterator points to.
void Remove(const T *obj, bool force=false)
Decrease ref count of given object.
Container_t::const_iterator begin() const
Iterator over contained objects.
Container_t::const_iterator end() const
End of contained objects.
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 containing 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).
TClass instances represent classes, structs and namespaces in the ROOT type system.
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
Return name of the file containing the declaration of this class.
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.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
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