Skip to content

Commit 517bf23

Browse files
committed
Add streamer for std::vector<o2::tpc::PadFlags>
1 parent d449a51 commit 517bf23

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#ifndef O2_DATAFORMATSTPC_VECTORPAD_FLAGSSTREAMER_H_
13+
#define O2_DATAFORMATSTPC_VECTORPAD_FLAGSSTREAMER_H_
14+
15+
#include "DataFormatsTPC/Defs.h"
16+
#include <TClassStreamer.h>
17+
#include <TBuffer.h>
18+
#include <vector>
19+
20+
class VectorPadFlagsStreamer : public TClassStreamer
21+
{
22+
public:
23+
void operator()(TBuffer& R__b, void* objp) override
24+
{
25+
std::vector<o2::tpc::PadFlags>* obj = static_cast<std::vector<o2::tpc::PadFlags>*>(objp);
26+
if (R__b.IsReading()) {
27+
std::vector<int> R__stl;
28+
R__stl.clear();
29+
int R__n;
30+
R__b >> R__n;
31+
R__stl.reserve(R__n);
32+
for (int R__i = 0; R__i < R__n; R__i++) {
33+
Int_t readtemp;
34+
R__b >> readtemp;
35+
R__stl.push_back(readtemp);
36+
}
37+
auto data = reinterpret_cast<unsigned short*>(R__stl.data());
38+
for (int i = 0; i < R__n; ++i) {
39+
obj->push_back(static_cast<o2::tpc::PadFlags>(data[i]));
40+
}
41+
} else {
42+
// We always save things with the old format.
43+
R__b << (int)obj->size() / 2;
44+
for (size_t i = 0; i < obj->size(); i++) {
45+
R__b << (short)obj->at(i);
46+
}
47+
}
48+
}
49+
};
50+
51+
#endif // O2_DATAFORMATSTPC_VECTORPAD_FLAGSSTREAMER_H_

GPU/Workflow/src/GPUWorkflowTPC.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
#include <chrono>
8181
#include "GPUReconstructionConvert.h"
8282
#include "DetectorsRaw/RDHUtils.h"
83+
#include "DataFormatsTPC/VectorPadFlagsStreamer.h"
84+
8385
#include <TStopwatch.h>
8486
#include <TObjArray.h>
8587
#include <TH1F.h>
@@ -98,6 +100,8 @@ namespace o2::gpu
98100

99101
void GPURecoWorkflowSpec::initFunctionTPCCalib(InitContext& ic)
100102
{
103+
TClass* cls = TClass::GetClass("std::vector<o2::tpc::PadFlags>");
104+
cls->AdoptStreamer(new VectorPadFlagsStreamer());
101105
mTPCDeadChannelMapCreator.reset(new o2::tpc::DeadChannelMapCreator());
102106
const auto deadMapSource = (mSpecConfig.tpcDeadMapSources > -1) ? static_cast<tpc::SourcesDeadMap>(mSpecConfig.tpcDeadMapSources) : tpc::SourcesDeadMap::All;
103107
mTPCDeadChannelMapCreator->init();

0 commit comments

Comments
 (0)