From ed56f12413ff28b3707fd30ceb4b81219faebff1 Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Wed, 5 Aug 2026 21:41:52 +0200 Subject: [PATCH 01/10] [PWGDQ] fix linter errors --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 237 ++++++++++++++-------------- 1 file changed, 118 insertions(+), 119 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index bdd60ef5717..86c9491f73a 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -132,78 +132,78 @@ struct muonGlobalAlignment { Configurable cfgProduceMFTTable{"cfgProduceMFTTable", false, "flag to produce MFTsa table"}; //// Variables for selecting MCH and MFT tracks - Configurable fTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""}; - Configurable fPtMchLow{"cfgPtMchLow", 0.7f, ""}; - Configurable fEtaMftLow{"cfgEtaMftlow", -3.6f, ""}; - Configurable fEtaMftUp{"cfgEtaMftup", -2.5f, ""}; - Configurable fRabsLow{"cfgRabsLow", 17.6f, ""}; - Configurable fRabsUp{"cfgRabsUp", 89.5f, ""}; - Configurable fSigmaPdcaUp{"cfgPdcaUp", 6.f, ""}; + Configurable cfgTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""}; + Configurable cfgPtMchLow{"cfgPtMchLow", 0.7f, ""}; + Configurable cfgEtaMftlow{"cfgEtaMftlow", -3.6f, ""}; + Configurable cfgEtaMftup{"cfgEtaMftup", -2.5f, ""}; + Configurable cfgRabsLow{"cfgRabsLow", 17.6f, ""}; + Configurable cfgRabsUp{"cfgRabsUp", 89.5f, ""}; + Configurable fSigmaPdcaUp{"fSigmaPdcaUp", 6.f, ""}; - Configurable fTrackNClustMftLow{"cfgTrackNClustMftLow", 7, ""}; - Configurable fTrackChi2MftUp{"cfgTrackChi2MftUp", 999.f, ""}; + Configurable cfgTrackNClustMftLow{"cfgTrackNClustMftLow", 7, ""}; + Configurable cfgTrackChi2MftUp{"cfgTrackChi2MftUp", 999.f, ""}; - Configurable fMftMchResidualsPLow{"cfgMftMchResidualsPLow", 30.f, ""}; - Configurable fMftMchResidualsPtLow{"cfgMftMchResidualsPtLow", 4.f, ""}; + Configurable cfgMftMchResidualsPLow{"cfgMftMchResidualsPLow", 30.f, ""}; + Configurable cfgMftMchResidualsPtLow{"cfgMftMchResidualsPtLow", 4.f, ""}; - Configurable fMftTracksMultiplicityMax{"cfgMftTracksMultiplicityMax", 0, "Maximum number of MFT tracks to be processed per event (zero means no limit)"}; + Configurable cfgMftTracksMultiplicityMax{"cfgMftTracksMultiplicityMax", 0, "Maximum number of MFT tracks to be processed per event (zero means no limit)"}; - Configurable fVertexZshift{"cfgVertexZshift", 0.0f, "Correction to the vertex z position"}; - Configurable fDipoleZshift{"cfgDipoleZshift", 0.0f, "Correction to the dipole z position"}; + Configurable cfgDipoleZshift{"cfgDipoleZshift", 0.0f, "Correction to the dipole z position"}; + Configurable cfgVertexZshift{"cfgVertexZshift", 0.0f, "Correction to the vertex z position"}; //// Variables for MFT alignment corrections struct : ConfigurableGroup { - Configurable fEnableMFTAlignmentCorrections{"cfgEnableMFTAlignmentCorrections", false, ""}; + Configurable cfgEnableMFTAlignmentCorrections{"cfgEnableMFTAlignmentCorrections", false, ""}; // slope corrections - Configurable fMFTAlignmentCorrXSlopeTop{"cfgMFTAlignmentCorrXSlopeTop", (-0.0006696 - 0.0005621) / 2.f, "MFT X slope correction - top half"}; - Configurable fMFTAlignmentCorrXSlopeBottom{"cfgMFTAlignmentCorrXSlopeBottom", (0.00105 + 0.001007) / 2.f, "MFT X slope correction - bottom half"}; - Configurable fMFTAlignmentCorrYSlopeTop{"cfgMFTAlignmentCorrYSlopeTop", (-0.002299 - 0.002442) / 2.f, "MFT Y slope correction - top half"}; - Configurable fMFTAlignmentCorrYSlopeBottom{"cfgMFTAlignmentCorrYSlopeBottom", (-0.0005339 - 0.0006921) / 2.f, "MFT Y slope correction - bottom half"}; + Configurable cfgMFTAlignmentCorrXSlopeTop{"cfgMFTAlignmentCorrXSlopeTop", (-0.0006696 - 0.0005621) / 2.f, "MFT X slope correction - top half"}; + Configurable cfgMFTAlignmentCorrXSlopeBottom{"cfgMFTAlignmentCorrXSlopeBottom", (0.00105 + 0.001007) / 2.f, "MFT X slope correction - bottom half"}; + Configurable cfgMFTAlignmentCorrYSlopeTop{"cfgMFTAlignmentCorrYSlopeTop", (-0.002299 - 0.002442) / 2.f, "MFT Y slope correction - top half"}; + Configurable cfgMFTAlignmentCorrYSlopeBottom{"cfgMFTAlignmentCorrYSlopeBottom", (-0.0005339 - 0.0006921) / 2.f, "MFT Y slope correction - bottom half"}; // offset corrections - Configurable fMFTAlignmentCorrXOffsetTop{"cfgMFTAlignmentCorrXOffsetTop", 0.f, "MFT X offset correction - top half"}; - Configurable fMFTAlignmentCorrXOffsetBottom{"cfgMFTAlignmentCorrXOffsetBottom", 0.f, "MFT X offset correction - bottom half"}; - Configurable fMFTAlignmentCorrYOffsetTop{"cfgMFTAlignmentCorrYOffsetTop", 0.f, "MFT Y offset correction - top half"}; - Configurable fMFTAlignmentCorrYOffsetBottom{"cfgMFTAlignmentCorrYOffsetBottom", 0.f, "MFT Y offset correction - bottom half"}; + Configurable cfgMFTAlignmentCorrXOffsetTop{"cfgMFTAlignmentCorrXOffsetTop", 0.f, "MFT X offset correction - top half"}; + Configurable cfgMFTAlignmentCorrXOffsetBottom{"cfgMFTAlignmentCorrXOffsetBottom", 0.f, "MFT X offset correction - bottom half"}; + Configurable cfgMFTAlignmentCorrYOffsetTop{"cfgMFTAlignmentCorrYOffsetTop", 0.f, "MFT Y offset correction - top half"}; + Configurable cfgMFTAlignmentCorrYOffsetBottom{"cfgMFTAlignmentCorrYOffsetBottom", 0.f, "MFT Y offset correction - bottom half"}; } configMFTAlignmentCorrections; //// Variables for re-alignment setup struct : ConfigurableGroup { - Configurable fEnableMCHRealign{"cfgEnableMCHRealign", true, "Enable re-alignment of MCH clusters and tracks"}; - Configurable fChamberResolutionX{"cfgChamberResolutionX", 0.4, "Chamber resolution along X configuration for refit"}; // 0.4cm pp, 0.2cm PbPb - Configurable fChamberResolutionY{"cfgChamberResolutionY", 0.4, "Chamber resolution along Y configuration for refit"}; // 0.4cm pp, 0.2cm PbPb - Configurable fSigmaCutImprove{"cfgSigmaCutImprove", 6., "Sigma cut for track improvement"}; - Configurable fMCHRealignCorrections{"cfgMCHRealignCorrections", "", "MCH DE positions/angles corrections in JSON format"}; + Configurable cfgEnableMCHRealign{"cfgEnableMCHRealign", true, "Enable re-alignment of MCH clusters and tracks"}; + Configurable cfgChamberResolutionX{"cfgChamberResolutionX", 0.4, "Chamber resolution along X configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgChamberResolutionY{"cfgChamberResolutionY", 0.4, "Chamber resolution along Y configuration for refit"}; // 0.4cm pp, 0.2cm PbPb + Configurable cfgSigmaCutImprove{"cfgSigmaCutImprove", 6., "Sigma cut for track improvement"}; + Configurable cfgMCHRealignCorrections{"cfgMCHRealignCorrections", "", "MCH DE positions/angles corrections in JSON format"}; } configRealign; //// Variables for ccdb struct : ConfigurableGroup { - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; // Configurable geoPathRealign{"geoPathRealign", "Users/j/jcastill/GeometryAlignedFix10Fix15ShiftCh1BNew2", "Path of the geometry file"}; Configurable geoPathRealign{"geoPathRealign", "Users/j/jcastill/GeometryAlignedLoczzm4pLHC24anap1sR5a", "Path of the geometry file"}; - Configurable nolaterthan{"ccdb-no-later-than-ref", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of reference basis"}; - Configurable nolaterthanRealign{"ccdb-no-later-than-new", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of new basis"}; + Configurable cfgCcdbNoLaterThanRef{"cfgCcdbNoLaterThanRef", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of reference basis"}; + Configurable cfgCcdbNoLaterThanNew{"cfgCcdbNoLaterThanNew", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object of new basis"}; } configCCDB; - Configurable fRequireGoodRCT{"cfgRequireGoodRCT", true, "Require good detector flags in Run Condition Table"}; + Configurable cfgRequireGoodRCT{"cfgRequireGoodRCT", true, "Require good detector flags in Run Condition Table"}; - Configurable fEnableVertexShiftAnalysis{"cfgEnableVertexShiftAnalysis", true, "Enable the analysis of vertex shift"}; - Configurable fEnableMftDcaAnalysis{"cfgEnableMftDcaAnalysis", true, "Enable the analysis of DCA-based MFT alignment"}; - Configurable fEnableMftDcaExtraPlots{"cfgEnableMftDcaExtraPlots", false, "Enable additional plots for the analysis of DCA-based MFT alignment"}; - Configurable fEnableGlobalFwdDcaAnalysis{"cfgEnableGlobalFwdDcaAnalysis", true, "Enable the analysis of DCA-based MFT alignment using global forward tracks"}; - Configurable fEnableMftMchResidualsAnalysis{"cfgEnableMftMchResidualsAnalysis", true, "Enable the analysis of residuals between MFT tracks and MCH clusters"}; - Configurable fEnableMftMchResidualsExtraPlots{"cfgEnableMftMchResidualsExtraPlots", false, "Enable additional plots for the analysis of residuals between MFT tracks and MCH clusters"}; - Configurable fEnableMftMchMatchingAnalysis{"cfgEnableMftMchMatchingAnalysis", false, "Enable the analysis of residuals between MFT and MCH tracks at reference planes"}; + Configurable cfgEnableVertexShiftAnalysis{"cfgEnableVertexShiftAnalysis", false, "Enable the analysis of vertex shift"}; + Configurable cfgEnableMftDcaAnalysis{"cfgEnableMftDcaAnalysis", false, "Enable the analysis of DCA-based MFT alignment"}; + Configurable cfgEnableMftDcaExtraPlots{"cfgEnableMftDcaExtraPlots", false, "Enable additional plots for the analysis of DCA-based MFT alignment"}; + Configurable cfgEnableGlobalFwdDcaAnalysis{"cfgEnableGlobalFwdDcaAnalysis", false, "Enable the analysis of DCA-based MFT alignment using global forward tracks"}; + Configurable cfgEnableMftMchResidualsAnalysis{"cfgEnableMftMchResidualsAnalysis", true, "Enable the analysis of residuals between MFT tracks and MCH clusters"}; + Configurable cfgEnableMftMchResidualsExtraPlots{"cfgEnableMftMchResidualsExtraPlots", false, "Enable additional plots for the analysis of residuals between MFT tracks and MCH clusters"}; + Configurable cfgEnableMftMchMatchingAnalysis{"cfgEnableMftMchMatchingAnalysis", false, "Enable the analysis of residuals between MFT and MCH tracks at reference planes"}; - Configurable fRefPlaneZMFT{"cfgRefPlaneZMFT", o2::mft::constants::mft::LayerZCoordinate()[0], "Reference plane on MFT side"}; - Configurable fRefPlaneZMCH{"cfgRefPlaneZMCH", -526.0, "Reference plane on MCH side"}; + Configurable cfgRefPlaneZMFT{"cfgRefPlaneZMFT", o2::mft::constants::mft::LayerZCoordinate()[0], "Reference plane on MFT side"}; + Configurable cfgRefPlaneZMCH{"cfgRefPlaneZMCH", -526.0, "Reference plane on MCH side"}; int mRunNumber{0}; // needed to detect if the run changed and trigger update of magnetic field Service ccdbManager; - o2::field::MagneticField* fieldB; + o2::field::MagneticField* fieldB{nullptr}; o2::ccdb::CcdbApi ccdbApi; // Derived version of mch::Track class that handles the associated clusters as internal objects and deletes them in the destructor @@ -228,7 +228,7 @@ struct muonGlobalAlignment { TGeoManager* geoNew = nullptr; TGeoManager* geoRef = nullptr; TrackFitter trackFitter; // Track fitter from MCH tracking library - double mImproveCutChi2; // Chi2 cut for track improvement. + double mImproveCutChi2{0}; // Chi2 cut for track improvement. struct AlignmentCorrections { double x{0}; @@ -278,7 +278,7 @@ struct muonGlobalAlignment { auto collision = collisions.rawIteratorAt(muonTrack.collisionId()); - if (fRequireGoodRCT && !rctChecker(collision)) + if (cfgRequireGoodRCT && !rctChecker(collision)) continue; uint64_t collisionIndex = collision.globalIndex(); @@ -377,12 +377,12 @@ struct muonGlobalAlignment { } // Load geometry information from CCDB/local - LOGF(info, "Loading reference aligned geometry from CCDB no later than %d", configCCDB.nolaterthan.value); - ccdbManager->setCreatedNotAfter(configCCDB.nolaterthan); // this timestamp has to be consistent with what has been used in reco + LOGF(info, "Loading reference aligned geometry from CCDB no later than %d", configCCDB.cfgCcdbNoLaterThanRef.value); + ccdbManager->setCreatedNotAfter(configCCDB.cfgCcdbNoLaterThanRef); // this timestamp has to be consistent with what has been used in reco geoRef = ccdbManager->getForTimeStamp(configCCDB.geoPath, bc.timestamp()); ccdbManager->clearCache(configCCDB.geoPath); - if (configRealign.fEnableMCHRealign && fEnableMftMchResidualsAnalysis) { + if (configRealign.cfgEnableMCHRealign && (cfgEnableMftMchResidualsAnalysis)) { if (geoRef != nullptr) { transformation = geo::transformationFromTGeoManager(*geoRef); } else { @@ -393,8 +393,8 @@ struct muonGlobalAlignment { transformRef[iDEN] = transformation(iDEN); } - LOGF(info, "Loading new aligned geometry from CCDB no later than %d", configCCDB.nolaterthanRealign.value); - ccdbManager->setCreatedNotAfter(configCCDB.nolaterthanRealign); // make sure this timestamp can be resolved regarding the reference one + LOGF(info, "Loading new aligned geometry from CCDB no later than %d", configCCDB.cfgCcdbNoLaterThanNew.value); + ccdbManager->setCreatedNotAfter(configCCDB.cfgCcdbNoLaterThanNew); // make sure this timestamp can be resolved regarding the reference one geoNew = ccdbManager->getForTimeStamp(configCCDB.geoPathRealign, bc.timestamp()); ccdbManager->clearCache(configCCDB.geoPathRealign); if (geoNew != nullptr) { @@ -412,10 +412,10 @@ struct muonGlobalAlignment { void init(o2::framework::InitContext&) { // Load geometry - ccdbManager->setURL(configCCDB.ccdburl); + ccdbManager->setURL(configCCDB.ccdbUrl); ccdbManager->setCaching(true); ccdbManager->setLocalObjectValidityChecking(); - ccdbApi.init(configCCDB.ccdburl); + ccdbApi.init(configCCDB.ccdbUrl); mRunNumber = 0; if (!o2::base::GeometryManager::isGeometryLoaded()) { @@ -426,15 +426,15 @@ struct muonGlobalAlignment { // Configuration for track fitter const auto& trackerParam = TrackerParam::Instance(); trackFitter.setBendingVertexDispersion(trackerParam.bendingVertexDispersion); - trackFitter.setChamberResolution(configRealign.fChamberResolutionX, configRealign.fChamberResolutionY); + trackFitter.setChamberResolution(configRealign.cfgChamberResolutionX, configRealign.cfgChamberResolutionY); trackFitter.smoothTracks(true); trackFitter.useChamberResolution(); - mImproveCutChi2 = 2. * configRealign.fSigmaCutImprove * configRealign.fSigmaCutImprove; + mImproveCutChi2 = 2. * configRealign.cfgSigmaCutImprove * configRealign.cfgSigmaCutImprove; // Fill table of MCH alignment corrections rapidjson::Document document; // Check that the json is parsed correctly - rapidjson::ParseResult jsonOk = document.Parse(configRealign.fMCHRealignCorrections.value.c_str()); + rapidjson::ParseResult jsonOk = document.Parse(configRealign.cfgMCHRealignCorrections.value.c_str()); if (jsonOk) { for (rapidjson::Value::ConstMemberIterator it = document.MemberBegin(); it != document.MemberEnd(); it++) { LOG(info) << "DE" << it->name.GetString() << " alignment corrections:"; @@ -479,12 +479,12 @@ struct muonGlobalAlignment { registry.add("vertex_y_vs_x", std::format("Vertex y vs. x").c_str(), {HistType::kTH2F, {vxAxis, vyAxis}}); registry.add("vertex_z", std::format("Vertex z").c_str(), {HistType::kTH1F, {vzAxis}}); - if (fEnableVertexShiftAnalysis || fEnableMftDcaAnalysis) { + if (cfgEnableVertexShiftAnalysis || cfgEnableMftDcaAnalysis) { registry.add("DCA/MFT/nTracksMFT", std::format("Number of MFT tracks per collision").c_str(), {HistType::kTH1F, {{100, 0, 1000, "# of MFT tracks"}}}); registry.add("DCA/MFT/DCA_y_vs_x", std::format("DCA y vs. x").c_str(), {HistType::kTH2F, {dcaxMFTAxis, dcayMFTAxis}}); } - if (fEnableVertexShiftAnalysis) { + if (cfgEnableVertexShiftAnalysis) { registry.add("DCA/MFT/DCA_x_vs_phi_vs_zshift", std::format("DCA(x) vs. #phi vs. z shift").c_str(), {HistType::kTH3F, {zshiftAxis, phiAxis, dcaxMFTAxis}}); registry.add("DCA/MFT/DCA_y_vs_phi_vs_zshift", std::format("DCA(y) vs. #phi vs. z shift").c_str(), {HistType::kTH3F, {zshiftAxis, phiAxis, dcayMFTAxis}}); @@ -494,13 +494,13 @@ struct muonGlobalAlignment { registry.add("DCA/MFT/DCA_y_vs_slopey_vs_zshift", std::format("DCA(y) vs. y slope vs. z shift").c_str(), {HistType::kTH3F, {zshiftAxis, syAxis, dcayMFTAxis}}); } - if (fEnableMftDcaAnalysis) { + if (cfgEnableMftDcaAnalysis) { registry.add("DCA/MFT/DCA_x", "DCA(x) vs. vz, tx, ty, nclus", HistType::kTHnSparseF, {dcaxMFTAxis, dcazAxis, txAxis, tyAxis, nMftClustersAxis}); registry.add("DCA/MFT/DCA_y", "DCA(y) vs. vz, tx, ty, nclus", HistType::kTHnSparseF, {dcayMFTAxis, dcazAxis, txAxis, tyAxis, nMftClustersAxis}); - if (fEnableMftDcaExtraPlots) { + if (cfgEnableMftDcaExtraPlots) { registry.add("DCA/MFT/layers", "Layers vs. tx, ty, nclus", HistType::kTHnSparseF, {mftLayerAxis, txAxis, tyAxis, nMftClustersAxis}); registry.add("DCA/MFT/trackChi2", "Track #chi^{2} vs. tx, ty, nclus, layer", @@ -520,14 +520,14 @@ struct muonGlobalAlignment { } } - if (fEnableGlobalFwdDcaAnalysis) { + if (cfgEnableGlobalFwdDcaAnalysis) { registry.add("DCA/GlobalFwd/DCA_x", "DCA(x) vs. vz, tx, ty, nclus", HistType::kTHnSparseF, {dcaxMFTAxis, dcazAxis, txAxis, tyAxis, nMftClustersAxis}); registry.add("DCA/GlobalFwd/DCA_y", "DCA(y) vs. vz, tx, ty, nclus", HistType::kTHnSparseF, {dcayMFTAxis, dcazAxis, txAxis, tyAxis, nMftClustersAxis}); } - if (fEnableMftMchResidualsAnalysis) { + if (cfgEnableMftMchResidualsAnalysis) { AxisSpec dxAxis = {400, -20.0, 20.0, "#Delta x (cm)"}; AxisSpec dyAxis = {400, -20.0, 20.0, "#Delta y (cm)"}; @@ -571,7 +571,7 @@ struct muonGlobalAlignment { registry.get(HIST("residuals/de_alignment_corrections_y"))->SetBinError(deIndex + 1, 0.1); } - if (fEnableMftMchResidualsExtraPlots) { + if (cfgEnableMftMchResidualsExtraPlots) { registry.add("DCA/MCH/DCA_x_vs_sign_vs_quadrant_vs_vz", std::format("DCA(x) vs. vz, quadrant, chargeSign").c_str(), {HistType::kTHnSparseF, {dcazAxis, {4, 0, 4, "quadrant"}, {2, 0, 2, "sign"}, dcaxMCHAxis}}); registry.add("DCA/MCH/DCA_y_vs_sign_vs_quadrant_vs_vz", std::format("DCA(y) vs. vz, quadrant, chargeSign").c_str(), {HistType::kTHnSparseF, {dcazAxis, {4, 0, 4, "quadrant"}, {2, 0, 2, "sign"}, dcayMCHAxis}}); @@ -580,7 +580,7 @@ struct muonGlobalAlignment { } } - if (fEnableMftMchMatchingAnalysis) { + if (cfgEnableMftMchMatchingAnalysis) { AxisSpec dxAxis = {200, -10.0, 10.0, "#Deltax (cm)"}; AxisSpec dyAxis = {200, -10.0, 10.0, "#Deltay (cm)"}; AxisSpec dsxAxis = {200, -0.1, 0.1, "#Deltaslope(x) (rad)"}; @@ -978,7 +978,7 @@ struct muonGlobalAlignment { template bool IsGoodMFT(const T& mftTrack) { - return IsGoodMFT(mftTrack, fTrackChi2MftUp, fTrackNClustMftLow); + return IsGoodMFT(mftTrack, cfgTrackChi2MftUp, cfgTrackNClustMftLow); } template @@ -1082,15 +1082,15 @@ struct muonGlobalAlignment { double xSlope = track.getNonBendingSlope(); double ySlope = track.getBendingSlope(); - double xSlopeCorrection = (y > 0) ? configMFTAlignmentCorrections.fMFTAlignmentCorrXSlopeTop : configMFTAlignmentCorrections.fMFTAlignmentCorrXSlopeBottom; + double xSlopeCorrection = (y > 0) ? configMFTAlignmentCorrections.cfgMFTAlignmentCorrXSlopeTop : configMFTAlignmentCorrections.cfgMFTAlignmentCorrXSlopeBottom; double xCorrection = xSlopeCorrection * z + - ((y > 0) ? configMFTAlignmentCorrections.fMFTAlignmentCorrXOffsetTop : configMFTAlignmentCorrections.fMFTAlignmentCorrXOffsetBottom); + ((y > 0) ? configMFTAlignmentCorrections.cfgMFTAlignmentCorrXOffsetTop : configMFTAlignmentCorrections.cfgMFTAlignmentCorrXOffsetBottom); track.setNonBendingCoor(x + xCorrection); track.setNonBendingSlope(xSlope + xSlopeCorrection); - double ySlopeCorrection = (y > 0) ? configMFTAlignmentCorrections.fMFTAlignmentCorrYSlopeTop : configMFTAlignmentCorrections.fMFTAlignmentCorrYSlopeBottom; + double ySlopeCorrection = (y > 0) ? configMFTAlignmentCorrections.cfgMFTAlignmentCorrYSlopeTop : configMFTAlignmentCorrections.cfgMFTAlignmentCorrYSlopeBottom; double yCorrection = ySlopeCorrection * z + - ((y > 0) ? configMFTAlignmentCorrections.fMFTAlignmentCorrYOffsetTop : configMFTAlignmentCorrections.fMFTAlignmentCorrYOffsetBottom); + ((y > 0) ? configMFTAlignmentCorrections.cfgMFTAlignmentCorrYOffsetTop : configMFTAlignmentCorrections.cfgMFTAlignmentCorrYOffsetBottom); track.setBendingCoor(y + yCorrection); track.setBendingSlope(ySlope + ySlopeCorrection); /* @@ -1202,10 +1202,10 @@ struct muonGlobalAlignment { o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, z); } else if (z < absBack) { // extrapolation downstream of the absorber, correct for dipole longitudinal shift if needed - if (fDipoleZshift.value != 0) { - mchTrack.setZ(mchTrack.getZ() + fDipoleZshift.value); - o2::mch::TrackExtrap::extrapToZCov(mchTrack, z + fDipoleZshift.value); - mchTrack.setZ(mchTrack.getZ() - fDipoleZshift.value); + if (cfgDipoleZshift.value != 0) { + mchTrack.setZ(mchTrack.getZ() + cfgDipoleZshift.value); + o2::mch::TrackExtrap::extrapToZCov(mchTrack, z + cfgDipoleZshift.value); + mchTrack.setZ(mchTrack.getZ() - cfgDipoleZshift.value); } else { o2::mch::TrackExtrap::extrapToZCov(mchTrack, z); } @@ -1305,7 +1305,7 @@ struct muonGlobalAlignment { 0, 0, 0, 0, 0}; SMatrix55 tcovs(v1.begin(), v1.end()); o2::track::TrackParCovFwd fwdtrack{mftTrack.z(), tpars, tcovs, chi2}; - if (configMFTAlignmentCorrections.fEnableMFTAlignmentCorrections) { + if (configMFTAlignmentCorrections.cfgEnableMFTAlignmentCorrections) { TransformMFT(fwdtrack); } o2::dataformats::GlobalFwdTrack propmuon; @@ -1349,7 +1349,7 @@ struct muonGlobalAlignment { 0, 0, 0, 0, 0}; SMatrix55 tcovs(v1.begin(), v1.end()); o2::track::TrackParCovFwd fwdtrack{mftTrack.z(), tpars, tcovs, chi2}; - if (configMFTAlignmentCorrections.fEnableMFTAlignmentCorrections) { + if (configMFTAlignmentCorrections.cfgEnableMFTAlignmentCorrections) { TransformMFT(fwdtrack); } @@ -1389,7 +1389,7 @@ struct muonGlobalAlignment { o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrackAtMFT, mftTrack.z()); auto mftTrackPar = FwdToTrackPar(mftTrack); - if (configMFTAlignmentCorrections.fEnableMFTAlignmentCorrections) { + if (configMFTAlignmentCorrections.cfgEnableMFTAlignmentCorrections) { TransformMFT(mftTrackPar); } auto mftTrackProp = FwdtoMCH(mftTrackPar); @@ -1399,20 +1399,20 @@ struct muonGlobalAlignment { UpdateTrackMomentum(mftTrackProp, mchTrackPar); } - if (fDipoleZshift.value != 0) { + if (cfgDipoleZshift.value != 0) { // extrapolate to the back of the absorber, taking into account the dipole shift, // to avoid that the correction bring the track starting point back into the absorber - if (fDipoleZshift.value < 0) { + if (cfgDipoleZshift.value < 0) { o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -505.f); - } else if (fDipoleZshift.value > 0) { - o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -505.f - fDipoleZshift.value); + } else if (cfgDipoleZshift.value > 0) { + o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -505.f - cfgDipoleZshift.value); } // shift the track starting point - mftTrackProp.setZ(mftTrackProp.getZ() + fDipoleZshift.value); + mftTrackProp.setZ(mftTrackProp.getZ() + cfgDipoleZshift.value); // extrapolate to the final z, corrected for the dipole shift - o2::mch::TrackExtrap::extrapToZ(mftTrackProp, z + fDipoleZshift.value); + o2::mch::TrackExtrap::extrapToZ(mftTrackProp, z + cfgDipoleZshift.value); // remove the shift from the extrapolated track - mftTrackProp.setZ(mftTrackProp.getZ() - fDipoleZshift.value); + mftTrackProp.setZ(mftTrackProp.getZ() - cfgDipoleZshift.value); } else { o2::mch::TrackExtrap::extrapToZ(mftTrackProp, z); } @@ -1439,17 +1439,17 @@ struct muonGlobalAlignment { registry.get(HIST("vertex_y_vs_x"))->Fill(collision.posX(), collision.posY()); registry.get(HIST("vertex_z"))->Fill(collision.posZ()); - if (fEnableVertexShiftAnalysis || fEnableMftDcaAnalysis) { + if (cfgEnableVertexShiftAnalysis || cfgEnableMftDcaAnalysis) { registry.get(HIST("DCA/MFT/nTracksMFT"))->Fill(collisionInfo.mftTracks.size()); } - if (fEnableVertexShiftAnalysis || fEnableMftDcaAnalysis) { + if (cfgEnableVertexShiftAnalysis || cfgEnableMftDcaAnalysis) { // loop over MFT tracks auto mftTrackIds = collisionInfo.mftTracks; - if (fMftTracksMultiplicityMax > 0 && mftTrackIds.size() > fMftTracksMultiplicityMax) { + if (cfgMftTracksMultiplicityMax > 0 && mftTrackIds.size() > cfgMftTracksMultiplicityMax) { auto rng = std::default_random_engine{}; std::shuffle(std::begin(mftTrackIds), std::end(mftTrackIds), rng); - mftTrackIds.resize(fMftTracksMultiplicityMax); + mftTrackIds.resize(cfgMftTracksMultiplicityMax); } for (auto mftIndex : mftTrackIds) { @@ -1463,7 +1463,7 @@ struct muonGlobalAlignment { if (!isGoodMFT) continue; - auto mftTrackAtDCA = PropagateMFTToDCA(mftTrack, collision, fVertexZshift); + auto mftTrackAtDCA = PropagateMFTToDCA(mftTrack, collision, cfgVertexZshift); double dcax = mftTrackAtDCA.getX() - collision.posX(); double dcay = mftTrackAtDCA.getY() - collision.posY(); double phi = mftTrack.phi() * 180 / TMath::Pi(); @@ -1480,9 +1480,8 @@ struct muonGlobalAlignment { } } - if (fEnableMftDcaAnalysis) { - const int nMftLayers = 10; - if (fEnableMftDcaExtraPlots) { + if (cfgEnableMftDcaAnalysis) { + if (cfgEnableMftDcaExtraPlots) { for (int i = 0; i < nMftLayers; i++) { if (firedLayers[i]) { registry.get(HIST("DCA/MFT/trackChi2"))->Fill(mftTrack.chi2() / chi2NDF, mftTrack.x(), mftTrack.y(), mftNclusters, i); @@ -1490,7 +1489,7 @@ struct muonGlobalAlignment { } } - if (mftTrack.chi2() <= fTrackChi2MftUp) { + if (mftTrack.chi2() <= cfgTrackChi2MftUp) { registry.get(HIST("DCA/MFT/DCA_y_vs_x"))->Fill(dcax, dcay); registry.get(HIST("DCA/MFT/DCA_x"))->Fill(dcax, collision.posZ(), mftTrack.x(), mftTrack.y(), mftNclusters); registry.get(HIST("DCA/MFT/DCA_y"))->Fill(dcay, collision.posZ(), mftTrack.x(), mftTrack.y(), mftNclusters); @@ -1503,7 +1502,7 @@ struct muonGlobalAlignment { mftTrack.x(), mftTrack.y(), mftTrack.z()); } - if (fEnableMftDcaExtraPlots) { + if (cfgEnableMftDcaExtraPlots) { if (mftNclusters >= 6) { for (int i = 0; i < nMftLayers; i++) { auto mftTrackAtLayer = PropagateMFT(mftTrack, o2::mft::constants::mft::LayerZCoordinate()[i]); @@ -1523,8 +1522,8 @@ struct muonGlobalAlignment { } } - if (fEnableVertexShiftAnalysis) { - if (mftTrack.chi2() <= fTrackChi2MftUp && std::fabs(collision.posZ()) < 1.f && mftNclusters >= 6) { + if (cfgEnableVertexShiftAnalysis) { + if (mftTrack.chi2() <= cfgTrackChi2MftUp && std::fabs(collision.posZ()) < 1.f && mftNclusters >= 6) { float zshift[21] = {// in millimeters -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; @@ -1548,7 +1547,7 @@ struct muonGlobalAlignment { } } - if (fEnableGlobalFwdDcaAnalysis) { + if (cfgEnableGlobalFwdDcaAnalysis) { // loop over global muon tracks for (auto& [muonIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { auto const& muonTrack = muonTracks.rawIteratorAt(globalTracksVector[0]); @@ -1572,21 +1571,21 @@ struct muonGlobalAlignment { continue; } - bool isGoodMFT = IsGoodMFT(mftTrack, fTrackChi2MftUp, 5); + bool isGoodMFT = IsGoodMFT(mftTrack, cfgTrackChi2MftUp, 5); if (!isGoodMFT) { continue; } - bool isGoodMuon = IsGoodMuon(mchTrack, collision, fTrackChi2MchUp, 0.f, fPtMchLow, {fEtaMftLow, fEtaMftUp}, {fRabsLow, fRabsUp}, fSigmaPdcaUp); + bool isGoodMuon = IsGoodMuon(mchTrack, collision, cfgTrackChi2MchUp, 0.f, cfgPtMchLow, {cfgEtaMftlow, cfgEtaMftup}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp); if (!isGoodMuon) continue; - auto mftTrackAtDCA = PropagateMFTToDCA(mftTrack, mchTrack, collision, fVertexZshift); + auto mftTrackAtDCA = PropagateMFTToDCA(mftTrack, mchTrack, collision, cfgVertexZshift); double dcax = mftTrackAtDCA.getX() - collision.posX(); double dcay = mftTrackAtDCA.getY() - collision.posY(); int mftNclusters = mftTrack.nClusters(); - if (mftTrack.chi2() <= fTrackChi2MftUp) { + if (mftTrack.chi2() <= cfgTrackChi2MftUp) { registry.get(HIST("DCA/GlobalFwd/DCA_x"))->Fill(dcax, collision.posZ(), mftTrack.x(), mftTrack.y(), mftNclusters); registry.get(HIST("DCA/GlobalFwd/DCA_y"))->Fill(dcay, collision.posZ(), mftTrack.x(), mftTrack.y(), mftNclusters); } @@ -1615,15 +1614,15 @@ struct muonGlobalAlignment { master.SetXYZ(cluster.x(), cluster.y(), cluster.z()); - if (configRealign.fEnableMCHRealign) { + if (configRealign.cfgEnableMCHRealign) { // Transformation from reference geometry frame to new geometry frame transformRef[cluster.deId()].MasterToLocal(master, local); transformNew[cluster.deId()].LocalToMaster(local, master); } // shift the clusters to correct the longitudinal shift of the dipole - if (fDipoleZshift.value != 0) { - master.SetZ(master.z() + fDipoleZshift.value); + if (cfgDipoleZshift.value != 0) { + master.SetZ(master.z() + cfgDipoleZshift.value); } if (applyCorrections) { @@ -1660,9 +1659,9 @@ struct muonGlobalAlignment { } // subtract the longitudinal shift of the dipole from the track z - if (fDipoleZshift.value != 0) { + if (cfgDipoleZshift.value != 0) { auto& trackParam = *(convertedTrack.begin()); - trackParam.setZ(trackParam.getZ() - fDipoleZshift.value); + trackParam.setZ(trackParam.getZ() - cfgDipoleZshift.value); } return !removable; @@ -1674,7 +1673,7 @@ struct muonGlobalAlignment { aod::FwdTrkCls const& clusters, const std::map& collisionInfos) { - if (!fEnableMftMchResidualsAnalysis && !fEnableMftMchMatchingAnalysis) { + if (!cfgEnableMftMchResidualsAnalysis && !cfgEnableMftMchMatchingAnalysis) { return; } @@ -1697,11 +1696,11 @@ struct muonGlobalAlignment { int quadrant = GetQuadrant(mftTrack); int posNeg = (mchTrack.sign() >= 0) ? 0 : 1; - bool isGoodMuon = IsGoodMuon(mchTrack, collision, fTrackChi2MchUp, fMftMchResidualsPLow, fMftMchResidualsPtLow, {fEtaMftLow, fEtaMftUp}, {fRabsLow, fRabsUp}, fSigmaPdcaUp); + bool isGoodMuon = IsGoodMuon(mchTrack, collision, cfgTrackChi2MchUp, cfgMftMchResidualsPLow, cfgMftMchResidualsPtLow, {cfgEtaMftlow, cfgEtaMftup}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp); if (!isGoodMuon) continue; - bool isGoodMFT = IsGoodMFT(mftTrack, fTrackChi2MftUp, fTrackNClustMftLow); + bool isGoodMFT = IsGoodMFT(mftTrack, cfgTrackChi2MftUp, cfgTrackNClustMftLow); if (!isGoodMFT) continue; @@ -1712,7 +1711,7 @@ struct muonGlobalAlignment { // refit MCH track if enabled TrackRealigned convertedTrack; bool convertedTrackOk = false; - if (configRealign.fEnableMCHRealign) { + if (configRealign.cfgEnableMCHRealign) { convertedTrackOk = MchRealignTrack(mchTrack, clusters, convertedTrack, false); } @@ -1723,7 +1722,7 @@ struct muonGlobalAlignment { convertedTrackWithCorrOk = MchRealignTrack(mchTrack, clusters, convertedTrackWithCorr, true); } - if (fEnableMftMchResidualsAnalysis) { + if (cfgEnableMftMchResidualsAnalysis) { // loop over attached clusters auto clustersSliced = clusters.sliceBy(perMuon, mchTrack.globalIndex()); // Slice clusters by muon id for (auto const& cluster : clustersSliced) { @@ -1741,7 +1740,7 @@ struct muonGlobalAlignment { masterWithCorr.SetXYZ(cluster.x(), cluster.y(), cluster.z()); // apply realignment to MCH cluster - if (configRealign.fEnableMCHRealign) { + if (configRealign.cfgEnableMCHRealign) { // Transformation from reference geometry frame to new geometry frame transformRef[cluster.deId()].MasterToLocal(master, local); transformNew[cluster.deId()].LocalToMaster(local, master); @@ -1762,8 +1761,8 @@ struct muonGlobalAlignment { // MFT-MCH residuals (MCH cluster is realigned if enabled) // if the realignment is enabled and successful, the MFT track is extrpolated // by taking the momentum from the MCH track refitted with the new alignment - if (!configRealign.fEnableMCHRealign || convertedTrackOk) { - auto mftTrackAtCluster = configRealign.fEnableMCHRealign ? PropagateMFTtoMCH(mftTrack, mch::TrackParam(convertedTrack.first()), master.z()) : PropagateMFTtoMCH(mftTrack, FwdtoMCH(FwdToTrackPar(mchTrack)), master.z()); + if (!configRealign.cfgEnableMCHRealign || convertedTrackOk) { + auto mftTrackAtCluster = configRealign.cfgEnableMCHRealign ? PropagateMFTtoMCH(mftTrack, mch::TrackParam(convertedTrack.first()), master.z()) : PropagateMFTtoMCH(mftTrack, FwdtoMCH(FwdToTrackPar(mchTrack)), master.z()); auto mftTrackParamAtCluster = FwdtoMCH(mftTrackAtCluster); std::array xPos{master.x(), mftTrackAtCluster.getX()}; @@ -1795,8 +1794,8 @@ struct muonGlobalAlignment { } } - if (!configRealign.fEnableMCHRealign || convertedTrackOk) { - auto mchTrackAtDCA = configRealign.fEnableMCHRealign ? PropagateMCHRealigned(convertedTrack, collision.posZ()) : PropagateMCH(mchTrack, collision.posZ()); + if (!configRealign.cfgEnableMCHRealign || convertedTrackOk) { + auto mchTrackAtDCA = configRealign.cfgEnableMCHRealign ? PropagateMCHRealigned(convertedTrack, collision.posZ()) : PropagateMCH(mchTrack, collision.posZ()); auto dcax = mchTrackAtDCA.getX() - collision.posX(); auto dcay = mchTrackAtDCA.getY() - collision.posY(); @@ -1804,10 +1803,10 @@ struct muonGlobalAlignment { registry.get(HIST("DCA/MCH/DCA_x_vs_sign_vs_quadrant_vs_mom"))->Fill(mchTrack.p(), quadrant, posNeg, dcax); registry.get(HIST("DCA/MCH/DCA_y_vs_sign_vs_quadrant_vs_mom"))->Fill(mchTrack.p(), quadrant, posNeg, dcay); - if (fEnableMftMchResidualsExtraPlots) { + if (cfgEnableMftMchResidualsExtraPlots) { registry.get(HIST("DCA/MCH/DCA_x_vs_sign_vs_quadrant_vs_vz"))->Fill(collision.posZ(), quadrant, posNeg, dcax); registry.get(HIST("DCA/MCH/DCA_y_vs_sign_vs_quadrant_vs_vz"))->Fill(collision.posZ(), quadrant, posNeg, dcay); - auto mchTrackAtMFT = configRealign.fEnableMCHRealign ? PropagateMCHRealigned(convertedTrack, mftTrack.z()) : PropagateMCH(mchTrack, mftTrack.z()); + auto mchTrackAtMFT = configRealign.cfgEnableMCHRealign ? PropagateMCHRealigned(convertedTrack, mftTrack.z()) : PropagateMCH(mchTrack, mftTrack.z()); double deltaPhi = mchTrackAtMFT.getPhi() - mftTrack.phi(); registry.get(HIST("residuals/dphi_at_mft"))->Fill(deltaPhi, mftTrack.x(), mftTrack.y(), posNeg, mchTrackAtMFT.getP()); } @@ -1824,8 +1823,8 @@ struct muonGlobalAlignment { } // MFT-MCH track residuals analysis - if (fEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk) { - double refPlaneZ[2] = {fRefPlaneZMFT, fRefPlaneZMCH}; + if (cfgEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk)) { + double refPlaneZ[2] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; std::shared_ptr dxPlots[2]{registry.get(HIST("matching/dxAtMFT")), registry.get(HIST("matching/dxAtMCH"))}; std::shared_ptr dyPlots[2]{registry.get(HIST("matching/dyAtMFT")), registry.get(HIST("matching/dyAtMCH"))}; @@ -1834,8 +1833,8 @@ struct muonGlobalAlignment { std::shared_ptr dphiPlots[2]{registry.get(HIST("matching/dphiAtMFT")), registry.get(HIST("matching/dphiAtMCH"))}; for (int iRefPlane = 0; iRefPlane < 2; iRefPlane++) { - const auto mftTrackAtRefPlane = configRealign.fEnableMCHRealign ? PropagateMFTtoMCH(mftTrack, mch::TrackParam(convertedTrackWithCorr.first()), refPlaneZ[iRefPlane]) : PropagateMFTtoMCH(mftTrack, FwdtoMCH(FwdToTrackPar(mchTrack)), refPlaneZ[iRefPlane]); - const auto mchTrackAtRefPlane = configRealign.fEnableMCHRealign ? PropagateMCHRealigned(convertedTrackWithCorr, refPlaneZ[iRefPlane]) : PropagateMCH(mchTrack, refPlaneZ[iRefPlane]); + const auto mftTrackAtRefPlane = configRealign.cfgEnableMCHRealign ? PropagateMFTtoMCH(mftTrack, mch::TrackParam(convertedTrackWithCorr.first()), refPlaneZ[iRefPlane]) : PropagateMFTtoMCH(mftTrack, FwdtoMCH(FwdToTrackPar(mchTrack)), refPlaneZ[iRefPlane]); + const auto mchTrackAtRefPlane = configRealign.cfgEnableMCHRealign ? PropagateMCHRealigned(convertedTrackWithCorr, refPlaneZ[iRefPlane]) : PropagateMCH(mchTrack, refPlaneZ[iRefPlane]); const auto& refTrackAtRefPlane = (iRefPlane == 0) ? mftTrackAtRefPlane : mchTrackAtRefPlane; auto dx = mchTrackAtRefPlane.getX() - mftTrackAtRefPlane.getX(); From 88909a1fdf1ef30ea6b4bbeb6d65b2ee216ad19d Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Wed, 5 Aug 2026 22:13:08 +0200 Subject: [PATCH 02/10] [PWGDQ] more fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 38 +++++++++++++---------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index 86c9491f73a..d4c6755e258 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -128,6 +128,8 @@ using CompactMFTTrack = CompactMFTTracks; struct muonGlobalAlignment { + static constexpr int GlobalTrackTypeMax = 2; + Produces mftTable; Configurable cfgProduceMFTTable{"cfgProduceMFTTable", false, "flag to produce MFTsa table"}; @@ -289,7 +291,7 @@ struct muonGlobalAlignment { collisionInfo.bc = bc.globalBC(); collisionInfo.zVertex = collision.posZ(); - if (static_cast(muonTrack.trackType()) > 2) { + if (static_cast(muonTrack.trackType()) > GlobalTrackTypeMax) { // standalone MCH or MCH-MID tracks uint64_t mchTrackIndex = muonTrack.globalIndex(); collisionInfo.mchTracks.push_back(mchTrackIndex); @@ -320,8 +322,8 @@ struct muonGlobalAlignment { return (track1.chi2MatchMCHMFT() < track2.chi2MatchMCHMFT()); }; - for (auto& [collisionIndex, collisionInfo] : collisionInfos) { - for (auto& [mchIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { + for (auto& [collisionIndex, collisionInfo] : collisionInfos) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) + for (auto& [mchIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareChi2); } } @@ -336,7 +338,7 @@ struct muonGlobalAlignment { InitCollisions(collisions, bcs, muonTracks, collisionInfos); // fill collision information for MFT standalone tracks - for (auto mftTrack : mftTracks) { + for (const auto& mftTrack : mftTracks) { if (!mftTrack.has_collision()) continue; @@ -950,7 +952,7 @@ struct muonGlobalAlignment { } if (!removeTrack) { - for (auto& param : track) { + for (auto& param : track) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) param.setParameters(param.getSmoothParameters()); param.setCovariances(param.getSmoothCovariances()); } @@ -1093,12 +1095,6 @@ struct muonGlobalAlignment { ((y > 0) ? configMFTAlignmentCorrections.cfgMFTAlignmentCorrYOffsetTop : configMFTAlignmentCorrections.cfgMFTAlignmentCorrYOffsetBottom); track.setBendingCoor(y + yCorrection); track.setBendingSlope(ySlope + ySlopeCorrection); - /* - std::cout << std::format("[TOTO] MFT position: pos={:0.3f},{:0.3f}", x, y) << std::endl; - std::cout << std::format("[TOTO] MFT corrections: pos={:0.3f},{:0.3f} slope={:0.12f},{:0.12f} angle={:0.12f},{:0.12f}", - xCorrection, yCorrection, xSlopeCorrection, ySlopeCorrection, - std::atan2(xSlopeCorrection, 1), std::atan2(ySlopeCorrection, 1)) << std::endl; - */ } void TransformMFT(o2::dataformats::GlobalFwdTrack& track) @@ -1133,8 +1129,8 @@ struct muonGlobalAlignment { template T UpdateTrackMomentum(const T& track, const double p, int sign) { - double px = p * sin(M_PI / 2 - atan(track.tgl())) * cos(track.phi()); - double py = p * sin(M_PI / 2 - atan(track.tgl())) * sin(track.phi()); + double px = p * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::cos(track.phi()); + double py = p * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::sin(track.phi()); double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); SMatrix5 tpars = {track.x(), track.y(), track.phi(), track.tgl(), sign / pt}; @@ -1154,8 +1150,8 @@ struct muonGlobalAlignment { template T UpdateTrackMomentum(const T& track, const o2::mch::TrackParam& track4mom) { - double px = track4mom.p() * sin(M_PI / 2 - atan(track.tgl())) * cos(track.phi()); - double py = track4mom.p() * sin(M_PI / 2 - atan(track.tgl())) * sin(track.phi()); + double px = track4mom.p() * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::cos(track.phi()); + double py = track4mom.p() * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::sin(track.phi()); double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); double sign = track4mom.getCharge(); @@ -1427,7 +1423,7 @@ struct muonGlobalAlignment { const std::map& collisionInfos) { // outer loop over collisions - for (auto& [collisionIndex, collisionInfo] : collisionInfos) { + for (const auto& [collisionIndex, collisionInfo] : collisionInfos) { auto const& collision = collisions.rawIteratorAt(collisionIndex); const auto& bc = bcs.rawIteratorAt(collision.bcId()); @@ -1452,7 +1448,7 @@ struct muonGlobalAlignment { mftTrackIds.resize(cfgMftTracksMultiplicityMax); } - for (auto mftIndex : mftTrackIds) { + for (const auto& mftIndex : mftTrackIds) { auto const& mftTrack = mftTracks.rawIteratorAt(mftIndex); if (mftTrack.isCA()) { @@ -1549,7 +1545,7 @@ struct muonGlobalAlignment { if (cfgEnableGlobalFwdDcaAnalysis) { // loop over global muon tracks - for (auto& [muonIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { + for (const auto& [muonIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { auto const& muonTrack = muonTracks.rawIteratorAt(globalTracksVector[0]); const auto& mchTrack = muonTrack.template matchMCHTrack_as(); const auto& mftTrack = muonTrack.template matchMFTTrack_as(); @@ -1678,7 +1674,7 @@ struct muonGlobalAlignment { } // loop over collisions - for (auto& [collisionIndex, collisionInfo] : collisionInfos) { + for (const auto& [collisionIndex, collisionInfo] : collisionInfos) { auto const& collision = collisions.rawIteratorAt(collisionIndex); const auto& bc = bcs.rawIteratorAt(collision.bcId()); @@ -1688,7 +1684,7 @@ struct muonGlobalAlignment { continue; // loop over global muon tracks - for (auto& [muonIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { + for (const auto& [muonIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { auto const& muonTrack = muonTracks.rawIteratorAt(globalTracksVector[0]); const auto& mchTrack = muonTrack.template matchMCHTrack_as(); const auto& mftTrack = muonTrack.template matchMFTTrack_as(); @@ -1823,7 +1819,7 @@ struct muonGlobalAlignment { } // MFT-MCH track residuals analysis - if (cfgEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk)) { + if (cfgEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk) { double refPlaneZ[2] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; std::shared_ptr dxPlots[2]{registry.get(HIST("matching/dxAtMFT")), registry.get(HIST("matching/dxAtMCH"))}; From 62b8b097f38744c4036f800f59262c5f916ef719 Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Wed, 5 Aug 2026 22:32:06 +0200 Subject: [PATCH 03/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index d4c6755e258..b58823a88d5 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -129,6 +129,10 @@ using CompactMFTTrack = CompactMFTTracks; struct muonGlobalAlignment { static constexpr int GlobalTrackTypeMax = 2; + static constexpr int NMchChambers = 10; + static constexpr int NMchDetElems = 156; + static constexpr int ThetaAbsBoundaryDeg = 3; + static constexpr double SlopeResolutionZ = 535.; Produces mftTable; Configurable cfgProduceMFTTable{"cfgProduceMFTTable", false, "flag to produce MFTsa table"}; @@ -390,7 +394,7 @@ struct muonGlobalAlignment { } else { LOGF(fatal, "Reference aligned geometry object is not available in CCDB at timestamp=%llu", bc.timestamp()); } - for (int i = 0; i < 156; i++) { + for (int i = 0; i < NMchDetElems; i++) { int iDEN = GetDetElemId(i); transformRef[iDEN] = transformation(iDEN); } @@ -404,7 +408,7 @@ struct muonGlobalAlignment { } else { LOGF(fatal, "New aligned geometry object is not available in CCDB at timestamp=%llu", bc.timestamp()); } - for (int i = 0; i < 156; i++) { + for (int i = 0; i < NMchDetElems; i++) { int iDEN = GetDetElemId(i); transformNew[iDEN] = transformation(iDEN); } @@ -630,7 +634,7 @@ struct muonGlobalAlignment { // get chamber and element number in chamber int iCh = 0; int iDet = 0; - for (int i = 1; i <= 10; i++) { + for (int i = 1; i <= NMchChambers; i++) { if (iDetElemNumber < fgSNDetElemCh[i]) { iCh = i; iDet = iDetElemNumber - fgSNDetElemCh[i - 1]; @@ -639,7 +643,7 @@ struct muonGlobalAlignment { } // make sure detector index is valid - if (!(iCh > 0 && iCh <= 10 && iDet < fgNDetElemCh[iCh - 1])) { + if (!(iCh > 0 && iCh <= NMchChambers && iDet < fgNDetElemCh[iCh - 1])) { LOGF(fatal, "Invalid detector element id: %d", 100 * iCh + iDet); } @@ -682,7 +686,7 @@ struct muonGlobalAlignment { { static int nDE = 0; if (nDE <= 0) { - for (int c = 0; c < 10; c++) { + for (int c = 0; c < NMchChambers; c++) { nDE += getNumDEinChamber(c); } } @@ -937,7 +941,7 @@ struct muonGlobalAlignment { auto itNextToNextParam = (itNextParam == track.end()) ? itNextParam : std::next(itNextParam); itStartingParam = track.rbegin(); - if (track.getNClusters() < 10) { + if (track.getNClusters() < NMchChambers) { removeTrack = true; break; } else { @@ -1000,10 +1004,10 @@ struct muonGlobalAlignment { double p = mchTrackAtVertex.getP(); double pDCA = mchTrack.pDca(); - double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310; + double sigmaPDCA = (thetaAbs < ThetaAbsBoundaryDeg) ? sigmaPDCA23 : sigmaPDCA310; double nrp = nSigmaPDCA * relPRes * p; double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp)); - double slopeResEffect = 535. * slopeRes * p; + double slopeResEffect = SlopeResolutionZ * slopeRes * p; double sigmaPDCAWithRes = TMath::Sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect); if (pDCA > nSigmaPDCA * sigmaPDCAWithRes) { return false; @@ -1021,7 +1025,7 @@ struct muonGlobalAlignment { std::array rAbsCut, double nSigmaPdcaCut) { - auto const& mchTrack = (static_cast(muonTrack.trackType()) <= 2) ? muonTrack.template matchMCHTrack_as() : muonTrack; + auto const& mchTrack = (static_cast(muonTrack.trackType()) <= GlobalTrackTypeMax) ? muonTrack.template matchMCHTrack_as() : muonTrack; // chi2 cut if (mchTrack.chi2() > chi2Cut) @@ -1252,7 +1256,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFT(const TMFT& mftTrack, float z) { - static double Bz = -10001; + //static double Bz = -10001; double chi2 = mftTrack.chi2(); SMatrix5 tpars = {mftTrack.x(), mftTrack.y(), mftTrack.phi(), mftTrack.tgl(), mftTrack.signed1Pt()}; std::vector v1{0, 0, 0, 0, 0, @@ -1270,12 +1274,12 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - if (Bz < -10000) { - double centerZ[3] = {0, 0, (-45.f - 77.5f) / 2.f}; - o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); - Bz = field->getBz(centerZ); - } - fwdtrack.propagateToZ(z, Bz); + //if (Bz < -10000) { + // double centerZ[3] = {0, 0, (-45.f - 77.5f) / 2.f}; + // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); + // Bz = field->getBz(centerZ); + //} + fwdtrack.propagateToZ(z, mBzAtMftCenter); propmuon.setParameters(fwdtrack.getParameters()); propmuon.setZ(fwdtrack.getZ()); From 68bfcdff0be2c325908c5e2282cbf3d84f9c1851 Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Wed, 5 Aug 2026 22:42:03 +0200 Subject: [PATCH 04/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 41 ++++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index b58823a88d5..ff4b5c0250b 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -133,6 +133,8 @@ struct muonGlobalAlignment { static constexpr int NMchDetElems = 156; static constexpr int ThetaAbsBoundaryDeg = 3; static constexpr double SlopeResolutionZ = 535.; + static constexpr double AbsorberBackZ = -505.f; + static constexpr double BransonPlaneZ = -466.f; Produces mftTable; Configurable cfgProduceMFTTable{"cfgProduceMFTTable", false, "flag to produce MFTsa table"}; @@ -1291,7 +1293,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFTToDCA(const TMFT& mftTrack, const C& collision, float zshift) { - static double Bz = -10001; + //static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; @@ -1318,12 +1320,12 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - if (Bz < -10000) { - double centerZ[3] = {0, 0, -45.f / 2.f}; - o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); - Bz = field->getBz(centerZ); - } - fwdtrack.propagateToZ(collision.posZ() - zshift, Bz); + //if (Bz < -10000) { + // double centerZ[3] = {0, 0, -45.f / 2.f}; + // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); + // Bz = field->getBz(centerZ); + //} + fwdtrack.propagateToZ(collision.posZ() - zshift, mBzAtMftCenter); propmuon.setParameters(fwdtrack.getParameters()); propmuon.setZ(fwdtrack.getZ()); @@ -1335,7 +1337,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFTToDCA(const TMFT& mftTrack, const TMUON& mchTrack, const C& collision, float zshift) { - static double Bz = -10001; + //static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; @@ -1366,12 +1368,12 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - if (Bz < -10000) { - double centerZ[3] = {0, 0, -45.f / 2.f}; - o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); - Bz = field->getBz(centerZ); - } - fwdtrack.propagateToZ(collision.posZ() - zshift, Bz); + //if (Bz < -10000) { + // double centerZ[3] = {0, 0, -45.f / 2.f}; + // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); + // Bz = field->getBz(centerZ); + //} + fwdtrack.propagateToZ(collision.posZ() - zshift, mBzAtMftCenter); o2::dataformats::GlobalFwdTrack propmuon; propmuon.setParameters(fwdtrack.getParameters()); @@ -1394,8 +1396,8 @@ struct muonGlobalAlignment { } auto mftTrackProp = FwdtoMCH(mftTrackPar); UpdateTrackMomentum(mftTrackProp, mchTrackAtMFT); - if (z < -505.f) { - o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -466.f); + if (z < AbsorberBackZ) { + o2::mch::TrackExtrap::extrapToZ(mftTrackProp, BransonPlaneZ); UpdateTrackMomentum(mftTrackProp, mchTrackPar); } @@ -1403,9 +1405,9 @@ struct muonGlobalAlignment { // extrapolate to the back of the absorber, taking into account the dipole shift, // to avoid that the correction bring the track starting point back into the absorber if (cfgDipoleZshift.value < 0) { - o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -505.f); + o2::mch::TrackExtrap::extrapToZ(mftTrackProp, AbsorberBackZ); } else if (cfgDipoleZshift.value > 0) { - o2::mch::TrackExtrap::extrapToZ(mftTrackProp, -505.f - cfgDipoleZshift.value); + o2::mch::TrackExtrap::extrapToZ(mftTrackProp, AbsorberBackZ - cfgDipoleZshift.value); } // shift the track starting point mftTrackProp.setZ(mftTrackProp.getZ() + cfgDipoleZshift.value); @@ -1503,7 +1505,8 @@ struct muonGlobalAlignment { } if (cfgEnableMftDcaExtraPlots) { - if (mftNclusters >= 6) { + static constexpr int nMftClustersMin = 6; + if (mftNclusters >= nMftClustersMin) { for (int i = 0; i < nMftLayers; i++) { auto mftTrackAtLayer = PropagateMFT(mftTrack, o2::mft::constants::mft::LayerZCoordinate()[i]); std::get>(mMftTrackEffDen[i])->Fill(mftTrackAtLayer.getX(), mftTrackAtLayer.getY()); From 2c659eb14dcce276fdafdffddaa23a43d71a831c Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Wed, 5 Aug 2026 22:59:07 +0200 Subject: [PATCH 05/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 31 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index ff4b5c0250b..f4d3ca89208 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -/// \file muonDCA.cxx +/// \file muonGlobalAlignment.cxx // o2-linter: disable=name/file-cpp,name/workflow-file (legacy workflow executable name) /// \brief Task to compute and evaluate DCA quantities /// \author Nicolas Bizé , SUBATECH // @@ -151,6 +151,8 @@ struct muonGlobalAlignment { Configurable cfgTrackNClustMftLow{"cfgTrackNClustMftLow", 7, ""}; Configurable cfgTrackChi2MftUp{"cfgTrackChi2MftUp", 999.f, ""}; + Configurable cfgMftDcaMatchChi2Up{"cfgMftDcaMatchChi2Up", 10.f, ""}; + Configurable cfgMftMchResidualsPLow{"cfgMftMchResidualsPLow", 30.f, ""}; Configurable cfgMftMchResidualsPtLow{"cfgMftMchResidualsPtLow", 4.f, ""}; @@ -280,7 +282,7 @@ struct muonGlobalAlignment { std::map& collisionInfos) { // fill collision information for global muon tracks (MFT-MCH-MID matches) - for (auto muonTrack : muonTracks) { + for (const auto& muonTrack : muonTracks) { if (!muonTrack.has_collision()) continue; @@ -1526,11 +1528,13 @@ struct muonGlobalAlignment { } if (cfgEnableVertexShiftAnalysis) { - if (mftTrack.chi2() <= cfgTrackChi2MftUp && std::fabs(collision.posZ()) < 1.f && mftNclusters >= 6) { - float zshift[21] = {// in millimeters + static constexpr int nMftClustersMin = 6; + if (mftTrack.chi2() <= cfgTrackChi2MftUp && std::fabs(collision.posZ()) < 1.f && mftNclusters >= nMftClustersMin) { + static constexpr int nPoints = 21; + float zshift[nPoints] = {// in millimeters -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; - for (int zi = 0; zi < 21; zi++) { + for (int zi = 0; zi < nPoints; zi++) { auto mftTrackAtDCAshifted = PropagateMFTToDCA(mftTrack, collision, zshift[zi] / 10.f); double dcaxShifted = mftTrackAtDCAshifted.getX() - collision.posX(); double dcayShifted = mftTrackAtDCAshifted.getY() - collision.posY(); @@ -1557,7 +1561,7 @@ struct muonGlobalAlignment { const auto& mchTrack = muonTrack.template matchMCHTrack_as(); const auto& mftTrack = muonTrack.template matchMFTTrack_as(); - if (muonTrack.chi2MatchMCHMFT() < 50) { + if (muonTrack.chi2MatchMCHMFT() < cfgMftDcaMatchChi2Up.value) { continue; } @@ -1565,7 +1569,7 @@ struct muonGlobalAlignment { auto const& muonTrack2 = muonTracks.rawIteratorAt(globalTracksVector[1]); double dchi2 = muonTrack2.chi2MatchMCHMFT() - muonTrack.chi2MatchMCHMFT(); - if (dchi2 < 50) { + if (dchi2 < cfgMftDcaMatchChi2Up.value) { continue; } } @@ -1608,7 +1612,7 @@ struct muonGlobalAlignment { int deId = cluster.deId(); int chamber = deId / 100 - 1; - if (chamber < 0 || chamber > 9) { + if (chamber < 0 || chamber >= NMchChambers) { continue; } @@ -1707,8 +1711,8 @@ struct muonGlobalAlignment { if (!isGoodMFT) continue; - double matchChi2 = muonTrack.chi2MatchMCHMFT() / 5.f; - if (matchChi2 > 10.f) + double matchChi2 = muonTrack.chi2MatchMCHMFT(); + if (matchChi2 > cfgMftDcaMatchChi2Up.value) continue; // refit MCH track if enabled @@ -1731,7 +1735,7 @@ struct muonGlobalAlignment { for (auto const& cluster : clustersSliced) { int deId = cluster.deId(); int chamber = deId / 100 - 1; - if (chamber < 0 || chamber > 9) + if (chamber < 0 || chamber >= NMchChambers) continue; int deIndex = getDEindex(deId); @@ -1827,7 +1831,8 @@ struct muonGlobalAlignment { // MFT-MCH track residuals analysis if (cfgEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk) { - double refPlaneZ[2] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; + static constexpr int nRefPlanes = 2; + double refPlaneZ[nRefPlanes] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; std::shared_ptr dxPlots[2]{registry.get(HIST("matching/dxAtMFT")), registry.get(HIST("matching/dxAtMCH"))}; std::shared_ptr dyPlots[2]{registry.get(HIST("matching/dyAtMFT")), registry.get(HIST("matching/dyAtMCH"))}; @@ -1835,7 +1840,7 @@ struct muonGlobalAlignment { std::shared_ptr dsyPlots[2]{registry.get(HIST("matching/dsyAtMFT")), registry.get(HIST("matching/dsyAtMCH"))}; std::shared_ptr dphiPlots[2]{registry.get(HIST("matching/dphiAtMFT")), registry.get(HIST("matching/dphiAtMCH"))}; - for (int iRefPlane = 0; iRefPlane < 2; iRefPlane++) { + for (int iRefPlane = 0; iRefPlane < nRefPlanes; iRefPlane++) { const auto mftTrackAtRefPlane = configRealign.cfgEnableMCHRealign ? PropagateMFTtoMCH(mftTrack, mch::TrackParam(convertedTrackWithCorr.first()), refPlaneZ[iRefPlane]) : PropagateMFTtoMCH(mftTrack, FwdtoMCH(FwdToTrackPar(mchTrack)), refPlaneZ[iRefPlane]); const auto mchTrackAtRefPlane = configRealign.cfgEnableMCHRealign ? PropagateMCHRealigned(convertedTrackWithCorr, refPlaneZ[iRefPlane]) : PropagateMCH(mchTrack, refPlaneZ[iRefPlane]); const auto& refTrackAtRefPlane = (iRefPlane == 0) ? mftTrackAtRefPlane : mchTrackAtRefPlane; From 9f3718c3a3fc1264bd1967c0b6f5a1170dafdb07 Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Thu, 6 Aug 2026 08:42:41 +0200 Subject: [PATCH 06/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index f4d3ca89208..4d079a08519 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -9,10 +9,9 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -/// \file muonGlobalAlignment.cxx // o2-linter: disable=name/file-cpp,name/workflow-file (legacy workflow executable name) -/// \brief Task to compute and evaluate DCA quantities -/// \author Nicolas Bizé , SUBATECH -// +/// \file muonGlobalAlignment.cxx +/// \brief Analysis of global alignment between MFT and MCH-MID +/// \author Andrea Ferrero , CEA-Saclay #include "PWGDQ/Core/VarManager.h" @@ -720,18 +719,18 @@ struct muonGlobalAlignment { return idx + offset; } - int GetQuadrant(double phi) + int GetQuadrant(float phi) { - if (phi >= 0 && phi < 90) { + if (phi >= 0 && phi < o2::constants::math::PIHalf) { return 0; } - if (phi >= 90 && phi <= 180) { + if (phi >= o2::constants::math::PIHalf && phi <= o2::constants::math::PI) { return 1; } - if (phi >= -180 && phi < -90) { + if (phi >= -o2::constants::math::PI && phi < -o2::constants::math::PIHalf) { return 2; } - if (phi >= -90 && phi < 0) { + if (phi >= -o2::constants::math::PIHalf && phi < 0) { return 3; } return -1; @@ -740,8 +739,8 @@ struct muonGlobalAlignment { template int GetQuadrant(const T& track) { - double phi = track.phi() * 180 / TMath::Pi(); - return GetQuadrant(phi); + //double phi = track.phi() * 180 / TMath::Pi(); + return GetQuadrant(track.phi()); } template From b380d0116c89f6abb984489190d8882d988d363e Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Thu, 6 Aug 2026 09:05:01 +0200 Subject: [PATCH 07/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index 4d079a08519..ba2b02c86b8 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +58,7 @@ #include #include +#include #include #include @@ -125,7 +125,7 @@ DECLARE_SOA_TABLE(CompactMFTTracks, "AOD", "COMPACTMFT", //! standalone table fo using CompactMFTTrack = CompactMFTTracks; } // namespace o2::aod -struct muonGlobalAlignment { +struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struct (exception) static constexpr int GlobalTrackTypeMax = 2; static constexpr int NMchChambers = 10; @@ -236,8 +236,8 @@ struct muonGlobalAlignment { std::map transformNew; // new geometry TGeoManager* geoNew = nullptr; TGeoManager* geoRef = nullptr; - TrackFitter trackFitter; // Track fitter from MCH tracking library - double mImproveCutChi2{0}; // Chi2 cut for track improvement. + TrackFitter trackFitter; // Track fitter from MCH tracking library + double mImproveCutChi2{0}; // Chi2 cut for track improvement. struct AlignmentCorrections { double x{0}; @@ -329,7 +329,7 @@ struct muonGlobalAlignment { return (track1.chi2MatchMCHMFT() < track2.chi2MatchMCHMFT()); }; - for (auto& [collisionIndex, collisionInfo] : collisionInfos) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) + for (auto& [collisionIndex, collisionInfo] : collisionInfos) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) for (auto& [mchIndex, globalTracksVector] : collisionInfo.globalMuonTracks) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop) std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareChi2); } @@ -739,7 +739,7 @@ struct muonGlobalAlignment { template int GetQuadrant(const T& track) { - //double phi = track.phi() * 180 / TMath::Pi(); + // double phi = track.phi() * 180 / TMath::Pi(); return GetQuadrant(track.phi()); } @@ -1259,7 +1259,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFT(const TMFT& mftTrack, float z) { - //static double Bz = -10001; + // static double Bz = -10001; double chi2 = mftTrack.chi2(); SMatrix5 tpars = {mftTrack.x(), mftTrack.y(), mftTrack.phi(), mftTrack.tgl(), mftTrack.signed1Pt()}; std::vector v1{0, 0, 0, 0, 0, @@ -1277,7 +1277,7 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - //if (Bz < -10000) { + // if (Bz < -10000) { // double centerZ[3] = {0, 0, (-45.f - 77.5f) / 2.f}; // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); // Bz = field->getBz(centerZ); @@ -1294,7 +1294,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFTToDCA(const TMFT& mftTrack, const C& collision, float zshift) { - //static double Bz = -10001; + // static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; @@ -1321,7 +1321,7 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - //if (Bz < -10000) { + // if (Bz < -10000) { // double centerZ[3] = {0, 0, -45.f / 2.f}; // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); // Bz = field->getBz(centerZ); @@ -1338,7 +1338,7 @@ struct muonGlobalAlignment { template o2::dataformats::GlobalFwdTrack PropagateMFTToDCA(const TMFT& mftTrack, const TMUON& mchTrack, const C& collision, float zshift) { - //static double Bz = -10001; + // static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; @@ -1369,7 +1369,7 @@ struct muonGlobalAlignment { // double centerZ[3] = {mftTrack.x() + propVec[0] / 2., // mftTrack.y() + propVec[1] / 2., // mftTrack.z() + propVec[2] / 2.}; - //if (Bz < -10000) { + // if (Bz < -10000) { // double centerZ[3] = {0, 0, -45.f / 2.f}; // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); // Bz = field->getBz(centerZ); @@ -1531,8 +1531,8 @@ struct muonGlobalAlignment { if (mftTrack.chi2() <= cfgTrackChi2MftUp && std::fabs(collision.posZ()) < 1.f && mftNclusters >= nMftClustersMin) { static constexpr int nPoints = 21; float zshift[nPoints] = {// in millimeters - -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, - 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; + -5.0, -4.5, -4.0, -3.5, -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, + 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; for (int zi = 0; zi < nPoints; zi++) { auto mftTrackAtDCAshifted = PropagateMFTToDCA(mftTrack, collision, zshift[zi] / 10.f); double dcaxShifted = mftTrackAtDCAshifted.getX() - collision.posX(); @@ -1831,7 +1831,7 @@ struct muonGlobalAlignment { // MFT-MCH track residuals analysis if (cfgEnableMftMchMatchingAnalysis && convertedTrackWithCorrOk) { static constexpr int nRefPlanes = 2; - double refPlaneZ[nRefPlanes] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; + const double refPlaneZ[nRefPlanes] = {cfgRefPlaneZMFT, cfgRefPlaneZMCH}; std::shared_ptr dxPlots[2]{registry.get(HIST("matching/dxAtMFT")), registry.get(HIST("matching/dxAtMCH"))}; std::shared_ptr dyPlots[2]{registry.get(HIST("matching/dyAtMFT")), registry.get(HIST("matching/dyAtMCH"))}; From 89be48853d303a2e8062f4e9d3745f766b22689b Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Thu, 6 Aug 2026 09:13:40 +0200 Subject: [PATCH 08/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index ba2b02c86b8..60ebc686d06 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,6 @@ #include #include -#include #include #include @@ -1136,8 +1136,8 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc template T UpdateTrackMomentum(const T& track, const double p, int sign) { - double px = p * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::cos(track.phi()); - double py = p * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::sin(track.phi()); + double px = p * std::sin(o2::constants::math::PIHalf - std::atan(track.tgl())) * std::cos(track.phi()); + double py = p * std::sin(o2::constants::math::PIHalf - std::atan(track.tgl())) * std::sin(track.phi()); double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); SMatrix5 tpars = {track.x(), track.y(), track.phi(), track.tgl(), sign / pt}; @@ -1157,8 +1157,8 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc template T UpdateTrackMomentum(const T& track, const o2::mch::TrackParam& track4mom) { - double px = track4mom.p() * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::cos(track.phi()); - double py = track4mom.p() * std::sin(M_PI / 2 - std::atan(track.tgl())) * std::sin(track.phi()); + double px = track4mom.p() * std::sin(o2::constants::math::PIHalf - std::atan(track.tgl())) * std::cos(track.phi()); + double py = track4mom.p() * std::sin(o2::constants::math::PIHalf - std::atan(track.tgl())) * std::sin(track.phi()); double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); double sign = track4mom.getCharge(); @@ -1297,7 +1297,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc // static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; - double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; + double phiCorr = phiCorrDeg * o2::constants::math::Deg2Rad; double tR = std::hypot(mftTrack.x(), mftTrack.y()); double tphi = std::atan2(mftTrack.y(), mftTrack.x()); double tx = std::cos(tphi + phiCorr) * tR; @@ -1325,7 +1325,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc // double centerZ[3] = {0, 0, -45.f / 2.f}; // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); // Bz = field->getBz(centerZ); - //} + // } fwdtrack.propagateToZ(collision.posZ() - zshift, mBzAtMftCenter); propmuon.setParameters(fwdtrack.getParameters()); @@ -1341,7 +1341,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc // static double Bz = -10001; double chi2 = mftTrack.chi2(); double phiCorrDeg = 0; - double phiCorr = phiCorrDeg * TMath::Pi() / 180.f; + double phiCorr = phiCorrDeg * o2::constants::math::Deg2Rad; double tR = std::hypot(mftTrack.x(), mftTrack.y()); double tphi = std::atan2(mftTrack.y(), mftTrack.x()); double tx = std::cos(tphi + phiCorr) * tR; @@ -1373,7 +1373,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc // double centerZ[3] = {0, 0, -45.f / 2.f}; // o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); // Bz = field->getBz(centerZ); - //} + // } fwdtrack.propagateToZ(collision.posZ() - zshift, mBzAtMftCenter); o2::dataformats::GlobalFwdTrack propmuon; @@ -1469,7 +1469,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc auto mftTrackAtDCA = PropagateMFTToDCA(mftTrack, collision, cfgVertexZshift); double dcax = mftTrackAtDCA.getX() - collision.posX(); double dcay = mftTrackAtDCA.getY() - collision.posY(); - double phi = mftTrack.phi() * 180 / TMath::Pi(); + double phi = mftTrack.phi() * o2::constants::math::Rad2Deg; int mftNclusters = mftTrack.nClusters(); double chi2NDF = static_cast(mftNclusters) * 2 - 5; @@ -1858,10 +1858,10 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc dsyPlots[iRefPlane]->Fill(dsy, refTrackAtRefPlane.getX(), refTrackAtRefPlane.getY(), quadrant, posNeg, mchTrack.p()); auto dphi = mchTrackAtRefPlane.getPhi() - mftTrackAtRefPlane.getPhi(); - if (dphi < -TMath::Pi()) { - dphi += TMath::Pi() * 2.0; - } else if (dphi > TMath::Pi()) { - dphi -= TMath::Pi() * 2.0; + if (dphi < -o2::constants::math::PI) { + dphi += o2::constants::math::TwoPI; + } else if (dphi > o2::constants::math::PI) { + dphi -= o2::constants::math::TwoPI; } dphiPlots[iRefPlane]->Fill(dphi, refTrackAtRefPlane.getX(), refTrackAtRefPlane.getY(), quadrant, posNeg, mchTrack.p()); } From e1846807b56bc9093b367693dc20913ce6a971c7 Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Thu, 6 Aug 2026 09:32:04 +0200 Subject: [PATCH 09/10] More fixes --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index 60ebc686d06..421f34607fc 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -1857,12 +1857,7 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc auto dsy = mchParamAtRefPlane.getBendingSlope() - mftParamAtRefPlane.getBendingSlope(); dsyPlots[iRefPlane]->Fill(dsy, refTrackAtRefPlane.getX(), refTrackAtRefPlane.getY(), quadrant, posNeg, mchTrack.p()); - auto dphi = mchTrackAtRefPlane.getPhi() - mftTrackAtRefPlane.getPhi(); - if (dphi < -o2::constants::math::PI) { - dphi += o2::constants::math::TwoPI; - } else if (dphi > o2::constants::math::PI) { - dphi -= o2::constants::math::TwoPI; - } + auto dphi = RecoDecay::constrainAngle(mchTrackAtRefPlane.getPhi() - mftTrackAtRefPlane.getPhi(), -o2::constants::math::PI); dphiPlots[iRefPlane]->Fill(dphi, refTrackAtRefPlane.getX(), refTrackAtRefPlane.getY(), quadrant, posNeg, mchTrack.p()); } } From 1682bd4083e346275c8bee6b3b0206a6d717aba2 Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Thu, 6 Aug 2026 12:40:06 +0200 Subject: [PATCH 10/10] Fix conflict --- PWGDQ/Tasks/muonGlobalAlignment.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index deb7a7febd0..0952aabc1ed 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -156,11 +156,11 @@ struct muonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc Configurable cfgMftMchResidualsPtLow{"cfgMftMchResidualsPtLow", 4.f, ""}; Configurable cfgMftTracksMultiplicityMax{"cfgMftTracksMultiplicityMax", 0, "Maximum number of MFT tracks to be processed per event (zero means no limit)"}; - + // Magnetic field position bias Configurable cfgFieldOriginBiasZ{"cfgFieldOriginBiasZ", 0.0f, "Bias applied to the magnetic field z position"}; - Configurable fVertexZshift{"cfgVertexZshift", 0.0f, "Correction to the vertex z position"}; - Configurable fDipoleZshift{"cfgDipoleZshift", 0.0f, "Correction to the dipole z position"}; + Configurable cfgVertexZshift{"cfgVertexZshift", 0.0f, "Correction to the vertex z position"}; + Configurable cfgDipoleZshift{"cfgDipoleZshift", 0.0f, "Correction to the dipole z position"}; //// Variables for MFT alignment corrections struct : ConfigurableGroup {