From d7e115e584a9b1ea95ebe3f7f084d680e3c7fbbc Mon Sep 17 00:00:00 2001 From: Yiping Wang Date: Mon, 7 Jul 2025 14:18:20 +0200 Subject: [PATCH 1/2] Enable reading collision system info from CCDB --- PWGDQ/Core/VarManager.cxx | 82 ++++++++++++++++++++++++--- PWGDQ/Core/VarManager.h | 25 +++----- PWGDQ/Tasks/tableReader_withAssoc.cxx | 7 +++ 3 files changed, 88 insertions(+), 26 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 00e07e5a38a..9165efadbd9 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -28,8 +28,6 @@ bool VarManager::fgUsedVars[VarManager::kNVars] = {false}; bool VarManager::fgUsedKF = false; float VarManager::fgMagField = 0.5; float VarManager::fgValues[VarManager::kNVars] = {0.0f}; -float VarManager::fgCenterOfMassEnergy = 13600; // GeV -float VarManager::fgMassofCollidingParticle = 9.382720; // GeV float VarManager::fgTPCInterSectorBoundary = 1.0; // cm int VarManager::fgITSROFbias = 0; int VarManager::fgITSROFlength = 100; @@ -37,6 +35,8 @@ int VarManager::fgITSROFBorderMarginLow = 0; int VarManager::fgITSROFBorderMarginHigh = 0; uint64_t VarManager::fgSOR = 0; uint64_t VarManager::fgEOR = 0; +ROOT::Math::PxPyPzEVector VarManager::fgBeamA(0, 0, 6799.99, 6800); // GeV, beam from A-side 4-momentum vector +ROOT::Math::PxPyPzEVector VarManager::fgBeamC(0, 0, -6799.99, 6800); // GeV, beam from C-side 4-momentum vector o2::vertexing::DCAFitterN<2> VarManager::fgFitterTwoProngBarrel; o2::vertexing::DCAFitterN<3> VarManager::fgFitterThreeProngBarrel; o2::vertexing::DCAFitterN<4> VarManager::fgFitterFourProngBarrel; @@ -114,15 +114,79 @@ void VarManager::SetCollisionSystem(TString system, float energy) // // Set the collision system and the center of mass energy // - fgCenterOfMassEnergy = energy; - - if (system.Contains("PbPb")) { - fgMassofCollidingParticle = MassProton * 208; - } - if (system.Contains("pp")) { - fgMassofCollidingParticle = MassProton; + int NumberOfNucleonsA = 1; // default value for pp collisions + int NumberOfNucleonsC = 1; // default value for pp collisions + int NumberOfProtonsA = 1; // default value for pp collisions + int NumberOfProtonsC = 1; // default value for pp collisions + if (system.EqualTo("PbPb")) { + NumberOfNucleonsA = 208; + NumberOfNucleonsC = 208; + NumberOfProtonsA = 82; // Pb has 82 protons + NumberOfProtonsC = 82; // Pb has 82 protons + } else if (system.EqualTo("pp")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 1; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 1; // proton has 1 proton + } else if (system.EqualTo("XeXe")) { + NumberOfNucleonsA = 129; + NumberOfNucleonsC = 129; + NumberOfProtonsA = 54; // Xe has 54 protons + NumberOfProtonsC = 54; // Xe has 54 protons + } else if (system.EqualTo("pPb")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 208; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 82; // Pb has 82 protons + } else if (system.EqualTo("Pbp")) { + NumberOfNucleonsA = 208; + NumberOfNucleonsC = 1; + NumberOfProtonsA = 82; // Pb has 82 protons + NumberOfProtonsC = 1; // proton has 1 proton + } else if (system.EqualTo("OO")) { + NumberOfNucleonsA = 16; + NumberOfNucleonsC = 16; + NumberOfProtonsA = 8; // O has 8 protons + NumberOfProtonsC = 8; // O has 8 protons + } else if (system.EqualTo("pO")) { + NumberOfNucleonsA = 1; + NumberOfNucleonsC = 16; + NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsC = 8; // O has 8 protons + } else if (system.EqualTo("NeNe")) { + NumberOfNucleonsA = 20; + NumberOfNucleonsC = 20; + NumberOfProtonsA = 10; // Ne has 5 protons + NumberOfProtonsC = 10; // Ne has 5 protons + } else { + LOGF(WARNING, "Unknown collision system %s, using default pp", system.Data()); } // TO Do: add more systems + + // set the beam 4-momentum vectors + float beamAEnergy = energy / 2.0 * sqrt(NumberOfProtonsA * NumberOfProtonsC / NumberOfProtonsC / NumberOfProtonsA); // GeV + float beamCEnergy = energy / 2.0 * sqrt(NumberOfProtonsC * NumberOfProtonsA / NumberOfProtonsA / NumberOfProtonsC); // GeV + float beamAMomentum = std::sqrt(beamAEnergy * beamAEnergy - NumberOfNucleonsA * NumberOfNucleonsA * MassProton * MassProton); + float beamCMomentum = std::sqrt(beamCEnergy * beamCEnergy - NumberOfNucleonsC * NumberOfNucleonsC * MassProton * MassProton); + fgBeamA.SetPxPyPzE(0, 0, beamAMomentum, beamAEnergy); + fgBeamC.SetPxPyPzE(0, 0, -beamCMomentum, beamCEnergy); +} + +//__________________________________________________________________ +void VarManager::SetCollisionSystem(o2::parameters::GRPLHCIFData* grplhcif) +{ + // + // Set the collision system and the center of mass energy from the GRP information + double beamAEnergy = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamDirection::BeamA); + double beamCEnergy = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamDirection::BeamC); + double beamANucleons = grplhcif->getBeamA(o2::constants::lhc::BeamDirection::BeamA); + double beamCNucleons = grplhcif->getBeamA(o2::constants::lhc::BeamDirection::BeamC); + double beamAMomentum = std::sqrt(beamAEnergy * beamAEnergy - beamANucleons * beamANucleons * MassProton * MassProton); + double beamCMomentum = std::sqrt(beamCEnergy * beamCEnergy - beamCNucleons * beamCNucleons * MassProton * MassProton); + fgBeamA.SetPxPyPzE(0, 0, beamAMomentum, beamAEnergy); + fgBeamC.SetPxPyPzE(0, 0, -beamCMomentum, beamCEnergy); + LOGF(INFO, "Beam A energy = %.2f GeV, beam C energy = %.2f GeV", beamAEnergy, beamCEnergy); + LOGF(INFO, "Beam A with %.0f nucleons, beam C with %.0f nucleons", beamANucleons, beamCNucleons); } //__________________________________________________________________ diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 0d56f77491a..3e4531b357b 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -67,6 +67,7 @@ #include "KFVertex.h" #include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/CollisionTypeHelper.h" using std::complex; using std::cout; @@ -927,6 +928,7 @@ class VarManager : public TObject // Setup the collision system static void SetCollisionSystem(TString system, float energy); + static void SetCollisionSystem(o2::parameters::GRPLHCIFData* grplhcif); static void SetMagneticField(float magField) { @@ -1197,6 +1199,8 @@ class VarManager : public TObject static int fgITSROFBorderMarginHigh; // ITS ROF border high margin static uint64_t fgSOR; // Timestamp for start of run static uint64_t fgEOR; // Timestamp for end of run + static ROOT::Math::PxPyPzEVector fgBeamA; // beam from A-side 4-momentum vector + static ROOT::Math::PxPyPzEVector fgBeamC; // beam from C-side 4-momentum vector // static void FillEventDerived(float* values = nullptr); static void FillTrackDerived(float* values = nullptr); @@ -2866,16 +2870,11 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values) bool useRM = fgUsedVars[kCosThetaRM]; // Random frame if (useHE || useCS || usePP || useRM) { - // TO DO: get the correct values from CCDB - double BeamMomentum = TMath::Sqrt(fgCenterOfMassEnergy * fgCenterOfMassEnergy / 4 - fgMassofCollidingParticle * fgMassofCollidingParticle); // GeV - ROOT::Math::PxPyPzEVector Beam1(0., 0., -BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::PxPyPzEVector Beam2(0., 0., BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::Boost boostv12{v12.BoostToCM()}; ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam1_CM{(boostv12(Beam1).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam2_CM{(boostv12(Beam2).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam1_CM{(boostv12(fgBeamA).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam2_CM{(boostv12(fgBeamC).Vect()).Unit()}; // using positive sign convention for the first track ROOT::Math::XYZVectorF v_CM = (t1.sign() > 0 ? v1_CM : v2_CM); @@ -3381,16 +3380,11 @@ void VarManager::FillPairMC(T1 const& t1, T2 const& t2, float* values) bool useRM = fgUsedVars[kMCCosThetaRM]; // Random frame if (useHE || useCS || usePP || useRM) { - // TO DO: get the correct values from CCDB - double BeamMomentum = TMath::Sqrt(fgCenterOfMassEnergy * fgCenterOfMassEnergy / 4 - fgMassofCollidingParticle * fgMassofCollidingParticle); // GeV - ROOT::Math::PxPyPzEVector Beam1(0., 0., -BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::PxPyPzEVector Beam2(0., 0., BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::Boost boostv12{v12.BoostToCM()}; ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam1_CM{(boostv12(Beam1).Vect()).Unit()}; - ROOT::Math::XYZVectorF Beam2_CM{(boostv12(Beam2).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam1_CM{(boostv12(fgBeamA).Vect()).Unit()}; + ROOT::Math::XYZVectorF Beam2_CM{(boostv12(fgBeamC).Vect()).Unit()}; // using positive sign convention for the first track ROOT::Math::XYZVectorF v_CM = (t1.pdgCode() > 0 ? v1_CM : v2_CM); @@ -4848,9 +4842,6 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) // global polarization parameters bool useGlobalPolarizatiobSpinOne = fgUsedVars[kCosThetaStarTPC] || fgUsedVars[kCosThetaStarFT0A] || fgUsedVars[kCosThetaStarFT0C]; if (useGlobalPolarizatiobSpinOne) { - double BeamMomentum = TMath::Sqrt(fgCenterOfMassEnergy * fgCenterOfMassEnergy / 4 - fgMassofCollidingParticle * fgMassofCollidingParticle); // GeV - ROOT::Math::PxPyPzEVector Beam1(0., 0., -BeamMomentum, fgCenterOfMassEnergy / 2); - ROOT::Math::Boost boostv12{v12.BoostToCM()}; ROOT::Math::XYZVectorF v1_CM{(boostv12(v1).Vect()).Unit()}; ROOT::Math::XYZVectorF v2_CM{(boostv12(v2).Vect()).Unit()}; diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index ebb21398062..11c63afc903 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -1217,6 +1217,7 @@ struct AnalysisSameEventPairing { Configurable grpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable GrpLhcIfPath{"grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; } fConfigCCDB; struct : ConfigurableGroup { @@ -1231,6 +1232,7 @@ struct AnalysisSameEventPairing { Configurable collisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable centerMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; Configurable propTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; + Configurable useRemoteCollisionInfo{"cfgUseRemoteCollisionInfo", false, "Use remote collision information from CCDB"}; } fConfigOptions; Service fCCDB; @@ -1551,6 +1553,11 @@ struct AnalysisSameEventPairing { uint64_t sor = std::atol(header["SOR"].c_str()); uint64_t eor = std::atol(header["EOR"].c_str()); VarManager::SetSORandEOR(sor, eor); + + if (fConfigOptions.useRemoteCollisionInfo) { + o2::parameters::GRPLHCIFData* grpo = fCCDB->getForTimeStamp(fConfigCCDB.GrpLhcIfPath, timestamp); + VarManager::SetCollisionSystem(grpo); + } } // Template function to run same event pairing (barrel-barrel, muon-muon, barrel-muon) From 5340199cbc117ba3ed60e0aa9f338139fbce55ed Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 7 Jul 2025 12:31:44 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGDQ/Core/VarManager.cxx | 10 +++--- PWGDQ/Core/VarManager.h | 67 +++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index 9165efadbd9..b68a61bd74d 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -35,7 +35,7 @@ int VarManager::fgITSROFBorderMarginLow = 0; int VarManager::fgITSROFBorderMarginHigh = 0; uint64_t VarManager::fgSOR = 0; uint64_t VarManager::fgEOR = 0; -ROOT::Math::PxPyPzEVector VarManager::fgBeamA(0, 0, 6799.99, 6800); // GeV, beam from A-side 4-momentum vector +ROOT::Math::PxPyPzEVector VarManager::fgBeamA(0, 0, 6799.99, 6800); // GeV, beam from A-side 4-momentum vector ROOT::Math::PxPyPzEVector VarManager::fgBeamC(0, 0, -6799.99, 6800); // GeV, beam from C-side 4-momentum vector o2::vertexing::DCAFitterN<2> VarManager::fgFitterTwoProngBarrel; o2::vertexing::DCAFitterN<3> VarManager::fgFitterThreeProngBarrel; @@ -116,8 +116,8 @@ void VarManager::SetCollisionSystem(TString system, float energy) // int NumberOfNucleonsA = 1; // default value for pp collisions int NumberOfNucleonsC = 1; // default value for pp collisions - int NumberOfProtonsA = 1; // default value for pp collisions - int NumberOfProtonsC = 1; // default value for pp collisions + int NumberOfProtonsA = 1; // default value for pp collisions + int NumberOfProtonsC = 1; // default value for pp collisions if (system.EqualTo("PbPb")) { NumberOfNucleonsA = 208; NumberOfNucleonsC = 208; @@ -136,13 +136,13 @@ void VarManager::SetCollisionSystem(TString system, float energy) } else if (system.EqualTo("pPb")) { NumberOfNucleonsA = 1; NumberOfNucleonsC = 208; - NumberOfProtonsA = 1; // proton has 1 proton + NumberOfProtonsA = 1; // proton has 1 proton NumberOfProtonsC = 82; // Pb has 82 protons } else if (system.EqualTo("Pbp")) { NumberOfNucleonsA = 208; NumberOfNucleonsC = 1; NumberOfProtonsA = 82; // Pb has 82 protons - NumberOfProtonsC = 1; // proton has 1 proton + NumberOfProtonsC = 1; // proton has 1 proton } else if (system.EqualTo("OO")) { NumberOfNucleonsA = 16; NumberOfNucleonsC = 16; diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 3e4531b357b..dfcba891bfc 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -24,50 +24,49 @@ #define HomogeneousField #endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "TRandom.h" -#include "TH3F.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "Math/GenVector/Boost.h" -#include "Math/VectorUtil.h" - -#include "Framework/DataTypes.h" -#include "TGeoGlobalMagField.h" -#include "Field/MagneticField.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/Vertex.h" -#include "DCAFitter/DCAFitterN.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/CCDB/TriggerAliases.h" -#include "ReconstructionDataFormats/DCA.h" -#include "DetectorsBase/Propagator.h" +#include "Common/Core/CollisionTypeHelper.h" +#include "Common/Core/EventPlaneHelper.h" #include "Common/Core/trackUtilities.h" -#include "Math/SMatrix.h" -#include "ReconstructionDataFormats/TrackFwd.h" +#include "CommonConstants/LHCConstants.h" +#include "CommonConstants/PhysicsConstants.h" +#include "DCAFitter/DCAFitterN.h" #include "DCAFitter/FwdDCAFitterN.h" +#include "DetectorsBase/Propagator.h" +#include "Field/MagneticField.h" +#include "Framework/DataTypes.h" #include "GlobalTracking/MatchGlobalFwd.h" -#include "CommonConstants/PhysicsConstants.h" -#include "CommonConstants/LHCConstants.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackFwd.h" +#include "ReconstructionDataFormats/Vertex.h" + +#include "Math/GenVector/Boost.h" +#include "Math/SMatrix.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" +#include "Math/VectorUtil.h" +#include "TGeoGlobalMagField.h" +#include "TH3F.h" +#include "TRandom.h" +#include +#include -#include "KFParticle.h" #include "KFPTrack.h" #include "KFPVertex.h" +#include "KFParticle.h" #include "KFParticleBase.h" #include "KFVertex.h" -#include "Common/Core/EventPlaneHelper.h" -#include "Common/Core/CollisionTypeHelper.h" +#include +#include +#include +#include +#include +#include +#include using std::complex; using std::cout; @@ -1199,8 +1198,8 @@ class VarManager : public TObject static int fgITSROFBorderMarginHigh; // ITS ROF border high margin static uint64_t fgSOR; // Timestamp for start of run static uint64_t fgEOR; // Timestamp for end of run - static ROOT::Math::PxPyPzEVector fgBeamA; // beam from A-side 4-momentum vector - static ROOT::Math::PxPyPzEVector fgBeamC; // beam from C-side 4-momentum vector + static ROOT::Math::PxPyPzEVector fgBeamA; // beam from A-side 4-momentum vector + static ROOT::Math::PxPyPzEVector fgBeamC; // beam from C-side 4-momentum vector // static void FillEventDerived(float* values = nullptr); static void FillTrackDerived(float* values = nullptr);