Commit 10271ba0 authored by Mauro Dinardo's avatar Mauro Dinardo
Browse files

Added message for threqu not centered and fixed problem with burstNumbers being too small

parent 4bc29d1d
......@@ -16,7 +16,7 @@ void GainOptimizationHistograms::book(TFile* theOutputFile, const DetectorContai
{
ContainerFactory::copyStructure(theDetectorStructure, DetectorData);
uint16_t rangeKrumCurr = RD53Shared::setBits(static_cast<RD53*>(theDetectorStructure.at(0)->at(0)->at(0)->at(0))->getNumberOfBits("KRUM_CURR_LIN")) + 1;
const uint16_t rangeKrumCurr = RD53Shared::setBits(static_cast<RD53*>(theDetectorStructure.at(0)->at(0)->at(0)->at(0))->getNumberOfBits("KRUM_CURR_LIN")) + 1;
auto hKrumCurr = CanvasContainer<TH1F>("KrumCurr", "KrumCurr", rangeKrumCurr, 0, rangeKrumCurr);
bookImplementer(theOutputFile, theDetectorStructure, KrumCurr, hKrumCurr, "Krummenacher Current", "Entries");
......
......@@ -15,9 +15,9 @@ void PhysicsHistograms::book(TFile* theOutputFile, const DetectorContainer& theD
{
ContainerFactory::copyStructure(theDetectorStructure, DetectorData);
size_t ToTsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TOT / RD53Constants::NPIX_REGION) + 1;
size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1;
size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1;
const size_t ToTsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TOT / RD53Constants::NPIX_REGION) + 1;
const size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1;
const size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1;
auto hToT1D = CanvasContainer<TH1F>("ToT1D", "ToT Distribution", ToTsize, 0, ToTsize);
bookImplementer(theOutputFile, theDetectorStructure, ToT1D, hToT1D, "ToT", "Entries");
......
......@@ -19,11 +19,10 @@ void PixelAliveHistograms::book(TFile* theOutputFile, const DetectorContainer& t
// #######################
// # Retrieve parameters #
// #######################
nEvents = this->findValueInSettings(settingsMap, "nEvents");
size_t ToTsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TOT / RD53Constants::NPIX_REGION) + 1;
size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1;
size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1;
nEvents = this->findValueInSettings(settingsMap, "nEvents");
const size_t ToTsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TOT / RD53Constants::NPIX_REGION) + 1;
const size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1;
const size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1;
auto hOcc1D = CanvasContainer<TH1F>("Occ1D", "Occ1D", nEvents + 1, 0, 1 + 1. / nEvents);
bookImplementer(theOutputFile, theDetectorStructure, Occupancy1D, hOcc1D, "Efficiency", "Entries");
......
......@@ -19,13 +19,12 @@ void ThrEqualizationHistograms::book(TFile* theOutputFile, const DetectorContain
// #######################
// # Retrieve parameters #
// #######################
nEvents = this->findValueInSettings(settingsMap, "nEvents");
nEvents = this->findValueInSettings(settingsMap, "nEvents");
size_t TDACsize = RD53Shared::setBits(RD53Constants::NBIT_TDAC) + 1;
size_t TDACsize = RD53Shared::setBits(RD53Constants::NBIT_TDAC) + 1;
size_t colStart = this->findValueInSettings(settingsMap, "COLstart");
size_t colStop = this->findValueInSettings(settingsMap, "COLstop");
frontEnd = RD53::getMajorityFE(colStart, colStop);
const size_t colStart = this->findValueInSettings(settingsMap, "COLstart");
const size_t colStop = this->findValueInSettings(settingsMap, "COLstop");
frontEnd = RD53::getMajorityFE(colStart, colStop);
if(frontEnd == &RD53::DIFF) TDACsize *= 2;
auto hThrEqualization = CanvasContainer<TH1F>("ThrEqualization", "ThrEqualization", nEvents + 1, 0, 1 + 1. / nEvents);
......
......@@ -16,7 +16,7 @@ void ThresholdHistograms::book(TFile* theOutputFile, const DetectorContainer& th
{
ContainerFactory::copyStructure(theDetectorStructure, DetectorData);
uint16_t rangeThreshold = RD53Shared::setBits(static_cast<RD53*>(theDetectorStructure.at(0)->at(0)->at(0)->at(0))->getNumberOfBits("Vthreshold_LIN")) + 1;
const uint16_t rangeThreshold = RD53Shared::setBits(static_cast<RD53*>(theDetectorStructure.at(0)->at(0)->at(0)->at(0))->getNumberOfBits("Vthreshold_LIN")) + 1;
auto hThrehsold = CanvasContainer<TH1F>("Threhsold", "Threhsold", rangeThreshold, 0, rangeThreshold);
bookImplementer(theOutputFile, theDetectorStructure, Threhsold, hThrehsold, "Threhsold", "Entries");
......
......@@ -687,20 +687,10 @@ uint32_t RD53FWInterface::ReadData(BeBoard* pBoard, bool pBreakTrigger, std::vec
{
uint32_t nWordsInMemoryOld, nWordsInMemory = 0;
// ########################################
// # Wait until we have something in DDR3 #
// ########################################
if(HANDSHAKE_EN == true)
while(ReadReg("user.stat_regs.readout4.readout_req") == 0)
{
LOG(ERROR) << BOLDRED << "Waiting for readout request, FSM status: " << BOLDYELLOW << ReadReg("user.stat_regs.readout4.fsm_status") << RESET;
usleep(READOUTSLEEP);
}
nWordsInMemory = ReadReg("user.stat_regs.words_to_read");
// #############################################
// # Wait for a stable number of words to read #
// #############################################
nWordsInMemory = ReadReg("user.stat_regs.words_to_read");
do
{
nWordsInMemoryOld = nWordsInMemory;
......@@ -1138,14 +1128,6 @@ void RD53FWInterface::ConfigureFastCommands(const FastCommandsConfig* cfg)
{"user.ctrl_regs.fast_cmd_reg_7.glb_pulse_data", (uint32_t)bits::pack<4, 1, 4, 1>(RD53Constants::BROADCAST_CHIPID, 0, 8, 0)}});
RD53FWInterface::SendBoardCommand("user.ctrl_regs.fast_cmd_reg_1.load_config");
// #############################
// # Configuring readout block #
// #############################
RegManager::WriteStackReg({
{"user.ctrl_regs.readout_block.data_handshake_en", HANDSHAKE_EN},
{"user.ctrl_regs.readout_block.l1a_timeout_value", L1A_TIMEOUT},
});
}
void RD53FWInterface::SetAndConfigureFastCommands(const BeBoard* pBoard, size_t nTRIGxEvent, size_t injType, uint32_t nClkDelays, bool enableAutozero)
......@@ -1259,6 +1241,7 @@ void RD53FWInterface::SetAndConfigureFastCommands(const BeBoard* pBoard, size_t
<< 1. / (FSMperiod * (RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_ecr + RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_inject +
RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_trigger + RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_prime))
<< std::setprecision(-1) << " Hz" << RESET;
RD53Shared::resetDefaultFloat();
// ##############################
// # Download the configuration #
......
......@@ -36,12 +36,6 @@
#define NBIT_FWVER 16 // Number of bits for the firmware version
#define IPBUS_FASTDURATION 1 // Duration of a fast command in terms of 40 MHz clk cycles
// #################
// # READOUT BLOCK #
// #################
#define HANDSHAKE_EN false
#define L1A_TIMEOUT 4000
namespace RD53FWEvtEncoder
{
// ################
......
......@@ -44,6 +44,7 @@ class RD53RunProgress
LOG(INFO) << GREEN << "n. 32 bit words : " << std::setw(9) << std::fixed << dataSize << RESET;
LOG(INFO) << BOLDMAGENTA << ">>>> Progress : " << std::setw(5) << std::setprecision(1) << std::fixed << fraction * 100 << "% <<<<" << std::setprecision(-1) << RESET;
LOG(INFO) << CYAN << "---------------------------" << RESET;
RD53Shared::resetDefaultFloat();
if(fraction != 1)
for(int i = 0; i < 5; i++) std::cout << "\x1b[A";
}
......
......@@ -33,3 +33,5 @@ size_t RD53Shared::countBitsOne(size_t num)
}
return count;
}
void RD53Shared::resetDefaultFloat() { std::cout.setf(std::ios_base::fmtflags(0), std::ios_base::floatfield); }
......@@ -10,10 +10,11 @@
#ifndef RD53Shared_H
#define RD53Shared_H
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <thread>
#include <iostream>
namespace RD53Shared
{
......@@ -27,6 +28,7 @@ const size_t NTHREADS = round(std::thread::hardware_concurrency() / 2.); //
std::string fromInt2Str(int val);
std::string composeFileName(const std::string& configFileName, const std::string& fName2Add);
size_t countBitsOne(size_t num);
void resetDefaultFloat();
constexpr size_t setBits(size_t nBit2Set) { return (1 << nBit2Set) - 1; }
} // namespace RD53Shared
......
......@@ -363,6 +363,7 @@ std::shared_ptr<DetectorDataContainer> Gain::analyze()
LOG(INFO) << BOLDBLUE << "\t--> Highest gain: " << BOLDYELLOW << std::fixed << std::setprecision(4)
<< theMaxGainContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<float>() << std::setprecision(-1)
<< RESET;
RD53Shared::resetDefaultFloat();
}
return theGainAndInterceptContainer;
......
......@@ -364,7 +364,7 @@ void Physics::monitor()
{
while(this->fKeepRunning == true)
{
for(const auto cBoard: *fDetectorContainer) SystemController::ReadSystemMonitor(cBoard, "VOUT_ana_ShuLDO", "VOUT_dig_ShuLDO", "ADCbandgap", "VREF_VDAC", "Iref", "TEMPSENS_1", "TEMPSENS_4");
for(const auto cBoard: *fDetectorContainer) SystemController::ReadSystemMonitor(cBoard, "VOUT_ana_ShuLDO", "VOUT_dig_ShuLDO", "ADCbandgap", "Iref", "TEMPSENS_1", "TEMPSENS_4");
std::this_thread::sleep_for(std::chrono::seconds(MONITORSLEEP));
}
}
......@@ -349,6 +349,7 @@ std::shared_ptr<DetectorDataContainer> SCurve::analyze()
LOG(INFO) << BOLDBLUE << "\t--> Highest threshold: " << BOLDYELLOW << std::fixed << std::setprecision(1)
<< theMaxThresholdContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<float>()
<< std::setprecision(-1) << RESET;
RD53Shared::resetDefaultFloat();
}
return theThresholdAndNoiseContainer;
......
......@@ -223,19 +223,41 @@ void ThrEqualization::draw()
void ThrEqualization::analyze()
{
const float maxTDACdistance = 2;
const size_t TDACcenter = RD53Shared::setBits(RD53Constants::NBIT_TDAC) / 2;
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
for(const auto cChip: *cHybrid)
{
static_cast<RD53*>(cChip)->copyMaskFromDefault();
float avgTDAC = 0;
int counter = 0;
for(auto row = 0u; row < RD53::nRows; row++)
for(auto col = 0u; col < RD53::nCols; col++)
if(static_cast<RD53*>(cChip)->getChipOriginalMask()->isChannelEnabled(row, col) && this->fChannelGroupHandler->allChannelGroup()->isChannelEnabled(row, col))
{
static_cast<RD53*>(cChip)->setTDAC(
row, col, theTDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getChannel<uint16_t>(row, col));
avgTDAC += theTDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getChannel<uint16_t>(row, col);
counter++;
}
avgTDAC /= counter;
// ###########################
// # Check TDAC distribution #
// ###########################
if(fabs(avgTDAC - TDACcenter) > maxTDACdistance)
{
LOG(WARNING) << BOLDRED << "Average TDAC distribution not centered around " << BOLDYELLOW << TDACcenter << BOLDRED << " (i.e. " << std::setprecision(1) << BOLDYELLOW << avgTDAC
<< BOLDRED << " - center > " << BOLDYELLOW << maxTDACdistance << BOLDRED << ") for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/"
<< cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDRED << "]" << std::setprecision(-1) << RESET;
}
static_cast<RD53*>(cChip)->copyMaskToDefault();
}
}
......
......@@ -1198,7 +1198,7 @@ class MeasureBeBoardDataPerGroup : public ScanBase
void operator()() override
{
uint16_t burstNumbers;
uint32_t burstNumbers;
uint32_t lastBurstNumberOfEvents;
if(fNumberOfEventsPerBurst <= 0)
{
......
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