1 #include "otsdaq-utilities/VisualizationV2/VisualSupervisorV2.h"
2 #include "otsdaq/XmlUtilities/XmlDocument.h"
5 #include "otsdaq/DataManager/DataManagerSingleton.h"
6 #include "otsdaq/Macros/BinaryStringMacros.h"
8 #include <boost/regex.hpp>
9 #include "otsdaq/DataManager/DQMHistosConsumerBase.h"
10 #include "otsdaq/Macros/MessageTools.h"
11 #include "otsdaq/RootUtilities/RootFileExplorer.h"
16 #include <TBranchElement.h>
18 #include <TBufferJSON.h>
21 #include <TDirectory.h>
25 #include <TIterator.h>
32 #include "TBufferFile.h"
38 #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")) + "/VisualizerV2Data/"
53 #define PREFERENCES_FILE_EXT ".pref"
55 #define ROOT_VIEWER_PERMISSIONS_THRESHOLD 100
60 #define __MF_SUBJECT__ "VisualizerV2"
65 #define STDLINE(X, Y) __COUT__ << X
68 VisualSupervisorV2::VisualSupervisorV2(xdaq::ApplicationStub* stub)
69 : CoreSupervisorBase(stub), theDataManager_(nullptr), loadedRunNumber_(-1)
71 __SUP_COUT__ <<
"Constructor." << __E__;
72 INIT_MF(
"VisualSupervisorV2");
74 mkdir(((std::string)PREFERENCES_PATH).c_str(), 0755);
76 __SUP_COUT__ <<
"Constructed." << __E__;
80 VisualSupervisorV2::~VisualSupervisorV2(
void)
82 __SUP_COUT__ <<
"Destructor." << __E__;
84 __SUP_COUT__ <<
"Destructed." << __E__;
88 void VisualSupervisorV2::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__;
107 __SUP_COUT__ <<
"Configuring..." << __E__;
111 if(RunControlStateMachine::getIterationIndex() == 0 &&
112 RunControlStateMachine::getSubIterationIndex() == 0)
114 std::pair<std::string , TableGroupKey> theGroup(
115 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
117 .getValue(
"ConfigurationTableGroupName"),
119 SOAPUtilities::translate(theStateMachine_.getCurrentMessage())
121 .getValue(
"ConfigurationTableGroupKey")));
123 __SUP_COUT__ <<
"Configuration table group name: " << theGroup.first
124 <<
" key: " << theGroup.second << __E__;
127 theConfigurationManager_->loadTableGroup(
140 ConfigurationManager::LoadGroupType::ALL_TYPES,
145 __COUTV__(theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName());
146 __COUTV__(theConfigurationManager_
147 ->getNode(theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)
149 .getValueAsString());
152 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName() +
153 CorePropertySupervisorBase::getSupervisorConfigurationPath());
155 ConfigurationTree appLink = theConfigurationManager_->getNode(
156 "/" + theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)->getTableName() +
157 CorePropertySupervisorBase::getSupervisorConfigurationPath());
159 __COUTV__(appLink.getValueAsString());
161 if(!appLink.isDisconnected())
163 theDataManager_ = DataManagerSingleton::getInstance<VisualDataManagerV2>(
164 theConfigurationManager_->getNode(
165 theConfigurationManager_->__GET_CONFIG__(XDAQContextTable)
167 CorePropertySupervisorBase::getSupervisorConfigurationPath(),
168 CorePropertySupervisorBase::getSupervisorUID());
170 CoreSupervisorBase::theStateMachineImplementation_.push_back(theDataManager_);
172 __SUP_COUT__ <<
"Done instantiating Visual data manager." << __E__;
175 __SUP_COUT__ <<
"No Visual Supervisor configuration link, so skipping Visual "
176 "data manager instantiation."
180 CoreSupervisorBase::transitionConfiguringFSMs();
182 __SUP_COUT__ <<
"Configured." << __E__;
186 void VisualSupervisorV2::transitionHalting(toolbox::Event::Reference e)
188 __SUP_COUT__ <<
"Halting..." << __E__;
190 CoreSupervisorBase::transitionHalting(e);
193 __SUP_COUT__ <<
"Halted." << __E__;
202 CorePropertySupervisorBase::setSupervisorProperty(
203 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AllowNoLoginRequestTypes,
204 "setUserPreferences | getUserPreferences | getDirectoryContents | getRoot | "
207 CorePropertySupervisorBase::setSupervisorProperty(
208 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.UserPermissionsThreshold,
209 "*=1 | rootAdminControls=100");
217 CorePropertySupervisorBase::setSupervisorProperty(
218 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.AutomatedRequestTypes,
219 "getRoot | getEvents");
220 CorePropertySupervisorBase::setSupervisorProperty(
221 CorePropertySupervisorBase::SUPERVISOR_PROPERTIES.NoXmlWhiteSpaceRequestTypes,
222 "getRoot | getEvents");
229 HttpXmlDocument& xmlOut,
230 const WebUsers::RequestUserInfo& userInfo)
259 __SUP_COUT__ << __E__;
264 if(theDataManager_ ==
nullptr)
266 __SS__ <<
"No data manager instantiated." << __E__;
269 __SUP_COUT__ <<
"Getting Raw data and converting to binary string" << __E__;
270 xmlOut.addBinaryStringToData(
"rawData", theDataManager_->getRawData());
271 __SUP_COUT__ << __E__;
273 catch(std::exception
const& e)
276 <<
"ERROR! Exception while getting raw data. Incoming exception data..."
278 __SUP_COUT__ << e.what() << __E__;
279 __SUP_COUT__ <<
"End Exception Data" << __E__;
283 __SUP_COUT__ <<
"ERROR! Something went wrong trying to get raw data."
289 catch(
const std::exception& e)
291 __SUP_COUT_ERR__ <<
"Exception message: " << e.what();
296 __SUP_COUT_INFO__ <<
"ERROR! Something went wrong trying to get raw data."
301 requestType ==
"setUserPreferences" &&
302 userInfo.username_ !=
305 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
306 std::string fullPath =
307 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
308 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
310 std::string radioSelect = CgiDataUtilities::getData(cgiIn,
"radioSelect");
311 std::string autoRefresh = CgiDataUtilities::getData(cgiIn,
"autoRefresh");
312 std::string autoHide = CgiDataUtilities::getData(cgiIn,
"autoHide");
313 std::string hardRefresh = CgiDataUtilities::getData(cgiIn,
"hardRefresh");
314 std::string autoRefreshPeriod =
315 CgiDataUtilities::getData(cgiIn,
"autoRefreshPeriod");
317 __SUP_COUT__ <<
"radioSelect: " << radioSelect << __E__;
318 __SUP_COUT__ <<
"autoRefresh: " << autoRefresh << __E__;
319 __SUP_COUT__ <<
"autoHide: " << autoHide << __E__;
320 __SUP_COUT__ <<
"hardRefresh: " << hardRefresh << __E__;
321 __SUP_COUT__ <<
"autoRefreshPeriod: " << autoRefreshPeriod << __E__;
324 FILE* fp = fopen(fullPath.c_str(),
"r");
330 fgets(line, 100, fp);
331 sscanf(line,
"%*s %s", val);
332 if(radioSelect ==
"")
335 fgets(line, 100, fp);
336 sscanf(line,
"%*s %s", val);
337 if(autoRefresh ==
"")
340 fgets(line, 100, fp);
341 sscanf(line,
"%*s %s", val);
345 fgets(line, 100, fp);
346 sscanf(line,
"%*s %s", val);
347 if(hardRefresh ==
"")
350 fgets(line, 100, fp);
351 sscanf(line,
"%*s %s", val);
352 if(autoRefreshPeriod ==
"")
353 autoRefreshPeriod = val;
359 fp = fopen(fullPath.c_str(),
"w");
362 fprintf(fp,
"radioSelect %s\n", radioSelect.c_str());
363 fprintf(fp,
"autoRefresh %s\n", autoRefresh.c_str());
364 fprintf(fp,
"autoHide %s\n", autoHide.c_str());
365 fprintf(fp,
"hardRefresh %s\n", hardRefresh.c_str());
366 fprintf(fp,
"autoRefreshPeriod %s\n", autoRefreshPeriod.c_str());
370 __SUP_COUT_ERR__ <<
"Failure writing preferences to file: " << fullPath
375 "getUserPreferences")
377 __SUP_COUT__ <<
"userInfo.username_: " << userInfo.username_ << __E__;
378 std::string fullPath =
379 (std::string)PREFERENCES_PATH + userInfo.username_ + PREFERENCES_FILE_EXT;
380 __SUP_COUT__ <<
"fullPath: " << fullPath << __E__;
382 FILE* fp = fopen(fullPath.c_str(),
"r");
389 fgets(line, 100, fp);
390 sscanf(line,
"%*s %d", &val);
391 if(val < 0 || val > 3)
393 xmlOut.addTextElementToData(
"radioSelect", std::to_string(val));
394 fgets(line, 100, fp);
395 sscanf(line,
"%*s %d", &val);
396 xmlOut.addTextElementToData(
"autoRefresh", std::to_string(val));
397 fgets(line, 100, fp);
398 sscanf(line,
"%*s %d", &val);
399 xmlOut.addTextElementToData(
"autoHide", std::to_string(val));
400 fgets(line, 100, fp);
401 sscanf(line,
"%*s %d", &val);
402 xmlOut.addTextElementToData(
"hardRefresh", std::to_string(val));
403 fgets(line, 100, fp);
404 sscanf(line,
"%*s %d", &val);
405 xmlOut.addTextElementToData(
"autoRefreshPeriod", std::to_string(val));
411 xmlOut.addTextElementToData(
"radioSelect",
"");
412 xmlOut.addTextElementToData(
"autoRefresh",
"");
413 xmlOut.addTextElementToData(
"autoHide",
"");
414 xmlOut.addTextElementToData(
"hardRefresh",
"");
415 xmlOut.addTextElementToData(
"autoRefreshPeriod",
"");
420 "getDirectoryContents")
424 std::string rootpath = std::string(ROOT_BROWSER_PATH) +
"/";
425 std::string path = CgiDataUtilities::postData(cgiIn,
"Path");
426 boost::regex re(
"%2F");
427 path = boost::regex_replace(path, re,
"/");
437 userInfo.permissionLevel_ >=
438 CoreSupervisorBase::getSupervisorPropertyUserPermissionsThreshold(
439 "rootAdminControls"));
440 xmlOut.addTextElementToData(
"permissions", permStr);
444 std::string dirpath = rootpath + path;
445 if(path ==
"/" + PRE_MADE_ROOT_CFG_DIR +
"/")
446 dirpath = ROOT_DISPLAY_CONFIG_PATH;
448 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
450 dirpath = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
451 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
454 __SUP_COUT__ <<
"full path: " << dirpath << __E__;
457 struct dirent* entry;
460 if((pDIR = opendir(dirpath.c_str())))
462 xmlOut.addTextElementToData(
"path", path);
463 xmlOut.addTextElementToData(
"headOfSearch",
"located");
472 xmlOut.addTextElementToData(
"dir",
473 LIVEDQM_DIR +
".root");
476 DIR* pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH);
477 bool recheck =
false;
481 if(mkdir(ROOT_DISPLAY_CONFIG_PATH,
482 S_IRWXU | (S_IRGRP | S_IXGRP) |
483 (S_IROTH | S_IXOTH)))
484 __SUP_COUT__ <<
"Failed to make directory for pre made views: "
485 << ROOT_DISPLAY_CONFIG_PATH << __E__;
490 if(!recheck || (pRtDIR = opendir(ROOT_DISPLAY_CONFIG_PATH)))
494 xmlOut.addTextElementToData(
"dir",
495 PRE_MADE_ROOT_CFG_DIR);
501 while((entry = readdir(pDIR)))
505 if(entry->d_name[0] !=
'.' &&
508 entry->d_type == 4 ||
514 std::string(entry->d_name).find(
".rcfg") == std::string::npos;
517 if(entry->d_type == 0)
521 DIR* pTmpDIR = opendir((dirpath + entry->d_name).c_str());
531 if((entry->d_type == 8 ||
532 (!isDir && entry->d_type == 0))
533 && std::string(entry->d_name).find(
".root") == std::string::npos &&
536 else if(entry->d_type == 4)
539 xmlOut.addTextElementToData(
540 isDir ?
"dir" : (isNotRtCfg ?
"dir" :
"file"), entry->d_name);
546 __SUP_COUT__ <<
"Failed to access directory contents!" << __E__;
557 ss <<
"PID: " << ::getpid();
559 std::string path = CgiDataUtilities::postData(cgiIn,
"RootPath");
560 boost::regex re1(
"%2F");
561 path = boost::regex_replace(
564 boost::regex re2(
"%20");
565 path = boost::regex_replace(
568 boost::regex re3(
"%3A");
569 path = boost::regex_replace(path, re3,
"");
572 ss <<
"path : " << path;
573 STDLINE(ss.str(), ACCyan);
574 std::string fullPath = std::string(__ENV__(
"ROOT_BROWSER_PATH")) + path;
576 ss <<
"fullPath: " << fullPath;
577 STDLINE(ss.str(),
"");
579 __SUP_COUTV__(fullPath);
581 const size_t rootExtensionStart = fullPath.find(
".root");
582 const size_t rootExtensionEnd = rootExtensionStart + std::string(
".root").size();
584 std::string rootFileName = fullPath.substr(0, rootExtensionEnd);
586 __SUP_COUTV__(rootFileName);
587 std::string rootDirectoryName =
589 fullPath.substr(rootExtensionEnd, fullPath.size() - rootExtensionEnd + 1);
591 __SUP_COUTV__(rootDirectoryName);
592 std::string::size_type LDQM_pos = path.find(
"/" + LIVEDQM_DIR +
".root/");
593 __SUP_COUTV__(LDQM_pos);
594 TFile* rootFile =
nullptr;
595 if(LDQM_pos == std::string::npos)
597 __SUP_COUTV__(rootFileName);
598 rootFile = TFile::Open(rootFileName.c_str());
600 if(rootFile ==
nullptr || !rootFile->IsOpen())
602 __SUP_SS__ <<
"Failed to access ROOT file: " << rootFileName << __E__;
608 if(theDataManager_ !=
nullptr &&
611 __SUP_COUT__ <<
"Attempting to get LIVE ROOT object." << __E__;
612 __SUP_COUTV__(rootDirectoryName);
613 rootDirectoryName = path.substr((
"/" + LIVEDQM_DIR +
".root").length());
614 __SUP_COUTV__(rootDirectoryName);
617 __SUP_COUT__ <<
"LIVE file name: " << rootFile->GetName() << __E__;
619 if(rootFile ==
nullptr || !rootFile->IsOpen())
621 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
623 __SUP_COUT__ << ss.str();
624 xmlOut.addTextElementToData(
"Warning", ss.str());
631 __SUP_SS__ <<
"Failed to access LIVE ROOT file: " << rootFileName
633 __SUP_COUT__ << ss.str();
634 xmlOut.addTextElementToData(
"Warning", ss.str());
642 xmlOut.addTextElementToData(
"path", path);
643 STDLINE(
string(
"######## getting directory from ") + rootDirectoryName,
"");
644 TDirectory* directory = rootFile->GetDirectory(rootDirectoryName.c_str());
645 TObject* tobject =
nullptr;
653 rootDirectoryName = fullPath.substr(
656 std::vector<std::string> splitTTreePath =
657 StringMacros::getVectorFromString(rootDirectoryName, {
'/'});
658 __SUP_COUTV__(StringMacros::vectorToString(splitTTreePath));
660 unsigned int spliti = 0;
661 while(spliti < splitTTreePath.size() && splitTTreePath[spliti].size() == 0)
664 if(spliti < splitTTreePath.size())
666 __SUP_COUTV__(splitTTreePath[spliti]);
667 tobject = (TObject*)rootFile->Get(splitTTreePath[spliti].c_str());
671 if(tobject ==
nullptr)
673 __SUP_SS__ <<
"Failed to access ROOT sub path: " << rootDirectoryName
677 __SUP_COUTV__(tobject->ClassName());
679 if(std::string(tobject->ClassName()) ==
"TTree" ||
680 std::string(tobject->ClassName()).find(
"TBranch") !=
682 std::string(tobject->ClassName()).find(
"TDirectory") != std::string::npos)
687 while(spliti < splitTTreePath.size() &&
688 splitTTreePath[spliti].size() == 0)
690 if(spliti >= splitTTreePath.size())
693 __SUP_COUTV__(splitTTreePath[spliti]);
694 __SUP_COUT__ <<
"Parent class = " << (tobject->ClassName()) << __E__;
695 if(std::string(tobject->ClassName()) ==
"TTree")
696 tobject = (TObject*)((TTree*)tobject)
697 ->GetBranch(splitTTreePath[spliti].c_str());
698 else if(std::string(tobject->ClassName()).find(
"TBranch") !=
700 tobject = (TObject*)((TBranchElement*)tobject)
701 ->FindBranch(splitTTreePath[spliti].c_str());
702 else if(std::string(tobject->ClassName()).find(
"TDirectory") !=
704 tobject = (TObject*)((TDirectoryFile*)tobject)
705 ->Get(splitTTreePath[spliti].c_str());
710 if(tobject ==
nullptr)
712 __SUP_SS__ <<
"Failed to access root sub path: " << rootDirectoryName
717 __SUP_COUTV__(tobject->ClassName());
723 TObjArray* objects =
nullptr;
725 if(std::string(tobject->ClassName()) ==
"TTree")
726 objects = ((TTree*)tobject)->GetListOfBranches();
727 else if(std::string(tobject->ClassName()).find(
"TBranch") !=
729 objects = ((TBranchElement*)tobject)->GetListOfBranches();
731 if(objects !=
nullptr && !objects->IsEmpty())
733 __SUP_COUT__ <<
"Handling as TTree/TBranchElement directory" << __E__;
737 TIter nextobj(objects->MakeIterator());
738 TRegexp re(
"*", kTRUE);
739 while((obj = (TObject*)nextobj()))
741 std::string name = obj->GetName();
743 if(s.Index(re) == kNPOS)
746 __SUP_COUT__ <<
"Child class Name: " << obj->IsA()->GetName()
747 <<
" " << name << __E__;
749 if(std::string(obj->IsA()->GetName()).find(
"TBranch") !=
754 <<
"Child '" << name <<
"' of type '"
755 << ((TBranchElement*)obj)->GetTypeName() <<
"' isLeaf="
756 << ((TBranchElement*)obj)->GetListOfBranches()->IsEmpty()
759 xmlOut.addTextElementToData(
760 (((TBranchElement*)obj)->GetListOfBranches()->IsEmpty())
767 xmlOut.addTextElementToData(
768 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
770 std::string(obj->IsA()->GetName()) ==
"TTree")
779 else if(spliti < splitTTreePath.size())
781 __COUTV__(rootDirectoryName);
784 tobject = (TObject*)rootFile->Get(rootDirectoryName.c_str());
790 if(directory ==
nullptr)
792 __SUP_COUT__ <<
"This is not a directory!" << __E__;
794 if(tobject ==
nullptr)
797 <<
"Something is wrong. Failed to access ROOT TObject at path: "
798 << fullPath << __E__;
804 if(tobject !=
nullptr)
809 bool doJSONobject =
false;
811 std::string tmpClassName = tobject->ClassName();
812 if(tmpClassName.find(
"TBranch") != std::string::npos)
814 __COUT__ <<
"Attempting to plot '" << tobject->ClassName()
815 <<
"' type." << __E__;
818 TTree* t3 = ((TBranch*)tobject)->GetTree();
822 t3->Draw(
"Value>>h8",
"",
"goff");
823 tobject = gDirectory->Get(
"h8");
825 __COUT__ <<
"Attempting to plot '" << tobject->ClassName()
826 <<
"' type." << __E__;
831 TBufferFile tBuffer(TBuffer::kWrite);
832 if(theDataManager_ !=
nullptr &&
835 if(tobject->IsA() == TCanvas::Class())
837 static_cast<TCanvas*
>(tobject)->Modified();
838 static_cast<TCanvas*
>(tobject)->Update();
840 std::unique_lock<std::mutex> lock(
841 static_cast<DQMHistosConsumerBase*
>(
843 ->getFillHistoMutex());
844 if(std::string(tobject->ClassName()) ==
"TCanvas")
848 dynamic_cast<TCanvas*
>(tobject)->Update();
849 dynamic_cast<TCanvas*
>(tobject)->Modified();
851 json = TBufferJSON::ConvertToJSON(tobject);
852 tobject->Streamer(tBuffer);
858 json = TBufferJSON::ConvertToJSON(tobject);
859 tobject->Streamer(tBuffer);
862 std::string hexString = BinaryStringMacros::binaryStringToHexString(
863 tBuffer.Buffer(), tBuffer.Length());
868 xmlOut.addTextElementToData(
"rootType",
869 doJSONobject ?
"JSON" : tobject->ClassName());
870 xmlOut.addTextElementToData(
"rootData", hexString);
871 xmlOut.addTextElementToData(
"rootJSON", json.Data());
877 __SUP_COUT_ERR__ <<
"Failed to access:-" << rootDirectoryName <<
"-"
879 STDLINE(
"Done with it!", ACBlue);
883 __SUP_COUT__ <<
"directory found getting the content!" << __E__;
884 STDLINE(
"Directory found getting the content!", ACGreen);
885 TRegexp re(
"*", kTRUE);
889 TIter nextobj(directory->GetList());
890 while((obj = (TObject*)nextobj()))
892 TString s = obj->GetName();
893 if(s.Index(re) == kNPOS)
895 __SUP_COUT__ <<
"Class Name: " << obj->IsA()->GetName() << __E__;
897 xmlOut.addTextElementToData(
898 (std::string(obj->IsA()->GetName()).find(
"Directory") !=
900 std::string(obj->IsA()->GetName()) ==
"TTree" ||
901 std::string(obj->IsA()->GetName()).find(
"TBranch") !=
913 TIter next(directory->GetListOfKeys());
914 while((key = (TKey*)next()))
916 TString s = key->GetName();
917 if(s.Index(re) == kNPOS)
919 __SUP_COUT__ <<
"Class Name: " << key->GetClassName() << __E__;
920 xmlOut.addTextElementToData(
921 (std::string(key->GetClassName()).find(
"Directory") !=
923 std::string(key->GetClassName()) ==
"TTree" ||
924 std::string(key->GetClassName()).find(
"TBranch") !=
934 if(LDQM_pos == std::string::npos)
942 if(theDataManager_ ==
nullptr)
944 __SS__ <<
"No Data Manager instantiated." << __E__;
948 int Run = atoi(cgiIn(
"run").c_str());
950 __SUP_COUT__ <<
"getEvents for run " << Run << __E__;
952 if(Run != (
int)loadedRunNumber_ || loadedRunNumber_ == (
unsigned int)-1)
954 theDataManager_->load(
"Run1684.root",
"Monicelli");
955 loadedRunNumber_ = Run;
958 xmlOut.addTextElementToData(
"events",
"");
1001 __SUP_COUT__ <<
"Done hits xml" << __E__;
1007 __SUP_COUT__ <<
"getGeometry" << __E__;
1009 if(theDataManager_ ==
nullptr)
1011 __SS__ <<
"No Data Manager instantiated." << __E__;
1016 theDataManager_->load(
"Run1684.geo",
"Geometry");
1018 __SUP_COUT__ <<
"getGeometry" << __E__;
1020 xmlOut.addTextElementToData(
"geometry",
"");
1055 std::string path = CgiDataUtilities::postData(cgiIn,
"RootConfigPath");
1056 __SUP_COUT__ <<
"path " << path << __E__;
1058 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1061 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1062 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2);
1063 __SUP_COUT__ <<
"mod path " << path << __E__;
1066 HttpXmlDocument cfgXml;
1067 if(cfgXml.loadXmlDocument(path))
1069 xmlOut.addTextElementToData(
"status",
"1");
1070 xmlOut.copyDataChildren(cfgXml);
1071 cfgXml.saveXmlDocument(path);
1074 xmlOut.addTextElementToData(
"status",
1075 "Failed. File to properly load config file.");
1079 "rootAdminControls")
1091 std::string cmd = cgiIn(
"cmd");
1096 std::string path = CgiDataUtilities::postData(cgiIn,
"path");
1097 std::string name = CgiDataUtilities::postData(cgiIn,
"name");
1098 __SUP_COUT__ <<
"cmd " << cmd << __E__;
1099 __SUP_COUT__ <<
"path " << path << __E__;
1100 __SUP_COUT__ <<
"name " << name << __E__;
1102 if(path.find(
"/" + PRE_MADE_ROOT_CFG_DIR +
"/") ==
1105 path = std::string(ROOT_DISPLAY_CONFIG_PATH) +
"/" +
1106 path.substr(PRE_MADE_ROOT_CFG_DIR.length() + 2) + name;
1107 __SUP_COUT__ <<
"mod path " << path << __E__;
1111 if(mkdir(path.c_str(),
1112 S_IRWXU | (S_IRGRP | S_IXGRP) |
1113 (S_IROTH | S_IXOTH)))
1114 xmlOut.addTextElementToData(
"status",
1115 "Failed. Directory create rejected.");
1117 xmlOut.addTextElementToData(
"status",
"1");
1119 else if(cmd ==
"save")
1121 path += PRE_MADE_ROOT_CFG_FILE_EXT;
1123 bool useRunWildCard =
1124 atoi(CgiDataUtilities::postData(cgiIn,
"useRunWildCard")
1126 std::string config = CgiDataUtilities::postData(cgiIn,
"config");
1127 __SUP_COUT__ <<
"config " << config << __E__;
1128 __SUP_COUT__ <<
"useRunWildCard " << useRunWildCard << __E__;
1131 FILE* fp = fopen(path.c_str(),
"r");
1135 xmlOut.addTextElementToData(
"status",
"Failed. File already exists.");
1136 __SUP_COUT__ <<
" Failed. File already exists." << __E__;
1145 fp = fopen(path.c_str(),
"w");
1146 fputs(config.c_str(), fp);
1150 HttpXmlDocument cfgXml;
1151 if(cfgXml.loadXmlDocument(path))
1154 cfgXml.saveXmlDocument(path);
1155 xmlOut.addTextElementToData(
"status",
"1");
1159 xmlOut.addTextElementToData(
1160 "status",
"Failed. Fatal. Improper file format.");
1161 if(remove(path.c_str()) != 0)
1162 __SUP_COUT__ <<
"Failed. Could not remove poorly formed Root "
1168 else if(cmd ==
"delete")
1171 if(rmdir(path.c_str()) == 0 ||
1172 remove((path + PRE_MADE_ROOT_CFG_FILE_EXT).c_str()) == 0)
1173 xmlOut.addTextElementToData(
"status",
"1");
1175 xmlOut.addTextElementToData(
"status",
1176 "Failed. Target could not be deleted.");
1179 xmlOut.addTextElementToData(
"status",
"Failed. Unrecognized command.");
1182 xmlOut.addTextElementToData(
"status",
"Failed. Invalid path.");
1190 xmlOut.setDarioStyle(
true);
1191 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1192 std::string fRootPath = CgiDataUtilities::postData(cgiIn,
"Path");
1193 boost::regex re(
"%2F");
1194 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1195 std::string fullPath = fSystemPath + fRootPath;
1197 STDLINE(std::string(
"Begin: fSystemPath = ") + fSystemPath, ACWhite);
1198 STDLINE(std::string(
"Begin: fRootPath = ") + fRootPath, ACWhite);
1199 STDLINE(std::string(
"Begin: fullPath = ") + fullPath, ACWhite);
1202 xmlOut.setRootPath(fRootPath);
1203 xmlOut.makeDirectoryBinaryTree(fSystemPath, fRootPath, 0, NULL);
1204 std::ostringstream* out =
new std::ostringstream();
1205 xmlOut.outputXmlDocument((std::ostringstream*)out,
true);
1211 xmlOut.setDarioStyle(
true);
1212 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1213 std::string fRootPath = CgiDataUtilities::postData(cgiIn,
"fRootPath");
1214 std::string fFoldersPath = CgiDataUtilities::postData(cgiIn,
"fFoldersPath");
1215 std::string fHistName = CgiDataUtilities::postData(cgiIn,
"fHistName");
1216 std::string fRFoldersPath = CgiDataUtilities::postData(cgiIn,
"fRFoldersPath");
1217 std::string fFileName = CgiDataUtilities::postData(cgiIn,
"fFileName");
1218 boost::regex re(
"%2F");
1219 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1220 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1221 STDLINE(std::string(
"fSystemPath : ") + fSystemPath, ACCyan);
1222 STDLINE(std::string(
"fRootPath : ") + fRootPath, ACCyan);
1223 STDLINE(std::string(
"fFoldersPath : ") + fFoldersPath, ACCyan);
1224 STDLINE(std::string(
"fHistName : ") + fHistName, ACCyan);
1225 STDLINE(std::string(
"fRFoldersPath: ") + fRFoldersPath, ACCyan);
1226 STDLINE(std::string(
"fFileName : ") + fFileName, ACCyan);
1227 RootFileExplorer* theExplorer =
new RootFileExplorer(
1228 fSystemPath, fRootPath, fFoldersPath, fHistName, fRFoldersPath, fFileName);
1229 xmlOut.setDocument(theExplorer->initialize(
false));
1230 std::ostringstream* out = NULL;
1231 xmlOut.outputXmlDocument((std::ostringstream*)out,
true);
1235 "getMeLIVE-DQMFile")
1237 xmlOut.setDarioStyle(
true);
1238 std::string fSystemPath = std::string(ROOT_BROWSER_PATH) +
"/";
1239 std::string fRootPath = CgiDataUtilities::postData(cgiIn,
"fRootPath");
1240 std::string fFoldersPath = CgiDataUtilities::postData(cgiIn,
"fFoldersPath");
1241 std::string fHistName = CgiDataUtilities::postData(cgiIn,
"fHistName");
1242 std::string fRFoldersPath = CgiDataUtilities::postData(cgiIn,
"fRFoldersPath");
1243 std::string fFileName = CgiDataUtilities::postData(cgiIn,
"fFileName");
1244 STDLINE(std::string(
"fSystemPath : ") + fSystemPath, ACCyan);
1245 STDLINE(std::string(
"fRootPath : ") + fRootPath, ACCyan);
1246 STDLINE(std::string(
"fFoldersPath : ") + fFoldersPath, ACCyan);
1247 STDLINE(std::string(
"fHistName : ") + fHistName, ACCyan);
1248 STDLINE(std::string(
"fRFoldersPath: ") + fRFoldersPath, ACCyan);
1249 STDLINE(std::string(
"fFileName : ") + fFileName, ACCyan);
1250 boost::regex re(
"%2F");
1251 fRootPath = boost::regex_replace(fRootPath, re,
"/");
1252 fFoldersPath = boost::regex_replace(fFoldersPath, re,
"/");
1253 fRFoldersPath = boost::regex_replace(fRFoldersPath, re,
"/");
1259 fRootPath =
"LIVE_DQM.root";
1263 rootFile = TFile::Open(fRootPath.c_str());
1265 RootFileExplorer* theExplorer =
new RootFileExplorer(fSystemPath,
1272 xmlOut.setDocument(theExplorer->initialize(
true));
1273 std::ostringstream* out = NULL;
1274 xmlOut.outputXmlDocument((std::ostringstream*)out,
true);
1278 "saveConfiguration")
1280 std::string configPayload = CgiDataUtilities::postData(cgiIn,
"configPayload");
1281 STDLINE(
"configPayload: ", ACRed);
1282 STDLINE(configPayload, ACYellow);
1285 outFile.open(
"/tmp/configPayload.json", ios::out | ios::app);
1286 outFile << configPayload << endl;
1293 std::string configPayload = CgiDataUtilities::postData(cgiIn,
"configPayload");
1294 std::string JSONPayLoad =
"";
1295 std::string line =
"";
1297 ifstream JSONFile(
"/tmp/configPayload.json");
1299 if(JSONFile.is_open())
1301 while(getline(JSONFile, line))
1303 JSONPayLoad += line;
1308 xmlOut.addTextElementToData(
"JSONPayLoad", JSONPayLoad);
DQMHistosBase * getLiveDQMHistos(void)
Getters.
virtual void transitionConfiguring(toolbox::Event::Reference e) override
virtual void request(const std::string &requestType, cgicc::Cgicc &cgiIn, HttpXmlDocument &xmlOut, const WebUsers::RequestUserInfo &userInfo) override
virtual void forceSupervisorPropertyValues(void) override
virtual void setSupervisorPropertyDefaults(void) override