Skip to content
Merged
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
126 changes: 37 additions & 89 deletions EventFiltering/PWGLF/nucleiFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,50 @@
// 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.
// O2 includes

Check failure on line 11 in EventFiltering/PWGLF/nucleiFilter.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \author is missing, incorrect or misplaced.

Check failure on line 11 in EventFiltering/PWGLF/nucleiFilter.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \brief is missing, incorrect or misplaced.

Check failure on line 11 in EventFiltering/PWGLF/nucleiFilter.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

#include <cmath>
#include <string>
#include "../filterTables.h"

#include "Math/Vector4D.h"
#include "Math/GenVector/Boost.h"
#include "PWGLF/DataModel/LFPIDTOFGenericTables.h"
#include "PWGLF/DataModel/LFStrangenessTables.h"
#include "PWGLF/DataModel/Vtx3BodyTables.h"
#include "PWGLF/Utils/pidTOFGeneric.h"

#include "Common/Core/PID/PIDTOF.h"
#include "Common/Core/trackUtilities.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "CCDB/BasicCCDBManager.h"
#include "DCAFitter/DCAFitterN.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsTOF/ParameterContainers.h"
#include "DataFormatsTPC/BetheBlochAleph.h"
#include "DetectorsBase/GeometryManager.h"
#include "DetectorsBase/Propagator.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/runDataProcessing.h"
#include "ReconstructionDataFormats/Track.h"

#include "PWGLF/DataModel/Vtx3BodyTables.h"
#include "../filterTables.h"
#include "Math/GenVector/Boost.h"
#include "Math/Vector4D.h"

#include "ReconstructionDataFormats/Track.h"
#include "Common/Core/trackUtilities.h"
#include "DetectorsBase/Propagator.h"
#include "DetectorsBase/GeometryManager.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "DataFormatsTOF/ParameterContainers.h"
#include "CCDB/BasicCCDBManager.h"
#include "DCAFitter/DCAFitterN.h"
#include "PWGLF/DataModel/pidTOFGeneric.h"
#include "PWGLF/DataModel/LFStrangenessTables.h"
#include "Common/Core/PID/PIDTOF.h"
#include <cmath>
#include <memory>
#include <string>
#include <vector>

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

o2::common::core::MetadataHelper metadataInfo;

