CbmRoot
Loading...
Searching...
No Matches
CbmMuchUnpackConfig.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 Fair GmbH, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
6
7#include "CbmMuchUnpackAlgo.h"
8
9#include <Logger.h>
10
11#include <Rtypes.h>
12#include <RtypesCore.h>
13
14#include <memory>
15#include <vector>
16
17CbmMuchUnpackConfig::CbmMuchUnpackConfig(std::string detGeoSetupTag, UInt_t runid)
18 : CbmRecoUnpackConfig("CbmMuchUnpackConfig", detGeoSetupTag, runid)
19{
20}
21
23
24// ---- Init ----
26{
27 // Set the minimum adc cut
28 fAlgo->SetMinAdcCut(fdAdcCut);
29
30 // Set the minimum adc cut Feb independent
31 for (auto cut = fdAdcCut_perFeb.begin(); cut != fdAdcCut_perFeb.end(); cut++) {
32 fAlgo->SetMinAdcCut(cut->first, cut->second);
33 }
34
35 // Set the single asics time offsets
36 fAlgo->SetAsicTimeOffsetVec(fvdTimeOffsetNsAsics);
37
38 // Set the flags for duplicate digis rejections
39 fAlgo->SetDuplicatesRejection(fbRejectDuplicateDigis, fbDupliWithoutAdc);
40
41 // --- Read list of inactive channels
42 if (!fInactiveChannelFileName.IsNull()) {
43 LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
44 auto result = ReadInactiveChannels();
45 if (!result.second) {
46 LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
47 return;
48 }
49 //LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
50 // << " channels set inactive";
51 }
52
53
54 if (fMonitor) {
55 fAlgo->SetMonitor(fMonitor);
56 }
57
58 // Now we have all information required to initialise the algorithm
59 fAlgo->Init();
60
61 // Mask the noisy channels set by the user
62 for (auto chmask : fvChanMasks)
63 fAlgo->MaskNoisyChannel(chmask.uFeb, chmask.uChan, chmask.bMasked);
64}
65
66// ---- chooseAlgo ----
67std::shared_ptr<CbmMuchUnpackAlgo> CbmMuchUnpackConfig::chooseAlgo()
68{
69
70 if (fDoLog) LOG(info) << fName << "::Init - chooseAlgo";
71
72 // Default unpacker selection
73 // Unpacker algo from mcbm 2021-2022 on and hopefully default for a long time.
74 auto algo = std::make_shared<CbmMuchUnpackAlgo>();
75 LOG(info) << fName << "::chooseAlgo() - selected algo = " << algo->Class_Name();
76
77 // Make sure the par file name picked by the user is sent to the algo
78 algo->SetParFileName(fsParFileName);
79
80 return algo;
81
82 LOG(error) << fName
83 << "::Init - chooseAlgo() - no algorithm created something went wrong. We can not work like this!";
84 return nullptr;
85}
86
87
88// ----- Read list of inactive channels ---------------------------------
90{
91
92 if (fInactiveChannelFileName.IsNull()) return std::make_pair(0, true);
93
94 FILE* channelFile = fopen(fInactiveChannelFileName.Data(), "r");
95 if (channelFile == nullptr) return std::make_pair(0, false);
96
97 size_t nLines = 0;
98 uint32_t channel = 0;
99 while (fscanf(channelFile, "%u", &channel) == 1) {
100 fAlgo->SetInactiveChannel(channel);
101 nLines++;
102 }
103 bool success = feof(channelFile);
104
105 fclose(channelFile);
106 LOG(info) << " Number of Noisy Channels in CbmAddress Format : " << nLines;
107 return std::make_pair(nLines, success);
108}
109// --------------------------------------------------------------------------
110
111
ClassImp(CbmConverterManager)
MUCH unpacker algorithms.
Configuration class for an unpacker algorithm.
std::map< uint32_t, uint32_t > fdAdcCut_perFeb
Minimum adc cut per Feb to store a hit.
virtual ~CbmMuchUnpackConfig()
Destroy the Cbm Sts Unpack Task object.
void InitAlgo()
Initialize the algorithm, should include all steps needing te parameter objects to be present....
bool fbDupliWithoutAdc
If rejecting duplicate digis, enables rejection even if ADC differs.
bool fbRejectDuplicateDigis
Enables the rejection of duplicate digis.
uint32_t fdAdcCut
Minimum adc cut to store a hit.
std::shared_ptr< CbmMuchUnpackMonitor > fMonitor
pointer to the monitor object
virtual std::shared_ptr< CbmMuchUnpackAlgo > chooseAlgo()
Choose the derived unpacker algorithm to be used for the DAQ output to Digi translation....
std::vector< double > fvdTimeOffsetNsAsics
Vector with the Asic time offsets.
std::string fsParFileName
Parameter file name.
std::vector< FebChanMaskReco > fvChanMasks
Temporary storage of user parameters.
virtual std::pair< size_t, bool > ReadInactiveChannels()
Read Inactive Channel list based on CbmMuchAddress from a file.
CbmMuchUnpackConfig(std::string detGeoSetupTag, UInt_t runid=0)
Create the Cbm Sts Unpack Task object.