Skip to content

Commit

Permalink
IDCs: adding possibility to disable sending of output
Browse files Browse the repository at this point in the history
adding debug output
  • Loading branch information
matthias-kleiner committed May 11, 2022
1 parent 4aaa476 commit 2cd2924
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class TPCDistributeIDCSpec : public o2::framework::Task

const auto descr = tpcCRUHeader->dataDescription;
if (TPCFLPIDCDevice<TPCFLPIDCDeviceGroup>::getDataDescriptionIDCGroup() == descr) {
LOGP(debug, "receiving IDCs for CRU: {}", cru);
mIDCs[currentBuffer][cru][relTF] = pc.inputs().get<pmr::vector<float>>(ref);
LOGP(info, "receiving IDCs for CRU: {} of size {}", cru, mIDCs[currentBuffer][cru][relTF].size());
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Detectors/TPC/workflow/include/TPCWorkflow/TPCFLPIDCSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,14 @@ class TPCFLPIDCDevice : public o2::framework::Task

// TODO use this and fix #include <boost/container/pmr/polymorphic_allocator.hpp> in ROOT CINT
// output.adoptContainer(Output{gDataOriginTPC, getDataDescriptionIDCGroup(), subSpec, Lifetime::Timeframe}, std::move(mIDCs[cru]).getIDCGroupData());
LOGP(info, "Sending IDCs of size {}", mIDCStruct.getData(cru).size());
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIDCGroup(), subSpec, Lifetime::Timeframe}, mIDCStruct.getData(cru));

mBuffer1DIDCs[cru].emplace_back(std::move(idcOne));
mBuffer1DIDCs[cru].pop_front(); // removing oldest 1D-IDCs

fill1DIDCs(cru);
LOGP(info, "Sending 1D-IDCs to EPNs of size {} and weights of size {}", mOneDIDCs.first.size(), mOneDIDCs.second.size());
output.snapshot(Output{gDataOriginTPC, getDataDescription1DIDCEPN(), subSpec, Lifetime::Timeframe}, mOneDIDCs.first);
output.snapshot(Output{gDataOriginTPC, getDataDescription1DIDCEPNWeights(), subSpec, Lifetime::Timeframe}, mOneDIDCs.second);
}
Expand Down
37 changes: 22 additions & 15 deletions Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class TPCFactorizeIDCSpec : public o2::framework::Task
template <bool IsEnabled = true, typename std::enable_if<(IsEnabled && (std::is_same<Type, TPCFactorizeIDCSpecNoGroup>::value)), int>::type = 0>
TPCFactorizeIDCSpec(const std::vector<uint32_t>& crus, const unsigned int timeframes, const unsigned int timeframesDeltaIDC, std::array<unsigned char, Mapper::NREGIONS> groupPads,
std::array<unsigned char, Mapper::NREGIONS> groupRows, std::array<unsigned char, Mapper::NREGIONS> groupLastRowsThreshold,
std::array<unsigned char, Mapper::NREGIONS> groupLastPadsThreshold, const unsigned int groupPadsSectorEdges, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp)
: mCRUs{crus}, mIDCFactorization{groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges, timeframes, timeframesDeltaIDC, crus}, mCompressionDeltaIDC{compression}, mDebug{debug}, mSendOutDebug{senddebug}, mUsePrecisetimeStamp{usePrecisetimeStamp} {};
std::array<unsigned char, Mapper::NREGIONS> groupLastPadsThreshold, const unsigned int groupPadsSectorEdges, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp, const bool sendOutputFFT)
: mCRUs{crus}, mIDCFactorization{groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges, timeframes, timeframesDeltaIDC, crus}, mCompressionDeltaIDC{compression}, mDebug{debug}, mSendOutDebug{senddebug}, mUsePrecisetimeStamp{usePrecisetimeStamp}, mSendOutFFT{sendOutputFFT} {};

