18#include <fairlogger/Logger.h>
25 switch (mappingtype) {
27 mMappingFile = Form(
"%s/share/Detectors/FOC/files/mapping_ib.data", gSystem->Getenv(
"O2_ROOT"));
30 mMappingFile = Form(
"%s/share/Detectors/FOC/files/mapping_ob.data", gSystem->Getenv(
"O2_ROOT"));
35 if (mMappingFile.length()) {
40void PixelMapper::init()
42 if (gSystem->AccessPathName(mMappingFile.data())) {
43 throw MappingNotSetException();
45 LOG(
debug) <<
"Reading pixel mapping from file: " << mMappingFile;
47 std::ifstream reader(mMappingFile);
49 while (std::getline(reader,
buffer)) {
50 auto delimiter =
buffer.find(
"//");
56 if (delimiter != std::string::npos) {
60 std::stringstream decoder(
data);
61 std::string linebuffer;
62 std::vector<int> identifiers;
63 while (std::getline(decoder, linebuffer,
',')) {
64 identifiers.push_back(std::stoi(linebuffer));
66 if (identifiers.size() < 8) {
67 LOG(error) <<
"Chip coordinates not fully defined (" <<
data <<
"), skipping ...";
69 ChipIdentifier nextIdentifier;
70 nextIdentifier.mFEEID = identifiers[0];
71 nextIdentifier.mLaneID = identifiers[1];
72 nextIdentifier.mChipID = identifiers[2];
73 ChipPosition nextPosition;
74 nextPosition.mLayer = identifiers[3];
75 nextPosition.mColumn = identifiers[4];
76 nextPosition.mRow = identifiers[5];
77 nextPosition.mInvertColumn = (identifiers[6] == 1 ? true :
false);
78 nextPosition.mInvertRow = (identifiers[7] == 1 ? true :
false);
79 LOG(
debug) <<
"Inserting chip: (FEE " << nextIdentifier.mFEEID <<
", Lane " << nextIdentifier.mLaneID <<
", Chip " << nextIdentifier.mChipID <<
") -> (Layer " << nextPosition.mLayer <<
", Col " << nextPosition.mColumn <<
", Row " << nextPosition.mRow <<
", Inv Col " << (nextPosition.mInvertColumn ?
"yes" :
"no") <<
", Inv Row " << (nextPosition.mInvertRow ?
"yes" :
"no") <<
")";
80 if (mMapping.find(nextIdentifier) != mMapping.end()) {
81 LOG(error) <<
"Chip with FEE" << nextIdentifier.mFEEID <<
", Lane " << nextIdentifier.mLaneID <<
", Chip " << nextIdentifier.mChipID <<
" already present, not overwriting ...";
84 mMapping.insert({nextIdentifier, nextPosition});
85 if (nextPosition.mRow + 1 > mNumberOfRows) {
86 mNumberOfRows = nextPosition.mRow + 1;
88 if (nextPosition.mColumn + 1 > mNumberOfColumns) {
89 mNumberOfColumns = nextPosition.mColumn + 1;
92 LOG(info) <<
"Pixel Mapper: Found " << mMapping.size() <<
" chips, in " << mNumberOfColumns <<
" colums and " << mNumberOfRows <<
" rows";
98 auto cardindex = feeID & 0x00FF;
101 auto found = mMapping.find(identifier);
102 if (found == mMapping.end()) {
105 return found->second;
108void PixelMapper::checkInitialized()
const
110 if (!mMapping.size()) {
111 throw UninitException();
void print(std::ostream &stream) const
void print(std::ostream &stream) const
void print(std::ostream &stream) const
ChipPosition getPosition(unsigned int feeID, unsigned int laneID, unsigned int chipID) const
PixelMapper(MappingType_t mappingtype)
std::ostream & operator<<(std::ostream &in, const IndexExceptionEvent &error)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"