Project
Loading...
Searching...
No Matches
ClusterWriterSpec.cxx
Go to the documentation of this file.
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
13
14#include <algorithm>
15#include <cctype>
16#include <memory>
17#include <vector>
18#include <format>
19
28
29using namespace o2::framework;
30
31namespace o2::itsmft
32{
33
34template <typename T>
36using CompClusType = std::vector<o2::itsmft::CompClusterExt>;
37using PatternsType = std::vector<unsigned char>;
38using ROFrameRType = std::vector<o2::itsmft::ROFRecord>;
40using ROFRecLblT = std::vector<o2::itsmft::MC2ROFRecord>;
41using namespace o2::header;
42
43template <int N>
45{
48 const auto detName = Origin.as<std::string>();
49 // Spectators for logging
50 auto compClusterSizes = std::make_shared<std::array<size_t, NLayers>>();
51 auto compClustersSizeGetter = [compClusterSizes](CompClusType const& compClusters, DataRef const& ref) {
52 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
53 (*compClusterSizes)[dh->subSpecification] = compClusters.size();
54 };
55 auto logger = [detName, compClusterSizes](std::vector<o2::itsmft::ROFRecord> const& rofs, DataRef const& ref) {
56 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
57 const auto i = dh->subSpecification;
58 LOG(info) << detName << "ClusterWriter:" << i << " pulled " << (*compClusterSizes)[i] << " clusters, in " << rofs.size() << " RO frames";
59 };
60 auto getIndex = [](DataRef const& ref) -> size_t {
61 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
62 return static_cast<size_t>(dh->subSpecification);
63 };
64 auto getName = [](std::string base, size_t index) -> std::string {
66 return base += "_" + std::to_string(index);
67 }
68 return base;
69 };
70 auto detNameLC = detName;
71 std::transform(detNameLC.begin(), detNameLC.end(), detNameLC.begin(), [](unsigned char c) { return std::tolower(c); });
72 return MakeRootTreeWriterSpec(std::format("{}-cluster-writer", detNameLC).c_str(),
73 (o2::detectors::DetID::ITS == N) ? "o2clus_its.root" : "mftclusters.root",
74 MakeRootTreeWriterSpec::TreeAttributes{.name = "o2sim", .title = std::format("Tree with {} clusters", detName)},
75 BranchDefinition<CompClusType>{InputSpec{"compclus", ConcreteDataTypeMatcher{Origin, "COMPCLUSTERS"}},
76 (detName + "ClusterComp").c_str(), "compact-cluster-branch",
77 NLayers,
78 compClustersSizeGetter,
79 getIndex,
80 getName},
82 (detName + "ClusterPatt").c_str(), "cluster-pattern-branch",
83 NLayers,
84 getIndex,
85 getName},
86 BranchDefinition<ROFrameRType>{InputSpec{"ROframes", ConcreteDataTypeMatcher{Origin, "CLUSTERSROF"}},
87 (detName + "ClustersROF").c_str(), "cluster-rof-branch",
88 NLayers,
89 logger,
90 getIndex,
91 getName},
92 BranchDefinition<LabelsType>{InputSpec{"labels", ConcreteDataTypeMatcher{Origin, "CLUSTERSMCTR"}},
93 (detName + "ClusterMCTruth").c_str(), "cluster-label-branch",
94 (useMC ? NLayers : 0),
95 getIndex,
96 getName},
97 BranchDefinition<ROFRecLblT>{InputSpec{"MC2ROframes", ConcreteDataTypeMatcher{Origin, "CLUSTERSMC2ROF"}},
98 (detName + "ClustersMC2ROF").c_str(), "cluster-mc2rof-branch",
99 (useMC ? NLayers : 0),
100 getIndex,
101 getName})();
102}
103
104framework::DataProcessorSpec getITSClusterWriterSpec(bool useMC) { return getClusterWriterSpec<o2::detectors::DetID::ITS>(useMC); }
105framework::DataProcessorSpec getMFTClusterWriterSpec(bool useMC) { return getClusterWriterSpec<o2::detectors::DetID::MFT>(useMC); }
106
107} // namespace o2::itsmft
Definition of the ITSMFT compact cluster.
std::string getName(const TDataMember *dm, int index, int size)
int32_t i
Definition of the ITSMFT ROFrame (trigger) record.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Configurable generator for RootTreeWriter processor spec.
uint32_t c
Definition RawData.h:2
static constexpr ID ITS
Definition DetID.h:63
Generate a processor spec for the RootTreeWriter utility.
GLuint index
Definition glcorearb.h:781
GLint ref
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:572
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
Defining PrimaryVertex explicitly as messageable.
O2 data header classes and API, v0.1.
Definition DetID.h:49
std::vector< o2::itsmft::ROFRecord > ROFrameRType
std::vector< o2::itsmft::MC2ROFRecord > ROFRecLblT
framework::DataProcessorSpec getClusterWriterSpec(bool useMC)
framework::DataProcessorSpec getMFTClusterWriterSpec(bool useMC)
std::vector< unsigned char > PatternsType
framework::DataProcessorSpec getITSClusterWriterSpec(bool useMC)
std::vector< o2::itsmft::CompClusterExt > CompClusType
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static constexpr bool supportsStaggering() noexcept
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"