template <bool IsEnabled = true, typename std::enable_if<(IsEnabled && (std::is_same<Type, TPCFactorizeIDCSpecGroup>::value)), int>::type = 0>
TPCFactorizeIDCSpec(const std::vector<uint32_t>& crus, const unsigned int timeframes, const unsigned int timeframesDeltaIDC, std::array<unsigned char, Mapper::NREGIONS> groupPads,
std::array<unsigned char, Mapper::NREGIONS> groupRows, std::array<unsigned char, Mapper::NREGIONS> groupLastRowsThreshold,
std::array<unsigned char, Mapper::NREGIONS> groupLastPadsThreshold, const unsigned int groupPadsSectorEdges, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp)
: mCRUs{crus}, mIDCFactorization{std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 0, timeframes, timeframesDeltaIDC, crus}, mIDCStruct{TPCFactorizeIDCStruct<TPCFactorizeIDCSpecGroup>(groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges)}, mCompressionDeltaIDC{compression}, mDebug{debug}, mSendOutDebug{senddebug}, mUsePrecisetimeStamp{usePrecisetimeStamp} {};
std::array<unsigned char, Mapper::NREGIONS> groupLastPadsThreshold, const unsigned int groupPadsSectorEdges, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp, const bool sendOutputFFT)
: mCRUs{crus}, mIDCFactorization{std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, std::array<unsigned char, Mapper::NREGIONS>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 0, timeframes, timeframesDeltaIDC, crus}, mIDCStruct{TPCFactorizeIDCStruct<TPCFactorizeIDCSpecGroup>(groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges)}, mCompressionDeltaIDC{compression}, mDebug{debug}, mSendOutDebug{senddebug}, mUsePrecisetimeStamp{usePrecisetimeStamp}, mSendOutFFT{sendOutputFFT} {};

void init(o2::framework::InitContext& ic) final
{
Expand Down Expand Up @@ -135,6 +135,7 @@ class TPCFactorizeIDCSpec : public o2::framework::Task
if (TPCDistributeIDCSpec::getDataDescriptionIDC() == descr) {
const int cru = tpcCRUHeader->subSpecification - mLaneId * CRU::MaxCRU;
mIDCFactorization.setIDCs(pc.inputs().get<std::vector<float>>(ref), cru, mProcessedTFs); // aggregate IDCs
LOGP(info, "Received IDCs for CRU {} of size {}", cru, mIDCFactorization.getIDCs()[cru][mProcessedTFs].size());
}
}
++mProcessedTFs;
Expand Down Expand Up @@ -181,6 +182,7 @@ class TPCFactorizeIDCSpec : public o2::framework::Task
const bool mDebug{false}; ///< dump IDCs to tree for debugging
const bool mSendOutDebug{false}; ///< flag if the output will be send (for debugging)
const bool mUsePrecisetimeStamp{true}; ///< use precise time stamp when writing to CCDB
const bool mSendOutFFT{false}; ///< flag if the output will be send for the FFT
o2::ccdb::CcdbApi mDBapi; ///< API for storing the IDCs in the CCDB
std::map<std::string, std::string> mMetadata; ///< meta data of the stored object in CCDB
bool mWriteToDB{}; ///< flag if writing to CCDB will be done
Expand Down Expand Up @@ -244,11 +246,13 @@ class TPCFactorizeIDCSpec : public o2::framework::Task
const auto timeStampEnd = (mTimeStampCCDB.second <= timeStampStart) ? timeStampStart + 1 : mTimeStampCCDB.second;

// sending output to FFT
LOGP(info, "Sending output");
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::A}}, mIDCFactorization.getIDCOne(Side::A));
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::C}}, mIDCFactorization.getIDCOne(Side::C));
output.snapshot(Output{gDataOriginTPC, getDataDescriptionTimeStamp()}, std::vector<uint64_t>{timeStampStart, timeStampEnd});
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIntervals()}, mIDCFactorization.getIntegrationIntervalsPerTF());
if (mSendOutFFT) {
LOGP(info, "Sending output");
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::A}}, mIDCFactorization.getIDCOne(Side::A));
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::C}}, mIDCFactorization.getIDCOne(Side::C));
output.snapshot(Output{gDataOriginTPC, getDataDescriptionTimeStamp()}, std::vector<uint64_t>{timeStampStart, timeStampEnd});
output.snapshot(Output{gDataOriginTPC, getDataDescriptionIntervals()}, mIDCFactorization.getIntegrationIntervalsPerTF());
}

if (mWriteToDB) {
LOGP(info, "Writing IDCs to CCDB");
Expand Down Expand Up @@ -326,17 +330,20 @@ class TPCFactorizeIDCSpec : public o2::framework::Task
};

