CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2018UnpackerTaskPsd.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Nikolay Karpushkin, David Emschermann [committer] */
4
5// -----------------------------------------------------------------------------
6// ----- -----
7// ----- CbmMcbm2018UnpackerTaskPsd -----
8// ----- Created 09.10.2019 by N.Karpushkin -----
9// ----- based on CbmMcbm2018UnpackerTaskTof by P.-A. Loizeau -----
10// ----- -----
11// -----------------------------------------------------------------------------
12
14
15#include "CbmMcbm2018PsdPar.h"
17
18#include "FairParGenericSet.h"
19#include "FairRootManager.h"
20#include "FairRun.h"
21#include "FairRunOnline.h"
22#include "FairRuntimeDb.h"
23#include <Logger.h>
24
25#include "TClonesArray.h"
26#include "TH1.h"
27#include "THttpServer.h"
28#include "TROOT.h"
29#include "TString.h"
30#include <TFile.h>
31
32#include <chrono>
33#include <fstream>
34#include <iomanip>
35#include <iostream>
36
37#include <stdint.h>
38
40
43 , fbMonitorMode(kFALSE)
44 , fbDebugMonitorMode(kFALSE)
45 , fbWriteOutput(kTRUE)
46 , fbDebugWriteOutput(kFALSE)
47 , fulTsCounter(0)
48 , fPsdDigiVector(nullptr)
49 , fPsdDspVector(nullptr)
50 , fUnpackerAlgo(nullptr)
51{
52 LOG(info) << "CbmMcbm2018UnpackerTaskPsd::Allocate";
54}
55
57
59{
60 LOG(info) << "CbmMcbm2018UnpackerTaskPsd::Init";
61 LOG(info) << "Initializing mCBM PSD 2018 Unpacker";
62 Bool_t initOK = kTRUE;
63
64 FairRootManager* ioman = FairRootManager::Instance();
65 if (NULL == ioman) { LOG(fatal) << "No FairRootManager instance"; }
66
68 fPsdDigiVector = new std::vector<CbmPsdDigi>();
69 if (fPsdDigiVector) {
70 ioman->RegisterAny("PsdDigi", fPsdDigiVector, fbWriteOutput);
72 }
73 else {
74 LOG(fatal) << "fPsdDigiVector could not be registered at FairRootManager";
75 }
76
79 fPsdDspVector = new std::vector<CbmPsdDsp>();
80 if (fPsdDspVector) {
81 ioman->RegisterAny("PsdDsp", fPsdDspVector, fbDebugWriteOutput);
83 }
84 else {
85 LOG(fatal) << "fPsdDspVector could not be registered at FairRootManager";
86 }
87 }
88
89 return initOK;
90}
91
93{
94 LOG(info) << "Setting parameter containers for " << GetName();
95
96 TList* fParCList = fUnpackerAlgo->GetParList();
97
98 for (Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC) {
99 FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
100 fParCList->Remove(tempObj);
101
102 std::string sParamName {tempObj->GetName()};
103 FairParGenericSet* newObj =
104 dynamic_cast<FairParGenericSet*>(FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
105
106 if (nullptr == newObj) {
107 LOG(error) << "Failed to obtain parameter container " << sParamName << ", for parameter index " << iparC;
108 return;
109 } // if( nullptr == newObj )
110
111 fParCList->AddAt(newObj, iparC);
112 // delete tempObj;
113 } // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
114}
115
117{
118 LOG(info) << "Init parameter containers for " << GetName();
119
121 CbmMcbm2018PsdPar* pUnpackPar =
122 dynamic_cast<CbmMcbm2018PsdPar*>(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMcbm2018PsdPar"));
123 if (nullptr == pUnpackPar) {
124 LOG(error) << "Failed to obtain parameter container CbmMcbm2018PsdPar";
125 return kFALSE;
126 } // if( nullptr == pUnpackPar )
127
128 Bool_t initOK = fUnpackerAlgo->InitContainers();
129
130 return initOK;
131}
132
134{
135 LOG(info) << "ReInit parameter containers for " << GetName();
136 Bool_t initOK = fUnpackerAlgo->ReInitContainers();
137
138 return initOK;
139}
140
141void CbmMcbm2018UnpackerTaskPsd::AddMsComponentToList(size_t component, UShort_t usDetectorId)
142{
143 fUnpackerAlgo->AddMsComponentToList(component, usDetectorId);
144}
145
146Bool_t CbmMcbm2018UnpackerTaskPsd::DoUnpack(const fles::Timeslice& ts, size_t component)
147{
148
150 LOG(info) << "Reset PSD unpacker histos ";
153 } // if( fbMonitorMode && bMcbm2018UnpackerTaskPsdResetHistos )
154
155 fUnpackerAlgo->unpack(&ts, component);
156 /*
157 if (kFALSE == fUnpackerAlgo->ProcessTs(ts)) {
158 LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
159 return kTRUE;
160 } // if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
161*/
162 /*
164 => Done in the algo!!!
165 sort(fPsdDigiVector->begin(), fPsdDigiVector->end(),
166 [](const CbmPsdDigi & a, const CbmPsdDigi & b) -> bool
167 {
168 return a.GetTime() < b.GetTime();
169 });
170*/
171
172 /*
173*/
174 if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << "TS";
175 fulTsCounter++;
176
177 return kTRUE;
178}
179
185
186
188{
189 LOG(info) << "Finish of CbmMcbm2018UnpackerTaskPsd";
191}
192
194{
195 fbDebugWriteOutput = bFlagIn;
197}
200
ClassImp(CbmConverterManager)
Bool_t bMcbm2018UnpackerTaskPsdResetHistos
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
Bool_t SetDigiOutputPointer(std::vector< CbmPsdDigi > *const pVector)
void SetDspWriteMode(Bool_t bFlagIn=kTRUE)
void SetTimeOffsetNs(Double_t dOffsetIn=0.0)
std::pair< std::vector< CbmPsdDigi > *, std::vector< CbmPsdDsp > * > unpack(const fles::Timeslice *ts, std::uint16_t icomp)
Bool_t SetDspOutputPointer(std::vector< CbmPsdDsp > *const pVector)
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
Bool_t fbWriteOutput
Switch ON the filling of a additional set of histograms.
uint64_t fulTsCounter
If ON the output vector of dsp debug information is written to disk.
std::vector< CbmPsdDigi > * fPsdDigiVector
Output Digi vector.
Bool_t fbDebugWriteOutput
If ON the output vector of digi is written to disk.
void SetIgnoreOverlapMs(Bool_t bFlagIn=kTRUE)
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
Temp until we change from CbmMcbmUnpack to something else.
CbmMcbm2018UnpackerAlgoPsd * fUnpackerAlgo
Processing algo.
void SetTimeOffsetNs(Double_t dOffsetIn=0.0)
std::vector< CbmPsdDsp > * fPsdDspVector
Output Dsp vector – preprocessed info for debugging.
void SetDspWriteMode(Bool_t bFlagIn=kTRUE)
void SetIgnoreOverlapMs(Bool_t bFlagIn=kTRUE)
Control flags.