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
33
34using namespace o2::framework;
35using namespace o2::itsmft;
36
37namespace o2
38{
39namespace its
40{
41
43{
44 mClusterer = std::make_unique<o2::itsmft::Clusterer>();
45 mClusterer->setNChips(o2::itsmft::ChipMappingITS::getNChips());
46 mUseClusterDictionary = !ic.options().get<bool>("ignore-cluster-dictionary");
48 mNThreads = std::max(1, ic.options().get<int>("nthreads"));
49 LOGP(info, "Initialising ITSClusterer with {} threads", mNThreads);
50 mState = 1;
51}
52
54{
55 updateTimeDependentParams(pc);
56 auto digits = pc.inputs().get<gsl::span<o2::itsmft::Digit>>("digits");
57 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
58
59 gsl::span<const o2::itsmft::MC2ROFRecord> mc2rofs;
60 gsl::span<const char> labelbuffer;
61 if (mUseMC) {
62 labelbuffer = pc.inputs().get<gsl::span<char>>("labels");
63 mc2rofs = pc.inputs().get<gsl::span<o2::itsmft::MC2ROFRecord>>("MC2ROframes");
64 }
66
67 LOG(info) << "ITSClusterer pulled " << digits.size() << " digits, in "
68 << rofs.size() << " RO frames";
69 LOG(info) << "ITSClusterer pulled " << labels.getNElements() << " labels ";
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(info) << "ITSClusterer pushed " << clusCompVec.size() << " clusters, in " << clusROFVec.size() << " RO frames";
108}
109
111void ClustererDPL::updateTimeDependentParams(ProcessingContext& pc)
112{
113 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::ITS));
121 // settings for the fired pixel overflow masking
124 mClusterer->setDropHugeClusters(clParams.dropHugeClusters);
125 if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
126 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);
127 }
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(clParams.maxBCDiffToSquashBias > 0 ? nROFsToSquash : 0);
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("ITS", "CLUSDICT", 0)) {
152 LOG(info) << "cluster dictionary updated" << (!mUseClusterDictionary ? " but its using is disabled" : "");
153 if (mUseClusterDictionary) {
154 mClusterer->setDictionary((const o2::itsmft::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("ITS", "ALPIDEPARAM", 0)) {
160 LOG(info) << "Alpide param updated";
162 par.printKeyValues();
163 return;
164 }
165 if (matcher == ConcreteDataMatcher("ITS", "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", "ITS", "DIGITS", 0, Lifetime::Timeframe);
177 inputs.emplace_back("ROframes", "ITS", "DIGITSROF", 0, Lifetime::Timeframe);
178 inputs.emplace_back("cldict", "ITS", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("ITS/Calib/ClusterDictionary"));
179 inputs.emplace_back("cluspar", "ITS", "CLUSPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/Config/ClustererParam"));
180 inputs.emplace_back("alppar", "ITS", "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/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("ITS", "COMPCLUSTERS", 0, Lifetime::Timeframe);
191 outputs.emplace_back("ITS", "PATTERNS", 0, Lifetime::Timeframe);
192 outputs.emplace_back("ITS", "CLUSTERSROF", 0, Lifetime::Timeframe);
193
194 if (useMC) {
195 inputs.emplace_back("labels", "ITS", "DIGITSMCTR", 0, Lifetime::Timeframe);
196 inputs.emplace_back("MC2ROframes", "ITS", "DIGITSMC2ROF", 0, Lifetime::Timeframe);
197 outputs.emplace_back("ITS", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
198 outputs.emplace_back("ITS", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe);
199 }
200
201 return DataProcessorSpec{
202 "its-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
213{
214 mClusterer->print();
215}
216
217} // namespace its
218} // 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 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)
static constexpr ID ITS
Definition DetID.h:63
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 init(InitContext &ic) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
static constexpr int getNChips()
number of chips per barrel
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
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