32 constexpr std::array<int, 2> startLayer{0, 3};
33 const Long64_t
nEvents = hitsTree->GetEntries();
37 std::vector<o2::trk::Hit>* trkHit =
nullptr;
38 hitsTree->SetBranchAddress(
"TRKHit", &trkHit);
40 const int inROFpileup{config.contains(
"inROFpileup") ? config[
"inROFpileup"].get<
int>() : 1};
43 this->mNrof = (
nEvents + inROFpileup - 1) / inROFpileup;
46 for (
int iLayer{0}; iLayer < nLayers; ++iLayer) {
47 this->mMinR[iLayer] = std::numeric_limits<float>::max();
48 this->mMaxR[iLayer] = std::numeric_limits<float>::lowest();
49 this->mROFramesClusters[iLayer].clear();
50 this->mROFramesClusters[iLayer].resize(this->mNrof + 1, 0);
51 this->mUnsortedClusters[iLayer].clear();
52 this->mTrackingFrameInfo[iLayer].clear();
53 this->mClusterExternalIndices[iLayer].clear();
58 std::array<int, nLayers> clusterCountPerLayer{};
59 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
60 hitsTree->GetEntry(iEvent);
61 for (
const auto& hit : *trkHit) {
62 if (gman->
getDisk(hit.GetDetectorID()) != -1) {
65 int subDetID = gman->
getSubDetID(hit.GetDetectorID());
66 const int layer = startLayer[subDetID] + gman->
getLayer(hit.GetDetectorID());
67 if (
layer >= nLayers) {
70 ++clusterCountPerLayer[
layer];
76 for (
int iLayer{0}; iLayer < nLayers; ++iLayer) {
77 this->mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]);
78 this->mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]);
79 this->mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]);
81 clearResizeBoundedVector(this->mClusterSize, totalNHits, this->mMemoryPool.get());
83 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};
84 if (config[
"geometry"][
"pitch"].
size() == nLayers) {
85 for (
int iLayer{0}; iLayer < config[
"geometry"][
"pitch"].size(); ++iLayer) {
86 LOGP(info,
"Setting resolution for layer {} from config", iLayer);
87 LOGP(info,
"Layer {} pitch {} cm", iLayer, config[
"geometry"][
"pitch"][iLayer].get<float>());
88 resolution[iLayer] = config[
"geometry"][
"pitch"][iLayer].get<
float>() / std::sqrt(12.f);
97 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
98 hitsTree->GetEntry(iEvent);
100 for (
auto& hit : *trkHit) {
101 if (gman->
getDisk(hit.GetDetectorID()) != -1) {
104 int subDetID = gman->
getSubDetID(hit.GetDetectorID());
105 const int layer = startLayer[subDetID] + gman->
getLayer(hit.GetDetectorID());
111 if (
layer >= nLayers) {
115 int chipID = hit.GetDetectorID();
118 auto locXYZ = l2g ^ (hit.GetPos());
119 locXYZ.SetX(locXYZ.X() + gRandom->Gaus(0.0, resolution[
layer]));
120 locXYZ.SetZ(locXYZ.Z() + gRandom->Gaus(0.0, resolution[
layer]));
123 r = std::hypot(gloXYZ.X(), gloXYZ.Y());
125 const auto& hitPos = hit.GetPos();
126 r = std::hypot(hitPos.X(), hitPos.Y());
127 alpha = std::atan2(hitPos.Y(), hitPos.X()) + gRandom->Gaus(0.0, resolution[
layer] /
r);
128 o2::math_utils::bringTo02Pi(
alpha);
129 gloXYZ.SetX(
r * std::cos(
alpha));
130 gloXYZ.SetY(
r * std::sin(
alpha));
131 gloXYZ.SetZ(hitPos.Z() + gRandom->Gaus(0.0, resolution[
layer]));
134 trkXYZ.SetZ(gloXYZ.Z());
136 this->mMinR[
layer] = std::min(this->mMinR[
layer],
r);
137 this->mMaxR[
layer] = std::max(this->mMaxR[
layer],
r);
138 this->addTrackingFrameInfoToLayer(
layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(),
alpha,
139 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
140 std::array<float, 3>{resolution[layer] * resolution[layer], 0., resolution[layer] * resolution[layer]});
142 this->addClusterToLayer(
layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), this->mUnsortedClusters[
layer].size());
143 this->addClusterExternalIndexToLayer(
layer, hitCounter);
146 this->mClusterSize[hitCounter] = 1;
152 if ((iEvent + 1) % inROFpileup == 0 || iEvent ==
nEvents - 1) {
154 for (
unsigned int iLayer{0}; iLayer < this->mUnsortedClusters.size(); ++iLayer) {
155 this->mROFramesClusters[iLayer][iRof] = this->mUnsortedClusters[iLayer].size();
159 this->mClusterLabels =
labels;
168 mcHeaderTree->SetBranchAddress(
"MCEventHeader.", &mcheader);
170 this->mROFramesPV.clear();
171 this->mROFramesPV.resize(nRofs + 1, 0);
172 this->mPrimaryVertices.clear();
175 for (Long64_t iEvent = 0; iEvent <
nEvents; ++iEvent) {
176 mcHeaderTree->GetEntry(iEvent);
178 vertex.setXYZ(mcheader->GetX(), mcheader->GetY(), mcheader->GetZ());
179 vertex.setNContributors(30);
181 LOGP(
debug,
"ROF {}: Added primary vertex at ({}, {}, {})", iRof, mcheader->GetX(), mcheader->GetY(), mcheader->GetZ());
182 this->mPrimaryVertices.push_back(
vertex);
183 if ((iEvent + 1) % inROFpileup == 0 || iEvent ==
nEvents - 1) {
185 this->mROFramesPV[iRof] = this->mPrimaryVertices.size();
188 this->mMultiplicityCutMask.resize(nRofs,
true);