diff --git a/ALICE3/DataModel/OTFLUT.h b/ALICE3/DataModel/OTFLUT.h new file mode 100644 index 00000000000..a678488bdf9 --- /dev/null +++ b/ALICE3/DataModel/OTFLUT.h @@ -0,0 +1,48 @@ +// 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 OTFLUT.h +/// \since 23/02/2026 +/// \author Jesper & Nicolò +/// \brief Set of tables for ALICE 3 tracker +/// + +#ifndef ALICE3_DATAMODEL_OTFLUT_H_ +#define ALICE3_DATAMODEL_OTFLUT_H_ + +#include "ALICE3/Core/DelphesO2TrackSmearer.h" + +#include "DataFormatsTOF/CalibLHCphaseTOF.h" +#include "Framework/AnalysisDataModel.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace otf::lut +{ + +// lutHeader_t* mLUTHeader[nLUTs] = {nullptr}; +// lutEntry_t***** mLUTEntry[nLUTs] = {nullptr}; + +DECLARE_SOA_CCDB_COLUMN(LUTHeader, lutHeader, lutHeader_t, "LUTS"); //! +// DECLARE_SOA_CCDB_COLUMN(LUTHeader, lutHeader, o2::dataformats::CalibLHCphaseTOF, "TOF/Calib/LHCphase"); //! + +} // namespace otf::lut + +DECLARE_SOA_TIMESTAMPED_TABLE(LUTs, aod::Timestamps, o2::aod::timestamp::Timestamp, 1, "LUTs", //! + otf::lut::LUTHeader); +} // namespace o2::aod + +#endif // ALICE3_DATAMODEL_OTFLUT_H_ diff --git a/ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx b/ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx index 293745458c9..65c0c334bc5 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx @@ -17,6 +17,7 @@ /// #include "ALICE3/Core/FastTracker.h" +#include "ALICE3/DataModel/OTFLUT.h" #include #include @@ -33,6 +34,7 @@ struct OnTheFlyDetectorGeometryProvider { o2::framework::Configurable> detectorConfiguration{"detectorConfiguration", std::vector{"$O2PHYSICS_ROOT/share/alice3/a3geometry_v3.ini"}, "Paths of the detector geometry configuration files"}; + o2::framework::Produces lutTable; o2::framework::Service ccdb; void init(o2::framework::InitContext&) { @@ -64,9 +66,41 @@ struct OnTheFlyDetectorGeometryProvider { LOG(info) << "Initialization completed"; } + lutHeader_t* mLUTHeader[10] = {nullptr}; void process(o2::aod::McCollisions const& mcCollisions, o2::aod::McParticles const& mcParticles) { - LOG(debug) << "On-the-fly detector geometry provider processing " << mcCollisions.size() << " collisions and " << mcParticles.size() << " particles."; + const int ipdg = 0; + mLUTHeader[ipdg] = new lutHeader_t; + + const std::string filename = "ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/el"; + const std::string localFilename = o2::fastsim::GeometryEntry::accessFile(filename, "./.ALICE3/LUTs/", ccdb.operator->(), 10); + + std::ifstream lutFile(localFilename, std::ifstream::binary); + if (!lutFile.is_open()) { + LOG(info) << " --- cannot open covariance matrix file for PDG " << pdg << ": " << localFilename << std::endl; + delete mLUTHeader[ipdg]; + mLUTHeader[ipdg] = nullptr; + return false; + } + lutFile.read(reinterpret_cast(mLUTHeader[ipdg]), sizeof(lutHeader_t)); + if (lutFile.gcount() != sizeof(lutHeader_t)) { + LOG(info) << " --- troubles reading covariance matrix header for PDG " << pdg << ": " << filename << std::endl; + LOG(info) << " --- expected/detected " << sizeof(lutHeader_t) << "/" << lutFile.gcount() << std::endl; + delete mLUTHeader[ipdg]; + mLUTHeader[ipdg] = nullptr; + return false; + } + if (mLUTHeader[ipdg]->version != LUTCOVM_VERSION) { + LOG(info) << " --- LUT header version mismatch: expected/detected = " << LUTCOVM_VERSION << "/" << mLUTHeader[ipdg]->version << std::endl; + delete mLUTHeader[ipdg]; + mLUTHeader[ipdg] = nullptr; + return false; + } + + lutTable + + LOG(debug) + << "On-the-fly detector geometry provider processing " << mcCollisions.size() << " collisions and " << mcParticles.size() << " particles."; } };