Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally add time of FIT channels to AO2D #13857

Merged
merged 1 commit into from
Jan 30, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ O2_DEFINE_ENUM_BIT_OPERATORS(AODProducerStreamerMask)
class AODProducerWorkflowDPL : public Task
{
public:
AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr<DataRequest> dataRequest, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool enableSV, bool useMC = true) : mUseMC(useMC), mEnableSV(enableSV), mInputSources(src), mDataRequest(dataRequest), mGGCCDBRequest(gr) {}
AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr<DataRequest> dataRequest, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool enableSV, bool useMC = true, bool enableFITextra = false) : mUseMC(useMC), mEnableSV(enableSV), mEnableFITextra(enableFITextra), mInputSources(src), mDataRequest(dataRequest), mGGCCDBRequest(gr) {}
~AODProducerWorkflowDPL() override = default;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;
Expand Down Expand Up @@ -257,6 +257,7 @@ class AODProducerWorkflowDPL : public Task
int mNThreads = 1;
bool mUseMC = true;
bool mEnableSV = true; // enable secondary vertices
bool mEnableFITextra = false;
bool mFieldON = false;
const float cSpeed = 0.029979246f; // speed of light in TOF units

Expand Down Expand Up @@ -373,8 +374,11 @@ class AODProducerWorkflowDPL : public Task
uint32_t mMuonCl = 0xFFFFFF00; // 15 bits
uint32_t mMuonClErr = 0xFFFF0000; // 7 bits
uint32_t mV0Time = 0xFFFFF000; // 11 bits
uint32_t mV0ChannelTime = 0xFFFFFF00; // 15 bits
uint32_t mFDDTime = 0xFFFFF000; // 11 bits
uint32_t mFDDChannelTime = 0xFFFFFF00; // 15 bits
uint32_t mT0Time = 0xFFFFFF00; // 15 bits
uint32_t mT0ChannelTime = 0xFFFFFFF0; // 19 bits
uint32_t mV0Amplitude = 0xFFFFF000; // 11 bits
uint32_t mFDDAmplitude = 0xFFFFF000; // 11 bits
uint32_t mT0Amplitude = 0xFFFFF000; // 11 bits
Expand Down Expand Up @@ -672,7 +676,7 @@ class AODProducerWorkflowDPL : public Task
};

/// create a processor spec
framework::DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableST, bool useMC, bool CTPConfigPerRun);
framework::DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableST, bool useMC, bool CTPConfigPerRun, bool enableFITextra);

// helper interface for calo cells to "befriend" emcal and phos cells
class CellHelper
Expand Down
65 changes: 49 additions & 16 deletions Detectors/AOD/src/AODProducerWorkflowSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1744,8 +1744,11 @@ void AODProducerWorkflowDPL::init(InitContext& ic)
mMuonCl = 0xFFFFFFFF;
mMuonClErr = 0xFFFFFFFF;
mV0Time = 0xFFFFFFFF;
mV0ChannelTime = 0xFFFFFFFF;
mFDDTime = 0xFFFFFFFF;
mFDDChannelTime = 0xFFFFFFFF;
mT0Time = 0xFFFFFFFF;
mT0ChannelTime = 0xFFFFFFFF;
mV0Amplitude = 0xFFFFFFFF;
mFDDAmplitude = 0xFFFFFFFF;
mT0Amplitude = 0xFFFFFFFF;
Expand Down Expand Up @@ -1830,8 +1833,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
auto trackedV0Cursor = createTableCursor<o2::aod::TrackedV0s>(pc);
auto tracked3BodyCurs = createTableCursor<o2::aod::Tracked3Bodys>(pc);
auto fddCursor = createTableCursor<o2::aod::FDDs>(pc);
auto fddExtraCursor = createTableCursor<o2::aod::FDDsExtra>(pc);
auto ft0Cursor = createTableCursor<o2::aod::FT0s>(pc);
auto ft0ExtraCursor = createTableCursor<o2::aod::FT0sExtra>(pc);
auto fv0aCursor = createTableCursor<o2::aod::FV0As>(pc);
auto fv0aExtraCursor = createTableCursor<o2::aod::FV0AsExtra>(pc);
auto fwdTracksCursor = createTableCursor<o2::aod::StoredFwdTracks>(pc);
auto fwdTracksCovCursor = createTableCursor<o2::aod::StoredFwdTracksCov>(pc);
auto fwdTrkClsCursor = createTableCursor<o2::aod::FwdTrkCls>(pc);
Expand Down Expand Up @@ -1897,16 +1903,18 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
tfNumber = mTFNumber;
}

