Skip to content
Merged
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
50 changes: 28 additions & 22 deletions ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Provide mandatory file documentation.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -8,10 +8,18 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

//
// Task to add a table of track parameters propagated to the primary vertex
//
/// \file onTheFlyTOFPID.cxx
///
/// \brief This task goes straight from a combination of track table and mcParticles
/// and a custom TOF configuration to a table of TOF NSigmas for the particles
/// being analysed. It currently contemplates 5 particle types:
/// electrons, pions, kaons, protons and muons
///
/// More particles could be added but would have to be added to the LUT
/// being used in the onTheFly tracker task.
///
/// \author David Dobrigkeit Chinellato, UNICAMP
/// \author Nicola Nicassio, University and INFN Bari

Check failure on line 22 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

#include <utility>
#include <map>
Expand Down Expand Up @@ -45,18 +53,6 @@
#include "TableHelper.h"
#include "ALICE3/Core/DelphesO2TrackSmearer.h"

/// \file onTheFlyTOFPID.cxx
///
/// \brief This task goes straight from a combination of track table and mcParticles
/// and a custom TOF configuration to a table of TOF NSigmas for the particles
/// being analysed. It currently contemplates 5 particle types:
/// electrons, pions, kaons, protons and muons
///
/// More particles could be added but would have to be added to the LUT
/// being used in the onTheFly tracker task.
///
/// \author David Dobrigkeit Chinellato, UNICAMP, Nicola Nicassio, University and INFN Bari

using namespace o2;
using namespace o2::framework;

Expand Down Expand Up @@ -150,10 +146,13 @@
}

