From 5ba373243c7bc34705f8fc6853e1e86268b61669 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 5 Apr 2021 15:22:53 +0200 Subject: [PATCH 01/24] First version of MFT calibration : generating noise map and writing in CCDB --- Detectors/ITSMFT/MFT/CMakeLists.txt | 1 + .../ITSMFT/MFT/calibration/CMakeLists.txt | 27 +++ .../include/MFTCalibration/NoiseCalibrator.h | 65 ++++++ .../MFTCalibration/NoiseCalibratorSpec.h | 63 ++++++ .../calibration/src/MFTCalibrationLinkDef.h | 19 ++ .../MFT/calibration/src/NoiseCalibrator.cxx | 94 +++++++++ .../calibration/src/NoiseCalibratorSpec.cxx | 186 ++++++++++++++++++ .../MFT/calibration/testWorkflow/README.md | 18 ++ .../testWorkflow/mft-calib-workflow.cxx | 43 ++++ 9 files changed, 516 insertions(+) create mode 100644 Detectors/ITSMFT/MFT/calibration/CMakeLists.txt create mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h create mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h create mode 100644 Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h create mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx create mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx create mode 100644 Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md create mode 100644 Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx diff --git a/Detectors/ITSMFT/MFT/CMakeLists.txt b/Detectors/ITSMFT/MFT/CMakeLists.txt index 5615d7d3d0381..76ac508305e36 100644 --- a/Detectors/ITSMFT/MFT/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/CMakeLists.txt @@ -13,5 +13,6 @@ add_subdirectory(simulation) add_subdirectory(macros) add_subdirectory(tracking) add_subdirectory(workflow) +add_subdirectory(calibration) o2_data_file(COPY data DESTINATION Detectors/Geometry/MFT/) diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt new file mode 100644 index 0000000000000..bc7ce042ceda1 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright CERN and copyright holders of ALICE O2. This software is distributed +# under the terms of the GNU General Public License v3 (GPL Version 3), copied +# verbatim in the file "COPYING". +# +# See http://alice-o2.web.cern.ch/license for full licensing information. +# +# 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_add_library(MFTCalibration + SOURCES src/NoiseCalibrator.cxx + SOURCES src/NoiseCalibratorSpec.cxx + PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase + O2::DetectorsCalibration + O2::CCDB) + + o2_target_root_dictionary(MFTCalibration + HEADERS include/MFTCalibration/NoiseCalibrator.h + LINKDEF src/MFTCalibrationLinkDef.h) + +o2_add_executable(mft-calib-workflow + COMPONENT_NAME calibration + SOURCES testWorkflow/mft-calib-workflow.cxx + PUBLIC_LINK_LIBRARIES O2::Framework + O2::MFTCalibration) + diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h new file mode 100644 index 0000000000000..0e1893e2e16de --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -0,0 +1,65 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibrator.h + +#ifndef O2_MFT_NOISECALIBRATOR +#define O2_MFT_NOISECALIBRATOR + +#include + +#include "DataFormatsITSMFT/NoiseMap.h" +#include "gsl/span" + +namespace o2 +{ + +namespace itsmft +{ +class CompClusterExt; +class ROFRecord; +} // namespace itsmft + +namespace mft +{ + +class NoiseCalibrator +{ + public: + NoiseCalibrator() = default; + NoiseCalibrator(bool one, float prob) + { + m1pix = one; + mProbabilityThreshold = prob; + } + ~NoiseCalibrator() = default; + + void setThreshold(unsigned int t) { mThreshold = t; } + + bool processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs); + + void finalize(); + + const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } + + private: + o2::itsmft::NoiseMap mNoiseMap{926}; + float mProbabilityThreshold = 3e-6f; + unsigned int mThreshold = 100; + unsigned int mNumberOfStrobes = 0; + bool m1pix = true; +}; + +} // namespace mft +} // namespace o2 + +#endif /* O2_MFT_NOISECALIBRATOR */ diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h new file mode 100644 index 0000000000000..bd431d97962de --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -0,0 +1,63 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorSpec.h + +#ifndef O2_MFT_NOISECALIBRATORSPEC +#define O2_MFT_NOISECALIBRATORSPEC + +#include + +#include "Framework/DataProcessorSpec.h" +#include "Framework/Task.h" + +#include "MFTCalibration/NoiseCalibrator.h" +using CALIBRATOR = o2::mft::NoiseCalibrator; + +#include "DataFormatsITSMFT/NoiseMap.h" + +using namespace o2::framework; + +namespace o2 +{ + +namespace mft +{ + +class NoiseCalibratorSpec : public Task +{ + public: + NoiseCalibratorSpec() = default; + ~NoiseCalibratorSpec() override = default; + + void init(InitContext& ic) final; + void run(ProcessingContext& pc) final; + void endOfStream(EndOfStreamContext& ec) final; + + private: + void sendOutput(DataAllocator& output); + o2::itsmft::NoiseMap mNoiseMap{926}; + std::unique_ptr mCalibrator = nullptr; + std::string mPath; + std::string mMeta; + double mThresh; + int64_t mStart; + int64_t mEnd; + +}; + +/// create a processor spec +/// run MFT noise calibration +DataProcessorSpec getNoiseCalibratorSpec(); + +} // namespace mft +} // namespace o2 + +#endif /* O2_MFT_NOISECALIBRATORSPEC */ diff --git a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h new file mode 100644 index 0000000000000..fa990979fb3e2 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h @@ -0,0 +1,19 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::mft::NoiseCalibrator + ; + +#endif diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx new file mode 100644 index 0000000000000..deabb266e26a4 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx @@ -0,0 +1,94 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibrator.cxx + +#include "MFTCalibration/NoiseCalibrator.h" + +#include "FairLogger.h" +#include "TFile.h" +#include "DataFormatsITSMFT/ClusterPattern.h" +#include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/ROFRecord.h" + +namespace o2 +{ +namespace mft +{ +bool NoiseCalibrator::processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs) +{ + static int nTF = 0; + LOG(INFO) << "Processing TF# " << nTF++; + + auto pattIt = patterns.begin(); + for (const auto& rof : rofs) { + auto clustersInFrame = rof.getROFData(clusters); + for (const auto& c : clustersInFrame) { + if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { + // For the noise calibration, we use "pass1" clusters... + continue; + } + o2::itsmft::ClusterPattern patt(pattIt); + + auto id = c.getSensorID(); + auto row = c.getRow(); + auto col = c.getCol(); + auto colSpan = patt.getColumnSpan(); + auto rowSpan = patt.getRowSpan(); + + // Fast 1-pixel calibration + if ((rowSpan == 1) && (colSpan == 1)) { + mNoiseMap.increaseNoiseCount(id, row, col); + continue; + } + if (m1pix) { + continue; + } + + // All-pixel calibration + auto nBits = rowSpan * colSpan; + int ic = 0, ir = 0; + for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { + unsigned char tempChar = patt.getByte(i); + int s = 128; // 0b10000000 + while (s > 0) { + if ((tempChar & s) != 0) { + mNoiseMap.increaseNoiseCount(id, row + ir, col + ic); + } + ic++; + s >>= 1; + if ((ir + 1) * ic == nBits) { + break; + } + if (ic == colSpan) { + ic = 0; + ir++; + } + } + if ((ir + 1) * ic == nBits) { + break; + } + } + } + } + mNumberOfStrobes += rofs.size(); + return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; +} + +void NoiseCalibrator::finalize() +{ + LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; + mNoiseMap.applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes); +} + +} // namespace mft +} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx new file mode 100644 index 0000000000000..a74394edc507c --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -0,0 +1,186 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorSpec.cxx + +#include "CCDB/CcdbApi.h" +#include "DetectorsCalibration/Utils.h" +#include "MFTCalibration/NoiseCalibratorSpec.h" +#include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/ROFRecord.h" + +#include "FairLogger.h" +#include "Framework/ControlService.h" +#include "Framework/ConfigParamRegistry.h" + +using namespace o2::framework; + +// Remove leading whitespace +std::string ltrimSpace(std::string src) +{ + return src.erase(0, src.find_first_not_of(' ')); +} + +// Remove trailing whitespace +std::string rtrimSpace(std::string src) +{ + return src.erase(src.find_last_not_of(' ') + 1); +} + +// Remove leading/trailing whitespace +std::string trimSpace(std::string const& src) +{ + return ltrimSpace(rtrimSpace(src)); +} + + +std::vector splitString(const std::string& src, char delim, bool trim = false) +{ + std::stringstream ss(src); + std::string token; + std::vector tokens; + + while (std::getline(ss, token, delim)) { + token = (trim ? trimSpace(token) : token); + if (!token.empty()) { + tokens.push_back(std::move(token)); + } + } + + return tokens; +} + +namespace o2 +{ +namespace mft +{ + +void NoiseCalibratorSpec::init(InitContext& ic) +{ + auto onepix = ic.options().get("1pix-only"); + LOG(INFO) << "Fast 1=pixel calibration: " << onepix; + auto probT = ic.options().get("prob-threshold"); + LOG(INFO) << "Setting the probability threshold to " << probT; + + mPath = ic.options().get("path"); + mMeta = ic.options().get("meta"); + mStart = ic.options().get("tstart"); + mEnd = ic.options().get("tend"); + + mCalibrator = std::make_unique(onepix, probT); +} + +void NoiseCalibratorSpec::run(ProcessingContext& pc) +{ + const auto compClusters = pc.inputs().get>("compClusters"); + gsl::span patterns = pc.inputs().get>("patterns"); + const auto rofs = pc.inputs().get>("ROframes"); + + if (mCalibrator->processTimeFrame(compClusters, patterns, rofs)) { + LOG(INFO) << "Minimum number of noise counts has been reached !"; + sendOutput(pc.outputs()); + pc.services().get().readyToQuit(QuitRequest::All); + } +} + +void NoiseCalibratorSpec::sendOutput(DataAllocator& output) +{ + mCalibrator->finalize(); + + const auto& payload = mCalibrator->getNoiseMap(); + + long tstart = mStart; + if (tstart == -1) { + tstart = o2::ccdb::getCurrentTimestamp(); + } + long tend = mEnd; + if (tend == -1) { + constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60; + tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); + } + + auto toKeyValPairs = [](std::vector const& tokens) { + std::vector> pairs; + + for (auto& token : tokens) { + auto keyval = splitString(token, '='); + if (keyval.size() != 2) { + // LOG(FATAL) << "Illegal command-line key/value string: " << token; + continue; + } + + std::pair pair = std::make_pair(keyval[0], trimSpace(keyval[1])); + pairs.push_back(pair); + } + + return pairs; + }; + std::map meta; + auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); + + // fill meta map + for (auto& p : keyvalues) { + meta[p.first] = p.second; + } + + + o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); + auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); + auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); + info.setFileName(flName); + LOG(INFO) << "Sending object " << info.getPath() << "/" << info.getFileName() + << " of size " << image->size() + << " bytes, valid for " << info.getStartValidityTimestamp() + << " : " << info.getEndValidityTimestamp(); + + using clbUtils = o2::calibration::Utils; + output.snapshot( + Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload, 0}, *image.get()); + output.snapshot( + Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo, 0}, info); +} + +void NoiseCalibratorSpec::endOfStream(o2::framework::EndOfStreamContext& ec) +{ + sendOutput(ec.outputs()); +} + +DataProcessorSpec getNoiseCalibratorSpec() +{ + o2::header::DataOrigin detOrig = o2::header::gDataOriginMFT; + std::vector inputs; + inputs.emplace_back("compClusters", detOrig, "COMPCLUSTERS", 0, Lifetime::Timeframe); + inputs.emplace_back("patterns", detOrig, "PATTERNS", 0, Lifetime::Timeframe); + inputs.emplace_back("ROframes", detOrig, "CLUSTERSROF", 0, Lifetime::Timeframe); + + using clbUtils = o2::calibration::Utils; + std::vector outputs; + outputs.emplace_back( + ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload}); + outputs.emplace_back( + ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo}); + + return DataProcessorSpec{ + "mft-noise-calibrator", + inputs, + outputs, + AlgorithmSpec{adaptFromTask()}, + Options{ + {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, + {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, + {"tstart",VariantType::Int64,-1ll,{"Start of validity timestamp"}}, + {"tend",VariantType::Int64,-1ll,{"End of validity timestamp"}}, + {"path", VariantType::String, "/MFT/Calib/NoiseMap",{"Path to write to in CCDB"}}, + {"meta", VariantType::String, "",{"meta data to write in CCDB"}} + }}; +} + +} // namespace mft +} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md new file mode 100644 index 0000000000000..b60c4c9dd8ace --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -0,0 +1,18 @@ + +# MFT calibration workflows + +This will read data from raw data file, produces clusters and write a noise map to a local CCDB running on port 8080: + +```shell +o2-raw-file-reader-workflow -b --delay ${DELAY_S} --nocheck-missing-stop --nocheck-starts-with-tf --nocheck-packet-increment --nocheck-hbf-jump --nocheck-hbf-per-tf --detect-tf0 --configKeyValues "HBFUtils.nHBFPerTF=${HBF_PER_TF}" --input-conf ${CFGFILE} | \ +o2-itsmft-stf-decoder-workflow -b --nthreads ${N_THREAD} --runmft --decoder-verbosity ${DECODER_VERBOSITY} | \ +o2-calibration-mft-calib-workflow --path "/MFT/test_CCDB/" --meta "Description=MFT;Author=Maurice Coquet;Uploader=Maurice Coquet" -b | \ +o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b +``` + +Additional options to the mft-calib DPL : + --path "/path/in/CCDBB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") + --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB + --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) + --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) + --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx new file mode 100644 index 0000000000000..68fc7807e5d31 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -0,0 +1,43 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. + +#include "Framework/ConfigParamSpec.h" +#include "CommonUtils/ConfigurableParam.h" + + +using namespace o2::framework; + +// we need to add workflow options before including Framework/runDataProcessing +void customize(std::vector& workflowOptions) +{ + // option allowing to set parameters + workflowOptions.push_back(ConfigParamSpec{"doNoise",VariantType::Bool,true,{"Generate noisy-pixel maps"}}); +} + +// ------------------------------------------------------------------ + +#include "Framework/runDataProcessing.h" +#include "MFTCalibration/NoiseCalibratorSpec.h" +#include "MFTCalibration/NoiseCalibrator.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec specs; + auto doNoise = cfgc.options().get("doNoise"); + + LOG(INFO) << "ITS calibration workflow options"; + LOG(INFO) << "Generate noisy-pixel maps: " << doNoise; + + if (doNoise) { + specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); + } + + return specs; +} From 5c9b3ab16b8abe06cf20b56ff835eac1729bc1e3 Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Mon, 5 Apr 2021 15:27:34 +0200 Subject: [PATCH 02/24] Update README.md --- Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md index b60c4c9dd8ace..1612e0ddd68f5 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -11,8 +11,10 @@ o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b ``` Additional options to the mft-calib DPL : +``` --path "/path/in/CCDBB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) +``` From 1d3899bf6c9747d013b818bf08d41301e8af90d7 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Apr 2021 19:36:44 +0200 Subject: [PATCH 03/24] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20Detectors/ITSMFT/MFT/calibration/CMakeLists.txt=20=09n?= =?UTF-8?q?ouveau=20fichier=C2=A0:=20Detectors/ITSMFT/MFT/calibration/incl?= =?UTF-8?q?ude/MFTCalibration/NoiseCalibratorDigits.h=20=09nouveau=20fichi?= =?UTF-8?q?er=C2=A0:=20Detectors/ITSMFT/MFT/calibration/include/MFTCalibra?= =?UTF-8?q?tion/NoiseCalibratorDigitsSpec.h=20=09modifi=C3=A9=C2=A0:=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20Detectors/ITSMFT/MFT/calibration/src/MFTCa?= =?UTF-8?q?librationLinkDef.h=20=09nouveau=20fichier=C2=A0:=20Detectors/IT?= =?UTF-8?q?SMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx=20=09nouveau?= =?UTF-8?q?=20fichier=C2=A0:=20Detectors/ITSMFT/MFT/calibration/src/NoiseC?= =?UTF-8?q?alibratorDigitsSpec.cxx=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20Detectors/ITSMFT/MFT/calibration/testWorkflow/READM?= =?UTF-8?q?E.md=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20Detecto?= =?UTF-8?q?rs/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ITSMFT/MFT/calibration/CMakeLists.txt | 3 + .../MFTCalibration/NoiseCalibratorDigits.h | 65 ++++++++ .../NoiseCalibratorDigitsSpec.h | 63 ++++++++ .../calibration/src/MFTCalibrationLinkDef.h | 1 + .../calibration/src/NoiseCalibratorDigits.cxx | 51 ++++++ .../src/NoiseCalibratorDigitsSpec.cxx | 151 ++++++++++++++++++ .../MFT/calibration/testWorkflow/README.md | 6 +- 7 files changed, 336 insertions(+), 4 deletions(-) create mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h create mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h create mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx create mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index bc7ce042ceda1..fd079e99d7c13 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -11,12 +11,15 @@ o2_add_library(MFTCalibration SOURCES src/NoiseCalibrator.cxx SOURCES src/NoiseCalibratorSpec.cxx + SOURCES src/NoiseCalibratorDigits.cxx + SOURCES src/NoiseCalibratorDigitsSpec.cxx PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase O2::DetectorsCalibration O2::CCDB) o2_target_root_dictionary(MFTCalibration HEADERS include/MFTCalibration/NoiseCalibrator.h + HEADERS include/MFTCalibration/NoiseCalibratorDigits.h LINKDEF src/MFTCalibrationLinkDef.h) o2_add_executable(mft-calib-workflow diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h new file mode 100644 index 0000000000000..377f9ee874c80 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h @@ -0,0 +1,65 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorDigits.h + +#ifndef O2_MFT_NOISECALIBRATORDIGITS +#define O2_MFT_NOISECALIBRATORDIGITS + +#include + +#include "DataFormatsITSMFT/NoiseMap.h" +#include "DataFormatsITSMFT/Digit.h" +#include "gsl/span" + +namespace o2 +{ + +namespace itsmft +{ +class CompClusterExt; +class ROFRecord; +} // namespace itsmft + +namespace mft +{ + +class NoiseCalibratorDigits +{ + public: + NoiseCalibratorDigits() = default; + NoiseCalibratorDigits(bool one, float prob) + { + m1pix = one; + mProbabilityThreshold = prob; + } + ~NoiseCalibratorDigits() = default; + + void setThreshold(unsigned int t) { mThreshold = t; } + + bool processTimeFrame(gsl::span const& digits, + gsl::span const& rofs); + + void finalize(); + + const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } + + private: + o2::itsmft::NoiseMap mNoiseMap{926}; + float mProbabilityThreshold = 3e-6f; + unsigned int mThreshold = 100; + unsigned int mNumberOfStrobes = 0; + bool m1pix = true; +}; + +} // namespace mft +} // namespace o2 + +#endif /* O2_MFT_NOISECALIBRATORDIGITS */ diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h new file mode 100644 index 0000000000000..8827c5df6da64 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h @@ -0,0 +1,63 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorDigitsSpec.h + +#ifndef O2_MFT_NOISECALIBRATORDIGITSSPEC +#define O2_MFT_NOISECALIBRATORDIGITSSPEC + +#include + +#include "Framework/DataProcessorSpec.h" +#include "Framework/Task.h" + +#include "MFTCalibration/NoiseCalibratorDigits.h" +using CALIBRATOR = o2::mft::NoiseCalibratorDigits; + +#include "DataFormatsITSMFT/NoiseMap.h" + +using namespace o2::framework; + +namespace o2 +{ + +namespace mft +{ + +class NoiseCalibratorDigitsSpec : public Task +{ + public: + NoiseCalibratorDigitsSpec() = default; + ~NoiseCalibratorDigitsSpec() override = default; + + void init(InitContext& ic) final; + void run(ProcessingContext& pc) final; + void endOfStream(EndOfStreamContext& ec) final; + + private: + void sendOutput(DataAllocator& output); + o2::itsmft::NoiseMap mNoiseMap{926}; + std::unique_ptr mCalibrator = nullptr; + std::string mPath; + std::string mMeta; + double mThresh; + int64_t mStart; + int64_t mEnd; + +}; + +/// create a processor spec +/// run MFT noise calibration +DataProcessorSpec getNoiseCalibratorDigitsSpec(); + +} // namespace mft +} // namespace o2 + +#endif /* O2_MFT_NOISECALIBRATORDIGITSSPEC */ diff --git a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h index fa990979fb3e2..3422379706337 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h +++ b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h @@ -15,5 +15,6 @@ #pragma link off all functions; #pragma link C++ class o2::mft::NoiseCalibrator + ; +#pragma link C++ class o2::mft::NoiseCalibratorDigits + ; #endif diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx new file mode 100644 index 0000000000000..9de6f8fb5f43d --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx @@ -0,0 +1,51 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorDigits.cxx + +#include "MFTCalibration/NoiseCalibratorDigits.h" + +#include "FairLogger.h" +#include "TFile.h" +#include "DataFormatsITSMFT/Digit.h" +#include "DataFormatsITSMFT/ROFRecord.h" + +namespace o2 +{ +namespace mft +{ +bool NoiseCalibratorDigits::processTimeFrame(gsl::span const& digits, + gsl::span const& rofs) +{ + static int nTF = 0; + LOG(INFO) << "Processing TF# " << nTF++; + + for (const auto& rof : rofs) { + auto digitsInFrame = rof.getROFData(digits); + for (const auto& d : digitsInFrame) { + auto id = d.getChipIndex(); + auto row = d.getRow(); + auto col = d.getColumn(); + + mNoiseMap.increaseNoiseCount(id, row, col); + } + } + mNumberOfStrobes += rofs.size(); + return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; +} + +void NoiseCalibratorDigits::finalize() +{ + LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; + mNoiseMap.applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes); +} + +} // namespace mft +} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx new file mode 100644 index 0000000000000..aa9421275128e --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx @@ -0,0 +1,151 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseCalibratorDigitsSpec.cxx + +#include "CCDB/CcdbApi.h" +#include "DetectorsCalibration/Utils.h" +#include "MFTCalibration/NoiseCalibratorDigitsSpec.h" +#include "DataFormatsITSMFT/ROFRecord.h" +#include "DataFormatsITSMFT/Digit.h" + +#include "FairLogger.h" +#include "Framework/ControlService.h" +#include "Framework/ConfigParamRegistry.h" + +using namespace o2::framework; + +namespace o2 +{ +namespace mft +{ + +void NoiseCalibratorDigitsSpec::init(InitContext& ic) +{ + auto onepix = ic.options().get("1pix-only"); + LOG(INFO) << "Fast 1=pixel calibration: " << onepix; + auto probT = ic.options().get("prob-threshold"); + LOG(INFO) << "Setting the probability threshold to " << probT; + + mPath = ic.options().get("path"); + mMeta = ic.options().get("meta"); + mStart = ic.options().get("tstart"); + mEnd = ic.options().get("tend"); + + mCalibrator = std::make_unique(onepix, probT); +} + +void NoiseCalibratorDigitsSpec::run(ProcessingContext& pc) +{ + const auto digits = pc.inputs().get>("digits"); + const auto rofs = pc.inputs().get>("digitsROF"); + + + if (mCalibrator->processTimeFrame(digits, rofs)) { + LOG(INFO) << "Minimum number of noise counts has been reached !"; + sendOutput(pc.outputs()); + pc.services().get().readyToQuit(QuitRequest::All); + } +} + +void NoiseCalibratorDigitsSpec::sendOutput(DataAllocator& output) +{ + mCalibrator->finalize(); + + const auto& payload = mCalibrator->getNoiseMap(); + + long tstart = mStart; + if (tstart == -1) { + tstart = o2::ccdb::getCurrentTimestamp(); + } + long tend = mEnd; + if (tend == -1) { + constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60; + tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); + } + + auto toKeyValPairs = [](std::vector const& tokens) { + std::vector> pairs; + + for (auto& token : tokens) { + auto keyval = splitString(token, '='); + if (keyval.size() != 2) { + // LOG(FATAL) << "Illegal command-line key/value string: " << token; + continue; + } + + std::pair pair = std::make_pair(keyval[0], trimSpace(keyval[1])); + pairs.push_back(pair); + } + + return pairs; + }; + std::map meta; + auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); + + // fill meta map + for (auto& p : keyvalues) { + meta[p.first] = p.second; + } + + + o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); + auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); + auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); + info.setFileName(flName); + LOG(INFO) << "Sending object " << info.getPath() << "/" << info.getFileName() + << " of size " << image->size() + << " bytes, valid for " << info.getStartValidityTimestamp() + << " : " << info.getEndValidityTimestamp(); + + using clbUtils = o2::calibration::Utils; + output.snapshot( + Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload, 0}, *image.get()); + output.snapshot( + Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo, 0}, info); +} + +void NoiseCalibratorDigitsSpec::endOfStream(o2::framework::EndOfStreamContext& ec) +{ + sendOutput(ec.outputs()); +} + +DataProcessorSpec getNoiseCalibratorDigitsSpec() +{ + o2::header::DataOrigin detOrig = o2::header::gDataOriginMFT; + std::vector inputs; + inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); + inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); + + + using clbUtils = o2::calibration::Utils; + std::vector outputs; + outputs.emplace_back( + ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload}); + outputs.emplace_back( + ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo}); + + return DataProcessorSpec{ + "mft-noise-calibrator", + inputs, + outputs, + AlgorithmSpec{adaptFromTask()}, + Options{ + {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, + {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, + {"tstart",VariantType::Int64,-1ll,{"Start of validity timestamp"}}, + {"tend",VariantType::Int64,-1ll,{"End of validity timestamp"}}, + {"path", VariantType::String, "/MFT/Calib/NoiseMap",{"Path to write to in CCDB"}}, + {"meta", VariantType::String, "",{"meta data to write in CCDB"}} + }}; +} + +} // namespace mft +} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md index 1612e0ddd68f5..573c34d158b85 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -11,10 +11,8 @@ o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b ``` Additional options to the mft-calib DPL : -``` - --path "/path/in/CCDBB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") + --path "/path/in/CCDB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) - --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) + --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) -``` From 62ac66b1993cb02b9257e8596aa5d9dfa2c45b93 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Apr 2021 19:37:49 +0200 Subject: [PATCH 04/24] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-cali?= =?UTF-8?q?b-workflow.cxx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calibration/testWorkflow/mft-calib-workflow.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx index 68fc7807e5d31..3aee240dfd5f4 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -18,7 +18,7 @@ using namespace o2::framework; void customize(std::vector& workflowOptions) { // option allowing to set parameters - workflowOptions.push_back(ConfigParamSpec{"doNoise",VariantType::Bool,true,{"Generate noisy-pixel maps"}}); + workflowOptions.push_back(ConfigParamSpec{"useDigits",VariantType::Bool,false,{"Use decoded digits"}}); } // ------------------------------------------------------------------ @@ -26,16 +26,20 @@ void customize(std::vector& workflowOptions) #include "Framework/runDataProcessing.h" #include "MFTCalibration/NoiseCalibratorSpec.h" #include "MFTCalibration/NoiseCalibrator.h" +#include "MFTCalibration/NoiseCalibratorDigitsSpec.h" +#include "MFTCalibration/NoiseCalibratorDigits.h" WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec specs; - auto doNoise = cfgc.options().get("doNoise"); + auto useDigits = cfgc.options().get("useDigits"); - LOG(INFO) << "ITS calibration workflow options"; + LOG(INFO) << "MFT calibration workflow options"; LOG(INFO) << "Generate noisy-pixel maps: " << doNoise; - if (doNoise) { + if (useDigits) { + specs.emplace_back(o2::mft::getNoiseCalibratorDigitsSpec()); + }else{ specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); } From e48d8a9942af1992db40e736d3ad2b99d85d16da Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Apr 2021 22:54:26 +0200 Subject: [PATCH 05/24] Implementation of noise calibration DPL using digits --- .../NoiseCalibratorDigitsSpec.h | 4 +- .../src/NoiseCalibratorDigitsSpec.cxx | 42 +++++++++++++++++-- .../MFT/calibration/testWorkflow/README.md | 7 ++++ .../testWorkflow/mft-calib-workflow.cxx | 2 +- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h index 8827c5df6da64..85a039f7f3b5c 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h @@ -19,7 +19,7 @@ #include "Framework/Task.h" #include "MFTCalibration/NoiseCalibratorDigits.h" -using CALIBRATOR = o2::mft::NoiseCalibratorDigits; +using CALIBRATORDIGITS = o2::mft::NoiseCalibratorDigits; #include "DataFormatsITSMFT/NoiseMap.h" @@ -44,7 +44,7 @@ class NoiseCalibratorDigitsSpec : public Task private: void sendOutput(DataAllocator& output); o2::itsmft::NoiseMap mNoiseMap{926}; - std::unique_ptr mCalibrator = nullptr; + std::unique_ptr mCalibrator = nullptr; std::string mPath; std::string mMeta; double mThresh; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx index aa9421275128e..1258f349f8a1c 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx @@ -27,6 +27,40 @@ namespace o2 namespace mft { +// Remove leading whitespace +std::string ltrimSpaceStream(std::string src) +{ + return src.erase(0, src.find_first_not_of(' ')); +} + +// Remove trailing whitespace +std::string rtrimSpaceStream(std::string src) +{ + return src.erase(src.find_last_not_of(' ') + 1); +} + +// Remove leading/trailing whitespace +std::string trimSpaceStream(std::string const& src) +{ + return ltrimSpaceStream(rtrimSpaceStream(src)); +} + + +std::vector splitStringStream(const std::string& src, char delim, bool trim = false) +{ + std::stringstream ss(src); + std::string token; + std::vector tokens; + + while (std::getline(ss, token, delim)) { + token = (trim ? trimSpaceStream(token) : token); + if (!token.empty()) { + tokens.push_back(std::move(token)); + } + } + + return tokens; +} void NoiseCalibratorDigitsSpec::init(InitContext& ic) { auto onepix = ic.options().get("1pix-only"); @@ -39,7 +73,7 @@ void NoiseCalibratorDigitsSpec::init(InitContext& ic) mStart = ic.options().get("tstart"); mEnd = ic.options().get("tend"); - mCalibrator = std::make_unique(onepix, probT); + mCalibrator = std::make_unique(onepix, probT); } void NoiseCalibratorDigitsSpec::run(ProcessingContext& pc) @@ -75,20 +109,20 @@ void NoiseCalibratorDigitsSpec::sendOutput(DataAllocator& output) std::vector> pairs; for (auto& token : tokens) { - auto keyval = splitString(token, '='); + auto keyval = splitStringStream(token, '='); if (keyval.size() != 2) { // LOG(FATAL) << "Illegal command-line key/value string: " << token; continue; } - std::pair pair = std::make_pair(keyval[0], trimSpace(keyval[1])); + std::pair pair = std::make_pair(keyval[0], trimSpaceStream(keyval[1])); pairs.push_back(pair); } return pairs; }; std::map meta; - auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); + auto keyvalues = toKeyValPairs(splitStringStream(mMeta, ';', true)); // fill meta map for (auto& p : keyvalues) { diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md index 573c34d158b85..8ff025b312bdc 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -9,6 +9,13 @@ o2-itsmft-stf-decoder-workflow -b --nthreads ${N_THREAD} --runmft --decoder-verb o2-calibration-mft-calib-workflow --path "/MFT/test_CCDB/" --meta "Description=MFT;Author=Maurice Coquet;Uploader=Maurice Coquet" -b | \ o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b ``` +The same as before but uses digits instead of clusters: +```shell +o2-raw-file-reader-workflow -b --delay ${DELAY_S} --nocheck-missing-stop --nocheck-starts-with-tf --nocheck-packet-increment --nocheck-hbf-jump --nocheck-hbf-per-tf --detect-tf0 --configKeyValues "HBFUtils.nHBFPerTF=${HBF_PER_TF}" --input-conf ${CFGFILE} | \ +o2-itsmft-stf-decoder-workflow -b --nthreads ${N_THREAD} --runmft --digits --no-clusters --no-cluster-patterns --decoder-verbosity ${DECODER_VERBOSITY} | \ +o2-calibration-mft-calib-workflow --useDigits --path "/MFT/test_CCDB/" --meta "Description=MFT;Author=Maurice Coquet;Uploader=Maurice Coquet" -b | \ +o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b +``` Additional options to the mft-calib DPL : --path "/path/in/CCDB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx index 3aee240dfd5f4..7a16ce598a42e 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -35,7 +35,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) auto useDigits = cfgc.options().get("useDigits"); LOG(INFO) << "MFT calibration workflow options"; - LOG(INFO) << "Generate noisy-pixel maps: " << doNoise; + LOG(INFO) << "Use Digits: " << useDigits; if (useDigits) { specs.emplace_back(o2::mft::getNoiseCalibratorDigitsSpec()); From eee7e85d433204653c5b81746133d86b80ebd0d1 Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Fri, 9 Apr 2021 22:56:50 +0200 Subject: [PATCH 06/24] Update README.md --- Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md index 8ff025b312bdc..ec84eb056209f 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -18,8 +18,10 @@ o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b ``` Additional options to the mft-calib DPL : +``` --path "/path/in/CCDB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) +``` From bec5f130d071dac27d06dc5781c1ff72446f382f Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 19 Apr 2021 10:46:20 +0200 Subject: [PATCH 07/24] TimeSlot calibration --- .../ITSMFT/MFT/calibration/CMakeLists.txt | 10 +- .../MFTCalibration/NoiseCalibratorSpec.h | 10 +- .../MFTCalibration/NoiseSlotCalibrator.h | 90 +++++++++++++ .../calibration/src/MFTCalibrationLinkDef.h | 2 + .../calibration/src/NoiseCalibratorSpec.cxx | 8 +- .../calibration/src/NoiseSlotCalibrator.cxx | 122 ++++++++++++++++++ 6 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h create mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index fd079e99d7c13..b4462114b5041 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -10,6 +10,7 @@ o2_add_library(MFTCalibration SOURCES src/NoiseCalibrator.cxx + SOURCES src/NoiseSlotCalibrator.cxx SOURCES src/NoiseCalibratorSpec.cxx SOURCES src/NoiseCalibratorDigits.cxx SOURCES src/NoiseCalibratorDigitsSpec.cxx @@ -17,10 +18,11 @@ o2_add_library(MFTCalibration O2::DetectorsCalibration O2::CCDB) - o2_target_root_dictionary(MFTCalibration - HEADERS include/MFTCalibration/NoiseCalibrator.h - HEADERS include/MFTCalibration/NoiseCalibratorDigits.h - LINKDEF src/MFTCalibrationLinkDef.h) +o2_target_root_dictionary(MFTCalibration + HEADERS include/ITSCalibration/NoiseSlotCalibrator.h + HEADERS include/MFTCalibration/NoiseCalibrator.h + HEADERS include/MFTCalibration/NoiseCalibratorDigits.h + LINKDEF src/MFTCalibrationLinkDef.h) o2_add_executable(mft-calib-workflow COMPONENT_NAME calibration diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index bd431d97962de..dce6624b95ed1 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -18,8 +18,14 @@ #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" -#include "MFTCalibration/NoiseCalibrator.h" -using CALIBRATOR = o2::mft::NoiseCalibrator; +//#define TIME_SLOT_CALIBRATION +#ifdef TIME_SLOT_CALIBRATION +#include "ITSCalibration/NoiseSlotCalibrator.h" +using CALIBRATOR = o2::its::NoiseSlotCalibrator; +#else +#include "ITSCalibration/NoiseCalibrator.h" +using CALIBRATOR = o2::its::NoiseCalibrator; +#endif #include "DataFormatsITSMFT/NoiseMap.h" diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h new file mode 100644 index 0000000000000..2fe2173ed23c3 --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -0,0 +1,90 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseSlotCalibrator.h + +#ifndef O2_MFT_NOISESLOTCALIBRATOR +#define O2_MFT_NOISESLOTCALIBRATOR + +#include + +#include "DetectorsCalibration/TimeSlotCalibration.h" +#include "DetectorsCalibration/TimeSlot.h" + +#include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/NoiseMap.h" +#include "gsl/span" + +namespace o2 +{ + +namespace itsmft +{ +class ROFRecord; +} // namespace itsmft + +namespace mft +{ + +class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration +{ + using Slot = calibration::TimeSlot; + + public: + NoiseSlotCalibrator() { setUpdateAtTheEndOfRunOnly(); } + NoiseSlotCalibrator(bool one, float prob) + { + m1pix = one; + mProbabilityThreshold = prob; + setUpdateAtTheEndOfRunOnly(); + } + ~NoiseSlotCalibrator() final = default; + + void setThreshold(unsigned int t) { mThreshold = t; } + + bool processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs); + + void finalize() + { + LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; + auto& slot = getSlots().back(); + slot.getContainer()->applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes); + } + + const o2::itsmft::NoiseMap& getNoiseMap(long& start, long& end) + { + const auto& slot = getSlots().back(); + start = slot.getTFStart(); + end = slot.getTFEnd(); + return *(slot.getContainer()); + } + + // Functions overloaded from the calibration framework + bool process(calibration::TFType tf, const gsl::span data) final; + + // Functions required by the calibration framework + void initOutput() final {} + Slot& emplaceNewSlot(bool, calibration::TFType, calibration::TFType) final; + void finalizeSlot(Slot& slot) final; + bool hasEnoughData(const Slot& slot) const final; + + private: + float mProbabilityThreshold = 3e-6f; + unsigned int mThreshold = 100; + unsigned int mNumberOfStrobes = 0; + bool m1pix = true; +}; + +} // namespace mft +} // namespace o2 + +#endif /* O2_MFT_NOISESLOTCALIBRATOR */ diff --git a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h index 3422379706337..1e677f7f70cad 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h +++ b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h @@ -14,6 +14,8 @@ #pragma link off all classes; #pragma link off all functions; +#pragma link C++ class o2::calibration::TimeSlot < o2::itsmft::CompClusterExt > +; +#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::itsmft::CompClusterExt, o2::itsmft::NoiseMap > +; #pragma link C++ class o2::mft::NoiseCalibrator + ; #pragma link C++ class o2::mft::NoiseCalibratorDigits + ; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index a74394edc507c..e021aec4d61d3 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -94,8 +94,6 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) { mCalibrator->finalize(); - const auto& payload = mCalibrator->getNoiseMap(); - long tstart = mStart; if (tstart == -1) { tstart = o2::ccdb::getCurrentTimestamp(); @@ -131,6 +129,12 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) } +#ifdef TIME_SLOT_CALIBRATION + const auto& payload = mCalibrator->getNoiseMap(tstart, tend); +#else + const auto& payload = mCalibrator->getNoiseMap(); +#endif + o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx new file mode 100644 index 0000000000000..2fe9fb0d450ce --- /dev/null +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -0,0 +1,122 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 NoiseSlotCalibrator.cxx + +#include "MFTCalibration/NoiseSlotCalibrator.h" + +#include "FairLogger.h" +#include "TFile.h" +#include "DataFormatsITSMFT/ClusterPattern.h" +#include "DataFormatsITSMFT/ROFRecord.h" + +namespace o2 +{ +using Slot = calibration::TimeSlot; + +namespace mft +{ +bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs) +{ + calibration::TFType nTF = rofs[0].getBCData().orbit / 256; + LOG(INFO) << "Processing TF# " << nTF; + + auto& slotTF = getSlotForTF(nTF); + auto& noiseMap = *(slotTF.getContainer()); + + auto pattIt = patterns.begin(); + for (const auto& rof : rofs) { + auto clustersInFrame = rof.getROFData(clusters); + for (const auto& c : clustersInFrame) { + if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { + // For the noise calibration, we use "pass1" clusters... + continue; + } + o2::itsmft::ClusterPattern patt(pattIt); + + auto id = c.getSensorID(); + auto row = c.getRow(); + auto col = c.getCol(); + auto colSpan = patt.getColumnSpan(); + auto rowSpan = patt.getRowSpan(); + + // Fast 1-pixel calibration + if ((rowSpan == 1) && (colSpan == 1)) { + noiseMap.increaseNoiseCount(id, row, col); + continue; + } + if (m1pix) { + continue; + } + + // All-pixel calibration + auto nBits = rowSpan * colSpan; + int ic = 0, ir = 0; + for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { + unsigned char tempChar = patt.getByte(i); + int s = 128; // 0b10000000 + while (s > 0) { + if ((tempChar & s) != 0) { + noiseMap.increaseNoiseCount(id, row + ir, col + ic); + } + ic++; + s >>= 1; + if ((ir + 1) * ic == nBits) { + break; + } + if (ic == colSpan) { + ic = 0; + ir++; + } + } + if ((ir + 1) * ic == nBits) { + break; + } + } + } + } + + mNumberOfStrobes += rofs.size(); + return hasEnoughData(slotTF); +} + +// Functions overloaded from the calibration framework +bool NoiseSlotCalibrator::process(calibration::TFType tf, const gsl::span data) +{ + LOG(WARNING) << "Only 1-pix noise calibraton is possible !"; + return calibration::TimeSlotCalibration::process(tf, data); +} + +// Functions required by the calibration framework + +Slot& NoiseSlotCalibrator::emplaceNewSlot(bool front, calibration::TFType tstart, calibration::TFType tend) +{ + auto& cont = getSlots(); + auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend); + slot.setContainer(std::make_unique(926)); + return slot; +} + +bool NoiseSlotCalibrator::hasEnoughData(const Slot&) const +{ + return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; +} + +void NoiseSlotCalibrator::finalizeSlot(Slot& slot) +{ + LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; + o2::itsmft::NoiseMap* map = slot.getContainer(); + map->applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes); +} + +} // namespace mft +} // namespace o2 From 941570765c7bbb58657c821276f27c119df9a752 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 19 Apr 2021 10:52:32 +0200 Subject: [PATCH 08/24] Clang format --- .../MFTCalibration/NoiseCalibratorDigitsSpec.h | 1 - .../include/MFTCalibration/NoiseCalibratorSpec.h | 1 - .../MFT/calibration/src/MFTCalibrationLinkDef.h | 4 ++-- .../MFT/calibration/src/NoiseCalibratorDigits.cxx | 2 +- .../calibration/src/NoiseCalibratorDigitsSpec.cxx | 15 +++++---------- .../MFT/calibration/src/NoiseCalibratorSpec.cxx | 13 +++++-------- .../testWorkflow/mft-calib-workflow.cxx | 5 ++--- 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h index 85a039f7f3b5c..587972001dd12 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h @@ -50,7 +50,6 @@ class NoiseCalibratorDigitsSpec : public Task double mThresh; int64_t mStart; int64_t mEnd; - }; /// create a processor spec diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index dce6624b95ed1..a82e33aa65cd0 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -56,7 +56,6 @@ class NoiseCalibratorSpec : public Task double mThresh; int64_t mStart; int64_t mEnd; - }; /// create a processor spec diff --git a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h index 1e677f7f70cad..02965af4f36b2 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h +++ b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h @@ -14,8 +14,8 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::calibration::TimeSlot < o2::itsmft::CompClusterExt > +; -#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::itsmft::CompClusterExt, o2::itsmft::NoiseMap > +; +#pragma link C++ class o2::calibration::TimeSlot < o2::itsmft::CompClusterExt> + ; +#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::itsmft::CompClusterExt, o2::itsmft::NoiseMap> + ; #pragma link C++ class o2::mft::NoiseCalibrator + ; #pragma link C++ class o2::mft::NoiseCalibratorDigits + ; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx index 9de6f8fb5f43d..9701e3e6c6717 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx @@ -22,7 +22,7 @@ namespace o2 namespace mft { bool NoiseCalibratorDigits::processTimeFrame(gsl::span const& digits, - gsl::span const& rofs) + gsl::span const& rofs) { static int nTF = 0; LOG(INFO) << "Processing TF# " << nTF++; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx index 1258f349f8a1c..14ea7e40cc7d3 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx @@ -45,7 +45,6 @@ std::string trimSpaceStream(std::string const& src) return ltrimSpaceStream(rtrimSpaceStream(src)); } - std::vector splitStringStream(const std::string& src, char delim, bool trim = false) { std::stringstream ss(src); @@ -81,7 +80,6 @@ void NoiseCalibratorDigitsSpec::run(ProcessingContext& pc) const auto digits = pc.inputs().get>("digits"); const auto rofs = pc.inputs().get>("digitsROF"); - if (mCalibrator->processTimeFrame(digits, rofs)) { LOG(INFO) << "Minimum number of noise counts has been reached !"; sendOutput(pc.outputs()); @@ -105,7 +103,7 @@ void NoiseCalibratorDigitsSpec::sendOutput(DataAllocator& output) tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); } - auto toKeyValPairs = [](std::vector const& tokens) { + auto toKeyValPairs = [](std::vector const& tokens) { std::vector> pairs; for (auto& token : tokens) { @@ -129,7 +127,6 @@ void NoiseCalibratorDigitsSpec::sendOutput(DataAllocator& output) meta[p.first] = p.second; } - o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); @@ -158,7 +155,6 @@ DataProcessorSpec getNoiseCalibratorDigitsSpec() inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); - using clbUtils = o2::calibration::Utils; std::vector outputs; outputs.emplace_back( @@ -174,11 +170,10 @@ DataProcessorSpec getNoiseCalibratorDigitsSpec() Options{ {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, - {"tstart",VariantType::Int64,-1ll,{"Start of validity timestamp"}}, - {"tend",VariantType::Int64,-1ll,{"End of validity timestamp"}}, - {"path", VariantType::String, "/MFT/Calib/NoiseMap",{"Path to write to in CCDB"}}, - {"meta", VariantType::String, "",{"meta data to write in CCDB"}} - }}; + {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, + {"tend", VariantType::Int64, -1ll, {"End of validity timestamp"}}, + {"path", VariantType::String, "/MFT/Calib/NoiseMap", {"Path to write to in CCDB"}}, + {"meta", VariantType::String, "", {"meta data to write in CCDB"}}}}; } } // namespace mft diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index e021aec4d61d3..c8285e1be0ee7 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -40,7 +40,6 @@ std::string trimSpace(std::string const& src) return ltrimSpace(rtrimSpace(src)); } - std::vector splitString(const std::string& src, char delim, bool trim = false) { std::stringstream ss(src); @@ -104,7 +103,7 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); } - auto toKeyValPairs = [](std::vector const& tokens) { + auto toKeyValPairs = [](std::vector const& tokens) { std::vector> pairs; for (auto& token : tokens) { @@ -128,7 +127,6 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) meta[p.first] = p.second; } - #ifdef TIME_SLOT_CALIBRATION const auto& payload = mCalibrator->getNoiseMap(tstart, tend); #else @@ -179,11 +177,10 @@ DataProcessorSpec getNoiseCalibratorSpec() Options{ {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, - {"tstart",VariantType::Int64,-1ll,{"Start of validity timestamp"}}, - {"tend",VariantType::Int64,-1ll,{"End of validity timestamp"}}, - {"path", VariantType::String, "/MFT/Calib/NoiseMap",{"Path to write to in CCDB"}}, - {"meta", VariantType::String, "",{"meta data to write in CCDB"}} - }}; + {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, + {"tend", VariantType::Int64, -1ll, {"End of validity timestamp"}}, + {"path", VariantType::String, "/MFT/Calib/NoiseMap", {"Path to write to in CCDB"}}, + {"meta", VariantType::String, "", {"meta data to write in CCDB"}}}}; } } // namespace mft diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx index 7a16ce598a42e..97b4989e44a3c 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -11,14 +11,13 @@ #include "Framework/ConfigParamSpec.h" #include "CommonUtils/ConfigurableParam.h" - using namespace o2::framework; // we need to add workflow options before including Framework/runDataProcessing void customize(std::vector& workflowOptions) { // option allowing to set parameters - workflowOptions.push_back(ConfigParamSpec{"useDigits",VariantType::Bool,false,{"Use decoded digits"}}); + workflowOptions.push_back(ConfigParamSpec{"useDigits", VariantType::Bool, false, {"Use decoded digits"}}); } // ------------------------------------------------------------------ @@ -39,7 +38,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) if (useDigits) { specs.emplace_back(o2::mft::getNoiseCalibratorDigitsSpec()); - }else{ + } else { specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); } From 79fdaed0edd4d19c3ad2bd0d2460b311788643fc Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:35:33 +0200 Subject: [PATCH 09/24] Fix typo --- Detectors/ITSMFT/MFT/calibration/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index b4462114b5041..43589ecc46e27 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -19,7 +19,7 @@ o2_add_library(MFTCalibration O2::CCDB) o2_target_root_dictionary(MFTCalibration - HEADERS include/ITSCalibration/NoiseSlotCalibrator.h + HEADERS include/MFTCalibration/NoiseSlotCalibrator.h HEADERS include/MFTCalibration/NoiseCalibrator.h HEADERS include/MFTCalibration/NoiseCalibratorDigits.h LINKDEF src/MFTCalibrationLinkDef.h) From 3e1d144bc98ca9310844927a8cc06c4b664b1dfb Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Mon, 19 Apr 2021 13:41:59 +0200 Subject: [PATCH 10/24] Fix typo --- .../calibration/include/MFTCalibration/NoiseCalibratorSpec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index a82e33aa65cd0..bbdcf04789dcc 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -20,10 +20,10 @@ //#define TIME_SLOT_CALIBRATION #ifdef TIME_SLOT_CALIBRATION -#include "ITSCalibration/NoiseSlotCalibrator.h" +#include "MFTCalibration/NoiseSlotCalibrator.h" using CALIBRATOR = o2::its::NoiseSlotCalibrator; #else -#include "ITSCalibration/NoiseCalibrator.h" +#include "MFTCalibration/NoiseCalibrator.h" using CALIBRATOR = o2::its::NoiseCalibrator; #endif From 1f95842deae62ab3fa68fd989bfad179a3a0a786 Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Mon, 19 Apr 2021 13:49:20 +0200 Subject: [PATCH 11/24] Fix typo --- .../calibration/include/MFTCalibration/NoiseCalibratorSpec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index bbdcf04789dcc..13689b5a1a0e6 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -21,10 +21,10 @@ //#define TIME_SLOT_CALIBRATION #ifdef TIME_SLOT_CALIBRATION #include "MFTCalibration/NoiseSlotCalibrator.h" -using CALIBRATOR = o2::its::NoiseSlotCalibrator; +using CALIBRATOR = o2::mft::NoiseSlotCalibrator; #else #include "MFTCalibration/NoiseCalibrator.h" -using CALIBRATOR = o2::its::NoiseCalibrator; +using CALIBRATOR = o2::mft::NoiseCalibrator; #endif #include "DataFormatsITSMFT/NoiseMap.h" From 99e538a27ea488715e18433b05845fdd27674051 Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:25:12 +0200 Subject: [PATCH 12/24] Update NoiseCalibrator.h --- .../MFT/calibration/include/MFTCalibration/NoiseCalibrator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h index 0e1893e2e16de..d30d588abe959 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -52,7 +52,7 @@ class NoiseCalibrator const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } private: - o2::itsmft::NoiseMap mNoiseMap{926}; + o2::itsmft::NoiseMap mNoiseMap{936}; float mProbabilityThreshold = 3e-6f; unsigned int mThreshold = 100; unsigned int mNumberOfStrobes = 0; From 8643ee55e03b18441e36061b6aaddded60a2827d Mon Sep 17 00:00:00 2001 From: mcoquet642 <74600025+mcoquet642@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:26:01 +0200 Subject: [PATCH 13/24] Update NoiseCalibratorDigits.h --- .../calibration/include/MFTCalibration/NoiseCalibratorDigits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h index 377f9ee874c80..bbbec5bbd380d 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h @@ -52,7 +52,7 @@ class NoiseCalibratorDigits const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } private: - o2::itsmft::NoiseMap mNoiseMap{926}; + o2::itsmft::NoiseMap mNoiseMap{936}; float mProbabilityThreshold = 3e-6f; unsigned int mThreshold = 100; unsigned int mNumberOfStrobes = 0; From e7e6eb596d35aff85561be44f708f89f6d204854 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 6 May 2021 16:31:02 +0200 Subject: [PATCH 14/24] Updating TimeSolt implementation --- .../ITSMFT/MFT/calibration/CMakeLists.txt | 3 - .../include/MFTCalibration/NoiseCalibrator.h | 5 +- .../MFTCalibration/NoiseCalibratorDigits.h | 65 ------- .../NoiseCalibratorDigitsSpec.h | 62 ------ .../MFTCalibration/NoiseCalibratorSpec.h | 4 +- .../MFTCalibration/NoiseSlotCalibrator.h | 7 +- .../calibration/src/MFTCalibrationLinkDef.h | 2 +- .../MFT/calibration/src/NoiseCalibrator.cxx | 58 +----- .../calibration/src/NoiseCalibratorDigits.cxx | 51 ----- .../src/NoiseCalibratorDigitsSpec.cxx | 180 ------------------ .../calibration/src/NoiseCalibratorSpec.cxx | 25 +-- .../calibration/src/NoiseSlotCalibrator.cxx | 64 ++----- .../testWorkflow/mft-calib-workflow.cxx | 13 +- 13 files changed, 44 insertions(+), 495 deletions(-) delete mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h delete mode 100644 Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h delete mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx delete mode 100644 Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index 43589ecc46e27..1584948fcf500 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -12,8 +12,6 @@ o2_add_library(MFTCalibration SOURCES src/NoiseCalibrator.cxx SOURCES src/NoiseSlotCalibrator.cxx SOURCES src/NoiseCalibratorSpec.cxx - SOURCES src/NoiseCalibratorDigits.cxx - SOURCES src/NoiseCalibratorDigitsSpec.cxx PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase O2::DetectorsCalibration O2::CCDB) @@ -21,7 +19,6 @@ o2_add_library(MFTCalibration o2_target_root_dictionary(MFTCalibration HEADERS include/MFTCalibration/NoiseSlotCalibrator.h HEADERS include/MFTCalibration/NoiseCalibrator.h - HEADERS include/MFTCalibration/NoiseCalibratorDigits.h LINKDEF src/MFTCalibrationLinkDef.h) o2_add_executable(mft-calib-workflow diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h index d30d588abe959..0944573a036e1 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -23,7 +23,7 @@ namespace o2 namespace itsmft { -class CompClusterExt; +class Digit; class ROFRecord; } // namespace itsmft @@ -43,8 +43,7 @@ class NoiseCalibrator void setThreshold(unsigned int t) { mThreshold = t; } - bool processTimeFrame(gsl::span const& clusters, - gsl::span const& patterns, + bool processTimeFrame(gsl::span const& digits, gsl::span const& rofs); void finalize(); diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h deleted file mode 100644 index bbbec5bbd380d..0000000000000 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigits.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// 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 NoiseCalibratorDigits.h - -#ifndef O2_MFT_NOISECALIBRATORDIGITS -#define O2_MFT_NOISECALIBRATORDIGITS - -#include - -#include "DataFormatsITSMFT/NoiseMap.h" -#include "DataFormatsITSMFT/Digit.h" -#include "gsl/span" - -namespace o2 -{ - -namespace itsmft -{ -class CompClusterExt; -class ROFRecord; -} // namespace itsmft - -namespace mft -{ - -class NoiseCalibratorDigits -{ - public: - NoiseCalibratorDigits() = default; - NoiseCalibratorDigits(bool one, float prob) - { - m1pix = one; - mProbabilityThreshold = prob; - } - ~NoiseCalibratorDigits() = default; - - void setThreshold(unsigned int t) { mThreshold = t; } - - bool processTimeFrame(gsl::span const& digits, - gsl::span const& rofs); - - void finalize(); - - const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } - - private: - o2::itsmft::NoiseMap mNoiseMap{936}; - float mProbabilityThreshold = 3e-6f; - unsigned int mThreshold = 100; - unsigned int mNumberOfStrobes = 0; - bool m1pix = true; -}; - -} // namespace mft -} // namespace o2 - -#endif /* O2_MFT_NOISECALIBRATORDIGITS */ diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h deleted file mode 100644 index 587972001dd12..0000000000000 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorDigitsSpec.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// 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 NoiseCalibratorDigitsSpec.h - -#ifndef O2_MFT_NOISECALIBRATORDIGITSSPEC -#define O2_MFT_NOISECALIBRATORDIGITSSPEC - -#include - -#include "Framework/DataProcessorSpec.h" -#include "Framework/Task.h" - -#include "MFTCalibration/NoiseCalibratorDigits.h" -using CALIBRATORDIGITS = o2::mft::NoiseCalibratorDigits; - -#include "DataFormatsITSMFT/NoiseMap.h" - -using namespace o2::framework; - -namespace o2 -{ - -namespace mft -{ - -class NoiseCalibratorDigitsSpec : public Task -{ - public: - NoiseCalibratorDigitsSpec() = default; - ~NoiseCalibratorDigitsSpec() override = default; - - void init(InitContext& ic) final; - void run(ProcessingContext& pc) final; - void endOfStream(EndOfStreamContext& ec) final; - - private: - void sendOutput(DataAllocator& output); - o2::itsmft::NoiseMap mNoiseMap{926}; - std::unique_ptr mCalibrator = nullptr; - std::string mPath; - std::string mMeta; - double mThresh; - int64_t mStart; - int64_t mEnd; -}; - -/// create a processor spec -/// run MFT noise calibration -DataProcessorSpec getNoiseCalibratorDigitsSpec(); - -} // namespace mft -} // namespace o2 - -#endif /* O2_MFT_NOISECALIBRATORDIGITSSPEC */ diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index 13689b5a1a0e6..16791bdd08480 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -18,7 +18,7 @@ #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" -//#define TIME_SLOT_CALIBRATION +#define TIME_SLOT_CALIBRATION #ifdef TIME_SLOT_CALIBRATION #include "MFTCalibration/NoiseSlotCalibrator.h" using CALIBRATOR = o2::mft::NoiseSlotCalibrator; @@ -49,7 +49,7 @@ class NoiseCalibratorSpec : public Task private: void sendOutput(DataAllocator& output); - o2::itsmft::NoiseMap mNoiseMap{926}; + o2::itsmft::NoiseMap mNoiseMap{936}; std::unique_ptr mCalibrator = nullptr; std::string mPath; std::string mMeta; diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index 2fe2173ed23c3..9f5ecea663533 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -19,6 +19,7 @@ #include "DetectorsCalibration/TimeSlot.h" #include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/Digit.h" #include "DataFormatsITSMFT/NoiseMap.h" #include "gsl/span" @@ -39,7 +40,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration const& clusters, - gsl::span const& patterns, + bool processTimeFrame(gsl::span const& digits, gsl::span const& rofs); void finalize() @@ -82,6 +82,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration + ; #pragma link C++ class o2::calibration::TimeSlotCalibration < o2::itsmft::CompClusterExt, o2::itsmft::NoiseMap> + ; #pragma link C++ class o2::mft::NoiseCalibrator + ; -#pragma link C++ class o2::mft::NoiseCalibratorDigits + ; +#pragma link C++ class o2::mft::NoiseSlotCalibrator + ; #endif diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx index deabb266e26a4..b8601baeb3a69 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx @@ -14,70 +14,28 @@ #include "FairLogger.h" #include "TFile.h" -#include "DataFormatsITSMFT/ClusterPattern.h" -#include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/Digit.h" #include "DataFormatsITSMFT/ROFRecord.h" namespace o2 { namespace mft { -bool NoiseCalibrator::processTimeFrame(gsl::span const& clusters, - gsl::span const& patterns, +bool NoiseCalibrator::processTimeFrame(gsl::span const& digits, gsl::span const& rofs) { static int nTF = 0; LOG(INFO) << "Processing TF# " << nTF++; - auto pattIt = patterns.begin(); for (const auto& rof : rofs) { - auto clustersInFrame = rof.getROFData(clusters); - for (const auto& c : clustersInFrame) { - if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { - // For the noise calibration, we use "pass1" clusters... - continue; - } - o2::itsmft::ClusterPattern patt(pattIt); + auto digitsInFrame = rof.getROFData(digits); + for (const auto& d : digitsInFrame) { + auto id = d.getChipIndex(); + auto row = d.getRow(); + auto col = d.getColumn(); - auto id = c.getSensorID(); - auto row = c.getRow(); - auto col = c.getCol(); - auto colSpan = patt.getColumnSpan(); - auto rowSpan = patt.getRowSpan(); + mNoiseMap.increaseNoiseCount(id, row, col); - // Fast 1-pixel calibration - if ((rowSpan == 1) && (colSpan == 1)) { - mNoiseMap.increaseNoiseCount(id, row, col); - continue; - } - if (m1pix) { - continue; - } - - // All-pixel calibration - auto nBits = rowSpan * colSpan; - int ic = 0, ir = 0; - for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { - unsigned char tempChar = patt.getByte(i); - int s = 128; // 0b10000000 - while (s > 0) { - if ((tempChar & s) != 0) { - mNoiseMap.increaseNoiseCount(id, row + ir, col + ic); - } - ic++; - s >>= 1; - if ((ir + 1) * ic == nBits) { - break; - } - if (ic == colSpan) { - ic = 0; - ir++; - } - } - if ((ir + 1) * ic == nBits) { - break; - } - } } } mNumberOfStrobes += rofs.size(); diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx deleted file mode 100644 index 9701e3e6c6717..0000000000000 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigits.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// 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 NoiseCalibratorDigits.cxx - -#include "MFTCalibration/NoiseCalibratorDigits.h" - -#include "FairLogger.h" -#include "TFile.h" -#include "DataFormatsITSMFT/Digit.h" -#include "DataFormatsITSMFT/ROFRecord.h" - -namespace o2 -{ -namespace mft -{ -bool NoiseCalibratorDigits::processTimeFrame(gsl::span const& digits, - gsl::span const& rofs) -{ - static int nTF = 0; - LOG(INFO) << "Processing TF# " << nTF++; - - for (const auto& rof : rofs) { - auto digitsInFrame = rof.getROFData(digits); - for (const auto& d : digitsInFrame) { - auto id = d.getChipIndex(); - auto row = d.getRow(); - auto col = d.getColumn(); - - mNoiseMap.increaseNoiseCount(id, row, col); - } - } - mNumberOfStrobes += rofs.size(); - return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; -} - -void NoiseCalibratorDigits::finalize() -{ - LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; - mNoiseMap.applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes); -} - -} // namespace mft -} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx deleted file mode 100644 index 14ea7e40cc7d3..0000000000000 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorDigitsSpec.cxx +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// 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 NoiseCalibratorDigitsSpec.cxx - -#include "CCDB/CcdbApi.h" -#include "DetectorsCalibration/Utils.h" -#include "MFTCalibration/NoiseCalibratorDigitsSpec.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "DataFormatsITSMFT/Digit.h" - -#include "FairLogger.h" -#include "Framework/ControlService.h" -#include "Framework/ConfigParamRegistry.h" - -using namespace o2::framework; - -namespace o2 -{ -namespace mft -{ - -// Remove leading whitespace -std::string ltrimSpaceStream(std::string src) -{ - return src.erase(0, src.find_first_not_of(' ')); -} - -// Remove trailing whitespace -std::string rtrimSpaceStream(std::string src) -{ - return src.erase(src.find_last_not_of(' ') + 1); -} - -// Remove leading/trailing whitespace -std::string trimSpaceStream(std::string const& src) -{ - return ltrimSpaceStream(rtrimSpaceStream(src)); -} - -std::vector splitStringStream(const std::string& src, char delim, bool trim = false) -{ - std::stringstream ss(src); - std::string token; - std::vector tokens; - - while (std::getline(ss, token, delim)) { - token = (trim ? trimSpaceStream(token) : token); - if (!token.empty()) { - tokens.push_back(std::move(token)); - } - } - - return tokens; -} -void NoiseCalibratorDigitsSpec::init(InitContext& ic) -{ - auto onepix = ic.options().get("1pix-only"); - LOG(INFO) << "Fast 1=pixel calibration: " << onepix; - auto probT = ic.options().get("prob-threshold"); - LOG(INFO) << "Setting the probability threshold to " << probT; - - mPath = ic.options().get("path"); - mMeta = ic.options().get("meta"); - mStart = ic.options().get("tstart"); - mEnd = ic.options().get("tend"); - - mCalibrator = std::make_unique(onepix, probT); -} - -void NoiseCalibratorDigitsSpec::run(ProcessingContext& pc) -{ - const auto digits = pc.inputs().get>("digits"); - const auto rofs = pc.inputs().get>("digitsROF"); - - if (mCalibrator->processTimeFrame(digits, rofs)) { - LOG(INFO) << "Minimum number of noise counts has been reached !"; - sendOutput(pc.outputs()); - pc.services().get().readyToQuit(QuitRequest::All); - } -} - -void NoiseCalibratorDigitsSpec::sendOutput(DataAllocator& output) -{ - mCalibrator->finalize(); - - const auto& payload = mCalibrator->getNoiseMap(); - - long tstart = mStart; - if (tstart == -1) { - tstart = o2::ccdb::getCurrentTimestamp(); - } - long tend = mEnd; - if (tend == -1) { - constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60; - tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); - } - - auto toKeyValPairs = [](std::vector const& tokens) { - std::vector> pairs; - - for (auto& token : tokens) { - auto keyval = splitStringStream(token, '='); - if (keyval.size() != 2) { - // LOG(FATAL) << "Illegal command-line key/value string: " << token; - continue; - } - - std::pair pair = std::make_pair(keyval[0], trimSpaceStream(keyval[1])); - pairs.push_back(pair); - } - - return pairs; - }; - std::map meta; - auto keyvalues = toKeyValPairs(splitStringStream(mMeta, ';', true)); - - // fill meta map - for (auto& p : keyvalues) { - meta[p.first] = p.second; - } - - o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); - auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); - auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); - info.setFileName(flName); - LOG(INFO) << "Sending object " << info.getPath() << "/" << info.getFileName() - << " of size " << image->size() - << " bytes, valid for " << info.getStartValidityTimestamp() - << " : " << info.getEndValidityTimestamp(); - - using clbUtils = o2::calibration::Utils; - output.snapshot( - Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload, 0}, *image.get()); - output.snapshot( - Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo, 0}, info); -} - -void NoiseCalibratorDigitsSpec::endOfStream(o2::framework::EndOfStreamContext& ec) -{ - sendOutput(ec.outputs()); -} - -DataProcessorSpec getNoiseCalibratorDigitsSpec() -{ - o2::header::DataOrigin detOrig = o2::header::gDataOriginMFT; - std::vector inputs; - inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); - inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); - - using clbUtils = o2::calibration::Utils; - std::vector outputs; - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload}); - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo}); - - return DataProcessorSpec{ - "mft-noise-calibrator", - inputs, - outputs, - AlgorithmSpec{adaptFromTask()}, - Options{ - {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, - {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, - {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, - {"tend", VariantType::Int64, -1ll, {"End of validity timestamp"}}, - {"path", VariantType::String, "/MFT/Calib/NoiseMap", {"Path to write to in CCDB"}}, - {"meta", VariantType::String, "", {"meta data to write in CCDB"}}}}; -} - -} // namespace mft -} // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index c8285e1be0ee7..8cbee54b8c3dd 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -13,7 +13,7 @@ #include "CCDB/CcdbApi.h" #include "DetectorsCalibration/Utils.h" #include "MFTCalibration/NoiseCalibratorSpec.h" -#include "DataFormatsITSMFT/CompCluster.h" +#include "DataFormatsITSMFT/Digit.h" #include "DataFormatsITSMFT/ROFRecord.h" #include "FairLogger.h" @@ -67,22 +67,23 @@ void NoiseCalibratorSpec::init(InitContext& ic) LOG(INFO) << "Fast 1=pixel calibration: " << onepix; auto probT = ic.options().get("prob-threshold"); LOG(INFO) << "Setting the probability threshold to " << probT; + auto HBperTF = ic.options().get("hb-per-tf"); + LOG(INFO) << "Nb of HBF per TF used : " << HBperTF; mPath = ic.options().get("path"); mMeta = ic.options().get("meta"); mStart = ic.options().get("tstart"); mEnd = ic.options().get("tend"); - mCalibrator = std::make_unique(onepix, probT); + mCalibrator = std::make_unique(onepix, probT, HBperTF); } void NoiseCalibratorSpec::run(ProcessingContext& pc) { - const auto compClusters = pc.inputs().get>("compClusters"); - gsl::span patterns = pc.inputs().get>("patterns"); - const auto rofs = pc.inputs().get>("ROframes"); + const auto digits = pc.inputs().get>("digits"); + const auto rofs = pc.inputs().get>("digitsROF"); - if (mCalibrator->processTimeFrame(compClusters, patterns, rofs)) { + if (mCalibrator->processTimeFrame(digits, rofs)) { LOG(INFO) << "Minimum number of noise counts has been reached !"; sendOutput(pc.outputs()); pc.services().get().readyToQuit(QuitRequest::All); @@ -127,8 +128,10 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) meta[p.first] = p.second; } + long startTF, endTF; + #ifdef TIME_SLOT_CALIBRATION - const auto& payload = mCalibrator->getNoiseMap(tstart, tend); + const auto& payload = mCalibrator->getNoiseMap(startTF, endTF); #else const auto& payload = mCalibrator->getNoiseMap(); #endif @@ -158,9 +161,8 @@ DataProcessorSpec getNoiseCalibratorSpec() { o2::header::DataOrigin detOrig = o2::header::gDataOriginMFT; std::vector inputs; - inputs.emplace_back("compClusters", detOrig, "COMPCLUSTERS", 0, Lifetime::Timeframe); - inputs.emplace_back("patterns", detOrig, "PATTERNS", 0, Lifetime::Timeframe); - inputs.emplace_back("ROframes", detOrig, "CLUSTERSROF", 0, Lifetime::Timeframe); + inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); + inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); using clbUtils = o2::calibration::Utils; std::vector outputs; @@ -180,7 +182,8 @@ DataProcessorSpec getNoiseCalibratorSpec() {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, {"tend", VariantType::Int64, -1ll, {"End of validity timestamp"}}, {"path", VariantType::String, "/MFT/Calib/NoiseMap", {"Path to write to in CCDB"}}, - {"meta", VariantType::String, "", {"meta data to write in CCDB"}}}}; + {"meta", VariantType::String, "", {"meta data to write in CCDB"}}, + {"hb-per-tf", VariantType::Int, 256, {"Number of HBF per TF"}}}}; } } // namespace mft diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index 2fe9fb0d450ce..404f6cfbd699f 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -14,6 +14,7 @@ #include "FairLogger.h" #include "TFile.h" +#include "DataFormatsITSMFT/Digit.h" #include "DataFormatsITSMFT/ClusterPattern.h" #include "DataFormatsITSMFT/ROFRecord.h" @@ -23,65 +24,24 @@ using Slot = calibration::TimeSlot; namespace mft { -bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& clusters, - gsl::span const& patterns, +bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& digits, gsl::span const& rofs) { - calibration::TFType nTF = rofs[0].getBCData().orbit / 256; + calibration::TFType nTF = rofs[0].getBCData().orbit / mHBFperTF; LOG(INFO) << "Processing TF# " << nTF; auto& slotTF = getSlotForTF(nTF); auto& noiseMap = *(slotTF.getContainer()); - auto pattIt = patterns.begin(); for (const auto& rof : rofs) { - auto clustersInFrame = rof.getROFData(clusters); - for (const auto& c : clustersInFrame) { - if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { - // For the noise calibration, we use "pass1" clusters... - continue; - } - o2::itsmft::ClusterPattern patt(pattIt); - - auto id = c.getSensorID(); - auto row = c.getRow(); - auto col = c.getCol(); - auto colSpan = patt.getColumnSpan(); - auto rowSpan = patt.getRowSpan(); - - // Fast 1-pixel calibration - if ((rowSpan == 1) && (colSpan == 1)) { - noiseMap.increaseNoiseCount(id, row, col); - continue; - } - if (m1pix) { - continue; - } - - // All-pixel calibration - auto nBits = rowSpan * colSpan; - int ic = 0, ir = 0; - for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { - unsigned char tempChar = patt.getByte(i); - int s = 128; // 0b10000000 - while (s > 0) { - if ((tempChar & s) != 0) { - noiseMap.increaseNoiseCount(id, row + ir, col + ic); - } - ic++; - s >>= 1; - if ((ir + 1) * ic == nBits) { - break; - } - if (ic == colSpan) { - ic = 0; - ir++; - } - } - if ((ir + 1) * ic == nBits) { - break; - } - } + auto digitsInFrame = rof.getROFData(digits); + for (const auto& d : digitsInFrame) { + auto id = d.getChipIndex(); + auto row = d.getRow(); + auto col = d.getColumn(); + + noiseMap.increaseNoiseCount(id, row, col); + } } @@ -102,7 +62,7 @@ Slot& NoiseSlotCalibrator::emplaceNewSlot(bool front, calibration::TFType tstart { auto& cont = getSlots(); auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend); - slot.setContainer(std::make_unique(926)); + slot.setContainer(std::make_unique(936)); return slot; } diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx index 97b4989e44a3c..f09b0c61e67b1 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -17,7 +17,6 @@ using namespace o2::framework; void customize(std::vector& workflowOptions) { // option allowing to set parameters - workflowOptions.push_back(ConfigParamSpec{"useDigits", VariantType::Bool, false, {"Use decoded digits"}}); } // ------------------------------------------------------------------ @@ -25,22 +24,12 @@ void customize(std::vector& workflowOptions) #include "Framework/runDataProcessing.h" #include "MFTCalibration/NoiseCalibratorSpec.h" #include "MFTCalibration/NoiseCalibrator.h" -#include "MFTCalibration/NoiseCalibratorDigitsSpec.h" -#include "MFTCalibration/NoiseCalibratorDigits.h" WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec specs; - auto useDigits = cfgc.options().get("useDigits"); - LOG(INFO) << "MFT calibration workflow options"; - LOG(INFO) << "Use Digits: " << useDigits; - - if (useDigits) { - specs.emplace_back(o2::mft::getNoiseCalibratorDigitsSpec()); - } else { - specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); - } + specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); return specs; } From e836f0543ba27840e62fe0e8040cebfb18c95bc4 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 6 May 2021 16:33:07 +0200 Subject: [PATCH 15/24] Clang format --- Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx | 1 - Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx | 1 - 2 files changed, 2 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx index b8601baeb3a69..9cbba40546bb0 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx @@ -35,7 +35,6 @@ bool NoiseCalibrator::processTimeFrame(gsl::span const& auto col = d.getColumn(); mNoiseMap.increaseNoiseCount(id, row, col); - } } mNumberOfStrobes += rofs.size(); diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index 404f6cfbd699f..441bfe5ef578e 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -41,7 +41,6 @@ bool NoiseSlotCalibrator::processTimeFrame(gsl::span co auto col = d.getColumn(); noiseMap.increaseNoiseCount(id, row, col); - } } From e2e8f7be41cb524e95d900e74d3b157885e7f5ef Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 12 May 2021 15:16:29 +0200 Subject: [PATCH 16/24] Digits/Clusters implementation --- .../include/MFTCalibration/NoiseCalibrator.h | 8 ++- .../MFTCalibration/NoiseCalibratorSpec.h | 7 +- .../MFTCalibration/NoiseSlotCalibrator.h | 5 ++ .../MFT/calibration/src/NoiseCalibrator.cxx | 63 +++++++++++++++++ .../calibration/src/NoiseCalibratorSpec.cxx | 46 ++++++++++--- .../calibration/src/NoiseSlotCalibrator.cxx | 68 +++++++++++++++++++ .../testWorkflow/mft-calib-workflow.cxx | 7 +- 7 files changed, 188 insertions(+), 16 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h index 0944573a036e1..d79a71d3e1b2f 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -34,10 +34,11 @@ class NoiseCalibrator { public: NoiseCalibrator() = default; - NoiseCalibrator(bool one, float prob) + NoiseCalibrator(bool one, float prob, int hbpertf) { m1pix = one; mProbabilityThreshold = prob; + mHBFperTF = hbpertf; } ~NoiseCalibrator() = default; @@ -46,6 +47,10 @@ class NoiseCalibrator bool processTimeFrame(gsl::span const& digits, gsl::span const& rofs); + bool processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs); + void finalize(); const o2::itsmft::NoiseMap& getNoiseMap() const { return mNoiseMap; } @@ -56,6 +61,7 @@ class NoiseCalibrator unsigned int mThreshold = 100; unsigned int mNumberOfStrobes = 0; bool m1pix = true; + int mHBFperTF = 256; }; } // namespace mft diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index 16791bdd08480..ba2519b4125c0 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -18,7 +18,7 @@ #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" -#define TIME_SLOT_CALIBRATION +//#define TIME_SLOT_CALIBRATION #ifdef TIME_SLOT_CALIBRATION #include "MFTCalibration/NoiseSlotCalibrator.h" using CALIBRATOR = o2::mft::NoiseSlotCalibrator; @@ -40,7 +40,7 @@ namespace mft class NoiseCalibratorSpec : public Task { public: - NoiseCalibratorSpec() = default; + NoiseCalibratorSpec(bool digits = false); ~NoiseCalibratorSpec() override = default; void init(InitContext& ic) final; @@ -56,11 +56,12 @@ class NoiseCalibratorSpec : public Task double mThresh; int64_t mStart; int64_t mEnd; + bool mDigits=false; }; /// create a processor spec /// run MFT noise calibration -DataProcessorSpec getNoiseCalibratorSpec(); +DataProcessorSpec getNoiseCalibratorSpec(bool useDigits); } // namespace mft } // namespace o2 diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index 9f5ecea663533..377be972238b0 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -44,6 +44,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration const& digits, gsl::span const& rofs); + bool processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs); + void finalize() { LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx index 9cbba40546bb0..e6c0a7c22c212 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx @@ -15,6 +15,7 @@ #include "FairLogger.h" #include "TFile.h" #include "DataFormatsITSMFT/Digit.h" +#include "DataFormatsITSMFT/ClusterPattern.h" #include "DataFormatsITSMFT/ROFRecord.h" namespace o2 @@ -41,6 +42,68 @@ bool NoiseCalibrator::processTimeFrame(gsl::span const& return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; } +bool NoiseCalibrator::processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs) +{ + static int nTF = 0; + LOG(INFO) << "Processing TF# " << nTF++; + + auto pattIt = patterns.begin(); + for (const auto& rof : rofs) { + auto clustersInFrame = rof.getROFData(clusters); + for (const auto& c : clustersInFrame) { + if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { + // For the noise calibration, we use "pass1" clusters... + continue; + } + o2::itsmft::ClusterPattern patt(pattIt); + + auto id = c.getSensorID(); + auto row = c.getRow(); + auto col = c.getCol(); + auto colSpan = patt.getColumnSpan(); + auto rowSpan = patt.getRowSpan(); + + // Fast 1-pixel calibration + if ((rowSpan == 1) && (colSpan == 1)) { + mNoiseMap.increaseNoiseCount(id, row, col); + continue; + } + if (m1pix) { + continue; + } + + // All-pixel calibration + auto nBits = rowSpan * colSpan; + int ic = 0, ir = 0; + for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { + unsigned char tempChar = patt.getByte(i); + int s = 128; // 0b10000000 + while (s > 0) { + if ((tempChar & s) != 0) { + mNoiseMap.increaseNoiseCount(id, row + ir, col + ic); + } + ic++; + s >>= 1; + if ((ir + 1) * ic == nBits) { + break; + } + if (ic == colSpan) { + ic = 0; + ir++; + } + } + if ((ir + 1) * ic == nBits) { + break; + } + } + } + } + mNumberOfStrobes += rofs.size(); + return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; +} + void NoiseCalibrator::finalize() { LOG(INFO) << "Number of processed strobes is " << mNumberOfStrobes; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index 8cbee54b8c3dd..98fca40ea67ab 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -14,6 +14,7 @@ #include "DetectorsCalibration/Utils.h" #include "MFTCalibration/NoiseCalibratorSpec.h" #include "DataFormatsITSMFT/Digit.h" +#include "DataFormatsITSMFT/CompCluster.h" #include "DataFormatsITSMFT/ROFRecord.h" #include "FairLogger.h" @@ -61,6 +62,11 @@ namespace o2 namespace mft { +NoiseCalibratorSpec::NoiseCalibratorSpec(bool useDigits) + : mDigits(useDigits) +{ +} + void NoiseCalibratorSpec::init(InitContext& ic) { auto onepix = ic.options().get("1pix-only"); @@ -80,13 +86,25 @@ void NoiseCalibratorSpec::init(InitContext& ic) void NoiseCalibratorSpec::run(ProcessingContext& pc) { - const auto digits = pc.inputs().get>("digits"); - const auto rofs = pc.inputs().get>("digitsROF"); - - if (mCalibrator->processTimeFrame(digits, rofs)) { - LOG(INFO) << "Minimum number of noise counts has been reached !"; - sendOutput(pc.outputs()); - pc.services().get().readyToQuit(QuitRequest::All); + if (mDigits) { + const auto digits = pc.inputs().get>("digits"); + const auto rofs = pc.inputs().get>("digitsROF"); + + if (mCalibrator->processTimeFrame(digits, rofs)) { + LOG(INFO) << "Minimum number of noise counts has been reached !"; + sendOutput(pc.outputs()); + pc.services().get().readyToQuit(QuitRequest::All); + } + }else{ + const auto compClusters = pc.inputs().get>("compClusters"); + gsl::span patterns = pc.inputs().get>("patterns"); + const auto rofs = pc.inputs().get>("ROframes"); + + if (mCalibrator->processTimeFrame(compClusters, patterns, rofs)) { + LOG(INFO) << "Minimum number of noise counts has been reached !"; + sendOutput(pc.outputs()); + pc.services().get().readyToQuit(QuitRequest::All); + } } } @@ -157,12 +175,18 @@ void NoiseCalibratorSpec::endOfStream(o2::framework::EndOfStreamContext& ec) sendOutput(ec.outputs()); } -DataProcessorSpec getNoiseCalibratorSpec() +DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) { o2::header::DataOrigin detOrig = o2::header::gDataOriginMFT; std::vector inputs; - inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); - inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); + if (useDigits) { + inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); + inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); + }else{ + inputs.emplace_back("compClusters", detOrig, "COMPCLUSTERS", 0, Lifetime::Timeframe); + inputs.emplace_back("patterns", detOrig, "PATTERNS", 0, Lifetime::Timeframe); + inputs.emplace_back("ROframes", detOrig, "CLUSTERSROF", 0, Lifetime::Timeframe); + } using clbUtils = o2::calibration::Utils; std::vector outputs; @@ -175,7 +199,7 @@ DataProcessorSpec getNoiseCalibratorSpec() "mft-noise-calibrator", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(useDigits)}, Options{ {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index 441bfe5ef578e..a190b0a94de6f 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -48,6 +48,74 @@ bool NoiseSlotCalibrator::processTimeFrame(gsl::span co return hasEnoughData(slotTF); } +bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& clusters, + gsl::span const& patterns, + gsl::span const& rofs) +{ + calibration::TFType nTF = rofs[0].getBCData().orbit / 256; + LOG(INFO) << "Processing TF# " << nTF; + + auto& slotTF = getSlotForTF(nTF); + auto& noiseMap = *(slotTF.getContainer()); + + auto pattIt = patterns.begin(); + for (const auto& rof : rofs) { + auto clustersInFrame = rof.getROFData(clusters); + for (const auto& c : clustersInFrame) { + if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) { + // For the noise calibration, we use "pass1" clusters... + continue; + } + o2::itsmft::ClusterPattern patt(pattIt); + + auto id = c.getSensorID(); + auto row = c.getRow(); + auto col = c.getCol(); + auto colSpan = patt.getColumnSpan(); + auto rowSpan = patt.getRowSpan(); + + // Fast 1-pixel calibration + if ((rowSpan == 1) && (colSpan == 1)) { + noiseMap.increaseNoiseCount(id, row, col); + continue; + } + if (m1pix) { + continue; + } + + // All-pixel calibration + auto nBits = rowSpan * colSpan; + int ic = 0, ir = 0; + for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) { + unsigned char tempChar = patt.getByte(i); + int s = 128; // 0b10000000 + while (s > 0) { + if ((tempChar & s) != 0) { + noiseMap.increaseNoiseCount(id, row + ir, col + ic); + } + ic++; + s >>= 1; + if ((ir + 1) * ic == nBits) { + break; + } + if (ic == colSpan) { + ic = 0; + ir++; + } + } + if ((ir + 1) * ic == nBits) { + break; + } + } + } + } + + mNumberOfStrobes += rofs.size(); + return hasEnoughData(slotTF); +} + + + // Functions overloaded from the calibration framework bool NoiseSlotCalibrator::process(calibration::TFType tf, const gsl::span data) { diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx index f09b0c61e67b1..a26d609be0674 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/mft-calib-workflow.cxx @@ -17,6 +17,7 @@ using namespace o2::framework; void customize(std::vector& workflowOptions) { // option allowing to set parameters + workflowOptions.push_back(ConfigParamSpec{"useDigits", VariantType::Bool, false, {"Use decoded digits"}}); } // ------------------------------------------------------------------ @@ -28,8 +29,12 @@ void customize(std::vector& workflowOptions) WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec specs; + auto useDigits = cfgc.options().get("useDigits"); - specs.emplace_back(o2::mft::getNoiseCalibratorSpec()); + LOG(INFO) << "MFT calibration workflow options"; + LOG(INFO) << "Use Digits: " << useDigits; + + specs.emplace_back(o2::mft::getNoiseCalibratorSpec(useDigits)); return specs; } From d99ee56309549fcdf1cc6ac188a9d221382e5a92 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 21 May 2021 21:19:04 +0200 Subject: [PATCH 17/24] Using StringUtils --- .../ITSMFT/MFT/calibration/CMakeLists.txt | 2 - .../MFTCalibration/NoiseCalibratorSpec.h | 6 --- .../calibration/src/MFTCalibrationLinkDef.h | 3 -- .../calibration/src/NoiseCalibratorSpec.cxx | 52 ++++--------------- 4 files changed, 10 insertions(+), 53 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index 1584948fcf500..7f491ecfdfff4 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -10,14 +10,12 @@ o2_add_library(MFTCalibration SOURCES src/NoiseCalibrator.cxx - SOURCES src/NoiseSlotCalibrator.cxx SOURCES src/NoiseCalibratorSpec.cxx PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase O2::DetectorsCalibration O2::CCDB) o2_target_root_dictionary(MFTCalibration - HEADERS include/MFTCalibration/NoiseSlotCalibrator.h HEADERS include/MFTCalibration/NoiseCalibrator.h LINKDEF src/MFTCalibrationLinkDef.h) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index ba2519b4125c0..dc11511450524 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -18,14 +18,8 @@ #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" -//#define TIME_SLOT_CALIBRATION -#ifdef TIME_SLOT_CALIBRATION -#include "MFTCalibration/NoiseSlotCalibrator.h" -using CALIBRATOR = o2::mft::NoiseSlotCalibrator; -#else #include "MFTCalibration/NoiseCalibrator.h" using CALIBRATOR = o2::mft::NoiseCalibrator; -#endif #include "DataFormatsITSMFT/NoiseMap.h" diff --git a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h index acc42cc03d399..fa990979fb3e2 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h +++ b/Detectors/ITSMFT/MFT/calibration/src/MFTCalibrationLinkDef.h @@ -14,9 +14,6 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::calibration::TimeSlot < o2::itsmft::CompClusterExt> + ; -#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::itsmft::CompClusterExt, o2::itsmft::NoiseMap> + ; #pragma link C++ class o2::mft::NoiseCalibrator + ; -#pragma link C++ class o2::mft::NoiseSlotCalibrator + ; #endif diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index 98fca40ea67ab..f1c51d71efa2b 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -11,6 +11,7 @@ /// @file NoiseCalibratorSpec.cxx #include "CCDB/CcdbApi.h" +#include "CommonUtils/StringUtils.h" #include "DetectorsCalibration/Utils.h" #include "MFTCalibration/NoiseCalibratorSpec.h" #include "DataFormatsITSMFT/Digit.h" @@ -22,40 +23,7 @@ #include "Framework/ConfigParamRegistry.h" using namespace o2::framework; - -// Remove leading whitespace -std::string ltrimSpace(std::string src) -{ - return src.erase(0, src.find_first_not_of(' ')); -} - -// Remove trailing whitespace -std::string rtrimSpace(std::string src) -{ - return src.erase(src.find_last_not_of(' ') + 1); -} - -// Remove leading/trailing whitespace -std::string trimSpace(std::string const& src) -{ - return ltrimSpace(rtrimSpace(src)); -} - -std::vector splitString(const std::string& src, char delim, bool trim = false) -{ - std::stringstream ss(src); - std::string token; - std::vector tokens; - - while (std::getline(ss, token, delim)) { - token = (trim ? trimSpace(token) : token); - if (!token.empty()) { - tokens.push_back(std::move(token)); - } - } - - return tokens; -} +using namespace o2::utils; namespace o2 { @@ -122,24 +90,28 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); } + auto toKeyValPairs = [](std::vector const& tokens) { std::vector> pairs; - + Str strutils; for (auto& token : tokens) { - auto keyval = splitString(token, '='); +// auto keyval = splitString(token, '='); + auto keyval = Str::tokenize(token, '=', false); if (keyval.size() != 2) { // LOG(FATAL) << "Illegal command-line key/value string: " << token; continue; } - std::pair pair = std::make_pair(keyval[0], trimSpace(keyval[1])); + strutils.trim(keyval[1]); + std::pair pair = std::make_pair(keyval[0],keyval[1]); pairs.push_back(pair); } return pairs; }; std::map meta; - auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); +// auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); + auto keyvalues = toKeyValPairs(Str::tokenize(mMeta, ';', true)); // fill meta map for (auto& p : keyvalues) { @@ -148,11 +120,7 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) long startTF, endTF; -#ifdef TIME_SLOT_CALIBRATION - const auto& payload = mCalibrator->getNoiseMap(startTF, endTF); -#else const auto& payload = mCalibrator->getNoiseMap(); -#endif o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); From be27469157dd5262d55cf691a1b3f8eeeed80d13 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 21 May 2021 21:21:31 +0200 Subject: [PATCH 18/24] Clang Format --- .../include/MFTCalibration/NoiseCalibratorSpec.h | 2 +- .../MFT/calibration/src/NoiseCalibratorSpec.cxx | 13 ++++++------- .../MFT/calibration/src/NoiseSlotCalibrator.cxx | 2 -- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index dc11511450524..d933bf4e6e089 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -50,7 +50,7 @@ class NoiseCalibratorSpec : public Task double mThresh; int64_t mStart; int64_t mEnd; - bool mDigits=false; + bool mDigits = false; }; /// create a processor spec diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index f1c51d71efa2b..8ce0c8bc41166 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -54,7 +54,7 @@ void NoiseCalibratorSpec::init(InitContext& ic) void NoiseCalibratorSpec::run(ProcessingContext& pc) { - if (mDigits) { + if (mDigits) { const auto digits = pc.inputs().get>("digits"); const auto rofs = pc.inputs().get>("digitsROF"); @@ -63,7 +63,7 @@ void NoiseCalibratorSpec::run(ProcessingContext& pc) sendOutput(pc.outputs()); pc.services().get().readyToQuit(QuitRequest::All); } - }else{ + } else { const auto compClusters = pc.inputs().get>("compClusters"); gsl::span patterns = pc.inputs().get>("patterns"); const auto rofs = pc.inputs().get>("ROframes"); @@ -90,12 +90,11 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); } - auto toKeyValPairs = [](std::vector const& tokens) { std::vector> pairs; Str strutils; for (auto& token : tokens) { -// auto keyval = splitString(token, '='); + // auto keyval = splitString(token, '='); auto keyval = Str::tokenize(token, '=', false); if (keyval.size() != 2) { // LOG(FATAL) << "Illegal command-line key/value string: " << token; @@ -103,14 +102,14 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) } strutils.trim(keyval[1]); - std::pair pair = std::make_pair(keyval[0],keyval[1]); + std::pair pair = std::make_pair(keyval[0], keyval[1]); pairs.push_back(pair); } return pairs; }; std::map meta; -// auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); + // auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); auto keyvalues = toKeyValPairs(Str::tokenize(mMeta, ';', true)); // fill meta map @@ -150,7 +149,7 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) if (useDigits) { inputs.emplace_back("digits", detOrig, "DIGITS", 0, Lifetime::Timeframe); inputs.emplace_back("digitsROF", detOrig, "DIGITSROF", 0, Lifetime::Timeframe); - }else{ + } else { inputs.emplace_back("compClusters", detOrig, "COMPCLUSTERS", 0, Lifetime::Timeframe); inputs.emplace_back("patterns", detOrig, "PATTERNS", 0, Lifetime::Timeframe); inputs.emplace_back("ROframes", detOrig, "CLUSTERSROF", 0, Lifetime::Timeframe); diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index a190b0a94de6f..9b866374ce6fe 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -114,8 +114,6 @@ bool NoiseSlotCalibrator::processTimeFrame(gsl::span data) { From 6942be4950a74dd7d2560b0600128c51250c3768 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 21 May 2021 23:32:34 +0200 Subject: [PATCH 19/24] Fixing spaces and tabs --- Detectors/ITSMFT/MFT/calibration/CMakeLists.txt | 10 +++++----- .../ITSMFT/MFT/calibration/testWorkflow/README.md | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt index 7f491ecfdfff4..56fcdbec15d3b 100644 --- a/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt +++ b/Detectors/ITSMFT/MFT/calibration/CMakeLists.txt @@ -10,18 +10,18 @@ o2_add_library(MFTCalibration SOURCES src/NoiseCalibrator.cxx - SOURCES src/NoiseCalibratorSpec.cxx - PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase + SOURCES src/NoiseCalibratorSpec.cxx + PUBLIC_LINK_LIBRARIES O2::DataFormatsMFT O2::MFTBase O2::DetectorsCalibration O2::CCDB) o2_target_root_dictionary(MFTCalibration - HEADERS include/MFTCalibration/NoiseCalibrator.h - LINKDEF src/MFTCalibrationLinkDef.h) + HEADERS include/MFTCalibration/NoiseCalibrator.h + LINKDEF src/MFTCalibrationLinkDef.h) o2_add_executable(mft-calib-workflow COMPONENT_NAME calibration SOURCES testWorkflow/mft-calib-workflow.cxx PUBLIC_LINK_LIBRARIES O2::Framework - O2::MFTCalibration) + O2::MFTCalibration) diff --git a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md index ec84eb056209f..39319c968878c 100644 --- a/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md +++ b/Detectors/ITSMFT/MFT/calibration/testWorkflow/README.md @@ -17,11 +17,11 @@ o2-calibration-mft-calib-workflow --useDigits --path "/MFT/test_CCDB/" --meta "D o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:8080" -b ``` -Additional options to the mft-calib DPL : +Additional options to the mft-calib DPL : ``` - --path "/path/in/CCDB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") - --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB - --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) - --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) - --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) + --path "/path/in/CCDB/" : defines path to write to in CCDB (default : "/MFT/Calib/NoiseMap") + --meta "Description=...;Author=...;Uploader=..." : add meta data to the input in the CCDB + --tstart : defines the start of validity timestamp of the file written in the CCDB (default is -1 : current timestamp) + --tend : defines the start of validity timestamp of the file written in the CCDB (defult is -1 : one year from the current timestamp) + --prob-threshold : defined probability threshold for noisy pixels (default : 3e-6) ``` From 233ca1a8ceaa030f031ea6d8e964c4243c2ba4ed Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 25 May 2021 13:36:43 +0200 Subject: [PATCH 20/24] Changes for PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modifié : ../include/MFTCalibration/NoiseCalibrator.h modifié : ../include/MFTCalibration/NoiseCalibratorSpec.h modifié : ../include/MFTCalibration/NoiseSlotCalibrator.h modifié : NoiseCalibrator.cxx modifié : NoiseCalibratorSpec.cxx modifié : NoiseSlotCalibrator.cxx --- .../include/MFTCalibration/NoiseCalibrator.h | 16 +++++----- .../MFTCalibration/NoiseCalibratorSpec.h | 3 ++ .../MFTCalibration/NoiseSlotCalibrator.h | 12 +++---- .../MFT/calibration/src/NoiseCalibrator.cxx | 9 +++--- .../calibration/src/NoiseCalibratorSpec.cxx | 32 ++++++++----------- .../calibration/src/NoiseSlotCalibrator.cxx | 11 +++---- 6 files changed, 37 insertions(+), 46 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h index d79a71d3e1b2f..814b51e2903b1 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -16,6 +16,8 @@ #include #include "DataFormatsITSMFT/NoiseMap.h" +#include "DetectorsCalibration/TimeSlotCalibration.h" +#include "DetectorsCalibration/TimeSlot.h" #include "gsl/span" namespace o2 @@ -34,20 +36,20 @@ class NoiseCalibrator { public: NoiseCalibrator() = default; - NoiseCalibrator(bool one, float prob, int hbpertf) + NoiseCalibrator(float prob) { - m1pix = one; mProbabilityThreshold = prob; - mHBFperTF = hbpertf; } ~NoiseCalibrator() = default; void setThreshold(unsigned int t) { mThreshold = t; } - bool processTimeFrame(gsl::span const& digits, + bool processTimeFrame(calibration::TFType tf, + gsl::span const& digits, gsl::span const& rofs); - bool processTimeFrame(gsl::span const& clusters, + bool processTimeFrame(calibration::TFType tf, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs); @@ -57,11 +59,9 @@ class NoiseCalibrator private: o2::itsmft::NoiseMap mNoiseMap{936}; - float mProbabilityThreshold = 3e-6f; + float mProbabilityThreshold = 1e-6f; unsigned int mThreshold = 100; unsigned int mNumberOfStrobes = 0; - bool m1pix = true; - int mHBFperTF = 256; }; } // namespace mft diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index d933bf4e6e089..aa86abe435be5 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -21,6 +21,9 @@ #include "MFTCalibration/NoiseCalibrator.h" using CALIBRATOR = o2::mft::NoiseCalibrator; +//#include "MFTCalibration/NoiseSlotCalibrator.h" //For TimeSlot calibration +//using CALIBRATOR = o2::mft::NoiseSlotCalibrator; + #include "DataFormatsITSMFT/NoiseMap.h" using namespace o2::framework; diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index 377be972238b0..5e8de0f0150f0 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -40,21 +40,21 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration const& digits, + bool processTimeFrame(calibration::TFType tf, + gsl::span const& digits, gsl::span const& rofs); - bool processTimeFrame(gsl::span const& clusters, + bool processTimeFrame(calibration::TFType tf, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs); @@ -86,8 +86,6 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration const& digits, +bool NoiseCalibrator::processTimeFrame(calibration::TFType tf, + gsl::span const& digits, gsl::span const& rofs) { static int nTF = 0; @@ -42,7 +43,8 @@ bool NoiseCalibrator::processTimeFrame(gsl::span const& return (mNumberOfStrobes * mProbabilityThreshold >= mThreshold) ? true : false; } -bool NoiseCalibrator::processTimeFrame(gsl::span const& clusters, +bool NoiseCalibrator::processTimeFrame(calibration::TFType tf, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs) { @@ -70,9 +72,6 @@ bool NoiseCalibrator::processTimeFrame(gsl::span("1pix-only"); - LOG(INFO) << "Fast 1=pixel calibration: " << onepix; auto probT = ic.options().get("prob-threshold"); LOG(INFO) << "Setting the probability threshold to " << probT; - auto HBperTF = ic.options().get("hb-per-tf"); - LOG(INFO) << "Nb of HBF per TF used : " << HBperTF; mPath = ic.options().get("path"); mMeta = ic.options().get("meta"); mStart = ic.options().get("tstart"); mEnd = ic.options().get("tend"); - mCalibrator = std::make_unique(onepix, probT, HBperTF); + mCalibrator = std::make_unique(probT); +// mCalibrator->setSlotLength(std::numeric_limits::max); //For TimeSlot calibration } void NoiseCalibratorSpec::run(ProcessingContext& pc) @@ -57,8 +54,9 @@ void NoiseCalibratorSpec::run(ProcessingContext& pc) if (mDigits) { const auto digits = pc.inputs().get>("digits"); const auto rofs = pc.inputs().get>("digitsROF"); + const auto tfcounter = o2::header::get(pc.inputs().get("digitsROF").header)->startTime; - if (mCalibrator->processTimeFrame(digits, rofs)) { + if (mCalibrator->processTimeFrame(tfcounter, digits, rofs)) { LOG(INFO) << "Minimum number of noise counts has been reached !"; sendOutput(pc.outputs()); pc.services().get().readyToQuit(QuitRequest::All); @@ -67,8 +65,9 @@ void NoiseCalibratorSpec::run(ProcessingContext& pc) const auto compClusters = pc.inputs().get>("compClusters"); gsl::span patterns = pc.inputs().get>("patterns"); const auto rofs = pc.inputs().get>("ROframes"); + const auto tfcounter = o2::header::get(pc.inputs().get("ROframes").header)->startTime; - if (mCalibrator->processTimeFrame(compClusters, patterns, rofs)) { + if (mCalibrator->processTimeFrame(tfcounter, compClusters, patterns, rofs)) { LOG(INFO) << "Minimum number of noise counts has been reached !"; sendOutput(pc.outputs()); pc.services().get().readyToQuit(QuitRequest::All); @@ -94,7 +93,6 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) std::vector> pairs; Str strutils; for (auto& token : tokens) { - // auto keyval = splitString(token, '='); auto keyval = Str::tokenize(token, '=', false); if (keyval.size() != 2) { // LOG(FATAL) << "Illegal command-line key/value string: " << token; @@ -109,7 +107,6 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) return pairs; }; std::map meta; - // auto keyvalues = toKeyValPairs(splitString(mMeta, ';', true)); auto keyvalues = toKeyValPairs(Str::tokenize(mMeta, ';', true)); // fill meta map @@ -120,6 +117,7 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) long startTF, endTF; const auto& payload = mCalibrator->getNoiseMap(); +// const auto& payload = mCalibrator->getNoiseMap(starTF, endTF); //For TimeSlot calibration o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); @@ -131,10 +129,8 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) << " : " << info.getEndValidityTimestamp(); using clbUtils = o2::calibration::Utils; - output.snapshot( - Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload, 0}, *image.get()); - output.snapshot( - Output{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo, 0}, info); + output.snapshot(Output{clbUtils::gDataOriginCDBPayload, "MFT_NoiseMap", 0}, *image.get()); + output.snapshot(Output{clbUtils::gDataOriginCDBWrapper, "MFT_NoiseMap", 0}, info); } void NoiseCalibratorSpec::endOfStream(o2::framework::EndOfStreamContext& ec) @@ -157,10 +153,9 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) using clbUtils = o2::calibration::Utils; std::vector outputs; - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload}); - outputs.emplace_back( - ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo}); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "MFT_NoiseMap"}); + outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "MFT_NoiseMap"}); + return DataProcessorSpec{ "mft-noise-calibrator", @@ -168,8 +163,7 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) outputs, AlgorithmSpec{adaptFromTask(useDigits)}, Options{ - {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only"}}, - {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, + {"prob-threshold", VariantType::Float, 1.e-6f, {"Probability threshold for noisy pixels"}}, {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, {"tend", VariantType::Int64, -1ll, {"End of validity timestamp"}}, {"path", VariantType::String, "/MFT/Calib/NoiseMap", {"Path to write to in CCDB"}}, diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index 9b866374ce6fe..a265a0f95819a 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -24,10 +24,10 @@ using Slot = calibration::TimeSlot; namespace mft { -bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& digits, +bool NoiseSlotCalibrator::processTimeFrame(calibration::TFType nTF, + gsl::span const& digits, gsl::span const& rofs) { - calibration::TFType nTF = rofs[0].getBCData().orbit / mHBFperTF; LOG(INFO) << "Processing TF# " << nTF; auto& slotTF = getSlotForTF(nTF); @@ -48,11 +48,11 @@ bool NoiseSlotCalibrator::processTimeFrame(gsl::span co return hasEnoughData(slotTF); } -bool NoiseSlotCalibrator::processTimeFrame(gsl::span const& clusters, +bool NoiseSlotCalibrator::processTimeFrame(calibration::TFType nTF, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs) { - calibration::TFType nTF = rofs[0].getBCData().orbit / 256; LOG(INFO) << "Processing TF# " << nTF; auto& slotTF = getSlotForTF(nTF); @@ -79,9 +79,6 @@ bool NoiseSlotCalibrator::processTimeFrame(gsl::span Date: Tue, 25 May 2021 13:39:41 +0200 Subject: [PATCH 21/24] Clang format --- .../MFT/calibration/include/MFTCalibration/NoiseCalibrator.h | 4 ++-- .../calibration/include/MFTCalibration/NoiseSlotCalibrator.h | 4 ++-- Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx | 4 ++-- Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx | 5 ++--- Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h index 814b51e2903b1..d8b1a1f360c6d 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibrator.h @@ -45,11 +45,11 @@ class NoiseCalibrator void setThreshold(unsigned int t) { mThreshold = t; } bool processTimeFrame(calibration::TFType tf, - gsl::span const& digits, + gsl::span const& digits, gsl::span const& rofs); bool processTimeFrame(calibration::TFType tf, - gsl::span const& clusters, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs); diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index 5e8de0f0150f0..d6f01e6d2a7ac 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -50,11 +50,11 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration const& digits, + gsl::span const& digits, gsl::span const& rofs); bool processTimeFrame(calibration::TFType tf, - gsl::span const& clusters, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs); diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx index 810a78cf99160..f86159f0222eb 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibrator.cxx @@ -23,7 +23,7 @@ namespace o2 namespace mft { bool NoiseCalibrator::processTimeFrame(calibration::TFType tf, - gsl::span const& digits, + gsl::span const& digits, gsl::span const& rofs) { static int nTF = 0; @@ -44,7 +44,7 @@ bool NoiseCalibrator::processTimeFrame(calibration::TFType tf, } bool NoiseCalibrator::processTimeFrame(calibration::TFType tf, - gsl::span const& clusters, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs) { diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index 2cfd992ddd786..741a398f904b8 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -46,7 +46,7 @@ void NoiseCalibratorSpec::init(InitContext& ic) mEnd = ic.options().get("tend"); mCalibrator = std::make_unique(probT); -// mCalibrator->setSlotLength(std::numeric_limits::max); //For TimeSlot calibration + // mCalibrator->setSlotLength(std::numeric_limits::max); //For TimeSlot calibration } void NoiseCalibratorSpec::run(ProcessingContext& pc) @@ -117,7 +117,7 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) long startTF, endTF; const auto& payload = mCalibrator->getNoiseMap(); -// const auto& payload = mCalibrator->getNoiseMap(starTF, endTF); //For TimeSlot calibration + // const auto& payload = mCalibrator->getNoiseMap(starTF, endTF); //For TimeSlot calibration o2::ccdb::CcdbObjectInfo info(mPath, "NoiseMap", "noise.root", meta, tstart, tend); auto flName = o2::ccdb::CcdbApi::generateFileName("noise"); @@ -156,7 +156,6 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "MFT_NoiseMap"}); outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBWrapper, "MFT_NoiseMap"}); - return DataProcessorSpec{ "mft-noise-calibrator", inputs, diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx index a265a0f95819a..fca4f32dac303 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseSlotCalibrator.cxx @@ -25,7 +25,7 @@ using Slot = calibration::TimeSlot; namespace mft { bool NoiseSlotCalibrator::processTimeFrame(calibration::TFType nTF, - gsl::span const& digits, + gsl::span const& digits, gsl::span const& rofs) { LOG(INFO) << "Processing TF# " << nTF; @@ -49,7 +49,7 @@ bool NoiseSlotCalibrator::processTimeFrame(calibration::TFType nTF, } bool NoiseSlotCalibrator::processTimeFrame(calibration::TFType nTF, - gsl::span const& clusters, + gsl::span const& clusters, gsl::span const& patterns, gsl::span const& rofs) { From 1429e38ce2dc45d1b12a166ce93a005de8f8bb0e Mon Sep 17 00:00:00 2001 From: mcoquet642 Date: Thu, 27 May 2021 09:53:55 +0200 Subject: [PATCH 22/24] Changes for PR --- .../MFTCalibration/NoiseSlotCalibrator.h | 3 +- .../calibration/src/NoiseCalibratorSpec.cxx | 34 ++++++------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index d6f01e6d2a7ac..a53ef78af5ac8 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -44,6 +44,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration::max); } ~NoiseSlotCalibrator() final = default; @@ -83,7 +84,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration("tend"); mCalibrator = std::make_unique(probT); - // mCalibrator->setSlotLength(std::numeric_limits::max); //For TimeSlot calibration } void NoiseCalibratorSpec::run(ProcessingContext& pc) @@ -89,30 +88,19 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) tend = o2::ccdb::getFutureTimestamp(SECONDSPERYEAR); } - auto toKeyValPairs = [](std::vector const& tokens) { - std::vector> pairs; - Str strutils; - for (auto& token : tokens) { - auto keyval = Str::tokenize(token, '=', false); - if (keyval.size() != 2) { - // LOG(FATAL) << "Illegal command-line key/value string: " << token; - continue; - } - - strutils.trim(keyval[1]); - std::pair pair = std::make_pair(keyval[0], keyval[1]); - pairs.push_back(pair); + std::map meta; + auto toKeyValPairs = [&meta](std::vector const& tokens) { + for (auto& token : tokens) { + auto keyval = Str::tokenize(token, '=', false); + if (keyval.size() != 2) { + LOG(ERROR) << "Illegal command-line key/value string: " << token; + continue; + } + Str::trim(keyval[1]); + meta[keyval[0]] = keyval[1]; } - - return pairs; }; - std::map meta; - auto keyvalues = toKeyValPairs(Str::tokenize(mMeta, ';', true)); - - // fill meta map - for (auto& p : keyvalues) { - meta[p.first] = p.second; - } + toKeyValPairs(Str::tokenize(mMeta, ';', true)); long startTF, endTF; From 661aaead7faec845712b233d83e2da27a387045b Mon Sep 17 00:00:00 2001 From: mcoquet642 Date: Thu, 27 May 2021 09:58:09 +0200 Subject: [PATCH 23/24] Clang Format --- .../MFT/calibration/src/NoiseCalibratorSpec.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index b2f03f222c845..e40d2b577fddb 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -90,14 +90,14 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) std::map meta; auto toKeyValPairs = [&meta](std::vector const& tokens) { - for (auto& token : tokens) { - auto keyval = Str::tokenize(token, '=', false); - if (keyval.size() != 2) { - LOG(ERROR) << "Illegal command-line key/value string: " << token; - continue; - } - Str::trim(keyval[1]); - meta[keyval[0]] = keyval[1]; + for (auto& amp; token : tokens) { + auto keyval = Str::tokenize(token, '=', false); + if (keyval.size() != 2) { + LOG(ERROR) << "Illegal command-line key/value string: " << token; + continue; + } + Str::trim(keyval[1]); + meta[keyval[0]] = keyval[1]; } }; toKeyValPairs(Str::tokenize(mMeta, ';', true)); From f3d0c72a21e0a18e217dc23766c7a889c1fad0a2 Mon Sep 17 00:00:00 2001 From: mcoquet642 Date: Thu, 27 May 2021 10:11:55 +0200 Subject: [PATCH 24/24] Fix typo --- Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index e40d2b577fddb..b1606e36ce2d9 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -90,7 +90,7 @@ void NoiseCalibratorSpec::sendOutput(DataAllocator& output) std::map meta; auto toKeyValPairs = [&meta](std::vector const& tokens) { - for (auto& amp; token : tokens) { + for (auto& token : tokens) { auto keyval = Str::tokenize(token, '=', false); if (keyval.size() != 2) { LOG(ERROR) << "Illegal command-line key/value string: " << token;