1 #include "otsdaq-core/RootUtilities/DQMHistosOuterTracker.h"
2 #include "otsdaq-core/DataDecoders/FSSRData.h"
3 #include "otsdaq-core/DataDecoders/VIPICData.h"
4 #include "otsdaq-core/NetworkUtilities/NetworkConverters.h"
5 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
7 #include "otsdaq-core/ConfigurationPluginDataFormats/DetectorConfiguration.h"
8 #include "otsdaq-core/ConfigurationPluginDataFormats/FEConfiguration.h"
9 #include "otsdaq-core/ConfigurationPluginDataFormats/DetectorToFEConfiguration.h"
10 #include "otsdaq-core/ConfigurationPluginDataFormats/DataManagerConfiguration.h"
11 #include "otsdaq-core/ConfigurationPluginDataFormats/DataBufferConfiguration.h"
12 #include "otsdaq-core/ConfigurationPluginDataFormats/UDPDataStreamerConsumerConfiguration.h"
13 #include "otsdaq-core/ConfigurationPluginDataFormats/UDPDataListenerProducerConfiguration.h"
14 #include "otsdaq-core/ConfigurationDataFormats/FEInterfaceConfigurationBase.h"
32 #include <TDirectory.h>
46 DQMHistosOuterTracker::DQMHistosOuterTracker(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID)
48 , theDataDecoder_ (supervisorApplicationUID, bufferUID, processorUID)
49 , supervisorApplicationUID_(supervisorApplicationUID)
50 , bufferUID_ (bufferUID)
51 , processorUID_ (processorUID)
53 gStyle->SetPalette(1);
57 DQMHistosOuterTracker::~DQMHistosOuterTracker(
void)
63 void DQMHistosOuterTracker::openFile (std::string fileName)
66 currentDirectory_ = 0;
67 theFile_ = TFile::Open(fileName.c_str(),
"RECREATE");
73 void DQMHistosOuterTracker::book()
75 std::cout << __COUT_HDR_FL__ <<
"Booking start!" << std::endl;
77 currentDirectory_ = theFile_->mkdir(
"General",
"General");
78 currentDirectory_->cd();
79 numberOfTriggers_ =
new TH1I(
"NumberOfTriggers",
"Number of triggers", 1, -0.5, 0.5);
80 currentDirectory_ = theFile_->mkdir(
"Planes",
"Planes");
81 currentDirectory_->cd();
82 std::stringstream name;
83 std::stringstream title;
87 const DataManagerConfiguration* dataManagerConfiguration = theConfigurationManager_->__GET_CONFIG__(DataManagerConfiguration);
98 std::stringstream processName;
99 std::vector<std::string> bufferList = dataManagerConfiguration->getListOfDataBuffers();
100 std::vector<std::string> interfaceList = feConfiguration->getListOfFEIDs();
101 for(
const auto& itInterfaces: interfaceList)
103 std::string streamToIP;
104 std::string streamToPort;
111 if(feConfiguration->getFEInterfaceType(itInterfaces).find(
"FSSRInterface") != std::string::npos)
113 const ConfigurationBase* interfaceConfiguration = theConfigurationManager_->getConfigurationByName(feConfiguration->getFEInterfaceType(itInterfaces)+
"Configuration");
115 if(feinterfaceConfiguration) {
116 streamToIP = feinterfaceConfiguration->getStreamingIPAddress(itInterfaces);
117 streamToPort = feinterfaceConfiguration->getStreamingPort(itInterfaces);
121 for(
const auto& itBuffers: bufferList)
123 std::vector<std::string> producerList = dataBufferConfiguration->getProducerIDList(itBuffers);
124 std::vector<std::string> consumerList = dataBufferConfiguration->getConsumerIDList(itBuffers);
125 for(
const auto& itProducers: producerList)
127 if(dataBufferConfiguration->getProducerClass(itBuffers,itProducers) ==
"UDPDataListenerProducer")
130 if(listerConfiguration->getIPAddress(itProducers) == streamToIP && listerConfiguration->getPort(itProducers) == streamToPort)
132 for(
const auto& itConsumers: consumerList)
134 std::cout << __COUT_HDR_FL__ <<
"CONSUMER LIST: " << itConsumers << std::endl;
135 if(dataBufferConfiguration->getConsumerClass(itBuffers,itConsumers) ==
"UDPDataStreamerConsumer")
138 std::string ipAddress = NetworkConverters::nameToStringIP(dataStreamerConsumerConfiguration->getIPAddress(itConsumers));
140 std::string port = NetworkConverters::unsignedToStringPort(dataStreamerConsumerConfiguration->getPort(itConsumers));
141 planeOccupancies_[ipAddress][port] = std::map<unsigned int, TH1*>();
142 std::cout << __COUT_HDR_FL__ <<
"IP: " << NetworkConverters::stringToNameIP(ipAddress) <<
" Port:----" << NetworkConverters::stringToUnsignedPort(port) <<
"----" << std::endl;
143 const std::vector<std::string> rocList = detectorToFEConfiguration->getFEReaderDetectorList(itInterfaces);
144 std::cout << __COUT_HDR_FL__ <<
"List of rocs for FER: " << itInterfaces <<
" has size: " << rocList.size() << std::endl;
145 for(
const auto& itROC: rocList)
147 std::string ROCType = detectorConfiguration->getDetectorType(itROC);
149 if(ROCType ==
"FSSR")
151 unsigned int fedChannel = detectorToFEConfiguration->getFEReaderChannel(itROC);
152 if(planeOccupancies_[ipAddress][port].find(fedChannel) == planeOccupancies_[ipAddress][port].end())
156 name <<
"Plane_FE" << itInterfaces <<
"_Channel"<< fedChannel <<
"_Occupancy";
157 title <<
"Plane FE" << itInterfaces <<
" Channel"<< fedChannel <<
" Occupancy";
158 std::cout << __COUT_HDR_FL__ <<
"Adding:" << name.str() << std::endl;
159 planeOccupancies_[ipAddress][port][fedChannel] =
new TH1F(name.str().c_str(), title.str().c_str(), 640, -0.5, 639.5);
229 std::cout << __COUT_HDR_FL__ <<
"Booking done!" << std::endl;
262 void DQMHistosOuterTracker::fill(std::string& buffer, std::map<std::string, std::string> header)
270 std::string ipAddress = header[
"IPAddress"];
271 std::string port = header[
"Port"];
275 if (NetworkConverters::stringToUnsignedPort(port) == 48003)
276 theDataDecoder_.convertBuffer(buffer, convertedBuffer_,
false);
278 theDataDecoder_.convertBuffer(buffer, convertedBuffer_,
true);
280 unsigned int bufferCounter = 0;
281 uint32_t oldData = 0;
282 while (!convertedBuffer_.empty())
288 if (NetworkConverters::stringToUnsignedPort(port) == 48003 && bufferCounter%2 == 1)
290 convertedBuffer_.pop();
296 if (theDataDecoder_.isFSSRData(convertedBuffer_.front()))
301 oldData = convertedBuffer_.front();
303 theDataDecoder_.decodeData(convertedBuffer_.front(), (
DetectorDataBase**)&detectorDataFSSR);
310 if( planeOccupancies_.find(ipAddress) != planeOccupancies_.end()
311 && planeOccupancies_[ipAddress].find(port) != planeOccupancies_[ipAddress].end()
312 && planeOccupancies_[ipAddress][port].find(detectorDataFSSR->getChannelNumber()) != planeOccupancies_[ipAddress][port].end())
313 planeOccupancies_[ipAddress][port][detectorDataFSSR->getChannelNumber()]->Fill(detectorDataFSSR->getSensorStrip());
315 std::cout << __COUT_HDR_FL__
316 <<
"ERROR: I haven't book histos for streamer " << NetworkConverters::stringToNameIP(ipAddress)
317 <<
" port number: " << NetworkConverters::stringToUnsignedPort(port)
318 <<
" channel: " << detectorDataFSSR->getChannelNumber()
319 <<
" data: " << std::hex << convertedBuffer_.front() << std::dec
388 convertedBuffer_.pop();
407 void DQMHistosOuterTracker::save(
void)
409 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ <<
"Saving file!" << std::endl;
415 void DQMHistosOuterTracker::load(std::string fileName)
418 theFile_ = TFile::Open(fileName.c_str());
419 if (!theFile_->IsOpen())
422 numberOfTriggers_ = (TH1I*)theFile_->Get(
"General/NumberOfTriggers");
424 std::string directory =
"Planes";
425 std::stringstream name;
426 for(
unsigned int p=0; p<4; p++)
429 name << directory <<
"/Plane_" << p <<
"_Occupancy";
441 void DQMHistosOuterTracker::closeFile(
void)
451 TObject* DQMHistosOuterTracker::get(std::string name)
454 return theFile_->Get(name.c_str());