34 constexpr std::array<int, 2> startLayer{0, 3};
35 const Long64_t
nEvents = hitsTree->GetEntries();
39 std::vector<o2::trk::Hit>* trkHit =
nullptr;
40 hitsTree->SetBranchAddress(
"TRKHit", &trkHit);
42 const int inROFpileup{config.contains(
"inROFpileup") ? config[
"inROFpileup"].get<
int>() : 1};
45 const int nRofs = (
nEvents + inROFpileup - 1) / inROFpileup;
48 constexpr uint32_t rofLength = 198;
50 for (
int iLayer = 0; iLayer < NLayers; ++iLayer) {
51 overlapTable.defineLayer(iLayer, nRofs, rofLength, 0, 0, 0);
54 this->setROFOverlapTable(overlapTable);
58 for (
int iLayer = 0; iLayer < NLayers; ++iLayer) {
59 vtxLookupTable.defineLayer(iLayer, nRofs, rofLength, 0, 0, 0);
61 vtxLookupTable.init();
62 this->setROFVertexLookupTable(vtxLookupTable);
65 for (
int iLayer{0}; iLayer < NLayers; ++iLayer) {
66 this->mMinR[iLayer] = std::numeric_limits<float>::max();
67 this->mMaxR[iLayer] = std::numeric_limits<float>::lowest();
68 this->mROFramesClusters[iLayer].clear();
69 this->mROFramesClusters[iLayer].resize(nRofs + 1, 0);
70 this->mUnsortedClusters[iLayer].clear();
71 this->mTrackingFrameInfo[iLayer].clear();
72 this->mClusterExternalIndices[iLayer].clear();
76 std::array<int, NLayers> clusterCountPerLayer{};
77 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
78 hitsTree->GetEntry(iEvent);
79 for (
const auto& hit : *trkHit) {
80 if (gman->
getDisk(hit.GetDetectorID()) != -1) {
83 int subDetID = gman->
getSubDetID(hit.GetDetectorID());
84 const int layer = startLayer[subDetID] + gman->
getLayer(hit.GetDetectorID());
85 if (
layer >= NLayers) {
88 ++clusterCountPerLayer[
layer];
93 for (
int iLayer{0}; iLayer < NLayers; ++iLayer) {
94 this->mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
95 this->mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
96 this->mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
97 clearResizeBoundedVector(this->mClusterSize[iLayer], clusterCountPerLayer[iLayer], this->mMemoryPool.get());
100 std::array<float, 11> resolution{0.001, 0.001, 0.001, 0.001, 0.004, 0.004, 0.004, 0.004, 0.004, 0.004, 0.004};
101 if (config[
"geometry"][
"pitch"].
size() ==
static_cast<size_t>(NLayers)) {
102 for (
size_t iLayer{0}; iLayer < config[
"geometry"][
"pitch"].size(); ++iLayer) {
103 LOGP(info,
"Setting resolution for layer {} from config", iLayer);
104 LOGP(info,
"Layer {} pitch {} cm", iLayer, config[
"geometry"][
"pitch"][iLayer].get<float>());
105 resolution[iLayer] = config[
"geometry"][
"pitch"][iLayer].get<
float>() / std::sqrt(12.f);
115 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
116 hitsTree->GetEntry(iEvent);
118 for (
auto& hit : *trkHit) {
119 if (gman->
getDisk(hit.GetDetectorID()) != -1) {
122 int subDetID = gman->
getSubDetID(hit.GetDetectorID());
123 const int layer = startLayer[subDetID] + gman->
getLayer(hit.GetDetectorID());
129 if (
layer >= NLayers) {
133 int chipID = hit.GetDetectorID();
136 auto locXYZ = l2g ^ (hit.GetPos());
137 locXYZ.SetX(locXYZ.X() + gRandom->Gaus(0.0, resolution[
layer]));
138 locXYZ.SetZ(locXYZ.Z() + gRandom->Gaus(0.0, resolution[
layer]));
141 r = std::hypot(gloXYZ.X(), gloXYZ.Y());
143 const auto& hitPos = hit.GetPos();
144 r = std::hypot(hitPos.X(), hitPos.Y());
145 alpha = std::atan2(hitPos.Y(), hitPos.X()) + gRandom->Gaus(0.0, resolution[
layer] /
r);
146 o2::math_utils::bringTo02Pi(
alpha);
147 gloXYZ.SetX(
r * std::cos(
alpha));
148 gloXYZ.SetY(
r * std::sin(
alpha));
149 gloXYZ.SetZ(hitPos.Z() + gRandom->Gaus(0.0, resolution[
layer]));
152 trkXYZ.SetZ(gloXYZ.Z());
154 this->mMinR[
layer] = std::min(this->mMinR[
layer],
r);
155 this->mMaxR[
layer] = std::max(this->mMaxR[
layer],
r);
156 this->addTrackingFrameInfoToLayer(
layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(),
alpha,
157 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
158 std::array<float, 3>{resolution[layer] * resolution[layer], 0., resolution[layer] * resolution[layer]});
160 const int clusterIdxInLayer = this->mUnsortedClusters[
layer].size();
161 this->addClusterToLayer(
layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), clusterIdxInLayer);
162 this->addClusterExternalIndexToLayer(
layer, hitCounter);
165 this->mClusterSize[
layer][clusterIdxInLayer] = 1;
171 if ((iEvent + 1) % inROFpileup == 0 || iEvent ==
nEvents - 1) {
173 for (
unsigned int iLayer{0}; iLayer < this->mUnsortedClusters.size(); ++iLayer) {
174 this->mROFramesClusters[iLayer][iRof] = this->mUnsortedClusters[iLayer].size();
180 for (
int iLayer = 0; iLayer < NLayers; ++iLayer) {
181 this->mClusterLabels[iLayer] =
labels;
191 mcHeaderTree->SetBranchAddress(
"MCEventHeader.", &mcheader);
193 this->mPrimaryVertices.clear();
196 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
197 mcHeaderTree->GetEntry(iEvent);
199 vertex.setXYZ(mcheader->GetX(), mcheader->GetY(), mcheader->GetZ());
200 vertex.setNContributors(30);
205 const uint32_t rofCenter =
static_cast<uint32_t
>(rofLength * iRof + rofLength / 2);
206 const uint16_t rofHalf =
static_cast<uint16_t
>(rofLength / 2);
207 vertex.setTimeStamp({rofCenter, rofHalf});
209 LOGP(
debug,
"ROF {}: Added primary vertex at ({}, {}, {}) with BC timestamp [{}, +/-{}]",
210 iRof, mcheader->GetX(), mcheader->GetY(), mcheader->GetZ(), rofCenter, rofHalf);
211 this->addPrimaryVertex(
vertex);
212 if ((iEvent + 1) % inROFpileup == 0 || iEvent ==
nEvents - 1) {
216 this->mMultiplicityCutMask.resetMask(1u);
219 this->updateROFVertexLookupTable();