1 #include "otsdaq-utilities/Visualization/VisualSupervisor.h"
2 #include "otsdaq/XmlUtilities/XmlDocument.h"
5 #include <boost/regex.hpp>
6 #include "otsdaq/DataManager/DataManagerSingleton.h"
7 #include "otsdaq/Macros/BinaryStringMacros.h"
9 #include "otsdaq/DataManager/DQMHistosConsumerBase.h"
11 #include "otsdaq/Macros/MessageTools.h"
12 #include "otsdaq/RootUtilities/RootFileExplorer.h"
17 #include <TBranchElement.h>
19 #include <TBufferJSON.h>
22 #include <TDirectory.h>
26 #include <TIterator.h>
33 #include "TBufferFile.h"
39 #include <xdaq/NamespaceURI.h>
44 #define ROOT_BROWSER_PATH __ENV__("ROOT_BROWSER_PATH")
45 #define ROOT_DISPLAY_CONFIG_PATH __ENV__("ROOT_DISPLAY_CONFIG_PATH")
47 #define LIVEDQM_DIR std::string("LIVE_DQM")
48 #define PRE_MADE_ROOT_CFG_DIR std::string("Pre-made Views")
50 #define PRE_MADE_ROOT_CFG_FILE_EXT std::string(".rcfg")
52 #define PREFERENCES_PATH std::string(__ENV__("SERVICE_DATA_PATH")) + "/VisualizerData/"
53 #define PREFERENCES_FILE_EXT ".pref"
55 #define ROOT_VIEWER_PERMISSIONS_THRESHOLD 100
60 #define __MF_SUBJECT__ "Visualizer"
65 #define STDLINE(X, Y) __COUT__ << X
68 VisualSupervisor::VisualSupervisor(xdaq::ApplicationStub* stub)
69 : CoreSupervisorBase(stub), theDataManager_(nullptr), loadedRunNumber_(-1)
71 __SUP_COUT__ <<
"Constructor." << __E__;
74 mkdir(((std::string)PREFERENCES_PATH).c_str(), 0755);
76 __SUP_COUT__ <<
"Constructed." << __E__;
80 VisualSupervisor::~VisualSupervisor(
void)
82 __SUP_COUT__ <<
"Destructor." << __E__;
84 __SUP_COUT__ <<
"Destructed." << __E__;
88 void VisualSupervisor::destroy(
void)
90 __SUP_COUT__ <<
"Destroying..." << __E__;
92 DataManagerSingleton::deleteInstance(CorePropertySupervisorBase::getSupervisorUID());
93 if(theStateMachineImplementation_.size() > 1)
95 __SS__ <<
"Not expecting more than one visual data manager!" << __E__;
98 if(theStateMachineImplementation_.size())
99 theStateMachineImplementation_.pop_back();
101 __COUT_WARN__ <<
"No visual data manager was pushed." << __E__;
105 void VisualSupervisor::transitionConfiguring(toolbox::Event::Reference )
107 __SUP_COUT__ <<
"Configuring..." << __E__;
111 if(RunControlStateMachine::getIterationIndex() == 0 && RunControlStateMachine::getSubIterationIndex() == 0)
113 std::pair<std::string , TableGroupKey> theGroup(
114 SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupName"),
115 TableGroupKey(SOAPUtilities::translate(theStateMachine_.getCurrentMessage()).getParameters().getValue(
"ConfigurationTableGroupKey")));
117 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first <<
" key: " << theGroup.second << __E__;
119 theConfigurationManager_->loadTableGroup(theGroup.first, theGroup.second,
true );
123 __COUTV__(theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName());
124 __COUTV__(theConfigurationManager_->getNode(
125 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName()).getValueAsString());
127 __COUTV__(
"/" + theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName() + CorePropertySupervisorBase::getSupervisorConfigurationPath());
130 ConfigurationTree appLink = theConfigurationManager_->getNode(
"/" +
131 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName() +
132 CorePropertySupervisorBase::getSupervisorConfigurationPath());
134 __COUTV__(appLink.getValueAsString());
137 if(!appLink.isDisconnected())
139 theDataManager_ = DataManagerSingleton::getInstance<VisualDataManager>(
140 theConfigurationManager_->getNode(
141 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName()),
142 CorePropertySupervisorBase::getSupervisorConfigurationPath(),
143 CorePropertySupervisorBase::getSupervisorUID());
145 CoreSupervisorBase::theStateMachineImplementation_.push_back(theDataManager_);
147 __SUP_COUT__ <<
"Done instantiating Visual data manager." << __E__;
150 __SUP_COUT__ <<
"No Visual Supervisor configuration link, so skipping Visual data manager instantiation." << __E__;
153 CoreSupervisorBase::transitionConfiguringFSMs();
155 __SUP_COUT__ <<
"Configured." << __E__;
159 void VisualSupervisor::transitionHalting(toolbox::Event::Reference e)
161 __SUP_COUT__ <<
"Halting..." << __E__;
163 CoreSupervisorBase::transitionHalting(e);
166 __SUP_COUT__ <<
"Halted." << __E__;
173 void VisualSupervisor::setSupervisorPropertyDefaults()
175 CorePropertySupervisorBase::setSupervisorProperty(
176 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AllowNoLoginRequestTypes,
177 "setUserPreferences | getUserPreferences | getDirectoryContents | getRoot | "
180 CorePropertySupervisorBase::setSupervisorProperty(
181 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
182 "*=1 | rootAdminControls=100");
188 void VisualSupervisor::forceSupervisorPropertyValues()
190 CorePropertySupervisorBase::setSupervisorProperty(
191 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
192 "getRoot | getEvents");
193 CorePropertySupervisorBase::setSupervisorProperty(
194 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.NoXmlWhiteSpaceRequestTypes,
195 "getRoot | getEvents");
205 HttpXmlDocument& xmlOut,
206 const WebUsers::RequestUserInfo& userInfo)
229 std::stringstream ss;
235 __SUP_COUT__ << __E__;
240 if(theDataManager_ ==
nullptr)
242 __SS__ <<
"No data manager instantiated." << __E__;
245 __SUP_COUT__ <<
"Getting Raw data and converting to binary string" << __E__;
246 xmlOut.addBinaryStringToData(
"rawData", theDataManager_->getRawData());
247 __SUP_COUT__ << __E__;
249 catch(std::exception
const& e)
252 <<
"ERROR! Exception while getting raw data. Incoming exception data..."
254 __SUP_COUT__ << e.what() << __E__;
255 __SUP_COUT__ <<
"End Exception Data" << __E__;
259 __SUP_COUT__ <<
"ERROR! Something went wrong trying to get raw data."
261 __SUP_COUT_INFO__ <<
"ERROR! Something went wrong trying to get raw data."
266 requestType ==
"setUserPreferences" &&
267 userInfo.username_ !=
270 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
271 std::string fullPath =
272 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
273 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
275 std::string radioSelect = CgiDataUtilities::getData(cgiIn,
"radioSelect");
276 std::string autoRefresh = CgiDataUtilities::getData(cgiIn,
"autoRefresh");
277 std::string autoHide = CgiDataUtilities::getData(cgiIn,
"autoHide");
278 std::string hardRefresh = CgiDataUtilities::getData(cgiIn,
"hardRefresh");
279 std::string autoRefreshPeriod =
280 CgiDataUtilities::getData(cgiIn,
"autoRefreshPeriod");
282 __SUP_COUT__ <<
"radioSelect: " << radioSelect << __E__;
283 __SUP_COUT__ <<
"autoRefresh: " << autoRefresh << __E__;
284 __SUP_COUT__ <<
"autoHide: " << autoHide << __E__;
285 __SUP_COUT__ <<
"hardRefresh: " << hardRefresh << __E__;
286 __SUP_COUT__ <<
"autoRefreshPeriod: " << autoRefreshPeriod << __E__;
289 FILE* fp = fopen(fullPath.c_str(),
"r");
295 fgets(line, 100, fp);
296 sscanf(line,
"%*s %s", val);
297 if(radioSelect ==
"")
300 fgets(line, 100, fp);
301 sscanf(line,
"%*s %s", val);
302 if(autoRefresh ==
"")
305 fgets(line, 100, fp);
306 sscanf(line,
"%*s %s", val);
310 fgets(line, 100, fp);
311 sscanf(line,
"%*s %s", val);
312 if(hardRefresh ==
"")
315 fgets(line, 100, fp);
316 sscanf(line,
"%*s %s", val);
317 if(autoRefreshPeriod ==
"")
318 autoRefreshPeriod = val;
324 fp = fopen(fullPath.c_str(),
"w");
327 fprintf(fp,
"radioSelect %s\n", radioSelect.c_str());
328 fprintf(fp,
"autoRefresh %s\n", autoRefresh.c_str());
329 fprintf(fp,
"autoHide %s\n", autoHide.c_str());
330 fprintf(fp,
"hardRefresh %s\n", hardRefresh.c_str());
331 fprintf(fp,
"autoRefreshPeriod %s\n", autoRefreshPeriod.c_str());
335 __SUP_COUT_ERR__ <<
"Failure writing preferences to file: " << fullPath
340 "getUserPreferences")
342 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
343 std::string fullPath =
344 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
345 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
347 FILE* fp = fopen(fullPath.c_str(),
"r");
354 fgets(line, 100, fp);
355 sscanf(line,
"%*s %d", &val);
356 if(val < 0 || val > 3)
358 xmlOut.addTextElementToData(
"radioSelect", std::to_string(val));
359 fgets(line, 100, fp);
360 sscanf(line,
"%*s %d", &val);
361 xmlOut.addTextElementToData(
"autoRefresh", std::to_string(val));
362 fgets(line, 100, fp);
363 sscanf(line,
"%*s %d", &val);
364 xmlOut.addTextElementToData(
"autoHide", std::to_string(val));
365 fgets(line, 100, fp);
366 sscanf(line,
"%*s %d", &val);
367 xmlOut.addTextElementToData(
"hardRefresh", std::to_string(val));
368 fgets(line, 100, fp);
369 sscanf(line,
"%*s %d", &val);
370 xmlOut.addTextElementToData(
"autoRefreshPeriod", std::to_string(val));
376 xmlOut.addTextElementToData(
"radioSelect",
"");
377 xmlOut.addTextElementToData(
"autoRefresh",
"");
378 xmlOut.addTextElementToData(
"autoHide",
"");
379 xmlOut.addTextElementToData(
"hardRefresh",
"");
380 xmlOut.addTextElementToData(
"autoRefreshPeriod",
"");
385 "getDirectoryContents")
389 std::string rootpath = std::string(ROOT_BROWSER_PATH) +
"/";
390 std::string path = CgiDataUtilities::postData(cgiIn,
"Path");
391 boost::regex re(
"%2F");
392 path = boost::regex_replace(path, re,
"/");
403 userInfo.permissionLevel_ >=
404 CoreSupervisorBase::getSupervisorPropertyUserPermissionsThreshold(
405 "rootAdminControls"));
406 xmlOut.addTextElementToData(
"permissions", permStr);
410 std::string dirpath = rootpath + path;
411 if(path ==
"/" + PRE_MADE_ROOT_CFG_DIR +
"/")
412 dirpath = ROOT_DISPLAY_CONFIG_PATH;
414 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
416 dirpath = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
417 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
420 __SUP_COUT__ <<
"full path: " << dirpath << __E__;
423 struct dirent* entry;
426 if((pDIR = opendir(dirpath.c_str())))
428 xmlOut.addTextElementToData(
"path", path);
429 xmlOut.addTextElementToData(
"headOfSearch",
"located");
437 if(theDataManager_ !=
nullptr &&
438 theDataManager_->getLiveDQMHistos() != 0)
439 xmlOut.addTextElementToData(
"dir",
440 LIVEDQM_DIR +
".root");
445 DIR* pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH);
446 bool recheck =
false;
450 if(mkdir(ROOT_DISPLAY_CONFIG_PATH,
451 S_IRWXU | (S_IRGRP | S_IXGRP) |
452 (S_IROTH | S_IXOTH)))
453 __SUP_COUT__ <<
"Failed to make directory for pre made views: "
454 << ROOT_DISPLAY_CONFIG_PATH << __E__;
459 if(!recheck || (pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH)))
462 xmlOut.addTextElementToData(
"dir",
463 PRE_MADE_ROOT_CFG_DIR);
469 while((entry = readdir(pDIR)))
473 if(entry->d_name[0] !=
'.' &&
476 entry->d_type == 4 ||
482 std::string(entry->d_name).find(
".rcfg") == std::string::npos;
485 if(entry->d_type == 0)
489 DIR* pTmpDIR = opendir((dirpath + entry->d_name).c_str());
499 if((entry->d_type == 8 ||
500 (!isDir && entry->d_type == 0))
501 && std::string(entry->d_name).find(
".root") == std::string::npos &&
504 else if(entry->d_type == 4)
509 xmlOut.addTextElementToData(
510 isDir ?
"dir" : (isNotRtCfg ?
"dir" :
"file"), entry->d_name);
516 __SUP_COUT__ <<
"Failed to access directory contents!" << __E__;
525 std::string path = CgiDataUtilities::postData(cgiIn,
"RootPath");
526 boost::regex re(
"%2F");
527 path = boost::regex_replace(path, re,
"/");
530 boost::regex re1(
"%3A");
531 path = boost::regex_replace(path, re1,
"");
536 ss <<
"path : " << path;
537 STDLINE(ss.str(), ACCyan);
538 std::string fullPath = std::string(__ENV__(
"ROOT_BROWSER_PATH")) + path;
540 __SUP_COUTV__(fullPath);
542 const size_t rootExtensionStart = fullPath.find(
".root");
543 const size_t rootExtensionEnd = rootExtensionStart + std::string(
".root").size();
545 std::string rootFileName = fullPath.substr(0, rootExtensionEnd);
547 __SUP_COUTV__(rootFileName);
548 std::string rootDirectoryName =
550 fullPath.substr(rootExtensionEnd, fullPath.size() - rootExtensionEnd + 1);
552 __SUP_COUTV__(rootDirectoryName);
553 std::string::size_type LDQM_pos = path.find(
"/" + LIVEDQM_DIR +
".root/");
554 __SUP_COUTV__(LDQM_pos);
555 TFile* rootFile =
nullptr;
557 if(LDQM_pos == std::string::npos)
559 __SUP_COUTV__(rootFileName);
560 rootFile = TFile::Open(rootFileName.c_str());
562 if(rootFile ==
nullptr || !rootFile->IsOpen())
564 __SUP_SS__ <<
"Failed to access ROOT file: " << rootFileName << __E__;
570 if(theDataManager_ !=
nullptr &&
571 theDataManager_->getLiveDQMHistos() !=
nullptr)
573 __SUP_COUT__ <<
"Attempting to get LIVE ROOT object." << __E__;
574 __SUP_COUTV__(rootDirectoryName);
575 rootDirectoryName = path.substr((
"/" + LIVEDQM_DIR +
".root").length());
576 __SUP_COUTV__(rootDirectoryName);
577 rootFile = theDataManager_->getLiveDQMHistos()->getFile();
579 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
581 if(rootFile ==
nullptr || !rootFile->IsOpen())
583 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
585 __SUP_COUT__ << ss.str();
586 xmlOut.addTextElementToData(
"Warning", ss.str());
593 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
595 __SUP_COUT__ << ss.str();
596 xmlOut.addTextElementToData(
"Warning", ss.str());
604 xmlOut.addTextElementToData(
"path", path);
606 TDirectory* directory = rootFile->GetDirectory(rootDirectoryName.c_str());
607 TObject* tobject =
nullptr;
615 rootDirectoryName = fullPath.substr(
618 std::vector<std::string> splitTTreePath =
619 StringMacros::getVectorFromString(rootDirectoryName, {
'/'});
620 __SUP_COUTV__(StringMacros::vectorToString(splitTTreePath));
622 unsigned int spliti = 0;
623 while(spliti < splitTTreePath.size() && splitTTreePath[spliti].size() == 0)
626 if(spliti < splitTTreePath.size())
628 __SUP_COUTV__(splitTTreePath[spliti]);
629 tobject = (TObject*)rootFile->Get(splitTTreePath[spliti].c_str());
633 if(tobject ==
nullptr)
635 __SUP_SS__ <<
"Failed to access ROOT sub path: " << rootDirectoryName
639 __SUP_COUTV__(tobject->ClassName());
641 if(std::string(tobject->ClassName()) ==
"TTree" ||
642 std::string(tobject->ClassName()).find(
"TBranch") != std::string::npos ||
643 std::string(tobject->ClassName()).find(
"TDirectory") !=
649 while(spliti < splitTTreePath.size() &&
650 splitTTreePath[spliti].size() == 0)
652 if(spliti >= splitTTreePath.size())
655 __SUP_COUTV__(splitTTreePath[spliti]);
656 __SUP_COUT__ <<
"Parent class = " << (tobject->ClassName()) << __E__;
657 if(std::string(tobject->ClassName()) ==
"TTree")
658 tobject = (TObject*)((TTree*)tobject)
659 ->GetBranch(splitTTreePath[spliti].c_str());
660 else if(std::string(tobject->ClassName()).find(
"TBranch") != std::string::npos)
661 tobject = (TObject*)((TBranchElement*)tobject)
662 ->FindBranch(splitTTreePath[spliti].c_str());
663 else if(std::string(tobject->ClassName()).find(
"TDirectory") != std::string::npos)
664 tobject = (TObject*)((TDirectoryFile*)tobject)
665 ->Get(splitTTreePath[spliti].c_str());
670 if(tobject ==
nullptr)
672 __SUP_SS__ <<
"Failed to access root sub path: " << rootDirectoryName
677 __SUP_COUTV__(tobject->ClassName());
683 TObjArray* objects =
nullptr;
685 if(std::string(tobject->ClassName()) ==
"TTree")
686 objects = ((TTree*)tobject)->GetListOfBranches();
687 else if(std::string(tobject->ClassName()).find(
"TBranch") != std::string::npos)
688 objects = ((TBranchElement*)tobject)->GetListOfBranches();
690 if(objects !=
nullptr && !objects->IsEmpty())
692 __SUP_COUT__ <<
"Handling as TTree/TBranchElement directory" << __E__;
696 TIter nextobj(objects->MakeIterator());
697 TRegexp re(
"*", kTRUE);
698 while((obj = (TObject*)nextobj()))
700 std::string name = obj->GetName();
702 if(s.Index(re) == kNPOS)
705 __SUP_COUT__ <<
"Child class Name: " << obj->IsA()->GetName()
706 <<
" " << name << __E__;
708 if(std::string(obj->IsA()->GetName()).find(
"TBranch") != std::string::npos)
712 <<
"Child '" << name <<
"' of type '"
713 << ((TBranchElement*)obj)->GetTypeName() <<
"' isLeaf="
714 << ((TBranchElement*)obj)->GetListOfBranches()->IsEmpty()
717 xmlOut.addTextElementToData(
718 (((TBranchElement*)obj)->GetListOfBranches()->IsEmpty())
725 xmlOut.addTextElementToData(
726 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
728 std::string(obj->IsA()->GetName()) ==
"TTree")
737 else if(spliti < splitTTreePath.size())
739 __COUTV__(rootDirectoryName);
742 tobject = (TObject*)rootFile->Get(rootDirectoryName.c_str());
748 if(directory ==
nullptr)
750 __SUP_COUT__ <<
"This is not a directory!" << __E__;
752 if(tobject ==
nullptr)
755 <<
"Something is wrong. Failed to access ROOT TObject at path: "
756 << fullPath << __E__;
760 TObject* tobjectClone =
nullptr;
762 if(tobject !=
nullptr)
767 bool doJSONobject =
false;
769 std::string tmpClassName = tobject->ClassName();
770 if(tmpClassName.find(
"TBranch") != std::string::npos)
772 __COUT__ <<
"Attempting to plot '" << tobject->ClassName() <<
"' type." << __E__;
775 TTree * t3 = ((TBranch*)tobject)->GetTree();
778 t3->Draw(
"Value>>h8",
"",
"goff");
779 tobject = gDirectory->Get(
"h8");
781 __COUT__ <<
"Attempting to plot '" << tobject->ClassName() <<
"' type." << __E__;
787 if(theDataManager_ !=
nullptr &&
788 theDataManager_->getLiveDQMHistos() !=
nullptr &&
791 std::unique_lock<std::mutex> lock(
792 static_cast<DQMHistosConsumerBase*>(
793 theDataManager_->getLiveDQMHistos())
794 ->getFillHistoMutex());
795 tobjectClone = tobject->Clone();
799 tobjectClone = tobject->Clone();
804 TString json = TBufferJSON::ConvertToJSON(tobjectClone);
805 TBufferFile tBuffer(TBuffer::kWrite);
806 tobjectClone->Streamer(tBuffer);
808 std::string hexString = BinaryStringMacros::binaryStringToHexString(
809 tBuffer.Buffer(), tBuffer.Length());
811 __SUP_COUT__ <<
"Returning object '" << tobjectClone->GetName()
812 <<
"' of class '" << tobjectClone->ClassName() << __E__;
814 xmlOut.addTextElementToData(
"rootType", doJSONobject?
"JSON":tobjectClone->ClassName());
815 xmlOut.addTextElementToData(
"rootData", hexString);
816 xmlOut.addTextElementToData(
"rootJSON", json.Data());
818 if(tobjectClone !=
nullptr)
824 __SUP_COUT_ERR__ <<
"Failed to access:-" << rootDirectoryName <<
"-"
826 STDLINE(
"Done with it!", ACBlue);
830 __SUP_COUT__ <<
"directory found getting the content!" << __E__;
831 STDLINE(
"Directory found getting the content!", ACGreen);
832 TRegexp re(
"*", kTRUE);
836 TIter nextobj(directory->GetList());
837 while((obj = (TObject*)nextobj()))
839 TString s = obj->GetName();
840 if(s.Index(re) == kNPOS)
842 __SUP_COUT__ <<
"Class Name: " << obj->IsA()->GetName() << __E__;
844 xmlOut.addTextElementToData(
845 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
847 std::string(obj->IsA()->GetName()) ==
"TTree" ||
848 std::string(obj->IsA()->GetName()).find(
"TBranch") != std::string::npos)
859 TIter next(directory->GetListOfKeys());
860 while((key = (TKey*)next()))
862 TString s = key->GetName();
863 if(s.Index(re) == kNPOS)
865 __SUP_COUT__ <<
"Class Name: " << key->GetClassName() << __E__;
866 xmlOut.addTextElementToData(
867 (std::string(key->GetClassName()).find(
"Directory") !=
869 std::string(key->GetClassName()) ==
"TTree" ||
870 std::string(key->GetClassName()).find(
"TBranch") != std::string::npos)
879 if(LDQM_pos == std::string::npos)
887 if(theDataManager_ ==
nullptr)
889 __SS__ <<
"No Data Manager instantiated." << __E__;
893 int Run = atoi(cgiIn(
"run").c_str());
895 __SUP_COUT__ <<
"getEvents for run " << Run << __E__;
897 if(Run != (
int)loadedRunNumber_ || loadedRunNumber_ == (
unsigned int)-1)
899 theDataManager_->load(
"Run1684.root",
"Monicelli");
900 loadedRunNumber_ = Run;
903 xmlOut.addTextElementToData(
"events",
"");
946 __SUP_COUT__ <<
"Done hits xml" << __E__;
952 __SUP_COUT__ <<
"getGeometry" << __E__;
954 if(theDataManager_ ==
nullptr)
956 __SS__ <<
"No Data Manager instantiated." << __E__;
961 theDataManager_->load(
"Run1684.geo",
"Geometry");
963 __SUP_COUT__ <<
"getGeometry" << __E__;
965 xmlOut.addTextElementToData(
"geometry",
"");
1000 std::string path = CgiDataUtilities::postData(cgiIn,
"RootConfigPath");
1001 __SUP_COUT__ <<
"path " << path << __E__;
1003 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1006 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1007 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
1008 __SUP_COUT__ <<
"mod path " << path << __E__;
1011 HttpXmlDocument cfgXml;
1012 if(cfgXml.loadXmlDocument(path))
1014 xmlOut.addTextElementToData(
"status",
"1");
1015 xmlOut.copyDataChildren(cfgXml);
1016 cfgXml.saveXmlDocument(path);
1019 xmlOut.addTextElementToData(
"status",
1020 "Failed. File to properly load config file.");
1024 "rootAdminControls")
1036 std::string cmd = cgiIn(
"cmd");
1041 std::string path = CgiDataUtilities::postData(cgiIn,
"path");
1042 std::string name = CgiDataUtilities::postData(cgiIn,
"name");
1043 __SUP_COUT__ <<
"cmd " << cmd << __E__;
1044 __SUP_COUT__ <<
"path " << path << __E__;
1045 __SUP_COUT__ <<
"name " << name << __E__;
1047 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1050 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1051 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2) + name;
1052 __SUP_COUT__ <<
"mod path " << path << __E__;
1056 if(mkdir(path.c_str(),
1057 S_IRWXU | (S_IRGRP | S_IXGRP) |
1058 (S_IROTH | S_IXOTH)))
1059 xmlOut.addTextElementToData(
"status",
1060 "Failed. Directory create rejected.");
1062 xmlOut.addTextElementToData(
"status",
"1");
1064 else if(cmd ==
"save")
1066 path += PRE_MADE_ROOT_CFG_FILE_EXT;
1068 bool useRunWildCard =
1069 atoi(CgiDataUtilities::postData(cgiIn,
"useRunWildCard")
1071 std::string config = CgiDataUtilities::postData(cgiIn,
"config");
1072 __SUP_COUT__ <<
"config " << config << __E__;
1073 __SUP_COUT__ <<
"useRunWildCard " << useRunWildCard << __E__;
1076 FILE* fp = fopen(path.c_str(),
"r");
1080 xmlOut.addTextElementToData(
"status",
"Failed. File already exists.");
1081 __SUP_COUT__ <<
" Failed. File already exists." << __E__;
1090 fp = fopen(path.c_str(),
"w");
1091 fputs(config.c_str(), fp);
1095 HttpXmlDocument cfgXml;
1096 if(cfgXml.loadXmlDocument(path))
1099 cfgXml.saveXmlDocument(path);
1100 xmlOut.addTextElementToData(
"status",
"1");
1104 xmlOut.addTextElementToData(
1105 "status",
"Failed. Fatal. Improper file format.");
1106 if(
remove(path.c_str()) != 0)
1107 __SUP_COUT__ <<
"Failed. Could not remove poorly formed Root "
1113 else if(cmd ==
"delete")
1116 if(rmdir(path.c_str()) == 0 ||
1117 remove((path + PRE_MADE_ROOT_CFG_FILE_EXT).c_str()) == 0)
1118 xmlOut.addTextElementToData(
"status",
"1");
1120 xmlOut.addTextElementToData(
"status",
1121 "Failed. Target could not be deleted.");
1124 xmlOut.addTextElementToData(
"status",
"Failed. Unrecognized command.");
1127 xmlOut.addTextElementToData(
"status",
"Failed. Invalid path.");
1135 xmlOut.setDarioStyle(
true);
1136 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1137 std::string fRootPath = CgiDataUtilities::postData(cgiIn,
"Path");
1138 boost::regex re(
"%2F");
1139 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1140 std::string fullPath = fSystemPath + fRootPath;
1142 STDLINE(std::string(
"Begin: fSystemPath = ") + fSystemPath, ACWhite);
1143 STDLINE(std::string(
"Begin: fRootPath = ") + fRootPath, ACWhite);
1144 STDLINE(std::string(
"Begin: fullPath = ") + fullPath, ACWhite);
1147 xmlOut.setRootPath(fRootPath);
1148 xmlOut.makeDirectoryBinaryTree(fSystemPath, fRootPath, 0, NULL);
1149 std::ostringstream* out =
new std::ostringstream();
1150 xmlOut.outputXmlDocument((std::ostringstream*)out,
true);
1156 xmlOut.setDarioStyle(
true);
1157 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1158 std::string fRootPath = CgiDataUtilities::postData(cgiIn,
"fRootPath");
1159 std::string fFoldersPath = CgiDataUtilities::postData(cgiIn,
"fFoldersPath");
1160 std::string fHistName = CgiDataUtilities::postData(cgiIn,
"fHistName");
1161 std::string fFileName = CgiDataUtilities::postData(cgiIn,
"fFileName");
1162 boost::regex re(
"%2F");
1163 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1164 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1165 STDLINE(std::string(
"fSystemPath : ") + fSystemPath, ACCyan);
1166 STDLINE(std::string(
"fRootPath : ") + fRootPath, ACCyan);
1167 STDLINE(std::string(
"fFoldersPath: ") + fFoldersPath, ACCyan);
1168 STDLINE(std::string(
"fHistName : ") + fHistName, ACCyan);
1169 STDLINE(std::string(
"fFileName : ") + fFileName, ACCyan);
1170 RootFileExplorer* theExplorer =
new RootFileExplorer(
1171 fSystemPath, fRootPath, fFoldersPath, fHistName, fFileName, xmlOut);
1172 xmlOut.setDocument(theExplorer->initialize());
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo) override