forked from bovulpes/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKryptonClustererSpec.cxx
More file actions
102 lines (82 loc) · 3.29 KB
/
KryptonClustererSpec.cxx
File metadata and controls
102 lines (82 loc) · 3.29 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <memory>
#include "Framework/Task.h"
#include "Framework/InputRecordWalker.h"
#include "Framework/Logger.h"
#include "Framework/DataProcessorSpec.h"
#include "Headers/DataHeader.h"
#include "DataFormatsTPC/TPCSectorHeader.h"
#include "DataFormatsTPC/KrCluster.h"
#include "TPCReconstruction/KrBoxClusterFinder.h"
#include "TPCWorkflow/KryptonClustererSpec.h"
using namespace o2::framework;
using namespace o2::header;
using SubSpecificationType = o2::framework::DataAllocator::SubSpecificationType;
namespace o2
{
namespace tpc
{
class KrBoxClusterFinderDevice : public o2::framework::Task
{
public:
KrBoxClusterFinderDevice() : mClusterFinder{std::make_unique<KrBoxClusterFinder>()} {}
void init(o2::framework::InitContext& ic) final
{
mClusterFinder->init();
}
void run(o2::framework::ProcessingContext& pc) final
{
for (auto const& inputRef : InputRecordWalker(pc.inputs())) {
auto const* sectorHeader = DataRefUtils::getHeader<TPCSectorHeader*>(inputRef);
if (sectorHeader == nullptr) {
LOGP(error, "sector header missing on header stack for input on ", inputRef.spec->binding);
continue;
}
const int sector = sectorHeader->sector();
auto inDigits = pc.inputs().get<gsl::span<o2::tpc::Digit>>(inputRef);
mClusterFinder->loopOverSector(inDigits, sector);
snapshotClusters(pc.outputs(), mClusterFinder->getClusters(), sector);
LOGP(info, "processed sector {} with {} digits and {} reconstructed clusters", sector, inDigits.size(), mClusterFinder->getClusters().size());
mClusterFinder->resetClusters();
}
++mProcessedTFs;
LOGP(info, "Number of processed time frames: {}", mProcessedTFs);
}
private:
std::unique_ptr<KrBoxClusterFinder> mClusterFinder;
uint32_t mProcessedTFs{0};
//____________________________________________________________________________
void snapshotClusters(DataAllocator& output, const std::vector<o2::tpc::KrCluster>& clusters, int sector)
{
o2::tpc::TPCSectorHeader header{sector};
header.activeSectors = (0x1 << sector);
output.snapshot(Output{gDataOriginTPC, "KRCLUSTERS", static_cast<SubSpecificationType>(sector), Lifetime::Timeframe, header}, clusters);
}
};
o2::framework::DataProcessorSpec getKryptonClustererSpec()
{
using device = o2::tpc::KrBoxClusterFinderDevice;
std::vector<InputSpec> inputs{
InputSpec{"digits", gDataOriginTPC, "DIGITS", 0, Lifetime::Timeframe},
};
std::vector<OutputSpec> outputs;
outputs.emplace_back(gDataOriginTPC, "KRCLUSTERS", 0, Lifetime::Timeframe);
return DataProcessorSpec{
"tpc-krypton-clusterer",
inputs,
outputs,
AlgorithmSpec{adaptFromTask<device>()},
Options{} // end Options
}; // end DataProcessorSpec
}
} // namespace tpc
} // namespace o2