Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PWGDQ/Core/VarManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
bool VarManager::fgPVrecalKF = true;
float VarManager::fgMagField = 0.5;
float VarManager::fgzMatching = -77.5;
float VarManager::fgxShiftFwd = 0.0;
float VarManager::fgyShiftFwd = 0.0;
float VarManager::fgzShiftFwd = 0.0;
float VarManager::fgValues[VarManager::kNVars] = {0.0f};
float VarManager::fgTPCInterSectorBoundary = 1.0; // cm
Expand Down Expand Up @@ -198,8 +200,8 @@
// TO Do: add more systems

// set the beam 4-momentum vectors
float beamAEnergy = energy / 2.0 * sqrt(NumberOfProtonsA * NumberOfProtonsC / NumberOfProtonsC / NumberOfProtonsA); // GeV

Check failure on line 203 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
float beamCEnergy = energy / 2.0 * sqrt(NumberOfProtonsC * NumberOfProtonsA / NumberOfProtonsA / NumberOfProtonsC); // GeV

Check failure on line 204 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
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);
Expand Down Expand Up @@ -298,7 +300,7 @@
double mean = calibMeanHist->GetBinContent(binTPCncls, binPin, binEta);
double sigma = calibSigmaHist->GetBinContent(binTPCncls, binPin, binEta);
return (nSigmaValue - mean) / sigma; // Return the calibrated nSigma value
} else if (fgCalibrationType == 2) {

Check failure on line 303 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
// get the calibration histograms
CalibObjects calibMean, calibSigma, calibStatus;
switch (species) {
Expand Down Expand Up @@ -533,14 +535,14 @@
// Bimodality coefficient = (skewness^2 + 1) / kurtosis
// return a tuple including the coefficient, mean, RMS, skewness, and kurtosis
size_t n = data.size();
if (n < 3) {

Check failure on line 538 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return std::make_tuple(-1.0, -1.0, -1.0, -1.0, -1.0);
}
float mean = std::accumulate(data.begin(), data.end(), 0.0) / n;

float m2 = 0.0, m3 = 0.0, m4 = 0.0;
float diff, diff2;
for (float x : data) {

Check failure on line 545 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
diff = x - mean;
diff2 = diff * diff;
m2 += diff2;
Expand Down Expand Up @@ -579,7 +581,7 @@
int nBins = static_cast<int>((max - min) / binWidth);
std::vector<int> counts(nBins, 0.0);

for (float x : data) {

Check failure on line 584 in PWGDQ/Core/VarManager.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (x < min || x >= max) {
continue; // skip out-of-range values
}
Expand Down
18 changes: 14 additions & 4 deletions PWGDQ/Core/VarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,14 @@
fgzShiftFwd = z;
}

// Set x, y and z shifts for forward tracks
static void Set3DShift(float x, float y, float z)
{
fgxShiftFwd = x;
fgyShiftFwd = y;
fgzShiftFwd = z;
}

// Setup the 2 prong KFParticle
static void SetupTwoProngKFParticle(float magField)
{
Expand Down Expand Up @@ -1524,7 +1532,7 @@

static void SetCalibrationType(int type, bool useInterpolation = true)
{
if (type < 0 || type > 2) {

Check failure on line 1535 in PWGDQ/Core/VarManager.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOG(fatal) << "Invalid calibration type. Must be 0, 1, or 2.";
}
fgCalibrationType = type;
Expand Down Expand Up @@ -1576,6 +1584,8 @@

static float fgMagField;
static float fgzMatching;
static float fgxShiftFwd;
static float fgyShiftFwd;
static float fgzShiftFwd;
static float fgCenterOfMassEnergy; // collision energy
static float fgMassofCollidingParticle; // mass of the colliding particle
Expand Down Expand Up @@ -1755,9 +1765,9 @@
template <typename T, typename C>
o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C& collision, const int endPoint)
{
o2::track::TrackParCovFwd fwdtrack = o2::aod::fwdtrackutils::getTrackParCovFwdShift(muon, fgzShiftFwd, muon);
o2::track::TrackParCovFwd fwdtrack = o2::aod::fwdtrackutils::getTrackParCovFwd3DShift(muon, fgxShiftFwd, fgyShiftFwd, fgzShiftFwd, muon);
o2::dataformats::GlobalFwdTrack propmuon;
if (static_cast<int>(muon.trackType()) > 2) {

Check failure on line 1770 in PWGDQ/Core/VarManager.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
o2::dataformats::GlobalFwdTrack track;
track.setParameters(fwdtrack.getParameters());
track.setZ(fwdtrack.getZ());
Expand All @@ -1782,7 +1792,7 @@
propmuon.setZ(proptrack.getZ());
propmuon.setCovariances(proptrack.getCovariances());

} else if (static_cast<int>(muon.trackType()) < 2) {

Check failure on line 1795 in PWGDQ/Core/VarManager.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
std::array<double, 3> dcaInfOrig{999.f, 999.f, 999.f};
fwdtrack.propagateToDCAhelix(fgMagField, {collision.posX(), collision.posY(), collision.posZ()}, dcaInfOrig);
propmuon.setParameters(fwdtrack.getParameters());
Expand Down Expand Up @@ -1844,7 +1854,7 @@

// Redo propagation only for muon tracks
// propagation of MFT tracks alredy done in fwdtrack-extention task
if (static_cast<int>(muon.trackType()) > 2) {

Check failure on line 1857 in PWGDQ/Core/VarManager.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(muon, collision, kToDCA);
o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, kToRabs);
float dcaX = (propmuonAtDCA.getX() - collision.posX());
Expand Down Expand Up @@ -1887,7 +1897,7 @@
double py = propmuon.getP() * std::sin(o2::constants::math::PIHalf - std::atan(mfttrack.tgl())) * std::sin(mfttrack.phi());
double pz = propmuon.getP() * std::cos(o2::constants::math::PIHalf - std::atan(mfttrack.tgl()));
double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2));
auto mftprop = o2::aod::fwdtrackutils::getTrackParCovFwdShift(mfttrack, fgzShiftFwd);
auto mftprop = o2::aod::fwdtrackutils::getTrackParCovFwd3DShift(mfttrack, fgxShiftFwd, fgyShiftFwd, fgzShiftFwd);
values[kX] = mftprop.getX();
values[kY] = mftprop.getY();
values[kZ] = mftprop.getZ();
Expand All @@ -1908,7 +1918,7 @@
if constexpr ((MuonfillMap & MuonCov) > 0) {
if constexpr ((MFTfillMap & MFTCov) > 0) {
o2::dataformats::GlobalFwdTrack propmuon = PropagateMuon(muontrack, collision);
auto mft = o2::aod::fwdtrackutils::getTrackParCovFwdShift(mfttrack, fgzShiftFwd, mftcov);
auto mft = o2::aod::fwdtrackutils::getTrackParCovFwd3DShift(mfttrack, fgxShiftFwd, fgyShiftFwd, fgzShiftFwd, mftcov);

o2::dataformats::GlobalFwdTrack globalRefit = o2::aod::fwdtrackutils::refitGlobalMuonCov(propmuon, mft);
values[kX] = globalRefit.getX();
Expand Down Expand Up @@ -3327,7 +3337,7 @@
values[kMuonC1Pt21Pt2] = track.c1Pt21Pt2();
}
if constexpr ((fillMap & MuonCov) > 0 || (fillMap & MuonCovRealign) > 0) {
auto muonTrack = o2::aod::fwdtrackutils::getTrackParCovFwdShift(track, fgzShiftFwd, track);
auto muonTrack = o2::aod::fwdtrackutils::getTrackParCovFwd3DShift(track, fgxShiftFwd, fgyShiftFwd, fgzShiftFwd, track);
auto muonCov = muonTrack.getCovariances();
values[kX] = muonTrack.getX();
values[kY] = muonTrack.getY();
Expand Down
18 changes: 11 additions & 7 deletions PWGDQ/TableProducer/tableMaker_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ struct TableMaker {
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
Configurable<std::string> fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
Configurable<std::string> fConfigGrpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
Configurable<std::string> fZShiftPath{"zShiftPath", "Users/m/mcoquet/ZShift", "CCDB path for z shift to apply to forward tracks"};
Configurable<bool> fUseRemoteZShift{"cfgUseRemoteZShift", false, "Enable getting Zshift from ccdb"};
Configurable<std::string> fFwdShiftPath{"fwdShiftPath", "Users/m/mcoquet/ZShift", "CCDB path for the shift to apply to forward tracks, either 1 value (z) or 3 values (x, y, z)"};
Configurable<bool> fUseRemoteFwdShift{"cfgUseRemoteFwdShift", false, "Enable getting the forward track shift from ccdb"};
Configurable<float> fManualZShift{"cfgManualZShift", 0.f, "Manual value for the Zshift for muons."};
Configurable<std::string> fConfigGrpMagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"};
} fConfigCCDB;
Expand Down Expand Up @@ -1726,12 +1726,16 @@ struct TableMaker {
o2::base::Propagator::initFieldFromGRP(fGrpMag);
VarManager::SetMagneticField(fGrpMag->getNominalL3Field());
}
if (fConfigCCDB.fUseRemoteZShift) {
auto* fZShift = fCCDB->getForTimeStamp<std::vector<float>>(fConfigCCDB.fZShiftPath, bcs.begin().timestamp());
if (fZShift != nullptr && !fZShift->empty()) {
VarManager::SetZShift((*fZShift)[0]);
if (fConfigCCDB.fUseRemoteFwdShift) {
auto* fFwdShift = fCCDB->getForTimeStamp<std::vector<float>>(fConfigCCDB.fFwdShiftPath, bcs.begin().timestamp());
if (fFwdShift == nullptr || fFwdShift->empty()) {
LOG(fatal) << "Could not retrieve forward track shift values from CCDB";
} else if (fFwdShift->size() == 1) {
VarManager::SetZShift((*fFwdShift)[0]);
} else if (fFwdShift->size() == 3) {
VarManager::Set3DShift((*fFwdShift)[0], (*fFwdShift)[1], (*fFwdShift)[2]);
} else {
LOG(fatal) << "Could not retrieve Z-shift value from CCDB";
LOG(fatal) << "Unexpected number of shift values from CCDB: " << fFwdShift->size() << ", expected 1 (z) or 3 (x, y, z)";
}
} else {
VarManager::SetZShift(fConfigCCDB.fManualZShift.value);
Expand Down
Loading