template <class Type>
DataProcessorSpec getTPCFactorizeIDCSpec(const int lane, const std::vector<uint32_t>& crus, const unsigned int timeframes, const unsigned int timeframesDeltaIDC, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp)
DataProcessorSpec getTPCFactorizeIDCSpec(const int lane, const std::vector<uint32_t>& crus, const unsigned int timeframes, const unsigned int timeframesDeltaIDC, const IDCDeltaCompression compression, const bool debug, const bool senddebug, const bool usePrecisetimeStamp, const bool sendOutputFFT)
{
std::vector<OutputSpec> outputSpecs;
if (senddebug) {
outputSpecs.emplace_back(ConcreteDataTypeMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDC0()});
outputSpecs.emplace_back(ConcreteDataTypeMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDCDelta()});
}
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::A}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::C}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionTimeStamp(), header::DataHeader::SubSpecificationType{0}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIntervals(), header::DataHeader::SubSpecificationType{0}});

if (sendOutputFFT) {
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::A}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIDC1(), header::DataHeader::SubSpecificationType{Side::C}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionTimeStamp(), header::DataHeader::SubSpecificationType{0}});
outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCFactorizeIDCSpec<Type>::getDataDescriptionIntervals(), header::DataHeader::SubSpecificationType{0}});
}

std::vector<InputSpec> inputSpecs;
inputSpecs.reserve(crus.size());
Expand All @@ -363,7 +370,7 @@ DataProcessorSpec getTPCFactorizeIDCSpec(const int lane, const std::vector<uint3
fmt::format("tpc-factorize-idc-{:02}", lane).data(),
inputSpecs,
outputSpecs,
AlgorithmSpec{adaptFromTask<TPCFactorizeIDCSpec<Type>>(crus, timeframes, timeframesDeltaIDC, groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges, compression, debug, senddebug, usePrecisetimeStamp)},
AlgorithmSpec{adaptFromTask<TPCFactorizeIDCSpec<Type>>(crus, timeframes, timeframesDeltaIDC, groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, groupPadsSectorEdges, compression, debug, senddebug, usePrecisetimeStamp, sendOutputFFT)},
Options{{"ccdb-uri", VariantType::String, o2::base::NameConf::getCCDBServer(), {"URI for the CCDB access."}},
{"gainMapFile", VariantType::String, "", {"file to reference gain map, which will be used for correcting the cluster charge"}},
{"update-not-grouping-parameter", VariantType::Bool, false, {"Do NOT Update/Writing grouping parameters to CCDB."}}}}; // end DataProcessorSpec
Expand Down
9 changes: 5 additions & 4 deletions Detectors/TPC/workflow/src/IDCToVectorSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class IDCToVectorDevice : public o2::framework::Task
auto& idcs = *((idc::Container*)(data));
const uint32_t orbit = idcs.header.heartbeatOrbit;
const uint32_t bc = idcs.header.heartbeatBC;
//LOGP(info, "IDC Procssing orbit/BC: {:9}/{:4}", orbit, bc);
// LOGP(info, "IDC Procssing orbit/BC: {:9}/{:4}", orbit, bc);

