CbmRoot
Loading...
Searching...
No Matches
CbmTrdUnpackConfig.cxx
Go to the documentation of this file.
1/* Copyright (C) 2021 Goethe-University Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pascal Raisig [committer] */
4
6
8#include "CbmTrdUnpackAlgoR.h"
9
10#include <Logger.h>
11
12#include <Rtypes.h>
13#include <RtypesCore.h>
14
15#include <memory>
16#include <vector>
17
18CbmTrdUnpackConfig::CbmTrdUnpackConfig(std::string detGeoSetupTag, UInt_t runid)
19 : CbmRecoUnpackConfig("CbmTrdUnpackConfig", detGeoSetupTag, runid)
20{
21}
22
24
25// ---- Init ----
27{
28 LOG(info) << fName << "::Init -";
29
30 // First choose the derived unpacking algorithm to be used and pass the raw to digi method
31 auto algo = chooseAlgo();
32
33 // If we got a handmade spadic we pass it to the algorithm and the RTD method
34 if (fSpadic) {
35 algo->SetSpadicObject(fSpadic);
36 fRTDMethod->SetSpadicObject(fSpadic);
37 }
38
39 if (fDoLog) LOG(info) << fName << "::Init - SetRawToDigiMethod";
40 algo->SetRawToDigiMethod(fRTDMethod);
41
42 if (fDoLog) LOG(info) << fName << "::Init - SetParFilesBasePath";
43 algo->SetParFilesBasePath(fParFilesBasePath);
44
45 // Set the global system time offset
46 if (fDoLog) LOG(info) << fName << "::SetAlgo - SetSystemTimeOffset";
47 algo->SetSystemTimeOffset(fSystemTimeOffset);
48
49 // Set the flag controlling the overlap ignore
50 if (fDoLog) LOG(info) << fName << "::SetAlgo - SetDoIgnoreOverlappMs";
51 algo->SetDoIgnoreOverlappMs(fDoIgnoreOverlappMs);
52
53 // Set the global system time offset
54 if (fDoLog) LOG(info) << fName << "::SetAlgo - SetElinkTimeOffsetMap";
55 algo->SetElinkTimeOffsetMap(fElinkTimeOffsetMap);
56
57 // If we have a monitor in the config add it to the algo
58 if (fMonitor) algo->SetMonitor(fMonitor);
59
60 // Pass the algo to its member in the base class
61 fAlgo = algo;
62}
63
64// ---- chooseAlgo ----
65std::shared_ptr<CbmTrdUnpackAlgoBaseR> CbmTrdUnpackConfig::chooseAlgo()
66{
67 if (fDoLog) LOG(info) << fName << "::Init - chooseAlgo";
68
69 // Non default unpacker selection
70 // Legacy unpacker for data taken before mcbm 2021
71 if (fGeoSetupTag.find("Desy2019") != fGeoSetupTag.npos) {
72 auto algo = std::make_shared<CbmTrdUnpackAlgoLegacy2020R>();
73 LOG(info) << fName << "::chooseAlgo() - selected algo = " << algo->Class_Name();
74 return algo;
75 }
76 if (fGeoSetupTag.find("trd_IkfSmallChamber") != fGeoSetupTag.npos) {
77 auto algo = std::make_shared<CbmTrdUnpackAlgoLegacy2020R>();
78 LOG(info) << fName << "::chooseAlgo() - selected algo = " << algo->Class_Name();
79 return algo;
80 }
81 if (fGeoSetupTag.find("v20a_mcbm") != fGeoSetupTag.npos) {
82 auto algo = std::make_shared<CbmTrdUnpackAlgoLegacy2020R>();
83 LOG(info) << fName << "::chooseAlgo() - selected algo = " << algo->Class_Name();
84 return algo;
85 }
86
87 // Default unpacker selection
88 // Unpacker algo from mcbm 2021 on and hopefully default for a long time.
89 auto algo = std::make_shared<CbmTrdUnpackAlgoR>();
90 LOG(info) << fName << "::chooseAlgo() - selected algo = " << algo->Class_Name();
91 return algo;
92
93 LOG(error) << fName
94 << "::Init - chooseAlgo() - no algorithm created something went wrong. We can not work like this!";
95 return nullptr;
96}
97
98void CbmTrdUnpackConfig::SetElinkTimeOffset(std::uint32_t criid, std::uint8_t elinkid, std::int32_t offsetNs)
99{
100 // create vector for criid if not yet existing
101 if (fElinkTimeOffsetMap.find(criid) == fElinkTimeOffsetMap.end()) {
102 //vector has fixed size of 256 (max elinkid) and is initialized to 0
103 fElinkTimeOffsetMap.insert(std::make_pair(criid, std::vector<int32_t>(256, 0)));
104 }
105
106 fElinkTimeOffsetMap[criid][elinkid] = offsetNs;
107}
108
109
ClassImp(CbmConverterManager)
Unpacker algorithms for the TrdR 2020 data.
Unpacker algorithm for the TrdR 2021 data.
Configuration class for an unpacker algorithm.
void SetAlgo()
Setup the derived unpacker algorithm to be used for the DAQ output to Digi translation....
virtual ~CbmTrdUnpackConfig()
Destroy the Cbm Trd Unpack Task object.
CbmTrdUnpackConfig(std::string detGeoSetupTag, UInt_t runid=0)
Create the Cbm Trd Unpack Task object.
void SetElinkTimeOffset(std::uint32_t criid, std::uint8_t elinkid, std::int32_t offsetNs)
Register a time offeset to be substracted from the digis which come from a specific CRI.
std::shared_ptr< CbmTrdRawToDigiBaseR > fRTDMethod
pointer to the raw msg to digi method
std::map< std::uint32_t, std::vector< std::int32_t > > fElinkTimeOffsetMap
Map to store time offsets for each CRI&Elink combination.
std::shared_ptr< CbmTrdUnpackMonitor > fMonitor
pointer to the monitor object
virtual std::shared_ptr< CbmTrdUnpackAlgoBaseR > chooseAlgo()
Choose the derived unpacker algorithm to be used for the DAQ output to Digi translation....
std::shared_ptr< CbmTrdSpadic > fSpadic
Spadic software reprensentation object.