1 #include "otsdaq-core/RootUtilities/DQMHistosOuterTracker.h"
2 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
3 #include "otsdaq-core/DataDecoders/FSSRData.h"
4 #include "otsdaq-core/DataDecoders/VIPICData.h"
5 #include "otsdaq-core/NetworkUtilities/NetworkConverters.h"
7 #include "otsdaq-core/ConfigurationDataFormats/FEInterfaceTableBase.h"
8 #include "otsdaq-core/TablePlugins/DataBufferTable.h"
9 #include "otsdaq-core/TablePlugins/DataManagerTable.h"
10 #include "otsdaq-core/TablePlugins/DetectorTable.h"
11 #include "otsdaq-core/TablePlugins/DetectorToFETable.h"
12 #include "otsdaq-core/TablePlugins/FETable.h"
13 #include "otsdaq-core/TablePlugins/UDPDataListenerProducerTable.h"
14 #include "otsdaq-core/TablePlugins/UDPDataStreamerConsumerTable.h"
25 #include <TDirectory.h>
47 DQMHistosOuterTracker::DQMHistosOuterTracker(std::string supervisorApplicationUID,
48 std::string bufferUID,
49 std::string processorUID)
51 , theDataDecoder_(supervisorApplicationUID, bufferUID, processorUID)
52 , supervisorApplicationUID_(supervisorApplicationUID)
53 , bufferUID_(bufferUID)
54 , processorUID_(processorUID)
56 gStyle->SetPalette(1);
60 DQMHistosOuterTracker::~DQMHistosOuterTracker(
void) { closeFile(); }
63 void DQMHistosOuterTracker::openFile(std::string fileName)
66 currentDirectory_ = 0;
67 theFile_ = TFile::Open(fileName.c_str(),
"RECREATE");
72 void DQMHistosOuterTracker::book()
74 std::cout << __COUT_HDR_FL__ <<
"Booking start!" << std::endl;
76 currentDirectory_ = theFile_->mkdir(
"General",
"General");
77 currentDirectory_->cd();
78 numberOfTriggers_ =
new TH1I(
"NumberOfTriggers",
"Number of triggers", 1, -0.5, 0.5);
79 currentDirectory_ = theFile_->mkdir(
"Planes",
"Planes");
80 currentDirectory_->cd();
81 std::stringstream name;
82 std::stringstream title;
88 const DataManagerConfiguration* dataManagerConfiguration =
89 theConfigurationManager_->__GET_CONFIG__(DataManagerConfiguration);
102 std::stringstream processName;
103 std::vector<std::string> bufferList =
104 dataManagerConfiguration->getListOfDataBuffers();
105 std::vector<std::string> interfaceList = feConfiguration->getListOfFEIDs();
106 for(
const auto& itInterfaces : interfaceList)
108 std::string streamToIP;
109 std::string streamToPort;
117 if(feConfiguration->getFEInterfaceType(itInterfaces).find(
"FSSRInterface") !=
120 const TableBase* interfaceConfiguration =
121 theConfigurationManager_->getTableByName(
122 feConfiguration->getFEInterfaceType(itInterfaces) +
"Table");
123 auto feinterfaceConfiguration =
125 if(feinterfaceConfiguration)
128 feinterfaceConfiguration->getStreamingIPAddress(itInterfaces);
129 streamToPort = feinterfaceConfiguration->getStreamingPort(itInterfaces);
133 for(
const auto& itBuffers : bufferList)
135 std::vector<std::string> producerList =
136 dataBufferConfiguration->getProducerIDList(itBuffers);
137 std::vector<std::string> consumerList =
138 dataBufferConfiguration->getConsumerIDList(itBuffers);
139 for(
const auto& itProducers : producerList)
141 if(dataBufferConfiguration->getProducerClass(itBuffers, itProducers) ==
142 "UDPDataListenerProducer")
146 theConfigurationManager_->getTableByName(
147 "UDPDataListenerProducerConfiguration"));
148 if(listerConfiguration->getIPAddress(itProducers) == streamToIP &&
149 listerConfiguration->getPort(itProducers) == streamToPort)
151 for(
const auto& itConsumers : consumerList)
153 std::cout << __COUT_HDR_FL__
154 <<
"CONSUMER LIST: " << itConsumers << std::endl;
155 if(dataBufferConfiguration->getConsumerClass(
156 itBuffers, itConsumers) ==
"UDPDataStreamerConsumer")
160 std::string ipAddress = NetworkConverters::nameToStringIP(
161 dataStreamerConsumerConfiguration->getIPAddress(
166 NetworkConverters::unsignedToStringPort(
167 dataStreamerConsumerConfiguration->getPort(
169 planeOccupancies_[ipAddress][port] =
170 std::map<unsigned int, TH1*>();
171 std::cout << __COUT_HDR_FL__ <<
"IP: "
172 << NetworkConverters::stringToNameIP(ipAddress)
174 << NetworkConverters::stringToUnsignedPort(port)
175 <<
"----" << std::endl;
176 const std::vector<std::string> rocList =
177 detectorToFEConfiguration->getFEReaderDetectorList(
179 std::cout << __COUT_HDR_FL__
180 <<
"List of rocs for FER: " << itInterfaces
181 <<
" has size: " << rocList.size() << std::endl;
182 for(
const auto& itROC : rocList)
184 std::string ROCType =
185 detectorConfiguration->getDetectorType(itROC);
188 if(ROCType ==
"FSSR")
190 unsigned int fedChannel =
191 detectorToFEConfiguration->getFEReaderChannel(
193 if(planeOccupancies_[ipAddress][port].find(
195 planeOccupancies_[ipAddress][port].end())
199 name <<
"Plane_FE" << itInterfaces
200 <<
"_Channel" << fedChannel
202 title <<
"Plane FE" << itInterfaces
203 <<
" Channel" << fedChannel
205 std::cout << __COUT_HDR_FL__
206 <<
"Adding:" << name.str()
208 planeOccupancies_[ipAddress][port]
209 [fedChannel] =
new TH1F(
298 std::cout << __COUT_HDR_FL__ <<
"Booking done!" << std::endl;
333 std::map<std::string, std::string> header)
342 std::string ipAddress = header[
"IPAddress"];
343 std::string port = header[
"Port"];
349 if(NetworkConverters::stringToUnsignedPort(port) == 48003)
350 theDataDecoder_.convertBuffer(buffer, convertedBuffer_,
false);
352 theDataDecoder_.convertBuffer(buffer, convertedBuffer_,
true);
354 unsigned int bufferCounter = 0;
355 uint32_t oldData = 0;
356 while(!convertedBuffer_.empty())
362 if(NetworkConverters::stringToUnsignedPort(port) == 48003 &&
363 bufferCounter % 2 == 1)
365 convertedBuffer_.pop();
372 if(theDataDecoder_.isFSSRData(convertedBuffer_.front()))
379 oldData = convertedBuffer_.front();
380 FSSRData* detectorDataFSSR = 0;
381 theDataDecoder_.decodeData(convertedBuffer_.front(),
382 (DetectorDataBase**)&detectorDataFSSR);
390 if(planeOccupancies_.find(ipAddress) != planeOccupancies_.end() &&
391 planeOccupancies_[ipAddress].find(port) !=
392 planeOccupancies_[ipAddress].end() &&
393 planeOccupancies_[ipAddress][port].find(
394 detectorDataFSSR->getChannelNumber()) !=
395 planeOccupancies_[ipAddress][port].end())
396 planeOccupancies_[ipAddress][port][detectorDataFSSR->getChannelNumber()]
397 ->Fill(detectorDataFSSR->getSensorStrip());
399 std::cout << __COUT_HDR_FL__
400 <<
"ERROR: I haven't book histos for streamer "
401 << NetworkConverters::stringToNameIP(ipAddress)
403 << NetworkConverters::stringToUnsignedPort(port)
404 <<
" channel: " << detectorDataFSSR->getChannelNumber()
405 <<
" data: " << std::hex << convertedBuffer_.front() << std::dec
488 convertedBuffer_.pop();
509 void DQMHistosOuterTracker::save(
void)
511 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ <<
"Saving file!" << std::endl;
517 void DQMHistosOuterTracker::load(std::string fileName)
520 theFile_ = TFile::Open(
522 if(!theFile_->IsOpen())
525 numberOfTriggers_ = (TH1I*)theFile_->Get(
"General/NumberOfTriggers");
527 std::string directory =
"Planes";
528 std::stringstream name;
529 for(
unsigned int p = 0; p < 4; p++)
532 name << directory <<
"/Plane_" << p <<
"_Occupancy";
544 void DQMHistosOuterTracker::closeFile(
void)
554 TObject* DQMHistosOuterTracker::get(std::string name)
557 return theFile_->Get(name.c_str());
void fill(std::string &buffer, std::map< std::string, std::string > header)