Commit 22cb5a1e authored by Kevin Connor Nash's avatar Kevin Connor Nash
Browse files

Included ChannelGroup per chip, not tested

parent 2ef442b3
......@@ -11,6 +11,8 @@
#include "../MonitorUtils/CBCMonitor.h"
#include "../MonitorUtils/DetectorMonitor.h"
#include "../MonitorUtils/RD53Monitor.h"
#include "../Utils/ContainerFactory.h"
#include "../Utils/ChannelGroupHandler.h"
using namespace Ph2_HwDescription;
using namespace Ph2_HwInterface;
......@@ -86,6 +88,8 @@ void SystemController::Destroy()
delete fPowerSupplyClient;
fPowerSupplyClient = nullptr;
fChannelGroupHandlerContainer.reset();
LOG(INFO) << BOLDRED << ">>> Interfaces destroyed <<<" << RESET;
}
......@@ -131,6 +135,8 @@ void SystemController::InitializeHw(const std::string& pFilename, std::ostream&
this->fParser.parseHW(pFilename, fBeBoardFWMap, fDetectorContainer, os, pIsFile);
fBeBoardInterface = new BeBoardInterface(fBeBoardFWMap);
ContainerFactory::copyAndInitChip<std::shared_ptr<ChannelGroupHandler>>(*fDetectorContainer, fChannelGroupHandlerContainer);
fPowerSupplyClient = new TCPClient("127.0.0.1", 7000);
if(!fPowerSupplyClient->connect(1))
{
......@@ -1240,4 +1246,34 @@ void SystemController::DecodeData(const BeBoard* pBoard, const std::vector<uint3
} // end zero check
}
}
} // namespace Ph2_System
void SystemController::setChannelGroupHandler(ChannelGroupHandler& theChannelGroupHandler, std::function<bool(const ChipContainer*)> theQueryFunction)
{
auto theChannelGroupHandlerPointer = std::shared_ptr<ChannelGroupHandler>(&theChannelGroupHandler);
fDetectorContainer->setReadoutChipQueryFunction(theQueryFunction);
for(const auto board : *fDetectorContainer)
{
for(const auto opticalGroup : *board)
{
for(const auto hybrid : *opticalGroup)
{
for(const auto chip : *hybrid)
{
fChannelGroupHandlerContainer.getObject(board->getId())->getObject(opticalGroup->getId())->getObject(hybrid->getId())->getObject(chip->getId())->getSummary<std::shared_ptr<ChannelGroupHandler>>() = theChannelGroupHandlerPointer;
}
}
}
}
fDetectorContainer->resetReadoutChipQueryFunction();
return;
}
void SystemController::setChannelGroupHandler(ChannelGroupHandler& theChannelGroupHandler, FrontEndType theFrontEndType)
{
auto selectChipFlavourFunction = [theFrontEndType](const ChipContainer* theChip) { return (static_cast<const ReadoutChip*>(theChip)->getFrontEndType() == theFrontEndType); };
setChannelGroupHandler(theChannelGroupHandler, selectChipFlavourFunction);
return;
}
} // namespace Ph2_System
\ No newline at end of file
......@@ -59,6 +59,7 @@
#endif
class DetectorMonitor;
class ChannelGroupHandler;
/*!
* \namespace Ph2_System
......@@ -311,6 +312,13 @@ class SystemController
uint32_t fEventSize;
uint32_t fNCbc;
FileParser fParser;
protected:
DetectorDataContainer fChannelGroupHandlerContainer;
void setChannelGroupHandler(ChannelGroupHandler& theChannelGroupHandler, std::function<bool(const ChipContainer*)> theQueryFunction = [](const ChipContainer*){return true;});
void setChannelGroupHandler(ChannelGroupHandler& theChannelGroupHandler, FrontEndType theFrontEndType);
};
} // namespace Ph2_System
......
......@@ -206,12 +206,15 @@ class ChannelGroupHandler
const ChannelGroupBase* allChannelGroup() const { return allChannelGroup_; }
virtual ChannelGroupBase* getTestGroup(uint32_t groupNumber) const
virtual const ChannelGroupBase* getTestGroup(int groupNumber) const
{
if(groupNumber<0) return allChannelGroup();
allChannelGroup_->makeTestGroup(currentChannelGroup_, groupNumber, numberOfClustersPerGroup_, numberOfRowsPerCluster_, numberOfColsPerCluster_);
return currentChannelGroup_;
}
uint16_t getNumberOfGroups() const {return numberOfGroups_;};
protected:
uint32_t numberOfGroups_;
uint32_t numberOfClustersPerGroup_;
......
......@@ -81,6 +81,12 @@ class Container
return idObjectMap_[id];
}
const T* getObject(uint16_t id) const
{
if(idObjectMap_.find(id) == idObjectMap_.end()) throw Exception("T* getObject(uint16_t id) : Object Id not found");
return idObjectMap_.at(id);
}
void cleanDataStored() override
{
for(auto container: *this) { container->cleanDataStored(); }
......
......@@ -47,7 +47,7 @@ D19cCbc3Event::D19cCbc3Event(const BeBoard* pBoard, const std::vector<uint32_t>&
// SetEvent (pBoard, fNCbc, list );
}
void D19cCbc3Event::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cCbc3Event::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -56,6 +56,9 @@ void D19cCbc3Event::fillDataContainer(BoardDataContainer* boardContainer, const
for(auto chip: *hybrid)
{
unsigned int i = 0;
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
for(ChannelDataContainer<Occupancy>::iterator channel = chip->begin<Occupancy>(); channel != chip->end<Occupancy>(); channel++, i++)
{
if(cTestChannelGroup->isChannelEnabled(i)) { channel->fOccupancy += (float)privateDataBit(hybrid->getId(), chip->getId(), i); }
......
......@@ -201,7 +201,7 @@ class D19cCbc3Event : public Event
std::vector<Cluster> getClusters(uint8_t pFeId, uint8_t pCbcId) const override;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
void print(std::ostream& out) const override;
......
......@@ -18,7 +18,7 @@ using namespace Ph2_HwDescription;
namespace Ph2_HwInterface
{
void D19cCbc3EventZS::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cCbc3EventZS::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -26,6 +26,9 @@ void D19cCbc3EventZS::fillDataContainer(BoardDataContainer* boardContainer, cons
{
for(auto chip: *hybrid)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
unsigned int i = 0;
for(ChannelContainer<Occupancy>::iterator channel = chip->begin<Occupancy>(); channel != chip->end<Occupancy>(); channel++, i++)
{
......
......@@ -161,7 +161,7 @@ class D19cCbc3EventZS : public Event
std::vector<Cluster> getClusters(uint8_t pFeId, uint8_t pCbcId) const override;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
void print(std::ostream& out) const override;
......
......@@ -356,7 +356,7 @@ void D19cCic2Event::Set(const BeBoard* pBoard, const std::vector<uint32_t>& pDat
cNEvents++;
} while(cEventIterator < pData.end());
}
void D19cCic2Event::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cCic2Event::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -365,6 +365,9 @@ void D19cCic2Event::fillDataContainer(BoardDataContainer* boardContainer, const
// LOG(INFO) << BOLDBLUE << "Filling data container for hybrid " << +hybrid->getId() << RESET;
for(auto chip: *hybrid)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
std::vector<uint32_t> cHits = this->GetHits(hybrid->getId(), chip->getId());
// LOG(INFO) << BOLDBLUE << "Filling data container for chip " << +chip->getId()
// << " at index " << +chip->getIndex()
......
......@@ -200,7 +200,7 @@ class D19cCic2Event : public Event
std::vector<SCluster> GetStripClusters(uint8_t pFeId, uint8_t pMPAId) const;
std::vector<PCluster> GetPixelClusters(uint8_t pFeId, uint8_t pMPAId) const;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
void print(std::ostream& out) const override;
uint16_t L1Status(uint8_t pFeId) const;
......
......@@ -28,7 +28,7 @@ D19cMPAEvent::D19cMPAEvent(const BeBoard* pBoard, uint32_t pNMPA, uint32_t pNFe,
SetEvent(pBoard, pNMPA, list);
}
void D19cMPAEvent::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cMPAEvent::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -39,6 +39,9 @@ void D19cMPAEvent::fillDataContainer(BoardDataContainer* boardContainer, const C
unsigned int i = 0;
for(ChannelDataContainer<Occupancy>::iterator channel = chip->begin<Occupancy>(); channel != chip->end<Occupancy>(); channel++, i++)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
if(cTestChannelGroup->isChannelEnabled(i))
{
// TOFIX
......
......@@ -128,7 +128,7 @@ class D19cMPAEvent : public Event
* \return Glib flag string
*/
std::vector<Cluster> getClusters(uint8_t pFeId, uint8_t pCbcId) const override;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
std::string GlibFlagString(uint8_t pFeId, uint8_t pCbcId) const override;
/*!
* \brief Function to get Stub bit
......
......@@ -96,7 +96,7 @@ void D19cMPAEventAS::Set(const BeBoard* pBoard, const std::vector<uint32_t>& pDa
} // opticalGroup
}
// required by event but not sure if makes sense for AS
void D19cMPAEventAS::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cMPAEventAS::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -105,6 +105,8 @@ void D19cMPAEventAS::fillDataContainer(BoardDataContainer* boardContainer, const
for(auto chip: *hybrid)
{
if(chip->size() != 16 * 120) continue;
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
std::vector<uint32_t> cHits = GetHits(hybrid->getId(), chip->getId());
float cOcc = 0;
......
......@@ -25,7 +25,7 @@ class D19cMPAEventAS : public Event
std::vector<uint32_t> GetHits(uint8_t pFeId, uint8_t pMPAId) const override;
EventDataVector fEventDataVector;
static constexpr size_t encodeVectorIndex(const uint8_t pFeId, const uint8_t pCbcId, const uint8_t numberOfCBCs) { return pCbcId + pFeId * numberOfCBCs; }
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
inline bool privateDataBit(uint8_t pFeId, uint8_t pMPAId, uint8_t i) const;
size_t getFeIndex(const uint8_t pFeId) const
......
......@@ -129,13 +129,9 @@ void D19cPSEventAS::Set(const BeBoard* pBoard, const std::vector<uint32_t>& pDat
}// opticalGroup*/
}
// required by event but not sure if makes sense for AS
void D19cPSEventAS::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cPSEventAS::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
if(cTestChannelGroup == nullptr)
{
LOG(INFO) << BOLDRED << "!!!!" << RESET;
return;
}
// LOG (INFO) << cTestChannelGroup->getNumberOfRows() << " : " << cTestChannelGroup->getNumberOfCols() << RESET;
for(auto opticalGroup: *boardContainer)
{
......@@ -143,6 +139,9 @@ void D19cPSEventAS::fillDataContainer(BoardDataContainer* boardContainer, const
{
for(auto chip: *hybrid)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
std::vector<uint32_t> cHits = GetHits(hybrid->getId(), chip->getId());
float cOcc = 0;
size_t cChnl = 0;
......
......@@ -25,7 +25,7 @@ class D19cPSEventAS : public Event
std::vector<uint32_t> GetHits(uint8_t pFeId, uint8_t pMPAId) const override;
EventDataVector fEventDataVector;
static constexpr size_t encodeVectorIndex(const uint8_t pFeId, const uint8_t pCbcId, const uint8_t numberOfCBCs) { return pCbcId + pFeId * numberOfCBCs; }
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
inline bool privateDataBit(uint8_t pFeId, uint8_t pMPAId, uint8_t i) const;
size_t getFeIndex(const uint8_t pFeId) const
......
......@@ -14,7 +14,7 @@ D19cSSA2Event::D19cSSA2Event(const BeBoard* pBoard, uint32_t pNSSA2, uint32_t pN
fNSSA2 = pNSSA2;
SetEvent(pBoard, pNSSA2, list);
}
void D19cSSA2Event::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cSSA2Event::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -22,6 +22,9 @@ void D19cSSA2Event::fillDataContainer(BoardDataContainer* boardContainer, const
{
for(auto chip: *hybrid)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
unsigned int i = 0;
for(ChannelDataContainer<Occupancy>::iterator channel = chip->begin<Occupancy>(); channel != chip->end<Occupancy>(); channel++, i++)
{
......
......@@ -37,7 +37,7 @@ class D19cSSA2Event : public Event
uint32_t GetSSA2L1Counter(uint8_t pFeId, uint8_t pSSA2Id) const;
std::vector<uint32_t> GetHits(uint8_t pFeId, uint8_t pSSA2Id) const override;
std::vector<Cluster> getClusters(uint8_t pFeId, uint8_t pSSA2Id) const override;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
void print(std::ostream& out) const override;
bool DataBit(uint8_t pFeId, uint8_t pSSA2Id, uint32_t i) const override { return privateDataBit(pFeId, pSSA2Id, i); };
inline bool privateDataBit(uint8_t pFeId, uint8_t pSSA2Id, uint8_t i) const
......
......@@ -14,7 +14,7 @@ D19cSSAEvent::D19cSSAEvent(const BeBoard* pBoard, uint32_t pNSSA, uint32_t pNFe,
fNSSA = pNSSA;
SetEvent(pBoard, pNSSA, list);
}
void D19cSSAEvent::fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup)
void D19cSSAEvent::fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber)
{
for(auto opticalGroup: *boardContainer)
{
......@@ -22,6 +22,9 @@ void D19cSSAEvent::fillDataContainer(BoardDataContainer* boardContainer, const C
{
for(auto chip: *hybrid)
{
auto cTestChannelGroup = getChannelGroup(theChannelGroupHandler, groupNumber, opticalGroup->getId(), hybrid->getId(), chip->getId());
if(cTestChannelGroup == nullptr) continue;
unsigned int i = 0;
for(ChannelDataContainer<Occupancy>::iterator channel = chip->begin<Occupancy>(); channel != chip->end<Occupancy>(); channel++, i++)
{
......
......@@ -36,7 +36,7 @@ class D19cSSAEvent : public Event
uint32_t GetSSAL1Counter(uint8_t pFeId, uint8_t pSSAId) const;
std::vector<uint32_t> GetHits(uint8_t pFeId, uint8_t pSSAId) const override;
std::vector<Cluster> getClusters(uint8_t pFeId, uint8_t pSSAId) const override;
void fillDataContainer(BoardDataContainer* boardContainer, const ChannelGroupBase* cTestChannelGroup) override;
void fillDataContainer(BoardDataContainer* boardContainer, const BoardDataContainer* theChannelGroupHandler, int groupNumber) override;
void print(std::ostream& out) const override;
bool DataBit(uint8_t pFeId, uint8_t pSSAId, uint32_t i) const override { return privateDataBit(pFeId, pSSAId, i); };
inline bool privateDataBit(uint8_t pFeId, uint8_t pSSAId, uint8_t i) const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment