Project
Loading...
Searching...
No Matches
ClustererSpec.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 <vector>
15
20#include "ITS3Base/SpecsV2.h"
32
33using namespace o2::framework;
34
35namespace o2::its3
36{
37
39{
40 mClusterer = std::make_unique<o2::its3::Clusterer>();
41 mUseClusterDictionary = !ic.options().get<bool>("ignore-cluster-dictionary");
42 mNThreads = std::max(1, ic.options().get<int>("nthreads"));
45 mClusterer->print();
46 mState = 1;
47}
48
50{
51 updateTimeDependentParams(pc);
52 auto digits = pc.inputs().get<gsl::span<o2::itsmft::Digit>>("digits");
53 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
54
55 gsl::span<const o2::itsmft::MC2ROFRecord> mc2rofs;
56 gsl::span<const char> labelbuffer;
57 if (mUseMC) {
58 labelbuffer = pc.inputs().get<gsl::span<char>>("labels");
59 mc2rofs = pc.inputs().get<gsl::span<o2::itsmft::MC2ROFRecord>>("MC2ROframes");
60 }
62
63 LOGP(info, "ITS3Clusterer pulled {} digits in {} ROFs", digits.size(), rofs.size());
64 LOGP(info, "ITS3Clusterer pulled {} labels", labels.getNElements());
65
67 reader.setSquashingDepth(mClusterer->getMaxROFDepthToSquash());
68 reader.setSquashingDist(mClusterer->getMaxRowColDiffToMask()); // Sharing same parameter/logic with masking
69 reader.setMaxBCSeparationToSquash(mClusterer->getMaxBCSeparationToSquash());
70 reader.setDigits(digits);
71 reader.setROFRecords(rofs);
72 if (mUseMC) {
73 reader.setMC2ROFRecords(mc2rofs);
74 reader.setDigitsMCTruth(labels.getIndexedSize() > 0 ? &labels : nullptr);
75 }
76 reader.init();
78 std::vector<o2::itsmft::CompClusterExt> clusCompVec;
79 std::vector<o2::itsmft::ROFRecord> clusROFVec;
80 std::vector<unsigned char> clusPattVec;
81
82 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
83 if (mUseMC) {
84 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
85 }
86 mClusterer->process(mNThreads, reader, &clusCompVec, &clusPattVec, &clusROFVec, clusterLabels.get());
87 pc.outputs().snapshot(Output{orig, "COMPCLUSTERS", 0}, clusCompVec);
88 pc.outputs().snapshot(Output{orig, "CLUSTERSROF", 0}, clusROFVec);
89 pc.outputs().snapshot(Output{orig, "PATTERNS", 0}, clusPattVec);
90
91 if (mUseMC) {
92 pc.outputs().snapshot(Output{orig, "CLUSTERSMCTR", 0}, *clusterLabels); // at the moment requires snapshot
93 std::vector<o2::itsmft::MC2ROFRecord> clusterMC2ROframes(mc2rofs.size());
94 for (int i = mc2rofs.size(); i--;) {
95 clusterMC2ROframes[i] = mc2rofs[i]; // Simply, replicate it from digits ?
96 }
97 pc.outputs().snapshot(Output{orig, "CLUSTERSMC2ROF", 0}, clusterMC2ROframes);
98 }
99
100 // TODO: in principle, after masking "overflow" pixels the MC2ROFRecord maxROF supposed to change, nominally to minROF
101 // -> consider recalculationg maxROF
102 LOG(info) << "ITS3Clusterer pushed " << clusCompVec.size() << " clusters, in " << clusROFVec.size() << " RO frames";
103}
104
106void ClustererDPL::updateTimeDependentParams(ProcessingContext& pc)
107{
108 static bool initOnceDone = false;
110 if (!initOnceDone) { // this params need to be queried only once
111 initOnceDone = true;
112 pc.inputs().get<TopologyDictionary*>("cldict"); // just to trigger the finaliseCCDB
115 // settings for the fired pixel overflow masking
118 if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
119 LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToMaskBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
120 }
121 auto nbc = clParams.maxBCDiffToMaskBias;
122 nbc += mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS);
123 mClusterer->setMaxBCSeparationToMask(nbc);
124 mClusterer->setMaxRowColDiffToMask(clParams.maxRowColDiffToMask);
125 // Squasher
126 int rofBC = mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS); // ROF length in BC
127 mClusterer->setMaxBCSeparationToSquash(rofBC + clParams.maxBCDiffToSquashBias);
128 int nROFsToSquash = 0; // squashing disabled if no reset due to maxSOTMUS>0.
129 if (clParams.maxSOTMUS > 0 && rofBC > 0) {
130 nROFsToSquash = 2 + int(clParams.maxSOTMUS / (rofBC * o2::constants::lhc::LHCBunchSpacingMUS)); // use squashing
131 }
132 mClusterer->setMaxROFDepthToSquash(clParams.maxBCDiffToSquashBias > 0 ? nROFsToSquash : 0);
133 mClusterer->print();
134 }
135 // we may have other params which need to be queried regularly
136}
137
140{
142 return;
143 }
144 if (matcher == ConcreteDataMatcher("IT3", "CLUSDICT", 0)) {
145 LOG(info) << "cluster dictionary updated" << (!mUseClusterDictionary ? " but its using is disabled" : "");
146 if (mUseClusterDictionary) {
147 mClusterer->setDictionary((const o2::its3::TopologyDictionary*)obj);
148 }
149 return;
150 }
151 // Note: strictly speaking, for Configurable params we don't need finaliseCCDB check, the singletons are updated at the CCDB fetcher level
152 if (matcher == ConcreteDataMatcher("ITS", "ALPIDEPARAM", 0)) {
153 LOG(info) << "Alpide param updated";
155 par.printKeyValues();
156 return;
157 }
158 if (matcher == ConcreteDataMatcher("ITS", "CLUSPARAM", 0)) {
159 LOG(info) << "Cluster param updated";
161 par.printKeyValues();
162 return;
163 }
164}
165
167{
168 mClusterer->print();
169}
170
172{
173 std::vector<InputSpec> inputs;
174 inputs.emplace_back("digits", "IT3", "DIGITS", 0, Lifetime::Timeframe);
175 inputs.emplace_back("ROframes", "IT3", "DIGITSROF", 0, Lifetime::Timeframe);
176 inputs.emplace_back("cldict", "IT3", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("IT3/Calib/ClusterDictionary"));
177 inputs.emplace_back("cluspar", "ITS", "CLUSPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/Config/ClustererParam"));
178 inputs.emplace_back("alppar", "ITS", "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/Config/AlpideParam"));
179 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
180 false, // GRPECS
181 false, // GRPLHCIF
182 false, // GRPMagField
183 false, // askMatLUT
185 inputs,
186 true);
187 std::vector<OutputSpec> outputs;
188 outputs.emplace_back("ITS", "COMPCLUSTERS", 0, Lifetime::Timeframe);
189 outputs.emplace_back("ITS", "PATTERNS", 0, Lifetime::Timeframe);
190 outputs.emplace_back("ITS", "CLUSTERSROF", 0, Lifetime::Timeframe);
191
192 if (useMC) {
193 inputs.emplace_back("labels", "IT3", "DIGITSMCTR", 0, Lifetime::Timeframe);
194 inputs.emplace_back("MC2ROframes", "IT3", "DIGITSMC2ROF", 0, Lifetime::Timeframe);
195 outputs.emplace_back("ITS", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
196 outputs.emplace_back("ITS", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe);
197 }
198
199 return DataProcessorSpec{
200 "its3-clusterer",
201 inputs,
202 outputs,
203 AlgorithmSpec{adaptFromTask<ClustererDPL>(ggRequest, useMC)},
204 Options{
205 {"ignore-cluster-dictionary", VariantType::Bool, false, {"do not use cluster dictionary, always store explicit patterns"}},
206 {"nthreads", VariantType::Int, 1, {"Number of clustering threads"}}}};
207}
208
209} // namespace o2::its3
Definition of the ITS/MFT clusterer settings.
Definition of the ITSMFT compact cluster.
A const (ready only) version of MCTruthContainer.
Definition of the ITSMFT digit.
Definition of the BuildTopologyDictionary class for ITS3.
Definition of the Alpide pixel reader for MC digits processing.
int32_t i
Header of the General Run Parameters object.
Definition of the ITSMFT ROFrame (trigger) record.
Header to collect LHC related constants.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(InitContext &ic) final
static constexpr int MB
static constexpr int getNChips()
number of chips per barrel
static constexpr int OB
void setDigitsMCTruth(const o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > *m)
void setDigits(const gsl::span< const o2::itsmft::Digit > a)
void setSquashingDist(const int16_t v)
void setMC2ROFRecords(const gsl::span< const o2::itsmft::MC2ROFRecord > a)
void setROFRecords(const gsl::span< const o2::itsmft::ROFRecord > a)
void setSquashingDepth(const int16_t v)
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
constexpr double LHCBunchSpacingMUS
constexpr double LHCBunchSpacingNS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
constexpr unsigned int nChips
Definition SpecsV2.h:131
framework::DataProcessorSpec getClustererSpec(bool useMC)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits