$treeview $search $mathjax $extrastylesheet
otsdaq_utilities
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "otsdaq-utilities/Visualization/VisualDataManager.h" 00002 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h" 00003 #include "otsdaq-core/DataManager/DQMHistosConsumerBase.h" 00004 #include "otsdaq-core/DataManager/DataManager.h" 00005 #include "otsdaq-core/DataManager/DataProcessor.h" 00006 00007 #include "otsdaq-core/DataProcessorPlugins/RawDataVisualizerConsumer.h" 00008 00009 #include <cassert> 00010 #include <iostream> 00011 #include <sstream> 00012 00013 using namespace ots; 00014 00015 //======================================================================================================================== 00016 VisualDataManager::VisualDataManager(const ConfigurationTree& theXDAQContextConfigTree, 00017 const std::string& supervisorConfigurationPath) 00018 : DataManager(theXDAQContextConfigTree, supervisorConfigurationPath) 00019 , theLiveDQMHistos_(nullptr) 00020 , theRawDataConsumer_(nullptr) 00021 //, theFileDQMHistos_ (supervisorType, supervisorInstance, "VisualBuffer", 00022 //"FileDQMHistos") , theFileDQMHistos_ (supervisorType, supervisorInstance, 00023 //"VisualBuffer", "FileDQMHistos",0) , theFileDQMHistos_ () 00024 { 00025 } 00026 00027 //======================================================================================================================== 00028 VisualDataManager::~VisualDataManager(void) {} 00029 00030 //======================================================================================================================== 00031 void VisualDataManager::configure(void) { DataManager::configure(); } 00032 00033 //======================================================================================================================== 00034 void VisualDataManager::halt(void) 00035 { 00036 theLiveDQMHistos_ = nullptr; 00037 DataManager::halt(); 00038 } 00039 00040 //======================================================================================================================== 00041 void VisualDataManager::pause(void) 00042 { 00043 __CFG_COUT__ << "Pausing..." << std::endl; 00044 DataManager::pause(); 00045 } 00046 00047 //======================================================================================================================== 00048 void VisualDataManager::resume(void) { DataManager::resume(); } 00049 00050 //======================================================================================================================== 00051 void VisualDataManager::start(std::string runNumber) 00052 { 00053 __CFG_COUT__ << "Start!" << __E__; 00054 00055 theLiveDQMHistos_ = nullptr; 00056 theRawDataConsumer_ = nullptr; 00057 00058 DataManager::start(runNumber); 00059 00060 auto buffers = theXDAQContextConfigTree_ 00061 .getNode(theConfigurationPath_ + "/LinkToDataBufferTable") 00062 .getChildren(); 00063 00064 __CFG_COUT__ << "Buffer count " << buffers.size() << __E__; 00065 00066 for(const auto& buffer : buffers) 00067 { 00068 __CFG_COUT__ << "Data Buffer Name: " << buffer.first << std::endl; 00069 if(buffer.second.getNode(TableViewColumnInfo::COL_NAME_STATUS).getValue<bool>()) 00070 { 00071 std::vector<std::string> producers; 00072 std::vector<std::string> consumers; 00073 auto bufferConfigurationMap = 00074 buffer.second.getNode("LinkToDataProcessorTable").getChildren(); 00075 for(const auto& bufferConfiguration : bufferConfigurationMap) 00076 { 00077 __CFG_COUT__ << "Processor id: " << bufferConfiguration.first 00078 << std::endl; 00079 if(bufferConfiguration.second 00080 .getNode(TableViewColumnInfo::COL_NAME_STATUS) 00081 .getValue<bool>() && 00082 (bufferConfiguration.second.getNode("ProcessorType") 00083 .getValue<std::string>() == "Consumer")) 00084 { 00085 __CFG_COUT__ 00086 << "Consumer Plugin Type = " 00087 << bufferConfiguration.second.getNode("ProcessorPluginName") 00088 << __E__; 00089 00090 auto bufferIt = buffers_.at(buffer.first); 00091 for(const auto& consumer : bufferIt.consumers_) 00092 { 00093 __CFG_COUT__ 00094 << "CONSUMER PROCESSOR: " << consumer->getProcessorID() 00095 << std::endl; 00096 if(consumer->getProcessorID() == 00097 bufferConfiguration.second.getNode("ProcessorUID") 00098 .getValue<std::string>()) 00099 { 00100 __CFG_COUT__ << "CONSUMER: " << consumer->getProcessorID() 00101 << std::endl; 00102 00103 try 00104 { 00105 __CFG_COUT__ << "Trying for DQMHistosConsumerBase." 00106 << __E__; 00107 theLiveDQMHistos_ = 00108 dynamic_cast<DQMHistosConsumerBase*>(consumer); 00109 00110 __CFG_COUT__ << "Did we succeed? " << theLiveDQMHistos_ 00111 << __E__; 00112 } 00113 catch(...) 00114 { 00115 } // ignore failures 00116 00117 if(theLiveDQMHistos_ == nullptr) 00118 { 00119 __CFG_COUT__ << "Trying for raw data consumer." << __E__; 00120 00121 try 00122 { 00123 theRawDataConsumer_ = 00124 dynamic_cast<RawDataVisualizerConsumer*>( 00125 consumer); 00126 } 00127 catch(...) 00128 { 00129 } 00130 00131 __CFG_COUT__ << "Did we succeed? " << theRawDataConsumer_ 00132 << __E__; 00133 } 00134 00135 if(!theLiveDQMHistos_ && !theRawDataConsumer_) 00136 { 00137 __CFG_SS__ << "No valid visualizer consumer!" << __E__; 00138 __CFG_SS_THROW__; 00139 } 00140 } 00141 } 00142 } 00143 } 00144 } 00145 } 00146 } 00147 00148 //======================================================================================================================== 00149 void VisualDataManager::stop(void) 00150 { 00151 theLiveDQMHistos_ = nullptr; 00152 DataManager::stop(); 00153 } 00154 00155 //======================================================================================================================== 00156 void VisualDataManager::load(std::string fileName, std::string type) 00157 { 00158 if(type == "Histograms") 00159 theFileDQMHistos_.load(fileName); 00160 // else if(type == "Monicelli") 00161 // theMonicelliEventAnalyzer_.load(fileName); 00162 // else if(type == "Geometry") 00163 // theMonicelliGeometryConverter_.loadGeometry(fileName); 00164 } 00165 00166 //======================================================================================================================== 00167 DQMHistosBase* VisualDataManager::getLiveDQMHistos(void) { return theLiveDQMHistos_; } 00168 00169 //======================================================================================================================== 00170 DQMHistosBase& VisualDataManager::getFileDQMHistos(void) { return theFileDQMHistos_; } 00171 //======================================================================================================================== 00172 const std::string& VisualDataManager::getRawData(void) 00173 { 00174 //__CFG_COUT__ << __E__; 00175 00176 return theRawDataConsumer_->getLastRawDataBuffer(); 00177 } 00178 00180 // const Visual3DEvents& VisualDataManager::getVisual3DEvents(void) 00181 //{ 00182 // return theMonicelliEventAnalyzer_.getEvents(); 00183 //} 00184 // 00186 // const Visual3DGeometry& VisualDataManager::getVisual3DGeometry(void) 00187 //{ 00188 // return theMonicelliGeometryConverter_.getGeometry(); 00189 //}