diff --git a/DQMUtils/RD53GainOptimizationHistograms.cc b/DQMUtils/RD53GainOptimizationHistograms.cc index 8dffca220144a9de106ada76152cc11c32bc686a..c50b0bac62fe4d93c3de87e96506e22a6e16b950 100644 --- a/DQMUtils/RD53GainOptimizationHistograms.cc +++ b/DQMUtils/RD53GainOptimizationHistograms.cc @@ -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"); diff --git a/DQMUtils/RD53PhysicsHistograms.cc b/DQMUtils/RD53PhysicsHistograms.cc index eb965da631a75af40e6a666604b2d4e64d64ae63..70e6a9c22bf3d736729025a885d0b1ba95ab76ad 100644 --- a/DQMUtils/RD53PhysicsHistograms.cc +++ b/DQMUtils/RD53PhysicsHistograms.cc @@ -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"); diff --git a/DQMUtils/RD53PixelAliveHistograms.cc b/DQMUtils/RD53PixelAliveHistograms.cc index e32db48dbd5f492fb18d004fe5c58e331c05103e..48ef1a4c975ae558cd4b6e43464f20faa5422ca5 100644 --- a/DQMUtils/RD53PixelAliveHistograms.cc +++ b/DQMUtils/RD53PixelAliveHistograms.cc @@ -16,12 +16,16 @@ void PixelAliveHistograms::book(TFile* theOutputFile, const DetectorContainer& t { 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; + // ####################### + // # Retrieve parameters # + // ####################### + 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", 200 + 1, 0, 1 + 1. / 200); - bookImplementer(theOutputFile, theDetectorStructure, Occupancy1D, hOcc1D, "Number of hits", "Entries"); + auto hOcc1D = CanvasContainer<TH1F>("Occ1D", "Occ1D", nEvents + 1, 0, 1 + 1. / nEvents); + bookImplementer(theOutputFile, theDetectorStructure, Occupancy1D, hOcc1D, "Efficiency", "Entries"); auto hOcc2D = CanvasContainer<TH2F>("PixelAlive", "Pixel Alive", RD53::nCols, 0, RD53::nCols, RD53::nRows, 0, RD53::nRows); bookImplementer(theOutputFile, theDetectorStructure, Occupancy2D, hOcc2D, "Columns", "Rows"); @@ -93,9 +97,9 @@ void PixelAliveHistograms::fill(const DetectorDataContainer& DataContainer) for(auto row = 0u; row < RD53::nRows; row++) for(auto col = 0u; col < RD53::nCols; col++) { - if(cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy != 0) + if(cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy != RD53Shared::ISDISABLED) { - Occupancy1DHist->Fill(cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy); + Occupancy1DHist->Fill(cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy + Occupancy1DHist->GetBinWidth(0) / 2); Occupancy2DHist->SetBinContent(col + 1, row + 1, cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy); ToTHist->Fill(cChip->getChannel<OccupancyAndPh>(row, col).fPh); } diff --git a/DQMUtils/RD53PixelAliveHistograms.h b/DQMUtils/RD53PixelAliveHistograms.h index 1802bc93ccdac9cf67e5499266f662132d5adfe8..9e75cf5d581bb9f023f22ad4d848de0426cdebf2 100644 --- a/DQMUtils/RD53PixelAliveHistograms.h +++ b/DQMUtils/RD53PixelAliveHistograms.h @@ -40,6 +40,8 @@ class PixelAliveHistograms : public DQMHistogramBase DetectorDataContainer ToT; DetectorDataContainer BCID; DetectorDataContainer TriggerID; + + size_t nEvents; }; #endif diff --git a/DQMUtils/RD53SCurveHistograms.cc b/DQMUtils/RD53SCurveHistograms.cc index a6ebc21c31e835e37486e08c6afc77e289956baa..8fc66796e5d623e0f6495ce5bd85ef2b60a7d616 100644 --- a/DQMUtils/RD53SCurveHistograms.cc +++ b/DQMUtils/RD53SCurveHistograms.cc @@ -25,7 +25,7 @@ void SCurveHistograms::book(TFile* theOutputFile, const DetectorContainer& theDe stopValue = this->findValueInSettings(settingsMap, "VCalHstop"); offset = this->findValueInSettings(settingsMap, "VCalMED"); - auto hOcc2D = CanvasContainer<TH2F>("SCurves", "SCurves", nSteps, startValue - offset, stopValue - offset, nEvents + 1, 0, 1 + 1. / nEvents); + auto hOcc2D = CanvasContainer<TH2F>("SCurves", "SCurves", nSteps, startValue - offset, stopValue - offset, 2 * nEvents + 1, 0, 2 + 1. / nEvents); bookImplementer(theOutputFile, theDetectorStructure, Occupancy2D, hOcc2D, "#DeltaVCal", "Efficiency"); auto hErrorReadOut2D = CanvasContainer<TH2F>("ReadoutErrors", "Readout Errors", RD53::nCols, 0, RD53::nCols, RD53::nRows, 0, RD53::nRows); @@ -90,6 +90,8 @@ void SCurveHistograms::fillOccupancy(const DetectorDataContainer& OccupancyConta hOcc2D->Fill(DELTA_VCAL, cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy + hOcc2D->GetYaxis()->GetBinWidth(0) / 2.); if(cChip->getChannel<OccupancyAndPh>(row, col).readoutError == true) ErrorReadOut2DHist->Fill(col + 1, row + 1); } + + hOcc2D->GetYaxis()->SetRangeUser(0, 1 + 1. / nEvents); } } diff --git a/DQMUtils/RD53ThrEqualizationHistograms.cc b/DQMUtils/RD53ThrEqualizationHistograms.cc index 17fe9f8fad6402c411afc9752b7b26d5032124b8..c4919a88342291fa58a08df123d02239bf5613d9 100644 --- a/DQMUtils/RD53ThrEqualizationHistograms.cc +++ b/DQMUtils/RD53ThrEqualizationHistograms.cc @@ -19,10 +19,14 @@ 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; + 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); bookImplementer(theOutputFile, theDetectorStructure, ThrEqualization, hThrEqualization, "Efficiency", "Entries"); @@ -75,6 +79,7 @@ void ThrEqualizationHistograms::fillOccupancy(const DetectorDataContainer& Occup void ThrEqualizationHistograms::fillTDAC(const DetectorDataContainer& TDACContainer) { size_t TDACsize = RD53Shared::setBits(RD53Constants::NBIT_TDAC) + 1; + if(frontEnd == &RD53::DIFF) TDACsize *= 2; for(const auto cBoard: TDACContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/DQMUtils/RD53ThrEqualizationHistograms.h b/DQMUtils/RD53ThrEqualizationHistograms.h index c11b5c1c342fc923b93ab175a049bf4efa9ee1ef..30b9c0e0a78eb655a1ad50b03462ff4944ee6a0b 100644 --- a/DQMUtils/RD53ThrEqualizationHistograms.h +++ b/DQMUtils/RD53ThrEqualizationHistograms.h @@ -39,6 +39,8 @@ class ThrEqualizationHistograms : public DQMHistogramBase size_t nEvents; size_t VCalHnsteps; + + const Ph2_HwDescription::RD53::FrontEnd* frontEnd; }; #endif diff --git a/DQMUtils/RD53ThresholdHistograms.cc b/DQMUtils/RD53ThresholdHistograms.cc index 6fd85120cd65232a8ec92c82d622f14c27450c2c..f79e5a4ae69058bbdb51cbb508eed8f1d0320951 100644 --- a/DQMUtils/RD53ThresholdHistograms.cc +++ b/DQMUtils/RD53ThresholdHistograms.cc @@ -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"); diff --git a/HWDescription/MPA.cc b/HWDescription/MPA.cc index f05478c2b2ca025fe818a70aa132d7d2b1011187..7cadf82dde9cf17cd14b4a0d6cd9dddbf9fe30d3 100644 --- a/HWDescription/MPA.cc +++ b/HWDescription/MPA.cc @@ -26,7 +26,7 @@ MPA::MPA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pMPAId, uint8_t p { fMaxRegValue = 255; fChipOriginalMask = new ChannelGroup<1920>; - fPartnerId = pPartnerId; + fPartnerId = pPartnerId; loadfRegMap(filename); setFrontEndType(FrontEndType::MPA); } @@ -35,7 +35,7 @@ MPA::MPA(const FrontEndDescription& pFeDesc, uint8_t pMPAId, uint8_t pPartnerId, { fMaxRegValue = 255; // 8 bit registers in MPA fChipOriginalMask = new ChannelGroup<1920>; - fPartnerId = pPartnerId; + fPartnerId = pPartnerId; loadfRegMap(filename); setFrontEndType(FrontEndType::MPA); } @@ -103,7 +103,6 @@ void MPA::loadfRegMap(const std::string& filename) } // end loadfRegMap - void MPA::saveRegMap(const std::string& filename) { // start saveRegMap diff --git a/HWDescription/MPA.h b/HWDescription/MPA.h index 0c2cd2163430778ec8e817d9c0851eb4192ee288..eb6dc3ae5b7423edc9d54fca3e68039a0b782a1b 100644 --- a/HWDescription/MPA.h +++ b/HWDescription/MPA.h @@ -42,9 +42,9 @@ class MPA : public ReadoutChip using MPARegPair = std::pair<std::string, ChipRegItem>; uint8_t fPartnerId; - uint8_t getPartid() {return fPartnerId;} - void loadfRegMap(const std::string& filename) override; - void saveRegMap(const std::string& filename) override; + uint8_t getPartid() { return fPartnerId; } + void loadfRegMap(const std::string& filename) override; + void saveRegMap(const std::string& filename) override; bool isDACLocal(const std::string& dacName) override { @@ -61,13 +61,13 @@ class MPA : public ReadoutChip return 8; } - // row, col starts at index 0, global pix number starts at number 1 + // row, col starts at index 0, global pix number starts at number 1 - std::pair<uint32_t, uint32_t> PNlocal(const uint32_t PN) { return std::pair<uint32_t, uint32_t>((PN+1) / 120 , ((PN+1) % 120) - 2 ); } + std::pair<uint32_t, uint32_t> PNlocal(const uint32_t PN) { return std::pair<uint32_t, uint32_t>((PN + 1) / 120, ((PN + 1) % 120) - 2); } uint32_t getNumberOfChannels() const override { return NMPACHANNELS; } - uint32_t PNglobal(std::pair<uint32_t, uint32_t> PC) { return (PC.first) * 120 + (PC.second) +1; } + uint32_t PNglobal(std::pair<uint32_t, uint32_t> PC) { return (PC.first) * 120 + (PC.second) + 1; } }; struct MPARegItemComparer diff --git a/HWDescription/RD53.cc b/HWDescription/RD53.cc index 4422367621e58fbde5fc3ca5a48f8fadc65f206e..b5eb21c3c0d34d631b71c52b509e9aa2cf195995 100644 --- a/HWDescription/RD53.cc +++ b/HWDescription/RD53.cc @@ -242,7 +242,7 @@ void RD53::saveRegMap(const std::string& fName2Add) { const int Nspaces = 26; - std::string output = RD53Shared::composeFileName(configFileName, fName2Add); + std::string output = RD53::getFileName(fName2Add); std::ofstream file(output.c_str(), std::ios::out | std::ios::trunc); if(file) @@ -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; } diff --git a/HWDescription/RD53.h b/HWDescription/RD53.h index 9b407566c3679b8d6d489cd0a1c104c7c25460eb..fbe5f43ba191cbb1db3b2a34bbe69a1326b8f187 100644 --- a/HWDescription/RD53.h +++ b/HWDescription/RD53.h @@ -29,16 +29,19 @@ // ######################### namespace RD53Constants { -const uint8_t BROADCAST_CHIPID = 0x8; // Broadcast chip ID used to send the command to multiple chips -const uint8_t NREGIONS_LONGCMD = 6; // Number of regions to program with long write commands -const uint8_t FIELDS_SHORTCMD = 8; // Number of fields for the short write command -const uint8_t FIELDS_LONGCMD = 24; // Number of fields for the long write command -const uint8_t NBIT_TDAC = 4; // Number of TDAC bits -const uint8_t NBIT_MAXREG = 16; // Maximum number of bits for a chip register -const uint8_t NPIX_REGION = 4; // Number of pixels in a region (1x4) -const uint8_t NROW_CORE = 8; // Number of rows in a core -const uint8_t NBIT_ADDR = 9; // Number of address bits -const uint8_t NSYNC_WORS = 32; // Number of Sync words for synchronization +const uint8_t BROADCAST_CHIPID = 0x8; // Broadcast chip ID used to send the command to multiple chips +const uint8_t NREGIONS_LONGCMD = 6; // Number of regions to program with long write commands +const uint8_t FIELDS_SHORTCMD = 8; // Number of fields for the short write command +const uint8_t FIELDS_LONGCMD = 24; // Number of fields for the long write command +const uint8_t NBIT_TDAC = 4; // Number of TDAC bits +const uint8_t NBIT_MAXREG = 16; // Maximum number of bits for a chip register +const uint8_t NPIX_REGION = 4; // Number of pixels in a region (1x4) +const uint8_t NROW_CORE = 8; // Number of rows in a core +const uint8_t NBIT_ADDR = 9; // Number of address bits +const uint8_t NSYNC_WORS = 32; // Number of Sync words for synchronization +const uint8_t CDRCONFIG_ADDR = 0x40; // Address of CDR_CONFIG register +const uint16_t CDRCONFIG_1Gbit = 1048; // Value for 1.28 Gbit/s +const uint16_t CDRCONFIG_640Mbit = 1049; // Value for 640 Mbit/s } // namespace RD53Constants // ############ @@ -153,6 +156,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; } diff --git a/HWDescription/SSA.cc b/HWDescription/SSA.cc index f15cf93f2c5530df78d277daca2f2bff1b7b8fcb..06dc7216af91822e92adb84801e3d98299f52f56 100644 --- a/HWDescription/SSA.cc +++ b/HWDescription/SSA.cc @@ -22,11 +22,11 @@ namespace Ph2_HwDescription { // open namespace -SSA::SSA(const FrontEndDescription& pFeDesc, uint8_t pSSAId, uint8_t pPartnerId, uint8_t pSSASide, const std::string& filename) : ReadoutChip(pFeDesc, pSSAId) +SSA::SSA(const FrontEndDescription& pFeDesc, uint8_t pSSAId, uint8_t pPartnerId, uint8_t pSSASide, const std::string& filename) : ReadoutChip(pFeDesc, pSSAId) { fMaxRegValue = 255; // 8 bit registers in CBC fChipOriginalMask = new ChannelGroup<120>; - fPartnerId = pPartnerId; + fPartnerId = pPartnerId; loadfRegMap(filename); setFrontEndType(FrontEndType::SSA); } @@ -35,7 +35,7 @@ SSA::SSA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pSSAId, uint8_t p { fMaxRegValue = 255; // 8 bit registers in CBC fChipOriginalMask = new ChannelGroup<120>; - fPartnerId = pPartnerId; + fPartnerId = pPartnerId; loadfRegMap(filename); setFrontEndType(FrontEndType::SSA); } @@ -106,10 +106,6 @@ void SSA::loadfRegMap(const std::string& filename) } // end loadfRegMap - - - - void SSA::saveRegMap(const std::string& filename) { // start saveRegMap diff --git a/HWDescription/SSA.h b/HWDescription/SSA.h index 3e58b7051e93a9872ab91d11bdfbc9d0f46ff313..383e5ba80adfb030037d01a3e3b3fc0bc964ae7d 100644 --- a/HWDescription/SSA.h +++ b/HWDescription/SSA.h @@ -38,8 +38,8 @@ class SSA : public ReadoutChip SSA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pSSAId, uint8_t pPartnerId, uint8_t pSSASide, const std::string& filename); // C'tors with object FE Description SSA(const FrontEndDescription& pFeDesc, uint8_t pSSAId, uint8_t pPartnerId, uint8_t pSSASide, const std::string& filename); - uint8_t fPartnerId; - uint8_t getPartid() {return fPartnerId;} + uint8_t fPartnerId; + uint8_t getPartid() { return fPartnerId; } virtual void accept(HwDescriptionVisitor& pVisitor) { pVisitor.visitChip(*this); } void loadfRegMap(const std::string& filename) override; void saveRegMap(const std::string& filename) override; diff --git a/HWInterface/D19cFWInterface.cc b/HWInterface/D19cFWInterface.cc index c0fabbf7ede7b2a91826c88d2af7a33b7623d1fc..695e6c736c0a226a258c6f4bd6c3dc31a0b3ec25 100644 --- a/HWInterface/D19cFWInterface.cc +++ b/HWInterface/D19cFWInterface.cc @@ -3700,18 +3700,11 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPA(float VDDPST, float DVDD, flo PSInterfaceBoard_ConfigureI2CMaster(0, SLOW); } - - - void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, float AVDD, float VBG, float VBF, uint8_t mpaid, uint8_t ssaid) { - this->getBoardInfo(); this->PSInterfaceBoard_PowerOn(0, 0); - - - uint32_t write = 0; uint32_t SLOW = 2; uint32_t i2cmux = 0; @@ -3724,9 +3717,6 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, float Vc = 0.0003632813; - - - LOG(INFO) << "mpa vdd on"; float Vlimit = 1.32; @@ -3736,12 +3726,10 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, if(setvoltage > 4095) setvoltage = 4095; setvoltage = setvoltage << 4; - PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646 PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x34, setvoltage); // tx to DAC C std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - LOG(INFO) << "ssa vdd on"; Vlimit = 1.32; @@ -3756,8 +3744,6 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x33, setvoltage); // tx to DAC C std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - - LOG(INFO) << "mpa vddD on"; Vlimit = 1.2; if(DVDD > Vlimit) DVDD = Vlimit; @@ -3781,7 +3767,6 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x31, setvoltage); // tx to DAC C std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - LOG(INFO) << "mpa vddA on"; Vlimit = 1.32; if(AVDD > Vlimit) AVDD = Vlimit; @@ -3804,10 +3789,6 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x35, setvoltage); // tx to DAC C std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - - - - LOG(INFO) << "mpa VBG on"; Vlimit = 0.5; if(VBG > Vlimit) VBG = Vlimit; @@ -3841,7 +3822,6 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, std::this_thread::sleep_for(std::chrono::milliseconds(500)); PSInterfaceBoard_SendI2CCommand(pcf8574, 0, write, 0, 145); // set reset bit - /*LOG(INFO) << "mpa enable"; //uint32_t val2 = (mpaid << 5) + 16; uint32_t val2 = (mpaid << 5) + (ssaid << 1) + 1; // reset bit for MPA @@ -3853,11 +3833,8 @@ void D19cFWInterface::PSInterfaceBoard_PowerOn_MPASSA(float VDDPST, float DVDD, // disable the i2c master at the end (first set the mux to the chip PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x04); PSInterfaceBoard_ConfigureI2CMaster(0, SLOW); - } - - void D19cFWInterface::PSInterfaceBoard_PowerOff_SSA(uint8_t mpaid, uint8_t ssaid) { uint32_t write = 0; diff --git a/HWInterface/D19cFWInterface.h b/HWInterface/D19cFWInterface.h index cf7594c29d66b227c560a9bf1e8cb913f100c8bd..b11096e036ac5b21bebf00bd0f07fe82ca358f19 100644 --- a/HWInterface/D19cFWInterface.h +++ b/HWInterface/D19cFWInterface.h @@ -655,7 +655,7 @@ class D19cFWInterface : public BeBoardFWInterface void PSInterfaceBoard_PowerOn(uint8_t mpaid = 0, uint8_t ssaid = 0); void PSInterfaceBoard_PowerOff(); - void PSInterfaceBoard_PowerOn_MPASSA(float VDDPST = 1.25, float DVDD = 1.2, float AVDD = 1.25, float VBG = 0.3, float VBF=0.3,uint8_t mpaid = 0, uint8_t ssaid = 0); + void PSInterfaceBoard_PowerOn_MPASSA(float VDDPST = 1.25, float DVDD = 1.2, float AVDD = 1.25, float VBG = 0.3, float VBF = 0.3, uint8_t mpaid = 0, uint8_t ssaid = 0); // MPA power on void PSInterfaceBoard_PowerOn_MPA(float VDDPST = 1.25, float DVDD = 1.2, float AVDD = 1.25, float VBG = 0.3, uint8_t mpaid = 0, uint8_t ssaid = 0); void PSInterfaceBoard_PowerOff_MPA(uint8_t mpaid = 0, uint8_t ssaid = 0); diff --git a/HWInterface/D19clpGBTInterface.cc b/HWInterface/D19clpGBTInterface.cc index 6face9d36e1dbdeb98a629a037aef36a9e69b1ba..34f89151c02a169e413dc1c201fba44bc545b73f 100644 --- a/HWInterface/D19clpGBTInterface.cc +++ b/HWInterface/D19clpGBTInterface.cc @@ -22,7 +22,7 @@ bool D19clpGBTInterface::ConfigureChip(Ph2_HwDescription::Chip* pChip, bool pVer { LOG(INFO) << BOLDBLUE << "Configuring lpGBT" << RESET; setBoard(pChip->getBeBoardId()); - //Load register map from configuration file + // Load register map from configuration file ChipRegMap clpGBTRegMap = pChip->getRegMap(); for(const auto& cRegItem: clpGBTRegMap) { diff --git a/HWInterface/MPAInterface.cc b/HWInterface/MPAInterface.cc index 92b18415127ae8370e53f06ac0e291d7a4162a30..9889784a1e2089d6eb3a382b0de00efcf618ba43 100644 --- a/HWInterface/MPAInterface.cc +++ b/HWInterface/MPAInterface.cc @@ -170,7 +170,7 @@ bool MPAInterface::ConfigureChip(Chip* pMPA, bool pVerifLoop, uint32_t pBlockSiz if(cSuccess) { auto cReadBack = ReadChipReg(pMPA, cRegItem.first); - //LOG(INFO) << BOLDRED << cRegItem.first<<" "<<cReadBack<<","<<cRegItem.second.fValue << RESET; + // LOG(INFO) << BOLDRED << cRegItem.first<<" "<<cReadBack<<","<<cRegItem.second.fValue << RESET; if(cReadBack != cRegItem.second.fValue) { std::size_t found = (cRegItem.first).find("ReadCounter"); diff --git a/HWInterface/MPAInterface.h b/HWInterface/MPAInterface.h index 2b86c316a50b2f8038b12ab5fc1f2c5891f3fd11..6a4cc7431285e5150f1351ef405966759192b220 100644 --- a/HWInterface/MPAInterface.h +++ b/HWInterface/MPAInterface.h @@ -78,7 +78,7 @@ class MPAInterface : public ReadoutChipInterface void Activate_sync(Ph2_HwDescription::Chip* pMPA); void Activate_pp(Ph2_HwDescription::Chip* pMPA); void Activate_ss(Ph2_HwDescription::Chip* pMPA); - void Activate_ps(Ph2_HwDescription::Chip* pMPA, uint8_t win=8); + void Activate_ps(Ph2_HwDescription::Chip* pMPA, uint8_t win = 8); void Enable_pix_counter(Ph2_HwDescription::ReadoutChip* pMPA, uint32_t p); void Enable_pix_sync(Ph2_HwDescription::ReadoutChip* pMPA, uint32_t p); diff --git a/HWInterface/RD53FWInterface.cc b/HWInterface/RD53FWInterface.cc index fa3c4c30716a7fe56748e004c043c5f5a5010836..b93404f7955bcfda2866d4cf33fc6d65024ea29d 100644 --- a/HWInterface/RD53FWInterface.cc +++ b/HWInterface/RD53FWInterface.cc @@ -152,7 +152,11 @@ void RD53FWInterface::ConfigureBoard(const BeBoard* pBoard) // ############################## // # AURORA lock on data stream # // ############################## - while(RD53FWInterface::CheckChipCommunication() == false) RD53FWInterface::InitHybridByHybrid(pBoard); + if(RD53FWInterface::CheckChipCommunication() == false) + { + RD53FWInterface::InitHybridByHybrid(pBoard); + RD53FWInterface::CheckChipCommunication(); + } } void RD53FWInterface::ConfigureFromXML(const BeBoard* pBoard) @@ -180,13 +184,16 @@ void RD53FWInterface::ConfigureFromXML(const BeBoard* pBoard) } void RD53FWInterface::WriteChipCommand(const std::vector<uint16_t>& data, int hybridId) -// ############################################# -// # hybridId < 0 --> broadcast to all hybrids # -// ############################################# { - size_t n32bitWords = (data.size() / 2) + (data.size() % 2); - bool retry; - int nAttempts = 0; + std::vector<uint32_t> commandList; + + RD53FWInterface::ComposeAndPackChipCommands(data, hybridId, commandList); + RD53FWInterface::SendChipCommandsPack(commandList); +} + +void RD53FWInterface::ComposeAndPackChipCommands(const std::vector<uint16_t>& data, int hybridId, std::vector<uint32_t>& commandList) +{ + const size_t n32bitWords = (data.size() / 2) + (data.size() % 2); // ##################### // # Check if all good # @@ -194,25 +201,29 @@ void RD53FWInterface::WriteChipCommand(const std::vector<uint16_t>& data, int hy if(ReadReg("user.stat_regs.slow_cmd.error_flag") == true) LOG(ERROR) << BOLDRED << "Write-command FIFO error" << RESET; if(ReadReg("user.stat_regs.slow_cmd.fifo_empty") == false) LOG(ERROR) << BOLDRED << "Write-command FIFO not empty" << RESET; - // ####################### - // # Load command vector # - // ####################### - std::vector<uint32_t> stackRegisters; - stackRegisters.reserve(n32bitWords + 1); - - // Header - stackRegisters.emplace_back(bits::pack<6, 10, 4, 12>(HEADEAR_WRTCMD, (hybridId < 0 ? enabledHybrids : 1 << hybridId), 0, n32bitWords)); + // ########## + // # Header # + // ########## + commandList.emplace_back(bits::pack<6, 10, 4, 12>(HEADEAR_WRTCMD, (hybridId < 0 ? enabledHybrids : 1 << hybridId), 0, n32bitWords)); - // Commands - for(auto i = 1u; i < data.size(); i += 2) stackRegisters.emplace_back(bits::pack<16, 16>(data[i - 1], data[i])); + // ############ + // # Commands # + // ############ + for(auto i = 1u; i < data.size(); i += 2) commandList.emplace_back(bits::pack<16, 16>(data[i - 1], data[i])); // If data.size() is not even, add a sync command - if(data.size() % 2 != 0) stackRegisters.emplace_back(bits::pack<16, 16>(data.back(), RD53CmdEncoder::SYNC)); + if(data.size() % 2 != 0) commandList.emplace_back(bits::pack<16, 16>(data.back(), RD53CmdEncoder::SYNC)); +} + +void RD53FWInterface::SendChipCommandsPack(const std::vector<uint32_t>& commandList) +{ + int nAttempts = 0; + bool retry; // ############################### // # Send command(s) to the chip # // ############################### - RegManager::WriteBlockReg("user.ctrl_regs.Slow_cmd_fifo_din", stackRegisters); + RegManager::WriteBlockReg("user.ctrl_regs.Slow_cmd_fifo_din", commandList); RegManager::WriteStackReg({{"user.ctrl_regs.Slow_cmd.dispatch_packet", 1}, {"user.ctrl_regs.Slow_cmd.dispatch_packet", 0}}); // #################################### @@ -321,8 +332,8 @@ bool RD53FWInterface::CheckChipCommunication() // ############################### // # Check RD53 AURORA registers # // ############################### - unsigned int speed_flag = ReadReg("user.stat_regs.aurora_rx.speed"); - LOG(INFO) << BOLDBLUE << "\t--> Aurora speed: " << BOLDYELLOW << (speed_flag == 0 ? "1.28 Gbps" : "640 Mbps") << RESET; + auroraSpeed = ReadReg("user.stat_regs.aurora_rx.speed"); + LOG(INFO) << BOLDBLUE << "\t--> Aurora speed: " << BOLDYELLOW << (auroraSpeed == 0 ? "1.28 Gbps" : "640 Mbps") << RESET; // ######################################## // # Check communication with the chip(s) # @@ -356,9 +367,9 @@ void RD53FWInterface::InitHybridByHybrid(const BeBoard* pBoard) for(const auto cOpticalGroup: *pBoard) for(const auto cHybrid: *cOpticalGroup) { - // ############################# - // # Check if all lanes are up # - // ############################# + // ################################# + // # Check if all lanes are active # + // ################################# const uint32_t hybrid_id = cHybrid->getId(); const uint32_t chips_en_to_check = RD53FWInterface::GetHybridEnabledChips(cHybrid); const uint32_t channel_up = ReadReg("user.stat_regs.aurora_rx_channel_up"); @@ -384,12 +395,20 @@ void RD53FWInterface::InitHybridByHybrid(const BeBoard* pBoard) for(unsigned int i = 0; i < MAXATTEMPTS; i++) { + // ########################### + // # Set proper AURORA speed # + // ########################### + if(auroraSpeed == 0) + RD53FWInterface::WriteChipCommand(RD53Cmd::WrReg(RD53Constants::BROADCAST_CHIPID, RD53Constants::CDRCONFIG_ADDR, RD53Constants::CDRCONFIG_1Gbit).getFrames(), -1); + else + RD53FWInterface::WriteChipCommand(RD53Cmd::WrReg(RD53Constants::BROADCAST_CHIPID, RD53Constants::CDRCONFIG_ADDR, RD53Constants::CDRCONFIG_640Mbit).getFrames(), -1); + RD53FWInterface::WriteChipCommand(initSequence, hybrid_id); usleep(DEEPSLEEP); - // ############################# - // # Check if all lanes are up # - // ############################# + // ################################# + // # Check if all lanes are active # + // ################################# lanes_up = false; uint32_t channel_up = ReadReg("user.stat_regs.aurora_rx_channel_up"); @@ -408,7 +427,7 @@ void RD53FWInterface::InitHybridByHybrid(const BeBoard* pBoard) if(lanes_up == true) break; } - if(lanes_up == false) LOG(ERROR) << BOLDRED << "Not all data lanes are up for hybrid: " << BOLDYELLOW << hybrid_id << RESET; + if(lanes_up == false) LOG(ERROR) << BOLDRED << "Not all data lanes are active for hybrid: " << BOLDYELLOW << hybrid_id << RESET; } } @@ -687,20 +706,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; @@ -779,55 +788,57 @@ void RD53FWInterface::ReadNEvents(BeBoard* pBoard, uint32_t pNEvents, std::vecto // ########################################## // # Use of OpenMP (compiler flag -fopenmp) # // ########################################## -uint16_t RD53FWInterface::DecodeEventsMultiThreads (const std::vector<uint32_t>& data, -std::vector<RD53FWInterface::Event>& events) +uint16_t RD53FWInterface::DecodeEventsMultiThreads(const std::vector<uint32_t>& data, std::vector<RD53FWInterface::Event>& events) { - // ###################### - // # Consistency checks # - // ###################### - if (data.size() == 0) return RD53FWEvtEncoder::EMPTY; - - - uint16_t evtStatus = RD53FWEvtEncoder::GOOD; + // ###################### + // # Consistency checks # + // ###################### + if(data.size() == 0) return RD53FWEvtEncoder::EMPTY; - std::vector<size_t> eventStart; - for (auto i = 0u; i < data.size(); i++) - if (data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) eventStart.push_back(i); - if (eventStart.size() == 0) return RD53FWEvtEncoder::NOHEADER; - const auto nEvents = ceil(static_cast<double>(eventStart.size()) / omp_get_max_threads()); - eventStart.push_back(data.size()); + uint16_t evtStatus = RD53FWEvtEncoder::GOOD; + std::vector<size_t> eventStart; + size_t i = 0u; + while(i < data.size()) + if(data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) + { + eventStart.push_back(i); + i += RD53FWEvtEncoder::EVT_HEADER_SIZE; + } + else + i++; + if(eventStart.size() == 0) return RD53FWEvtEncoder::NOHEADER; + const auto nEvents = ceil(static_cast<double>(eventStart.size()) / omp_get_max_threads()); + eventStart.push_back(data.size()); - // ###################### - // # Unpack data vector # - // ###################### - #pragma omp parallel + // ###################### + // # Unpack data vector # + // ###################### +#pragma omp parallel { - std::vector<RD53FWInterface::Event> vecEvents; - std::vector<size_t> vecEventStart; + std::vector<RD53FWInterface::Event> vecEvents; + std::vector<size_t> vecEventStart; - if (eventStart.begin() + nEvents * omp_get_thread_num() < eventStart.end()) + if(eventStart.begin() + nEvents * omp_get_thread_num() < eventStart.end()) { - auto firstEvent = eventStart.begin() + nEvents * omp_get_thread_num(); - auto lastEvent = firstEvent + nEvents + 1 < eventStart.end() ? firstEvent + nEvents + 1 : eventStart.end(); - std::move(firstEvent, lastEvent, std::back_inserter(vecEventStart)); - - uint16_t status = RD53FWInterface::DecodeEvents(data, vecEvents, vecEventStart); + auto firstEvent = eventStart.begin() + nEvents * omp_get_thread_num(); + auto lastEvent = firstEvent + nEvents + 1 < eventStart.end() ? firstEvent + nEvents + 1 : eventStart.end(); + std::move(firstEvent, lastEvent, std::back_inserter(vecEventStart)); - #pragma omp atomic - evtStatus |= status; + uint16_t status = RD53FWInterface::DecodeEvents(data, vecEvents, vecEventStart); +#pragma omp atomic + evtStatus |= status; - // ##################### - // # Pack event vector # - // ##################### - #pragma omp critical - std::move(vecEvents.begin(), vecEvents.end(), std::back_inserter(events)); + // ##################### + // # Pack event vector # + // ##################### +#pragma omp critical + std::move(vecEvents.begin(), vecEvents.end(), std::back_inserter(events)); } } - - return evtStatus; + return evtStatus; } */ uint16_t RD53FWInterface::DecodeEventsMultiThreads(const std::vector<uint32_t>& data, std::vector<RD53FWInterface::Event>& events) @@ -845,8 +856,15 @@ uint16_t RD53FWInterface::DecodeEventsMultiThreads(const std::vector<uint32_t>& std::vector<std::vector<size_t>> vecEventStart(RD53Shared::NTHREADS); std::vector<size_t> eventStart; - for(auto i = 0u; i < data.size(); i++) - if(data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) eventStart.push_back(i); + size_t i = 0u; + while(i < data.size()) + if(data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) + { + eventStart.push_back(i); + i += RD53FWEvtEncoder::EVT_HEADER_SIZE; + } + else + i++; if(eventStart.size() == 0) return RD53FWEvtEncoder::NOHEADER; const auto nEvents = ceil(static_cast<double>(eventStart.size()) / RD53Shared::NTHREADS); eventStart.push_back(data.size()); @@ -854,8 +872,7 @@ uint16_t RD53FWInterface::DecodeEventsMultiThreads(const std::vector<uint32_t>& // ###################### // # Unpack data vector # // ###################### - auto i = 0u; - for(; i < RD53Shared::NTHREADS - 1; i++) + for(i = 0u; i < RD53Shared::NTHREADS - 1; i++) { auto firstEvent = eventStart.begin() + nEvents * i; if(firstEvent + nEvents + 1 > eventStart.end() - 1) break; @@ -892,9 +909,9 @@ void RD53FWInterface::DecodeEventsWrapper(const std::vector<uint32_t>& data, std uint16_t RD53FWInterface::DecodeEvents(const std::vector<uint32_t>& data, std::vector<RD53FWInterface::Event>& events, const std::vector<size_t>& eventStartExt) { - uint16_t evtStatus = RD53FWEvtEncoder::GOOD; std::vector<size_t> eventStartLocal; std::vector<size_t>& refEventStart = const_cast<std::vector<size_t>&>(eventStartExt); + uint16_t evtStatus = RD53FWEvtEncoder::GOOD; const size_t maxL1Counter = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1; // ###################### @@ -904,8 +921,15 @@ uint16_t RD53FWInterface::DecodeEvents(const std::vector<uint32_t>& data, std::v if(eventStartExt.size() == 0) { - for(auto i = 0u; i < data.size(); i++) - if(data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) eventStartLocal.push_back(i); + size_t i = 0u; + while(i < data.size()) + if(data[i] >> RD53FWEvtEncoder::NBIT_BLOCKSIZE == RD53FWEvtEncoder::EVT_HEADER) + { + eventStartLocal.push_back(i); + i += RD53FWEvtEncoder::EVT_HEADER_SIZE; + } + else + i++; if(eventStartLocal.size() == 0) return RD53FWEvtEncoder::NOHEADER; eventStartLocal.push_back(data.size()); refEventStart = eventStartLocal; @@ -952,7 +976,7 @@ void RD53FWInterface::Event::fillDataContainer(BoardDataContainer* boardContaine for(const auto& cOpticalGroup: *boardContainer) for(const auto& cHybrid: *cOpticalGroup) for(const auto& cChip: *cHybrid) - if(RD53FWInterface::Event::isHittedChip(cHybrid->getId(), cChip->getId(), chipIndx) == true) + if((evtStatus == RD53FWEvtEncoder::GOOD) && (RD53FWInterface::Event::isHittedChip(cHybrid->getId(), cChip->getId(), chipIndx) == true)) { if(vectorRequired == true) { @@ -1009,7 +1033,7 @@ RD53FWInterface::Event::Event(const uint32_t* data, size_t n) // ###################### // # Consistency checks # // ###################### - if(n < 4) + if(n < RD53FWEvtEncoder::EVT_HEADER_SIZE) { evtStatus = RD53FWEvtEncoder::INCOMPLETE; return; @@ -1138,17 +1162,14 @@ 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) +void RD53FWInterface::SetAndConfigureFastCommands(const BeBoard* pBoard, + const uint32_t nTRIGxEvent, + const size_t injType, + const uint32_t injLatency, + const uint32_t nClkDelays, + const bool enableAutozero) // ############################ // # injType == 0 --> None # // # injType == 1 --> Analog # @@ -1182,14 +1203,14 @@ void RD53FWInterface::SetAndConfigureFastCommands(const BeBoard* pBoard, size_t // ####################################### // # Configuration for digital injection # // ####################################### - RD53::CalCmd calcmd_first(1, 0, 2, 0, 0); + RD53::CalCmd calcmd_first(1, 2, 10, 0, 0); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.first_cal_data = calcmd_first.getCalCmd(chipId); - RD53::CalCmd calcmd_second(0, 0, 2, 0, 0); + RD53::CalCmd calcmd_second(0, 0, 0, 0, 0); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.second_cal_data = calcmd_second.getCalCmd(chipId); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_first_prime = (nClkDelays == 0 ? (uint32_t)INJdelay::Loop : nClkDelays); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_ecr = 0; - RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_inject = INJdelay::AfterInjectCal; + RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_inject = (injLatency == 0 ? (uint32_t)INJdelay::AfterInjectCal : injLatency); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_trigger = INJdelay::BeforePrimeCal; RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_prime = (nClkDelays == 0 ? (uint32_t)INJdelay::Loop : nClkDelays); @@ -1203,14 +1224,14 @@ void RD53FWInterface::SetAndConfigureFastCommands(const BeBoard* pBoard, size_t // ###################################### // # Configuration for analog injection # // ###################################### - RD53::CalCmd calcmd_first(1, 0, 2, 0, 0); + RD53::CalCmd calcmd_first(1, 0, 0, 0, 0); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.first_cal_data = calcmd_first.getCalCmd(chipId); - RD53::CalCmd calcmd_second(0, 0, 2, 0, 0); + RD53::CalCmd calcmd_second(0, 0, 1, 0, 0); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.second_cal_data = calcmd_second.getCalCmd(chipId); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_first_prime = (nClkDelays == 0 ? (uint32_t)INJdelay::Loop : nClkDelays); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_ecr = 0; - RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_inject = INJdelay::AfterInjectCal; + RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_inject = (injLatency == 0 ? (uint32_t)INJdelay::AfterInjectCal : injLatency); RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_trigger = INJdelay::BeforePrimeCal; RD53FWInterface::localCfgFastCmd.fast_cmd_fsm.delay_after_prime = (nClkDelays == 0 ? (uint32_t)INJdelay::Loop : nClkDelays); @@ -1259,6 +1280,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 # @@ -1692,7 +1714,8 @@ float RD53FWInterface::ReadHybridVoltage(int hybridId) usleep(DEEPSLEEP); auto value = calcVoltage(senseVDD, senseGND); - LOG(INFO) << BOLDBLUE << "\t--> Hybrid voltage: " << BOLDYELLOW << std::setprecision(3) << value << BOLDBLUE << " V (corresponds to VOUT_dig_ShuLDO of the chip)" << std::setprecision(-1) << RESET; + LOG(INFO) << BOLDBLUE << "\t--> Hybrid voltage: " << BOLDYELLOW << std::setprecision(3) << value << BOLDBLUE << " V (corresponds to half VOUT_dig_ShuLDO of the chip)" << std::setprecision(-1) + << RESET; return value; } diff --git a/HWInterface/RD53FWInterface.h b/HWInterface/RD53FWInterface.h index c7bf61a32f08f4eea4aa32e7cd2b6dbc3853502e..8f51dee9a41624ee4e0512a1e8a8d6040b14a9df 100644 --- a/HWInterface/RD53FWInterface.h +++ b/HWInterface/RD53FWInterface.h @@ -36,26 +36,21 @@ #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 { // ################ // # Event header # // ################ -const uint16_t EVT_HEADER = 0xFFFF; -const uint8_t NBIT_EVTHEAD = 16; // Number of bits for the Error Code -const uint8_t NBIT_BLOCKSIZE = 16; // Number of bits for the Block Size -const uint8_t NBIT_TRIGID = 16; // Number of bits for the TLU Trigger ID -const uint8_t NBIT_FMTVER = 8; // Number of bits for the Format Version -const uint8_t NBIT_DUMMY = 8; // Number of bits for the Dummy Size -const uint8_t NBIT_TDC = 8; // Number of bits for the TDC -const uint8_t NBIT_L1ACNT = 24; // Number of bits for the L1A Counter (Event number) -const uint8_t NBIT_BXCNT = 32; // Number of bits for the BX Counter +const uint16_t EVT_HEADER = 0xFFFF; +const uint16_t EVT_HEADER_SIZE = 4; // Number of words in event header +const uint8_t NBIT_EVTHEAD = 16; // Number of bits for the Error Code +const uint8_t NBIT_BLOCKSIZE = 16; // Number of bits for the Block Size +const uint8_t NBIT_TRIGID = 16; // Number of bits for the TLU Trigger ID +const uint8_t NBIT_FMTVER = 8; // Number of bits for the Format Version +const uint8_t NBIT_DUMMY = 8; // Number of bits for the Dummy Size +const uint8_t NBIT_TDC = 8; // Number of bits for the TDC +const uint8_t NBIT_L1ACNT = 24; // Number of bits for the L1A Counter (Event number) +const uint8_t NBIT_BXCNT = 32; // Number of bits for the BX Counter // ############### // # Chip header # @@ -108,7 +103,12 @@ class RD53FWInterface : public BeBoardFWInterface void ChipReset() override; void ChipReSync() override; + // ############################################# + // # hybridId < 0 --> broadcast to all hybrids # + // ############################################# void WriteChipCommand(const std::vector<uint16_t>& data, int hybridId); + void ComposeAndPackChipCommands(const std::vector<uint16_t>& data, int hybridId, std::vector<uint32_t>& commandList); + void SendChipCommandsPack(const std::vector<uint32_t>& commandList); std::vector<std::pair<uint16_t, uint16_t>> ReadChipRegisters(Ph2_HwDescription::ReadoutChip* pChip); struct ChipFrame @@ -189,7 +189,7 @@ class RD53FWInterface : public BeBoardFWInterface uint32_t delay_after_ecr = 0; uint32_t delay_after_autozero = 0; // @TMP@ uint32_t delay_after_inject = 0; - uint16_t delay_after_trigger = 0; + uint32_t delay_after_trigger = 0; uint32_t delay_after_prime = 0; }; @@ -211,7 +211,12 @@ class RD53FWInterface : public BeBoardFWInterface }; void ConfigureFromXML(const Ph2_HwDescription::BeBoard* pBoard); - void SetAndConfigureFastCommands(const Ph2_HwDescription::BeBoard* pBoard, size_t nTRIGxEvent, size_t injType, uint32_t nClkDelays = 0, bool enableAutozero = false); + void SetAndConfigureFastCommands(const Ph2_HwDescription::BeBoard* pBoard, + const uint32_t nTRIGxEvent, + const size_t injType, + const uint32_t injLatency = 0, + const uint32_t nClkDelays = 0, + const bool enableAutozero = false); struct DIO5Config { @@ -302,6 +307,7 @@ class RD53FWInterface : public BeBoardFWInterface D19cFpgaConfig* fpgaConfig; size_t ddr3Offset; bool singleChip; + unsigned int auroraSpeed; uint16_t enabledHybrids; }; diff --git a/HWInterface/RD53Interface.cc b/HWInterface/RD53Interface.cc index f324cc39954db665e9a74f8640a17004e5084d44..d9ccdd9894efece9119572a9635fa39dd8bd2055 100644 --- a/HWInterface/RD53Interface.cc +++ b/HWInterface/RD53Interface.cc @@ -181,53 +181,53 @@ void RD53Interface::InitRD53Aurora(ReadoutChip* pChip, int nActiveLanes) usleep(DEEPSLEEP); } -bool RD53Interface::WriteChipReg(Chip* pChip, const std::string& pRegNode, const uint16_t data, bool pVerifLoop) +bool RD53Interface::WriteChipReg(Chip* pChip, const std::string& regName, const uint16_t data, bool pVerifLoop) { this->setBoard(pChip->getBeBoardId()); - RD53Interface::sendCommand(static_cast<RD53*>(pChip), RD53Cmd::WrReg(pChip->getId(), pChip->getRegItem(pRegNode).fAddress, data)); - if((pRegNode == "VCAL_HIGH") || (pRegNode == "VCAL_MED")) usleep(VCALSLEEP); // @TMP@ + RD53Interface::sendCommand(static_cast<RD53*>(pChip), RD53Cmd::WrReg(pChip->getId(), pChip->getRegItem(regName).fAddress, data)); + if((regName == "VCAL_HIGH") || (regName == "VCAL_MED")) usleep(VCALSLEEP); // @TMP@ if(pVerifLoop == true) { - if(pRegNode == "PIX_PORTAL") + if(regName == "PIX_PORTAL") { auto pixMode = RD53Interface::ReadChipReg(pChip, "PIX_MODE"); if(pixMode == 0) { - auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), pRegNode); + auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), regName); auto row = RD53Interface::ReadChipReg(pChip, "REGION_ROW"); if(regReadback.size() == 0 /* @TMP@ */ || regReadback[0].first != row || regReadback[0].second != data) { - LOG(ERROR) << BOLDRED << "Error while writing into RD53 reg. " << BOLDYELLOW << pRegNode << RESET; + LOG(ERROR) << BOLDRED << "Error while writing into RD53 reg. " << BOLDYELLOW << regName << RESET; return false; } } } - else if(data != RD53Interface::ReadChipReg(pChip, pRegNode)) + else if(data != RD53Interface::ReadChipReg(pChip, regName)) return false; } - pChip->setReg(pRegNode, data); + pChip->setReg(regName, data); return true; } -void RD53Interface::WriteBoardBroadcastChipReg(const BeBoard* pBoard, const std::string& pRegNode, const uint16_t data) +void RD53Interface::WriteBoardBroadcastChipReg(const BeBoard* pBoard, const std::string& regName, const uint16_t data) { this->setBoard(pBoard->getId()); - const uint16_t address = static_cast<RD53*>(pBoard->at(0)->at(0)->at(0))->getRegItem(pRegNode).fAddress; + const uint16_t address = static_cast<RD53*>(pBoard->at(0)->at(0)->at(0))->getRegItem(regName).fAddress; static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(RD53Cmd::WrReg(RD53Constants::BROADCAST_CHIPID, address, data).getFrames(), -1); } -uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& pRegNode) +uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& regName) { this->setBoard(pChip->getBeBoardId()); const int nAttempts = 2; for(auto attempt = 0; attempt < nAttempts; attempt++) { - auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), pRegNode); + auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), regName); if(regReadback.size() == 0) { LOG(WARNING) << BLUE << "Empty register readback, attempt n. " << YELLOW << attempt << RESET; @@ -242,11 +242,11 @@ uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& pRegNode) return 0; } -std::vector<std::pair<uint16_t, uint16_t>> RD53Interface::ReadRD53Reg(ReadoutChip* pChip, const std::string& pRegNode) +std::vector<std::pair<uint16_t, uint16_t>> RD53Interface::ReadRD53Reg(ReadoutChip* pChip, const std::string& regName) { this->setBoard(pChip->getBeBoardId()); - RD53Interface::sendCommand(pChip, RD53Cmd::RdReg(pChip->getId(), pChip->getRegItem(pRegNode).fAddress)); + RD53Interface::sendCommand(pChip, RD53Cmd::RdReg(pChip->getId(), pChip->getRegItem(regName).fAddress)); auto regReadback = static_cast<RD53FWInterface*>(fBoardFW)->ReadChipRegisters(pChip); for(auto i = 0u; i < regReadback.size(); i++) @@ -291,7 +291,7 @@ void RD53Interface::WriteRD53Mask(RD53* pRD53, bool doSparse, bool doDefault, bo const uint16_t PIX_PORTAL_ADDR = pRD53->getRegItem("PIX_PORTAL").fAddress; const uint8_t highGain = pRD53->getRegItem("HighGain_LIN").fValue; const uint8_t chipID = pRD53->getId(); - std::vector<perColumnPixelData>& mask = doDefault ? *pRD53->getPixelsMaskDefault() : *pRD53->getPixelsMask(); + std::vector<perColumnPixelData>& mask = doDefault == true ? *pRD53->getPixelsMaskDefault() : *pRD53->getPixelsMask(); // ########################## // # Disable default config # @@ -437,6 +437,21 @@ void RD53Interface::ReadChipAllLocalReg(ReadoutChip* pChip, const std::string& r for(auto col = 0u; col < RD53::nCols; col++) pValue.getChannel<uint16_t>(row, col) = pRD53->getTDAC(row, col); } +void RD53Interface::PackChipCommands(ReadoutChip* pChip, const std::string& regName, uint16_t data, std::vector<uint16_t>& chipCommandList, bool updateReg) +{ + RD53Cmd::WrReg(pChip->getId(), pChip->getRegItem(regName).fAddress, data).appendTo(chipCommandList); + if(updateReg == true) pChip->setReg(regName, data); +} + +void RD53Interface::SendChipCommandsPack(const std::vector<uint16_t>& chipCommandList, int hybridId) { static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(chipCommandList, hybridId); } + +void RD53Interface::PackHybridCommands(const std::vector<uint16_t>& chipCommandList, int hybridId, std::vector<uint32_t>& hybridCommandList) +{ + static_cast<RD53FWInterface*>(fBoardFW)->ComposeAndPackChipCommands(chipCommandList, hybridId, hybridCommandList); +} + +void RD53Interface::SendHybridCommandsPack(const std::vector<uint32_t>& hybridCommandList) { static_cast<RD53FWInterface*>(fBoardFW)->SendChipCommandsPack(hybridCommandList); } + // ########################### // # Dedicated to minitoring # // ########################### diff --git a/HWInterface/RD53Interface.h b/HWInterface/RD53Interface.h index f0380ca07b0fc6fbc1a1fefab709ae82354b8e56..8f284f7d7a24d417087314fefcf7bb93a0008023 100644 --- a/HWInterface/RD53Interface.h +++ b/HWInterface/RD53Interface.h @@ -30,17 +30,23 @@ class RD53Interface : public ReadoutChipInterface int CheckChipID(Ph2_HwDescription::Chip* pChip, int chipIDfromDB); bool ConfigureChip(Ph2_HwDescription::Chip* pChip, bool pVerifLoop = true, uint32_t pBlockSize = 310) override; - bool WriteChipReg(Ph2_HwDescription::Chip* pChip, const std::string& pRegNode, uint16_t data, bool pVerifLoop = true) override; - void WriteBoardBroadcastChipReg(const Ph2_HwDescription::BeBoard* pBoard, const std::string& pRegNode, uint16_t data) override; + bool WriteChipReg(Ph2_HwDescription::Chip* pChip, const std::string& regName, uint16_t data, bool pVerifLoop = true) override; + void WriteBoardBroadcastChipReg(const Ph2_HwDescription::BeBoard* pBoard, const std::string& regName, uint16_t data) override; bool WriteChipAllLocalReg(Ph2_HwDescription::ReadoutChip* pChip, const std::string& regName, ChipContainer& pValue, bool pVerifLoop = true) override; void ReadChipAllLocalReg(Ph2_HwDescription::ReadoutChip* pChip, const std::string& regName, ChipContainer& pValue) override; - uint16_t ReadChipReg(Ph2_HwDescription::Chip* pChip, const std::string& pRegNode) override; + uint16_t ReadChipReg(Ph2_HwDescription::Chip* pChip, const std::string& regName) override; bool ConfigureChipOriginalMask(Ph2_HwDescription::ReadoutChip* pChip, bool pVerifLoop = true, uint32_t pBlockSize = 310) override; bool MaskAllChannels(Ph2_HwDescription::ReadoutChip* pChip, bool mask, bool pVerifLoop = true) override; bool maskChannelsAndSetInjectionSchema(Ph2_HwDescription::ReadoutChip* pChip, const ChannelGroupBase* group, bool mask, bool inject, bool pVerifLoop = false) override; + void PackChipCommands(Ph2_HwDescription::ReadoutChip* pChip, const std::string& regName, uint16_t data, std::vector<uint16_t>& chipCommandList, bool updateReg = false); + void SendChipCommandsPack(const std::vector<uint16_t>& chipCommandList, int hybridId); + + void PackHybridCommands(const std::vector<uint16_t>& chipCommandList, int hybridId, std::vector<uint32_t>& hybridCommandList); + void SendHybridCommandsPack(const std::vector<uint32_t>& hybridCommandList); + private: - std::vector<std::pair<uint16_t, uint16_t>> ReadRD53Reg(Ph2_HwDescription::ReadoutChip* pChip, const std::string& pRegNode); + std::vector<std::pair<uint16_t, uint16_t>> ReadRD53Reg(Ph2_HwDescription::ReadoutChip* pChip, const std::string& regName); void WriteRD53Mask(Ph2_HwDescription::RD53* pRD53, bool doSparse, bool doDefault, bool pVerifLoop = false); void InitRD53Aurora(Ph2_HwDescription::ReadoutChip* pChip, int nActiveLanes = 1); diff --git a/NetworkUtils/TCPClientBase.cc b/NetworkUtils/TCPClientBase.cc index c348cd38104fef802694342ff96868d812cc22d4..eda25cc2217dccf52334202bfcf8bb16659dedaf 100644 --- a/NetworkUtils/TCPClientBase.cc +++ b/NetworkUtils/TCPClientBase.cc @@ -5,7 +5,8 @@ #include <iostream> #include <netdb.h> #include <netinet/in.h> // inet_aton, struct sockaddr_in -#include <strings.h> // bzero +#include <sstream> +#include <strings.h> // bzero #include <thread> #include <sstream> diff --git a/README.md b/README.md index 7c1fdfb617ecaf7d4bc8ee8776134ac620db2d8c..c8c4f17414ccca464ec0e8f0d91946ab03a77ea3 100755 --- a/README.md +++ b/README.md @@ -19,18 +19,18 @@ 8. Once the previous command is done, you can list the SD card: `./imgtool /dev/sd_card_name list` - there should be a GoldenImage.bin, with 20MB block size 9. Insert the SD card into the FC7 -Use the guide (https://gitlab.cern.ch/cms_tk_ph2/d19c-firmware/blob/master/doc/IPAddress_Tutorial.md) to find the MAC address of the FC7 (Wireshark option) and to set the proper IP. - +Use the guide (https://gitlab.cern.ch/cms_tk_ph2/d19c-firmware/blob/master/doc/IPAddress_Tutorial.md) to find the MAC address of the FC7 (Wireshark option) and to set the proper IP <br/> More informations can be found at https://indico.cern.ch/event/842824/attachments/1920624/3177632/PreparingFC7.pdf +<hr> ## Middleware for the Inner-Tracker (IT) system ```diff -+ Last change made to this section: 06/11/2020 ++ Last change made to this section: 14/12/2020 ``` **Suggested software and firmware versions:** -- Software git branch / tag : `master` / `IT-v3.9.8` +- Software git branch / tag : `master` / `IT-v3.9.9` - Firmware tag: `3.4` - Mattermost forum: `cms-it-daq` (https://mattermost.web.cern.ch/cms-it-daq/) @@ -68,6 +68,8 @@ A detailed manual about the firmware can be found here: https://gitlab.cern.ch/c 10. Run the command: `CMSITminiDAQ -f CMSIT.xml -r` to reset the FC7 (just once) 11. Run the command: `CMSITminiDAQ -f CMSIT.xml -c name_of_the_calibration` (or `CMSITminiDAQ --help` for help) +**N.B.:** a skeleton/template file to build your own IT mini DAQ can be found in `src/templateCMSITminiDAQ.cc` + **Basic list of commands for the `fpgaconfig` program (run from the `choose_a_name` directory):** - Run the command: `fpgaconfig -c CMSIT.xml -l` to check which firmware is on the microSD card - Run the command: `fpgaconfig -c CMSIT.xml -f firmware_file_name_on_the_PC -i firmware_file_name_on_the_microSD` to upload a new firmware to the microSD card diff --git a/System/FileParser.cc b/System/FileParser.cc index 725bce78aef097a9fb816aa8da706bc27954218b..50cdea93caa1eabbf5b21aff7dfa37f5c7fb9991 100644 --- a/System/FileParser.cc +++ b/System/FileParser.cc @@ -182,7 +182,7 @@ void FileParser::parseBeBoard(pugi::xml_node pBeBordNode, BeBoardFWMap& pBeBoard if(std::string(cBeBoardRegNode.name()) == "Register") { std::string cNameString; - uint32_t cValue; + double cValue; this->parseRegister(cBeBoardRegNode, cNameString, cValue, cBeBoard, os); } } @@ -303,7 +303,7 @@ void FileParser::parseOpticalGroupContainer(pugi::xml_node pOpticalGroupNode, Be } } -void FileParser::parseRegister(pugi::xml_node pRegisterNode, std::string& pAttributeString, uint32_t& pValue, BeBoard* pBoard, std::ostream& os) +void FileParser::parseRegister(pugi::xml_node pRegisterNode, std::string& pAttributeString, double& pValue, BeBoard* pBoard, std::ostream& os) { if(std::string(pRegisterNode.name()) == "Register") { @@ -324,7 +324,7 @@ void FileParser::parseRegister(pugi::xml_node pRegisterNode, std::string& pAttri if(!pAttributeString.empty()) pAttributeString += "."; pAttributeString += pRegisterNode.attribute("name").value(); - pValue = convertAnyInt(pRegisterNode.first_child().value()); + pValue = convertAnyDouble(pRegisterNode.first_child().value()); os << GREEN << "|\t|\t|" << "----" << pAttributeString << ": " << BOLDYELLOW << pValue << RESET << std::endl; pBoard->setReg(pAttributeString, pValue); @@ -473,7 +473,7 @@ void FileParser::parseSSAContainer(pugi::xml_node pSSAnode, Hybrid* pHybrid, std << ", File: " << expandEnvironmentVariables(pSSAnode.attribute("configfile").value()) << RESET << std::endl; // Get ID of SSA then add to the Hybrid! - uint32_t cChipId = pSSAnode.attribute("Id").as_int(); + uint32_t cChipId = pSSAnode.attribute("Id").as_int(); uint32_t cPartnerId = pSSAnode.attribute("partid").as_int(); std::string cFileName; if(!cFilePrefix.empty()) @@ -496,7 +496,7 @@ void FileParser::parseSSASettings(pugi::xml_node pHybridNode, ReadoutChip* pSSA) void FileParser::parseMPA(pugi::xml_node pHybridNode, Hybrid* pHybrid, std::string cFilePrefix) { // Get ID of MPA then add to the Hybrid! - uint32_t cChipId = pHybridNode.attribute("Id").as_int(); + uint32_t cChipId = pHybridNode.attribute("Id").as_int(); uint32_t cPartnerId = pHybridNode.attribute("partid").as_int(); std::string cFileName; if(!cFilePrefix.empty()) diff --git a/System/FileParser.h b/System/FileParser.h index 71669a8dd35b5d52095d641bd6857a64d16e6c37..4b9037b506e633526ec855ad5c0bbd41f755c64b 100644 --- a/System/FileParser.h +++ b/System/FileParser.h @@ -76,7 +76,7 @@ class FileParser void parseSettingsxml(const std::string& pFilename, SettingsMap& pSettingsMap, std::ostream& os, bool pIsFile); void parseBeBoard(pugi::xml_node pBeBordNode, BeBoardFWMap& pBeBoardFWMap, DetectorContainer* pDetectorContainer, std::ostream& os); - void parseRegister(pugi::xml_node pRegisterNode, std::string& pAttributeString, uint32_t& pValue, Ph2_HwDescription::BeBoard* pBoard, std::ostream& os); + void parseRegister(pugi::xml_node pRegisterNode, std::string& pAttributeString, double& pValue, Ph2_HwDescription::BeBoard* pBoard, std::ostream& os); void parseSLink(pugi::xml_node pSLinkNode, Ph2_HwDescription::BeBoard* pBoard, std::ostream& os); void parseOpticalGroupContainer(pugi::xml_node pOpticalGroupNode, Ph2_HwDescription::BeBoard* pBoard, std::ostream& os); void parseHybridContainer(pugi::xml_node pHybridNode, Ph2_HwDescription::OpticalGroup* pOpticalGroup, std::ostream& os, Ph2_HwDescription::BeBoard* pBoard); diff --git a/System/SystemController.cc b/System/SystemController.cc index 94ff54611961583d74c2761db5937f3e4e6364a0..9260bb6d3fb5cd71ed81fde37abb94dd9b66ca1b 100644 --- a/System/SystemController.cc +++ b/System/SystemController.cc @@ -187,10 +187,10 @@ void SystemController::ConfigureHw(bool bIgnoreI2c) for(const auto cBoard: *fDetectorContainer) { - uint8_t cAsync = (cBoard->getEventType() == EventType::SSAAS) ? 1 : 0; - if(cBoard->getBoardType() != BoardType::RD53) { + uint8_t cAsync = (cBoard->getEventType() == EventType::SSAAS) ? 1 : 0; + // setting up back-end board fBeBoardInterface->ConfigureBoard(cBoard); LOG(INFO) << GREEN << "Successfully configured Board " << int(cBoard->getId()) << RESET; @@ -284,9 +284,12 @@ void SystemController::ConfigureHw(bool bIgnoreI2c) // ################### size_t nTRIGxEvent = SystemController::findValueInSettings("nTRIGxEvent"); size_t injType = SystemController::findValueInSettings("INJtype"); + size_t injLatency = SystemController::findValueInSettings("InjLatency"); size_t nClkDelays = SystemController::findValueInSettings("nClkDelays"); size_t colStart = SystemController::findValueInSettings("COLstart"); - static_cast<RD53FWInterface*>(this->fBeBoardFWMap[cBoard->getId()])->SetAndConfigureFastCommands(cBoard, nTRIGxEvent, injType, nClkDelays, colStart < RD53::LIN.colStart); + bool resetMask = SystemController::findValueInSettings("ResetMask"); + bool resetTDAC = SystemController::findValueInSettings("ResetTDAC"); + static_cast<RD53FWInterface*>(this->fBeBoardFWMap[cBoard->getId()])->SetAndConfigureFastCommands(cBoard, nTRIGxEvent, injType, injLatency, nClkDelays, colStart < RD53::LIN.colStart); LOG(INFO) << GREEN << "Configured FSM fast command block" << RESET; // ######################## @@ -319,12 +322,15 @@ void SystemController::ConfigureHw(bool bIgnoreI2c) for(auto cHybrid: *cOpticalGroup) { LOG(INFO) << GREEN << "Initializing communication to Hybrid: " << RESET << BOLDYELLOW << +cHybrid->getId() << RESET; - for(const auto cRD53: *cHybrid) + for(const auto cChip: *cHybrid) { - LOG(INFO) << GREEN << "Configuring RD53: " << RESET << BOLDYELLOW << +cRD53->getId() << RESET; - static_cast<RD53Interface*>(fReadoutChipInterface)->ConfigureChip(static_cast<RD53*>(cRD53)); - LOG(INFO) << GREEN << "Number of masked pixels: " << RESET << BOLDYELLOW << static_cast<RD53*>(cRD53)->getNbMaskedPixels() << RESET; - // @TMP@ static_cast<RD53Interface*>(fReadoutChipInterface)->CheckChipID(static_cast<RD53*>(cRD53), 0); + LOG(INFO) << GREEN << "Configuring RD53: " << RESET << BOLDYELLOW << +cChip->getId() << RESET; + if(resetMask == true) static_cast<RD53*>(cChip)->enableAllPixels(); + if(resetTDAC == true) static_cast<RD53*>(cChip)->resetTDAC(); + static_cast<RD53*>(cChip)->copyMaskToDefault(); + static_cast<RD53Interface*>(fReadoutChipInterface)->ConfigureChip(static_cast<RD53*>(cChip)); + LOG(INFO) << GREEN << "Number of masked pixels: " << RESET << BOLDYELLOW << static_cast<RD53*>(cChip)->getNbMaskedPixels() << RESET; + // @TMP@ static_cast<RD53Interface*>(fReadoutChipInterface)->CheckChipID(static_cast<RD53*>(cChip), 0); } } } @@ -512,18 +518,23 @@ void SystemController::SetFuture(const BeBoard* pBoard, const std::vector<uint32 void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint32_t>& pData, uint32_t pNevents, BoardType pType) { + // #################### + // # Decoding IT data # + // #################### if(pType == BoardType::RD53) { fEventList.clear(); if(RD53FWInterface::decodedEvents.size() == 0) RD53FWInterface::DecodeEventsMultiThreads(pData, RD53FWInterface::decodedEvents); RD53FWInterface::Event::addBoardInfo2Events(pBoard, RD53FWInterface::decodedEvents); - for(auto i = 0u; i < RD53FWInterface::decodedEvents.size(); i++) fEventList.push_back(&RD53FWInterface::decodedEvents[i]); + for(auto& evt: RD53FWInterface::decodedEvents) fEventList.push_back(&evt); } + // #################### + // # Decoding OT data # + // #################### else if(pType == BoardType::D19C) { for(auto& pevt: fEventList) delete pevt; fEventList.clear(); - fCurrentEvent = 0; if(pNevents == 0) { LOG(INFO) << BOLDRED << "Asking to decode 0 events. . something might not be right here!!!" << RESET; } else @@ -532,27 +543,19 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3 uint32_t fNFe = pBoard->getNFe(); uint32_t cBlockSize = 0x0000FFFF & pData.at(0); LOG(DEBUG) << BOLDBLUE << "Reading events from " << +fNFe << " FEs connected to uDTC...[ " << +cBlockSize * 4 << " 32 bit words to decode]" << RESET; - fEventSize = static_cast<uint32_t>((pData.size()) / pNevents); - //uint32_t nmpa = 0; + fEventSize = static_cast<uint32_t>((pData.size()) / pNevents); + // uint32_t nmpa = 0; uint32_t maxind = 0; - - //if(fEventType == EventType::SSAAS) - // { - // uint16_t nSSA = (fEventSize - D19C_EVENT_HEADER1_SIZE_32_SSA) / D19C_EVENT_SIZE_32_SSA / fNFe; - // nSSA = pData.size() / 120; - // } - + // if(fEventType == EventType::SSAAS) + // { + // uint16_t nSSA = (fEventSize - D19C_EVENT_HEADER1_SIZE_32_SSA) / D19C_EVENT_SIZE_32_SSA / fNFe; + // nSSA = pData.size() / 120; + // } for(auto opticalGroup: *pBoard) { - for(auto hybrid: *opticalGroup) - { - - maxind = std::max(maxind, uint32_t(hybrid->size())); - - - } + for(auto hybrid: *opticalGroup) { maxind = std::max(maxind, uint32_t(hybrid->size())); } } if(fEventType == EventType::SSAAS) { fEventList.push_back(new D19cSSAEventAS(pBoard, pData)); } @@ -568,7 +571,7 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3 { uint32_t cEventSize = (0x0000FFFF & (*cEventIterator)) * 4; // event size is given in 128 bit words auto cEnd = ((cEventIterator + cEventSize) > pData.end()) ? pData.end() : (cEventIterator + cEventSize); - + // retrieve chunck of data vector belonging to this event if(cEnd - cEventIterator == cEventSize) { diff --git a/System/SystemController.h b/System/SystemController.h index 9f32a085454ca738406fdc407b7e2bcc76f09668..75212a89d6741512c779cada821bbb876dcf7699 100644 --- a/System/SystemController.h +++ b/System/SystemController.h @@ -229,24 +229,7 @@ class SystemController const Ph2_HwDescription::BeBoard* getBoard(int index) const { return (index < static_cast<int>(fDetectorContainer->size()) ? fDetectorContainer->at(index) : nullptr); } - /*! - * \brief Get next event from data buffer - * \param pBoard - * \return Next event - */ - const Ph2_HwInterface::Event* GetNextEvent(const Ph2_HwDescription::BeBoard* pBoard) - { - if(fFuture.valid() == true) fFuture.get(); - return ((fCurrentEvent >= fEventList.size()) ? nullptr : fEventList.at(fCurrentEvent++)); - } - - const Ph2_HwInterface::Event* GetEvent(const Ph2_HwDescription::BeBoard* pBoard, unsigned int i) - { - if(fFuture.valid() == true) fFuture.get(); - return ((i >= fEventList.size()) ? nullptr : fEventList.at(i)); - } - - const std::vector<Ph2_HwInterface::Event*>& GetEvents(const Ph2_HwDescription::BeBoard* pBoard) + const std::vector<Ph2_HwInterface::Event*>& GetEvents() { if(fFuture.valid() == true) fFuture.get(); return fEventList; @@ -261,9 +244,7 @@ class SystemController std::vector<Ph2_HwInterface::Event*> fEventList; std::future<void> fFuture; - uint32_t fCurrentEvent; uint32_t fEventSize; - uint32_t fNevents; uint32_t fNCbc; FileParser fParser; }; diff --git a/Utils/CommonVisitors.h b/Utils/CommonVisitors.h index ec6a89379fb0985ddeb70b877462750fabf74e8b..e28db929d0aadeed6598ab9a72161207809f3097 100644 --- a/Utils/CommonVisitors.h +++ b/Utils/CommonVisitors.h @@ -368,7 +368,7 @@ struct LatencyVisitor : public HwDescriptionVisitor if(fOption == 'w') { std::vector<std::pair<std::string, uint16_t>> cRegVec; - cRegVec.emplace_back("L1-Latency_LSB", (0x00FF & fLatency) >> 0 ); + cRegVec.emplace_back("L1-Latency_LSB", (0x00FF & fLatency) >> 0); cRegVec.emplace_back("L1-Latency_MSB", (0x0100 & fLatency) >> 8); fInterface->WriteChipMultReg(&pCbc, cRegVec); } @@ -383,7 +383,7 @@ struct LatencyVisitor : public HwDescriptionVisitor if(fOption == 'w') { std::vector<std::pair<std::string, uint16_t>> cRegVec; - cRegVec.emplace_back("L1Offset_1_ALL", (0x00FF & fLatency) >> 0 ); + cRegVec.emplace_back("L1Offset_1_ALL", (0x00FF & fLatency) >> 0); cRegVec.emplace_back("L1Offset_2_ALL", (0x0100 & fLatency) >> 8); fInterface->WriteChipMultReg(&pCbc, cRegVec); } diff --git a/Utils/D19cMPAEvent.cc b/Utils/D19cMPAEvent.cc index 2e04f3fad7d64161b406f97fa054f58782c5927c..5ea0980bf312805764f26c9482514e0e6854d29f 100644 --- a/Utils/D19cMPAEvent.cc +++ b/Utils/D19cMPAEvent.cc @@ -52,8 +52,7 @@ void D19cMPAEvent::fillDataContainer(BoardDataContainer* boardContainer, const C void D19cMPAEvent::SetEvent(const BeBoard* pBoard, uint32_t pNMPA, const std::vector<uint32_t>& list) { - - //for (auto L : list) LOG(INFO) << BOLDBLUE << std::bitset<32>(L) << RESET; + // for (auto L : list) LOG(INFO) << BOLDBLUE << std::bitset<32>(L) << RESET; // Not sure about dsize... // fEventSize = 4*((0x0000FFFF & list.at (0)) - (0x000000FF & list.at (1))); fEventSize = 4 * (0x0000FFFF & list.at(0)); @@ -73,8 +72,8 @@ void D19cMPAEvent::SetEvent(const BeBoard* pBoard, uint32_t pNMPA, const std::ve for(auto cChip: *cHybrid) { uint8_t pMPAId = cChip->getId(); - - if (cChip->getFrontEndType() != FrontEndType::MPA) continue; + + if(cChip->getFrontEndType() != FrontEndType::MPA) continue; uint8_t cPLeadingMPA = ((0xF0000000 & list.at(data_offset)) >> 28); uint8_t cErrorMPA = ((0x0F000000 & list.at(data_offset)) >> 24); @@ -91,17 +90,16 @@ void D19cMPAEvent::SetEvent(const BeBoard* pBoard, uint32_t pNMPA, const std::ve uint8_t cSyncBit1 = ((0x00008000 & list.at(data_offset + cL1size_32_MPA + 1)) >> 15); uint8_t cSyncBit2 = ((0x00004000 & list.at(data_offset + cL1size_32_MPA + 1)) >> 14); - if(cPLeadingMPA != 0xA) LOG(ERROR) << "Incorrect L1A header for MPA " << unsigned(pMPAId)<<","<<unsigned(cHybrid->getId())<<","<<unsigned(cOpticalGroup->getId()); - if(cSLeadingMPA != 0x5) LOG(ERROR) << "Incorrect stub header for MPA " << unsigned(pMPAId)<<","<<unsigned(cHybrid->getId())<<","<<unsigned(cOpticalGroup->getId()); + if(cPLeadingMPA != 0xA) LOG(ERROR) << "Incorrect L1A header for MPA " << unsigned(pMPAId) << "," << unsigned(cHybrid->getId()) << "," << unsigned(cOpticalGroup->getId()); + if(cSLeadingMPA != 0x5) LOG(ERROR) << "Incorrect stub header for MPA " << unsigned(pMPAId) << "," << unsigned(cHybrid->getId()) << "," << unsigned(cOpticalGroup->getId()); if(cErrorMPA != 0) LOG(INFO) << BOLDRED << "Error code " << unsigned(cErrorMPA) << " for MPA " << unsigned(pMPAId); if(cSyncBit1 != 1) LOG(INFO) << BOLDRED << "Warning, sync bit 1 not 1, data frame probably misaligned!" << RESET; if(cSyncBit2 != 0) LOG(INFO) << BOLDRED << "Warning, sync bit 2 not 0, data frame probably misaligned!" << RESET; - - uint16_t cKey = encodeVectorIndex(cFeId, pMPAId, fNMPA); + uint16_t cKey = encodeVectorIndex(cFeId, pMPAId, fNMPA); uint32_t begin = data_offset; uint16_t cFevSize = cL1size_32_MPA + cSsize_32_MPA; - uint32_t end = begin + cFevSize; + uint32_t end = begin + cFevSize; // std::vector<uint32_t> cMPAData (std::next (std::begin (list), begin), std::next (std::begin (list), end) // ); @@ -111,9 +109,7 @@ void D19cMPAEvent::SetEvent(const BeBoard* pBoard, uint32_t pNMPA, const std::ve } } address_offset = data_offset; // probably needs to be fixed - } - } bool D19cMPAEvent::Error(uint8_t pFeId, uint8_t pMPAId, uint32_t i) const @@ -134,7 +130,7 @@ uint32_t D19cMPAEvent::Error(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint32_t cError = ((lvec.at(0) & 0x00000003) >> 0); @@ -151,7 +147,7 @@ uint16_t D19cMPAEvent::GetMPAL1Counter(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint16_t L1cnt = ((lvec.at(2) & 0x01FF0000) >> 16); @@ -168,7 +164,7 @@ uint8_t D19cMPAEvent::GetMPAChipType(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint8_t MPACT = ((lvec.at(1) & 0x0000F000) >> 12); @@ -185,7 +181,7 @@ uint8_t D19cMPAEvent::GetMPAChipID(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint8_t MPACID = ((lvec.at(0) & 0x0000F000) >> 12); @@ -202,7 +198,7 @@ uint16_t D19cMPAEvent::GetMPAHybridID(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint16_t MPAHID = ((lvec.at(0) & 0x00FF0000) >> 16); @@ -219,7 +215,7 @@ uint8_t D19cMPAEvent::GetMPAError(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint8_t MPAERR = ((lvec.at(0) & 0xC0000000) >> 30); @@ -234,10 +230,10 @@ uint8_t D19cMPAEvent::GetMPAError(uint8_t pFeId, uint8_t pMPAId) const uint8_t D19cMPAEvent::GetNStripClusters(uint8_t pFeId, uint8_t pMPAId) const { - //LOG (INFO) << fEventDataVector.size()<<" "<<encodeVectorIndex(pFeId, pMPAId, fNMPA) << RESET; + // LOG (INFO) << fEventDataVector.size()<<" "<<encodeVectorIndex(pFeId, pMPAId, fNMPA) << RESET; std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint8_t Nstrip = ((lvec.at(2) & 0x00001F00) >> 8); @@ -253,7 +249,7 @@ uint8_t D19cMPAEvent::GetNStripClusters(uint8_t pFeId, uint8_t pMPAId) const uint8_t D19cMPAEvent::GetNPixelClusters(uint8_t pFeId, uint8_t pMPAId) const { std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + if(lvec.size() > 1) { // buf overflow and lat error uint8_t Npix = (lvec.at(2) & 0x0000001F); @@ -269,20 +265,17 @@ uint32_t D19cMPAEvent::DivideBy2RoundUp(uint32_t value) const { return (value + uint32_t D19cMPAEvent::GetCluster(std::vector<uint32_t> lvec, uint8_t nclus, uint8_t cClusterSize, uint32_t deltaword) const { - - - uint32_t mask = ((1 << cClusterSize) - 1) << (32 - cClusterSize); uint32_t startbit = nclus * cClusterSize; - uint32_t endbit = (deltaword+startbit) + cClusterSize; - uint8_t nstartword = int((deltaword+startbit) / 32); + uint32_t endbit = (deltaword + startbit) + cClusterSize; + uint8_t nstartword = int((deltaword + startbit) / 32); uint8_t nendword = int((endbit) / 32); - uint32_t startword = lvec.at(nstartword ); - //LOG(INFO) << BOLDRED << "startword "<<unsigned(nstartword) <<" nclus "<<unsigned(nclus) <<" cClusterSize "<<unsigned(cClusterSize)<< RESET; - //LOG(INFO) << BOLDRED << "startbit "<<(startbit + deltaword) % 32 << RESET; - + uint32_t startword = lvec.at(nstartword); + // LOG(INFO) << BOLDRED << "startword "<<unsigned(nstartword) <<" nclus "<<unsigned(nclus) <<" cClusterSize "<<unsigned(cClusterSize)<< RESET; + // LOG(INFO) << BOLDRED << "startbit "<<(startbit + deltaword) % 32 << RESET; + uint8_t displaceL = (startbit + deltaword) % 32; uint32_t curLmask = mask >> displaceL; uint32_t curLword = ((startword & curLmask) >> std::max(0, 32 - (displaceL + cClusterSize + 1))); @@ -297,8 +290,8 @@ uint32_t D19cMPAEvent::GetCluster(std::vector<uint32_t> lvec, uint8_t nclus, uin uint32_t curRmask = mask << (cClusterSize - displaceR); curRword = ((endword & curRmask) >> (31 - displaceR)); } - //LOG(INFO) << BOLDRED << "curLword "<<std::bitset<12>(curLword)<< RESET; - //LOG(INFO) << BOLDRED << "curRword "<<std::bitset<12>(curRword)<< RESET; + // LOG(INFO) << BOLDRED << "curLword "<<std::bitset<12>(curLword)<< RESET; + // LOG(INFO) << BOLDRED << "curRword "<<std::bitset<12>(curRword)<< RESET; uint32_t word = ((curLword << abs(std::min(0, 31 - (displaceL + cClusterSize)))) + curRword) >> 1; return word; } @@ -315,7 +308,7 @@ std::vector<SCluster> D19cMPAEvent::GetStripClusters(uint8_t pFeId, uint8_t pMPA std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); uint8_t cSClusterSize = D19C_SCluster_SIZE_32_MPA; - uint8_t deltaword = 3*32; + uint8_t deltaword = 3 * 32; uint8_t nstrips = 0; while(nstrips < cNstrip) { @@ -325,9 +318,9 @@ std::vector<SCluster> D19cMPAEvent::GetStripClusters(uint8_t pFeId, uint8_t pMPA aSCluster.fMip = (0x0000000e & word) >> 1; aSCluster.fWidth = 0x00000001 & word; - //LOG(INFO) << BOLDRED << "STRIPS" << RESET; - //LOG (INFO) << BOLDRED << std::bitset<12>(word) << RESET; - //LOG(INFO) << BOLDRED << unsigned(aSCluster.fAddress)<<","<<unsigned(aSCluster.fWidth)<<","<< unsigned(aSCluster.fMip)<< RESET; + // LOG(INFO) << BOLDRED << "STRIPS" << RESET; + // LOG (INFO) << BOLDRED << std::bitset<12>(word) << RESET; + // LOG(INFO) << BOLDRED << unsigned(aSCluster.fAddress)<<","<<unsigned(aSCluster.fWidth)<<","<< unsigned(aSCluster.fMip)<< RESET; result.push_back(aSCluster); nstrips += 1; @@ -344,11 +337,10 @@ std::vector<PCluster> D19cMPAEvent::GetPixelClusters(uint8_t pFeId, uint8_t pMPA uint8_t cNstrip = GetNStripClusters(pFeId, pMPAId); uint8_t cSClusterSize = D19C_SCluster_SIZE_32_MPA; - uint8_t cPClusterSize = D19C_PCluster_SIZE_32_MPA; std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - uint8_t deltaword = 3*32 + cSClusterSize * (cNstrip); + uint8_t deltaword = 3 * 32 + cSClusterSize * (cNstrip); uint8_t npix = 0; while(npix < cNpix) @@ -357,9 +349,9 @@ std::vector<PCluster> D19cMPAEvent::GetPixelClusters(uint8_t pFeId, uint8_t pMPA aPCluster.fAddress = (0x00003f80 & word) >> 7; aPCluster.fWidth = (0x00000070 & word) >> 4; aPCluster.fZpos = 0x0000000F & word; - //LOG(INFO) << BOLDRED << "PIX" << RESET; - //LOG(INFO) << BOLDRED << std::bitset<15>(word) << RESET; - //LOG(INFO) << BOLDRED << unsigned(aPCluster.fAddress)<<","<<unsigned(aPCluster.fWidth)<<","<< unsigned(aPCluster.fZpos)<< RESET; + // LOG(INFO) << BOLDRED << "PIX" << RESET; + // LOG(INFO) << BOLDRED << std::bitset<15>(word) << RESET; + // LOG(INFO) << BOLDRED << unsigned(aPCluster.fAddress)<<","<<unsigned(aPCluster.fWidth)<<","<< unsigned(aPCluster.fZpos)<< RESET; result.push_back(aPCluster); npix += 1; } @@ -408,7 +400,7 @@ std::vector<Stub> D19cMPAEvent::StubVector(uint8_t pFeId, uint8_t pMPAId) const uint16_t cL1size_32_MPA = (0x00000FFF & lvec.at(0)) * 4; // Apparently something needs to be done with this? // uint16_t = (lvec.at (cL1size_32_MPA) & 0x00FFF000) >> 12 ; - if(lvec.size()>1) + if(lvec.size() > 1) { uint8_t pos1 = (lvec.at(cL1size_32_MPA + 1) & 0x00FF0000) >> 16; uint8_t pos2 = (lvec.at(cL1size_32_MPA + 2) & 0x000000FF) >> 0; @@ -444,27 +436,24 @@ uint8_t D19cMPAEvent::GetNStubs(uint8_t pFeId, uint8_t pMPAId) const { std::vector<Stub> cStubVec; // here create stubs and return the vector - //std::cout<<"GetNStubs"<<std::endl; - std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); - if(lvec.size()>1) + // std::cout<<"GetNStubs"<<std::endl; + std::vector<uint32_t> lvec = fEventDataVector.at(encodeVectorIndex(pFeId, pMPAId, fNMPA)); + if(lvec.size() > 1) { - //std::cout<<"GETEM"<<std::endl; - //for (auto L : lvec) LOG(INFO) << BOLDBLUE << std::bitset<32>(L) << RESET; - uint16_t cL1size_32_MPA = (0x00000FFF & lvec.at(0)) * 4; - //std::cout<<"GETEM"<<std::endl; - //std::cout<<std::bitset<32> (lvec.at(cL1size_32_MPA + 1))<<std::endl; - return (lvec.at(cL1size_32_MPA + 1) & 0x7) ; + // std::cout<<"GETEM"<<std::endl; + // for (auto L : lvec) LOG(INFO) << BOLDBLUE << std::bitset<32>(L) << RESET; + uint16_t cL1size_32_MPA = (0x00000FFF & lvec.at(0)) * 4; + // std::cout<<"GETEM"<<std::endl; + // std::cout<<std::bitset<32> (lvec.at(cL1size_32_MPA + 1))<<std::endl; + return (lvec.at(cL1size_32_MPA + 1) & 0x7); } else { - //LOG(INFO) << "Event: FE " << +pFeId << " MPA " << +pMPAId << " is not found."; LOG(INFO) << "Event: FE " << +pFeId << " MPA " << +pMPAId << " is not found."; + // LOG(INFO) << "Event: FE " << +pFeId << " MPA " << +pMPAId << " is not found."; LOG(INFO) << "Event: FE " << +pFeId << " MPA " << +pMPAId << " is not found."; return 0; } - - } - void D19cMPAEvent::print(std::ostream& os) const { os << "MPA Event #" << std::endl; @@ -484,9 +473,7 @@ void D19cMPAEvent::print(std::ostream& os) const } } -uint32_t D19cMPAEvent::GetNHits(uint8_t pFeId, uint8_t pMPAId) const { -return GetNPixelClusters(pFeId, pMPAId) + GetNStripClusters(pFeId, pMPAId); -} +uint32_t D19cMPAEvent::GetNHits(uint8_t pFeId, uint8_t pMPAId) const { return GetNPixelClusters(pFeId, pMPAId) + GetNStripClusters(pFeId, pMPAId); } std::string D19cMPAEvent::StubBitString(uint8_t pFeId, uint8_t pCbcId) const { @@ -515,10 +502,7 @@ std::vector<uint32_t> D19cMPAEvent::GetHits(uint8_t pFeId, uint8_t pMPAId) const std::string D19cMPAEvent::DataHexString(uint8_t pFeId, uint8_t pMPAId) const { return ""; } -bool D19cMPAEvent::StubBit(uint8_t pFeId, uint8_t pMPAId) const -{ - return (GetNStubs( pFeId, pMPAId)>0) ; -} +bool D19cMPAEvent::StubBit(uint8_t pFeId, uint8_t pMPAId) const { return (GetNStubs(pFeId, pMPAId) > 0); } SLinkEvent D19cMPAEvent::GetSLinkEvent(BeBoard* pBoard) const { diff --git a/Utils/OccupancyAndPh.cc b/Utils/OccupancyAndPh.cc index 7cb74d5a57ee3c528b9b885b2912b01a3d03098c..773f959a88fc1dd780ff841307b51ebabe6133a5 100644 --- a/Utils/OccupancyAndPh.cc +++ b/Utils/OccupancyAndPh.cc @@ -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) { diff --git a/Utils/OccupancyAndPh.h b/Utils/OccupancyAndPh.h index 5952914910d6af7b530b3a43a528c9881cdee462..fc53211484c138e6c72cf689ba95387f95b86e21 100644 --- a/Utils/OccupancyAndPh.h +++ b/Utils/OccupancyAndPh.h @@ -68,7 +68,7 @@ inline void OccupancyAndPh::makeChannelAverage<OccupancyAndPh>(const ChipContain numberOfEnabledChannels++; } - fOccupancy /= numberOfEnabledChannels; + fOccupancy /= (numberOfEnabledChannels > 0 ? numberOfEnabledChannels : 1); if(fPhError > 0) { diff --git a/Utils/RD53RunProgress.h b/Utils/RD53RunProgress.h index b6fe019d017726123bf38afd391de938f25083bc..9bdb5f57bc60f56d0f1b959d6d2666d02529029b 100644 --- a/Utils/RD53RunProgress.h +++ b/Utils/RD53RunProgress.h @@ -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"; } diff --git a/Utils/RD53Shared.cc b/Utils/RD53Shared.cc index e649d5d875c11bfc21056a2b42dcacd99ad148e9..fa1bde1d75e7613b750b8101fd88e13d46975698 100644 --- a/Utils/RD53Shared.cc +++ b/Utils/RD53Shared.cc @@ -19,7 +19,7 @@ std::string RD53Shared::fromInt2Str(int val) std::string RD53Shared::composeFileName(const std::string& configFileName, const std::string& fName2Add) { std::string output = configFileName; - output.insert(output.find(RD53Shared::NAMESEARCHinPATH), fName2Add); + output.insert(output.find_last_of("/\\") + 1, fName2Add); return output; } @@ -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); } diff --git a/Utils/RD53Shared.h b/Utils/RD53Shared.h index 02b015b3437e2218a8358c749d1b98c1e424fd22..0ca9b3ca75a57656eec6e12be384f1b2b58d6ffa 100644 --- a/Utils/RD53Shared.h +++ b/Utils/RD53Shared.h @@ -12,22 +12,23 @@ #include <cmath> #include <iomanip> +#include <iostream> #include <sstream> #include <thread> namespace RD53Shared { -const char NAMESEARCHinPATH[] = "CMSIT"; // Search for this name in config file name for manipulation -const char RESULTDIR[] = "Results"; // Directory containing the results -const double ISDISABLED = -1.0; // Encoding disabled channels -const double FITERROR = -2.0; // Encoding fit errors -const int NLATENCYBINS = 2; // Number of latencies spanned -const int MAXBITCHIPREG = 16; // Maximum number of bits of a chp register -const size_t NTHREADS = round(std::thread::hardware_concurrency() / 2.); // Number of potential threads for the current CPU (removing hyper-threading) +const char RESULTDIR[] = "Results"; // Directory containing the results +const double ISDISABLED = -1.0; // Encoding disabled channels +const double FITERROR = -2.0; // Encoding fit errors +const int NLATENCYBINS = 2; // Number of latencies spanned +const int MAXBITCHIPREG = 16; // Maximum number of bits of a chp register +const size_t NTHREADS = round(std::thread::hardware_concurrency() / 2.); // Number of potential threads for the current CPU (removing hyper-threading) 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 diff --git a/settings/CMSIT.xml b/settings/CMSIT.xml index 584ad3e7a0d80ae4c3ecf748afc864eb093b85f8..8f71b5ecb4f09f45fd78faba149976db7222413c 100755 --- a/settings/CMSIT.xml +++ b/settings/CMSIT.xml @@ -137,11 +137,9 @@ <Register name="ext_clk_en"> 0 </Register> </Register> - <!-- <Register name="fast_cmd_reg_3"> <Register name="triggers_to_accept"> 10 </Register> </Register> - --> </Register> </Register> @@ -149,15 +147,18 @@ </BeBoard> <Settings> - <!-- - === Calibration parameters === - INJtype = 0: no injection; INJtype = 1: analog; INJtype = 2: digital - DoFast = 0: run on all pixels in the selected region; DoFast = 1: run on a subset - DisplayHisto = 0: don't display; DisplayHisto = 1: display - UpdateChipCfg = 0: don't update; UpdateChipCfg = 1: update - - TargetCharge: average charge (electrons) corresponding to ToT point = max value - 1 - TargetOcc: average fraction of acceptable hits per pixel + <!-- === Calibration parameters === + INJtype = 0: no injection; INJtype = 1: analog; INJtype = 2: digital + ResetMask = 0: do not enable masked pixels; ResetMask = 1: enable all pixels + ResetTDAC = 0: do not reset TDAC; ResetTDAC = 1: reset TDAC to range midpoint + DoFast = 0: run on all pixels in the selected region; DoFast = 1: run on a subset + DisplayHisto = 0: don't display; DisplayHisto = 1: display + UpdateChipCfg = 0: don't update; UpdateChipCfg = 1: update + + TargetCharge (thradj): average charge (electrons) corresponding to ToT point = max value - 1 + TargetOcc (thrmin): average pixel occupancy + TargetOcc (pixelalive/noise): per pixel occupancy threhold below/above which pixels are masked + UnstuckPixels (pixelalive) = 0: do not try to unstuck pixels; UnstuckPixels = 1: set TDAC to 0 to unstuck pixels --> <Setting name="nEvents"> 100 </Setting> <Setting name="nEvtsBurst"> 100 </Setting> @@ -168,6 +169,8 @@ <Setting name="nTRIGxEvent"> 10 </Setting> <Setting name="INJtype"> 1 </Setting> + <Setting name="ResetMask"> 0 </Setting> + <Setting name="ResetTDAC"> 0 </Setting> <Setting name="ROWstart"> 0 </Setting> <Setting name="ROWstop"> 191 </Setting> @@ -190,6 +193,7 @@ <Setting name="ThrStop"> 440 </Setting> <Setting name="TargetThr"> 2000 </Setting> <Setting name="TargetOcc"> 1e-6 </Setting> + <Setting name="UnstuckPixels"> 0 </Setting> <Setting name="DoFast"> 0 </Setting> <Setting name="DisplayHisto"> 0 </Setting> @@ -198,10 +202,12 @@ <!-- === Expert settings === SaveBinaryData = 0: do not save raw data in binary format; SaveBinaryData = 1: save raw data in binary format nHITxCol: number of simultaneously injected pixels per column (it must be a divider of chip rows) - nClkDelays: controls the delay between two consecutive injections in terms of 100ns period + InjLatency: controls the latency of the injection in terms of 100ns period (up to 4095) + nClkDelays: controls the delay between two consecutive injections in terms of 100ns period (up to 4095) --> <Setting name="SaveBinaryData"> 0 </Setting> <Setting name="nHITxCol"> 1 </Setting> + <Setting name="InjLatency"> 32 </Setting> <Setting name="nClkDelays"> 280 </Setting> </Settings> diff --git a/settings/RD53Files/CMSIT_RD53.txt b/settings/RD53Files/CMSIT_RD53.txt index 5753e414b28a70d63d9600c403608176d31a4e84..3df3018e743d6adf109ad7e518131c63fa97b1c8 100755 --- a/settings/RD53Files/CMSIT_RD53.txt +++ b/settings/RD53Files/CMSIT_RD53.txt @@ -1738,61 +1738,61 @@ TDAC 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 COL 254 ENABLE 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 -HITBUS 0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 TDAC 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 diff --git a/setup.sh b/setup.sh old mode 100755 new mode 100644 index 01a76e820ee600493c19f9a45ecb2488c06a4f97..ba1a68d4dfa0164ebc4553ce1a57e78c5f3032fa --- a/setup.sh +++ b/setup.sh @@ -22,9 +22,14 @@ fi ######## # ROOT # ######## -source $ROOTSYS/bin/thisroot.sh -# source /usr/local/root/bin/thisroot.sh -# source /opt/local/root/bin/thisroot.sh +THISROOTSH=${ROOTSYS}/bin/thisroot.sh +[ ! -f ${THISROOTSH} ] || source ${THISROOTSH} +unset THISROOTSH + +if ! command -v root &> /dev/null; then + printf "%s\n" ">> ERROR -- CERN ROOT is not available; please install it before using Ph2_ACF (see README)" + return 1 +fi ####### # ZMQ # diff --git a/src/CMSITminiDAQ.cc b/src/CMSITminiDAQ.cc index 69dee0f7989f28b6a1fcdb9b177cff3b6522da66..bb8c4b8bf14b85aa65b5a65e848ca79107761ebc 100644 --- a/src/CMSITminiDAQ.cc +++ b/src/CMSITminiDAQ.cc @@ -1,6 +1,6 @@ /*! \file CMSITminiDAQ.cc - \brief Mini DAQ to test RD53 readout + \brief Mini DAQ to test RD53 readout chip \author Mauro DINARDO \version 1.0 \date 28/06/18 @@ -41,6 +41,8 @@ #define RUNNUMBER 0 #define SETBATCH 0 // Set batch mode when running supervisor #define FILERUNNUMBER "./RunNumber.txt" +#define BASEDIR "PH2ACF_BASE_DIR" +#define ARBITRARYDELAY 2e6 // [us] INITIALIZE_EASYLOGGINGPP @@ -62,9 +64,10 @@ void interruptHandler(int handler) exit(EXIT_FAILURE); } -void readBinaryData(std::string binaryFile, SystemController& mySysCntr, std::vector<RD53FWInterface::Event>& decodedEvents) +void readBinaryData(const std::string& binaryFile, SystemController& mySysCntr, std::vector<RD53FWInterface::Event>& decodedEvents) { - unsigned int errors = 0; + const unsigned int wordDataSize = 32; + unsigned int errors = 0; std::vector<uint32_t> data; LOG(INFO) << BOLDMAGENTA << "@@@ Decoding binary data file @@@" << RESET; @@ -80,9 +83,14 @@ void readBinaryData(std::string binaryFile, SystemController& mySysCntr, std::ve { LOG(ERROR) << BOLDBLUE << "\t--> Corrupted event n. " << BOLDYELLOW << i << RESET; errors++; + RD53FWInterface::PrintEvents({decodedEvents[i]}); } - LOG(INFO) << GREEN << "Percentage of corrupted events: " << std::setprecision(3) << BOLDYELLOW << 1. * errors / decodedEvents.size() * 100. << "%" << std::setprecision(-1) << RESET; + LOG(INFO) << GREEN << "Corrupted events: " << BOLDYELLOW << std::setprecision(3) << errors << " (" << 1. * errors / decodedEvents.size() * 100. << "%)" << std::setprecision(-1) << RESET; + int avgEventSize = data.size() / decodedEvents.size(); + LOG(INFO) << GREEN << "Average event size is " << BOLDYELLOW << avgEventSize * wordDataSize << RESET << GREEN << " bits over " << BOLDYELLOW << decodedEvents.size() << RESET << GREEN << " events" + << RESET; + mySysCntr.closeFileHandler(); } int main(int argc, char** argv) @@ -138,7 +146,7 @@ int main(int argc, char** argv) fileRunNumberIn.open(FILERUNNUMBER, std::ios::in); if(fileRunNumberIn.is_open() == true) fileRunNumberIn >> runNumber; fileRunNumberIn.close(); - system(std::string("mkdir " + std::string(RD53Shared::RESULTDIR)).c_str()); + system(std::string("mkdir -p " + std::string(RD53Shared::RESULTDIR)).c_str()); // #################### // # Retrieve options # @@ -161,7 +169,7 @@ int main(int argc, char** argv) std::string fileName("logs/CMSITminiDAQ" + RD53Shared::fromInt2Str(runNumber)); if(whichCalib != "") fileName += "_" + whichCalib; fileName += ".log"; - el::Configurations conf(std::string(std::getenv("PH2ACF_BASE_DIR")) + "/settings/logger.conf"); + el::Configurations conf(std::string(std::getenv(BASEDIR)) + "/settings/logger.conf"); conf.set(el::Level::Global, el::ConfigurationType::Format, "|%thread|%levshort| %msg"); conf.set(el::Level::Global, el::ConfigurationType::Filename, fileName); el::Loggers::reconfigureAllLoggers(conf); @@ -187,7 +195,7 @@ int main(int argc, char** argv) else if(runControllerPid == 0) { char* argv[] = {(char*)"RunController", NULL}; - execv((std::string(std::getenv("PH2ACF_BASE_DIR")) + "/bin/RunController").c_str(), argv); + execv((std::string(std::getenv(BASEDIR)) + "/bin/RunController").c_str(), argv); LOG(ERROR) << BOLDRED << "I can't run RunController, error occured" << RESET; exit(EXIT_FAILURE); } @@ -258,9 +266,9 @@ int main(int argc, char** argv) { LOG(INFO) << BOLDBLUE << "Supervisor sending stop" << RESET; - usleep(2e6); + usleep(ARBITRARYDELAY); theMiddlewareInterface.stop(); - usleep(2e6); + usleep(ARBITRARYDELAY); theDQMInterface.stopProcessingData(); stateMachineStatus = STOPPED; @@ -525,15 +533,16 @@ int main(int argc, char** argv) std::string fileName("Run" + RD53Shared::fromInt2Str(runNumber) + "_Physics"); Physics ph; ph.Inherit(&mySysCntr); - ph.localConfigure(fileName, -1); if(binaryFile == "") { + ph.localConfigure(fileName, -1); ph.Start(runNumber); - usleep(2e6); + usleep(ARBITRARYDELAY); ph.Stop(); } else { + ph.localConfigure(fileName, runNumber); ph.analyze(true); ph.draw(); } @@ -577,9 +586,12 @@ int main(int argc, char** argv) if(cmd.argument(0) == "") { - LOG(ERROR) << BOLDRED - << "Neither the time (to be given with -t <TIME IN SECONDS>) nor the number of frames (to be given with -n <NUMBER OF FRAMES>) was specified for the PRBS test. Abort." - << RESET; + if(whichCalib == "prbstime") { LOG(ERROR) << BOLDRED << "Failed to specify duration of PRBS test; use \"-c prbstime <TIME IN SECONDS>\"" << RESET; } + else if(whichCalib == "prbsframes") + { + LOG(ERROR) << BOLDRED << "Failed to specify number of frames for PRBS test; use \"-c prbsframes <NUMBER OF FRAMES>\"" << RESET; + } + exit(EXIT_FAILURE); } @@ -602,7 +614,7 @@ int main(int argc, char** argv) mySysCntr.fReadoutChipInterface->WriteChipReg(static_cast<RD53*>(cChip), "SER_SEL_OUT", 1, true); } } - else if(program == false) + else if((program == false) && (whichCalib != "")) { LOG(ERROR) << BOLDRED << "Option not recognized: " << BOLDYELLOW << whichCalib << RESET; exit(EXIT_FAILURE); @@ -611,10 +623,9 @@ int main(int argc, char** argv) // ########################### // # Copy configuration file # // ########################### - std::string fName2Add(std::string(RD53Shared::RESULTDIR) + "/Run" + RD53Shared::fromInt2Str(runNumber) + "_"); - std::string output(RD53Shared::composeFileName(configFile, fName2Add)); - std::string command("cp " + configFile + " " + output); - system(command.c_str()); + const auto configFileBasename = configFile.substr(configFile.find_last_of("/\\") + 1); + const auto outputConfigFile = std::string(RD53Shared::RESULTDIR) + "/Run" + RD53Shared::fromInt2Str(runNumber) + "_" + configFileBasename; + system(("cp " + configFile + " " + outputConfigFile).c_str()); // ##################### // # Update run number # diff --git a/src/MPA_sync_test.cc b/src/MPA_sync_test.cc index 38ec321c470343838d96fab413fef824012f87f3..158a1d743ebde46e62c51e8ce432afef02373016 100644 --- a/src/MPA_sync_test.cc +++ b/src/MPA_sync_test.cc @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) std::this_thread::sleep_for(ShortWait); uint32_t gpix = theMPA->PNglobal(std::pair<uint32_t, uint32_t>(row, col)); - //theMPAInterface->Disable_pixel(cMPA, 0); + // theMPAInterface->Disable_pixel(cMPA, 0); theMPAInterface->WriteChipReg(cMPA, "ENFLAGS_ALL", 0x57); theMPAInterface->WriteChipReg(cMPA, "ENFLAGS_P" + std::to_string(gpix), 0x57); // theMPAInterface->WriteChipReg(cMPA, "ClusterCut_P" + std::to_string(gpix), 0x57); @@ -129,127 +129,122 @@ int main(int argc, char* argv[]) // std::this_thread::sleep_for(ShortWait); - - - for(size_t ilat = 0; ilat <1000; ilat++) - { - //ilat=28; - std::cout <<"ilat "<< ilat << std::endl; - //for(size_t rr = 1; rr < 17; rr++) - // { - // theMPAInterface->WriteChipReg(cMPA, "L1Offset_1_ALL", (0x00FF & ilat) >> 0 ); - // theMPAInterface->WriteChipReg(cMPA, "L1Offset_2_ALL", (0x0100 & ilat) >> 8); - // } - - // theMPAInterface->WriteChipReg(cMPA, "PhaseShift", ilat); - theMPAInterface->WriteChipReg(cMPA, "L1Offset_1_ALL", (0x00FF & 56) >> 0); - theMPAInterface->WriteChipReg(cMPA, "L1Offset_2_ALL", (0x0100 & 56) >> 8); - cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.readout_block.global.common_stubdata_delay", ilat); - - // theMPAInterface->WriteChipReg(cMPA, "PhaseShift", ilat); - // cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.readout_block.global.zero_suppression_enable", 0); - // cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.fast_command_block.stub_trigger_delay_value", ilat); - - cTool.fBeBoardInterface->ChipReSync(pBoard); - static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->ResetReadout(); - - // theMPAInterface->WriteChipReg(cMPA, "LatencyRx40", ilat); - // theMPAInterface->enableInjection(cMPA,true); - cTool.ReadNEvents(pBoard, 100); - std::this_thread::sleep_for(ShortWait); - std::this_thread::sleep_for(ShortWait); - std::this_thread::sleep_for(ShortWait); - - auto rawstubs = - static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->ReadBlockRegValue("fc7_daq_stat.physical_interface_block.stat_slvs_debug_mpa_stub_0", 80); - std::vector<std::vector<uint8_t>> stubs(5, vector<uint8_t>(40, 0)); - uint32_t line = 0; - uint32_t cycle = 0; - - for(size_t ist = 0; ist < 50; ist++) + for(size_t ilat = 0; ilat < 1000; ilat++) { - // LOG(INFO) <<BOLDRED<<rawstubs[ist]<<std::dec<< RESET; - for(size_t ib = 0; ib < 4; ib++) + // ilat=28; + std::cout << "ilat " << ilat << std::endl; + // for(size_t rr = 1; rr < 17; rr++) + // { + // theMPAInterface->WriteChipReg(cMPA, "L1Offset_1_ALL", (0x00FF & ilat) >> 0 ); + // theMPAInterface->WriteChipReg(cMPA, "L1Offset_2_ALL", (0x0100 & ilat) >> 8); + // } + + // theMPAInterface->WriteChipReg(cMPA, "PhaseShift", ilat); + theMPAInterface->WriteChipReg(cMPA, "L1Offset_1_ALL", (0x00FF & 56) >> 0); + theMPAInterface->WriteChipReg(cMPA, "L1Offset_2_ALL", (0x0100 & 56) >> 8); + cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.readout_block.global.common_stubdata_delay", ilat); + + // theMPAInterface->WriteChipReg(cMPA, "PhaseShift", ilat); + // cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.readout_block.global.zero_suppression_enable", 0); + // cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.fast_command_block.stub_trigger_delay_value", ilat); + + cTool.fBeBoardInterface->ChipReSync(pBoard); + static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->ResetReadout(); + + // theMPAInterface->WriteChipReg(cMPA, "LatencyRx40", ilat); + // theMPAInterface->enableInjection(cMPA,true); + cTool.ReadNEvents(pBoard, 100); + std::this_thread::sleep_for(ShortWait); + std::this_thread::sleep_for(ShortWait); + std::this_thread::sleep_for(ShortWait); + + auto rawstubs = + static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->ReadBlockRegValue("fc7_daq_stat.physical_interface_block.stat_slvs_debug_mpa_stub_0", 80); + std::vector<std::vector<uint8_t>> stubs(5, vector<uint8_t>(40, 0)); + uint32_t line = 0; + uint32_t cycle = 0; + + for(size_t ist = 0; ist < 50; ist++) { - // LOG(INFO) <<BOLDRED<<std::bitset<32>(rawstubs[ist])<<std::dec<< RESET; - stubs[line][cycle] = ((rawstubs[ist]) & (0xFF << ib * 8)) >> ib * 8; // to_number(reverse_mask(word),(i+1)*8,i*8) - // LOG(INFO) <<BOLDRED<<line<<","<<cycle<<" "<<std::bitset<8>(stubs[line][cycle])<<std::dec<< RESET; - cycle += 1; - if(cycle == 40) + // LOG(INFO) <<BOLDRED<<rawstubs[ist]<<std::dec<< RESET; + for(size_t ib = 0; ib < 4; ib++) { - line += 1; - cycle = 0; + // LOG(INFO) <<BOLDRED<<std::bitset<32>(rawstubs[ist])<<std::dec<< RESET; + stubs[line][cycle] = ((rawstubs[ist]) & (0xFF << ib * 8)) >> ib * 8; // to_number(reverse_mask(word),(i+1)*8,i*8) + // LOG(INFO) <<BOLDRED<<line<<","<<cycle<<" "<<std::bitset<8>(stubs[line][cycle])<<std::dec<< RESET; + cycle += 1; + if(cycle == 40) + { + line += 1; + cycle = 0; + } } } - } - Stubs fst = theMPAInterface->Format_stubs(stubs); - uint32_t nst = 0; - for(auto& st1: fst.nst) - { - if(st1 != 0 and false) + Stubs fst = theMPAInterface->Format_stubs(stubs); + uint32_t nst = 0; + for(auto& st1: fst.nst) { - std::cout << "CYCLE " << uint32_t(nst) << std::endl; - std::cout << "pos " << uint32_t(fst.pos[nst][0]) << std::endl; - // for( auto& st2: fst.pos[nst])std::cout << "pos "<<uint32_t(st2)<< std::endl; - // for( auto& st2: fst.row[nst])std::cout << "row "<<uint32_t(st2)<< std::endl; - // for( auto& st2: fst.cur[nst])std::cout << "cur "<<uint32_t(st2)<< std::endl; + if(st1 != 0 and false) + { + std::cout << "CYCLE " << uint32_t(nst) << std::endl; + std::cout << "pos " << uint32_t(fst.pos[nst][0]) << std::endl; + // for( auto& st2: fst.pos[nst])std::cout << "pos "<<uint32_t(st2)<< std::endl; + // for( auto& st2: fst.row[nst])std::cout << "row "<<uint32_t(st2)<< std::endl; + // for( auto& st2: fst.cur[nst])std::cout << "cur "<<uint32_t(st2)<< std::endl; + } + nst += 1; } - nst += 1; - } - // std::this_thread::sleep_for(ShortWait); - // static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->Send_pulses(1500); - // std::this_thread::sleep_for(ShortWait); + // std::this_thread::sleep_for(ShortWait); + // static_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface())->Send_pulses(1500); + // std::this_thread::sleep_for(ShortWait); - // std::this_thread::sleep_for(ShortWait); - /*for(uint32_t cpix = 1; cpix <= 1920; cpix++) + // std::this_thread::sleep_for(ShortWait); + /*for(uint32_t cpix = 1; cpix <= 1920; cpix++) + { + uint8_t cRP1 = theMPAInterface->ReadChipReg(cMPA, "ReadCounter_LSB_P" + std::to_string(cpix)); + uint8_t cRP2 = theMPAInterface->ReadChipReg(cMPA, "ReadCounter_MSB_P" + std::to_string(cpix)); + + std::cout<<"counts"<<cpix<<" "<<(cRP2*256) + cRP1<<std::endl; + }*/ + const std::vector<Event*>& events = cTool.GetEvents(); + + // const std::vector<Event*> &eventVector = cTool.GetEvents(); + int nev = 0; + int nevtot = 0; + int nstub = 0; + for(__attribute__((unused)) auto& ev: events) { - uint8_t cRP1 = theMPAInterface->ReadChipReg(cMPA, "ReadCounter_LSB_P" + std::to_string(cpix)); - uint8_t cRP2 = theMPAInterface->ReadChipReg(cMPA, "ReadCounter_MSB_P" + std::to_string(cpix)); - - std::cout<<"counts"<<cpix<<" "<<(cRP2*256) + cRP1<<std::endl; - }*/ - const std::vector<Event*>& events = cTool.GetEvents(pBoard); - - // const std::vector<Event*> &eventVector = cTool.GetEvents(pBoard); - int nev=0; - int nevtot=0; - int nstub=0; - for(__attribute__((unused)) auto& ev: events) - { - //std::cout << clus << std::endl; - std::vector<PCluster> clus = static_cast<D19cMPAEvent*>(ev)->GetPixelClusters(0,0); - //nevtot+=clus.size(); - nevtot+= static_cast<D19cMPAEvent*>(ev)->GetNHits(0, 0); - - + // std::cout << clus << std::endl; + std::vector<PCluster> clus = static_cast<D19cMPAEvent*>(ev)->GetPixelClusters(0, 0); + // nevtot+=clus.size(); + nevtot += static_cast<D19cMPAEvent*>(ev)->GetNHits(0, 0); - std::cout << "GetNStubs -- " << +static_cast<D19cMPAEvent*>(ev)->GetNStubs(0,0) << std::endl; + std::cout << "GetNStubs -- " << +static_cast<D19cMPAEvent*>(ev)->GetNStubs(0, 0) << std::endl; - std::vector<Stub> stubs = static_cast<D19cMPAEvent*>(ev)->StubVector(0,0); - nstub+=stubs.size(); - //std::cout << "pclus "<< std::endl; - /*for( auto& pc: clus) + std::vector<Stub> stubs = static_cast<D19cMPAEvent*>(ev)->StubVector(0, 0); + nstub += stubs.size(); + // std::cout << "pclus "<< std::endl; + /*for( auto& pc: clus) { std::cout << "---------------------------------------------------------------------------------------------------------------------------------------"<< std::endl; std::cout << "fAddress "<<+pc.fAddress<< std::endl; std::cout << "fWidth "<<+pc.fWidth<< std::endl; std::cout << "fZpos "<<+pc.fZpos << std::endl<< std::endl; }*/ - //std::cout << "stubs "<< std::endl; - /*for( auto& st: stubs) + // std::cout << "stubs "<< std::endl; + /*for( auto& st: stubs) { std::cout << "getPosition "<<+st.getPosition()<< std::endl; std::cout << "getBend "<<+st.getBend()<< std::endl; std::cout << "getRow "<<+st.getRow()<< std::endl; std::cout << "getCenter "<<+st.getCenter()<< std::endl<< std::endl; }*/ - nev+=1; - + nev += 1; } - if (nevtot!=0)std::cout<<"nevtot "<< nevtot << std::endl; - if (nstub!=0)std::cout <<"nstub "<< nstub << std::endl; + if(nevtot != 0) std::cout << "nevtot " << nevtot << std::endl; + if(nstub != 0) std::cout << "nstub " << nstub << std::endl; } npixtot += 1; diff --git a/src/MPAlatency.cc b/src/MPAlatency.cc index 8f67313e215e7b14b0ea75457e6cf336e06bb13c..dd239f83b7b3220de52c3a8a2df6523dd81bb7e2 100644 --- a/src/MPAlatency.cc +++ b/src/MPAlatency.cc @@ -13,8 +13,6 @@ #include "tools/BackEndAlignment.h" #include <cstring> - - using namespace Ph2_HwDescription; using namespace Ph2_HwInterface; using namespace Ph2_System; @@ -43,12 +41,7 @@ int main(int argc, char* argv[]) cmd.defineOption("batch", "Run the application in batch mode", ArgvParser::NoOptionAttribute); cmd.defineOptionAlternative("batch", "b"); - - bool batchMode = (cmd.foundOption("batch")) ? true : false; - - - - + bool batchMode = (cmd.foundOption("batch")) ? true : false; int result = cmd.parse(argc, argv); @@ -78,14 +71,10 @@ int main(int argc, char* argv[]) cTool.CreateResultDirectory("Latency"); cTool.InitResultFile("Latency"); - - if(batchMode) - gROOT->SetBatch(true); - BeBoard* pBoard = static_cast<BeBoard*>(cTool.fDetectorContainer->at(0)); + if(batchMode) gROOT->SetBatch(true); + BeBoard* pBoard = static_cast<BeBoard*>(cTool.fDetectorContainer->at(0)); pBoard->setFrontEndType(FrontEndType::MPA); - - // cTool.StartHttpServer(); // align back-end .. if this moves to firmware then we can get rid of this step @@ -100,7 +89,6 @@ int main(int argc, char* argv[]) exit(0); } - LOG(INFO) << BOLDRED << "LatencyScan" << RESET; LatencyScan cLatencyScan; LOG(INFO) << BOLDRED << "Inherit" << RESET; @@ -110,158 +98,133 @@ int main(int argc, char* argv[]) LOG(INFO) << BOLDRED << "Scan" << RESET; pBoard->setFrontEndType(FrontEndType::MPA); - std::vector<int>rows{5,74,51,98,20}; - std::vector<int>cols{1}; + std::vector<int> rows{5, 74, 51, 98, 20}; + std::vector<int> cols{1}; for(auto cOpticalGroup: *pBoard) + { + for(auto cFe: *cOpticalGroup) + { + for(auto cChip: *cFe) { - for(auto cFe: *cOpticalGroup) + if(cChip->getFrontEndType() == FrontEndType::MPA) { - - for(auto cChip: *cFe) - { - if (cChip->getFrontEndType() == FrontEndType::MPA) - { - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Set_calibration(cChip, 50); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Set_threshold(cChip, 100); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Activate_sync(cChip); - //static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x57); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x0); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ClusterCut_ALL",2); - for(auto rr: rows) - { - for(auto cc: cols) - { - auto pngl=static_cast<MPA*>(cChip)->PNglobal(std::pair<uint32_t, uint32_t>{cc,rr} ); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_P"+std::to_string(pngl),0x57); - - } - } - } - if (cChip->getFrontEndType() == FrontEndType::SSA) - { - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS", 0); - } + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Set_calibration(cChip, 50); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Set_threshold(cChip, 100); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Activate_sync(cChip); + // static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x57); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x0); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ClusterCut_ALL", 2); + for(auto rr: rows) + { + for(auto cc: cols) + { + auto pngl = static_cast<MPA*>(cChip)->PNglobal(std::pair<uint32_t, uint32_t>{cc, rr}); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_P" + std::to_string(pngl), 0x57); + } } - - } + } + if(cChip->getFrontEndType() == FrontEndType::SSA) { static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS", 0); } } - - - - auto hitlatmpa=cLatencyScan.ScanLatency(30, 50); + } + } + auto hitlatmpa = cLatencyScan.ScanLatency(30, 50); for(auto cOpticalGroup: *pBoard) + { + for(auto cFe: *cOpticalGroup) + { + for(auto cChip: *cFe) { - for(auto cFe: *cOpticalGroup) + if(cChip->getFrontEndType() == FrontEndType::MPA) { static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0); } + if(cChip->getFrontEndType() == FrontEndType::SSA) { - - for(auto cChip: *cFe) - { - if (cChip->getFrontEndType() == FrontEndType::MPA) - { - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0); - } - if (cChip->getFrontEndType() == FrontEndType::SSA) - { - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "FE_Calibration", 1); - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS", 0); - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "Bias_CALDAC", 120); - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "Bias_THDAC", 60); - - for(auto rr: rows) - { - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_S"+std::to_string(rr+1),19); - } - - } - } + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "FE_Calibration", 1); + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS", 0); + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "Bias_CALDAC", 120); + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "Bias_THDAC", 60); - } + for(auto rr: rows) { static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_S" + std::to_string(rr + 1), 19); } + } } + } + } cLatencyScan.Initialize(0, 100); - auto hitlatssa=cLatencyScan.ScanLatency(30, 50); - + auto hitlatssa = cLatencyScan.ScanLatency(30, 50); for(auto cOpticalGroup: *pBoard) + { + for(auto cFe: *cOpticalGroup) + { + for(auto cChip: *cFe) { - for(auto cFe: *cOpticalGroup) + if(cChip->getFrontEndType() == FrontEndType::MPA) { - - for(auto cChip: *cFe) - { - if (cChip->getFrontEndType() == FrontEndType::MPA) - { - uint8_t hitlmpa=hitlatmpa[cFe]; - LOG(INFO) << BOLDRED << "Hit max " <<+hitlmpa<< RESET; - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1Offset_1_ALL", (0x00FF & hitlmpa) >> 0 ); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1Offset_2_ALL",(0x0100 & hitlmpa) >> 8); - } - - if (cChip->getFrontEndType() == FrontEndType::SSA) - { - uint8_t hitlssa=hitlatssa[cFe]; - LOG(INFO) << BOLDRED << "Hit max " <<+hitlssa<< RESET; - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1-Latency_LSB", (0x00FF & hitlssa) >> 0 ); - static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1-Latency_MSB",(0x0100 & hitlssa) >> 8); - } - } + uint8_t hitlmpa = hitlatmpa[cFe]; + LOG(INFO) << BOLDRED << "Hit max " << +hitlmpa << RESET; + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1Offset_1_ALL", (0x00FF & hitlmpa) >> 0); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1Offset_2_ALL", (0x0100 & hitlmpa) >> 8); + } - } + if(cChip->getFrontEndType() == FrontEndType::SSA) + { + uint8_t hitlssa = hitlatssa[cFe]; + LOG(INFO) << BOLDRED << "Hit max " << +hitlssa << RESET; + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1-Latency_LSB", (0x00FF & hitlssa) >> 0); + static_cast<SSAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "L1-Latency_MSB", (0x0100 & hitlssa) >> 8); + } } - - - for(size_t irt = 0; irt <10; irt++) + } + } + + for(size_t irt = 0; irt < 10; irt++) { - LOG(INFO) << BOLDRED << "RetimePix " << irt<< RESET; - bool found=false; + LOG(INFO) << BOLDRED << "RetimePix " << irt << RESET; + bool found = false; for(auto cOpticalGroup: *pBoard) + { + for(auto cFe: *cOpticalGroup) + { + for(auto cChip: *cFe) { - for(auto cFe: *cOpticalGroup) + if(cChip->getFrontEndType() == FrontEndType::MPA) { - - for(auto cChip: *cFe) - { - if (cChip->getFrontEndType() == FrontEndType::MPA) - { - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Activate_ps(cChip); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x0); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ClusterCut_ALL",4); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "RetimePix", irt); - for(auto rr: rows) - { - for(auto cc: cols) - { - auto pngl=static_cast<MPA*>(cChip)->PNglobal(std::pair<uint32_t, uint32_t>{cc,rr} ); - static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_P"+std::to_string(pngl),0x57); - } - } - - } + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->Activate_ps(cChip); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_ALL", 0x0); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ClusterCut_ALL", 4); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "RetimePix", irt); + for(auto rr: rows) + { + for(auto cc: cols) + { + auto pngl = static_cast<MPA*>(cChip)->PNglobal(std::pair<uint32_t, uint32_t>{cc, rr}); + static_cast<MPAInterface*>(cTool.fReadoutChipInterface)->WriteChipReg(cChip, "ENFLAGS_P" + std::to_string(pngl), 0x57); + } } - } + } } + } + } - auto stublat=cLatencyScan.ScanStubLatency(0, 50); + auto stublat = cLatencyScan.ScanStubLatency(0, 50); for(auto cOpticalGroup: *pBoard) - { + { for(auto cFe: *cOpticalGroup) + { + if(stublat[cFe] != 0) { - if (stublat[cFe]!=0) - { - found=true; - LOG(INFO) << BOLDRED << "Stub max " <<unsigned(stublat[cFe])<<" RetimePix " << irt<< RESET; + found = true; + LOG(INFO) << BOLDRED << "Stub max " << unsigned(stublat[cFe]) << " RetimePix " << irt << RESET; cTool.fBeBoardInterface->WriteBoardReg(pBoard, "fc7_daq_cnfg.readout_block.global.common_stubdata_delay", stublat[cFe]); - } - } + } } + } - if (found) break; + if(found) break; } - LOG(INFO) << BOLDRED << "Done" << RESET; diff --git a/src/Pedagogical.cc b/src/Pedagogical.cc index ec2d51dc9d897c3b1332b947d62e2d6c9621e3a0..6f609359af0839bc9841eb1f261ad8017c1c7123 100644 --- a/src/Pedagogical.cc +++ b/src/Pedagogical.cc @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) cTool.fReadoutChipInterface->WriteChipReg(theSSA, "Bias_THDAC", thd); } cTool.ReadNEvents(pBoard, 500); - const std::vector<Event*>& eventVector = cTool.GetEvents(pBoard); + const std::vector<Event*>& eventVector = cTool.GetEvents(); for(auto& event: eventVector) // for on events - begin { LOG(INFO) << BOLDRED << "L1N: " << static_cast<D19cSSAEvent*>(event)->GetL1Number() << RESET; diff --git a/src/cbc3irrad.cc b/src/cbc3irrad.cc index 4aeb5407b9292b9f3597d53f3e74825e090a7e68..1f41e5a0444b23c6b3b1dfd158c38df04f9103d7 100644 --- a/src/cbc3irrad.cc +++ b/src/cbc3irrad.cc @@ -371,7 +371,7 @@ int main(int argc, char* argv[]) else cTool.ReadNEvents(pBoard, cAcqSize); - const std::vector<Event*>& events = cTool.GetEvents(pBoard); + const std::vector<Event*>& events = cTool.GetEvents(); for(auto& ev: events) { diff --git a/src/cic_datatest.cc b/src/cic_datatest.cc index 79a7100d1727da1522737d83e8c778c7041d2a9a..09e800a75042de83256e8205956ff66b5adef547 100644 --- a/src/cic_datatest.cc +++ b/src/cic_datatest.cc @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) dynamic_cast<D19cFWInterface*>(cCicAligner.fBeBoardInterface->getFirmwareInterface())->ConfigureTriggerFSM(0, 75); // read n events from the board cCicAligner.ReadNEvents(pBoard, 10); - const std::vector<Event*>& events = cCicAligner.GetEvents(pBoard); + const std::vector<Event*>& events = cCicAligner.GetEvents(); LOG(INFO) << BOLDBLUE << "Read back " << +events.size() << " events from FC7." << RESET; LOG(INFO) << BOLDBLUE << "Vcth = " << +cVcth << " DAC units." << RESET; int cNevents = 0; diff --git a/src/cic_test.cc b/src/cic_test.cc index f2a422c05dde632d8a257c3e118f48adfabc7ea4..da5a0584a5914689005cc43f7b22f4bc30bed16f 100644 --- a/src/cic_test.cc +++ b/src/cic_test.cc @@ -276,7 +276,7 @@ int main(int argc, char* argv[]) } } cExtra.ReadNEvents(theBoard, 1); - const std::vector<Event*>& cEvents = cExtra.GetEvents(theBoard); + const std::vector<Event*>& cEvents = cExtra.GetEvents(); uint32_t cN = 0; for(auto& cEvent: cEvents) { diff --git a/src/cmtest.cc b/src/cmtest.cc index 4d3fbbf1a5694a3d18b25c1cc9b91c0e4517c6a7..d42ef43dc87a143155402ecae33fb78d535d1ad2 100644 --- a/src/cmtest.cc +++ b/src/cmtest.cc @@ -119,10 +119,11 @@ int main(int argc, char* argv[]) cPedeNoise.writeObjects(); // Set Vcth to pedestal, or overload with manual setting - std::vector<double_t> cNoiseV; - ThresholdVisitor cVisitor(cTool.fReadoutChipInterface, 0); - HybridContainer* cFe = cPedeNoise.fDetectorContainer->at(0)->at(0)->at(0); - int i = 0; + std::vector<double> cNoiseV; + ThresholdVisitor cVisitor(cTool.fReadoutChipInterface, 0); + HybridContainer* cFe = cPedeNoise.fDetectorContainer->at(0)->at(0)->at(0); + int i = 0; + for(auto cCbc: *cFe) { uint16_t cPedestal = 0; // round (cPedeNoise.getPedestal (cCbc) ); diff --git a/src/d19c_test.cc b/src/d19c_test.cc index 6343d0b0b56fc81fd568d0e745bf0882e7d040bb..d3cd921dec7524d34a54f71f308776c4de7b7eb8 100644 --- a/src/d19c_test.cc +++ b/src/d19c_test.cc @@ -138,7 +138,7 @@ int main(int argc, char** argv) cTool.setSystemTestPulse(cTestPulseAmplitude, i, true, false); cTool.ReadNEvents(pBoard, 1); - const std::vector<Event*>& events = cTool.GetEvents(pBoard); + const std::vector<Event*>& events = cTool.GetEvents(); for(auto& ev: events) { LOG(INFO) << ">>> Event #" << cN++; @@ -175,7 +175,7 @@ int main(int argc, char** argv) while(cN < cNEventsToCollect) { cTool.ReadData(pBoard); - const std::vector<Event*>& events = cTool.GetEvents(pBoard); + const std::vector<Event*>& events = cTool.GetEvents(); for(auto& ev: events) { count++; @@ -294,7 +294,7 @@ int main(int argc, char** argv) else { cTool.ReadNEvents(pBoard, cNEventsToCollect); - const std::vector<Event*>& events = cTool.GetEvents(pBoard); + const std::vector<Event*>& events = cTool.GetEvents(); for(auto& ev: events) { for(auto cOpticalGroup: *pBoard) @@ -343,7 +343,7 @@ int main(int argc, char** argv) // if nothing else /* uint32_t cNEventsToCollect = ( cmd.foundOption ( "events" ) ) ? convertAnyInt ( cmd.optionValue ( "events" ).c_str() ) : 10000; cTool.ReadNEvents( pBoard, cNEventsToCollect ); const std::vector<Event*>& - events = cTool.GetEvents ( pBoard ); int cNevents=0; for( auto& cEvent : events ) + events = cTool.GetEvents(); int cNevents=0; for( auto& cEvent : events ) { LOG (INFO) << ">>> Event #" << cNevents ; LOG (INFO) << *cEvent; diff --git a/src/datatest.cc b/src/datatest.cc index 4adf19056de6f837914b544a64a4bd9dcaa1b391..dbb059875669bb277e77f1b5ab2858dffdc531f9 100644 --- a/src/datatest.cc +++ b/src/datatest.cc @@ -180,7 +180,7 @@ int main(int argc, char* argv[]) cSystemController.readFile(cReadVec, 10 * fPlaybackEventSize32); size_t cCalcEvents = cReadVec.size() / fPlaybackEventSize32; cSystemController.DecodeData(pBoard, cReadVec, cCalcEvents, pBoard->getBoardType()); - pEvents = &cSystemController.GetEvents(pBoard); + pEvents = &cSystemController.GetEvents(); } else { @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) if(cN + cPacketSize > pEventsperVcth) cSystemController.fBeBoardInterface->Stop(pBoard); - pEvents = &cSystemController.GetEvents(pBoard); + pEvents = &cSystemController.GetEvents(); } for(auto& ev: *pEvents) diff --git a/src/fpgaconfig.cc b/src/fpgaconfig.cc index 85d634c9a8ac6e9d8d1ce76d6b8e059479be2960..dd51a8fd7f03f0fe61c33246c1ee35a798bc7156 100644 --- a/src/fpgaconfig.cc +++ b/src/fpgaconfig.cc @@ -1,5 +1,7 @@ -#include <cstring> +#include <cstdlib> #include <inttypes.h> +#include <string> +#include <vector> #include "../HWDescription/BeBoard.h" #include "../HWDescription/Chip.h" @@ -17,7 +19,6 @@ using namespace Ph2_HwInterface; using namespace Ph2_System; using namespace CommandLineProcessing; -using namespace std; INITIALIZE_EASYLOGGINGPP @@ -35,7 +36,7 @@ class AcqVisitor : public HwInterfaceVisitor } }; -void verifyImageName(const string& strImage, const vector<string>& lstNames) +void verifyImageName(const std::string& strImage, const std::vector<std::string>& lstNames) { if(lstNames.empty()) { @@ -68,9 +69,14 @@ void verifyImageName(const string& strImage, const vector<string>& lstNames) int main(int argc, char* argv[]) { - std::string loggerConfigFile = std::getenv("PH2ACF_BASE_DIR"); - loggerConfigFile += "/settings/logger.conf"; - el::Configurations conf(loggerConfigFile); + auto* baseDirChar_p = std::getenv("PH2ACF_BASE_DIR"); + if(baseDirChar_p == nullptr) + { + LOG(ERROR) << "Error, the environment variable PH2ACF_BASE_DIR is not initialized (hint: source setup.sh)"; + exit(1); + } + + el::Configurations conf(std::string(baseDirChar_p) + "/settings/logger.conf"); el::Loggers::reconfigureAllLoggers(conf); SystemController cSystemController; @@ -112,10 +118,10 @@ int main(int argc, char* argv[]) std::string cHWFile = (cmd.foundOption("config")) ? cmd.optionValue("config") : "settings/HWDescription_2CBC.xml"; std::ostringstream cStr; cSystemController.InitializeHw(cHWFile, cStr); - BeBoard* pBoard = cSystemController.fDetectorContainer->at(0); - vector<string> lstNames = cSystemController.fBeBoardInterface->getFpgaConfigList(pBoard); - std::string cFWFile; - string strImage("1"); + BeBoard* pBoard = cSystemController.fDetectorContainer->at(0); + std::vector<std::string> lstNames = cSystemController.fBeBoardInterface->getFpgaConfigList(pBoard); + std::string cFWFile; + std::string strImage("1"); if(cmd.foundOption("list")) { @@ -194,7 +200,7 @@ int main(int argc, char* argv[]) } else { - LOG(INFO) << progress << "% " << cSystemController.fBeBoardInterface->GetConfiguringFpga(pBoard)->getProgressString() << " \r" << flush; + LOG(INFO) << progress << "% " << cSystemController.fBeBoardInterface->GetConfiguringFpga(pBoard)->getProgressString() << " \r" << std::flush; sleep(1); } } diff --git a/src/miniDAQ.cc b/src/miniDAQ.cc index 98b8236bcfebdfd6183e77e64079c9f88d3c7338..8c12af5440506460d81ec2df6f05091ecb8dc886 100644 --- a/src/miniDAQ.cc +++ b/src/miniDAQ.cc @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) if(cN + cPacketSize >= pEventsperVcth) cTool.fBeBoardInterface->Stop(pBoard); - const std::vector<Event*>& events = cTool.GetEvents(pBoard); + const std::vector<Event*>& events = cTool.GetEvents(); std::vector<DQMEvent*> cDQMEvents; for(auto& ev: events) diff --git a/src/templateCMSITminiDAQ.cc b/src/templateCMSITminiDAQ.cc new file mode 100644 index 0000000000000000000000000000000000000000..7f053ffe8f71c7b8fe8a09682d873ba483754640 --- /dev/null +++ b/src/templateCMSITminiDAQ.cc @@ -0,0 +1,145 @@ +/*! + \file templateCMSITminiDAQ.cc + \brief Template file to be used as example for a Mini DAQ to test RD53 readout chip + \author Mauro DINARDO + \version 1.0 + \date 28/06/18 + Support: email to mauro.dinardo@cern.ch +*/ + +#include "../DQMUtils/DQMInterface.h" +#include "../System/SystemController.h" +#include "../Utils/MiddlewareInterface.h" +#include "../Utils/RD53Shared.h" +#include "../Utils/argvparser.h" + +#include "../tools/RD53ClockDelay.h" +#include "../tools/RD53Gain.h" +#include "../tools/RD53GainOptimization.h" +#include "../tools/RD53InjectionDelay.h" +#include "../tools/RD53Latency.h" +#include "../tools/RD53Physics.h" +#include "../tools/RD53PixelAlive.h" +#include "../tools/RD53SCurve.h" +#include "../tools/RD53ThrAdjustment.h" +#include "../tools/RD53ThrEqualization.h" +#include "../tools/RD53ThrMinimization.h" + +#ifdef __USE_ROOT__ +#include "TApplication.h" +#endif + +#ifdef __EUDAQ__ +#include "../tools/RD53eudaqProducer.h" +#endif + +// ################## +// # Default values # +// ################## +#define ARBITRARYDELAY 2e6 // [us] + +INITIALIZE_EASYLOGGINGPP + +using namespace Ph2_System; +using namespace Ph2_HwDescription; +using namespace Ph2_HwInterface; + +void readBinaryData(const std::string& binaryFile, SystemController& mySysCntr, std::vector<RD53FWInterface::Event>& decodedEvents) +{ + const unsigned int wordDataSize = 32; + unsigned int errors = 0; + std::vector<uint32_t> data; + + LOG(INFO) << BOLDMAGENTA << "@@@ Decoding binary data file @@@" << RESET; + mySysCntr.addFileHandler(binaryFile, 'r'); + LOG(INFO) << BOLDBLUE << "\t--> Data are being readout from binary file" << RESET; + mySysCntr.readFile(data, 0); + + RD53FWInterface::DecodeEventsMultiThreads(data, decodedEvents); + LOG(INFO) << GREEN << "Total number of events in binary file: " << BOLDYELLOW << decodedEvents.size() << RESET; + + for(auto i = 0u; i < decodedEvents.size(); i++) + if(RD53FWInterface::EvtErrorHandler(decodedEvents[i].evtStatus) == false) + { + LOG(ERROR) << BOLDBLUE << "\t--> Corrupted event n. " << BOLDYELLOW << i << RESET; + errors++; + RD53FWInterface::PrintEvents({decodedEvents[i]}); + } + + LOG(INFO) << GREEN << "Corrupted events: " << BOLDYELLOW << std::setprecision(3) << errors << " (" << 1. * errors / decodedEvents.size() * 100. << "%)" << std::setprecision(-1) << RESET; + int avgEventSize = data.size() / decodedEvents.size(); + LOG(INFO) << GREEN << "Average event size is " << BOLDYELLOW << avgEventSize * wordDataSize << RESET << GREEN << " bits over " << BOLDYELLOW << decodedEvents.size() << RESET << GREEN << " events" + << RESET; + mySysCntr.closeFileHandler(); +} + +int main(int argc, char** argv) +{ + const std::string configFile = "CMSIT.xml"; + const std::string binaryFile = "binaryFile.raw"; + const std::string fileName = "OutputRootFileName"; + const int runNumber = 0; + const bool doReset = false; + const bool doReadBinary = false; + + SystemController mySysCntr; + std::stringstream outp; + mySysCntr.InitializeHw(configFile, outp, true, false); + mySysCntr.InitializeSettings(configFile, outp); + + // ################## + // # Reset hardware # + // ################## + if(doReset == true) + { + static_cast<RD53FWInterface*>(mySysCntr.fBeBoardFWMap[mySysCntr.fDetectorContainer->at(0)->getId()])->ResetSequence(); + return EXIT_SUCCESS; + } + + if(doReadBinary == true) + { + // ###################################### + // # Read binary file and decode events # + // ###################################### + readBinaryData(binaryFile, mySysCntr, RD53FWInterface::decodedEvents); + RD53FWInterface::PrintEvents(RD53FWInterface::decodedEvents); + } + else + { + // ####################### + // # Initialize Hardware # + // ####################### + mySysCntr.Configure(configFile); + } + + // ################## + // # Run PixelAlive # + // ################## + // PixelAlive pa; + // pa.Inherit(&mySysCntr); + // pa.localConfigure(fileName, runNumber); + // pa.run(); + // pa.analyze(); + // pa.draw(); + + // ############### + // # Run Physics # + // ############### + Physics ph; + ph.Inherit(&mySysCntr); + if(doReadBinary == false) + { + ph.localConfigure(fileName, -1); + ph.Start(runNumber); + usleep(ARBITRARYDELAY); + ph.Stop(); + } + else + { + ph.localConfigure(fileName, runNumber); + ph.analyze(true); + ph.draw(); + } + + return EXIT_SUCCESS; +} diff --git a/tools/BackEndAlignment.cc b/tools/BackEndAlignment.cc index e21ee5d28a1d9123ae0379093311e58a97a111d4..573cb78b227329268af37260bf97509204ce186a 100644 --- a/tools/BackEndAlignment.cc +++ b/tools/BackEndAlignment.cc @@ -80,37 +80,33 @@ bool BackEndAlignment::PSAlignment(BeBoard* pBoard) { for(auto cHybrid: *cOpticalReadout) { - for(auto cChip: *cHybrid) + for(auto cChip: *cHybrid) { - ReadoutChip* cReadoutChip = static_cast<ReadoutChip*>(cChip); - if (cChip->getFrontEndType() == FrontEndType::SSA) - { + ReadoutChip* cReadoutChip = static_cast<ReadoutChip*>(cChip); + if(cChip->getFrontEndType() == FrontEndType::SSA) + { LOG(INFO) << GREEN << "SSA Alignment" << RESET; - ReadoutChip* cReadoutChip = static_cast<ReadoutChip*>(cChip); + ReadoutChip* cReadoutChip = static_cast<ReadoutChip*>(cChip); std::vector<std::string> cRegNames{"SLVS_pad_current", "ReadoutMode"}; std::vector<uint8_t> cOriginalValues; std::vector<uint8_t> cRegValues{0x7, 2}; - for(size_t cIndex = 0; cIndex < 2; cIndex++) - { - fReadoutChipInterface->WriteChipReg(cReadoutChip, cRegNames[cIndex], cRegValues[cIndex]); - } + for(size_t cIndex = 0; cIndex < 2; cIndex++) { fReadoutChipInterface->WriteChipReg(cReadoutChip, cRegNames[cIndex], cRegValues[cIndex]); } uint8_t cAlignmentPattern = 0x80; for(uint8_t cLineId = 0; cLineId < 8; cLineId++) { char cBuffer[11]; - sprintf(cBuffer, "OutPattern%d", cLineId ); + sprintf(cBuffer, "OutPattern%d", cLineId); std::string cRegName = (cLineId == 8) ? "OutPattern7/FIFOconfig" : std::string(cBuffer, sizeof(cBuffer)); fReadoutChipInterface->WriteChipReg(cReadoutChip, cRegName, cAlignmentPattern); - cTuned = cTuned && static_cast<D19cFWInterface*>(fBeBoardInterface->getFirmwareInterface())->PhaseTuning(pBoard, cHybrid->getId(), cChip->getId(), cLineId, cAlignmentPattern, 8); + cTuned = + cTuned && static_cast<D19cFWInterface*>(fBeBoardInterface->getFirmwareInterface())->PhaseTuning(pBoard, cHybrid->getId(), cChip->getId(), cLineId, cAlignmentPattern, 8); } for(size_t cIndex = 0; cIndex < 2; cIndex++) { fReadoutChipInterface->WriteChipReg(cReadoutChip, cRegNames[cIndex], cOriginalValues[cIndex]); } - } - - + } - if (cChip->getFrontEndType() == FrontEndType::MPA) - { + if(cChip->getFrontEndType() == FrontEndType::MPA) + { LOG(INFO) << GREEN << "MPA Alignment" << RESET; std::vector<std::string> cRegNames{"ReadoutMode", "ECM", "LFSR_data"}; std::vector<uint8_t> cOriginalValues; @@ -123,18 +119,20 @@ bool BackEndAlignment::PSAlignment(BeBoard* pBoard) } for(uint8_t cLineId = 0; cLineId < 8; cLineId++) - { cTuned = cTuned && static_cast<D19cFWInterface*>(fBeBoardInterface->getFirmwareInterface())->PhaseTuning(pBoard, cHybrid->getId(), cChip->getId(), cLineId, cAlignmentPattern, 8); } + { + cTuned = + cTuned && static_cast<D19cFWInterface*>(fBeBoardInterface->getFirmwareInterface())->PhaseTuning(pBoard, cHybrid->getId(), cChip->getId(), cLineId, cAlignmentPattern, 8); + } for(size_t cIndex = 0; cIndex < 3; cIndex++) { fReadoutChipInterface->WriteChipReg(cReadoutChip, cRegNames[cIndex], cOriginalValues[cIndex]); }; - - } - break; + } + break; } } } - LOG(INFO) << GREEN << "PS Phase tuning finished succesfully" << RESET; - return cTuned; + LOG(INFO) << GREEN << "PS Phase tuning finished succesfully" << RESET; + return cTuned; } bool BackEndAlignment::CICAlignment(BeBoard* pBoard) diff --git a/tools/CMTester.cc b/tools/CMTester.cc index 5ea2b6f7432e278fdb1646437f994d65b3410683..8591c5090d350d964d2667ca08f7a81a07dc105b 100644 --- a/tools/CMTester.cc +++ b/tools/CMTester.cc @@ -237,7 +237,7 @@ void CMTester::ScanNoiseChannels() //{ BeBoard* theBoard = static_cast<BeBoard*>(pBoard); ReadNEvents(theBoard, cTotalEvents); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) @@ -340,7 +340,7 @@ void CMTester::TakeData() // Run( theBoard, cNthAcq ); // ReadData (theBoard); ReadNEvents(theBoard, fNevents); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition diff --git a/tools/CalibrationExample.cc b/tools/CalibrationExample.cc index da2b4438fd6f34f377c5fff53653a19922f911d8..907f83e0ae8dcf6a798a4707225fb87b09d53eeb 100644 --- a/tools/CalibrationExample.cc +++ b/tools/CalibrationExample.cc @@ -40,7 +40,7 @@ void CalibrationExample::runCalibrationExample(void) ReadNEvents(theBeBoard, fEventsPerPoint); // Get the event vector (as it was in the past) - const std::vector<Event*>& eventVector = GetEvents(theBeBoard); + const std::vector<Event*>& eventVector = GetEvents(); for(auto& event: eventVector) // for on events - begin { diff --git a/tools/DataChecker.cc b/tools/DataChecker.cc index 9977b0f4dd4f19e608ef8c3c3a3a290808334e27..b752f4d96bedd1eae1cb8e2665204f47f3d01b38 100644 --- a/tools/DataChecker.cc +++ b/tools/DataChecker.cc @@ -281,7 +281,7 @@ void DataChecker::matchEvents(BeBoard* pBoard, std::vector<uint8_t> pChipIds, st auto& cThisHitCheckContainer = fHitCheckContainer.at(pBoard->getIndex()); auto& cThisStubCheckContainer = fStubCheckContainer.at(pBoard->getIndex()); - const std::vector<Event*>& cEvents = this->GetEvents(pBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(DEBUG) << BOLDMAGENTA << "Read back " << +cEvents.size() << " events from board." << RESET; for(auto cOpticalGroup: *pBoard) @@ -483,7 +483,7 @@ void DataChecker::AsyncTest() BeBoard* theBoard = static_cast<BeBoard*>(cBoard); LOG(INFO) << BOLDRED << "Reading counters .. " << RESET; this->ReadNEvents(theBoard, this->findValueInSettings("Nevents")); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *cBoard) { for(auto cHybrid: *cOpticalGroup) @@ -500,7 +500,7 @@ void DataChecker::AsyncTest() } LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadNEvents" << RESET; } - // const std::vector<Event*>& cEvents = this->GetEvents ( theBoard ); + // const std::vector<Event*>& cEvents = this->GetEvents(); } LOG(INFO) << BOLDBLUE << "Done!" << RESET; } @@ -538,7 +538,7 @@ void DataChecker::ReadDataTest() // }while( std::cin.get()!='\n'); LOG(INFO) << BOLDRED << "Reading data .. " << RESET; this->ReadData(theBoard, true); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; uint32_t cN = 0; @@ -590,7 +590,7 @@ void DataChecker::WriteSlinkTest(std::string pDAQFileName) BeBoard* cBeBoard = static_cast<BeBoard*>(cBoard); this->ReadNEvents(cBeBoard, cNevents); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; uint32_t cN = 0; for(auto& cEvent: cEvents) @@ -627,7 +627,7 @@ void DataChecker::CollectEvents() { int cEventsToRead = (cBurst == (cNBursts - 1)) ? (cNevents % cMaxNevents) : cMaxNevents; this->ReadNEvents(cBeBoard, cEventsToRead); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; cNrecordedEvents += cEvents.size(); } @@ -657,7 +657,7 @@ void DataChecker::ReadNeventsTest() } BeBoard* cBeBoard = static_cast<BeBoard*>(cBoard); this->ReadNEvents(cBeBoard, 1); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; uint32_t cN = 0; @@ -873,7 +873,7 @@ void DataChecker::TestPulse(std::vector<uint8_t> pChipIds) fBeBoardInterface->Stop(theBoard); // this->ReadNEvents ( theBoard , cEventsPerPoint); this->ReadData(theBoard, true); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); // matching for(auto cOpticalGroup: *cBoard) { @@ -1029,7 +1029,7 @@ void DataChecker::TestPulse(std::vector<uint8_t> pChipIds) // //if( cResync) // // fBeBoardInterface->ChipReSync ( cBoard ); // this->ReadNEvents ( cBoard , cEventsPerPoint); - // const std::vector<Event*>& cEvents = this->GetEvents ( cBoard ); + // const std::vector<Event*>& cEvents = this->GetEvents(); // // matching // for (auto& cHybrid : cBoard->fHybridVector) // { @@ -1215,7 +1215,7 @@ void DataChecker::TestPulse(std::vector<uint8_t> pChipIds) // // if( cResync) // // fBeBoardInterface->ChipReSync ( cBoard ); // // this->ReadNEvents ( cBoard , cEventsPerPoint); - // // const std::vector<Event*>& cEvents = this->GetEvents ( cBoard ); + // // const std::vector<Event*>& cEvents = this->GetEvents(); // // // matching // // for (auto& cHybrid : cBoard->fHybridVector) // // { @@ -1851,7 +1851,7 @@ void DataChecker::StubCheck(std::vector<uint8_t> pChipIds) LOG(INFO) << BOLDBLUE << "\t..L1A latency set to " << +cDelay << " stub latency set to " << +cStubDelay << " so delay is " << +(cDelay - cStubDelay) << RESET; this->ReadNEvents(cBeBoard, 5); - const std::vector<Event*>& cEventsWithStubs = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEventsWithStubs = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEventsWithStubs.size() << " events read back from FC7 with ReadData" << RESET; for(auto& cEvent: cEventsWithStubs) { @@ -1960,7 +1960,7 @@ void DataChecker::StubCheckWNoise(std::vector<uint8_t> pChipIds) LOG(INFO) << BOLDBLUE << "Stub latency set to " << +cStubDelay << RESET; this->ReadNEvents(cBeBoard, 5); - const std::vector<Event*>& cEventsWithStubs = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEventsWithStubs = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEventsWithStubs.size() << " events read back from FC7 with ReadData" << RESET; for(auto& cEvent: cEventsWithStubs) { @@ -2144,7 +2144,7 @@ void DataChecker::HitCheck2S(BeBoard* pBoard) // read events this->ReadNEvents(pBoard, cEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(pBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(DEBUG) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; // check for matches for(auto cOpticalGroup: *pBoard) @@ -2315,7 +2315,7 @@ void DataChecker::ClusterCheck(std::vector<uint8_t> pChannels) fReadoutChipInterface->maskChannelsGroup(cChip, &fCBCMask); } this->ReadNEvents(cBoard, cNevents); - const std::vector<Event*>& cEvents = this->GetEvents(cBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; for(auto cChip: *cHybrid) { diff --git a/tools/ExtraChecks.cc b/tools/ExtraChecks.cc index a36dff56be842964918f9909d3efcf5f803fac23..94b4f313946dcbf1314119885b49e8211ac6232a 100644 --- a/tools/ExtraChecks.cc +++ b/tools/ExtraChecks.cc @@ -431,7 +431,7 @@ void ExtraChecks::Evaluate(int pSigma, uint16_t pTriggerRate, bool pDisableStubs { // fBeBoardInterface->ChipReSync ( cBoard ); this->ReadNEvents(theBoard, cNevents); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); if(cIteration == 0 && cStepCount % 10 == 0) { LOG(INFO) << BOLDBLUE << "Threshold set to " << cVcth << "...\tIteration " << +cIteration << " : " << +cEvents.size() << " events read back from fc7." << RESET; } @@ -618,7 +618,7 @@ void ExtraChecks::OccupancyCheck(uint16_t pTriggerRate, bool pDisableStubs) { LOG(INFO) << BOLDBLUE << "Iteration : " << +cIteration << RESET; this->ReadNEvents(theBoard, cNevents); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *cBoard) { for(auto cFe: *cOpticalGroup) @@ -684,7 +684,7 @@ void ExtraChecks::ExternalTriggers(uint16_t pNconsecutive, const std::string& pS LOG(INFO) << BOLDBLUE << "Stopping triggers..." << RESET; this->ReadData(theBoard, true); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; for(auto cOpticalGroup: *cBoard) { @@ -749,7 +749,7 @@ void ExtraChecks::ConsecutiveTriggers(uint8_t pNconsecutive) // fBeBoardInterface->Stop(theBoard); // this->ReadData( theBoard , true); // this->ReadNEvents ( theBoard , cNevents ); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDBLUE << +cEvents.size() << " events read back from FC7 with ReadData" << RESET; for(auto cOpticalGroup: *cBoard) { @@ -1059,7 +1059,7 @@ void ExtraChecks::DataCheckTP(std::vector<uint8_t> pChipIds, uint8_t pTPamplitud // fBeBoardInterface->ChipReSync ( theBoard ); this->ReadNEvents(theBoard, cEventsPerAttempt); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *cBoard) { for(auto cFe: *cOpticalGroup) @@ -1363,7 +1363,7 @@ void ExtraChecks::QuickStubCheck(std::vector<uint8_t> pChipIds, uint16_t pTrigge // why do I need this? // this->setSameDacBeBoard(theBoard, "TriggerLatency", cDelay); this->ReadNEvents(theBoard, cEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *cBoard) { for(auto cFe: *cOpticalGroup) @@ -1533,7 +1533,7 @@ void ExtraChecks::DataCheck(std::vector<uint8_t> pChipIds, uint16_t pTriggerRate } // read N events this->ReadNEvents(theBoard, cEventsPerPoint); //*(1+cTriggerMultiplicity) ); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); LOG(INFO) << BOLDMAGENTA << "Read back " << +cEvents.size() << " events from board." << RESET; for(auto cEvent: cEvents) { @@ -1783,7 +1783,7 @@ void ExtraChecks::StubCheck(uint8_t pChipId, bool pUseNoise, uint8_t pTestPulseA // set DAC .. read events this->setSameDacBeBoard(theBoard, "VCth", cVcth); this->ReadNEvents(theBoard, cEventsPerAttempt); - // const std::vector<Event*>& cEvents = this->GetEvents ( theBoard ); + // const std::vector<Event*>& cEvents = this->GetEvents(); /*for (auto& cFe : cBoard->fModuleVector) { for (auto& cChip : cFe->fReadoutChipVector) @@ -1965,7 +1965,7 @@ void ExtraChecks::FindShorts(uint16_t pThreshold, uint16_t pTPamplitude) std::bitset<NCHANNELS> cBitset = std::bitset<NCHANNELS>(static_cast<const ChannelGroup<NCHANNELS>*>(cGroup)->getBitset()); LOG(INFO) << "Injecting charge into front-end object using test capacitor " << +cTestGroup << " : L1A latency set to " << +cDelay << RESET; this->ReadNEvents(theBoard, cEventsPerAttempt); - const std::vector<Event*>& cEvents = this->GetEvents(theBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *cBoard) { auto cOpticalGroupShorts = cThisShortsContainer->at(cOpticalGroup->getIndex()); diff --git a/tools/HybridTester.cc b/tools/HybridTester.cc index e95c0391403b52223aacd02ec479fb8682bcb944..d665417da401d989c50ced3105468b31d4d47b48 100644 --- a/tools/HybridTester.cc +++ b/tools/HybridTester.cc @@ -328,7 +328,7 @@ void HybridTester::ScanThresholds() { // Run( theBoard, cNthAcq ); ReadData(theBoard); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) @@ -439,7 +439,7 @@ void HybridTester::ScanThreshold() { // Run( theBoard, cNthAcq ); ReadData(theBoard); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) @@ -973,7 +973,7 @@ void HybridTester::FindShorts() // Run( theBoard, cNthAcq ); ReadData(theBoard); // ReadNEvents ( theBoard, cNthAcq ); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) @@ -1068,7 +1068,7 @@ void HybridTester::Measure() // Run( theBoard, cNthAcq ); ReadData(theBoard); // ReadNEvents ( theBoard, cNthAcq ); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) @@ -1223,7 +1223,7 @@ void HybridTester::AntennaScan(uint8_t pDigiPotentiometer) // Run( theBoard, cNthAcq ); ReadData(theBoard); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: events) diff --git a/tools/LatencyScan.cc b/tools/LatencyScan.cc index 661c84fa960ee3473b276136168fa12d4e8196dd..11e269d16ad159059149c9dc8828fb4e6b2f4cad 100644 --- a/tools/LatencyScan.cc +++ b/tools/LatencyScan.cc @@ -93,7 +93,7 @@ void LatencyScan::MeasureTriggerTDC() ReadNEvents(theBoard, fNevents); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); for(auto& cEvent: events) { @@ -149,7 +149,7 @@ std::map<HybridContainer*, uint8_t> LatencyScan::ScanLatency(uint8_t pStartLaten cVisitor.setLatency(cLat); this->accept(cVisitor); ReadNEvents(theBoard, fNevents); - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); countHitsLat(theBoard, events, "hybrid_latency", cLat, pStartLatency); // done counting hits for all FE's, now update the Histograms updateHists("hybrid_latency", false); @@ -165,15 +165,13 @@ std::map<HybridContainer*, uint8_t> LatencyScan::ScanLatency(uint8_t pStartLaten for(auto cFe: fHybridHistMap) { - TH1F* cTmpHist = dynamic_cast<TH1F*>(getHist(cFe.first, "hybrid_latency")); - uint8_t cHitLatency = static_cast<uint8_t>(cTmpHist->GetXaxis()->GetBinUpEdge(cTmpHist->GetMaximumBin())); + TH1F* cTmpHist = dynamic_cast<TH1F*>(getHist(cFe.first, "hybrid_latency")); + uint8_t cHitLatency = static_cast<uint8_t>(cTmpHist->GetXaxis()->GetBinUpEdge(cTmpHist->GetMaximumBin())); cLatencyMap[cFe.first] = cHitLatency; LOG(INFO) << "Hit Latency FE " << +cFe.first->getId() << ": " << +cHitLatency << " clock cycles!"; } - - return cLatencyMap; } @@ -201,24 +199,22 @@ void LatencyScan::StubLatencyScan(uint8_t pStartLatency, uint8_t pLatencyRange) bool cMaskOthers = (cCic != NULL) ? true : false; for(auto cChip: *cHybrid) { - - - if ((cChip->getFrontEndType() == FrontEndType::CBC3)) + if((cChip->getFrontEndType() == FrontEndType::CBC3)) + { + auto cReadoutChipInterface = static_cast<CbcInterface*>(fReadoutChipInterface); + if(cMaskOthers && cChip->getId() == 0) { - auto cReadoutChipInterface = static_cast<CbcInterface*>(fReadoutChipInterface); - if(cMaskOthers && cChip->getId() == 0) - { - if(cChip->getFrontEndType() == FrontEndType::CBC3) - { - uint8_t cFirstSeed = static_cast<uint8_t>(2 * (1 + std::floor((cTPgroup * 2 + 16 * 0) / 2.))); // in half strips - cReadoutChipInterface->injectStubs(cChip, {cFirstSeed}, {0}, false); - } - } - else if(cMaskOthers && cChip->getFrontEndType() == FrontEndType::CBC3) + if(cChip->getFrontEndType() == FrontEndType::CBC3) { - fReadoutChipInterface->WriteChipReg(cChip, "TestPulse", (int)0); + uint8_t cFirstSeed = static_cast<uint8_t>(2 * (1 + std::floor((cTPgroup * 2 + 16 * 0) / 2.))); // in half strips + cReadoutChipInterface->injectStubs(cChip, {cFirstSeed}, {0}, false); } } + else if(cMaskOthers && cChip->getFrontEndType() == FrontEndType::CBC3) + { + fReadoutChipInterface->WriteChipReg(cChip, "TestPulse", (int)0); + } + } } // roc } // hybrid @@ -244,7 +240,7 @@ void LatencyScan::StubLatencyScan(uint8_t pStartLatency, uint8_t pLatencyRange) for(auto cReg: getStubLatencyName(cBeBoard->getBoardType())) fBeBoardInterface->WriteBoardReg(cBeBoard, cReg, cLat); this->ReadNEvents(cBeBoard, this->findValueInSettings("Nevents")); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: cEvents) { @@ -312,8 +308,8 @@ void LatencyScan::StubLatencyScan(uint8_t pStartLatency, uint8_t pLatencyRange) } else if(cChip->getFrontEndType() == FrontEndType::MPA) { - auto cHits = cEvent->GetHits(cHybrid->getId(), cChip->getId()); - auto cStubs = cEvent->StubVector(cHybrid->getId(), cChip->getId()); + auto cHits = cEvent->GetHits(cHybrid->getId(), cChip->getId()); + auto cStubs = cEvent->StubVector(cHybrid->getId(), cChip->getId()); cNStubs += cStubs.size(); } } // chip @@ -384,7 +380,7 @@ std::map<HybridContainer*, uint8_t> LatencyScan::ScanStubLatency(uint8_t pStartL // here set the stub latency for(auto cReg: getStubLatencyName(cBeBoard->getBoardType())) fBeBoardInterface->WriteBoardReg(cBeBoard, cReg, cLat); this->ReadNEvents(cBeBoard, this->findValueInSettings("Nevents")); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); // Loop over Events from this Acquisition for(auto& cEvent: cEvents) { @@ -459,7 +455,7 @@ void LatencyScan::ScanLatency2D(uint8_t pStartLatency, uint8_t pLatencyRange) continue; } - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); cNevents += events.size(); for(auto cOpticalGroup: *pBoard) { @@ -571,9 +567,12 @@ int LatencyScan::countHitsLat(BeBoard* pBoard, const std::vector<Event*> pEventV for(auto cCbc: *cFe) { // now loop the channels for this particular event and increment a counter - if (cCbc->getFrontEndType() == FrontEndType::MPA) cHitCounter += static_cast<D19cMPAEvent*>(cEvent)->GetNPixelClusters(cFe->getId(), cCbc->getId()); - else if (cCbc->getFrontEndType() == FrontEndType::SSA) cHitCounter += static_cast<D19cMPAEvent*>(cEvent)->GetNStripClusters(cFe->getId(), static_cast<SSA*> (cCbc)->getPartid()); - else cHitCounter += cEvent->GetNHits(cFe->getId(), cCbc->getId()); + if(cCbc->getFrontEndType() == FrontEndType::MPA) + cHitCounter += static_cast<D19cMPAEvent*>(cEvent)->GetNPixelClusters(cFe->getId(), cCbc->getId()); + else if(cCbc->getFrontEndType() == FrontEndType::SSA) + cHitCounter += static_cast<D19cMPAEvent*>(cEvent)->GetNStripClusters(cFe->getId(), static_cast<SSA*>(cCbc)->getPartid()); + else + cHitCounter += cEvent->GetNHits(cFe->getId(), cCbc->getId()); } // now I have the number of hits in this particular event for all CBCs and the TDC value @@ -607,7 +606,6 @@ int LatencyScan::countStubs(Hybrid* pFe, const Event* pEvent, std::string pHistN for(auto cCbc: *pFe) { if(pEvent->StubBit(pFe->getId(), cCbc->getId())) cStubCounter += pEvent->StubVector(pFe->getId(), cCbc->getId()).size(); - } int cBin = cTmpHist->FindBin(pParameter); float cBinContent = cTmpHist->GetBinContent(cBin); diff --git a/tools/LatencyScan.h b/tools/LatencyScan.h index 3fc94ed6965ed25735ce306a8412f905e472532b..9d449aa7c12791c1ffb6742bba1118c328651947 100644 --- a/tools/LatencyScan.h +++ b/tools/LatencyScan.h @@ -69,10 +69,10 @@ class LatencyScan : public Tool // Members uint32_t fNevents; // uint32_t fInitialThreshold; - uint32_t fHoleMode; - uint32_t fNCbc; - uint8_t fTestPulseAmplitude; - uint32_t trigSource; + uint32_t fHoleMode; + uint32_t fNCbc; + uint8_t fTestPulseAmplitude; + uint32_t trigSource; const uint32_t fTDCBins = 8; int convertLatencyPhase(uint32_t pStartLatency, uint32_t cLatency, uint32_t cPhase) diff --git a/tools/OpenFinder.cc b/tools/OpenFinder.cc index ac6b151a83bb46aaa416e11b2a5615a1a44b4a04..8da5901c7716a31e3b22ffe5e6ac1a8cf5142abe 100644 --- a/tools/OpenFinder.cc +++ b/tools/OpenFinder.cc @@ -162,7 +162,7 @@ bool OpenFinder::FindLatency(BeBoard* pBoard, std::vector<uint16_t> pLatencies) fBeBoardInterface->ChipReSync(cBeBoard); // NEED THIS! ?? LOG(DEBUG) << BOLDBLUE << "L1A latency set to " << +cLatency << RESET; this->ReadNEvents(cBeBoard, fEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cOpticalGroup: *pBoard) { auto& cSummaryThisOpticalGroup = cSummaryThisBoard->at(cOpticalGroup->getIndex()); @@ -235,7 +235,7 @@ void OpenFinder::CountOpens(BeBoard* pBoard) auto cSearchAntennaMap = cAntennaMap.find(fAntennaPosition); // scan latency and record optimal latency this->ReadNEvents(cBeBoard, fEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); auto& cOpens = fOpens.at(pBoard->getIndex()); auto& cSummaryThisBoard = cMeasurement.at(pBoard->getIndex()); @@ -473,7 +473,7 @@ void OpenFinder::FindOpensPS() this->ReadNEvents(cBeBoard, fParameters.nTriggers); std::stringstream outp; - const std::vector<Event*>& cEvents = this->GetEvents(cBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); bool cOpensFound = false; for(auto cEvent: cEvents) { diff --git a/tools/PulseShape.cc b/tools/PulseShape.cc index a4e76972f1f64c4d3881956f94a90dd5a151947f..819e851925338714360efdf6745418275a8083bf 100644 --- a/tools/PulseShape.cc +++ b/tools/PulseShape.cc @@ -152,7 +152,7 @@ void PulseShape::ScanVcth(uint32_t pDelay, int cLow) // LOG(INFO) << "Reading N Events"; ReadNEvents(theBoard, fNevents); // LOG(INFO) << "End Reading N Events"; - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); if(events.empty()) LOG(INFO) << " EMPTY EVENT VECTOR !!!"; // LOG (INFO) <<"events size, VCTH value " << events.size()<< " "<< (uint16_t) cVcth; // int iii=0; diff --git a/tools/RD53ClockDelay.cc b/tools/RD53ClockDelay.cc index 2f824d1028b291a4d9fdec33d9ce4906458c0182..c8123458b9ee573bd9f998bfd2fbae945c3c8376 100644 --- a/tools/RD53ClockDelay.cc +++ b/tools/RD53ClockDelay.cc @@ -18,6 +18,7 @@ void ClockDelay::ConfigureCalibration() // # Initialize sub-calibration # // ############################## PixelAlive::ConfigureCalibration(); + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -250,10 +251,10 @@ void ClockDelay::analyze() } } - LOG(INFO) << GREEN << "Best delay for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" - << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << regVal << RESET << GREEN << " (1.5625 ns) computed over two bx" << RESET; - LOG(INFO) << GREEN << "New delay dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() - << "/" << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << (regVal & maxDelay) << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> Best clock delay for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << regVal << BOLDMAGENTA << " (1.5625 ns) computed over two bx <<<" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> New clock delay dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << (regVal & maxDelay) << BOLDMAGENTA << " <<<" << RESET; // #################################################### // # Fill delay container and download new DAC values # @@ -265,8 +266,8 @@ void ClockDelay::analyze() auto latency = this->fReadoutChipInterface->ReadChipReg(static_cast<RD53*>(cChip), "LATENCY_CONFIG"); if(regVal / (maxDelay + 1) == 0) latency--; this->fReadoutChipInterface->WriteChipReg(static_cast<RD53*>(cChip), "LATENCY_CONFIG", latency, true); - LOG(INFO) << GREEN << "New latency dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() - << "/" << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << latency << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> New latency dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << latency << BOLDMAGENTA << " <<<" << RESET; } } @@ -287,7 +288,7 @@ void ClockDelay::scanDac(const std::string& regName, const std::vector<uint16_t> // ########################### // # Download new DAC values # // ########################### - LOG(INFO) << BOLDMAGENTA << ">>> Register value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) @@ -353,7 +354,7 @@ void ClockDelay::chipErrorReport() void ClockDelay::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53ClockDelay.h b/tools/RD53ClockDelay.h index 4047574bfefe943653d5f1c31788283c9edbcb0e..38bd04616ce662d2c07006e884d90cf4fdb8ea5a 100644 --- a/tools/RD53ClockDelay.h +++ b/tools/RD53ClockDelay.h @@ -32,8 +32,12 @@ class ClockDelay : public PixelAlive void run(); void draw(); void analyze(); - size_t getNumberIterations() { return PixelAlive::getNumberIterations() * (stopValue - startValue); } - void saveChipRegisters(int currentRun); + size_t getNumberIterations() + { + return PixelAlive::getNumberIterations() * + (stopValue - startValue + 1 <= RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1 ? stopValue - startValue + 1 : RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1); + } + void saveChipRegisters(int currentRun); #ifdef __USE_ROOT__ ClockDelayHistograms* histos; diff --git a/tools/RD53Gain.cc b/tools/RD53Gain.cc index ffdbc3ee5a4184a9bc3104a36309bffe79c48838..082f9085d08d94fc43f3b27ba87f658a7b69cf4a 100644 --- a/tools/RD53Gain.cc +++ b/tools/RD53Gain.cc @@ -151,10 +151,7 @@ void Gain::run() // ########################## // # Set new VCAL_MED value # // ########################## - for(const auto cBoard: *fDetectorContainer) - for(const auto cOpticalGroup: *cBoard) - for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) this->fReadoutChipInterface->WriteChipReg(static_cast<RD53*>(cChip), "VCAL_MED", offset, true); + for(const auto cBoard: *fDetectorContainer) this->fReadoutChipInterface->WriteBoardBroadcastChipReg(cBoard, "VCAL_MED", offset); for(auto container: detectorContainerVector) theRecyclingBin.free(container); detectorContainerVector.clear(); @@ -363,6 +360,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; @@ -472,7 +470,7 @@ void Gain::chipErrorReport() void Gain::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53GainOptimization.cc b/tools/RD53GainOptimization.cc index 88e4f97d9b5cc581f1681ed1660f5c6a30390d5b..e686e2664e32fae28e2bdcb84961f19789a39384 100644 --- a/tools/RD53GainOptimization.cc +++ b/tools/RD53GainOptimization.cc @@ -20,6 +20,7 @@ void GainOptimization::ConfigureCalibration() Gain::ConfigureCalibration(); Gain::doDisplay = false; Gain::doUpdateChip = false; + RD53RunProgress::total() -= Gain::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -193,8 +194,11 @@ void GainOptimization::fillHisto() void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEvents, const float& target, uint16_t startValue, uint16_t stopValue) { + std::vector<uint16_t> chipCommandList; + std::vector<uint32_t> hybridCommandList; + uint16_t init; - uint16_t numberOfBits = log2(stopValue - startValue + 1) + 1; + uint16_t numberOfBits = floor(log2(stopValue - startValue + 1) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; @@ -210,10 +214,17 @@ void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nE ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer); ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer); - for(const auto cBoard: bestContainer) + // ######################### + // # Initialize containers # + // ######################### + for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) cChip->getSummary<OccupancyAndPh>().fPh = 0; + for(const auto cChip: *cHybrid) + { + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = 0; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = 0; + } for(auto i = 0u; i <= numberOfBits; i++) { @@ -222,7 +233,14 @@ void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nE // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) { midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = @@ -230,18 +248,26 @@ void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nE maxDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>()) / 2; - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); - LOG(INFO) << BOLDMAGENTA << ">>> " << regName << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" - << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW << midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA << " <<<" << RESET; } + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } + // ################ // # Run analysis # // ################ @@ -307,13 +333,39 @@ void GainOptimization::bitWiseScanGlobal(const std::string& regName, uint32_t nE // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + if(bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() != 0) + { + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + LOG(INFO) << BOLDMAGENTA << ">>> Best " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] = " << BOLDYELLOW + << bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA + << " <<<" << RESET; + } + else + LOG(WARNING) << BOLDRED << ">>> Best " << BOLDYELLOW << regName << BOLDRED << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDRED << "] was not found <<<" << RESET; + + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } // ################ // # Run analysis # @@ -352,7 +404,7 @@ void GainOptimization::chipErrorReport() void GainOptimization::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53GainOptimization.h b/tools/RD53GainOptimization.h index 2fc18e327ccd9d737e4136edae4ab6787e7bf1d4..c04a4f401042130a47f2d23b1d44ea3b806eef9f 100644 --- a/tools/RD53GainOptimization.h +++ b/tools/RD53GainOptimization.h @@ -39,9 +39,9 @@ class GainOptimization : public Gain void draw(); size_t getNumberIterations() { - uint16_t nBitKrumCurr = floor(log2(KrumCurrStop - KrumCurrStart + 1) + 1); - uint16_t moreIterations = 1; - return Gain::getNumberIterations() * (nBitKrumCurr + moreIterations); + uint16_t nIterationsKrumCurr = floor(log2(KrumCurrStop - KrumCurrStart + 1) + 1); + uint16_t moreIterations = 2; + return Gain::getNumberIterations() * (nIterationsKrumCurr + moreIterations); } void saveChipRegisters(int currentRun); diff --git a/tools/RD53InjectionDelay.cc b/tools/RD53InjectionDelay.cc index de7f060eec5a7a9ff4e17ee376ed8d5fe961a8d2..1918a6fac7f9f90a4cac3cdfcb302c31b816674b 100644 --- a/tools/RD53InjectionDelay.cc +++ b/tools/RD53InjectionDelay.cc @@ -18,6 +18,7 @@ void InjectionDelay::ConfigureCalibration() // # Initialize sub-calibration # // ############################## PixelAlive::ConfigureCalibration(); + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -248,10 +249,10 @@ void InjectionDelay::analyze() } } - LOG(INFO) << GREEN << "Best delay for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" - << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << regVal << RESET << GREEN << " (1.5625 ns) computed over two bx" << RESET; - LOG(INFO) << GREEN << "New delay dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() - << "/" << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << (regVal & maxDelay) << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> Best injection delay for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << regVal << BOLDMAGENTA << " (1.5625 ns) computed over two bx <<<" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> New injection delay dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << (regVal & maxDelay) << BOLDMAGENTA << " <<<" << RESET; // #################################################### // # Fill delay container and download new DAC values # @@ -263,8 +264,8 @@ void InjectionDelay::analyze() auto latency = this->fReadoutChipInterface->ReadChipReg(static_cast<RD53*>(cChip), "LATENCY_CONFIG"); if(regVal / (maxDelay + 1) == 0) latency--; this->fReadoutChipInterface->WriteChipReg(static_cast<RD53*>(cChip), "LATENCY_CONFIG", latency, true); - LOG(INFO) << GREEN << "New latency dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() - << "/" << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << latency << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> New latency dac value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << latency << BOLDMAGENTA << " <<<" << RESET; } } @@ -285,7 +286,7 @@ void InjectionDelay::scanDac(const std::string& regName, const std::vector<uint1 // ########################### // # Download new DAC values # // ########################### - LOG(INFO) << BOLDMAGENTA << ">>> Register value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) @@ -356,7 +357,7 @@ void InjectionDelay::chipErrorReport() void InjectionDelay::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53InjectionDelay.h b/tools/RD53InjectionDelay.h index 9df10db7d9ca60f5fa9a2a2d598f0ec889442f10..8321fda1d6a98def945d36aa04b1380ebcf6ab22 100644 --- a/tools/RD53InjectionDelay.h +++ b/tools/RD53InjectionDelay.h @@ -32,8 +32,12 @@ class InjectionDelay : public PixelAlive void run(); void draw(); void analyze(); - size_t getNumberIterations() { return PixelAlive::getNumberIterations() * (stopValue - startValue); } - void saveChipRegisters(int currentRun); + size_t getNumberIterations() + { + return PixelAlive::getNumberIterations() * + (stopValue - startValue + 1 <= RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1 ? stopValue - startValue + 1 : RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1); + } + void saveChipRegisters(int currentRun); #ifdef __USE_ROOT__ InjectionDelayHistograms* histos; diff --git a/tools/RD53Latency.cc b/tools/RD53Latency.cc index df4185ff7f2bae2eb5865f3a78f9a855e5e99c09..9bfc156ffd095a8f1924d82c28e7917b5a46c0a8 100644 --- a/tools/RD53Latency.cc +++ b/tools/RD53Latency.cc @@ -18,6 +18,7 @@ void Latency::ConfigureCalibration() // # Initialize sub-calibration # // ############################## PixelAlive::ConfigureCalibration(); + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -184,12 +185,12 @@ void Latency::analyze() } if(nTRIGxEvent > 1) - LOG(INFO) << GREEN << "Best latency for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" - << +cChip->getId() << RESET << GREEN << "] is within [" << BOLDYELLOW << (regVal - (int)nTRIGxEvent + 1 >= 0 ? std::to_string(regVal - (int)nTRIGxEvent + 1) : "N.A.") - << "," << regVal << GREEN << "] (n.bx)" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> Best latency for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is within [" << BOLDYELLOW + << (regVal - (int)nTRIGxEvent + 1 >= 0 ? std::to_string(regVal - (int)nTRIGxEvent + 1) : "N.A.") << "," << regVal << BOLDMAGENTA << "] (n.bx) <<<" << RESET; else - LOG(INFO) << GREEN << "Best latency for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" - << +cChip->getId() << RESET << GREEN << "] is " << BOLDYELLOW << regVal << RESET << GREEN << " (n.bx)" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> Best latency for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" + << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] is " << BOLDYELLOW << regVal << BOLDMAGENTA << " (n.bx) <<<" << RESET; // ###################################################### // # Fill latency container and download new DAC values # @@ -216,7 +217,7 @@ void Latency::scanDac(const std::string& regName, const std::vector<uint16_t>& d // ########################### // # Download new DAC values # // ########################### - LOG(INFO) << BOLDMAGENTA << ">>> Register value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value = " << BOLDYELLOW << dacList[i] << BOLDMAGENTA << " <<<" << RESET; for(const auto cBoard: *fDetectorContainer) this->fReadoutChipInterface->WriteBoardBroadcastChipReg(cBoard, regName, dacList[i]); // ################ @@ -275,7 +276,7 @@ void Latency::chipErrorReport() void Latency::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53Latency.h b/tools/RD53Latency.h index 9c1990f59bacb5cb0984fa5856c9a9095fcad3f9..dab231f223a86421fb90a2f8280b4d0a78d81689 100644 --- a/tools/RD53Latency.h +++ b/tools/RD53Latency.h @@ -32,8 +32,13 @@ class Latency : public PixelAlive void run(); void draw(bool saveData = true); void analyze(); - size_t getNumberIterations() { return PixelAlive::getNumberIterations() * (stopValue - startValue) / nTRIGxEvent; } - void saveChipRegisters(int currentRun); + size_t getNumberIterations() + { + return PixelAlive::getNumberIterations() * ((stopValue - startValue) / nTRIGxEvent + 1 <= RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1 + ? (stopValue - startValue) / nTRIGxEvent + 1 + : RD53Shared::setBits(RD53Shared::MAXBITCHIPREG) + 1); + } + void saveChipRegisters(int currentRun); #ifdef __USE_ROOT__ LatencyHistograms* histos; diff --git a/tools/RD53Physics.cc b/tools/RD53Physics.cc index 205514dbfe4920dec46bb3e93df05817c17a76ba..9ce61dc88829a822af755f633209f72118514d7a 100644 --- a/tools/RD53Physics.cc +++ b/tools/RD53Physics.cc @@ -149,11 +149,14 @@ void Physics::initializeFiles(const std::string fileRes_, int currentRun) void Physics::run() { + std::unique_lock<std::mutex> theGuard(theMtx, std::defer_lock); while(this->fKeepRunning == true) { RD53FWInterface::decodedEvents.clear(); Physics::analyze(); + theGuard.lock(); genericEvtConverter(RD53FWInterface::decodedEvents); + theGuard.unlock(); std::this_thread::sleep_for(std::chrono::microseconds(READOUTSLEEP)); numberOfEventsPerRun += RD53FWInterface::decodedEvents.size(); } @@ -193,8 +196,7 @@ void Physics::analyze(bool doReadBinary) else { dataSize = 1; - std::vector<uint32_t> data; - SystemController::DecodeData(cBoard, data, dataSize, cBoard->getBoardType()); + SystemController::DecodeData(cBoard, {}, 0, cBoard->getBoardType()); } if(dataSize != 0) @@ -214,72 +216,69 @@ void Physics::fillHisto() #endif } -void Physics::fillDataContainer(BeBoard* cBoard) +void Physics::fillDataContainer(BeBoard* theBoard) { const size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1; const size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1; + const auto cBoard = theOccContainer.at(theBoard->getIndex()); // ################### // # Clear container # // ################### - Physics::clearContainers(); + Physics::clearContainers(theBoard); // ################### // # Fill containers # // ################### - const std::vector<Event*>& events = SystemController::GetEvents(cBoard); - for(const auto& event: events) event->fillDataContainer(theOccContainer.at(cBoard->getIndex()), theChnGroupHandler->allChannelGroup()); + const std::vector<Event*>& events = SystemController::GetEvents(); + for(const auto& event: events) event->fillDataContainer(cBoard, theChnGroupHandler->allChannelGroup()); // ###################################### // # Copy register values for streaming # // ###################################### - for(const auto cBoard: theOccContainer) - for(const auto cOpticalGroup: *cBoard) - for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) + for(const auto cOpticalGroup: *cBoard) + for(const auto cHybrid: *cOpticalGroup) + for(const auto cChip: *cHybrid) + { + for(auto i = 1u; i < cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1.size(); i++) { - for(auto i = 1u; i < cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1.size(); i++) - { - int deltaBCID = cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1[i] - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1[i - 1]; - deltaBCID += (deltaBCID >= 0 ? 0 : RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1); - if(deltaBCID >= int(BCIDsize)) - LOG(ERROR) << BOLDBLUE << "[Physics::fillDataContainer] " << BOLDRED << "deltaBCID out of range: " << deltaBCID << RESET; - else - theBCIDContainer.at(cBoard->getIndex()) - ->at(cOpticalGroup->getIndex()) - ->at(cHybrid->getIndex()) - ->at(cChip->getIndex()) - ->getSummary<GenericDataArray<BCIDsize>>() - .data[deltaBCID]++; - } - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1.clear(); + int deltaBCID = cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1[i] - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1[i - 1]; + deltaBCID += (deltaBCID >= 0 ? 0 : RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1); + if(deltaBCID >= int(BCIDsize)) + LOG(ERROR) << BOLDBLUE << "[Physics::fillDataContainer] " << BOLDRED << "deltaBCID out of range: " << deltaBCID << RESET; + else + theBCIDContainer.at(cBoard->getIndex()) + ->at(cOpticalGroup->getIndex()) + ->at(cHybrid->getIndex()) + ->at(cChip->getIndex()) + ->getSummary<GenericDataArray<BCIDsize>>() + .data[deltaBCID]++; + } - for(auto i = 1u; i < cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2.size(); i++) - { - int deltaTrgID = cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2[i] - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2[i - 1]; - deltaTrgID += (deltaTrgID >= 0 ? 0 : RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1); - if(deltaTrgID >= int(TrgIDsize)) - LOG(ERROR) << BOLDBLUE << "[Physics::fillDataContainer] " << BOLDRED << "deltaTrgID out of range: " << deltaTrgID << RESET; - else - theTrgIDContainer.at(cBoard->getIndex()) - ->at(cOpticalGroup->getIndex()) - ->at(cHybrid->getIndex()) - ->at(cChip->getIndex()) - ->getSummary<GenericDataArray<TrgIDsize>>() - .data[deltaTrgID]++; - } - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2.clear(); + for(auto i = 1u; i < cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2.size(); i++) + { + int deltaTrgID = cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2[i] - cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2[i - 1]; + deltaTrgID += (deltaTrgID >= 0 ? 0 : RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1); + if(deltaTrgID >= int(TrgIDsize)) + LOG(ERROR) << BOLDBLUE << "[Physics::fillDataContainer] " << BOLDRED << "deltaTrgID out of range: " << deltaTrgID << RESET; + else + theTrgIDContainer.at(cBoard->getIndex()) + ->at(cOpticalGroup->getIndex()) + ->at(cHybrid->getIndex()) + ->at(cChip->getIndex()) + ->getSummary<GenericDataArray<TrgIDsize>>() + .data[deltaTrgID]++; } + } // ####################### // # Normalize container # // ####################### - for(const auto cBoard: theOccContainer) - for(const auto cOpticalGroup: *cBoard) - for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) - for(auto row = 0u; row < RD53::nRows; row++) - for(auto col = 0u; col < RD53::nCols; col++) cChip->getChannel<OccupancyAndPh>(row, col).normalize(events.size(), true); + for(const auto cOpticalGroup: *cBoard) + for(const auto cHybrid: *cOpticalGroup) + for(const auto cChip: *cHybrid) + for(auto row = 0u; row < RD53::nRows; row++) + for(auto col = 0u; col < RD53::nCols; col++) cChip->getChannel<OccupancyAndPh>(row, col).normalize(events.size(), true); } void Physics::chipErrorReport() @@ -312,7 +311,7 @@ void Physics::chipErrorReport() void Physics::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) @@ -329,40 +328,43 @@ void Physics::saveChipRegisters(int currentRun) } } -void Physics::clearContainers() +void Physics::clearContainers(BeBoard* theBoard) { const size_t BCIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_BCID) + 1; const size_t TrgIDsize = RD53Shared::setBits(RD53EvtEncoder::NBIT_TRIGID) + 1; + const auto cBoard = theOccContainer.at(theBoard->getIndex()); // #################### // # Clear containers # // #################### - for(const auto cBoard: theOccContainer) - for(const auto cOpticalGroup: *cBoard) - for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) - { - for(auto row = 0u; row < RD53::nRows; row++) - for(auto col = 0u; col < RD53::nCols; col++) - { - cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy = 0; - cChip->getChannel<OccupancyAndPh>(row, col).fPh = 0; - cChip->getChannel<OccupancyAndPh>(row, col).fPhError = 0; - cChip->getChannel<OccupancyAndPh>(row, col).readoutError = false; - } - - for(auto i = 0u; i < BCIDsize; i++) - theBCIDContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<GenericDataArray<BCIDsize>>().data[i] = 0; - for(auto i = 0u; i < TrgIDsize; i++) - theTrgIDContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<GenericDataArray<TrgIDsize>>().data[i] = 0; - } + for(const auto cOpticalGroup: *cBoard) + for(const auto cHybrid: *cOpticalGroup) + for(const auto cChip: *cHybrid) + { + for(auto row = 0u; row < RD53::nRows; row++) + for(auto col = 0u; col < RD53::nCols; col++) + { + cChip->getChannel<OccupancyAndPh>(row, col).fOccupancy = 0; + cChip->getChannel<OccupancyAndPh>(row, col).fPh = 0; + cChip->getChannel<OccupancyAndPh>(row, col).fPhError = 0; + cChip->getChannel<OccupancyAndPh>(row, col).readoutError = false; + } + + cChip->getSummary<GenericDataVector, OccupancyAndPh>().data1.clear(); + cChip->getSummary<GenericDataVector, OccupancyAndPh>().data2.clear(); + + for(auto i = 0u; i < BCIDsize; i++) + theBCIDContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<GenericDataArray<BCIDsize>>().data[i] = 0; + for(auto i = 0u; i < TrgIDsize; i++) + theTrgIDContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<GenericDataArray<TrgIDsize>>().data[i] = 0; + } } 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)); } } diff --git a/tools/RD53Physics.h b/tools/RD53Physics.h index efe9130af9e6f5f4bf91f97d7f0cf49c4c10393d..e8da15b54aee3a5d7a3444b0c740c0e11cd2eb72 100644 --- a/tools/RD53Physics.h +++ b/tools/RD53Physics.h @@ -47,7 +47,11 @@ class Physics : public Tool void fillDataContainer(Ph2_HwDescription::BeBoard* cBoard); void monitor(); - void setGenericEvtConverter(evtConvType arg) { genericEvtConverter = std::move(arg); } + void setGenericEvtConverter(evtConvType arg) + { + std::lock_guard<std::mutex> theGuard(theMtx); + genericEvtConverter = std::move(arg); + } #ifdef __USE_ROOT__ PhysicsHistograms* histos; @@ -68,7 +72,7 @@ class Physics : public Tool void fillHisto(); void chipErrorReport(); - void clearContainers(); + void clearContainers(Ph2_HwDescription::BeBoard* cBoard); protected: struct RD53dummyEvtConverter @@ -83,6 +87,7 @@ class Physics : public Tool bool doDisplay; bool saveBinaryData; std::thread thrMonitor; + std::mutex theMtx; evtConvType genericEvtConverter; }; diff --git a/tools/RD53PixelAlive.cc b/tools/RD53PixelAlive.cc index 2423d2720444bfc98eb070e96195ec0fea274482..27ebc7e9f7b9db9cc7e7c93b68adb25fa3779f28 100644 --- a/tools/RD53PixelAlive.cc +++ b/tools/RD53PixelAlive.cc @@ -27,6 +27,7 @@ void PixelAlive::ConfigureCalibration() nHITxCol = this->findValueInSettings("nHITxCol"); doFast = this->findValueInSettings("DoFast"); thrOccupancy = this->findValueInSettings("TargetOcc"); + unstuckPixels = this->findValueInSettings("UnstuckPixels"); doDisplay = this->findValueInSettings("DisplayHisto"); doUpdateChip = this->findValueInSettings("UpdateChipCfg"); saveBinaryData = this->findValueInSettings("SaveBinaryData"); @@ -159,6 +160,23 @@ void PixelAlive::run() this->fMaskChannelsFromOtherGroups = true; this->measureData(nEvents, nEvtsBurst); + // ######################### + // # Mark enabled channels # + // ######################### + for(const auto cBoard: *fDetectorContainer) + for(const auto cOpticalGroup: *cBoard) + for(const auto cHybrid: *cOpticalGroup) + for(const auto cChip: *cHybrid) + 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)) + theOccContainer->at(cBoard->getIndex()) + ->at(cOpticalGroup->getIndex()) + ->at(cHybrid->getIndex()) + ->at(cChip->getIndex()) + ->getChannel<OccupancyAndPh>(row, col) + .fOccupancy = RD53Shared::ISDISABLED; + // ################ // # Error report # // ################ @@ -230,12 +248,21 @@ std::shared_ptr<DetectorDataContainer> PixelAlive::analyze() ->at(cChip->getIndex()) ->getChannel<OccupancyAndPh>(row, col) .fOccupancy; - static_cast<RD53*>(cChip)->enablePixel(row, col, injType == INJtype::None ? occupancy <= thrOccupancy : occupancy >= thrOccupancy); - if((*static_cast<RD53*>(cChip)->getPixelsMask())[col].Enable[row] == false) nMaskedPixelsPerCalib++; + bool enable = (injType == INJtype::None ? occupancy <= thrOccupancy : occupancy >= thrOccupancy); + if(unstuckPixels == false) + static_cast<RD53*>(cChip)->enablePixel(row, col, enable); + else if(enable == false) + static_cast<RD53*>(cChip)->setTDAC(row, col, 0); + if(enable == false) nMaskedPixelsPerCalib++; } - LOG(INFO) << BOLDBLUE << "\t--> Number of potentially masked pixels in this iteration: " << BOLDYELLOW << nMaskedPixelsPerCalib << RESET; - LOG(INFO) << BOLDBLUE << "\t--> Total number of potentially masked pixels: " << BOLDYELLOW << static_cast<RD53*>(cChip)->getNbMaskedPixels() << RESET; + if(unstuckPixels == false) + { + LOG(INFO) << BOLDBLUE << "\t--> Number of potentially " << BOLDYELLOW << "masked" << BOLDBLUE << " pixels in this iteration: " << BOLDYELLOW << nMaskedPixelsPerCalib << RESET; + LOG(INFO) << BOLDBLUE << "\t--> Total number of potentially masked pixels: " << BOLDYELLOW << static_cast<RD53*>(cChip)->getNbMaskedPixels() << RESET; + } + else + LOG(INFO) << BOLDBLUE << "\t--> Number of potentially " << BOLDYELLOW << "unstuck" << BOLDBLUE << " pixels in this iteration: " << BOLDYELLOW << nMaskedPixelsPerCalib << RESET; // ###################################### // # Copy register values for streaming # @@ -352,7 +379,7 @@ void PixelAlive::chipErrorReport() void PixelAlive::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53PixelAlive.h b/tools/RD53PixelAlive.h index e8c9d1757f549ff21fb8b96975fc333acdf1b7c5..6aab017d32547decaf6a369ecc4db8552787e327 100644 --- a/tools/RD53PixelAlive.h +++ b/tools/RD53PixelAlive.h @@ -59,6 +59,7 @@ class PixelAlive : public Tool size_t injType; size_t nHITxCol; float thrOccupancy; + bool unstuckPixels; enum INJtype { None, diff --git a/tools/RD53SCurve.cc b/tools/RD53SCurve.cc index 6e12f1548059ba2a20400180e19eab8ae8695935..196ef89c25aefcf69768746182393205884e709c 100644 --- a/tools/RD53SCurve.cc +++ b/tools/RD53SCurve.cc @@ -151,10 +151,7 @@ void SCurve::run() // ########################## // # Set new VCAL_MED value # // ########################## - for(const auto cBoard: *fDetectorContainer) - for(const auto cOpticalGroup: *cBoard) - for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) this->fReadoutChipInterface->WriteChipReg(static_cast<RD53*>(cChip), "VCAL_MED", offset, true); + for(const auto cBoard: *fDetectorContainer) this->fReadoutChipInterface->WriteBoardBroadcastChipReg(cBoard, "VCAL_MED", offset); for(auto container: detectorContainerVector) theRecyclingBin.free(container); detectorContainerVector.clear(); @@ -283,20 +280,20 @@ std::shared_ptr<DetectorDataContainer> SCurve::analyze() if(static_cast<RD53*>(cChip)->getChipOriginalMask()->isChannelEnabled(row, col) && this->fChannelGroupHandler->allChannelGroup()->isChannelEnabled(row, col)) { for(auto i = 1u; i < dacList.size(); i++) - measurements[i] = fabs(detectorContainerVector[i] - ->at(cBoard->getIndex()) - ->at(cOpticalGroup->getIndex()) - ->at(cHybrid->getIndex()) - ->at(cChip->getIndex()) - ->getChannel<OccupancyAndPh>(row, col) - .fOccupancy - - detectorContainerVector[i - 1] - ->at(cBoard->getIndex()) - ->at(cOpticalGroup->getIndex()) - ->at(cHybrid->getIndex()) - ->at(cChip->getIndex()) - ->getChannel<OccupancyAndPh>(row, col) - .fOccupancy); + measurements[i - 1] = fabs(detectorContainerVector[i] + ->at(cBoard->getIndex()) + ->at(cOpticalGroup->getIndex()) + ->at(cHybrid->getIndex()) + ->at(cChip->getIndex()) + ->getChannel<OccupancyAndPh>(row, col) + .fOccupancy - + detectorContainerVector[i - 1] + ->at(cBoard->getIndex()) + ->at(cOpticalGroup->getIndex()) + ->at(cHybrid->getIndex()) + ->at(cChip->getIndex()) + ->getChannel<OccupancyAndPh>(row, col) + .fOccupancy); SCurve::computeStats(measurements, offset, nHits, mean, rms); @@ -349,6 +346,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; @@ -420,7 +418,7 @@ void SCurve::chipErrorReport() void SCurve::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53ThrAdjustment.cc b/tools/RD53ThrAdjustment.cc index 30e5e996c4bbb06b2e7a36e8d330e51880545e1d..323db1b6c40ede428fdaf74aab29d770bb6990f0 100644 --- a/tools/RD53ThrAdjustment.cc +++ b/tools/RD53ThrAdjustment.cc @@ -20,6 +20,7 @@ void ThrAdjustment::ConfigureCalibration() PixelAlive::ConfigureCalibration(); PixelAlive::doDisplay = false; PixelAlive::doUpdateChip = false; + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -192,14 +193,18 @@ void ThrAdjustment::fillHisto() void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEvents, const float& target, uint16_t startValue, uint16_t stopValue) { + std::vector<uint16_t> chipCommandList; + std::vector<uint32_t> hybridCommandList; + uint16_t init; - uint16_t numberOfBits = log2(stopValue - startValue + 1) + 1; + uint16_t numberOfBits = floor(log2(stopValue - startValue + 1) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; DetectorDataContainer maxDACcontainer; DetectorDataContainer bestDACcontainer; + DetectorDataContainer bestDACDACcontainer; DetectorDataContainer bestContainer; ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, minDACcontainer, init = startValue); @@ -207,12 +212,21 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, maxDACcontainer, init = (stopValue + 1)); ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer); + ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACDACcontainer); ContainerFactory::copyAndInitChip<float>(*fDetectorContainer, bestContainer); - for(const auto cBoard: bestContainer) + // ######################### + // # Initialize containers # + // ######################### + for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) cChip->getSummary<float>() = 0; + for(const auto cChip: *cHybrid) + { + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = 0; + bestDACDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = 0; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<float>() = 0; + } for(auto i = 0u; i <= numberOfBits; i++) { @@ -221,7 +235,14 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) { midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = @@ -229,18 +250,26 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven maxDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>()) / 2; - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); - LOG(INFO) << BOLDMAGENTA << ">>> " << regName << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" - << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW << midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA << " <<<" << RESET; } + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } + // ################ // # Run analysis # // ################ @@ -272,6 +301,9 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(); + + bestDACDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = + cChip->getSummary<uint16_t>(); } if(newValue > target) @@ -291,13 +323,46 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + if(bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() != 0) + { + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + "VCAL_HIGH", + bestDACDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + LOG(INFO) << BOLDMAGENTA << ">>> Best " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] = " << BOLDYELLOW + << bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA + << " <<<" << RESET; + } + else + LOG(WARNING) << BOLDRED << ">>> Best " << BOLDYELLOW << regName << BOLDRED << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDRED << "] was not found <<<" << RESET; + + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } // ################ // # Run analysis # @@ -308,8 +373,11 @@ void ThrAdjustment::bitWiseScanGlobal(const std::string& regName, uint32_t nEven std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureThr(const std::string& regName, uint32_t nEvents, const float& target, uint16_t startValue, uint16_t stopValue) { + std::vector<uint16_t> chipCommandList; + std::vector<uint32_t> hybridCommandList; + uint16_t init; - uint16_t numberOfBits = log2(stopValue - startValue + 1) + 1; + uint16_t numberOfBits = floor(log2(stopValue - startValue + 1) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; @@ -325,10 +393,18 @@ std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureT ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, *bestDACcontainer); ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer); - for(const auto cBoard: bestContainer) + // ######################### + // # Initialize containers # + // ######################### + for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) cChip->getSummary<OccupancyAndPh>().fPh = 0; + for(const auto cChip: *cHybrid) + { + bestDACcontainer->at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = + static_cast<RD53*>(cChip)->getReg("VCAL_MED"); + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = 0; + } for(auto i = 0u; i <= numberOfBits; i++) { @@ -337,7 +413,14 @@ std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureT // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) { midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = @@ -345,13 +428,26 @@ std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureT maxDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>()) / 2; - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW + << midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA + << " <<<" << RESET; } + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } + // ################ // # Run analysis # // ################ @@ -380,11 +476,11 @@ std::shared_ptr<DetectorDataContainer> ThrAdjustment::bitWiseScanGlobal_MeasureT // ######################## // # Save best DAC values # // ######################## - float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh; + float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy; if(fabs(newValue - target) < fabs(oldValue - target)) { - bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh = newValue; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = newValue; bestDACcontainer->at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(); @@ -435,7 +531,7 @@ void ThrAdjustment::chipErrorReport() void ThrAdjustment::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53ThrAdjustment.h b/tools/RD53ThrAdjustment.h index d58787bf4627f33d6de1e495092a017616b13431..9a128b1027d6b9beabe7655bd27e8fc021419ab9 100644 --- a/tools/RD53ThrAdjustment.h +++ b/tools/RD53ThrAdjustment.h @@ -39,10 +39,12 @@ class ThrAdjustment : public PixelAlive void analyze(); size_t getNumberIterations() { - uint16_t nBitThr = floor(log2(ThrStop - ThrStart + 1) + 1); - uint16_t nBitVCal = floor(log2(VCalStop - VCalStart + 1) + 1); - uint16_t moreIterations = 1; - return PixelAlive::getNumberIterations() * (nBitThr + moreIterations) * (nBitVCal + moreIterations); + uint16_t nIterationsThr = floor(log2(ThrStop - ThrStart + 1) + 1); + uint16_t moreIterationsThr = 1; + uint16_t nIterationsVCal = floor(log2(VCalStop - VCalStart + 1) + 1); + uint16_t moreIterationsVCal = 1; + uint16_t moreIterations = 1; + return PixelAlive::getNumberIterations() * ((nIterationsThr + moreIterationsThr) * (nIterationsVCal + moreIterationsVCal) + moreIterations); } void saveChipRegisters(int currentRun); diff --git a/tools/RD53ThrEqualization.cc b/tools/RD53ThrEqualization.cc index c1aba0e98aeb389165118ad8284712d51cd8183d..53dda0b90d9653e50f7cbf37508368265de6215e 100644 --- a/tools/RD53ThrEqualization.cc +++ b/tools/RD53ThrEqualization.cc @@ -20,6 +20,7 @@ void ThrEqualization::ConfigureCalibration() PixelAlive::ConfigureCalibration(); PixelAlive::doDisplay = false; PixelAlive::doUpdateChip = false; + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -155,6 +156,7 @@ void ThrEqualization::run() // # Run threshold equalization # // ############################## size_t TDACsize = RD53Shared::setBits(RD53Constants::NBIT_TDAC) + 1; + if(frontEnd == &RD53::DIFF) TDACsize *= 2; this->fDetectorDataContainer = &theOccContainer; ContainerFactory::copyAndInitStructure<OccupancyAndPh>(*fDetectorContainer, *this->fDetectorDataContainer); @@ -220,19 +222,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(); } } @@ -247,8 +271,11 @@ void ThrEqualization::fillHisto() void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEvents, const float& target, uint16_t startValue, uint16_t stopValue) { + std::vector<uint16_t> chipCommandList; + std::vector<uint32_t> hybridCommandList; + uint16_t init; - uint16_t numberOfBits = log2(stopValue - startValue + 1) + 1; + uint16_t numberOfBits = floor(log2(stopValue - startValue + 1) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; @@ -257,6 +284,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)); @@ -264,10 +293,19 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer); ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer); - for(const auto cBoard: bestContainer) + ContainerFactory::copyAndInitChannel<uint16_t>(*fDetectorContainer, theTDACcontainer); + + // ######################### + // # Initialize containers # + // ######################### + for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) cChip->getSummary<OccupancyAndPh>().fPh = 0; + for(const auto cChip: *cHybrid) + { + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = 0; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = 0; + } for(auto i = 0u; i <= numberOfBits; i++) { @@ -276,7 +314,14 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) { midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = @@ -284,18 +329,26 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv maxDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>()) / 2; - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); - LOG(INFO) << BOLDMAGENTA << ">>> " << regName << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" - << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW << midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA << " <<<" << RESET; } + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } + // ################ // # Run analysis # // ################ @@ -324,11 +377,11 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ######################## // # Save best DAC values # // ######################## - float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh; + float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy; if(fabs(newValue - target) < fabs(oldValue - target)) { - bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh = newValue; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = newValue; bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(); @@ -351,13 +404,39 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + if(bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() != 0) + { + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + LOG(INFO) << BOLDMAGENTA << ">>> Best " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] = " << BOLDYELLOW + << bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA + << " <<<" << RESET; + } + else + LOG(WARNING) << BOLDRED << ">>> Best " << BOLDYELLOW << regName << BOLDRED << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDRED << "] was not found <<<" << RESET; + + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } // ################ // # Run analysis # @@ -368,8 +447,8 @@ void ThrEqualization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv void ThrEqualization::bitWiseScanLocal(const std::string& regName, uint32_t nEvents, const float& target, uint32_t nEvtsBurst) { - uint16_t init; - unsigned int numberOfBits = ceil(log2(frontEnd->nTDACvalues)); + uint16_t init; + uint16_t numberOfBits = floor(log2(frontEnd->nTDACvalues) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; @@ -385,6 +464,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) @@ -524,7 +606,7 @@ void ThrEqualization::chipErrorReport() void ThrEqualization::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53ThrEqualization.h b/tools/RD53ThrEqualization.h index 25e4129a552b4751cde3d813ab29bfcdb0e34a26..08b5aa3fdac992f927badb1f06f3618f50f84de9 100644 --- a/tools/RD53ThrEqualization.h +++ b/tools/RD53ThrEqualization.h @@ -39,12 +39,13 @@ class ThrEqualization : public PixelAlive void analyze(); size_t getNumberIterations() { - uint16_t nBitVCal = floor(log2(stopValue - startValue + 1) + 1); - uint16_t moreIterationsPA = 1; - uint16_t nBitTDAC = 4; - uint16_t moreIterations = 2; - return PixelAlive::getNumberIterations() * (nBitVCal + moreIterationsPA) + - RD53ChannelGroupHandler::getNumberOfGroups(doFast == true ? RD53GroupType::OneGroup : RD53GroupType::AllGroups, nHITxCol) * (nBitTDAC + moreIterations) * nEvents / nEvtsBurst; + uint16_t nIterationsVCal = floor(log2(stopValue - startValue + 1) + 1); + uint16_t moreIterationsVCal = 2; + uint16_t nIterationsTDAC = floor(log2(frontEnd->nTDACvalues) + 1); + uint16_t moreIterationsTDAC = 2; + return PixelAlive::getNumberIterations() * (nIterationsVCal + moreIterationsVCal) + + RD53ChannelGroupHandler::getNumberOfGroups(doFast == true ? RD53GroupType::OneGroup : RD53GroupType::AllGroups, nHITxCol) * (nIterationsTDAC + moreIterationsTDAC) * nEvents / + nEvtsBurst; } void saveChipRegisters(int currentRun); diff --git a/tools/RD53ThrMinimization.cc b/tools/RD53ThrMinimization.cc index 7d692bc9f279bee5c45e8e2c9cfa083dc6416f88..67649cd208c25f735c46617e83c6ee2a11da8ee7 100644 --- a/tools/RD53ThrMinimization.cc +++ b/tools/RD53ThrMinimization.cc @@ -20,6 +20,7 @@ void ThrMinimization::ConfigureCalibration() PixelAlive::ConfigureCalibration(); PixelAlive::doDisplay = false; PixelAlive::doUpdateChip = false; + RD53RunProgress::total() -= PixelAlive::getNumberIterations(); // ####################### // # Retrieve parameters # @@ -190,8 +191,11 @@ void ThrMinimization::fillHisto() void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEvents, const float& target, uint16_t startValue, uint16_t stopValue) { + std::vector<uint16_t> chipCommandList; + std::vector<uint32_t> hybridCommandList; + uint16_t init; - uint16_t numberOfBits = log2(stopValue - startValue + 1) + 1; + uint16_t numberOfBits = floor(log2(stopValue - startValue + 1) + 1); DetectorDataContainer minDACcontainer; DetectorDataContainer midDACcontainer; @@ -207,10 +211,17 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv ContainerFactory::copyAndInitChip<uint16_t>(*fDetectorContainer, bestDACcontainer); ContainerFactory::copyAndInitChip<OccupancyAndPh>(*fDetectorContainer, bestContainer); - for(const auto cBoard: bestContainer) + // ######################### + // # Initialize containers # + // ######################### + for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) for(const auto cHybrid: *cOpticalGroup) - for(const auto cChip: *cHybrid) cChip->getSummary<OccupancyAndPh>().fPh = 0; + for(const auto cChip: *cHybrid) + { + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = 0; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = 0; + } for(auto i = 0u; i <= numberOfBits; i++) { @@ -219,7 +230,14 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) { midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = @@ -227,18 +245,26 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv maxDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>()) / 2; - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); - LOG(INFO) << BOLDMAGENTA << ">>> " << regName << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" << cOpticalGroup->getId() << "/" - << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW + LOG(INFO) << BOLDMAGENTA << ">>> " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << RESET << BOLDMAGENTA << "] = " << RESET << BOLDYELLOW << midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA << " <<<" << RESET; } + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } + // ################ // # Run analysis # // ################ @@ -267,11 +293,11 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ######################## // # Save best DAC values # // ######################## - float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh; + float oldValue = bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy; if(fabs(newValue - target) < fabs(oldValue - target)) { - bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fPh = newValue; + bestContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<OccupancyAndPh>().fOccupancy = newValue; bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() = midDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(); @@ -294,13 +320,39 @@ void ThrMinimization::bitWiseScanGlobal(const std::string& regName, uint32_t nEv // ########################### for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) + { + hybridCommandList.clear(); + for(const auto cHybrid: *cOpticalGroup) + { + chipCommandList.clear(); + int hybridId = cHybrid->getId(); + for(const auto cChip: *cHybrid) - this->fReadoutChipInterface->WriteChipReg( - static_cast<RD53*>(cChip), - regName, - bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), - true); + if(bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() != 0) + { + static_cast<RD53Interface*>(this->fReadoutChipInterface) + ->PackChipCommands(cChip, + regName, + bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>(), + chipCommandList, + true); + + LOG(INFO) << BOLDMAGENTA << ">>> Best " << BOLDYELLOW << regName << BOLDMAGENTA << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDMAGENTA << "] = " << BOLDYELLOW + << bestDACcontainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<uint16_t>() << BOLDMAGENTA + << " <<<" << RESET; + } + else + LOG(WARNING) << BOLDRED << ">>> Best " << BOLDYELLOW << regName << BOLDRED << " value for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << cBoard->getId() << "/" + << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/" << +cChip->getId() << BOLDRED << "] was not found <<<" << RESET; + + // static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendChipCommandsPack(chipCommandList, hybridId); + static_cast<RD53Interface*>(this->fReadoutChipInterface)->PackHybridCommands(chipCommandList, hybridId, hybridCommandList); + } + + static_cast<RD53Interface*>(this->fReadoutChipInterface)->SendHybridCommandsPack(hybridCommandList); + } // ################ // # Run analysis # @@ -339,7 +391,7 @@ void ThrMinimization::chipErrorReport() void ThrMinimization::saveChipRegisters(int currentRun) { - std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); + const std::string fileReg("Run" + RD53Shared::fromInt2Str(currentRun) + "_"); for(const auto cBoard: *fDetectorContainer) for(const auto cOpticalGroup: *cBoard) diff --git a/tools/RD53ThrMinimization.h b/tools/RD53ThrMinimization.h index 2b3045477a003832796c1690a1bba7d5e4a1b711..7a9b4cec0c8fd3f07b36087420051e52994ab8f5 100644 --- a/tools/RD53ThrMinimization.h +++ b/tools/RD53ThrMinimization.h @@ -34,9 +34,9 @@ class ThrMinimization : public PixelAlive void analyze(); size_t getNumberIterations() { - uint16_t nBitThr = floor(log2(ThrStop - ThrStart + 1) + 1); - uint16_t moreIterations = 1; - return PixelAlive::getNumberIterations() * (nBitThr + moreIterations); + uint16_t nIterationsThr = floor(log2(ThrStop - ThrStart + 1) + 1); + uint16_t moreIterations = 2; + return PixelAlive::getNumberIterations() * (nIterationsThr + moreIterations); } void saveChipRegisters(int currentRun); diff --git a/tools/RD53eudaqProducer.cc b/tools/RD53eudaqProducer.cc index 6afe34cf607f9abe152b5117dac002e9f30def1d..f033d12a81127152144d134119f8722b28ea4a63 100644 --- a/tools/RD53eudaqProducer.cc +++ b/tools/RD53eudaqProducer.cc @@ -67,10 +67,9 @@ void RD53eudaqProducer::DoStopRun() // ########################### // # Copy configuration file # // ########################### - std::string fName2Add(std::string(RD53Shared::RESULTDIR) + "/Run" + RD53Shared::fromInt2Str(fRunNumber) + "_"); - std::string output(RD53Shared::composeFileName(configFile, fName2Add)); - std::string command("cp " + configFile + " " + output); - system(command.c_str()); + const auto configFileBasename = configFile.substr(configFile.find_last_of("/\\") + 1); + const auto outputConfigFile = std::string(RD53Shared::RESULTDIR) + "/Run" + RD53Shared::fromInt2Str(runNumber) + "_" + configFileBasename; + system(("cp " + configFile + " " + outputConfigFile).c_str()); this->SetStatus(eudaq::Status::STATE_STOPPED, "RD53eudaqProducer::Stopped"); this->SetStatus(eudaq::Status::STATE_CONF, "RD53eudaqProducer::Configured"); diff --git a/tools/SSALatencyScan.cc b/tools/SSALatencyScan.cc index 3ffa4add311f3952120cdbae6ab5c60af58f06cf..3c6a9fd565c1cc5914d62201c7bfad2f2fb8cbc8 100644 --- a/tools/SSALatencyScan.cc +++ b/tools/SSALatencyScan.cc @@ -120,7 +120,7 @@ void SSALatencyScan::run(void) // this->enableTestPulse( true ); // setFWTestPulse(); this->ReadNEvents(theBeBoard, 200); - const std::vector<Event*>& eventVector = this->GetEvents(theBeBoard); + const std::vector<Event*>& eventVector = this->GetEvents(); unsigned int thiscount = 0; for(auto& event: eventVector) // for on events - begin diff --git a/tools/SSAPhysics.cc b/tools/SSAPhysics.cc index 2f0a63bd1ae2bea2748cc872ac082107f1cf3932..587ef508d2b847a77c816102d8414b810b2e0b5f 100644 --- a/tools/SSAPhysics.cc +++ b/tools/SSAPhysics.cc @@ -165,7 +165,7 @@ void SSAPhysics::fillDataContainer(BoardContainer* const& cBoard) // ################### // # Fill containers # // ################### - const std::vector<Event*>& events = SystemController::GetEvents(static_cast<BeBoard*>(cBoard)); + const std::vector<Event*>& events = SystemController::GetEvents(); for(const auto& event: events) { event->fillDataContainer(fOccContainer.at(cBoard->getIndex()), fChannelGroupHandler->allChannelGroup()); } } diff --git a/tools/SSASCurveAsync.cc b/tools/SSASCurveAsync.cc index 28dd0e480a8c889799a7aaf6dbd9351d2dd1d438..3bc38353022f7d0c1a0371eb115063fc922d15a7 100644 --- a/tools/SSASCurveAsync.cc +++ b/tools/SSASCurveAsync.cc @@ -177,7 +177,7 @@ void SSASCurve::run(void) // now ReadNEvents takes care of all of this // for both MPA and SSA this->ReadNEvents(theBeBoard, NMpulse); - const std::vector<Event*>& cEvents = this->GetEvents(theBeBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto opticalGroup: *cBoard) { diff --git a/tools/ShortFinder.cc b/tools/ShortFinder.cc index ac37c457000d0050a52003e4852b0005b2789340..66825ddbf24642c212f3b00039a861dde103aea8 100644 --- a/tools/ShortFinder.cc +++ b/tools/ShortFinder.cc @@ -359,7 +359,7 @@ void ShortFinder::FindShortsPS(BeBoard* pBoard) // read back events this->ReadNEvents(pBoard, fEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(pBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); // iterate over FE objects and check occupancy for(auto cEvent: cEvents) { @@ -451,7 +451,7 @@ void ShortFinder::FindShorts2S(BeBoard* pBoard) auto& cThisHitsContainer = fHitsContainer.at(pBoard->getIndex()); this->ReadNEvents(pBoard, fEventsPerPoint); - const std::vector<Event*>& cEvents = this->GetEvents(pBoard); + const std::vector<Event*>& cEvents = this->GetEvents(); for(auto cEvent: cEvents) { auto cEventCount = cEvent->GetEventCount(); diff --git a/tools/SignalScan.cc b/tools/SignalScan.cc index 83f3655ee1d794b76b1c5eca374028fac33bb650..58a6614b317859fa5c1c978318b09da90f5d8e80 100644 --- a/tools/SignalScan.cc +++ b/tools/SignalScan.cc @@ -130,7 +130,7 @@ void SignalScan::ScanSignal(uint16_t cVcthStart, uint16_t cVcthStop) continue; } - const std::vector<Event*>& events = GetEvents(theBoard); + const std::vector<Event*>& events = GetEvents(); cTotalEventCounter += events.size(); for(auto& cEvent: events) { @@ -263,7 +263,7 @@ void SignalScan::ScanSignal(uint16_t cVcthStart, uint16_t cVcthStop) // { // ReadData ( pBoard ); -// const std::vector<Event*>& events = GetEvents ( pBoard ); +// const std::vector<Event*>& events = GetEvents(); // cTotalEvents += events.size(); // // Loop over Events from this Acquisition diff --git a/tools/SignalScanFit.cc b/tools/SignalScanFit.cc index 4ec5c6514271a262a04f4d72e106c9357567e6b9..df6bbe3035c9857d7f9caf51f43e6bfa5e80044c 100644 --- a/tools/SignalScanFit.cc +++ b/tools/SignalScanFit.cc @@ -193,7 +193,7 @@ void SignalScanFit::ScanSignal(int pSignalScanLength) cTimeout = 10e-3; cTime = fNevents * 1e-3; } - const std::vector<Event*>& cEvents = GetEvents(theBoard); // Get the events and play with them + const std::vector<Event*>& cEvents = GetEvents(); // Get the events and play with them double cTriggerRate = (cEvents.size()) / cTime; cTotalEvents = cEvents.size(); LOG(INFO) << BOLDBLUE << "Vcth: " << +cVCth << ". Recorded " << cTotalEvents << " Events [ average trigger rate " << cTriggerRate << " ]" << RESET; diff --git a/tools/StubSweep.cc b/tools/StubSweep.cc index db421304994bb3d42c11a9ead79de20307d6ee11..58f3f7af876f8de1dcca5ff7f3285657e0f20356 100644 --- a/tools/StubSweep.cc +++ b/tools/StubSweep.cc @@ -205,7 +205,7 @@ void StubSweep::SweepStubs(uint32_t pNEvents) { cEvents.clear(); ReadNEvents(theBoard, pNEvents); - cEvents = GetEvents(theBoard); + cEvents = GetEvents(); unsigned int j = 0; do diff --git a/tools/StubTool.cc b/tools/StubTool.cc index f7b49475cf3e1ef73072ec2a5514dcb1d0ac5efd..b18eee706b130a90d46673b02eb88f9766d87462 100644 --- a/tools/StubTool.cc +++ b/tools/StubTool.cc @@ -165,7 +165,7 @@ void StubTool::scanStubs() // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { @@ -407,7 +407,7 @@ void StubTool::scanStubs_wNoise() // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { @@ -684,7 +684,7 @@ void StubTool::scanStubs_swap() // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { @@ -885,7 +885,7 @@ void StubTool::scanStubs_clusterWidth(unsigned int teststrip) // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { @@ -1122,7 +1122,7 @@ void StubTool::scanStubs_ptWidth() // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { @@ -1325,7 +1325,7 @@ void StubTool::scanStubs_SoF(unsigned int teststrip) // now read Events ReadNEvents(theBoard, fNevents); - const std::vector<Event*> cEvents = GetEvents(theBoard); + const std::vector<Event*> cEvents = GetEvents(); int countEvent = 0; for(auto cEvent: cEvents) { diff --git a/tools/Tool.cc b/tools/Tool.cc index c1c43c9c543a0fc7c6c0593cba4ee3418eb49378..33057f43633b11b5df11771f35c77a7a2d2f93d5 100644 --- a/tools/Tool.cc +++ b/tools/Tool.cc @@ -39,8 +39,8 @@ Tool::Tool() , fAllChan(false) , fMaskChannelsFromOtherGroups(false) , fTestPulse(false) - , fDoHybridBroadcast(false) , fDoBoardBroadcast(false) + , fDoHybridBroadcast(false) , fChannelGroupHandler(nullptr) { #ifdef __HTTP__ @@ -64,8 +64,8 @@ Tool::Tool(THttpServer* pHttpServer) , fAllChan(false) , fMaskChannelsFromOtherGroups(false) , fTestPulse(false) - , fDoHybridBroadcast(false) , fDoBoardBroadcast(false) + , fDoHybridBroadcast(false) , fChannelGroupHandler(nullptr) { } @@ -125,8 +125,8 @@ void Tool::Inherit(const Tool* pTool) fAllChan = pTool->fAllChan; fMaskChannelsFromOtherGroups = pTool->fMaskChannelsFromOtherGroups; fTestPulse = pTool->fTestPulse; - fDoHybridBroadcast = pTool->fDoHybridBroadcast; fDoBoardBroadcast = pTool->fDoBoardBroadcast; + fDoHybridBroadcast = pTool->fDoHybridBroadcast; #ifdef __HTTP__ fHttpServer = pTool->fHttpServer; @@ -1198,7 +1198,7 @@ class MeasureBeBoardDataPerGroup : public ScanBase void operator()() override { - uint16_t burstNumbers; + uint32_t burstNumbers; uint32_t lastBurstNumberOfEvents; if(fNumberOfEventsPerBurst <= 0) { @@ -1222,7 +1222,7 @@ class MeasureBeBoardDataPerGroup : public ScanBase if(burstNumbers == 1) currentNumberOfEvents = lastBurstNumberOfEvents; fTool->ReadNEvents(fDetectorContainer->at(fBoardIndex), currentNumberOfEvents); // Loop over Events from this Acquisition - const std::vector<Event*>& events = fTool->GetEvents(fDetectorContainer->at(fBoardIndex)); + const std::vector<Event*>& events = fTool->GetEvents(); for(auto& event: events) event->fillDataContainer((fDetectorDataContainer->at(fBoardIndex)), fTestChannelGroup); --burstNumbers; } @@ -1349,17 +1349,9 @@ void Tool::setAllGlobalDacBeBoard(uint16_t boardIndex, const std::string& dacNam void Tool::setAllLocalDacBeBoard(uint16_t boardIndex, const std::string& dacName, DetectorDataContainer& globalDACContainer) { for(auto cOpticalGroup: *(fDetectorContainer->at(boardIndex))) - { for(auto cHybrid: *cOpticalGroup) - { for(auto cChip: *cHybrid) - { - std::vector<uint16_t> dacVector; //= dacList.at(cHybrid->getHybridId()).at(cChip->getId()); fReadoutChipInterface->WriteChipAllLocalReg(cChip, dacName, *globalDACContainer.at(boardIndex)->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())); - } - } - } - return; } // Set same global DAC for all chips @@ -1372,18 +1364,12 @@ void Tool::setSameGlobalDac(const std::string& dacName, const uint16_t dacValue) void Tool::setSameGlobalDacBeBoard(BeBoard* pBoard, const std::string& dacName, const uint16_t dacValue) { if(fDoBoardBroadcast == false) - { for(auto cOpticalGroup: *pBoard) - { for(auto cHybrid: *cOpticalGroup) - { if(fDoHybridBroadcast == false) for(auto cChip: *cHybrid) fReadoutChipInterface->WriteChipReg(static_cast<ReadoutChip*>(cChip), dacName, dacValue); else fReadoutChipInterface->WriteHybridBroadcastChipReg(static_cast<Hybrid*>(cHybrid), dacName, dacValue); - } - } - } else fReadoutChipInterface->WriteBoardBroadcastChipReg(pBoard, dacName, dacValue); } diff --git a/tools/Tool.h b/tools/Tool.h index 7d1610492344cca42d77174a7f75bf3cd21c2c26..7643032a035e60c603a4a388cf2452b2052f86eb 100644 --- a/tools/Tool.h +++ b/tools/Tool.h @@ -333,8 +333,8 @@ class Tool : public Ph2_System::SystemController bool fAllChan; bool fMaskChannelsFromOtherGroups; bool fTestPulse; - bool fDoHybridBroadcast; bool fDoBoardBroadcast; + bool fDoHybridBroadcast; ChannelGroupHandler* fChannelGroupHandler; std::string getCalibrationName();