Commit 01e938b3 authored by Mauro Dinardo's avatar Mauro Dinardo
Browse files

Added TDAC reset for threqu

parent 25b4d8bb
......@@ -380,6 +380,11 @@ void RD53::injectPixel(unsigned int row, unsigned int col, bool inject) { fPixel
void RD53::setTDAC(unsigned int row, unsigned int col, uint8_t TDAC) { fPixelsMask[col].TDAC[row] = TDAC; }
void RD53::resetTDAC()
{
for(auto col = 0u; col < fPixelsMask.size(); col++) fPixelsMask[col].TDAC.fill(RD53Shared::setBits(RD53Constants::NBIT_TDAC) / 2);
}
uint8_t RD53::getTDAC(unsigned int row, unsigned int col) { return fPixelsMask[col].TDAC[row]; }
uint32_t RD53::getNumberOfChannels() const { return nRows * nCols; }
......
......@@ -153,6 +153,7 @@ class RD53 : public ReadoutChip
void enablePixel(unsigned int row, unsigned int col, bool enable);
void injectPixel(unsigned int row, unsigned int col, bool inject);
void setTDAC(unsigned int row, unsigned int col, uint8_t TDAC);
void resetTDAC();
uint8_t getTDAC(unsigned int row, unsigned int col);
uint8_t getChipLane() const { return myChipLane; }
......
......@@ -37,7 +37,7 @@ void OccupancyAndPh::makeSummaryAverage(const std::vector<OccupancyAndPh>* theOc
totalNumberOfEnableChannels += theNumberOfEnabledChannelsList[iContainer];
}
fOccupancy /= totalNumberOfEnableChannels;
fOccupancy /= (totalNumberOfEnableChannels > 0 ? totalNumberOfEnableChannels : 1);
if(fPhError > 0)
{
......
......@@ -68,7 +68,7 @@ inline void OccupancyAndPh::makeChannelAverage<OccupancyAndPh>(const ChipContain
numberOfEnabledChannels++;
}
fOccupancy /= numberOfEnabledChannels;
fOccupancy /= (numberOfEnabledChannels > 0 ? numberOfEnabledChannels : 1);
if(fPhError > 0)
{
......
......@@ -191,6 +191,8 @@
<Setting name="TargetThr"> 2000 </Setting>
<Setting name="TargetOcc"> 1e-6 </Setting>
<Setting name="ThrEquResetTDAC"> 0 </Setting>
<Setting name="DoFast"> 0 </Setting>
<Setting name="DisplayHisto"> 0 </Setting>
<Setting name="UpdateChipCfg"> 1 </Setting>
......
......@@ -211,6 +211,9 @@ void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nE
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer);
ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......
......@@ -212,6 +212,9 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACDACcontainer);
ContainerFactory::copyAndInitChip<float>(*fDetectorContainer, bestContainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......@@ -353,6 +356,9 @@ std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureT
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, *bestDACcontainer);
ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......
......@@ -33,6 +33,7 @@ void ThrEqualization::ConfigureCalibration()
nEvtsBurst = this->findValueInSettings("nEvtsBurst");
startValue = this->findValueInSettings("VCalHstart");
stopValue = this->findValueInSettings("VCalHstop");
resetTDAC = this->findValueInSettings("ThrEquResetTDAC");
nHITxCol = this->findValueInSettings("nHITxCol");
doFast = this->findValueInSettings("DoFast");
doDisplay = this->findValueInSettings("DisplayHisto");
......@@ -156,7 +157,7 @@ void ThrEqualization::run()
// # Run threshold equalization #
// ##############################
size_t TDACsize = RD53Shared::setBits(RD53Constants::NBIT_TDAC) + 1;
if(frontEnd == &RD53::DIFF) TDACsize *=2;
if(frontEnd == &RD53::DIFF) TDACsize *= 2;
this->fDetectorDataContainer = &theOccContainer;
ContainerFactory::copyAndInitStructure<OccupancyAndPh>(*fDetectorContainer, *this->fDetectorDataContainer);
......@@ -259,6 +260,8 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv
DetectorDataContainer bestDACcontainer;
DetectorDataContainer bestContainer;
DetectorDataContainer theTDACcontainer;
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, minDACcontainer, init = startValue);
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, midDACcontainer);
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, maxDACcontainer, init = (stopValue + 1));
......@@ -266,6 +269,11 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer);
ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer);
ContainerFactory::copyAndInitChannel<uint16_t>(*fDetectorContainer, theTDACcontainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......@@ -275,6 +283,22 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv
bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = 0;
}
// ##############
// # Reset TDAC #
// ##############
if(resetTDAC == true)
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
for(const auto cChip: *cHybrid)
{
static_cast<RD53*>(cChip)->resetTDAC();
this->fReadoutChipInterface->ReadChipAllLocalReg(
static_cast<RD53*>(cChip), regName, *theTDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex()));
this->fReadoutChipInterface->WriteChipAllLocalReg(
static_cast<RD53*>(cChip), regName, *theTDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex()));
}
for(auto i = 0u; i <= numberOfBits; i++)
{
// ###########################
......@@ -402,6 +426,9 @@ void ThrEqualization::bitWiseScanLocal(const std::string& regName, uint32_t nEve
ContainerFactory::copyAndInitChannel<uint16_t>(*fDetectorContainer, bestDACcontainer);
ContainerFactory::copyAndInitChannel<OccupancyAndPh>(*fDetectorContainer, bestContainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: bestContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......
......@@ -62,6 +62,7 @@ class ThrEqualization : public PixelAlive
size_t nEvtsBurst;
size_t startValue;
size_t stopValue;
bool resetTDAC;
size_t nHITxCol;
bool doFast;
......
......@@ -208,6 +208,9 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv
ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer);
ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer);
// #########################
// # Initialize containers #
// #########################
for(const auto cBoard: *fDetectorContainer)
for(const auto cOpticalGroup: *cBoard)
for(const auto cHybrid: *cOpticalGroup)
......
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