Skip to content

Commit 7c76602

Browse files
committed
Support per-layer ITS clusters in its3-alignment-workflow
1 parent fcbb158 commit 7c76602

3 files changed

Lines changed: 59 additions & 51 deletions

File tree

‎Detectors/Upgrades/ITS3/alignment/include/ITS3Align/AlignmentSpec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum class OutputOpt : uint8_t {
2929
};
3030
using OutputEnum = utils::EnumFlags<OutputOpt>;
3131

32-
o2::framework::DataProcessorSpec getAlignmentSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool useMC, bool withPV, bool withITS3, OutputEnum out);
32+
o2::framework::DataProcessorSpec getAlignmentSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool useMC, bool withPV, bool withITS3, OutputEnum out, bool itsStag);
3333
} // namespace o2::its3::align
3434

3535
#endif

‎Detectors/Upgrades/ITS3/alignment/src/AlignmentSpec.cxx‎

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "Framework/Task.h"
3232
#include "ITSBase/GeometryTGeo.h"
3333
#include "DataFormatsGlobalTracking/RecoContainer.h"
34+
#include "DataFormatsITSMFT/ClustersPerLayer.h"
3435
#include "DetectorsCommonDataFormats/DetID.h"
3536
#include "DetectorsBase/Propagator.h"
3637
#include "DetectorsBase/GRPGeomHelper.h"
@@ -124,7 +125,7 @@ class AlignmentSpec final : public Task
124125
bool prepareITSTrack(int iTrk, const o2::its::TrackITS& itsTrack, Track& resTrack);
125126

126127
// prepare ITS measuremnt points
127-
void prepareMeasurments(std::span<const itsmft::CompClusterExt> clusters, std::span<const unsigned char> pattIt);
128+
void prepareMeasurments();
128129

129130
// build track to vertex association
130131
void buildT2V();
@@ -143,7 +144,7 @@ class AlignmentSpec final : public Task
143144
const o2::its3::TopologyDictionary* mIT3Dict{nullptr};
144145
o2::globaltracking::RecoContainer* mRecoData = nullptr;
145146
std::unique_ptr<steer::MCKinematicsReader> mcReader;
146-
std::vector<FrameInfoExt> mITSTrackingInfo;
147+
o2::itsmft::ClustersPerLayer<FrameInfoExt> mITSTrackingInfo; // addressed by the composed (layer,index) ID
147148
std::shared_ptr<DataRequest> mDataRequest;
148149
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
149150
std::unique_ptr<AlignableVolume> mHierarchy; // tree-hiearchy
@@ -194,13 +195,11 @@ void AlignmentSpec::process()
194195
const auto bz = prop->getNominalBz();
195196
const auto itsTracks = mRecoData->getITSTracks();
196197
const auto itsClRefs = mRecoData->getITSTracksClusterRefs();
197-
const auto clusITS = mRecoData->getITSClusters();
198-
const auto patterns = mRecoData->getITSClustersPatterns();
199198
std::span<const o2::MCCompLabel> mcLbls;
200199
if (mUseMC) {
201200
mcLbls = mRecoData->getITSTracksMCLabels();
202201
}
203-
prepareMeasurments(clusITS, patterns);
202+
prepareMeasurments();
204203

205204
if (mWithPV) {
206205
buildT2V();
@@ -731,53 +730,60 @@ bool AlignmentSpec::prepareITSTrack(int iTrk, const o2::its::TrackITS& itsTrack,
731730
return true;
732731
}
733732

734-
void AlignmentSpec::prepareMeasurments(std::span<const itsmft::CompClusterExt> clusters, std::span<const unsigned char> patterns)
733+
void AlignmentSpec::prepareMeasurments()
735734
{
736-
LOGP(info, "Preparing {} measurments", clusters.size());
737735
auto geom = its::GeometryTGeo::Instance();
738736
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
739-
mITSTrackingInfo.clear();
740-
mITSTrackingInfo.reserve(clusters.size());
741-
auto pattIt = patterns.begin();
742-
for (const auto& cls : clusters) {
743-
const auto sens = cls.getSensorID();
744-
const auto lay = geom->getLayer(sens);
745-
double sigmaY2{0}, sigmaZ2{0};
746-
math_utils::Point3D<float> locXYZ;
747-
if (mIsITS3) {
748-
locXYZ = o2::its3::ioutils::extractClusterData(cls, pattIt, mIT3Dict, sigmaY2, sigmaZ2);
749-
} else {
750-
locXYZ = o2::its::ioutils::extractClusterData(cls, pattIt, mITSDict, sigmaY2, sigmaZ2);
751-
}
752-
sigmaY2 += mParams->extraClsErrY[lay] * mParams->extraClsErrY[lay];
753-
sigmaZ2 += mParams->extraClsErrZ[lay] * mParams->extraClsErrZ[lay];
754-
// Transformation to the local --> global
755-
const auto gloXYZ = geom->getMatrixL2G(sens) * locXYZ;
756-
// Inverse transformation to the local --> tracking
757-
auto trkXYZf = geom->getMatrixT2L(sens) ^ locXYZ;
758-
o2::math_utils::Point3D<double> trkXYZ;
759-
trkXYZ.SetCoordinates(trkXYZf.X(), trkXYZf.Y(), trkXYZf.Z());
760-
// Tracking alpha angle
761-
// We want that each cluster rotates its tracking frame to the clusters phi
762-
// that way the track linearization around the measurement is less biases to the arc
763-
// this means automatically that the measurement on the arc is at 0 for the curved layers
764-
double alpha = geom->getSensorRefAlpha(sens);
765-
double x = trkXYZ.x();
766-
if (mIsITS3 && constants::detID::isDetITS3(sens)) {
767-
trkXYZ.SetY(0.f);
768-
// alpha&x always have to be defined wrt to the global Z axis!
769-
x = std::hypot(gloXYZ.x(), gloXYZ.y());
770-
trkXYZ.SetX(x);
771-
alpha = std::atan2(gloXYZ.y(), gloXYZ.x());
772-
auto chip = constants::detID::getSensorID(sens);
773-
sigmaY2 += mParams->extraClsErrY[chip] * mParams->extraClsErrY[chip];
774-
sigmaZ2 += mParams->extraClsErrZ[chip] * mParams->extraClsErrZ[chip];
737+
int nLr = mRecoData->getITSPerLayer() ? o2::globaltracking::MaxITSLayers : 1;
738+
mITSTrackingInfo.init(nLr);
739+
for (int lr = 0; lr < nLr; lr++) { // with a single (monolithic) input all clusters are in the layer slot 0
740+
mITSTrackingInfo.beginLayer(lr);
741+
const auto clusters = mRecoData->getITSClusters(lr);
742+
const auto patterns = mRecoData->getITSClustersPatterns(lr);
743+
LOGP(info, "Preparing {} measurments of the layer slot {}", clusters.size(), lr);
744+
mITSTrackingInfo.getClusters().reserve(mITSTrackingInfo.size() + clusters.size());
745+
auto pattIt = patterns.begin();
746+
for (const auto& cls : clusters) {
747+
const auto sens = cls.getSensorID();
748+
const auto lay = geom->getLayer(sens);
749+
double sigmaY2{0}, sigmaZ2{0};
750+
math_utils::Point3D<float> locXYZ;
751+
if (mIsITS3) {
752+
locXYZ = o2::its3::ioutils::extractClusterData(cls, pattIt, mIT3Dict, sigmaY2, sigmaZ2);
753+
} else {
754+
locXYZ = o2::its::ioutils::extractClusterData(cls, pattIt, mITSDict, sigmaY2, sigmaZ2);
755+
}
756+
sigmaY2 += mParams->extraClsErrY[lay] * mParams->extraClsErrY[lay];
757+
sigmaZ2 += mParams->extraClsErrZ[lay] * mParams->extraClsErrZ[lay];
758+
// Transformation to the local --> global
759+
const auto gloXYZ = geom->getMatrixL2G(sens) * locXYZ;
760+
// Inverse transformation to the local --> tracking
761+
auto trkXYZf = geom->getMatrixT2L(sens) ^ locXYZ;
762+
o2::math_utils::Point3D<double> trkXYZ;
763+
trkXYZ.SetCoordinates(trkXYZf.X(), trkXYZf.Y(), trkXYZf.Z());
764+
// Tracking alpha angle
765+
// We want that each cluster rotates its tracking frame to the clusters phi
766+
// that way the track linearization around the measurement is less biases to the arc
767+
// this means automatically that the measurement on the arc is at 0 for the curved layers
768+
double alpha = geom->getSensorRefAlpha(sens);
769+
double x = trkXYZ.x();
770+
if (mIsITS3 && constants::detID::isDetITS3(sens)) {
771+
trkXYZ.SetY(0.f);
772+
// alpha&x always have to be defined wrt to the global Z axis!
773+
x = std::hypot(gloXYZ.x(), gloXYZ.y());
774+
trkXYZ.SetX(x);
775+
alpha = std::atan2(gloXYZ.y(), gloXYZ.x());
776+
auto chip = constants::detID::getSensorID(sens);
777+
sigmaY2 += mParams->extraClsErrY[chip] * mParams->extraClsErrY[chip];
778+
sigmaZ2 += mParams->extraClsErrZ[chip] * mParams->extraClsErrZ[chip];
779+
}
780+
math_utils::bringToPMPid(alpha);
781+
mITSTrackingInfo.getClusters().emplace_back(sens, lay, x, alpha,
782+
std::array<double, 2>{trkXYZ.y(), trkXYZ.z()},
783+
std::array<double, 3>{sigmaY2, 0., sigmaZ2});
775784
}
776-
math_utils::bringToPMPid(alpha);
777-
mITSTrackingInfo.emplace_back(sens, lay, x, alpha,
778-
std::array<double, 2>{trkXYZ.y(), trkXYZ.z()},
779-
std::array<double, 3>{sigmaY2, 0., sigmaZ2});
780-
}
785+
} // loop over the layer slots
786+
mITSTrackingInfo.finalize();
781787
}
782788

783789
void AlignmentSpec::buildT2V()
@@ -941,9 +947,10 @@ void AlignmentSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
941947
}
942948
}
943949

944-
DataProcessorSpec getAlignmentSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool useMC, bool withPV, bool withITS, OutputEnum out)
950+
DataProcessorSpec getAlignmentSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool useMC, bool withPV, bool withITS, OutputEnum out, bool itsStag)
945951
{
946952
auto dataRequest = std::make_shared<DataRequest>();
953+
dataRequest->setITSPerLayer(itsStag);
947954
std::shared_ptr<o2::base::GRPGeomRequest> ggRequest{nullptr};
948955
if (!out[OutputOpt::MilleRes]) {
949956
dataRequest->requestTracks(srcTracks, useMC);

‎Detectors/Upgrades/ITS3/alignment/src/alignment-workflow.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfg)
5454
const auto useMC = !cfg.options().get<bool>("disable-mc");
5555
const auto withPV = !cfg.options().get<bool>("without-pv");
5656
const auto withITS = cfg.options().get<bool>("with-its");
57+
const auto doStag = o2::itsmft::DPLAlpideParamInitializer::isITSStaggeringEnabled(cfg);
5758
const OutputEnum output(cfg.options().get<std::string>("output"));
5859

5960
WorkflowSpec specs;
@@ -66,7 +67,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfg)
6667
specs.emplace_back(o2::globaltracking::getNoInpDummyOutSpec(0));
6768
}
6869

69-
specs.emplace_back(o2::its3::align::getAlignmentSpec(srcTrc, srcCls, useMC, withPV, withITS, output));
70+
specs.emplace_back(o2::its3::align::getAlignmentSpec(srcTrc, srcCls, useMC, withPV, withITS, output, doStag));
7071

7172
o2::raw::HBFUtilsInitializer hbfIni(cfg, specs);
7273
return std::move(specs);

0 commit comments

Comments
 (0)