namespace
{

Expand Down Expand Up @@ -120,7 +126,9 @@
o2::base::MatLayerCylSet* lut = nullptr;
o2::vertexing::DCAFitterN<2> fitter2body;
o2::vertexing::DCAFitterN<3> fitter3body;
o2::pid::tof::TOFResoParamsV2 mRespParamsV2;
// TOF response and input parameters
o2::pid::tof::TOFResoParamsV3 mRespParamsV3;
o2::aod::pidtofgeneric::TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration
// configurable for hypertriton 3body decay
struct : ConfigurableGroup {
Configurable<double> bFieldInput{"trgH3L3Body.mBz", -999, "bz field, -999 is automatic"};
Expand Down Expand Up @@ -153,20 +161,12 @@
Configurable<std::string> grpmagPath{"trgH3L3Body.grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
Configurable<std::string> lutPath{"trgH3L3Body.lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
Configurable<std::string> geoPath{"trgH3L3Body.geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
// CCDB TOF PID paras
Configurable<int64_t> timestamp{"trgH3L3Body.ccdb-timestamp", -1, "timestamp of the object"};
Configurable<std::string> paramFileName{"trgH3L3Body.paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"};
Configurable<std::string> parametrizationPath{"trgH3L3Body.parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"};
Configurable<std::string> passName{"trgH3L3Body.passName", "", "Name of the pass inside of the CCDB parameter collection. If empty, the automatically deceted from metadata (to be implemented!!!)"};
Configurable<std::string> timeShiftCCDBPath{"trgH3L3Body.timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"};
Configurable<bool> loadResponseFromCCDB{"trgH3L3Body.loadResponseFromCCDB", false, "Flag to load the response from the CCDB"};
Configurable<bool> fatalOnPassNotAvailable{"trgH3L3Body.fatalOnPassNotAvailable", false, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"};
} trgH3L3Body;

HistogramRegistry qaHists{"qaHists", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
OutputObj<TH1D> hProcessedEvents{TH1D("hProcessedEvents", ";;Number of filtered events", kNtriggers + 1, -0.5, static_cast<double>(kNtriggers) + 0.5)};

void init(InitContext&)
void init(InitContext& initContext)
{
std::vector<double> ptBinning = {0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4., 5.};

Expand Down Expand Up @@ -214,6 +214,11 @@
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setFatalWhenNull(false);

// Initialization of TOF PID parameters for fH3L3Body
mTOFCalibConfig.metadataInfo = metadataInfo;
mTOFCalibConfig.inheritFromBaseTask(initContext);
mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters
}

void initCCDB(aod::BCsWithTimestamps::iterator const& bc)
Expand All @@ -223,10 +228,10 @@
}

// In case override, don't proceed, please - no CCDB access required
if (trgH3L3Body.bFieldInput > -990) {

Check failure on line 231 in EventFiltering/PWGLF/nucleiFilter.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.
mBz = trgH3L3Body.bFieldInput;
o2::parameters::GRPMagField grpmag;
if (std::fabs(mBz) > 1e-5) {

Check failure on line 234 in EventFiltering/PWGLF/nucleiFilter.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.
grpmag.setL3Current(30000.f / (mBz / 5.0f));
}
o2::base::Propagator::initFieldFromGRP(&grpmag);
Expand Down Expand Up @@ -258,71 +263,13 @@
fitter2body.setBz(mBz);
fitter3body.setBz(mBz);

if (trgH3L3Body.useMatCorrType == 2) {

Check failure on line 266 in EventFiltering/PWGLF/nucleiFilter.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.
// setMatLUT only after magfield has been initalized
// (setMatLUT has implicit and problematic init field call if not)
o2::base::Propagator::Instance()->setMatLUT(lut);
}

// Initial TOF PID Paras, copied from pidTOF.cxx
trgH3L3Body.timestamp.value = bc.timestamp();
ccdb->setTimestamp(trgH3L3Body.timestamp.value);
// Not later than now objects
ccdb->setCreatedNotAfter(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
// TODO: implement the automatic pass name detection from metadata
if (trgH3L3Body.passName.value == "") {
trgH3L3Body.passName.value = "unanchored"; // temporary default
LOG(warning) << "Passed autodetect mode for pass, not implemented yet, waiting for metadata. Taking '" << trgH3L3Body.passName.value << "'";
}
LOG(info) << "Using parameter collection, starting from pass '" << trgH3L3Body.passName.value << "'";

const std::string fname = trgH3L3Body.paramFileName.value;
if (!fname.empty()) { // Loading the parametrization from file
LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << trgH3L3Body.parametrizationPath.value;
if (1) {
o2::tof::ParameterCollection paramCollection;
paramCollection.loadParamFromFile(fname, trgH3L3Body.parametrizationPath.value);
LOG(info) << "+++ Loaded parameter collection from file +++";
if (!paramCollection.retrieveParameters(mRespParamsV2, trgH3L3Body.passName.value)) {
if (trgH3L3Body.fatalOnPassNotAvailable) {
LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", trgH3L3Body.passName.value.data());
} else {
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", trgH3L3Body.passName.value.data());
}
} else {
mRespParamsV2.setShiftParameters(paramCollection.getPars(trgH3L3Body.passName.value));
mRespParamsV2.printShiftParameters();
}
} else {
mRespParamsV2.loadParamFromFile(fname.data(), trgH3L3Body.parametrizationPath.value);
}
} else if (trgH3L3Body.loadResponseFromCCDB) { // Loading it from CCDB
LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << trgH3L3Body.parametrizationPath.value << " for timestamp " << trgH3L3Body.timestamp.value;
o2::tof::ParameterCollection* paramCollection = ccdb->getForTimeStamp<o2::tof::ParameterCollection>(trgH3L3Body.parametrizationPath.value, trgH3L3Body.timestamp.value);
paramCollection->print();
if (!paramCollection->retrieveParameters(mRespParamsV2, trgH3L3Body.passName.value)) { // Attempt at loading the parameters with the pass defined
if (trgH3L3Body.fatalOnPassNotAvailable) {
LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", trgH3L3Body.passName.value.data());
} else {
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", trgH3L3Body.passName.value.data());
}
} else { // Pass is available, load non standard parameters
mRespParamsV2.setShiftParameters(paramCollection->getPars(trgH3L3Body.passName.value));
mRespParamsV2.printShiftParameters();
}
}
mRespParamsV2.print();
if (trgH3L3Body.timeShiftCCDBPath.value != "") {
if (trgH3L3Body.timeShiftCCDBPath.value.find(".root") != std::string::npos) {
mRespParamsV2.setTimeShiftParameters(trgH3L3Body.timeShiftCCDBPath.value, "gmean_Pos", true);
mRespParamsV2.setTimeShiftParameters(trgH3L3Body.timeShiftCCDBPath.value, "gmean_Neg", false);
} else {
mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp<TGraph>(Form("%s/pos", trgH3L3Body.timeShiftCCDBPath.value.c_str()), trgH3L3Body.timestamp.value), true);
mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp<TGraph>(Form("%s/neg", trgH3L3Body.timeShiftCCDBPath.value.c_str()), trgH3L3Body.timestamp.value), false);
}
}

bachelorTOFPID.SetParams(mRespParamsV2);
mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, bc);
}

enum {
Expand Down Expand Up @@ -372,7 +319,7 @@
if (track.itsNCls() >= cfgCutNclusExtremeIonisationITS) {
double avgClsSize{0.};
double cosL{std::sqrt(1. / (1. + track.tgl() * track.tgl()))};
for (int iC{0}; iC < 7; ++iC) {

Check failure on line 322 in EventFiltering/PWGLF/nucleiFilter.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.
avgClsSize += track.itsClsSizeInLayer(iC);
}
avgClsSize = avgClsSize * cosL / track.itsNCls();
Expand All @@ -385,7 +332,7 @@
continue;
}

if (std::abs(track.tpcNSigmaDe()) < 5) {

Check failure on line 335 in EventFiltering/PWGLF/nucleiFilter.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.
qaHists.fill(HIST("fDeuTOFNsigma"), track.p() * track.sign(), track.tofNSigmaDe());
}

Expand Down Expand Up @@ -498,7 +445,7 @@
auto& piPropTrack = fitter2body.getTrack(1);
hePropTrack.getPxPyPzGlo(momHe3);
piPropTrack.getPxPyPzGlo(momPi);
for (int i = 0; i < 3; ++i) {

Check failure on line 448 in EventFiltering/PWGLF/nucleiFilter.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.
momHe3[i] *= 2;
momTot[i] = momHe3[i] + momPi[i];
}
Expand Down Expand Up @@ -568,7 +515,7 @@
float tofNSigmaDeuteron = -999;
if (track2.has_collision() && track2.hasTOF()) {
auto originalcol = track2.collision_as<ColWithEvTime>();
tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(track2, originalcol, collision);
tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(mRespParamsV3, track2, originalcol, collision);
}
if (track2.p() > trgH3L3Body.minDeuteronPUseTOF && (tofNSigmaDeuteron < trgH3L3Body.tofPIDNSigmaMin || tofNSigmaDeuteron > trgH3L3Body.tofPIDNSigmaMax)) {
continue;
Expand All @@ -585,7 +532,7 @@

std::array<float, 3> pos = {0.};
const auto& vtxXYZ = fitter3body.getPCACandidate();
for (int i = 0; i < 3; i++) {

Check failure on line 535 in EventFiltering/PWGLF/nucleiFilter.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.
pos[i] = vtxXYZ[i];
}

Expand Down Expand Up @@ -671,6 +618,7 @@

WorkflowSpec defineDataProcessing(ConfigContext const& cfg)
{
metadataInfo.initMetadata(cfg);
return WorkflowSpec{
adaptAnalysisTask<nucleiFilter>(cfg)};
}
5 changes: 3 additions & 2 deletions PWGLF/DataModel/LFHyperNucleiKinkTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ DECLARE_SOA_COLUMN(ItsClusterSizesMoth, itsClusterSizesMoth, uint32_t); //! ITS
DECLARE_SOA_COLUMN(ItsClusterSizesDaug, itsClusterSizesDaug, uint32_t); //! ITS cluster size of the daughter track
DECLARE_SOA_COLUMN(NSigmaTPCDaug, nSigmaTPCDaug, float); //! Number of tpc sigmas of the daughter track
DECLARE_SOA_COLUMN(NSigmaITSDaug, nSigmaITSDaug, float); //! Number of ITS sigmas of the daughter track
DECLARE_SOA_COLUMN(NSigmaTOFDaug, nSigmaTOFDaug, float); //! Number of TOF sigmas of the daughter track

DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); //! bool: true for hyperhelium4signal
DECLARE_SOA_COLUMN(IsSignalReco, isSignalReco, bool); //! bool: true if the signal is reconstructed
Expand Down Expand Up @@ -94,7 +95,7 @@ DECLARE_SOA_TABLE(HypKinkCand, "AOD", "HYPKINKCANDS",
hyperkink::PxDaugSV, hyperkink::PyDaugSV, hyperkink::PzDaugSV,
hyperkink::DcaMothPv, hyperkink::DcaDaugPv, hyperkink::DcaKinkTopo,
hyperkink::ItsChi2Moth, hyperkink::ItsClusterSizesMoth, hyperkink::ItsClusterSizesDaug,
hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug);
hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug, hyperkink::NSigmaTOFDaug);

DECLARE_SOA_TABLE(MCHypKinkCand, "AOD", "MCHYPKINKCANDS",
o2::soa::Index<>,
Expand All @@ -109,7 +110,7 @@ DECLARE_SOA_TABLE(MCHypKinkCand, "AOD", "MCHYPKINKCANDS",
hyperkink::PxDaugSV, hyperkink::PyDaugSV, hyperkink::PzDaugSV,
hyperkink::DcaMothPv, hyperkink::DcaDaugPv, hyperkink::DcaKinkTopo,
hyperkink::ItsChi2Moth, hyperkink::ItsClusterSizesMoth, hyperkink::ItsClusterSizesDaug,
hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug,
hyperkink::NSigmaTPCDaug, hyperkink::NSigmaITSDaug, hyperkink::NSigmaTOFDaug,
hyperkink::IsSignal, hyperkink::IsSignalReco, hyperkink::IsCollReco, hyperkink::IsSurvEvSelection,
hyperkink::TrueXSV, hyperkink::TrueYSV, hyperkink::TrueZSV,
hyperkink::TruePxMothPV, hyperkink::TruePyMothPV, hyperkink::TruePzMothPV,
Expand Down
59 changes: 59 additions & 0 deletions PWGLF/DataModel/LFPIDTOFGenericTables.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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.
//
/// \file LFPIDTOFGenericTables.h
/// \brief Table for event time without remving track bias
/// \author Yuanzhe Wang <yuanzhe.wang@cern.ch>

#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"

#ifndef PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_
#define PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_
#include "Common/Core/PID/PIDTOF.h"

#include "CommonDataFormat/InteractionRecord.h"

namespace o2::aod
{
namespace evtime
{

DECLARE_SOA_COLUMN(EvTime, evTime, float); //! Event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
DECLARE_SOA_COLUMN(EvTimeErr, evTimeErr, float); //! Error of event time. Can be obtained via a combination of detectors e.g. TOF, FT0A, FT0C
DECLARE_SOA_COLUMN(EvTimeTOF, evTimeTOF, float); //! Event time computed with the TOF detector
DECLARE_SOA_COLUMN(EvTimeTOFErr, evTimeTOFErr, float); //! Error of the event time computed with the TOF detector
DECLARE_SOA_COLUMN(EvTimeFT0, evTimeFT0, float); //! Event time computed with the FT0 detector
DECLARE_SOA_COLUMN(EvTimeFT0Err, evTimeFT0Err, float); //! Error of the event time computed with the FT0 detector
} // namespace evtime

DECLARE_SOA_TABLE(EvTimeTOFFT0, "AOD", "EvTimeTOFFT0", //! Table of the event time. One entry per collision.
evtime::EvTime,
evtime::EvTimeErr,
evtime::EvTimeTOF,
evtime::EvTimeTOFErr,
evtime::EvTimeFT0,
evtime::EvTimeFT0Err);

namespace tracktime
{

DECLARE_SOA_COLUMN(EvTimeForTrack, evTimeForTrack, float); //! Event time. Removed the bias for the specific track
DECLARE_SOA_COLUMN(EvTimeErrForTrack, evTimeErrForTrack, float); //! Error of event time. Removed the bias for the specific track
} // namespace tracktime

DECLARE_SOA_TABLE(EvTimeTOFFT0ForTrack, "AOD", "EvTimeForTrack", //! Table of the event time. One entry per track.
tracktime::EvTimeForTrack,
tracktime::EvTimeErrForTrack);

} // namespace o2::aod

#endif // PWGLF_DATAMODEL_LFPIDTOFGENERICTABLES_H_
Loading
Loading