From bd5d2188fa199aff21e540622865591cd4c6bffb Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 15 Jan 2023 11:34:06 +0100 Subject: [PATCH 1/4] dev:trigger offsets --- .../include/CTPWorkflow/RawDecoderSpec.h | 3 ++ Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h b/Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h index ca6dc79fb2ac7..eabd1a96785d2 100644 --- a/Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h +++ b/Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h @@ -19,6 +19,7 @@ #include "Framework/Task.h" #include "DataFormatsCTP/Digits.h" #include "DataFormatsCTP/LumiInfo.h" +#include "DataFormatsCTP/TriggerOffsetsParam.h" namespace o2 { @@ -72,6 +73,8 @@ class RawDecoderSpec : public framework::Task uint32_t mNTFToIntegrate = 1; uint32_t mNHBIntegratedT = 0; uint32_t mNHBIntegratedV = 0; + uint32_t mIRRejected = 0; + uint32_t mTCRRejected = 0; std::deque mHistoryT; std::deque mHistoryV; }; diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index 4ad16e1a0cf2b..c6c41a98843d7 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -183,7 +183,7 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx) for (auto const digmap : digits) { mOutputDigits.push_back(digmap.second); } - LOG(info) << "[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits ..."; + LOG(info) << "[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits. IR rejected:" << mIRRejected << " TCR rejected:" << mTCRRejected; ctx.outputs().snapshot(o2::framework::Output{"CTP", "DIGITS", 0, o2::framework::Lifetime::Timeframe}, mOutputDigits); } if (mDoLumi) { @@ -257,14 +257,21 @@ int RawDecoderSpec::addCTPDigit(uint32_t linkCRU, uint32_t triggerOrbit, gbtword pld >>= 12; CTPDigit digit; const gbtword80_t bcidmask = 0xfff; - uint32_t bcid = (diglet & bcidmask).to_ulong(); + uint16_t bcid = (diglet & bcidmask).to_ulong(); // LOG(info) << bcid << " pld:" << pld; - o2::InteractionRecord ir; - ir.orbit = triggerOrbit; - ir.bc = bcid; - digit.intRecord = ir; + o2::InteractionRecord ir = {bcid, triggerOrbit}; + int32_t BCShiftCorrection = o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP]; if (linkCRU == o2::ctp::GBTLinkIDIntRec) { LOG(debug) << "InputMaskCount:" << digits[ir].CTPInputMask.count(); + LOG(debug) << "ir ir ori:" << ir; + if((int32_t)ir.bc < BCShiftCorrection) { + //LOG(warning) << "Loosing ir:" << ir; + mIRRejected++; + return 0; + } + ir -= BCShiftCorrection; + LOG(debug) << "ir ir corrected:" << ir; + digit.intRecord = ir; if (digits.count(ir) == 0) { digit.setInputMask(pld); digits[ir] = digit; @@ -280,6 +287,17 @@ int RawDecoderSpec::addCTPDigit(uint32_t linkCRU, uint32_t triggerOrbit, gbtword LOG(error) << "Two digits with the same rimestamp:" << ir.bc << " " << ir.orbit; } } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) { + int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1 - 1; + LOG(debug) << "tcr ir ori:" << ir; + //if(0) { + if((int32_t)ir.bc < offset) { + //LOG(warning) << "Loosing tclass:" << ir; + mTCRRejected++; + return 0; + } + ir -= offset; + LOG(debug) << "tcr ir corrected:" << ir; + digit.intRecord = ir; if (digits.count(ir) == 0) { digit.setClassMask(pld); digits[ir] = digit; From bbb4ce2389de46859182219a1db3cc5af0045aae Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 15 Jan 2023 11:34:28 +0100 Subject: [PATCH 2/4] fix: ctp config tests/improvements --- .../include/DataFormatsCTP/Configuration.h | 3 +- .../Detectors/CTP/src/Configuration.cxx | 13 +++++- Detectors/CTP/macro/CMakeLists.txt | 4 ++ Detectors/CTP/macro/TestConfig.C | 42 +++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 Detectors/CTP/macro/TestConfig.C diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index ad411df273e9d..6fd7836a498e1 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -167,7 +167,8 @@ class CTPConfiguration uint64_t getClassMaskForInputMask(uint64_t inputMask) const; void printConfigString() { std::cout << mConfigString << std::endl; }; std::string getConfigString() { return mConfigString; }; - + CTPDescriptor* getDescriptor(int index) {return &mDescriptors[index];}; + int assignDescriptors(); private: std::string mConfigString = ""; uint32_t mRunNumber = 0; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 113fa6d4a2243..be048e959c206 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -202,7 +202,7 @@ int CTPConfiguration::loadConfigurationRun3(const std::string& ctpconfiguration) } } } - // createInputsInDecriptorsFromNames(); + createInputsInDecriptorsFromNames(); return ret; } int CTPConfiguration::processConfigurationLineRun3(std::string& line, int& level, std::map>& descInputsIndex) @@ -521,6 +521,7 @@ void CTPConfiguration::createInputsInDecriptorsFromNames() index = index - 100; } // CTPInput* inp = const_cast(isInputInConfig(index)); + LOG(info) << "Desc index:" << index; const CTPInput* inp = isInputInConfig(index); if (inp) { des.inputs.push_back(inp); @@ -592,6 +593,13 @@ uint64_t CTPConfiguration::getClassMaskForInputMask(uint64_t inputMask) const } return clsmask; } +int CTPConfiguration::assignDescriptors() +{ + for (auto & cls : mCTPClasses) { + cls.descriptor = &mDescriptors[cls.descriptorIndex]; + } + return 0; +} /// /// Run Managet to manage Config and Scalers /// @@ -864,7 +872,8 @@ CTPConfiguration CTPRunManager::getConfigFromCCDB(long timestamp, std::string ru if (ctpconfigdb == nullptr) { LOG(info) << "CTP config not in database, timestamp:" << timestamp; } else { - ctpconfigdb->printStream(std::cout); + //ctpconfigdb->printStream(std::cout); + LOG(info) << "CTP config found. Run:" << run; } return *ctpconfigdb; } diff --git a/Detectors/CTP/macro/CMakeLists.txt b/Detectors/CTP/macro/CMakeLists.txt index 833531ebcfe89..18711f55f4ada 100644 --- a/Detectors/CTP/macro/CMakeLists.txt +++ b/Detectors/CTP/macro/CMakeLists.txt @@ -33,3 +33,7 @@ o2_add_test_root_macro(CheckAOD2CTPDigits.C PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP O2::CCDB LABELS ctp) +o2_add_test_root_macro(TestConfig.C + PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP + O2::CCDB + LABELS ctp) diff --git a/Detectors/CTP/macro/TestConfig.C b/Detectors/CTP/macro/TestConfig.C new file mode 100644 index 0000000000000..a05f491a8258f --- /dev/null +++ b/Detectors/CTP/macro/TestConfig.C @@ -0,0 +1,42 @@ +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include +#include +#endif +using namespace o2::ctp; + +void TestConfig(bool test = 1){ + if(test == 0) { + return; + } + uint64_t timestamp = 1660196771632; + std::string run = "523148"; + o2::ctp::CTPRunManager::setCCDBHost("https://alice-ccdb.cern.ch"); + auto ctpcfg = o2::ctp::CTPRunManager::getConfigFromCCDB(timestamp, run); + CTPConfiguration ctpconfig; + ctpconfig.loadConfigurationRun3(ctpcfg.getConfigString()); + //ctpconfig.printStream(std::cout); + //return; + //ctpconfig.assignDescriptors(); + //ctpconfig.createInputsInDecriptorsFromNames(); + ctpconfig.printStream(std::cout); + auto &triggerclasses = ctpconfig.getCTPClasses(); + std::cout << "Found " << triggerclasses.size() << " trigger classes" << std::endl; + int indexInList = 0; + for(const auto &trgclass : triggerclasses) { + uint64_t inputmask = 0; + //auto desc = ctpconfig.getDescriptor(trgclass.descriptorIndex); + //std::cout << "desc index:" << trgclass.descriptorIndex << " " << desc << std::endl; + if(trgclass.descriptor != nullptr){ + inputmask = trgclass.descriptor->getInputsMask(); + std::cout << "inputmask:" << std::hex << inputmask << std::dec << std::endl; + } + trgclass.printStream(std::cout); + std::cout << indexInList << ": " << trgclass.name << ", input mask 0x" << std::hex << inputmask << ", class mask 0x" << trgclass.classMask << std::dec << std::endl; + indexInList++; + if(trgclass.cluster->getClusterDetNames().find("EMC") != std::string::npos) { + std::cout << "Found EMCAL trigger cluster, class mask: 0x" << std::hex << trgclass.classMask << std::dec << std::endl; + } + } + auto classmask = ctpconfig.getClassMaskForInputMask(0x4); + std::cout << "Found class mask " << classmask << std::endl; +} From dbe74009417eba749c57618f41b8ee9e986860b4 Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 15 Jan 2023 11:35:47 +0100 Subject: [PATCH 3/4] clang --- .../include/DataFormatsCTP/Configuration.h | 3 +- .../Detectors/CTP/src/Configuration.cxx | 4 +- Detectors/CTP/macro/TestConfig.C | 67 ++++++++++--------- Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 10 +-- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 6fd7836a498e1..432566cb58261 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -167,8 +167,9 @@ class CTPConfiguration uint64_t getClassMaskForInputMask(uint64_t inputMask) const; void printConfigString() { std::cout << mConfigString << std::endl; }; std::string getConfigString() { return mConfigString; }; - CTPDescriptor* getDescriptor(int index) {return &mDescriptors[index];}; + CTPDescriptor* getDescriptor(int index) { return &mDescriptors[index]; }; int assignDescriptors(); + private: std::string mConfigString = ""; uint32_t mRunNumber = 0; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index be048e959c206..ef06692900de5 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -595,7 +595,7 @@ uint64_t CTPConfiguration::getClassMaskForInputMask(uint64_t inputMask) const } int CTPConfiguration::assignDescriptors() { - for (auto & cls : mCTPClasses) { + for (auto& cls : mCTPClasses) { cls.descriptor = &mDescriptors[cls.descriptorIndex]; } return 0; @@ -872,7 +872,7 @@ CTPConfiguration CTPRunManager::getConfigFromCCDB(long timestamp, std::string ru if (ctpconfigdb == nullptr) { LOG(info) << "CTP config not in database, timestamp:" << timestamp; } else { - //ctpconfigdb->printStream(std::cout); + // ctpconfigdb->printStream(std::cout); LOG(info) << "CTP config found. Run:" << run; } return *ctpconfigdb; diff --git a/Detectors/CTP/macro/TestConfig.C b/Detectors/CTP/macro/TestConfig.C index a05f491a8258f..aed18ff8072e6 100644 --- a/Detectors/CTP/macro/TestConfig.C +++ b/Detectors/CTP/macro/TestConfig.C @@ -4,39 +4,40 @@ #endif using namespace o2::ctp; -void TestConfig(bool test = 1){ - if(test == 0) { - return; +void TestConfig(bool test = 1) +{ + if (test == 0) { + return; + } + uint64_t timestamp = 1660196771632; + std::string run = "523148"; + o2::ctp::CTPRunManager::setCCDBHost("https://alice-ccdb.cern.ch"); + auto ctpcfg = o2::ctp::CTPRunManager::getConfigFromCCDB(timestamp, run); + CTPConfiguration ctpconfig; + ctpconfig.loadConfigurationRun3(ctpcfg.getConfigString()); + // ctpconfig.printStream(std::cout); + // return; + // ctpconfig.assignDescriptors(); + // ctpconfig.createInputsInDecriptorsFromNames(); + ctpconfig.printStream(std::cout); + auto& triggerclasses = ctpconfig.getCTPClasses(); + std::cout << "Found " << triggerclasses.size() << " trigger classes" << std::endl; + int indexInList = 0; + for (const auto& trgclass : triggerclasses) { + uint64_t inputmask = 0; + // auto desc = ctpconfig.getDescriptor(trgclass.descriptorIndex); + // std::cout << "desc index:" << trgclass.descriptorIndex << " " << desc << std::endl; + if (trgclass.descriptor != nullptr) { + inputmask = trgclass.descriptor->getInputsMask(); + std::cout << "inputmask:" << std::hex << inputmask << std::dec << std::endl; } - uint64_t timestamp = 1660196771632; - std::string run = "523148"; - o2::ctp::CTPRunManager::setCCDBHost("https://alice-ccdb.cern.ch"); - auto ctpcfg = o2::ctp::CTPRunManager::getConfigFromCCDB(timestamp, run); - CTPConfiguration ctpconfig; - ctpconfig.loadConfigurationRun3(ctpcfg.getConfigString()); - //ctpconfig.printStream(std::cout); - //return; - //ctpconfig.assignDescriptors(); - //ctpconfig.createInputsInDecriptorsFromNames(); - ctpconfig.printStream(std::cout); - auto &triggerclasses = ctpconfig.getCTPClasses(); - std::cout << "Found " << triggerclasses.size() << " trigger classes" << std::endl; - int indexInList = 0; - for(const auto &trgclass : triggerclasses) { - uint64_t inputmask = 0; - //auto desc = ctpconfig.getDescriptor(trgclass.descriptorIndex); - //std::cout << "desc index:" << trgclass.descriptorIndex << " " << desc << std::endl; - if(trgclass.descriptor != nullptr){ - inputmask = trgclass.descriptor->getInputsMask(); - std::cout << "inputmask:" << std::hex << inputmask << std::dec << std::endl; - } - trgclass.printStream(std::cout); - std::cout << indexInList << ": " << trgclass.name << ", input mask 0x" << std::hex << inputmask << ", class mask 0x" << trgclass.classMask << std::dec << std::endl; - indexInList++; - if(trgclass.cluster->getClusterDetNames().find("EMC") != std::string::npos) { - std::cout << "Found EMCAL trigger cluster, class mask: 0x" << std::hex << trgclass.classMask << std::dec << std::endl; - } + trgclass.printStream(std::cout); + std::cout << indexInList << ": " << trgclass.name << ", input mask 0x" << std::hex << inputmask << ", class mask 0x" << trgclass.classMask << std::dec << std::endl; + indexInList++; + if (trgclass.cluster->getClusterDetNames().find("EMC") != std::string::npos) { + std::cout << "Found EMCAL trigger cluster, class mask: 0x" << std::hex << trgclass.classMask << std::dec << std::endl; } - auto classmask = ctpconfig.getClassMaskForInputMask(0x4); - std::cout << "Found class mask " << classmask << std::endl; + } + auto classmask = ctpconfig.getClassMaskForInputMask(0x4); + std::cout << "Found class mask " << classmask << std::endl; } diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index c6c41a98843d7..d0ae1961c6b31 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -264,8 +264,8 @@ int RawDecoderSpec::addCTPDigit(uint32_t linkCRU, uint32_t triggerOrbit, gbtword if (linkCRU == o2::ctp::GBTLinkIDIntRec) { LOG(debug) << "InputMaskCount:" << digits[ir].CTPInputMask.count(); LOG(debug) << "ir ir ori:" << ir; - if((int32_t)ir.bc < BCShiftCorrection) { - //LOG(warning) << "Loosing ir:" << ir; + if ((int32_t)ir.bc < BCShiftCorrection) { + // LOG(warning) << "Loosing ir:" << ir; mIRRejected++; return 0; } @@ -289,9 +289,9 @@ int RawDecoderSpec::addCTPDigit(uint32_t linkCRU, uint32_t triggerOrbit, gbtword } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) { int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1 - 1; LOG(debug) << "tcr ir ori:" << ir; - //if(0) { - if((int32_t)ir.bc < offset) { - //LOG(warning) << "Loosing tclass:" << ir; + // if(0) { + if ((int32_t)ir.bc < offset) { + // LOG(warning) << "Loosing tclass:" << ir; mTCRRejected++; return 0; } From 0c848072fbd44bd68f536770e2ea97c6f04ba333 Mon Sep 17 00:00:00 2001 From: lietava Date: Sun, 15 Jan 2023 11:57:13 +0100 Subject: [PATCH 4/4] fix: copyright added --- Detectors/CTP/macro/TestConfig.C | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Detectors/CTP/macro/TestConfig.C b/Detectors/CTP/macro/TestConfig.C index aed18ff8072e6..0ff91c514ee93 100644 --- a/Detectors/CTP/macro/TestConfig.C +++ b/Detectors/CTP/macro/TestConfig.C @@ -1,10 +1,21 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + #if !defined(__CLING__) || defined(__ROOTCLING__) #include #include #endif using namespace o2::ctp; -void TestConfig(bool test = 1) +void TestConfig(bool test = 0) { if (test == 0) { return;