Skip to content

Commit dc5b88a

Browse files
authored
[FOCAL] Add mapping for pixels + geometry histos (#1552)
- Testbeam setup for FOCAL pixels Nov. 22 (2 layers, 7 cols x 6 rows each) - Adding histograms for + hit profile (average number of hits / chip) + hit map (sum number of hits / chip) + hit distribution (number of hits / chip) + Total number of hits / trigger + Number of hits in layer / trigger - Add FOCAL decoding objects to LinkDef
1 parent 1611bb4 commit dc5b88a

6 files changed

Lines changed: 397 additions & 13 deletions

File tree

Modules/FOCAL/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
add_library(O2QcFOCAL)
44

5-
target_sources(O2QcFOCAL PRIVATE src/LaneData.cxx src/PadWord.cxx src/PadData.cxx src/PadDecoder.cxx src/PadMapper.cxx src/PixelHit.cxx src/PixelChip.cxx src/PixelDecoder.cxx src/TestbeamRawTask.cxx)
5+
target_sources(O2QcFOCAL PRIVATE src/LaneData.cxx src/PadWord.cxx src/PadData.cxx src/PadDecoder.cxx src/PadMapper.cxx src/PixelHit.cxx src/PixelChip.cxx src/PixelDecoder.cxx src/PixelMapper.cxx src/TestbeamRawTask.cxx)
66

77
target_include_directories(
88
O2QcFOCAL
@@ -20,6 +20,12 @@ install(TARGETS O2QcFOCAL
2020
add_root_dictionary(O2QcFOCAL
2121
HEADERS
2222
include/FOCAL/TestbeamRawTask.h
23+
include/FOCAL/PixelMapper.h
24+
include/FOCAL/PixelDecoder.h
25+
include/FOCAL/PadData.h
26+
include/FOCAL/PadMapper.h
27+
include/FOCAL/LaneData.h
28+
include/FOCAL/PadDecoder.h
2329
LINKDEF include/FOCAL/LinkDef.h)
2430

2531
install(

Modules/FOCAL/include/FOCAL/LinkDef.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,15 @@
44
#pragma link off all functions;
55

66
#pragma link C++ class o2::quality_control_modules::focal::TestbeamRawTask + ;
7+
#pragma link C++ class o2::quality_control_modules::focal::PixelMapper + ;
8+
#pragma link C++ class o2::quality_control_modules::focal::PixelMapping + ;
9+
#pragma link C++ class o2::quality_control_modules::focal::PixelDecoder + ;
10+
#pragma link C++ class o2::quality_control_modules::focal::PadMapper + ;
11+
#pragma link C++ class o2::quality_control_modules::focal::PadDecoder + ;
12+
#pragma link C++ class o2::quality_control_modules::focal::LaneHandler + ;
13+
#pragma link C++ class o2::quality_control_modules::focal::LanePayload + ;
14+
#pragma link C++ class o2::quality_control_modules::focal::PadData + ;
15+
#pragma link C++ class o2::quality_control_modules::focal::ASICContainer + ;
16+
#pragma link C++ class o2::quality_control_modules::focal::ASICData + ;
717

818
#endif
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
#ifndef QC_MODULE_FOCAL_PIXELMAPPER
12+
#define QC_MODULE_FOCAL_PIXELMAPPER
13+
14+
#include <array>
15+
#include <exception>
16+
#include <iosfwd>
17+
#include <string>
18+
#include <unordered_map>
19+
#include <boost/container_hash/hash.hpp>
20+
#include <FOCAL/PixelChip.h>
21+
22+
namespace o2::quality_control_modules::focal
23+
{
24+
25+
class PixelMapping
26+
{
27+
public:
28+
struct ChipIdentifier {
29+
unsigned int mLaneID;
30+
unsigned int mChipID;
31+
32+
bool operator==(const ChipIdentifier& other) const { return mLaneID == other.mLaneID && mChipID == other.mChipID; }
33+
};
34+
struct ChipPosition {
35+
unsigned int mColumn;
36+
unsigned int mRow;
37+
38+
bool operator==(const ChipPosition& other) const { return mColumn == other.mColumn && mRow == other.mRow; }
39+
};
40+
struct ChipIdentifierHasher {
41+
42+
/// \brief Functor implementation
43+
/// \param s ChipID for which to determine a hash value
44+
/// \return hash value for channel ID
45+
size_t operator()(const ChipIdentifier& s) const
46+
{
47+
std::size_t seed = 0;
48+
boost::hash_combine(seed, s.mChipID);
49+
boost::hash_combine(seed, s.mLaneID);
50+
return seed;
51+
}
52+
};
53+
54+
class InvalidChipException : public std::exception
55+
{
56+
public:
57+
InvalidChipException(unsigned int mappingVersion, PixelMapping::ChipIdentifier& identifier) : mMappingVersion(mappingVersion), mIdentifier(identifier), mMessage()
58+
{
59+
mMessage = "Invalid chip identifier for mapping " + std::to_string(mMappingVersion) + ": lane " + std::to_string(mIdentifier.mLaneID) + ", chip " + std::to_string(mIdentifier.mChipID);
60+
}
61+
~InvalidChipException() noexcept final = default;
62+
63+
const char* what() const noexcept final { return mMessage.data(); }
64+
const PixelMapping::ChipIdentifier& getIdentifier() const { return mIdentifier; }
65+
unsigned int getLane() const noexcept { return mIdentifier.mLaneID; }
66+
unsigned int getChipID() const noexcept { return mIdentifier.mChipID; }
67+
int getMappingVersion() const noexcept { return mMappingVersion; }
68+
void print(std::ostream& stream) const;
69+
70+
private:
71+
unsigned int mMappingVersion;
72+
PixelMapping::ChipIdentifier mIdentifier;
73+
std::string mMessage;
74+
};
75+
76+
class VersionException : public std::exception
77+
{
78+
public:
79+
VersionException(unsigned int version) : mMappingVersion(version), mMessage() {}
80+
~VersionException() noexcept final = default;
81+
82+
const char* what() const noexcept final { return mMessage.data(); }
83+
int getMappingVersion() const noexcept { return mMappingVersion; }
84+
void print(std::ostream& stream) const;
85+
86+
private:
87+
unsigned int mMappingVersion;
88+
std::string mMessage;
89+
};
90+
91+
PixelMapping() = default;
92+
PixelMapping(unsigned int version);
93+
~PixelMapping() = default;
94+
95+
void init(unsigned int version);
96+
97+
ChipPosition getPosition(unsigned int laneID, unsigned int chipID) const;
98+
ChipPosition getPosition(const PixelChip& chip) const { return getPosition(chip.mLaneID, chip.mChipID); }
99+
100+
private:
101+
void buildVersion0();
102+
void buildVersion1();
103+
104+
int mVersion;
105+
std::unordered_map<ChipIdentifier, ChipPosition, ChipIdentifierHasher> mMapping;
106+
};
107+
108+
class PixelMapper
109+
{
110+
public:
111+
PixelMapper();
112+
~PixelMapper() = default;
113+
114+
const PixelMapping& getMapping(unsigned int feeID) const;
115+
116+
private:
117+
std::array<PixelMapping, 2> mMappings;
118+
};
119+
120+
std::ostream& operator<<(std::ostream& stream, const PixelMapping::InvalidChipException& error);
121+
std::ostream& operator<<(std::ostream& stream, const PixelMapping::VersionException& error);
122+
123+
} // namespace o2::quality_control_modules::focal
124+
125+
#endif // QC_MODULE_FOCAL_PIXELMAPPER

Modules/FOCAL/include/FOCAL/TestbeamRawTask.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
#define QC_MODULE_FOCAL_FOCALTESTBEAMRAWTASK_H
1919

2020
#include <array>
21+
#include <unordered_map>
2122

2223
#include "QualityControl/TaskInterface.h"
24+
#include "CommonDataFormat/InteractionRecord.h"
2325
#include "ITSMFTReconstruction/GBTWord.h"
2426
#include "FOCAL/PadWord.h"
2527
#include "FOCAL/PadDecoder.h"
2628
#include "FOCAL/PadMapper.h"
2729
#include "FOCAL/PixelDecoder.h"
30+
#include "FOCAL/PixelMapper.h"
2831

2932
class TH1;
3033
class TH2;
@@ -59,9 +62,12 @@ class TestbeamRawTask final : public TaskInterface
5962
void processPixelPayload(gsl::span<const o2::itsmft::GBTWord> gbtpayload, uint16_t feeID);
6063
void processPadEvent(gsl::span<const PadGBTWord> gbtpayload);
6164

62-
PadDecoder mPadDecoder; ///< Decoder for pad data
63-
PadMapper mPadMapper; ///< Mapping for Pads
64-
PixelDecoder mPixelDecoder; ///< Decoder for pixel data
65+
PadDecoder mPadDecoder; ///< Decoder for pad data
66+
PadMapper mPadMapper; ///< Mapping for Pads
67+
PixelDecoder mPixelDecoder; ///< Decoder for pixel data
68+
PixelMapper mPixelMapper; ///< Testbeam mapping for pixels
69+
std::unordered_map<o2::InteractionRecord, int> mPixelNHitsAll; ///< Number of hits / event all layers
70+
std::array<std::unordered_map<o2::InteractionRecord, int>, 2> mPixelNHitsLayer; ///< Number of hits / event layer
6571

6672
/////////////////////////////////////////////////////////////////////////////////////
6773
/// Pad histograms
@@ -75,10 +81,15 @@ class TestbeamRawTask final : public TaskInterface
7581
/////////////////////////////////////////////////////////////////////////////////////
7682
/// Pixel histograms
7783
/////////////////////////////////////////////////////////////////////////////////////
78-
TH1* mLinksWithPayloadPixel; ///< HBF with payload per link
79-
TH2* mTriggersFeePixel; ///< Nunber of triggers per HBF and FEE ID
80-
TProfile2D* mAverageHitsChipPixel; ///< Average number of hits / chip
81-
TH1* mHitsChipPixel; ///< Number of hits / chip
84+
TH1* mLinksWithPayloadPixel; ///< HBF with payload per link
85+
TH2* mTriggersFeePixel; ///< Nunber of triggers per HBF and FEE ID
86+
TProfile2D* mAverageHitsChipPixel; ///< Average number of hits / chip
87+
TH1* mHitsChipPixel; ///< Number of hits / chip
88+
std::array<TProfile2D*, 2> mPixelChipHitPofileLayer; ///< Hit profile for pixel chips
89+
std::array<TH2*, 2> mPixelChipHitProfileLayer; ///< Hit map for pixel chips
90+
std::array<TH2*, 2> mPixelHitDistribitionLayer; ///< Hit distribution per chip in layer
91+
TH1* mPixelHitsTriggerAll; ///< Number of pixel hits / trigger
92+
std::array<TH1*, 2> mPixelHitsTriggerLayer; ///< Number of pixel hits in layer / trigger
8293
};
8394

8495
} // namespace o2::quality_control_modules::focal

Modules/FOCAL/src/PixelMapper.cxx

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include <iostream>
13+
#include <FOCAL/PixelMapper.h>
14+
15+
using namespace o2::quality_control_modules::focal;
16+
17+
PixelMapping::PixelMapping(unsigned int version) { init(version); }
18+
19+
void PixelMapping::init(unsigned int version)
20+
{
21+
if (version >= 2) {
22+
throw VersionException(version);
23+
}
24+
switch (version) {
25+
case 0:
26+
buildVersion0();
27+
break;
28+
29+
case 1:
30+
buildVersion0();
31+
break;
32+
33+
default:
34+
break;
35+
}
36+
}
37+
38+
PixelMapping::ChipPosition PixelMapping::getPosition(unsigned int laneID, unsigned int chipID) const
39+
{
40+
ChipIdentifier identifier{ laneID, chipID };
41+
auto found = mMapping.find(identifier);
42+
if (found == mMapping.end()) {
43+
throw InvalidChipException(mVersion, identifier);
44+
}
45+
return found->second;
46+
}
47+
48+
void PixelMapping::buildVersion0()
49+
{
50+
mMapping.clear();
51+
mMapping.insert({ { 7, 6 }, { 0, 0 } });
52+
mMapping.insert({ { 7, 5 }, { 1, 0 } });
53+
mMapping.insert({ { 7, 4 }, { 2, 0 } });
54+
mMapping.insert({ { 7, 3 }, { 3, 0 } });
55+
mMapping.insert({ { 7, 2 }, { 4, 0 } });
56+
mMapping.insert({ { 7, 1 }, { 5, 0 } });
57+
mMapping.insert({ { 7, 0 }, { 6, 0 } });
58+
mMapping.insert({ { 6, 8 }, { 0, 1 } });
59+
mMapping.insert({ { 6, 9 }, { 1, 1 } });
60+
mMapping.insert({ { 6, 10 }, { 2, 1 } });
61+
mMapping.insert({ { 6, 11 }, { 3, 1 } });
62+
mMapping.insert({ { 6, 12 }, { 4, 1 } });
63+
mMapping.insert({ { 6, 13 }, { 5, 1 } });
64+
mMapping.insert({ { 7, 14 }, { 6, 1 } });
65+
mMapping.insert({ { 21, 6 }, { 0, 4 } });
66+
mMapping.insert({ { 21, 5 }, { 1, 4 } });
67+
mMapping.insert({ { 21, 4 }, { 2, 4 } });
68+
mMapping.insert({ { 21, 3 }, { 3, 4 } });
69+
mMapping.insert({ { 21, 2 }, { 4, 4 } });
70+
mMapping.insert({ { 21, 1 }, { 5, 4 } });
71+
mMapping.insert({ { 21, 0 }, { 6, 4 } });
72+
mMapping.insert({ { 20, 8 }, { 0, 5 } });
73+
mMapping.insert({ { 20, 9 }, { 1, 5 } });
74+
mMapping.insert({ { 20, 10 }, { 2, 5 } });
75+
mMapping.insert({ { 20, 11 }, { 3, 5 } });
76+
mMapping.insert({ { 20, 12 }, { 4, 5 } });
77+
mMapping.insert({ { 20, 13 }, { 5, 5 } });
78+
mMapping.insert({ { 20, 14 }, { 6, 5 } });
79+
}
80+
81+
void PixelMapping::buildVersion1()
82+
{
83+
mMapping.clear();
84+
mMapping.insert({ { 6, 8 }, { 0, 2 } });
85+
mMapping.insert({ { 6, 9 }, { 1, 2 } });
86+
mMapping.insert({ { 6, 10 }, { 2, 2 } });
87+
mMapping.insert({ { 6, 11 }, { 3, 2 } });
88+
mMapping.insert({ { 6, 12 }, { 4, 2 } });
89+
mMapping.insert({ { 6, 13 }, { 5, 2 } });
90+
mMapping.insert({ { 6, 14 }, { 6, 2 } });
91+
mMapping.insert({ { 7, 6 }, { 0, 3 } });
92+
mMapping.insert({ { 7, 5 }, { 1, 3 } });
93+
mMapping.insert({ { 7, 4 }, { 2, 3 } });
94+
mMapping.insert({ { 7, 3 }, { 3, 3 } });
95+
mMapping.insert({ { 7, 2 }, { 4, 3 } });
96+
mMapping.insert({ { 7, 1 }, { 5, 3 } });
97+
mMapping.insert({ { 7, 0 }, { 6, 3 } });
98+
}
99+
100+
void PixelMapping::InvalidChipException::print(std::ostream& stream) const
101+
{
102+
stream << mMessage;
103+
}
104+
105+
void PixelMapping::VersionException::print(std::ostream& stream) const
106+
{
107+
stream << mMessage;
108+
}
109+
110+
PixelMapper::PixelMapper()
111+
{
112+
mMappings[0].init(0);
113+
mMappings[1].init(1);
114+
}
115+
116+
const PixelMapping& PixelMapper::getMapping(unsigned int feeID) const
117+
{
118+
return mMappings[feeID % 2];
119+
}
120+
121+
std::ostream& o2::quality_control_modules::focal::operator<<(std::ostream& stream, const PixelMapping::InvalidChipException& error)
122+
{
123+
error.print(stream);
124+
return stream;
125+
}
126+
127+
std::ostream& o2::quality_control_modules::focal::operator<<(std::ostream& stream, const PixelMapping::VersionException& error)
128+
{
129+
error.print(stream);
130+
return stream;
131+
}

0 commit comments

Comments
 (0)