std::vector<float> aAmplitudes;
std::vector<float> aAmplitudes, aTimes;
std::vector<uint8_t> aChannels;
fv0aCursor.reserve(fv0RecPoints.size());
for (auto& fv0RecPoint : fv0RecPoints) {
aAmplitudes.clear();
aChannels.clear();
aTimes.clear();
const auto channelData = fv0RecPoint.getBunchChannelData(fv0ChData);
for (auto& channel : channelData) {
if (channel.charge > 0) {
Copy link
Collaborator

@jotwinow jotwinow Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this condition on the charge

aAmplitudes.push_back(truncateFloatFraction(channel.charge, mV0Amplitude));
aTimes.push_back(truncateFloatFraction(channel.time * 1.E-3, mV0ChannelTime));
aChannels.push_back(channel.channel);
}
}
Expand All @@ -1923,6 +1931,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
aChannels,
truncateFloatFraction(fv0RecPoint.getCollisionGlobalMeanTime() * 1E-3, mV0Time), // ps to ns
fv0RecPoint.getTrigger().getTriggersignals());

if (mEnableFITextra) {
fv0aExtraCursor(bcID,
aTimes);
}
}

std::vector<float> zdcEnergy, zdcAmplitudes, zdcTime;
Expand Down Expand Up @@ -2026,25 +2039,17 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
[](const std::vector<int>& left, const std::vector<int>& right) { return (left[0] < right[0]); });

// vector of FDD amplitudes
int16_t aFDDAmplitudesA[8] = {0u};
int16_t aFDDAmplitudesC[8] = {0u};
int16_t aFDDAmplitudesA[8] = {0u}, aFDDAmplitudesC[8] = {0u};
float aFDDTimesA[8] = {0.f}, aFDDTimesC[8] = {0.f};
// filling FDD table
fddCursor.reserve(fddRecPoints.size());
for (const auto& fddRecPoint : fddRecPoints) {
for (int i = 0; i < 8; i++) {
aFDDAmplitudesA[i] = 0;
aFDDAmplitudesC[i] = 0;
aFDDTimesA[i] = 0.f;
aFDDTimesC[i] = 0.f;
}

const auto channelData = fddRecPoint.getBunchChannelData(fddChData);
for (const auto& channel : channelData) {
if (channel.mPMNumber < 8) {
aFDDAmplitudesC[channel.mPMNumber] = channel.mChargeADC; // amplitude
} else {
aFDDAmplitudesA[channel.mPMNumber - 8] = channel.mChargeADC; // amplitude
}
}

uint64_t globalBC = fddRecPoint.getInteractionRecord().toLong();
uint64_t bc = globalBC;
auto item = bcsMap.find(bc);
Expand All @@ -2054,21 +2059,39 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
} else {
LOG(fatal) << "Error: could not find a corresponding BC ID for a FDD rec. point; BC = " << bc;
}
const auto channelData = fddRecPoint.getBunchChannelData(fddChData);
for (const auto& channel : channelData) {
if (channel.mPMNumber < 8) {
aFDDAmplitudesC[channel.mPMNumber] = channel.mChargeADC; // amplitude
aFDDTimesC[channel.mPMNumber] = truncateFloatFraction(channel.mTime * 1E-3, mFDDChannelTime); // time
} else {
aFDDAmplitudesA[channel.mPMNumber - 8] = channel.mChargeADC; // amplitude
aFDDTimesA[channel.mPMNumber - 8] = truncateFloatFraction(channel.mTime * 1E-3, mFDDChannelTime); // time
}
}