auto infoIt = std::find(infoVec.begin(), infoVec.end(), orbit);
if (!infoVec.size()) {
Expand Down Expand Up @@ -188,9 +188,9 @@ class IDCToVectorDevice : public o2::framework::Task
const GlobalPadNumber padInRegion = padInSector - regionPadOffset;
const GlobalPadNumber vectorPosition = padInRegion + idcOffset * numberPads;
// TODO: for debugging, remove later
//auto rawVal = idcs.getChannelValue(iLink, iChannel);
//auto rawValF = idcs.getChannelValueFloat(iLink, iChannel);
//LOGP(info, "filling channel {}, link {}, fecLinkOffsetCRU {:2}, fecSectorOffset {:3}, fecInSector {:3}, idcVec[{} ({})] = {} ({} / {})", iChannel, iLink, fecLinkOffsetCRU, fecSectorOffset, fecInSector, vectorPosition, padInRegion, val, rawVal, rawValF);
// auto rawVal = idcs.getChannelValue(iLink, iChannel);
// auto rawValF = idcs.getChannelValueFloat(iLink, iChannel);
// LOGP(info, "filling channel {}, link {}, fecLinkOffsetCRU {:2}, fecSectorOffset {:3}, fecInSector {:3}, idcVec[{} ({})] = {} ({} / {})", iChannel, iLink, fecLinkOffsetCRU, fecSectorOffset, fecInSector, vectorPosition, padInRegion, val, rawVal, rawValF);
idcVec[vectorPosition] = val;
}
}
Expand Down Expand Up @@ -278,6 +278,7 @@ class IDCToVectorDevice : public o2::framework::Task
for (auto& [cru, idcVec] : mIDCvectors) {
idcVec.resize(Mapper::PADSPERREGION[CRU(cru).region()] * orbitsInTF);
const header::DataHeader::SubSpecificationType subSpec{cru << 7};
LOGP(info, "Sending IDCs for CRU {} of size {}", cru, idcVec.size());
output.snapshot(Output{gDataOriginTPC, "IDCVECTOR", subSpec}, idcVec);
output.snapshot(Output{gDataOriginTPC, "IDCORBITS", subSpec}, orbitBCInfo);
}
Expand Down
6 changes: 4 additions & 2 deletions Detectors/TPC/workflow/src/tpc-factorize-idc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{"nthreads-IDC-factorization", VariantType::Int, 1, {"Number of threads which will be used during the factorization of the IDCs."}},
{"nthreads-grouping", VariantType::Int, 1, {"Number of threads which will be used during the grouping of IDCDelta."}},
{"debug", VariantType::Bool, false, {"create debug files"}},
{"sendOutput", VariantType::Bool, false, {"send IDC0, IDC1, IDCDelta, fourier coefficients (for debugging)"}},
{"sendOutput", VariantType::Bool, false, {"send IDC0, IDCDelta (for debugging)"}},
{"sendOutputFFT", VariantType::Bool, false, {"sending the output for fourier transform device"}},
{"crus", VariantType::String, cruDefault.c_str(), {"List of CRUs, comma separated ranges, e.g. 0-3,7,9-15"}},
{"compression", VariantType::Int, 1, {"compression of DeltaIDC: 0 -> No, 1 -> Medium (data compression ratio 2), 2 -> High (data compression ratio ~6)"}},
{"input-lanes", VariantType::Int, 2, {"Number of parallel pipelines which were set in the TPCDistributeIDCSpec device."}},
Expand Down Expand Up @@ -72,6 +73,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
const auto debug = config.options().get<bool>("debug");
const auto groupIDCs = config.options().get<bool>("groupIDCs");
const auto sendOutput = config.options().get<bool>("sendOutput");
const auto sendOutputFFT = config.options().get<bool>("sendOutputFFT");
const auto nthreadsFactorization = static_cast<unsigned long>(config.options().get<int>("nthreads-IDC-factorization"));
IDCFactorization::setNThreads(nthreadsFactorization);
const auto nthreadsGrouping = static_cast<unsigned long>(config.options().get<int>("nthreads-grouping"));
Expand Down Expand Up @@ -100,7 +102,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
WorkflowSpec workflow;
workflow.reserve(nLanes);
for (int ilane = 0; ilane < nLanes; ++ilane) {
groupIDCs ? workflow.emplace_back(getTPCFactorizeIDCSpec<TPCFactorizeIDCSpecGroup>(ilane, rangeCRUs, timeframes, timeframesDeltaIDC, compression, debug, sendOutput, usePrecisetimeStamp)) : workflow.emplace_back(getTPCFactorizeIDCSpec<TPCFactorizeIDCSpecNoGroup>(ilane, rangeCRUs, timeframes, timeframesDeltaIDC, compression, debug, sendOutput, usePrecisetimeStamp));
groupIDCs ? workflow.emplace_back(getTPCFactorizeIDCSpec<TPCFactorizeIDCSpecGroup>(ilane, rangeCRUs, timeframes, timeframesDeltaIDC, compression, debug, sendOutput, usePrecisetimeStamp, sendOutputFFT)) : workflow.emplace_back(getTPCFactorizeIDCSpec<TPCFactorizeIDCSpecNoGroup>(ilane, rangeCRUs, timeframes, timeframesDeltaIDC, compression, debug, sendOutput, usePrecisetimeStamp, sendOutputFFT));
}
return workflow;
}

0 comments on commit 2cd2924

Please sign in to comment.