if (plotsConfig.doQAplots) {
const AxisSpec axisdNdeta{200, 0.0f, 1000.0f, Form("dN/d#eta in |#eta| < %f", simConfig.multiplicityEtaRange.value)};

histos.add("h1dNdeta", "h2dNdeta", kTH1F, {axisdNdeta});
histos.add("h2dEventTime", "h2dEventTime", kTH2F, {{200, -1000, 1000, "computed"}, {200, -1000, 1000, "generated"}});
histos.add("h1dEventTimegen", "h1dEventTimegen", kTH1F, {{200, -1000, 1000, "generated"}});
histos.add("h1dEventTimerec", "h1dEventTimerec", kTH1F, {{200, -1000, 1000, "computed"}});
histos.add("h1dEventTimeres", "h1dEventTimeres", kTH1F, {{300, 0, 300, "resolution"}});
histos.add("h2dEventTimeres", "h2dEventTimeres", kTH2F, {axisdNdeta, {300, 0, 300, "resolution"}});

const AxisSpec axisMomentum{static_cast<int>(plotsConfig.nBinsP), 0.0f, +10.0f, "#it{p} (GeV/#it{c})"};
const AxisSpec axisMomentumSmall{static_cast<int>(plotsConfig.nBinsP), 0.0f, +1.0f, "#it{p} (GeV/#it{c})"};
Expand Down Expand Up @@ -181,7 +180,7 @@

std::string particle_names1[5] = {"#it{e}", "#it{#mu}", "#it{#pi}", "#it{K}", "#it{p}"};
std::string particle_names2[5] = {"Elec", "Muon", "Pion", "Kaon", "Prot"};
for (int i_true = 0; i_true < 5; i_true++) {

Check failure on line 183 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
std::string name_title_inner_track_res = "h2dInnerTimeResTrack" + particle_names2[i_true] + "VsP";
std::string name_title_inner_total_res = "h2dInnerTimeResTotal" + particle_names2[i_true] + "VsP";
std::string name_title_outer_track_res = "h2dOuterTimeResTrack" + particle_names2[i_true] + "VsP";
Expand All @@ -194,8 +193,8 @@
histos.add(name_title_outer_total_res.c_str(), name_title_outer_total_res.c_str(), kTH2F, {axisMomentum, axisTotalTimeRes});
}

for (int i_true = 0; i_true < 5; i_true++) {

Check failure on line 196 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
for (int i_hyp = 0; i_hyp < 5; i_hyp++) {

Check failure on line 197 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
std::string name_title_inner = "h2dInnerNsigmaTrue" + particle_names2[i_true] + "Vs" + particle_names2[i_hyp] + "Hypothesis";
std::string name_title_outer = "h2dOuterNsigmaTrue" + particle_names2[i_true] + "Vs" + particle_names2[i_hyp] + "Hypothesis";
if (i_true == i_hyp) {
Expand Down Expand Up @@ -299,7 +298,7 @@
cosAngle = (point2[0] - trcCircle.xC) * (startPoint[0] - trcCircle.xC) + (point2[1] - trcCircle.yC) * (startPoint[1] - trcCircle.yC);
}
cosAngle /= modulus;
length = trcCircle.rC * TMath::ACos(cosAngle);

Check failure on line 301 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
length *= std::sqrt(1.0f + track.getTgl() * track.getTgl());
}
return length;
Expand Down Expand Up @@ -351,6 +350,7 @@
float sum = 0.;
float sumw = 0.;

// Todo: check the different mass hypothesis iteratively
for (const auto& track : tracks) {
auto pdgInfo = pdg->GetParticle(track.mPdgCode);
if (pdgInfo == nullptr) {
Expand Down Expand Up @@ -427,7 +427,7 @@

std::array<float, 6> mcPvCov = {0.};
o2::dataformats::VertexBase mcPvVtx({0.0f, 0.0f, 0.0f}, mcPvCov);
const float eventCollisionTimePS = collision.collisionTime() * 1e3; // convert ns to ps
const float eventCollisionTimePS = (simConfig.considerEventTime.value ? collision.collisionTime() * 1e3 : 0.f); // convert ns to ps
if (collision.has_mcCollision()) {
auto mcCollision = collision.mcCollision();
mcPvVtx.setX(mcCollision.posX());
Expand Down Expand Up @@ -459,6 +459,9 @@
dNdEta += 1.f;
}
}
if (plotsConfig.doQAplots) {
histos.fill(HIST("h1dNdeta"), dNdEta);
}

tracksWithTime.clear(); // clear the vector of tracks with time to prepare the cache for the next event
tracksWithTime.reserve(tracks.size());
Expand All @@ -474,7 +477,7 @@
float xPv = -100, trackLengthInnerTOF = -1, trackLengthOuterTOF = -1;
if (o2track.propagateToDCA(mcPvVtx, simConfig.dBz))
xPv = o2track.getX();
if (xPv > -99.) {

Check failure on line 480 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
trackLengthInnerTOF = trackLength(o2track, simConfig.innerTOFRadius, simConfig.dBz);
trackLengthOuterTOF = trackLength(o2track, simConfig.outerTOFRadius, simConfig.dBz);
}
Expand All @@ -499,7 +502,7 @@
auto recoTrack = getTrackParCov(track);
if (recoTrack.propagateToDCA(pvVtx, simConfig.dBz))
xPv = recoTrack.getX();
if (xPv > -99.) {

Check failure on line 505 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
trackLengthRecoInnerTOF = trackLength(recoTrack, simConfig.innerTOFRadius, simConfig.dBz);
trackLengthRecoOuterTOF = trackLength(recoTrack, simConfig.outerTOFRadius, simConfig.dBz);
}
Expand All @@ -519,16 +522,18 @@
// Now we compute the event time for the tracks

std::array<float, 2> tzero = {0.f, 0.f};
const bool etStatus = eventTime(tracksWithTime, tzero);
if (!etStatus) {
LOG(warning) << "Event time calculation failed with " << tracksWithTime.size() << " tracks";
if (simConfig.considerEventTime.value) {
const bool etStatus = eventTime(tracksWithTime, tzero);
if (!etStatus) {
LOG(warning) << "Event time calculation failed with " << tracksWithTime.size() << " tracks";
}
}

if (plotsConfig.doQAplots) {
histos.fill(HIST("h2dEventTime"), tzero[0], eventCollisionTimePS);
histos.fill(HIST("h1dEventTimegen"), eventCollisionTimePS);
histos.fill(HIST("h1dEventTimerec"), tzero[0]);
histos.fill(HIST("h1dEventTimeres"), tzero[1]);
histos.fill(HIST("h2dEventTimeres"), dNdEta, tzero[1]);
}

// Then we do a second loop to compute the measured quantities with the measured event time
Expand All @@ -543,6 +548,7 @@
const float trackLengthRecoOuterTOF = trkWithTime.mTrackLengthOuterTOF.first;
const float trackLengthInnerTOF = trkWithTime.mTrackLengthInnerTOF.second;
const float trackLengthOuterTOF = trkWithTime.mTrackLengthOuterTOF.second;
// Todo: remove the bias of the track used in the event time calculation for low multiplicity events
const float measuredTimeInnerTOF = trkWithTime.mInnerTOFTime.first - tzero[0];
const float measuredTimeOuterTOF = trkWithTime.mOuterTOFTime.first - tzero[0];
const float momentum = trkWithTime.mMomentum.first;
Expand Down Expand Up @@ -572,7 +578,7 @@
}
}

for (int ii = 0; ii < 5; ii++) {

Check failure on line 581 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
nSigmaInnerTOF[ii] = -100;
nSigmaOuterTOF[ii] = -100;

Expand Down Expand Up @@ -672,7 +678,7 @@
}

if (plotsConfig.doQAplots) {
for (int ii = 0; ii < 5; ii++) {

Check failure on line 681 in ALICE3/TableProducer/OTF/onTheFlyTOFPID.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.
if (std::fabs(mcParticle.pdgCode()) != pdg->GetParticle(lpdg_array[ii])->PdgCode()) {
continue;
}
Expand Down
Loading