fddCursor(bcID,
aFDDAmplitudesA,
aFDDAmplitudesC,
truncateFloatFraction(fddRecPoint.getCollisionTimeA() * 1E-3, mFDDTime), // ps to ns
truncateFloatFraction(fddRecPoint.getCollisionTimeC() * 1E-3, mFDDTime), // ps to ns
fddRecPoint.getTrigger().getTriggersignals());
if (mEnableFITextra) {
fddExtraCursor(bcID,
aFDDTimesA,
aFDDTimesC);
}
}

// filling FT0 table
std::vector<float> aAmplitudesA, aAmplitudesC;
std::vector<float> aAmplitudesA, aAmplitudesC, aTimesA, aTimesC;
std::vector<uint8_t> aChannelsA, aChannelsC;
ft0Cursor.reserve(ft0RecPoints.size());
for (auto& ft0RecPoint : ft0RecPoints) {
aAmplitudesA.clear();
aAmplitudesC.clear();
aTimesA.clear();
aTimesC.clear();
aChannelsA.clear();
aChannelsC.clear();
const auto channelData = ft0RecPoint.getBunchChannelData(ft0ChData);
Expand All @@ -2079,9 +2102,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
if (channel.ChId < nFT0ChannelsAside) {
aChannelsA.push_back(channel.ChId);
aAmplitudesA.push_back(truncateFloatFraction(channel.QTCAmpl, mT0Amplitude));
aTimesA.push_back(truncateFloatFraction(channel.CFDTime * 1E-3, mT0ChannelTime));
} else {
aChannelsC.push_back(channel.ChId - nFT0ChannelsAside);
aAmplitudesC.push_back(truncateFloatFraction(channel.QTCAmpl, mT0Amplitude));
aTimesC.push_back(truncateFloatFraction(channel.CFDTime * 1E-3, mT0ChannelTime));
}
}
}
Expand All @@ -2102,6 +2127,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
truncateFloatFraction(ft0RecPoint.getCollisionTimeA() * 1E-3, mT0Time), // ps to ns
truncateFloatFraction(ft0RecPoint.getCollisionTimeC() * 1E-3, mT0Time), // ps to ns
ft0RecPoint.getTrigger().getTriggersignals());
if (mEnableFITextra) {
ft0ExtraCursor(bcID,
aTimesA,
aTimesC);
}
}

if (mUseMC) {
Expand Down Expand Up @@ -3073,7 +3103,7 @@ void AODProducerWorkflowDPL::endOfStream(EndOfStreamContext& /*ec*/)
mStreamer.reset();
}

DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableStrangenessTracking, bool useMC, bool CTPConfigPerRun)
DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableStrangenessTracking, bool useMC, bool CTPConfigPerRun, bool enableFITextra)
{
auto dataRequest = std::make_shared<DataRequest>();
dataRequest->inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", CTPConfigPerRun));
Expand Down Expand Up @@ -3133,8 +3163,11 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
OutputForTable<Collisions>::spec(),
OutputForTable<Decay3Bodys>::spec(),
OutputForTable<FDDs>::spec(),
OutputForTable<FDDsExtra>::spec(),
OutputForTable<FT0s>::spec(),
OutputForTable<FT0sExtra>::spec(),
OutputForTable<FV0As>::spec(),
OutputForTable<FV0AsExtra>::spec(),
OutputForTable<StoredFwdTracks>::spec(),
OutputForTable<StoredFwdTracksCov>::spec(),
OutputForTable<StoredMFTTracks>::spec(),
Expand Down Expand Up @@ -3183,7 +3216,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
"aod-producer-workflow",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest, ggRequest, enableSV, useMC)},
AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest, ggRequest, enableSV, useMC, enableFITextra)},
Options{
ConfigParamSpec{"run-number", VariantType::Int64, -1L, {"The run-number. If left default we try to get it from DPL header."}},
ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}},
Expand Down
4 changes: 3 additions & 1 deletion Detectors/AOD/src/aod-producer-workflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{"disable-mc", o2::framework::VariantType::Bool, false, {"disable MC propagation"}},
{"disable-secondary-vertices", o2::framework::VariantType::Bool, false, {"disable filling secondary vertices"}},
{"disable-strangeness-tracker", o2::framework::VariantType::Bool, false, {"disable filling strangeness tracking"}},
{"enable-FIT-extra", o2::framework::VariantType::Bool, false, {"enable FIT extra output"}},
{"info-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}},
{"combine-source-devices", o2::framework::VariantType::Bool, false, {"merge DPL source devices"}},
Expand All @@ -54,6 +55,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
bool enableSV = !configcontext.options().get<bool>("disable-secondary-vertices");
bool enableST = !configcontext.options().get<bool>("disable-strangeness-tracker");
bool ctpcfgperrun = !configcontext.options().get<bool>("ctpconfig-run-independent");
bool enableFITextra = configcontext.options().get<bool>("enable-FIT-extra");

GID::mask_t allowedSrc = GID::getSourcesMask("ITS,MFT,MCH,MID,MCH-MID,TPC,TRD,ITS-TPC,TPC-TOF,TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TRD-TOF,MFT-MCH,FT0,FV0,FDD,ZDC,EMC,CTP,PHS,CPV,HMP");
GID::mask_t src = allowedSrc & GID::getSourcesMask(configcontext.options().get<std::string>("info-sources"));
Expand All @@ -64,7 +66,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
}

WorkflowSpec specs;
specs.emplace_back(o2::aodproducer::getAODProducerWorkflowSpec(src, enableSV, enableST, useMC, ctpcfgperrun));
specs.emplace_back(o2::aodproducer::getAODProducerWorkflowSpec(src, enableSV, enableST, useMC, ctpcfgperrun, enableFITextra));

auto srcCls = src & ~(GID::getSourceMask(GID::MCH) | GID::getSourceMask(GID::MID)); // Don't read global MID and MCH clusters (those attached to tracks are always read)
auto srcMtc = src;
Expand Down
20 changes: 20 additions & 0 deletions Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ namespace fv0a
{
DECLARE_SOA_INDEX_COLUMN(BC, bc); //! BC index
DECLARE_SOA_COLUMN(Amplitude, amplitude, std::vector<float>); //! Amplitudes of non-zero channels. The channel IDs are given in Channel (at the same index)
DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, std::vector<float>); //! Time of non-zero channels. The channel IDs are given in Channel (at the same index). Only for the FITExtra table
DECLARE_SOA_COLUMN(Channel, channel, std::vector<uint8_t>); //! Channel IDs which had non-zero amplitudes. There are at maximum 48 channels.
DECLARE_SOA_COLUMN(Time, time, float); //! Time in ns
DECLARE_SOA_COLUMN(TriggerMask, triggerMask, uint8_t); //!
Expand All @@ -1450,6 +1451,10 @@ DECLARE_SOA_TABLE(FV0As, "AOD", "FV0A", //!
o2::soa::Index<>, fv0a::BCId, fv0a::Amplitude, fv0a::Channel, fv0a::Time, fv0a::TriggerMask);
using FV0A = FV0As::iterator;

DECLARE_SOA_TABLE(FV0AsExtra, "AOD", "FV0AEXTRA", //! FV0AsExtra table
o2::soa::Index<>, fv0a::BCId, fv0a::TimeFV0A);
using FV0AExtra = FV0AsExtra::iterator;

// V0C table for Run2 only
namespace fv0c
{
Expand All @@ -1467,8 +1472,10 @@ namespace ft0
{
DECLARE_SOA_INDEX_COLUMN(BC, bc); //! BC index
DECLARE_SOA_COLUMN(AmplitudeA, amplitudeA, std::vector<float>); //! Amplitudes of non-zero channels on the A-side. The channel IDs are given in ChannelA (at the same index)
DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, std::vector<float>); //! Time of non-zero channels on the A-side. The channel IDs are given in ChannelA (at the same index). Only for the FITExtra table
pzhristov marked this conversation as resolved.
Show resolved Hide resolved
DECLARE_SOA_COLUMN(ChannelA, channelA, std::vector<uint8_t>); //! Channel IDs on the A side which had non-zero amplitudes. There are at maximum 96 channels.
DECLARE_SOA_COLUMN(AmplitudeC, amplitudeC, std::vector<float>); //! Amplitudes of non-zero channels on the C-side. The channel IDs are given in ChannelC (at the same index)
DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, std::vector<float>); //! Time of non-zero channels on the C-side. The channel IDs are given in ChannelC (at the same index). Only for the FITExtra table
DECLARE_SOA_COLUMN(ChannelC, channelC, std::vector<uint8_t>); //! Channel IDs on the C side which had non-zero amplitudes. There are at maximum 112 channels.
DECLARE_SOA_COLUMN(TimeA, timeA, float); //! Average A-side time
DECLARE_SOA_COLUMN(TimeC, timeC, float); //! Average C-side time
Expand Down Expand Up @@ -1512,6 +1519,11 @@ DECLARE_SOA_TABLE(FT0s, "AOD", "FT0", //!
ft0::SumAmpA<ft0::AmplitudeA>, ft0::SumAmpC<ft0::AmplitudeC>);
using FT0 = FT0s::iterator;

DECLARE_SOA_TABLE(FT0sExtra, "AOD", "FT0EXTRA", //! FT0sExtra table
o2::soa::Index<>, ft0::BCId,
ft0::TimeFT0A, ft0::TimeFT0C);
using FT0Extra = FT0sExtra::iterator;

namespace fdd
{
DECLARE_SOA_INDEX_COLUMN(BC, bc); //! BC index
Expand All @@ -1521,6 +1533,9 @@ DECLARE_SOA_COLUMN(AmplitudeC, amplitudeC, float[4]); //! Amplitude in adjacent
DECLARE_SOA_COLUMN(ChargeA, chargeA, int16_t[8]); //! Amplitude per channel A-side
DECLARE_SOA_COLUMN(ChargeC, chargeC, int16_t[8]); //! Amplitude per channel C-side

DECLARE_SOA_COLUMN(TimeFDDA, timeFDDA, float[8]); //! Time per channel A-side, only for the FITExtra table
DECLARE_SOA_COLUMN(TimeFDDC, timeFDDC, float[8]); //! Time per channel C-side, only for the FITExtra table

DECLARE_SOA_COLUMN(TimeA, timeA, float); //!
DECLARE_SOA_COLUMN(TimeC, timeC, float); //!
DECLARE_SOA_COLUMN(TriggerMask, triggerMask, uint8_t); //!
Expand All @@ -1542,6 +1557,11 @@ DECLARE_SOA_TABLE_VERSIONED(FDDs_001, "AOD", "FDD", 1, //! FDD table, version 00
using FDDs = FDDs_001; //! this defines the current default version
using FDD = FDDs::iterator;

DECLARE_SOA_TABLE(FDDsExtra, "AOD", "FDDEXTRA", //! FDDsExtra table
o2::soa::Index<>, fdd::BCId,
fdd::TimeFDDA, fdd::TimeFDDC);
using FDDExtra = FDDsExtra::iterator;

namespace v0
{
DECLARE_SOA_INDEX_COLUMN_FULL(PosTrack, posTrack, int, Tracks, "_Pos"); //! Positive track
Expand Down
Loading