diff --git a/core/base/utils/CbmMcbmUtils.cxx b/core/base/utils/CbmMcbmUtils.cxx index 291f600470154ddb82c9c37b48215047bf289973..1d051bd498aa4cbf8aef7c25f5c84acc39d68257 100644 --- a/core/base/utils/CbmMcbmUtils.cxx +++ b/core/base/utils/CbmMcbmUtils.cxx @@ -47,6 +47,11 @@ namespace cbm /// High Rate Gold runs with GEMs in Acceptance: 2498 - 2610 = 18/06/2022 - 20/06/2022 sSetupName = "mcbm_beam_2022_06_18_gold"; } + else if (2724 <= ulRunId) { + /// Dummy needed to run the unpack macro until we have a setup ready + /// FIXME: replace with 2024 setup!!!!! + sSetupName = "mcbm_beam_2022_06_16_gold"; + } else if (2611 < ulRunId) { /// Future runs, exception there to force implementation and support from users side throw(std::invalid_argument("RunId bigger than latest run mapped (2611, mCBM 2022)! Please complete the map!")); diff --git a/core/detectors/tof/CbmMcbm2018TofPar.cxx b/core/detectors/tof/CbmMcbm2018TofPar.cxx index 1674f521043c28a074ec2f6033b9754d29009ac6..1a1b46ef7ca9347d75231e423971e497e4993ef4 100644 --- a/core/detectors/tof/CbmMcbm2018TofPar.cxx +++ b/core/detectors/tof/CbmMcbm2018TofPar.cxx @@ -85,6 +85,7 @@ void CbmMcbm2018TofPar::clear() void CbmMcbm2018TofPar::putParams(FairParamList* l) { if (!l) return; + l->add("McbmTof2024", fbMcbmTof2024); l->add("NrOfGdpbs", fiNrOfGdpb); l->add("GdpbIdArray", fiGdpbIdArray); l->add("NrOfFeesPerGdpb", fiNrOfFeesPerGdpb); @@ -112,6 +113,12 @@ Bool_t CbmMcbm2018TofPar::getParams(FairParamList* l) if (!l) return kFALSE; + /// Optional flag for mCBM 2024 + l->fill("McbmTof2024", &fbMcbmTof2024); + if (fbMcbmTof2024) { + LOG(info) << "CbmMcbm2018TofPar::getParams => Using mTOF 2024 mapping checks!"; + } + if (!l->fill("NrOfGdpbs", &fiNrOfGdpb)) return kFALSE; fiGdpbIdArray.Set(fiNrOfGdpb); @@ -176,9 +183,12 @@ Int_t CbmMcbm2018TofPar::PadiChanToGet4Chan(UInt_t uChannelInFee) // ------------------------------------------------------------------------- Int_t CbmMcbm2018TofPar::ElinkIdxToGet4Idx(UInt_t uElink) { - if (gdpbv100::kuChipIdMergedEpoch == uElink) return uElink; - else if (uElink < kuNbGet4PerGdpb) + if (gdpbv100::kuChipIdMergedEpoch == uElink) { + return uElink; + } + else if (uElink < kuNbGet4PerGdpb) { return kuElinkToGet4[uElink % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElink / kuNbGet4PerGbtx); + } else { LOG(fatal) << "CbmMcbm2018TofPar::ElinkIdxToGet4Idx => Index out of bound, " << uElink << " vs " << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; @@ -187,15 +197,46 @@ Int_t CbmMcbm2018TofPar::ElinkIdxToGet4Idx(UInt_t uElink) } Int_t CbmMcbm2018TofPar::Get4IdxToElinkIdx(UInt_t uGet4) { - if (gdpbv100::kuChipIdMergedEpoch == uGet4) return uGet4; - else if (uGet4 < kuNbGet4PerGdpb) + if (gdpbv100::kuChipIdMergedEpoch == uGet4) { + return uGet4; + } + else if (uGet4 < kuNbGet4PerGdpb) { return kuGet4ToElink[uGet4 % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4 / kuNbGet4PerGbtx); + } else { LOG(fatal) << "CbmMcbm2018TofPar::Get4IdxToElinkIdx => Index out of bound, " << uGet4 << " vs " << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; return -1; } // else of if( uElink < kuNbGet4PerGbtx ) } +Int_t CbmMcbm2018TofPar::ElinkIdxToGet4IdxA(UInt_t uElink) +{ + if (gdpbv100::kuChipIdMergedEpoch == uElink) { + return uElink; + } + else if (uElink < kuNbGet4PerGdpb) { + return kuElinkToGet4A[uElink % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElink / kuNbGet4PerGbtx); + } + else { + LOG(fatal) << "CbmMcbm2018TofPar::ElinkIdxToGet4IdxA => Index out of bound, " << uElink << " vs " + << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; + return -1; + } // else of if( uElink < kuNbGet4PerGbtx ) +} +Int_t CbmMcbm2018TofPar::Get4IdxToElinkIdxA(UInt_t uGet4) +{ + if (gdpbv100::kuChipIdMergedEpoch == uGet4) { + return uGet4; + } + else if (uGet4 < kuNbGet4PerGdpb) { + return kuGet4ToElinkA[uGet4 % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4 / kuNbGet4PerGbtx); + } + else { + LOG(fatal) << "CbmMcbm2018TofPar::Get4IdxToElinkIdxA => Index out of bound, " << uGet4 << " vs " + << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; + return -1; + } // else of if( uElink < kuNbGet4PerGbtx ) +} // ------------------------------------------------------------------------- Double_t CbmMcbm2018TofPar::GetPadiThresholdVal(UInt_t uCode) { @@ -214,9 +255,16 @@ void CbmMcbm2018TofPar::BuildChannelsUidMap() UInt_t uNrOfChannels = uNrOfGet4 * fiNrOfChannelsPerGet4; fviRpcChUId.resize(uNrOfChannels); + UInt_t nbRobPerComp = 2; // number of Gbtx per Gdpb (flim) for the final channel count check + if (fbMcbmTof2024) { + // Hack for 2024 TOF mapping + nbRobPerComp = 1; + } + UInt_t uCh = 0; for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx) { - uint32_t uCh0 = uCh; + uint32_t uCh0 = uCh; + uint32_t uGdpb = uCh0 / (fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4); switch (fiRpcType[uGbtx]) { case 2: // intended fall-through case 0: { @@ -254,12 +302,22 @@ void CbmMcbm2018TofPar::BuildChannelsUidMap() case 7: [[fallthrough]]; case 9: // Star2 boxes { - BuildChannelsUidMapStar2(uCh, uGbtx); + if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) { + BuildChannelsUidMapStar2A(uCh, uGbtx); + } + else { + BuildChannelsUidMapStar2(uCh, uGbtx); + } break; } case 6: // Buc box { - BuildChannelsUidMapBuc(uCh, uGbtx); + if ((fiGdpbIdArray[uGdpb] & 0xF000) == 0xB000) { + BuildChannelsUidMapStar2A(uCh, uGbtx); + } + else { + BuildChannelsUidMapBuc(uCh, uGbtx); + } break; } case 69: { @@ -280,8 +338,10 @@ void CbmMcbm2018TofPar::BuildChannelsUidMap() LOG(error) << "Invalid Tof Type specifier for GBTx " << std::setw(2) << uGbtx << ": " << fiRpcType[uGbtx]; } } // switch (fiRpcType[uGbtx]) - if ((int32_t)(uCh - uCh0) != fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4 / 2) { - LOG(fatal) << "Tof mapping error for Gbtx " << uGbtx << ", diff = " << uCh - uCh0; + if ((int32_t)(uCh - uCh0) != fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4 / nbRobPerComp) { + LOG(fatal) << "Tof mapping error for Gbtx " << uGbtx << ", diff = " << uCh - uCh0 << ", expected " + << fiNrOfFeesPerGdpb * fiNrOfGet4PerFee * fiNrOfChannelsPerGet4 / nbRobPerComp + << " with nbRobPerFlim = " << nbRobPerComp; } } // for (UInt_t uGbtx = 0; uGbtx < uNrOfGbtx; ++uGbtx) } @@ -491,6 +551,95 @@ void CbmMcbm2018TofPar::BuildChannelsUidMapStar2(UInt_t& uCh, UInt_t uGbtx) } } // ------------------------------------------------------------------------- +void CbmMcbm2018TofPar::BuildChannelsUidMapStar2A(UInt_t& uCh, UInt_t uGbtx) +{ + LOG(info) << " Map Star2A box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh << " for type " + << fiRpcType[uGbtx]; + if (fiRpcSide[uGbtx] < 3) { + Int_t NrFeet = 2; + if (fiRpcSide[uGbtx] < 2) NrFeet = 1; + Int_t iFeet = 0; + for (; iFeet < NrFeet; iFeet++) { + for (Int_t iStr = 0; iStr < 32; iStr++) { + Int_t iStrMap = iStr; + Int_t iRpcMap = fiNrOfRpc[uGbtx]; + Int_t iSideMap = fiRpcSide[uGbtx]; + if (fiRpcSide[uGbtx] == 2) { + if (iFeet == 0) + iSideMap = 0; + else + iSideMap = 1; + } + else { + if (fiRpcSide[uGbtx] == 3) { + if (iFeet == 0) + iSideMap = 1; + else + iSideMap = 0; + } + } + if (fiRpcType[uGbtx] != 6) + if (iSideMap == 0) iStrMap = 31 - iStr; + + if (iSideMap > -1) + fviRpcChUId[uCh] = + CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]); + else + fviRpcChUId[uCh] = 0; + + uCh++; + } + } + while (iFeet < 2) { + for (Int_t iStr = 0; iStr < 32; iStr++) { + fviRpcChUId[uCh] = 0; + uCh++; + } + iFeet++; + } + } + else { + if (fiRpcSide[uGbtx] == 3) { + int iSideMap = -1; + int iStrMap = -1; + int iRpcMap = -1; + for (Int_t iFeet = 0; iFeet < 5; iFeet++) { + for (Int_t iStr = 0; iStr < 32; iStr++) { + switch (iFeet) { + case 0: iSideMap = -1; break; + case 1: + iRpcMap = 0; + iStrMap = iStr; + iSideMap = 0; + break; + case 2: + iRpcMap = 0; + iStrMap = iStr; + iSideMap = 1; + break; + case 3: + iRpcMap = 1; + iStrMap = iStr; + iSideMap = 0; + break; + case 4: + iRpcMap = 1; + iStrMap = iStr; + iSideMap = 1; + break; + } + if (iSideMap > -1) + fviRpcChUId[uCh] = + CbmTofAddress::GetUniqueAddress(fiModuleId[uGbtx], iRpcMap, iStrMap, iSideMap, fiRpcType[uGbtx]); + else + fviRpcChUId[uCh] = 0; + uCh++; + } + } + } + } +} +// ------------------------------------------------------------------------- void CbmMcbm2018TofPar::BuildChannelsUidMapBuc(UInt_t& uCh, UInt_t uGbtx) { LOG(info) << " Map Buc box " << fiModuleId[uGbtx] << " at GBTX " << uGbtx << " - uCh = " << uCh; diff --git a/core/detectors/tof/CbmMcbm2018TofPar.h b/core/detectors/tof/CbmMcbm2018TofPar.h index a1ae088ab4eab93118d646825fc1bf7fcfdbb7e3..31660932c8f845e638bb2b9d166abe3886abad6f 100644 --- a/core/detectors/tof/CbmMcbm2018TofPar.h +++ b/core/detectors/tof/CbmMcbm2018TofPar.h @@ -43,6 +43,8 @@ public: Int_t ElinkIdxToGet4Idx(UInt_t uElink); Int_t Get4IdxToElinkIdx(UInt_t uGet4); + Int_t ElinkIdxToGet4IdxA(UInt_t uElink); + Int_t Get4IdxToElinkIdxA(UInt_t uGet4); static constexpr UInt_t GetNrOfPadiThrCodes() { return kuNbPadiThrCodes; } Double_t GetPadiThresholdVal(UInt_t uCode); @@ -83,7 +85,10 @@ public: inline Double_t GetStarTriggWinSize(Int_t gdpb) { return fdStarTriggerWinSize[gdpb]; } inline Double_t GetTsDeadtimePeriod() { return fdTsDeadtimePeriod; } -private: + inline bool CheckBmonComp(uint32_t uCompId) { return ((uCompId & 0xFFF0) == 0xABF0); } + inline bool CheckInnerComp(uint32_t uCompId) { return ((uCompId & 0xFFF0) == 0xBBC0); } + + private: void BuildChannelsUidMap(); void BuildChannelsUidMapCbm(UInt_t& uCh, UInt_t uGbtx); void BuildChannelsUidMapStar(UInt_t& uCh, UInt_t uGbtx); @@ -92,6 +97,7 @@ private: void BuildChannelsUidMapCern(UInt_t& uCh, UInt_t uGbtx); void BuildChannelsUidMapCera(UInt_t& uCh, UInt_t uGbtx); void BuildChannelsUidMapStar2(UInt_t& uCh, UInt_t uGbtx); + void BuildChannelsUidMapStar2A(UInt_t& uCh, UInt_t uGbtx); void BuildChannelsUidMapBuc(UInt_t& uCh, UInt_t uGbtx); /// Constants @@ -123,6 +129,12 @@ private: 13, 15, 18, 16, 28, 34, 26, 17, 29, 27, 23, 22, 5, 0, 30, 32, 6, 4, 10, 8, 20, 19, 35, 9, 21, 36}; + const UInt_t kuElinkToGet4A[kuNbGet4PerGbtx] = {0, 16, 8, 17, 1, 18, 9, 19, 2, 20, 10, 21, 3, 22, + 11, 23, 4, 24, 12, 25, 5, 26, 13, 27, 6, 28, 14, 29, + 7, 30, 15, 31, 32, 33, 34, 35, 36, 37, 38, 39}; + const UInt_t kuGet4ToElinkA[kuNbGet4PerGbtx] = {0, 4, 8, 12, 16, 20, 24, 28, 2, 6, 10, 14, 18, 22, + 26, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, + 25, 27, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39}; /// PADI threshold measures and extrapolated code to value map static const uint32_t kuNbPadiThrCodes = 1024; // 0x3FF + 1 static const uint32_t kuNbThrMeasPoints = 65; @@ -140,6 +152,8 @@ private: 402.9, 422.8, 443.4, 463.7, 483.7, 503.7, 524.1, 544.3, 565.0, 585.0, 605.5, 626.0, 646.1}; std::vector<Double_t> fvdPadiThrCodeToValue; + Int_t fbMcbmTof2024 = 0; + Int_t fiNrOfGdpb; // Total number of GDPBs TArrayI fiGdpbIdArray; // Array to hold the unique IDs for all Tof GDPBs diff --git a/macro/beamtime/mcbm2023/mBmonCriPar.par b/macro/beamtime/mcbm2023/mBmonCriPar.par new file mode 100644 index 0000000000000000000000000000000000000000..73ac789cd76bb323e1fca122fc96b20a10457173 --- /dev/null +++ b/macro/beamtime/mcbm2023/mBmonCriPar.par @@ -0,0 +1,35 @@ +#################################################################################################### +[CbmMcbm2018BmonPar] +//---------------------------------------------------------------------------- +NrOfGdpbs: Int_t 4 +GdpbIdArray: Int_t \ +0xabf0 0xabf1 0xabf2 0xabf3 +//0xabf3 0xabf2 0xabf1 0xabf0 +NrOfFeesPerGdpb: Int_t 10 +NrOfGet4PerFee: Int_t 8 +NrOfChannelsPerGet4: Int_t 4 +NrOfGbtx: Int_t 8 +NrOfModule: Int_t 0 +NrOfRpc: Int_t \ + 1 1 1 1 +RpcType: Int_t \ + 99 -1 99 -1 99 -1 99 -1 +RpcSide: Int_t \ + 0 0 0 0 0 0 0 0 +ModuleId: Int_t \ + 0 -1 0 -1 0 -1 0 -1 +NbMsTot: Int_t 100 +NbMsOverlap: Int_t 1 +SizeMsInNs: Double_t 102400.0 +//SizeMsInNs: Double_t 1638400 +StarTriggerDeadtime: Double_t \ + 1000.0 1000.0 1000.0 1000.0 1000.0 +StarTriggerDelay: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +// 2000.0 2000.0 2000.0 2000.0 2000.0 +//-23000.0 -23000.0 -23000.0 -23000.0 -23000.0 +StarTriggerWinSize: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +TsDeadtimePeriod: Double_t 62.5 + +#################################################################################################### diff --git a/macro/beamtime/mcbm2023/monitor_bmon_microspills.C b/macro/beamtime/mcbm2023/monitor_bmon_microspills.C new file mode 100644 index 0000000000000000000000000000000000000000..af0b85d284202d0e450b4a46969350243fcb3ffa --- /dev/null +++ b/macro/beamtime/mcbm2023/monitor_bmon_microspills.C @@ -0,0 +1,279 @@ +/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Pierre-Alain Loizeau [committer] */ + +/** @file run_unpack_tsa.C + ** @author Volker Friese <v.friese@gsi.de> + ** @since May 2021 + **/ + + +// --- Includes needed for IDE +#include <RtypesCore.h> + +#include <cstdint> +#include <memory> +#include <string> +#include <vector> +#if !defined(__CLING__) +#include <FairLogger.h> +#include <FairRootFileSink.h> +#include <FairRunOnline.h> +#include <Logger.h> + +#include <TStopwatch.h> +#include <TSystem.h> +#endif + +std::shared_ptr<CbmTofUnpackMonitor> GetTofMonitor(std::string treefilename, bool bBmonMode = false); +std::string defaultSetupName = "mcbm_beam_2021_07_surveyed"; + +void monitor_bmon_microspills(std::vector<std::string> inputurl, UInt_t runid = 0, std::int32_t nevents = -1, + Int_t serverHttpPort = 8090, Int_t serverRefreshRate = 1, + std::string setupName = defaultSetupName, std::string outpath = "data/") +{ + + // ======================================================================== + // Adjust this part according to your requirements + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "INFO"; + TString logVerbosity = "LOW"; + // ------------------------------------------------------------------------ + + // ----- Environment -------------------------------------------------- + TString myName = "monitor_bmon_microspills"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + // ----- Output filename ---------------------------------------------- + std::string filename = Form("online_%05d.digi.root", runid); + std::string outfilename = outpath + filename; + if (inputurl[0].npos == inputurl[0].find("tcp://")) { + outfilename = inputurl[0]; + auto filenamepos = inputurl[0].find_last_of("/"); + if (inputurl[0].npos != filenamepos) { + filenamepos++; + } + else { + filenamepos = 0; + } + filename = inputurl[0].substr(filenamepos); + if (filename.find("*") != inputurl[0].npos) filename = std::to_string(runid) + ".tsa"; + if (filename.find(";") != inputurl[0].npos) filename = std::to_string(runid) + "_merged" + ".tsa"; + filename.replace(filename.find(".tsa"), 4, ".digi.root"); + if (outpath.empty()) { + auto multi_delim = inputurl[0].find_last_of(";"); + if (inputurl[0].npos != multi_delim) { + multi_delim++; + } + else { + multi_delim = 0; + } + outpath = inputurl[0].substr(multi_delim, filenamepos - multi_delim); + } + outfilename = outpath + filename; + } + std::cout << "-I- " << myName << ": Output file will be " << outfilename << std::endl; + // ------------------------------------------------------------------------ + + + // ----- Performance profiling ---------------------------------------- + // Set to true if you want some minimal performance profiling output + bool doPerfProfiling = true; + // Define if you want a special path and name for the performance profiling output file + std::string perfProfFileName = outpath + filename; + perfProfFileName.replace(perfProfFileName.find(".digi.root"), 10, ".perf.root"); + // ------------------------------------------------------------------------ + + + // ----- CbmSetup ----------------------------------------------------- + /// Do automatic mapping only if not overridden by user or empty + if (defaultSetupName == setupName || "" == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; + } + if (defaultSetupName != setupName) { + std::cout << "Automatic setup choice for run " << runid << ": " << setupName << std::endl; + } + } + auto cbmsetup = CbmSetup::Instance(); + cbmsetup->LoadSetup(setupName.c_str()); + // ------------------------------------------------------------------------ + + // ----- UnpackerConfigs ---------------------------------------------- + + // ---- BMON ---- + std::shared_ptr<CbmBmonUnpackConfig> bmonconfig = nullptr; + + bmonconfig = std::make_shared<CbmBmonUnpackConfig>("", runid); + if (bmonconfig) { + // bmonconfig->SetDebugState(); + // bmonconfig->SetDoWriteOutput(); + // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors"); + std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2023/", srcDir.Data()); + bmonconfig->SetParFilesBasePath(parfilesbasepathBmon); + bmonconfig->SetParFileName("mBmonCriPar.par"); + bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated + if (2160 <= runid) { + bmonconfig->SetSystemTimeOffset(-80); // [ns] value to be updated + } + if (2350 <= runid) { + bmonconfig->SetSystemTimeOffset(0); // [ns] value to be updated + } + /// Enable Monitor plots + bmonconfig->SetMonitor(GetTofMonitor(outfilename, true)); + if (2337 <= runid) { + bmonconfig->GetMonitor()->SetSpillThreshold(250); + bmonconfig->GetMonitor()->SetSpillThresholdNonPulser(100); + } + } + // ------------- + + + // ------------------------------------------------------------------------ + + // In general, the following parts need not be touched + // ======================================================================== + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + // ----- CbmSourceTsArchive ------------------------------------------- + std::unique_ptr<CbmSourceTsArchive> source = std::unique_ptr<CbmSourceTsArchive>(new CbmSourceTsArchive(inputurl)); + //source->SetDebugPrintout(); + auto unpack = source->GetRecoUnpack(); + //unpack->SetDoPerfProfiling(doPerfProfiling); + //unpack->SetOutputFilename(perfProfFileName); + // Enable full time sorting instead sorting per FLIM link + //unpack->SetTimeSorting(true); + unpack->SetMonitoringOnly(true); + + if (bmonconfig) unpack->SetUnpackConfig(bmonconfig); + // ------------------------------------------------------------------------ + + // ----- FairRunAna --------------------------------------------------- + auto run = new FairRunOnline(source.get()); + auto sink = new FairRootFileSink(outfilename.data()); + run->SetSink(sink); + auto eventheader = new CbmTsEventHeader(); + run->SetRunId(runid); + run->SetEventHeader(eventheader); + // ------------------------------------------------------------------------ + + + // ----- HttpServer for online monitoring ----------------------------- + run->ActivateHttpServer(serverRefreshRate, serverHttpPort); + run->GetHttpServer()->GetSniffer()->SetScanGlobalDir(kFALSE); + //run->SetAutoFinish(kFALSE); + // ------------------------------------------------------------------------ + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; + run->Init(); + // ------------------------------------------------------------------------ + + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; + if (nevents < 0) { + std::cout << "-I- " << myName << ": running until end of file" << std::endl; + run->Run(-1, 0); + } + else { + std::cout << "-I- " << myName << ": running for " << nevents << " timeslices " << std::endl; + run->Run(0, nevents); + } + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + std::cout << "Macro finished successfully." << std::endl; + std::cout << "After CpuTime = " << timer.CpuTime() << " s RealTime = " << timer.RealTime() << " s." << std::endl; + // ------------------------------------------------------------------------ + + // -- Release all shared pointers to config before ROOT destroys things - + // => We need to destroy things by hand because run->Finish calls (through the FairRootManager) Source->Close which + // does call the Source destructor, so due to share pointer things stay alive until out of macro scope... + run->SetSource(nullptr); + delete run; + + bmonconfig.reset(); + // ------------------------------------------------------------------------ + +} // End of main macro function + + +/** + * @brief Get the Tof Monitor. Extra function to keep default macro part more silent. + * @return std::shared_ptr<CbmTofUnpackMonitor> +*/ +std::shared_ptr<CbmTofUnpackMonitor> GetTofMonitor(std::string treefilename, bool bBmonMode = false) +{ + // ----- Output filename and path ------------------------------------- + std::string outpath = ""; + std::string filename = ""; + auto filenamepos = treefilename.find_last_of("/"); + if (filenamepos != treefilename.npos) { + outpath = treefilename.substr(0, filenamepos); + filename = treefilename.substr(filenamepos++); + } + if (outpath.empty()) outpath = gSystem->GetWorkingDirectory(); + //std::string mydir = "/qa"; + //outpath += mydir; + + auto currentdir = gSystem->GetWorkingDirectory(); + + if (!gSystem->cd(outpath.data())) { + gSystem->MakeDirectory(outpath.data()); + } + else { + gSystem->cd(currentdir.data()); + } + + std::string sSystemType = ".mon.tof.root"; + if (bBmonMode) { + // + sSystemType = ".mon.bmon.root"; + } + + std::string outfilename = outpath + filename; + auto filetypepos = outfilename.find(".digi.root"); + if (filetypepos != outfilename.npos) { + outfilename.replace(filetypepos, 10, sSystemType); + } + else { + outfilename += sSystemType; + } + // ------------------------------------------------------------------------ + + auto monitor = std::make_shared<CbmTofUnpackMonitor>(); + monitor->SetHistoFileName(outfilename); + monitor->SetBmonMicroSpillMode(bBmonMode); + return monitor; +} + +void monitor_bmon_microspills(std::string inputurl = "tcp://localhost:5556", UInt_t runid = 0, + std::int32_t nevents = -1, Int_t serverHttpPort = 8090, Int_t serverRefreshRate = 1, + std::string setupName = defaultSetupName, std::string outpath = "data/") +{ + std::vector<std::string> vInUrl = {inputurl}; + return monitor_bmon_microspills(vInUrl, runid, nevents, serverHttpPort, serverRefreshRate, setupName, outpath); +} diff --git a/macro/beamtime/mcbm2024/mBmonCriPar.par b/macro/beamtime/mcbm2024/mBmonCriPar.par new file mode 100644 index 0000000000000000000000000000000000000000..73ac789cd76bb323e1fca122fc96b20a10457173 --- /dev/null +++ b/macro/beamtime/mcbm2024/mBmonCriPar.par @@ -0,0 +1,35 @@ +#################################################################################################### +[CbmMcbm2018BmonPar] +//---------------------------------------------------------------------------- +NrOfGdpbs: Int_t 4 +GdpbIdArray: Int_t \ +0xabf0 0xabf1 0xabf2 0xabf3 +//0xabf3 0xabf2 0xabf1 0xabf0 +NrOfFeesPerGdpb: Int_t 10 +NrOfGet4PerFee: Int_t 8 +NrOfChannelsPerGet4: Int_t 4 +NrOfGbtx: Int_t 8 +NrOfModule: Int_t 0 +NrOfRpc: Int_t \ + 1 1 1 1 +RpcType: Int_t \ + 99 -1 99 -1 99 -1 99 -1 +RpcSide: Int_t \ + 0 0 0 0 0 0 0 0 +ModuleId: Int_t \ + 0 -1 0 -1 0 -1 0 -1 +NbMsTot: Int_t 100 +NbMsOverlap: Int_t 1 +SizeMsInNs: Double_t 102400.0 +//SizeMsInNs: Double_t 1638400 +StarTriggerDeadtime: Double_t \ + 1000.0 1000.0 1000.0 1000.0 1000.0 +StarTriggerDelay: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +// 2000.0 2000.0 2000.0 2000.0 2000.0 +//-23000.0 -23000.0 -23000.0 -23000.0 -23000.0 +StarTriggerWinSize: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +TsDeadtimePeriod: Double_t 62.5 + +#################################################################################################### diff --git a/macro/beamtime/mcbm2024/mTofCriPar.par b/macro/beamtime/mcbm2024/mTofCriPar.par new file mode 100644 index 0000000000000000000000000000000000000000..9e402cb4bcf24dd9c663cc52afc42e5d0e0dfcaa --- /dev/null +++ b/macro/beamtime/mcbm2024/mTofCriPar.par @@ -0,0 +1,36 @@ +#################################################################################################### +[CbmMcbm2018TofPar] +//---------------------------------------------------------------------------- +McbmTof2024: Int_t 1 +NrOfGdpbs: Int_t 15 +GdpbIdArray: Int_t \ +0xabc0 0xabc1 0xabc2 0xabc3 0xabc4 0xabc5 0xabc6 0xabc7 0xabc8 0xabc9 0xabca 0xabcb 0xabcc 0xabcd 0xbbc0 +NrOfFeesPerGdpb: Int_t 5 +NrOfGet4PerFee: Int_t 8 +NrOfChannelsPerGet4: Int_t 4 +NrOfGbtx: Int_t 15 +NrOfModule: Int_t 3 +// NrOfRpc used as RpcId +NrOfRpc: Int_t \ + 5 5 5 5 5 5 5 5 5 5 5 5 2 2 5 +RpcType: Int_t \ + 0 0 0 0 0 0 0 0 0 0 2 2 9 9 6 +RpcSide: Int_t \ + 0 1 0 1 0 1 0 1 0 1 0 1 2 2 3 +ModuleId: Int_t \ + 0 0 1 1 2 2 3 3 4 4 0 0 0 1 0 +NbMsTot: Int_t 100 +NbMsOverlap: Int_t 1 +SizeMsInNs: Double_t 102400.0 +//SizeMsInNs: Double_t 1638400 +StarTriggerDeadtime: Double_t \ + 1000.0 1000.0 1000.0 1000.0 1000.0 +StarTriggerDelay: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +// 2000.0 2000.0 2000.0 2000.0 2000.0 +//-23000.0 -23000.0 -23000.0 -23000.0 -23000.0 +StarTriggerWinSize: Double_t \ + 2000.0 2000.0 2000.0 2000.0 2000.0 +TsDeadtimePeriod: Double_t 62.5 + +#################################################################################################### diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C index fbd6eff2661c1e9272f078b056262e6160542345..ab71ea80ee1fc42e1f8feeac0c0795d525e39327 100644 --- a/macro/run/run_unpack_online.C +++ b/macro/run/run_unpack_online.C @@ -102,6 +102,12 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 bmonconfig->SetDoWriteOutput(); // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors"); std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data()); + if (2610 < runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2023/", srcDir.Data()); + } + if (2724 <= runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } bmonconfig->SetParFilesBasePath(parfilesbasepathBmon); bmonconfig->SetParFileName("mBmonCriPar.par"); bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated @@ -147,54 +153,55 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 stsconfig->SetSystemTimeOffset(-970); // [ns] value to be updated } - stsconfig->SetMinAdcCut(1, 1); - stsconfig->SetMinAdcCut(2, 1); - stsconfig->SetMinAdcCut(3, 1); - stsconfig->SetMinAdcCut(4, 1); - - stsconfig->MaskNoisyChannel(3, 56); - stsconfig->MaskNoisyChannel(3, 75); - stsconfig->MaskNoisyChannel(3, 79); - stsconfig->MaskNoisyChannel(3, 85); - stsconfig->MaskNoisyChannel(7, 123); - stsconfig->MaskNoisyChannel(7, 124); - stsconfig->MaskNoisyChannel(7, 125); - stsconfig->MaskNoisyChannel(7, 158); - stsconfig->MaskNoisyChannel(7, 159); - stsconfig->MaskNoisyChannel(7, 162); - stsconfig->MaskNoisyChannel(7, 715); - stsconfig->MaskNoisyChannel(9, 709); - stsconfig->MaskNoisyChannel(12, 119); + // Noise removal + stsconfig->SetMinAdcCut(1, 1); // ADC cut to Station 0 Ladder 0 Module 0 + stsconfig->SetMinAdcCut(2, 1); // ADC cut to Station 0 Ladder 0 Module 0 + stsconfig->SetMinAdcCut(3, 1); // ADC cut to Station 0 Ladder 0 Module 1 + stsconfig->SetMinAdcCut(4, 1); // ADC cut to Station 0 Ladder 0 Module 1 + + // Masking noisy channels + std::ifstream mask_channels(Form("%s/sts_mask_channels.par", parfilesbasepathSts.data())); + int feb_idx, feb_chn; + while (mask_channels >> feb_idx >> feb_chn) { + stsconfig->MaskNoisyChannel(feb_idx, feb_chn); + } // Time Walk correction - std::map<uint32_t, CbmStsParModule> walkMap; - auto parAsic = new CbmStsParAsic(128, 31, 31., 1., 5., 800., 1000., 3.9789e-3); + std::map<uint32_t, CbmStsParModule> moduleWalkMap; + auto parAsic = new CbmStsParAsic(128, 31, 31., 1., 5., 800., 1000., 3.9789e-3); // Default ASIC parameters + auto parMod = new CbmStsParModule(2048, 128); // Generic STS module parameter object - // Module params: number of channels, number of channels per ASIC - auto parMod = new CbmStsParModule(2048, 128); + std::array<double, 31> tw_map = {}; // Default time walk map + parAsic->SetWalkCoef(tw_map); // Set generic ASIC par with no time walk correction + parMod->SetAllAsics(*parAsic); // Set generic module ASIC as default ASIC parameter configuration - // default - double p0 = 0, p1 = 0, p2 = 0, p3 = 0; - parAsic->SetWalkCoef({p0, p1, p2, p3}); - parMod->SetAllAsics(*parAsic); - - walkMap[0x10107C02] = CbmStsParModule(*parMod); // Make a copy for storage - walkMap[0x101FFC02] = CbmStsParModule(*parMod); // Make a copy for storage + moduleWalkMap[0x10107C02] = CbmStsParModule(*parMod); // Make a copy for storage + moduleWalkMap[0x101FFC02] = CbmStsParModule(*parMod); // Make a copy for storage /// To be replaced by a storage in a new parameter class later int sensor, asic; std::ifstream asicTimeWalk_par(Form("%s/mStsAsicTimeWalk.par", parfilesbasepathSts.data())); - while (asicTimeWalk_par >> std::hex >> sensor >> std::dec >> asic >> p0 >> p1 >> p2 >> p3) { - // std::cout << Form("Setting time-walk parameters for: module %x, ASIC %u\n", sensor, asic); - parAsic->SetWalkCoef({p0, p1, p2, p3}); + while (asicTimeWalk_par >> std::hex >> sensor >> std::dec >> asic) { // Read module and ASIC + LOG(debug) << Form("[STS] Reading %x %u", sensor, asic); + for (int adc = 0; adc < 31; adc++) { // Read time offset by ADC + asicTimeWalk_par >> tw_map[adc]; // Set time walk map offset value for given ADC + if (std::fabs(tw_map[adc]) > 100) { + LOG(warning) + << "[STS] Very large time walk parameter"; // Large offset values could indicate par file malformation + } + } // end ASIC idx loop + parAsic->SetWalkCoef(tw_map); // Set time walk map for the ASIC par obj - if (walkMap.find(sensor) == walkMap.end()) { walkMap[sensor] = CbmStsParModule(*parMod); } - walkMap[sensor].SetAsic(asic, *parAsic); - // std::cout << Form("Done with time-walk parameters for: module %x, ASIC %u\n", sensor, asic); + if (!moduleWalkMap.count(sensor)) { // No parameters obj for given module + moduleWalkMap[sensor] = CbmStsParModule(*parMod); // Create CbmStsParModule obj for the loaded module + } + moduleWalkMap[sensor].SetAsic(asic, *parAsic); // Set ASIC parameter + + LOG(debug) << Form("\n[STS] Time Walk parameters loaded for: module %x, ASIC %u\n", sensor, asic); } - stsconfig->SetWalkMap(walkMap); - walkMap.clear(); + stsconfig->SetWalkMap(moduleWalkMap); + moduleWalkMap.clear(); delete parMod; delete parAsic; } @@ -250,6 +257,10 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 // muchconfig->SetMinAdcCut(1, 1); // muchconfig->MaskNoisyChannel(3, 56); + //List of noisy channels *.txt file based on CbmMuchAddress is placed at the same location as par files + // + std::string NoisyChannelFilePath = parfilesbasepathMuch + "mMuChNoisyChannelMarch2022.txt"; + muchconfig->SetNoisyChannelFile(NoisyChannelFilePath); } // ------------- @@ -383,6 +394,11 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 parFileNameTof = "mTofCriPar.par"; } } + if (2724 <= runid) { + /// mCBM 2024 + parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } + tofconfig->SetParFilesBasePath(parfilesbasepathTof); tofconfig->SetParFileName(parFileNameTof); tofconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated diff --git a/macro/run/run_unpack_online_bmon.C b/macro/run/run_unpack_online_bmon.C index f453b7057d1ce6f49bdff805be47b407ab1b8074..5ecca0b04f95a41b62adbc28a3d1ee998c59208e 100644 --- a/macro/run/run_unpack_online_bmon.C +++ b/macro/run/run_unpack_online_bmon.C @@ -94,6 +94,12 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho // bmonconfig->SetDoWriteOutput(); // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors"); std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data()); + if (2610 < runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2023/", srcDir.Data()); + } + if (2724 <= runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } bmonconfig->SetParFilesBasePath(parfilesbasepathBmon); bmonconfig->SetParFileName("mBmonCriPar.par"); bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index efa7317878d9ef8af54d55830c1440bce14a1f65..a3feefa1b2e307c0411ca85b470f59cdab242539 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -122,6 +122,12 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid bmonconfig->SetDoWriteOutput(); // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors"); std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data()); + if (2610 < runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2023/", srcDir.Data()); + } + if (2724 <= runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } bmonconfig->SetParFilesBasePath(parfilesbasepathBmon); bmonconfig->SetParFileName("mBmonCriPar.par"); bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated @@ -396,6 +402,11 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid parFileNameTof = "mTofCriPar.par"; } } + if (2724 <= runid) { + /// mCBM 2024 + parfilesbasepathTof = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } + tofconfig->SetParFilesBasePath(parfilesbasepathTof); tofconfig->SetParFileName(parFileNameTof); tofconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated diff --git a/macro/run/run_unpack_tsa_bmon.C b/macro/run/run_unpack_tsa_bmon.C index e911a5e413aba0581c7776b9c337146594191e04..b0aef0e80ba52b1d07e16442a945590fdda14b5c 100644 --- a/macro/run/run_unpack_tsa_bmon.C +++ b/macro/run/run_unpack_tsa_bmon.C @@ -107,6 +107,12 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t bmonconfig->SetDoWriteOutput(); // bmonconfig->SetDoWriteOptOutA("CbmBmonErrors"); std::string parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2022/", srcDir.Data()); + if (2610 < runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2023/", srcDir.Data()); + } + if (2724 <= runid) { + parfilesbasepathBmon = Form("%s/macro/beamtime/mcbm2024/", srcDir.Data()); + } bmonconfig->SetParFilesBasePath(parfilesbasepathBmon); bmonconfig->SetParFileName("mBmonCriPar.par"); bmonconfig->SetSystemTimeOffset(-1220); // [ns] value to be updated @@ -196,7 +202,6 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t } // End of main macro function - /** * @brief Get the Tof Monitor. Extra function to keep default macro part more silent. * @return std::shared_ptr<CbmTofUnpackMonitor> diff --git a/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx b/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx index cf12a3e74046cafcb94448f623aecdb9e9764f67..5a87b3a0fa7fcd961ab5ce891d56d46bd6d86ea0 100644 --- a/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx +++ b/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx @@ -126,7 +126,7 @@ Bool_t CbmTofUnpackAlgo::initParSet(CbmMcbm2018TofPar* parset) if (0 == uCh % 8) sPrintout += "\n"; if (0 == uCh % fuNrOfChannelsPerGdpb) { uint32_t uGdpbIdx = uCh / fuNrOfChannelsPerGdpb; - sPrintout += Form("\n Gdpb %u (0x%x)\n", uGdpbIdx, parset->GetGdpbId(uGdpbIdx)); + sPrintout += Form("\n Gdpb %u (0x%x), index %u \n", uGdpbIdx, parset->GetGdpbId(uGdpbIdx), uCh); } if (0 == fviRpcChUId[uCh]) { sPrintout += " ----------"; @@ -243,7 +243,13 @@ bool CbmTofUnpackAlgo::unpack(const fles::Timeslice* ts, std::uint16_t icomp, UI LOG(debug) << fName << "::unpack => " << "Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType) << std::dec; */ - fuGet4Id = fUnpackPar->ElinkIdxToGet4Idx(pMess[uIdx].getGet4Idx()); + if (fUnpackPar->CheckInnerComp(fuCurrDpbId)) { + fuGet4Id = fUnpackPar->ElinkIdxToGet4IdxA(pMess[uIdx].getGet4Idx()); + } + else { + fuGet4Id = fUnpackPar->ElinkIdxToGet4Idx(pMess[uIdx].getGet4Idx()); + } + if (0x90 == fuCurrentMsSysId) fuGet4Id = pMess[uIdx].getGet4Idx(); fuGet4Nr = (fuCurrDpbIdx * fuNrOfGet4PerGdpb) + fuGet4Id;