forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupcTestFitBitMapping.cxx
More file actions
121 lines (101 loc) · 4.23 KB
/
Copy pathupcTestFitBitMapping.cxx
File metadata and controls
121 lines (101 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//
/// \file upcTestFitBitMapping.cxx
/// \brief FIT bits to phi, eta mapping
/// \author Sandor Lokos, sandor.lokos@cern.ch
/// \since March 2026
#include "PWGUD/Core/UDHelpers.h" // udhelpers::Bits256, makeBits256, testBit, getPhiEtaFromFitBit
#include "PWGUD/DataModel/UDTables.h" // aod::UDCollisionFITBits
#include <CommonConstants/MathConstants.h> // o2::constants::math::TwoPI
#include <FT0Base/Geometry.h> // o2::ft0::Geometry
#include <Framework/AnalysisTask.h>
#include <Framework/Configurable.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/InitContext.h>
#include <Framework/runDataProcessing.h>
#include <array>
#include <cstdint>
using namespace o2;
using namespace o2::framework;
struct UpcTestFitBitMapping {
static constexpr int Thr2Selector = 2; // value of whichThr that selects the Thr2 bit set
Configurable<int> whichThr{"whichThr", 1, "Use 1=Thr1 bits or 2=Thr2 bits"};
Configurable<int> maxEvents{"maxEvents", -1, "Process at most this many rows (-1 = all)"};
// Minimal offset container compatible with UDHelpers.h expectations: getX/getY/getZ
struct OffsetXYZ {
double x{0}, y{0}, z{0};
double getX() const { return x; }
double getY() const { return y; }
double getZ() const { return z; }
};
std::array<OffsetXYZ, 1> offsetFT0{}; // iRunOffset = 0 for now
int iRunOffset = 0;
o2::ft0::Geometry ft0Det{};
HistogramRegistry registry{
"registry",
{
{"hPhiA", "FT0A #varphi;#varphi;counts", {HistType::kTH1F, {{18, 0.0, o2::constants::math::TwoPI}}}},
{"hEtaA", "FT0A #eta;#eta;counts", {HistType::kTH1F, {{8, 3.5, 5.0}}}},
{"hEtaPhiA", "FT0A #eta vs #varphi;#eta;#varphi", {HistType::kTH2F, {{8, 3.5, 5.0}, {18, 0.0, o2::constants::math::TwoPI}}}},
{"hPhiC", "FT0C #varphi;#varphi;counts", {HistType::kTH1F, {{18, 0.0, o2::constants::math::TwoPI}}}},
{"hEtaC", "FT0C #eta;#eta;counts", {HistType::kTH1F, {{8, -3.5, -2.0}}}},
{"hEtaPhiC", "FT0C #eta vs #varphi;#eta;#varphi", {HistType::kTH2F, {{8, -3.5, -2.0}, {18, 0.0, o2::constants::math::TwoPI}}}},
}};
void init(InitContext&)
{
// UDHelpers calls calculateChannelCenter() inside, but doing it once here is fine.
ft0Det.calculateChannelCenter();
}
void process(aod::UDCollisionFITBits const& bitsTable)
{
int64_t nProcessed = 0;
for (auto const& row : bitsTable) {
if (maxEvents >= 0 && nProcessed >= maxEvents) {
break;
}
++nProcessed;
// Use udhelpers' canonical packed type + builder
udhelpers::Bits256 w{};
if (whichThr == Thr2Selector) {
w = udhelpers::makeBits256(row.thr2W0(), row.thr2W1(), row.thr2W2(), row.thr2W3());
} else {
w = udhelpers::makeBits256(row.thr1W0(), row.thr1W1(), row.thr1W2(), row.thr1W3());
}
// Loop FT0 bits only (0..207). FV0 starts at 208 but ignored here.
for (int bit = 0; bit < udhelpers::kFT0Bits; ++bit) {
if (!udhelpers::testBit(w, bit)) {
continue;
}
double phi = 0., eta = 0.;
const bool ok = udhelpers::getPhiEtaFromFitBit(ft0Det, bit, offsetFT0, iRunOffset, phi, eta);
if (!ok) {
continue;
}
if (bit < udhelpers::kFT0AChannels) {
registry.fill(HIST("hPhiA"), phi);
registry.fill(HIST("hEtaA"), eta);
registry.fill(HIST("hEtaPhiA"), eta, phi);
} else {
registry.fill(HIST("hPhiC"), phi);
registry.fill(HIST("hEtaC"), eta);
registry.fill(HIST("hEtaPhiC"), eta, phi);
}
}
}
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<UpcTestFitBitMapping>(cfgc)};
}