Commit 3dc0d32d authored by Sarah Seif El Nasr's avatar Sarah Seif El Nasr
Browse files

Minor improvements in the monitor

parent 76f7b782
......@@ -409,7 +409,7 @@ bool CbcInterface::MaskAllChannels(ReadoutChip* pCbc, bool mask, bool pVerifLoop
bool CbcInterface::WriteChipReg(Chip* pCbc, const std::string& dacName, uint16_t dacValue, bool pVerifLoop)
{
std::lock_guard<std::mutex> theGuard(fMutex);
std::lock_guard<std::recursive_mutex> theGuard(fMutex);
LOG (DEBUG) << BOLDYELLOW << "CbcInterface::WriteChipReg " << dacName << RESET;
if(dacName == "VCth" || dacName == "Threshold")
{
......@@ -597,6 +597,7 @@ bool CbcInterface::ConfigurePage(Chip* pCbc, uint8_t pPage, bool pVerifLoop)
}
bool CbcInterface::WriteChipSingleReg(Chip* pCbc, const std::string& pRegNode, uint16_t pValue, bool pVerifLoop)
{
std::lock_guard<std::recursive_mutex> theGuard(fMutex);
// first, identify the correct BeBoardFWInterface
setBoard(pCbc->getBeBoardId());
bool cSuccess = false;
......@@ -756,7 +757,6 @@ bool CbcInterface::WriteChipMultReg(Chip* pCbc, const std::vector<std::pair<std:
}
bool CbcInterface::WriteChipAllLocalReg(ReadoutChip* pCbc, const std::string& dacName, ChipContainer& localRegValues, bool pVerifLoop)
{
std::lock_guard<std::mutex> theGuard(fMutex);
setBoard(pCbc->getBeBoardId());
assert(localRegValues.size() == pCbc->getNumberOfChannels());
std::string dacTemplate;
......@@ -838,7 +838,7 @@ uint8_t CbcInterface::ReadChipSingleReg(Chip* pCbc, const std::string& pRegNode)
}
uint16_t CbcInterface::ReadChipReg(Chip* pCbc, const std::string& pRegNode)
{
std::lock_guard<std::mutex> theGuard(fMutex);
std::lock_guard<std::recursive_mutex> theGuard(fMutex);
ChipRegItem cRegItem;
setBoard(pCbc->getBeBoardId());
std::vector<uint32_t> cVecReq;
......
......@@ -32,10 +32,10 @@ using BeBoardFWMap = std::map<uint16_t, BeBoardFWInterface*>; /*!< Map of Board
class ChipInterface
{
protected:
std::mutex fMutex;
BeBoardFWMap fBoardMap; /*!< Map of Board connected */
BeBoardFWInterface* fBoardFW; /*!< Board loaded */
uint16_t fPrevBoardIdentifier; /*!< Id of the previous board */
std::recursive_mutex fMutex;
BeBoardFWMap fBoardMap; /*!< Map of Board connected */
BeBoardFWInterface* fBoardFW; /*!< Board loaded */
uint16_t fPrevBoardIdentifier; /*!< Id of the previous board */
uint16_t fRegisterCount; /*!< Counter for the number of Registers written */
uint16_t fTransactionCount; /*!< Counter for the number of Transactions */
......
......@@ -58,6 +58,10 @@ void MonitorDQMPlotCBC::bookCBCPlots(TFile* theOutputFile, const DetectorContain
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetNdivisions(503);
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M");
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTimeOffset(0,"gmt");
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTitle("time");
theTGraphPedestalContainer.fTheGraph->GetYaxis()->SetTitle(registerName.c_str());
theTGraphPedestalContainer.fTheGraph->SetMarkerStyle(20);
theTGraphPedestalContainer.fTheGraph->SetMarkerSize(0.4);
// create Histograms for all the chips, they will be automatically accosiated to the output file, no need to save
// them, change the name for every chip or set their directory
RootContainerFactory::bookChipHistograms<GraphContainer<TGraph>>(theOutputFile, theDetectorStructure, fCBCRegisterMonitorPlotMap[registerName], theTGraphPedestalContainer);
......@@ -75,13 +79,17 @@ void MonitorDQMPlotCBC::bookLpGBTPlots(TFile* theOutputFile, const DetectorConta
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetNdivisions(503);
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M");
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTimeOffset(0,"gmt");
theTGraphPedestalContainer.fTheGraph->GetXaxis()->SetTitle("time");
theTGraphPedestalContainer.fTheGraph->GetYaxis()->SetTitle((registerName + " [V]").c_str());
theTGraphPedestalContainer.fTheGraph->SetMarkerStyle(20);
theTGraphPedestalContainer.fTheGraph->SetMarkerSize(0.4);
// create Histograms for all the chips, they will be automatically accosiated to the output file, no need to save
// them, change the name for every chip or set their directory
RootContainerFactory::bookOpticalGroupHistograms<GraphContainer<TGraph>>(theOutputFile, theDetectorStructure, fLpGBTRegisterMonitorPlotMap[registerName], theTGraphPedestalContainer);
}
//========================================================================================================================
void MonitorDQMPlotCBC::fillCBCRegisterPlots(DetectorDataContainer& theThresholdContainer, std::string registerName, time_t rawTime)
void MonitorDQMPlotCBC::fillCBCRegisterPlots(DetectorDataContainer& theThresholdContainer, std::string registerName)
{
if(!fCBCRegisterMonitorPlotMap.count(registerName))
{
......@@ -90,8 +98,6 @@ void MonitorDQMPlotCBC::fillCBCRegisterPlots(DetectorDataContainer& theThreshold
abort();
}
uint32_t timeStampForRoot = getTimeStampForRoot(rawTime);
for(auto board: theThresholdContainer) // for on boards - begin
{
size_t boardIndex = board->getIndex();
......@@ -112,7 +118,7 @@ void MonitorDQMPlotCBC::fillCBCRegisterPlots(DetectorDataContainer& theThreshold
if(!chip->hasSummary()) continue;
// // Get channel data and fill the histogram
// for(auto channel: *chip->getChannelContainer<uint32_t>()) // for on channel - begin
chipDQMPlot->SetPoint(chipDQMPlot->GetN(), timeStampForRoot, chip->getSummary<uint16_t>()); // for on channel - end
chipDQMPlot->SetPoint(chipDQMPlot->GetN(), getTimeStampForRoot(std::get<0>(chip->getSummary<std::tuple<time_t,uint16_t>>())), std::get<1>(chip->getSummary<std::tuple<time_t,uint16_t>>())); // for on channel - end
} // for on chip - end
} // for on hybrid - end
} // for on opticalGroup - end
......@@ -121,7 +127,7 @@ void MonitorDQMPlotCBC::fillCBCRegisterPlots(DetectorDataContainer& theThreshold
//========================================================================================================================
void MonitorDQMPlotCBC::fillLpGBTRegisterPlots(DetectorDataContainer& theThresholdContainer, std::string registerName, time_t rawTime)
void MonitorDQMPlotCBC::fillLpGBTRegisterPlots(DetectorDataContainer& theThresholdContainer, std::string registerName)
{
if(!fLpGBTRegisterMonitorPlotMap.count(registerName))
{
......@@ -130,8 +136,6 @@ void MonitorDQMPlotCBC::fillLpGBTRegisterPlots(DetectorDataContainer& theThresho
abort();
}
uint32_t timeStampForRoot = getTimeStampForRoot(rawTime);
for(auto board: theThresholdContainer) // for on boards - begin
{
size_t boardIndex = board->getIndex();
......@@ -140,7 +144,7 @@ void MonitorDQMPlotCBC::fillLpGBTRegisterPlots(DetectorDataContainer& theThresho
if(!opticalGroup->hasSummary()) continue;
size_t opticalGroupIndex = opticalGroup->getIndex();
TGraph* LpGBTDQMPlot = fLpGBTRegisterMonitorPlotMap[registerName].at(boardIndex)->at(opticalGroupIndex)->getSummary<GraphContainer<TGraph>>().fTheGraph;
LpGBTDQMPlot->SetPoint(LpGBTDQMPlot->GetN(), timeStampForRoot, opticalGroup->getSummary<uint16_t>() * CONVERSION_FACTOR);
LpGBTDQMPlot->SetPoint(LpGBTDQMPlot->GetN(), getTimeStampForRoot(std::get<0>(opticalGroup->getSummary<std::tuple<time_t,uint16_t>>())), std::get<1>(opticalGroup->getSummary<std::tuple<time_t,uint16_t>>()) * CONVERSION_FACTOR);
} // for on opticalGroup - end
} // for on boards - end
}
......@@ -162,7 +166,7 @@ bool MonitorDQMPlotCBC::fill(std::vector<char>& dataBuffer)
// IF YOU DO NOT WANT TO GO INTO THE SOC WITH YOUR DQM YOU DO NOT NEED THE FOLLOWING COMMENTED LINES
// I'm expecting to receive a data stream from an uint16_t contained from DQM "DQMExample"
ChipContainerStream<uint16_t, EmptyContainer, std::array<char, 50>, time_t> theDQMStreamer("CBCMonitor");
ChipContainerStream<uint16_t, EmptyContainer, std::array<char, 50>> theDQMStreamer("CBCMonitor");
// Try to see if the char buffer matched what I'm expection (container of uint16_t from DQMExample
// procedure)
......@@ -174,7 +178,7 @@ bool MonitorDQMPlotCBC::fill(std::vector<char>& dataBuffer)
theDQMStreamer.decodeChipData(fDetectorData);
// Filling the histograms
std::string registerName = "Not working!!!";
fillCBCRegisterPlots(fDetectorData, registerName, theDQMStreamer.getHeaderElement<1>());
fillCBCRegisterPlots(fDetectorData, registerName);
// Cleaning the data container to be ready for the next TCP string
fDetectorData.cleanDataStored();
return true;
......
......@@ -61,8 +61,8 @@ class MonitorDQMPlotCBC : public MonitorDQMPlotBase
* \param theCBCRegisterContainer : Container with the hits you want to plot
* \param timeStamp : timeStamp
*/
void fillCBCRegisterPlots (DetectorDataContainer& theCBCRegisterContainer, std::string registerName, time_t timeStamp);
void fillLpGBTRegisterPlots(DetectorDataContainer& theCBCRegisterContainer, std::string registerName, time_t timeStamp);
void fillCBCRegisterPlots (DetectorDataContainer& theCBCRegisterContainer, std::string registerName);
void fillLpGBTRegisterPlots(DetectorDataContainer& theCBCRegisterContainer, std::string registerName);
private:
bool fDoMonitorThreshold {false};
......
......@@ -36,7 +36,7 @@ void CBCMonitor::runMonitor()
void CBCMonitor::runCBCRegisterMonitor(std::string registerName)
{
DetectorDataContainer theCBCRegisterContainer;
ContainerFactory::copyAndInitChip<uint16_t>(*fTheSystemController->fDetectorContainer, theCBCRegisterContainer);
ContainerFactory::copyAndInitChip<std::tuple<time_t,uint16_t>>(*fTheSystemController->fDetectorContainer, theCBCRegisterContainer);
for(const auto& board: *fTheSystemController->fDetectorContainer)
{
......@@ -47,17 +47,17 @@ void CBCMonitor::runCBCRegisterMonitor(std::string registerName)
for(const auto& chip: *hybrid)
{
uint16_t registerValue = fTheSystemController->fReadoutChipInterface->ReadChipReg(chip, registerName); // just to read something
LOG(INFO) << BOLDMAGENTA << "CBC " << hybrid->getId() << " - " << registerName << " = " << registerValue << RESET;
theCBCRegisterContainer.at(board->getIndex())->at(opticalGroup->getIndex())->at(hybrid->getIndex())->at(chip->getIndex())->getSummary<uint16_t>() = registerValue;
LOG(DEBUG) << BOLDMAGENTA << "CBC " << hybrid->getId() << " - " << registerName << " = " << registerValue << RESET;
theCBCRegisterContainer.at(board->getIndex())->at(opticalGroup->getIndex())->at(hybrid->getIndex())->at(chip->getIndex())->getSummary<std::tuple<time_t,uint16_t>>() = std::make_tuple(getTimeStamp(), registerValue);
}
}
}
}
#ifdef __USE_ROOT__
fMonitorDQMPlotCBC->fillCBCRegisterPlots(theCBCRegisterContainer, registerName, getTimeStamp());
fMonitorDQMPlotCBC->fillCBCRegisterPlots(theCBCRegisterContainer, registerName);
#else
// auto theCBCRegisterStreamer = prepareHybridContainerStreamer<EmptyContainer, uint16_t, EmptyContainer, time_t>("CBCRegister");
// auto theCBCRegisterStreamer = prepareHybridContainerStreamer<EmptyContainer, std::tuple<time_t,uint16_t>, EmptyContainer>("CBCRegister");
// theCBCRegisterStreamer.setHeaderElement(getTimeStamp());
// if(fStreamerEnabled)
// {
......@@ -70,22 +70,22 @@ void CBCMonitor::runCBCRegisterMonitor(std::string registerName)
void CBCMonitor::runLpGBTRegisterMonitor(std::string registerName)
{
DetectorDataContainer theLpGBTRegisterContainer;
ContainerFactory::copyAndInitOpticalGroup<uint16_t>(*fTheSystemController->fDetectorContainer, theLpGBTRegisterContainer);
ContainerFactory::copyAndInitOpticalGroup<std::tuple<time_t,uint16_t>>(*fTheSystemController->fDetectorContainer, theLpGBTRegisterContainer);
for(const auto& board: *fTheSystemController->fDetectorContainer)
{
for(const auto& opticalGroup: *board)
{
uint16_t registerValue = static_cast<D19clpGBTInterface*>(fTheSystemController->flpGBTInterface)->ReadADC(opticalGroup->flpGBT, registerName);
LOG(INFO) << BOLDMAGENTA << "LpGBT " << opticalGroup->getId() << " - " << registerName << " = " << registerValue << RESET;
theLpGBTRegisterContainer.at(board->getIndex())->at(opticalGroup->getIndex())->getSummary<uint16_t>() = registerValue;
LOG(DEBUG) << BOLDMAGENTA << "LpGBT " << opticalGroup->getId() << " - " << registerName << " = " << registerValue << RESET;
theLpGBTRegisterContainer.at(board->getIndex())->at(opticalGroup->getIndex())->getSummary<std::tuple<time_t,uint16_t>>() = std::make_tuple(getTimeStamp(), registerValue);
}
}
#ifdef __USE_ROOT__
fMonitorDQMPlotCBC->fillLpGBTRegisterPlots(theLpGBTRegisterContainer, registerName, getTimeStamp());
fMonitorDQMPlotCBC->fillLpGBTRegisterPlots(theLpGBTRegisterContainer, registerName);
#else
// auto theLpGBTRegisterStreamer = prepareHybridContainerStreamer<EmptyContainer, uint16_t, EmptyContainer, time_t>("LpGBTRegister");
// auto theLpGBTRegisterStreamer = prepareHybridContainerStreamer<EmptyContainer, std::tuple<time_t,uint16_t>, EmptyContainer>("LpGBTRegister");
// theLpGBTRegisterStreamer.setHeaderElement(getTimeStamp());
// if(fStreamerEnabled)
// {
......
......@@ -263,11 +263,11 @@
<Monitoring type="2S" enable="1">
<MonitoringSleepTime> 100 </MonitoringSleepTime>
<MonitoringElements
CBCThreshold = "1"
CBCThreshold = "0"
LpGBT_ADC1 = "1"
LpGBT_VDD = "1"
LpGBT_VDDA = "1"
LpGBT_TEMP = "1"
LpGBT_TEMP = "0"
/>
</Monitoring>
</MonitoringSettings>
......
......@@ -598,6 +598,7 @@ int main(int argc, char* argv[])
{
LOG(ERROR) << BOLDRED << e.what() << RESET;
LOG(ERROR) << BOLDRED << "Closing ending gently the execution" << RESET;
std::this_thread::sleep_for(std::chrono::seconds(30));
// cTool.SaveResults();
// cTool.WriteRootFile();
// cTool.CloseResultFile();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment