Commit 7f206721 authored by minime's avatar minime
Browse files

Merged with OT

parent 0a5a57bc
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
......@@ -5,9 +5,9 @@
#include <iostream>
#include <netdb.h>
#include <netinet/in.h> // inet_aton, struct sockaddr_in
#include <strings.h> // bzero
#include <thread>
#include <sstream>
#include <strings.h> // bzero
#include <thread>
//========================================================================================================================
TCPClientBase::TCPClientBase(const std::string& serverIP, int serverPort) : fServerIP(serverIP), fServerPort(serverPort), fConnected(false) {}
......
......@@ -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())
......
......@@ -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;
......@@ -518,6 +518,9 @@ 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();
......@@ -525,6 +528,9 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3
RD53FWInterface::Event::addBoardInfo2Events(pBoard, RD53FWInterface::decodedEvents);
for(auto& evt: RD53FWInterface::decodedEvents) fEventList.push_back(&evt);
}
// ####################
// # Decoding OT data #
// ####################
else if(pType == BoardType::D19C)
{
for(auto& pevt: fEventList) delete pevt;
......@@ -537,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)); }
......@@ -573,7 +571,6 @@ 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)
{
......
......@@ -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);
}
......
......@@ -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
}
}