43 mClusterer = std::make_unique<o2::itsmft::Clusterer>();
45 mUseClusterDictionary = !ic.
options().
get<
bool>(
"ignore-cluster-dictionary");
47 mNThreads = std::max(1, ic.
options().
get<
int>(
"nthreads"));
48 mDetName = Origin.as<std::string>();
51 for (
int iLayer = 0; iLayer < NLayers; ++iLayer) {
52 mFilter.emplace_back(
"digits", Origin,
"DIGITS", iLayer, Lifetime::Timeframe);
53 mFilter.emplace_back(
"ROframe", Origin,
"DIGITSROF", iLayer, Lifetime::Timeframe);
55 mFilter.emplace_back(
"labels", Origin,
"DIGITSMCTR", iLayer, Lifetime::Timeframe);
56 mFilter.emplace_back(
"MC2ROframes", Origin,
"DIGITSMC2ROF", iLayer, Lifetime::Timeframe);
64 updateTimeDependentParams(pc);
67 std::array<gsl::span<const o2::itsmft::Digit>, NLayers>
digits;
68 std::array<gsl::span<const o2::itsmft::ROFRecord>, NLayers> rofs;
69 std::array<gsl::span<const char>, NLayers> labelsbuffer;
70 std::array<gsl::span<const o2::itsmft::MC2ROFRecord>, NLayers> mc2rofs;
72 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
77 rofs[dh->subSpecification] = pc.
inputs().
get<gsl::span<o2::itsmft::ROFRecord>>(
ref);
80 labelsbuffer[dh->subSpecification] = pc.
inputs().
get<gsl::span<char>>(
ref);
83 mc2rofs[dh->subSpecification] = pc.
inputs().
get<gsl::span<o2::itsmft::MC2ROFRecord>>(
ref);
96 for (uint32_t iLayer{0}; iLayer < NLayers; ++iLayer) {
99 LOG(info) << mDetName <<
"Clusterer:" <<
layer <<
" pulled " <<
digits[iLayer].size() <<
" digits, in " << rofs[iLayer].size() <<
" RO frames";
101 mClusterer->setMaxROFDepthToSquash(mClusterer->getMaxROFDepthToSquash(
layer));
110 LOG(info) << mDetName <<
"Clusterer:" <<
layer <<
" pulled " <<
labels.getNElements() <<
" labels ";
114 std::vector<o2::itsmft::CompClusterExt> clusCompVec;
115 std::vector<o2::itsmft::ROFRecord> clusROFVec;
116 std::vector<unsigned char> clusPattVec;
118 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
120 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
122 mClusterer->process(mNThreads, reader, &clusCompVec, &clusPattVec, &clusROFVec, clusterLabels.get());
125 size_t nROFs = clusROFVec.size();
128 if (nROFsTF != clusROFVec.size()) {
134 const size_t nROFsLayer = std::max((
size_t)nROFsTF, clusROFVec.size());
135 std::vector<o2::itsmft::ROFRecord> expClusRofVec(nROFsLayer);
136 for (
int iROF{0}; iROF < nROFsLayer; ++iROF) {
137 auto& rof = expClusRofVec[iROF];
142 rof.setROFrame(iROF);
144 rof.setFirstEntry(-1);
146 uint32_t prevEntry{0};
147 for (
const auto& rof : clusROFVec) {
148 const auto&
ir = rof.getBCData();
149 const auto irToFirst =
ir - firstIR;
150 const int irROF = irToFirst.
toLong() / par.getROFLengthInBC(iLayer);
151 auto& expROF = expClusRofVec[irROF];
152 expROF.setFirstEntry(rof.getFirstEntry());
153 expROF.setNEntries(rof.getNEntries());
154 if (expROF.getBCData() != rof.getBCData()) {
155 LOGP(fatal,
"detected mismatch between expected ROF:{} and received ROF:{}", expROF.asString(), rof.asString());
159 for (
auto& rof : expClusRofVec) {
160 if (rof.getFirstEntry() < 0) {
161 rof.setFirstEntry(prevFirst);
163 prevFirst = rof.getFirstEntry();
165 nROFs = expClusRofVec.size();
177 std::vector<o2::itsmft::MC2ROFRecord> clusterMC2ROframes(mc2rofs[iLayer].
size());
178 for (
int i = mc2rofs[iLayer].
size();
i--;) {
179 clusterMC2ROframes[
i] = mc2rofs[iLayer][
i];
188 LOG(info) << mDetName <<
"Clusterer:" <<
layer <<
" pushed " << clusCompVec.size() <<
" clusters, in " << nROFs <<
" RO frames in " <<
sw.RealTime() <<
" s";
191 LOG(info) << mDetName <<
"Clusterer produced " <<
nClusters <<
" clusters";
199 static bool initOnceDone =
false;
209 if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
210 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);
212 mClusterer->setDropHugeClusters(clParams.dropHugeClusters);
213 auto nbc = clParams.maxBCDiffToMaskBias;
215 mClusterer->setMaxBCSeparationToMask(nbc);
216 mClusterer->setMaxRowColDiffToMask(clParams.maxRowColDiffToMask);
219 mClusterer->setMaxBCSeparationToSquash(rofBC + clParams.maxBCDiffToSquashBias);
220 int nROFsToSquash = 0;
221 if (clParams.maxSOTMUS > 0 && rofBC > 0) {
224 mClusterer->setMaxROFDepthToSquash(nROFsToSquash);
226 if (mClusterer->isContinuousReadOut()) {
227 for (
int iLayer{0}; iLayer < NLayers; ++iLayer) {
228 mClusterer->addMaxBCSeparationToSquash(alpParams.getROFLengthInBC(iLayer) + clParams.getMaxBCDiffToSquashBias(iLayer));
233 mClusterer->print(
false);
246 LOG(info) <<
"cluster dictionary updated" << (!mUseClusterDictionary ?
" but its using is disabled" :
"");
247 if (mUseClusterDictionary) {
254 LOG(info) <<
"Alpide param updated";
256 par.printKeyValues();
260 LOG(info) <<
"Cluster param updated";
262 par.printKeyValues();
273 std::vector<InputSpec> inputs;
275 for (uint32_t iLayer = 0; iLayer < nLayers; ++iLayer) {
276 inputs.emplace_back(
"digits", Origin,
"DIGITS", iLayer, Lifetime::Timeframe);
277 inputs.emplace_back(
"ROframes", Origin,
"DIGITSROF", iLayer, Lifetime::Timeframe);
279 inputs.emplace_back(
"labels", Origin,
"DIGITSMCTR", iLayer, Lifetime::Timeframe);
280 inputs.emplace_back(
"MC2ROframes", Origin,
"DIGITSMC2ROF", iLayer, Lifetime::Timeframe);
283 inputs.emplace_back(
"cldict", Origin,
"CLUSDICT", 0, Lifetime::Condition,
ccdbParamSpec(
Origin.as<std::string>() +
"/Calib/ClusterDictionary"));
284 inputs.emplace_back(
"cluspar", Origin,
"CLUSPARAM", 0, Lifetime::Condition,
ccdbParamSpec(
Origin.as<std::string>() +
"/Config/ClustererParam"));
285 inputs.emplace_back(
"alppar", Origin,
"ALPIDEPARAM", 0, Lifetime::Condition,
ccdbParamSpec(
Origin.as<std::string>() +
"/Config/AlpideParam"));
286 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
294 std::vector<OutputSpec> outputs;
295 for (uint32_t iLayer = 0; iLayer <
nLayers; ++iLayer) {
296 outputs.emplace_back(Origin,
"COMPCLUSTERS", iLayer, Lifetime::Timeframe);
297 outputs.emplace_back(Origin,
"PATTERNS", iLayer, Lifetime::Timeframe);
298 outputs.emplace_back(Origin,
"CLUSTERSROF", iLayer, Lifetime::Timeframe);
300 outputs.emplace_back(Origin,
"CLUSTERSMCTR", iLayer, Lifetime::Timeframe);
301 outputs.emplace_back(Origin,
"CLUSTERSMC2ROF", iLayer, Lifetime::Timeframe);
310 {
"ignore-cluster-dictionary", VariantType::Bool,
false, {
"do not use cluster dictionary, always store explicit patterns"}},
311 {
"nthreads", VariantType::Int, 1, {
"Number of clustering threads"}}}};
317 return getClustererSpec<o2::detectors::DetID::ITS>(useMC);
322 return getClustererSpec<o2::detectors::DetID::MFT>(useMC);
std::vector< std::string > labels
Definition of the ITS/MFT clusterer settings.
Definition of the ITSMFT compact cluster.
A const (ready only) version of MCTruthContainer.
Definition of the Names Generator class.
Definition of the GeometryManager class.
Definition of the Alpide pixel reader for MC digits processing.
Header of the General Run Parameters object.
Header to collect LHC related constants.
void checkUpdates(o2::framework::ProcessingContext &pc)
static int getNHBFPerTF()
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static const DPLAlpideParam< N > & Instance()
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static constexpr int getNChips()
number of chips per barrel
static constexpr Int_t getNChips()
void init(InitContext &ic) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
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 setMaxBCSeparationToSquash(int n)
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)
GLenum GLuint GLint GLint layer
constexpr o2::header::DataOrigin gDataOriginMFT
constexpr o2::header::DataOrigin gDataOriginITS
constexpr double LHCBunchSpacingMUS
constexpr int LHCMaxBunches
constexpr double LHCBunchSpacingNS
AlgorithmSpec adaptFromTask(Args &&... args)
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
framework::DataProcessorSpec getMFTClustererSpec(bool useMC)
framework::DataProcessorSpec getITSClustererSpec(bool useMC)
static bool match(DataRef const &ref, const char *binding)
static constexpr int getNLayers()
static constexpr bool supportsStaggering() noexcept
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)
std::vector< Digit > digits