Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/** @file MCBM DATA unpacking
** @author Florian Uhlig <f.uhlig@gsi.de>
** @date 20.06.2016
** Modified by P.-A. Loizeau
** @date 30.01.2019
** ROOT macro to read tsa files which have been produced with the new data transport
** Convert data into cbmroot format.
** Uses CbmMcbm2018Source as source task.
*/
// In order to call later Finish, we make this global
FairRunOnline *run = NULL;
void unpack_tsa_mcbm_mfles( UInt_t uRunId = 0, UInt_t nrEvents=0, TString outDir="data", TString inDir="")
{
if( uRunId < 353 )
return kFALSE;
TString srcDir = gSystem->Getenv("VMCWORKDIR");
// --- Specify number of events to be produced.
// --- -1 means run until the end of the input file.
Int_t nEvents=-1;
// --- Specify output file name (this is just an example)
TString runId = TString::Format("%03u", uRunId);
TString outFile = outDir + "/unp_mcbm_" + runId + ".root";
TString parFile = outDir + "/unp_mcbm_params_" + runId + ".root";
// --- Set log output levels
FairLogger::GetLogger();
gLogger->SetLogScreenLevel("INFO");
//gLogger->SetLogScreenLevel("DEBUG4");
gLogger->SetLogVerbosityLevel("MEDIUM");
//gLogger->SetLogVerbosityLevel("LOW");
// --- Define parameter files
TList *parFileList = new TList();
TString paramDir = srcDir + "/macro/beamtime/mcbm2020/";
TString paramFileSts = paramDir + "mStsPar.par";
TObjString* parStsFileName = new TObjString(paramFileSts);
parFileList->Add(parStsFileName);
TString paramFileMuch = paramDir + "mMuchPar.par";
TObjString* parMuchFileName = new TObjString(paramFileMuch);
parFileList->Add(parMuchFileName);

Pierre-Alain Loizeau
committed
TString paramDirTrd = srcDir + "/parameters/trd/trd_v18q_mcbm";
parFileList->Add(new TObjString(Form("%s.asic.par", paramDirTrd.Data())));
TString paramFileTof = paramDir + "mTofPar.par";
TObjString* parTofFileName = new TObjString(paramFileTof);
parFileList->Add(parTofFileName);
TString paramFileRich = paramDir + "mRichPar.par";

Pierre-Alain Loizeau
committed
if (uRunId > 698) paramFileRich = paramDir + "mRichPar_70.par";
TObjString* parRichFileName = new TObjString(paramFileRich);
parFileList->Add(parRichFileName);
TString paramFilePsd = paramDir + "mPsdPar.par";
TObjString* parPsdFileName = new TObjString(paramFilePsd);
parFileList->Add(parPsdFileName);
// --- Set debug level
gDebug = 0;
std::cout << std::endl;
std::cout << ">>> unpack_tsa: output file is " << outFile << std::endl;
// ========================================================================
// ========================================================================
std::cout << std::endl;
std::cout << ">>> unpack_tsa: Initialising..." << std::endl;
CbmMcbm2018UnpackerTaskSts * unpacker_sts = new CbmMcbm2018UnpackerTaskSts();
CbmMcbm2018UnpackerTaskMuch * unpacker_much = new CbmMcbm2018UnpackerTaskMuch();

Pierre-Alain Loizeau
committed
CbmMcbm2018UnpackerTaskTrdR * unpacker_trdR = new CbmMcbm2018UnpackerTaskTrdR();
CbmMcbm2018UnpackerTaskTof * unpacker_tof = new CbmMcbm2018UnpackerTaskTof();
CbmMcbm2018UnpackerTaskRich * unpacker_rich = new CbmMcbm2018UnpackerTaskRich();
CbmMcbm2018UnpackerTaskPsd * unpacker_psd = new CbmMcbm2018UnpackerTaskPsd();
unpacker_sts ->SetMonitorMode();
unpacker_much->SetMonitorMode();

Pierre-Alain Loizeau
committed
unpacker_trdR->SetMonitorMode();
unpacker_tof ->SetMonitorMode();
unpacker_rich->SetMonitorMode();
unpacker_psd->SetMonitorMode();
unpacker_sts ->SetIgnoreOverlapMs();
unpacker_much->SetIgnoreOverlapMs();

Pierre-Alain Loizeau
committed
// unpacker_trdR ->SetIgnoreOverlapMs(); /// Default is kTRUE
unpacker_tof ->SetIgnoreOverlapMs();
unpacker_rich->SetIgnoreOverlapMs();
unpacker_psd ->SetIgnoreOverlapMs();

Pierre-Alain Loizeau
committed
// unpacker_sts ->SetAdcCut( 3 );
unpacker_tof ->SetSeparateArrayT0();

Pierre-Alain Loizeau
committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
switch( uRunId )
{
case 368:
unpacker_sts ->SetTimeOffsetNs( 2519880 ); // Run 368
break;
/*
case 159:
{
/// General System offsets (= offsets between sub-systems)
unpacker_sts ->SetTimeOffsetNs( -1750 ); // Run 159
unpacker_much->SetTimeOffsetNs( -1750 ); // Run 159
unpacker_tof ->SetTimeOffsetNs( -50 ); // Run 159
unpacker_rich->SetTimeOffsetNs( -1090 ); // Run 159
/// ASIC specific offsets (= offsets inside sub-system)
unpacker_sts ->SetTimeOffsetNsAsic( 0, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 1, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 2, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 3, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 4, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 5, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 6, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 7, 0.0 ); // Unused
unpacker_sts ->SetTimeOffsetNsAsic( 8, 0.0 ); // Run 160, Ladder 0, Module 1, N, Asic 0
unpacker_sts ->SetTimeOffsetNsAsic( 9, 18.75 ); // Run 160, Ladder 0, Module 1, N, Asic 1
unpacker_sts ->SetTimeOffsetNsAsic( 10, 0.0 ); // Run 160, Ladder 0, Module 1, N, Asic 2
unpacker_sts ->SetTimeOffsetNsAsic( 11, 25.0 ); // Run 160, Ladder 0, Module 1, N, Asic 3
unpacker_sts ->SetTimeOffsetNsAsic( 12, 0.0 ); // Run 160, Ladder 0, Module 1, N, Asic 4
unpacker_sts ->SetTimeOffsetNsAsic( 13, 56.25 ); // Run 160, Ladder 0, Module 1, N, Asic 5
unpacker_sts ->SetTimeOffsetNsAsic( 14, 0.0 ); // Run 160, Ladder 0, Module 1, N, Asic 6
unpacker_sts ->SetTimeOffsetNsAsic( 15, 37.5 ); // Run 160, Ladder 0, Module 1, N, Asic 7
unpacker_sts ->SetTimeOffsetNsAsic( 16, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 0
unpacker_sts ->SetTimeOffsetNsAsic( 17, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 1
unpacker_sts ->SetTimeOffsetNsAsic( 18, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 2
unpacker_sts ->SetTimeOffsetNsAsic( 19, 50.0 ); // Run 160, Ladder 0, Module 1, P, Asic 3
unpacker_sts ->SetTimeOffsetNsAsic( 20, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 4
unpacker_sts ->SetTimeOffsetNsAsic( 21, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 5
unpacker_sts ->SetTimeOffsetNsAsic( 22, 0.0 ); // Run 160, Ladder 0, Module 1, P, Asic 6
unpacker_sts ->SetTimeOffsetNsAsic( 23, 25.0 ); // Run 160, Ladder 0, Module 1, P, Asic 7
unpacker_sts ->SetTimeOffsetNsAsic( 24, 50.0 ); // Run 160, Ladder 0, Module 0, N, Asic 0
unpacker_sts ->SetTimeOffsetNsAsic( 25, 25.0 ); // Run 160, Ladder 0, Module 0, N, Asic 1
unpacker_sts ->SetTimeOffsetNsAsic( 26, 50.0 ); // Run 160, Ladder 0, Module 0, N, Asic 2
unpacker_sts ->SetTimeOffsetNsAsic( 27, 31.25 ); // Run 160, Ladder 0, Module 0, N, Asic 3
unpacker_sts ->SetTimeOffsetNsAsic( 28, 0.0 ); // Run 160, Ladder 0, Module 0, N, Asic 4
unpacker_sts ->SetTimeOffsetNsAsic( 29, 6.25 ); // Run 160, Ladder 0, Module 0, N, Asic 5
unpacker_sts ->SetTimeOffsetNsAsic( 30, 50.0 ); // Run 160, Ladder 0, Module 0, N, Asic 6
unpacker_sts ->SetTimeOffsetNsAsic( 31, 31.25 ); // Run 160, Ladder 0, Module 0, N, Asic 7
unpacker_sts ->SetTimeOffsetNsAsic( 32, 0.0 ); // Run 160, Ladder 0, Module 0, P, Asic 0
unpacker_sts ->SetTimeOffsetNsAsic( 33, 31.25 ); // Run 160, Ladder 0, Module 0, P, Asic 1
unpacker_sts ->SetTimeOffsetNsAsic( 34, 0.0 ); // Run 160, Ladder 0, Module 0, P, Asic 2
unpacker_sts ->SetTimeOffsetNsAsic( 35, 25.0 ); // Run 160, Ladder 0, Module 0, P, Asic 3
unpacker_sts ->SetTimeOffsetNsAsic( 36, 25.0 ); // Run 160, Ladder 0, Module 0, P, Asic 4
unpacker_sts ->SetTimeOffsetNsAsic( 37, 25.0 ); // Run 160, Ladder 0, Module 0, P, Asic 5
unpacker_sts ->SetTimeOffsetNsAsic( 38, 0.0 ); // Run 160, Ladder 0, Module 0, P, Asic 6
unpacker_sts ->SetTimeOffsetNsAsic( 39, 0.0 ); // Run 160, Ladder 0, Module 0, P, Asic 7
unpacker_much->SetTimeOffsetNsAsic( 0, 0.0 ); // Run 159, DPB 0 ASIC 0
unpacker_much->SetTimeOffsetNsAsic( 1, 109.0 ); // Run 159, DPB 0 ASIC 1
unpacker_much->SetTimeOffsetNsAsic( 2, 142.0 ); // Run 159, DPB 0 ASIC 2
unpacker_much->SetTimeOffsetNsAsic( 3, 84.0 ); // Run 159, DPB 0 ASIC 3
unpacker_much->SetTimeOffsetNsAsic( 4, 109.0 ); // Run 159, DPB 0 ASIC 4
unpacker_much->SetTimeOffsetNsAsic( 5, 0.0 ); // Run 159, DPB 0 ASIC 5
unpacker_much->SetTimeOffsetNsAsic( 6, 2820915.0 ); // Run 159, DPB 1 ASIC 0
unpacker_much->SetTimeOffsetNsAsic( 7, 2820905.0 ); // Run 159, DPB 1 ASIC 1
unpacker_much->SetTimeOffsetNsAsic( 8, 2820785.0 ); // Run 159, DPB 1 ASIC 2
unpacker_much->SetTimeOffsetNsAsic( 9, 2820915.0 ); // Run 159, DPB 1 ASIC 3
unpacker_much->SetTimeOffsetNsAsic( 10, 0.0 ); // Run 159, DPB 1 ASIC 4
unpacker_much->SetTimeOffsetNsAsic( 11, 2820805.0 ); // Run 159, DPB 1 ASIC 5
unpacker_much->SetTimeOffsetNsAsic( 12, 8144.0 ); // Run 159, DPB 2 ASIC 0
unpacker_much->SetTimeOffsetNsAsic( 13, 8133.0 ); // Run 159, DPB 2 ASIC 1
unpacker_much->SetTimeOffsetNsAsic( 14, 0.0 ); // Run 159, DPB 2 ASIC 2
unpacker_much->SetTimeOffsetNsAsic( 15, 0.0 ); // Run 159, DPB 2 ASIC 3
unpacker_much->SetTimeOffsetNsAsic( 16, 0.0 ); // Run 159, DPB 2 ASIC 4
unpacker_much->SetTimeOffsetNsAsic( 17, 0.0 ); // Run 159, DPB 2 ASIC 5
unpacker_much->SetTimeOffsetNsAsic( 18, 136.0 ); // Run 159, DPB 3 ASIC 0
unpacker_much->SetTimeOffsetNsAsic( 19, 119.0 ); // Run 159, DPB 3 ASIC 1
unpacker_much->SetTimeOffsetNsAsic( 20, 141.0 ); // Run 159, DPB 3 ASIC 2
unpacker_much->SetTimeOffsetNsAsic( 21, 0.0 ); // Run 159, DPB 3 ASIC 3
unpacker_much->SetTimeOffsetNsAsic( 22, 0.0 ); // Run 159, DPB 3 ASIC 4
unpacker_much->SetTimeOffsetNsAsic( 23, 0.0 ); // Run 159, DPB 3 ASIC 5
break;
} // 159
*/
default:
break;
} // switch( uRunId )
// --- Source task
CbmMcbm2018Source* source = new CbmMcbm2018Source();
/*
TString inFile = Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn02_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn04_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn05_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn06_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn08_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn10_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn11_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn12_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn13_0000.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn15_0000.tsa", uRunId );
*/
TString inFile = Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn02_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn04_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn05_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn06_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn08_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn10_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn11_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn12_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn13_*.tsa;", uRunId );
inFile += Form( "/scratch/mcbm_data/mcbm_all/data/%3u_pn15_*.tsa", uRunId );
source->SetFileName(inFile);
// source->SetInputDir(inDir);
source->AddUnpacker(unpacker_sts, 0x10, ECbmModuleId::kSts );//STS xyter

Pierre-Alain Loizeau
committed
source->AddUnpacker(unpacker_much, 0x50, ECbmModuleId::kMuch );//MUCH xyter
source->AddUnpacker(unpacker_trdR, 0x40, ECbmModuleId::kTrd);// Trd flibId (0x40) as at desy2019. kTrd defined in CbmDefs.h
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
source->AddUnpacker(unpacker_tof, 0x60, ECbmModuleId::kTof );//gDPB A & B & C
source->AddUnpacker(unpacker_tof, 0x90, ECbmModuleId::kTof );//gDPB T0 A & B
/// Avoid unpacking runs with RICH calibration triggers in first file until unpacker fixed
if( 358 != uRunId &&
361 != uRunId &&
367 != uRunId &&
369 != uRunId )
source->AddUnpacker(unpacker_rich, 0x30, ECbmModuleId::kRich );//RICH trb
source->AddUnpacker(unpacker_psd, 0x80, ECbmModuleId::kPsd );//PSD
// --- Event header
FairEventHeader* event = new CbmTbEvent();
event->SetRunId(uRunId);
// --- RootFileSink
// --- Open next outputfile after 4GB
FairRootFileSink* sink = new FairRootFileSink(outFile);
// sink->GetOutTree()->SetMaxTreeSize(4294967295LL);
// --- Run
run = new FairRunOnline(source);
run->SetSink(sink);
run->SetEventHeader(event);
run->SetAutoFinish(kFALSE);
// ----- Runtime database ---------------------------------------------
FairRuntimeDb* rtdb = run->GetRuntimeDb();
Bool_t kParameterMerged = kTRUE;
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
FairParAsciiFileIo* parIn = new FairParAsciiFileIo();
parOut->open(parFile.Data());
parIn->open(parFileList, "in");
rtdb->setFirstInput(parIn);
rtdb->setOutput(parOut);
run->Init();
// --- Start run
TStopwatch timer;
timer.Start();
std::cout << ">>> unpack_tsa_mcbm: Starting run..." << std::endl;
if ( 0 == nrEvents) {
run->Run(nEvents, 0); // run until end of input file
} else {
run->Run(0, nrEvents); // process N Events
}
run->Finish();
timer.Stop();
std::cout << "Processed " << std::dec << source->GetTsCount() << " timeslices" << std::endl;
// --- End-of-run info
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << ">>> unpack_tsa_mcbm: Macro finished successfully." << std::endl;
std::cout << ">>> unpack_tsa_mcbm: Output file is " << outFile << std::endl;
std::cout << ">>> unpack_tsa_mcbm: Real time " << rtime << " s, CPU time "
<< ctime << " s" << std::endl;
std::cout << std::endl;
/// --- Screen output for automatic tests
std::cout << " Test passed" << std::endl;
std::cout << " All ok " << std::endl;
}