Skip to content

Commit bf1bc56

Browse files
authored
FIT: starting refactor (#2160)
* FIT: refactor starting * FIT: starting refactoring * LevelCheck: some fixes and splitting line feature * FIT: bugfixes and features * dummy commit * bugfix
1 parent 20545ee commit bf1bc56

23 files changed

Lines changed: 1074 additions & 1118 deletions

Modules/FIT/Common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ set(SRCS
1111
)
1212

1313
set(HEADERS
14+
include/FITCommon/DetectorFIT.h
1415
include/FITCommon/HelperCommon.h
1516
include/FITCommon/HelperFIT.h
1617
include/FITCommon/HelperHist.h
1718
include/FITCommon/HelperLUT.h
1819
include/FITCommon/DigitSync.h
20+
include/FITCommon/PostProcHelper.h
1921
)
2022

2123
# ---- Library ----
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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+
///
13+
/// \file DetectorFIT.h
14+
/// \author Artur Furs afurs@cern.ch
15+
/// \brief Helper class for FIT detectors
16+
17+
#ifndef QC_MODULE_FIT_DETECTORFIT_H
18+
#define QC_MODULE_FIT_DETECTORFIT_H
19+
20+
#include "DataFormatsFDD/Digit.h"
21+
#include "DataFormatsFDD/ChannelData.h"
22+
23+
#include "DataFormatsFT0/Digit.h"
24+
#include "DataFormatsFT0/ChannelData.h"
25+
26+
#include "DataFormatsFV0/Digit.h"
27+
#include "DataFormatsFV0/ChannelData.h"
28+
29+
// #include "CommonDataFormat/InteractionRecord.h"
30+
31+
#include <array>
32+
#include <map>
33+
#include <string>
34+
#include <utility>
35+
#include <type_traits>
36+
// #include "FITCommon/HelperFIT.h"
37+
namespace o2::quality_control_modules::fit
38+
{
39+
namespace detectorFIT
40+
{
41+
42+
using TrgMap_t = std::map<unsigned int, std::string>;
43+
44+
enum EDetectorFIT { kFDD,
45+
kFT0,
46+
kFV0 };
47+
enum ESide { kNothing,
48+
kSideA,
49+
kSideC };
50+
#define CREATE_FIT_CHDATA_ACCESSOR(Name, Field) \
51+
template <typename T> \
52+
constexpr auto Name(T&& channelData)->std::decay_t<decltype(std::declval<T>().Field)>&& \
53+
{ \
54+
return std::forward<std::decay_t<decltype(std::declval<T>().Field)>>(channelData.mChargeADC); \
55+
}
56+
57+
// FT0 and FV0 has the same field names
58+
CREATE_FIT_CHDATA_ACCESSOR(Amp, mChargeADC)
59+
CREATE_FIT_CHDATA_ACCESSOR(Amp, QTCAmpl)
60+
61+
CREATE_FIT_CHDATA_ACCESSOR(Time, mTime)
62+
CREATE_FIT_CHDATA_ACCESSOR(Time, CFDTime)
63+
64+
CREATE_FIT_CHDATA_ACCESSOR(BitsPM, mFEEBits)
65+
CREATE_FIT_CHDATA_ACCESSOR(BitsPM, ChainQTC)
66+
67+
CREATE_FIT_CHDATA_ACCESSOR(ChannelID, mPMNumber)
68+
CREATE_FIT_CHDATA_ACCESSOR(ChannelID, ChId)
69+
70+
#undef CREATE_FIT_CHDATA_ACCESSOR
71+
72+
template <EDetectorFIT DetID, int NchannelsA, int NchannelsC, int NchannelsNone, typename DigitType, typename ChannelDataType, bool isChIDdirectForSides>
73+
class BaseDetectorFIT
74+
{
75+
public:
76+
typedef std::map<unsigned int, std::string> TrgMap_t;
77+
78+
constexpr static EDetectorFIT sDetFIT_ID = DetID;
79+
constexpr static int sNchannelsA = NchannelsA;
80+
constexpr static int sNchannelsC = NchannelsC;
81+
constexpr static int sNchannelsNone = NchannelsNone;
82+
constexpr static int sNchannelsAC = sNchannelsA + sNchannelsC;
83+
constexpr static int sNchannelsAll = sNchannelsAC + sNchannelsNone;
84+
constexpr static bool sIsChIDdirectForSides = isChIDdirectForSides;
85+
typedef DigitType Digit_t;
86+
typedef ChannelDataType ChannelData_t;
87+
typedef decltype(std::declval<Digit_t>().mTriggers) Triggers_t;
88+
constexpr static int getSide(int chID)
89+
{
90+
if (chID < sNchannelsA) {
91+
return isChIDdirectForSides ? ESide::kSideA : ESide::kSideC;
92+
} else if (chID < sNchannelsAC) {
93+
return isChIDdirectForSides ? ESide::kSideC : ESide::kSideA;
94+
}
95+
return ESide::kNothing;
96+
}
97+
constexpr static bool isSideA(int side) { return side == ESide::kSideA; }
98+
constexpr static bool isSideC(int side) { return side == ESide::kSideC; }
99+
static TrgMap_t addTechTrgBits(const TrgMap_t& trgMap)
100+
{
101+
auto newTrgMap = trgMap;
102+
newTrgMap.insert({ Triggers_t::bitLaser, "Laser" });
103+
newTrgMap.insert({ Triggers_t::bitOutputsAreBlocked, "OutputsAreBlocked" });
104+
newTrgMap.insert({ Triggers_t::bitDataIsValid, "DataIsValid" });
105+
return newTrgMap;
106+
}
107+
static const inline TrgMap_t sMapPMbits = {
108+
{ ChannelData_t::kNumberADC, "NumberADC" },
109+
{ ChannelData_t::kIsDoubleEvent, "IsDoubleEvent" },
110+
{ ChannelData_t::kIsTimeInfoNOTvalid, "IsTimeInfoNOTvalid" },
111+
{ ChannelData_t::kIsCFDinADCgate, "IsCFDinADCgate" },
112+
{ ChannelData_t::kIsTimeInfoLate, "IsTimeInfoLate" },
113+
{ ChannelData_t::kIsAmpHigh, "IsAmpHigh" },
114+
{ ChannelData_t::kIsEventInTVDC, "IsEventInTVDC" },
115+
{ ChannelData_t::kIsTimeInfoLost, "IsTimeInfoLost" }
116+
};
117+
118+
constexpr static std::array<int, sNchannelsAll> setChIDs2Side()
119+
{
120+
std::array<int, sNchannelsAll> chID2side{};
121+
for (int iCh = 0; iCh < chID2side.size(); iCh++) {
122+
chID2side[iCh] = getSide(iCh);
123+
}
124+
return chID2side;
125+
}
126+
constexpr static std::array<int, sNchannelsAll> sArrChID2Side = setChIDs2Side();
127+
128+
constexpr static std::array<std::vector<uint8_t>, 256> decompose1Byte()
129+
{
130+
std::array<std::vector<uint8_t>, 256> arrBitPos{};
131+
for (int iByteValue = 0; iByteValue < arrBitPos.size(); iByteValue++) {
132+
auto& vec = arrBitPos[iByteValue];
133+
for (int iBit = 0; iBit < 8; iBit++) {
134+
if (iByteValue & (1 << iBit)) {
135+
vec.push_back(iBit);
136+
}
137+
}
138+
}
139+
return arrBitPos;
140+
}
141+
static const inline std::array<std::vector<uint8_t>, 256> sArrDecomposed1Byte = decompose1Byte();
142+
};
143+
144+
template <EDetectorFIT DetID>
145+
class DetectorFIT : BaseDetectorFIT<DetID, 0, 0, 0, void, void, true>
146+
{
147+
};
148+
149+
template <>
150+
struct DetectorFIT<EDetectorFIT::kFDD> : public BaseDetectorFIT<EDetectorFIT::kFDD, 8, 8, 3, o2::fdd::Digit, o2::fdd::ChannelData, false> {
151+
static const inline TrgMap_t sMapTrgBits = {
152+
{ Triggers_t::bitA, "OrA" },
153+
{ Triggers_t::bitC, "OrC" },
154+
{ Triggers_t::bitVertex, "Vertex" },
155+
{ Triggers_t::bitCen, "Central" },
156+
{ Triggers_t::bitSCen, "SemiCentral" }
157+
};
158+
static const inline TrgMap_t sMapTechTrgBits = addTechTrgBits(sMapTrgBits);
159+
};
160+
161+
template <>
162+
struct DetectorFIT<EDetectorFIT::kFT0> : public BaseDetectorFIT<EDetectorFIT::kFT0, 96, 112, 4, o2::ft0::Digit, o2::ft0::ChannelData, true> {
163+
static const inline TrgMap_t sMapTrgBits = {
164+
{ Triggers_t::bitA, "OrA" },
165+
{ Triggers_t::bitC, "OrC" },
166+
{ Triggers_t::bitVertex, "Vertex" },
167+
{ Triggers_t::bitCen, "Central" },
168+
{ Triggers_t::bitSCen, "SemiCentral" }
169+
};
170+
static const inline TrgMap_t sMapTechTrgBits = addTechTrgBits(sMapTrgBits);
171+
};
172+
173+
template <>
174+
struct DetectorFIT<EDetectorFIT::kFV0> : public BaseDetectorFIT<EDetectorFIT::kFV0, 48, 0, 1, o2::fv0::Digit, o2::fv0::ChannelData, true> {
175+
static const inline TrgMap_t sMapTrgBits = {
176+
{ o2::fit::Triggers::bitA, "OrA" },
177+
{ o2::fit::Triggers::bitAOut, "OrAOut" },
178+
{ o2::fit::Triggers::bitTrgNchan, "TrgNChan" },
179+
{ o2::fit::Triggers::bitTrgCharge, "TrgCharge" },
180+
{ o2::fit::Triggers::bitAIn, "OrAIn" }
181+
182+
};
183+
static const inline TrgMap_t sMapTechTrgBits = addTechTrgBits(sMapTrgBits);
184+
};
185+
186+
using DetectorFDD = DetectorFIT<EDetectorFIT::kFDD>;
187+
using DetectorFT0 = DetectorFIT<EDetectorFIT::kFT0>;
188+
using DetectorFV0 = DetectorFIT<EDetectorFIT::kFV0>;
189+
190+
} // namespace detectorFIT
191+
192+
} // namespace o2::quality_control_modules::fit
193+
#endif

0 commit comments

Comments
 (0)