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
30#include "MFTBase/GeometryTGeo.h"
35
36using namespace o2::framework;
37using namespace o2::itsmft;
38
39namespace o2
40{
41namespace mft
42{
43
45{
46 mClusterer = std::make_unique<o2::itsmft::Clusterer>();
47 mClusterer->setNChips(o2::itsmft::ChipMappingMFT::getNChips());
48 mUseClusterDictionary = !ic.options().get<bool>("ignore-cluster-dictionary");
50 mNThreads = std::max(1, ic.options().get<int>("nthreads"));
51 mState = 1;
52}
53
55{
56 updateTimeDependentParams(pc);
57 auto digits = pc.inputs().get<gsl::span<o2::itsmft::Digit>>("digits");
58 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
59
60 gsl::span<const o2::itsmft::MC2ROFRecord> mc2rofs;
61 gsl::span<const char> labelbuffer;
62 if (mUseMC) {
63 labelbuffer = pc.inputs().get<gsl::span<char>>("labels");
64 mc2rofs = pc.inputs().get<gsl::span<o2::itsmft::MC2ROFRecord>>("MC2ROframes");
65 }
67
68 LOG(debug) << "MFTClusterer pulled " << digits.size() << " digits, in "
69 << rofs.size() << " RO frames";
70
72 reader.setSquashingDepth(mClusterer->getMaxROFDepthToSquash());
73 reader.setSquashingDist(mClusterer->getMaxRowColDiffToMask()); // Sharing same parameter/logic with masking
74 reader.setMaxBCSeparationToSquash(mClusterer->getMaxBCSeparationToSquash());
75 reader.setDigits(digits);
76 reader.setROFRecords(rofs);
77 if (mUseMC) {
78 reader.setMC2ROFRecords(mc2rofs);
79 reader.setDigitsMCTruth(labels.getIndexedSize() > 0 ? &labels : nullptr);
80 }
81 reader.init();
83 std::vector<o2::itsmft::CompClusterExt> clusCompVec;
84 std::vector<o2::itsmft::ROFRecord> clusROFVec;
85 std::vector<unsigned char> clusPattVec;
86
87 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
88 if (mUseMC) {
89 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
90 }
91 mClusterer->process(mNThreads, reader, &clusCompVec, &clusPattVec, &clusROFVec, clusterLabels.get());
92 pc.outputs().snapshot(Output{orig, "COMPCLUSTERS", 0}, clusCompVec);
93 pc.outputs().snapshot(Output{orig, "CLUSTERSROF", 0}, clusROFVec);
94 pc.outputs().snapshot(Output{orig, "PATTERNS", 0}, clusPattVec);
95
96 if (mUseMC) {
97 pc.outputs().snapshot(Output{orig, "CLUSTERSMCTR", 0}, *clusterLabels.get()); // at the moment requires snapshot
98 std::vector<o2::itsmft::MC2ROFRecord> clusterMC2ROframes(mc2rofs.size());
99 for (int i = mc2rofs.size(); i--;) {
100 clusterMC2ROframes[i] = mc2rofs[i]; // Simply, replicate it from digits ?
101 }
102 pc.outputs().snapshot(Output{orig, "CLUSTERSMC2ROF", 0}, clusterMC2ROframes);
103 }
104
105 // TODO: in principle, after masking "overflow" pixels the MC2ROFRecord maxROF supposed to change, nominally to minROF
106 // -> consider recalculationg maxROF
107 LOG(debug) << "MFTClusterer pushed " << clusCompVec.size() << " compressed clusters, in " << clusROFVec.size() << " RO frames";
108}
109
111void ClustererDPL::updateTimeDependentParams(ProcessingContext& pc)
112{
114 static bool initOnceDone = false;
115 if (!initOnceDone) { // this params need to be queried only once
116 initOnceDone = true;
117 pc.inputs().get<TopologyDictionary*>("cldict"); // just to trigger the finaliseCCDB
120 mClusterer->setContinuousReadOut(o2::base::GRPGeomHelper::instance().getGRPECS()->isDetContinuousReadOut(o2::detectors::DetID::MFT));
121 // settings for the fired pixel overflow masking
124 if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
125 LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToSquashBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
126 }
127 mClusterer->setDropHugeClusters(clParams.dropHugeClusters);
128 auto nbc = clParams.maxBCDiffToMaskBias;
129 nbc += mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS);
130 mClusterer->setMaxBCSeparationToMask(nbc);
131 mClusterer->setMaxRowColDiffToMask(clParams.maxRowColDiffToMask);
132 // Squasher
133 int rofBC = mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS); // ROF length in BC
134 mClusterer->setMaxBCSeparationToSquash(rofBC + clParams.maxBCDiffToSquashBias);
135 int nROFsToSquash = 0; // squashing disabled if no reset due to maxSOTMUS>0.
136 if (clParams.maxSOTMUS > 0 && rofBC > 0) {
137 nROFsToSquash = 2 + int(clParams.maxSOTMUS / (rofBC * o2::constants::lhc::LHCBunchSpacingMUS)); // use squashing
138 }
139 mClusterer->setMaxROFDepthToSquash(nROFsToSquash);
140 mClusterer->print();
141 }
142 // we may have other params which need to be queried regularly
143}
144
147{
149 return;
150 }
151 if (matcher == ConcreteDataMatcher("MFT", "CLUSDICT", 0)) {
152 LOG(info) << "cluster dictionary updated" << (!mUseClusterDictionary ? " but its using is disabled" : "");
153 if (mUseClusterDictionary) {
154 mClusterer->setDictionary((const TopologyDictionary*)obj);
155 }
156 return;
157 }
158 // Note: strictly speaking, for Configurable params we don't need finaliseCCDB check, the singletons are updated at the CCDB fetcher level
159 if (matcher == ConcreteDataMatcher("MFT", "ALPIDEPARAM", 0)) {
160 LOG(info) << "Alpide param updated";
162 par.printKeyValues();
163 return;
164 }
165 if (matcher == ConcreteDataMatcher("MFT", "CLUSPARAM", 0)) {
166 LOG(info) << "Cluster param updated";
168 par.printKeyValues();
169 return;
170 }
171}
172
174{
175 std::vector<InputSpec> inputs;
176 inputs.emplace_back("digits", "MFT", "DIGITS", 0, Lifetime::Timeframe);
177 inputs.emplace_back("ROframes", "MFT", "DIGITSROF", 0, Lifetime::Timeframe);
178 inputs.emplace_back("cldict", "MFT", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("MFT/Calib/ClusterDictionary"));
179 inputs.emplace_back("cluspar", "MFT", "CLUSPARAM", 0, Lifetime::Condition, ccdbParamSpec("MFT/Config/ClustererParam"));
180 inputs.emplace_back("alppar", "MFT", "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec("MFT/Config/AlpideParam"));
181 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
182 true, // GRPECS=true
183 false, // GRPLHCIF
184 false, // GRPMagField
185 false, // askMatLUT
187 inputs,
188 true);
189 std::vector<OutputSpec> outputs;
190 outputs.emplace_back("MFT", "COMPCLUSTERS", 0, Lifetime::Timeframe);
191 outputs.emplace_back("MFT", "PATTERNS", 0, Lifetime::Timeframe);
192 outputs.emplace_back("MFT", "CLUSTERSROF", 0, Lifetime::Timeframe);
193
194 if (useMC) {
195 inputs.emplace_back("labels", "MFT", "DIGITSMCTR", 0, Lifetime::Timeframe);
196 inputs.emplace_back("MC2ROframes", "MFT", "DIGITSMC2ROF", 0, Lifetime::Timeframe);
197 outputs.emplace_back("MFT", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
198 outputs.emplace_back("MFT", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe);
199 }
200
201 return DataProcessorSpec{
202 "mft-clusterer",
203 inputs,
204 outputs,
205 AlgorithmSpec{adaptFromTask<ClustererDPL>(ggRequest, useMC)},
206 Options{
207 {"ignore-cluster-dictionary", VariantType::Bool, false, {"do not use cluster dictionary, always store explicit patterns"}},
208 {"nthreads", VariantType::Int, 1, {"Number of clustering threads"}}}};
209}
210
211} // namespace mft
212} // namespace o2
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 ClusterTopology class.
Definition of the Names Generator class.
Definition of the GeometryManager class.
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.
std::ostringstream debug
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static constexpr ID MFT
Definition DetID.h:71
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.
static constexpr Int_t getNChips()
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)
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:572
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
framework::DataProcessorSpec getClustererSpec(bool useMC)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits