Commit 0a5a57bc authored by minime's avatar minime
Browse files

Merged with OT

parent ca93d222
......@@ -22,18 +22,20 @@ namespace Ph2_HwDescription
{
// C'tors which take BeId, FMCId, FeID, MPAId
MPA::MPA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pMPAId, const std::string& filename) : ReadoutChip(pBeId, pFMCId, pFeId, pMPAId)
MPA::MPA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pMPAId, uint8_t pPartnerId, const std::string& filename) : ReadoutChip(pBeId, pFMCId, pFeId, pMPAId)
{
fMaxRegValue = 255;
fChipOriginalMask = new ChannelGroup<1920>;
fPartnerId = pPartnerId;
loadfRegMap(filename);
setFrontEndType(FrontEndType::MPA);
}
MPA::MPA(const FrontEndDescription& pFeDesc, uint8_t pMPAId, const std::string& filename) : ReadoutChip(pFeDesc, pMPAId)
MPA::MPA(const FrontEndDescription& pFeDesc, uint8_t pMPAId, uint8_t pPartnerId, const std::string& filename) : ReadoutChip(pFeDesc, pMPAId)
{
fMaxRegValue = 255; // 8 bit registers in MPA
fChipOriginalMask = new ChannelGroup<1920>;
fPartnerId = pPartnerId;
loadfRegMap(filename);
setFrontEndType(FrontEndType::MPA);
}
......@@ -101,6 +103,7 @@ void MPA::loadfRegMap(const std::string& filename)
} // end loadfRegMap
void MPA::saveRegMap(const std::string& filename)
{ // start saveRegMap
......
......@@ -36,12 +36,13 @@ using CommentMap = std::map<int, std::string>;
class MPA : public ReadoutChip
{
public:
MPA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pMPAId, const std::string& filename);
MPA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pMPAId, uint8_t pPartnerId, const std::string& filename);
// C'tors with object FE Description
MPA(const FrontEndDescription& pFeDesc, uint8_t pMPAId, const std::string& filename);
MPA(const FrontEndDescription& pFeDesc, uint8_t pMPAId, uint8_t pPartnerId, const std::string& filename);
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;
......@@ -60,11 +61,13 @@ class MPA : public ReadoutChip
return 8;
}
std::pair<uint32_t, uint32_t> PNlocal(const uint32_t PN) { return std::pair<uint32_t, uint32_t>(PN / 120, PN % 120); }
// 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 ); }
uint32_t getNumberOfChannels() const override { return NMPACHANNELS; }
uint32_t PNglobal(std::pair<uint32_t, uint32_t> PC) { return PC.first * 120 + PC.second; }
uint32_t PNglobal(std::pair<uint32_t, uint32_t> PC) { return (PC.first) * 120 + (PC.second) +1; }
};
struct MPARegItemComparer
......
......@@ -22,18 +22,20 @@
namespace Ph2_HwDescription
{ // open namespace
SSA::SSA(const FrontEndDescription& pFeDesc, uint8_t pSSAId, 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;
loadfRegMap(filename);
setFrontEndType(FrontEndType::SSA);
}
SSA::SSA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pSSAId, uint8_t pSSASide, const std::string& filename) : ReadoutChip(pBeId, pFMCId, pFeId, pSSAId)
SSA::SSA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pSSAId, uint8_t pPartnerId, uint8_t pSSASide, const std::string& filename) : ReadoutChip(pBeId, pFMCId, pFeId, pSSAId)
{
fMaxRegValue = 255; // 8 bit registers in CBC
fChipOriginalMask = new ChannelGroup<120>;
fPartnerId = pPartnerId;
loadfRegMap(filename);
setFrontEndType(FrontEndType::SSA);
}
......@@ -104,6 +106,10 @@ void SSA::loadfRegMap(const std::string& filename)
} // end loadfRegMap
void SSA::saveRegMap(const std::string& filename)
{ // start saveRegMap
......
......@@ -35,10 +35,11 @@ class SSA : public ReadoutChip
{ // open class def
public:
// C'tors which take BeId, FMCId, FeID, SSAId
SSA(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pSSAId, uint8_t pSSASide, const std::string& filename);
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 pSSASide, const std::string& filename);
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;}
virtual void accept(HwDescriptionVisitor& pVisitor) { pVisitor.visitChip(*this); }
void loadfRegMap(const std::string& filename) override;
void saveRegMap(const std::string& filename) override;
......
......@@ -3700,6 +3700,164 @@ 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;
uint32_t pcf8574 = 1;
uint32_t dac7678 = 4;
std::this_thread::sleep_for(std::chrono::milliseconds(750));
PSInterfaceBoard_SetSlaveMap();
PSInterfaceBoard_ConfigureI2CMaster(1, SLOW);
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
float Vc = 0.0003632813;
LOG(INFO) << "mpa vdd on";
float Vlimit = 1.32;
if(VDDPST > Vlimit) VDDPST = Vlimit;
float diffvoltage = 1.5 - VDDPST;
uint32_t setvoltage = int(round(diffvoltage / Vc));
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;
if(VDDPST > Vlimit) VDDPST = Vlimit;
diffvoltage = 1.5 - VDDPST;
setvoltage = int(round(diffvoltage / Vc));
if(setvoltage > 4095) setvoltage = 4095;
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
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;
diffvoltage = 1.5 - DVDD;
setvoltage = int(round(diffvoltage / Vc));
if(setvoltage > 4095) setvoltage = 4095;
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x30, setvoltage); // tx to DAC C
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
LOG(INFO) << "ssa vddD on";
Vlimit = 1.32;
if(DVDD > Vlimit) DVDD = Vlimit;
diffvoltage = 1.5 - DVDD;
setvoltage = int(round(diffvoltage / Vc));
if(setvoltage > 4095) setvoltage = 4095;
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
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;
diffvoltage = 1.5 - AVDD;
setvoltage = int(round(diffvoltage / Vc));
if(setvoltage > 4095) setvoltage = 4095;
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x32, setvoltage); // tx to DAC C
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
LOG(INFO) << "ssa vddA on";
Vlimit = 1.32;
if(AVDD > Vlimit) AVDD = Vlimit;
diffvoltage = 1.5 - AVDD;
setvoltage = int(round(diffvoltage / Vc));
if(setvoltage > 4095) setvoltage = 4095;
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
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;
float Vc2 = 4095 / 1.5;
setvoltage = int(round(VBG * Vc2));
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x36, setvoltage); // tx to DAC C
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
/*LOG(INFO) << "ssa VBG on";
Vlimit = 1.32;
if(VBG > Vlimit) VBG = Vlimit;
Vc2 = 4095 / 1.5;
setvoltage = int(round(VBG * Vc2));
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x36, setvoltage); // tx to DAC C
std::this_thread::sleep_for(std::chrono::milliseconds(1000));*/
LOG(INFO) << "ssa VBF on";
Vlimit = 0.5;
if(VBF > Vlimit) VBF = Vlimit;
setvoltage = int(round(VBF * Vc2));
setvoltage = setvoltage << 4;
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x01); // to SCO on PCA9646
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
PSInterfaceBoard_SendI2CCommand(dac7678, 0, write, 0x37, setvoltage); // tx to DAC C
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x02);
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
PSInterfaceBoard_SendI2CCommand(i2cmux, 0, write, 0, 0x02); // route to 2nd PCF8574
std::this_thread::sleep_for(std::chrono::milliseconds(500));
PSInterfaceBoard_SendI2CCommand(pcf8574, 0, write, 0, val2); // set reset bit
std::this_thread::sleep_for(std::chrono::milliseconds(1000));*/
// 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;
......
......@@ -655,6 +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);
// 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);
......
......@@ -127,8 +127,9 @@ bool MPAInterface::WriteChipAllLocalReg(ReadoutChip* pMPA, const std::string& da
assert(localRegValues.size() == pMPA->getNumberOfChannels());
std::string dacTemplate;
if(dacName == "TrimDAC_P") dacTemplate = "TrimDAC_P%d";
if(dacName == "ThresholdTrim")
if(dacName == "TrimDAC_P")
dacTemplate = "TrimDAC_P%d";
else if(dacName == "ThresholdTrim")
dacTemplate = "TrimDAC_P%d";
else
LOG(ERROR) << "Error, DAC " << dacName << " is not a Local DAC";
......@@ -164,10 +165,12 @@ bool MPAInterface::ConfigureChip(Chip* pMPA, bool pVerifLoop, uint32_t pBlockSiz
#endif
// LOG (INFO) << BOLDRED << "Write "<<cRegItem.first<< RESET;
fBoardFW->EncodeReg(cRegItem.second, pMPA->getHybridId(), pMPA->getId(), cVec, pVerifLoop, true);
bool cSuccess = fBoardFW->WriteChipBlockReg(cVec, cWriteAttempts, pVerifLoop);
if(cSuccess)
{
auto cReadBack = ReadChipReg(pMPA, cRegItem.first);
//LOG(INFO) << BOLDRED << cRegItem.first<<" "<<cReadBack<<","<<cRegItem.second.fValue << RESET;
if(cReadBack != cRegItem.second.fValue)
{
std::size_t found = (cRegItem.first).find("ReadCounter");
......@@ -367,7 +370,7 @@ void MPAInterface::Activate_pp(Chip* pMPA) { this->WriteChipReg(pMPA, "ECM", 0x8
void MPAInterface::Activate_ss(Chip* pMPA) { this->WriteChipReg(pMPA, "ECM", 0x41); }
void MPAInterface::Activate_ps(Chip* pMPA) { this->WriteChipReg(pMPA, "ECM", 0x8); }
void MPAInterface::Activate_ps(Chip* pMPA, uint8_t win) { this->WriteChipReg(pMPA, "ECM", win); }
void MPAInterface::Pix_Smode(ReadoutChip* pMPA, uint32_t p, std::string smode = "edge")
{
......
......@@ -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);
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);
......
......@@ -7,6 +7,7 @@
#include <netinet/in.h> // inet_aton, struct sockaddr_in
#include <strings.h> // bzero
#include <thread>
#include <sstream>
//========================================================================================================================
TCPClientBase::TCPClientBase(const std::string& serverIP, int serverPort) : fServerIP(serverIP), fServerPort(serverPort), fConnected(false) {}
......
......@@ -474,6 +474,7 @@ void FileParser::parseSSAContainer(pugi::xml_node pSSAnode, Hybrid* pHybrid, std
// Get ID of SSA then add to the Hybrid!
uint32_t cChipId = pSSAnode.attribute("Id").as_int();
uint32_t cPartnerId = pSSAnode.attribute("partid").as_int();
std::string cFileName;
if(!cFilePrefix.empty())
{
......@@ -483,7 +484,7 @@ void FileParser::parseSSAContainer(pugi::xml_node pSSAnode, Hybrid* pHybrid, std
}
else
cFileName = expandEnvironmentVariables(pSSAnode.attribute("configfile").value());
ReadoutChip* cSSA = pHybrid->addChipContainer(cChipId, new SSA(pHybrid->getBeBoardId(), pHybrid->getFMCId(), pHybrid->getId(), cChipId, 0, cFileName));
ReadoutChip* cSSA = pHybrid->addChipContainer(cChipId, new SSA(pHybrid->getBeBoardId(), pHybrid->getFMCId(), pHybrid->getId(), cChipId, cPartnerId, 0, cFileName));
cSSA->setNumberOfChannels(120);
this->parseSSASettings(pSSAnode, cSSA);
}
......@@ -496,6 +497,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 cPartnerId = pHybridNode.attribute("partid").as_int();
std::string cFileName;
if(!cFilePrefix.empty())
{
......@@ -505,7 +507,7 @@ void FileParser::parseMPA(pugi::xml_node pHybridNode, Hybrid* pHybrid, std::stri
}
else
cFileName = expandEnvironmentVariables(pHybridNode.attribute("configfile").value());
ReadoutChip* cMPA = pHybrid->addChipContainer(cChipId, new MPA(pHybrid->getBeBoardId(), pHybrid->getFMCId(), pHybrid->getId(), cChipId, cFileName));
ReadoutChip* cMPA = pHybrid->addChipContainer(cChipId, new MPA(pHybrid->getBeBoardId(), pHybrid->getFMCId(), pHybrid->getId(), cChipId, cPartnerId, cFileName));
cMPA->setNumberOfChannels(1920);
this->parseMPASettings(pHybridNode, cMPA);
}
......
......@@ -464,7 +464,6 @@ void SystemController::ReadNEvents(BeBoard* pBoard, uint32_t pNEvents, std::vect
uint32_t cMultiplicity = 0;
if(fBeBoardInterface->getBoardType(pBoard) == BoardType::D19C) cMultiplicity = fBeBoardInterface->ReadBoardReg(pBoard, "fc7_daq_cnfg.fast_command_block.misc.trigger_multiplicity");
pNEvents = pNEvents * (cMultiplicity + 1);
this->DecodeData(pBoard, pData, pNEvents, fBeBoardInterface->getBoardType(pBoard));
}
......@@ -493,8 +492,8 @@ void SystemController::ReadASEvent(BeBoard* pBoard, uint32_t pNMsec, uint32_t pu
{
for(auto cChip: *cHybrid)
{
if(pBoard->getFrontEndType() == FrontEndType::MPA) static_cast<MPAInterface*>(fReadoutChipInterface)->ReadASEvent(cChip, cData);
if(pBoard->getFrontEndType() == FrontEndType::SSA) static_cast<SSAInterface*>(fReadoutChipInterface)->ReadASEvent(cChip, cData);
if(cChip->getFrontEndType() == FrontEndType::MPA) static_cast<MPAInterface*>(fReadoutChipInterface)->ReadASEvent(cChip, cData);
if(cChip->getFrontEndType() == FrontEndType::SSA) static_cast<SSAInterface*>(fReadoutChipInterface)->ReadASEvent(cChip, cData);
}
}
}
......@@ -539,25 +538,26 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3
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;
uint32_t maxind = 0;
if(pBoard->getFrontEndType() == FrontEndType::SSA)
{
uint16_t nSSA = (fEventSize - D19C_EVENT_HEADER1_SIZE_32_SSA) / D19C_EVENT_SIZE_32_SSA / fNFe;
if(fEventType == EventType::SSAAS) nSSA = pData.size() / 120;
for(auto opticalGroup: *pBoard)
{
//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)
{
for(auto chip: *hybrid)
{
// LOG (INFO) << BOLDBLUE <<chip->getId()+hybrid->getId()*nSSA <<RESET;
maxind = std::max(maxind, uint32_t(chip->getId() + hybrid->getId() * nSSA));
}
maxind = std::max(maxind, uint32_t(hybrid->size()));
}
}
// LOG (INFO) << BOLDBLUE << "maxind " << maxind << RESET;
}
if(fEventType == EventType::SSAAS) { fEventList.push_back(new D19cSSAEventAS(pBoard, pData)); }
......@@ -573,6 +573,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)
{
......@@ -587,18 +588,11 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3
}
else if(pBoard->getFrontEndType() == FrontEndType::SSA)
{
// LOG (INFO) << BOLDBLUE << "Decoding SSA data " << RESET;
// auto cL1Counter0 = (cEvent[4+2] & (0xF<<16)) >> 16;
// auto cL1Counter1 = (cEvent[4+8+4+2] & (0xF<<16)) >> 16;
// LOG (INFO) << BOLDBLUE << "L1A counter chip0 : " << cL1Counter0 << RESET;
// LOG (INFO) << BOLDBLUE << "L1A counter chip1 : " << cL1Counter1 << RESET;
// for(auto cWord : cEvent )
// LOG (INFO) << BOLDMAGENTA << std::bitset<32>(cWord) << RESET;
fEventList.push_back(new D19cSSAEvent(pBoard, maxind + 1, fNFe, cEvent));
fEventList.push_back(new D19cSSAEvent(pBoard, maxind, fNFe, cEvent));
}
else if(pBoard->getFrontEndType() == FrontEndType::MPA)
{
fEventList.push_back(new D19cMPAEvent(pBoard, maxind + 1, fNFe, cEvent));
fEventList.push_back(new D19cMPAEvent(pBoard, maxind, fNFe, cEvent));
}
cEventIndex++;
}
......
......@@ -368,8 +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);
}
......@@ -384,8 +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);
}
......
......@@ -24,7 +24,7 @@ namespace Ph2_HwInterface
D19cMPAEvent::D19cMPAEvent(const BeBoard* pBoard, uint32_t pNMPA, uint32_t pNFe, const std::vector<uint32_t>& list) : fEventDataVector(pNMPA * pNFe)
{
fNSSA = pNMPA;
fNMPA = pNMPA;
SetEvent(pBoard, pNMPA, list);
}
......@@ -52,81 +52,68 @@ void D19cMPAEvent::fillDataContainer(BoardDataContainer* boardContainer, const C
void D19cMPAEvent::SetEvent(const BeBoard* pBoard, uint32_t pNMPA, const std::vector<uint32_t>& list)
{
uint8_t fMaxHybrids = 0;
uint16_t cH1size_32_MPA = 4;
uint16_t index = cH1size_32_MPA;
std::set<uint16_t> HybridIds;
while(index < list.size())
{
uint16_t cSPLeading = ((0xF0000000 & list.at(index)) >> 28);
if(cSPLeading != 0x5 and cSPLeading != 0xA) break;
uint16_t fHID = ((0x00FF0000 & list.at(index)) >> 16);
if(HybridIds.find(fHID) == HybridIds.end())
{
fMaxHybrids += 1;
HybridIds.insert(fHID);
}
index += ((0x00000FFF & list.at(index))) * 4;
}
// 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));
// std::cout<<fEventSize<<","<<list.size()<<std::endl;
if(fEventSize != list.size()) LOG(ERROR) << "Incorrect event size";
uint16_t cLeading = ((0xFFFF0000 & list.at(0)) >> 16);
if(cLeading != 0xFFFF) LOG(ERROR) << "Incorrect leading bits";
// not iterate through hybrids
uint32_t address_offset = D19C_EVENT_HEADER1_SIZE_32_MPA;
uint32_t data_offset = address_offset;
// iterating through the first hybrid chips
for(uint8_t pFeId = 0; pFeId < fMaxHybrids; pFeId++)
for(auto cOpticalGroup: *pBoard)
{
for(uint8_t pMPAId = 0; pMPAId < pNMPA; pMPAId++)
for(auto cHybrid: *cOpticalGroup)
{
uint8_t cPLeadingMPA = ((0xF0000000 & list.at(data_offset)) >> 28);
uint8_t cErrorMPA = ((0x0F000000 & list.at(data_offset)) >> 24);
uint8_t cFeId = ((0x00FF0000 & list.at(data_offset)) >> 16);
// uint8_t cCidMPA = ((0x0000F000 & list.at (data_offset)) >> 16 );
uint16_t cL1size_32_MPA = ((0x00000FFF & list.at(data_offset))) * 4;
// uint16_t cFrameDelay = (0x00000FFF & list.at (data_offset+1)) ;
// uint8_t cChipType = (0x0000F000 & list.at (data_offset+1)) ;
uint8_t cSsize_32_MPA = 0;
cSsize_32_MPA = ((0x00000FFF & list.at(data_offset + cL1size_32_MPA))) * 4;
uint8_t cSLeadingMPA = ((0xF0000000 & list.at(data_offset + cL1size_32_MPA)) >> 28);
// uint16_t cSdelay = ((0x00FFF000 & list.at (data_offset+cL1size_32_MPA))>>12);
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);
if(cSLeadingMPA != 0x5) LOG(ERROR) << "Incorrect stub header for MPA " << unsigned(pMPAId);
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, pNMPA);
uint32_t begin = data_offset;
uint16_t cFevSize = cL1size_32_MPA + cSsize_32_MPA;
uint32_t end = begin + cFevSize;
// std::vector<uint32_t> cMPAData (std::next (std::begin (list), begin), std::next (std::begin (list), end)
// );
fEventDataVector[cKey] = std::vector<uint32_t>(std::next(std::begin(list), begin), std::next(std::begin(list), end));
// LOG (INFO) << "Size "<<fEventDataVector[cKey].size()<< RESET;
data_offset += cFevSize;
for(auto cChip: *cHybrid)
{
uint8_t pMPAId = cChip->getId();
if (cChip->getFrontEndType() != FrontEndType::MPA) continue;
uint8_t cPLeadingMPA = ((0xF0000000 & list.at(data_offset)) >> 28);
uint8_t cErrorMPA = ((0x0F000000 & list.at(data_offset)) >> 24);
uint8_t cFeId = ((0x00FF0000 & list.at(data_offset)) >> 16);
// uint8_t cCidMPA = ((0x0000F000 & list.at (data_offset)) >> 16 );
uint16_t cL1size_32_MPA = ((0x00000FFF & list.at(data_offset))) * 4;