CbmRoot
Loading...
Searching...
No Matches
bmon/Clusterizer.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10
11#include "bmon/Clusterizer.h"
12
14#include "CbmBmonDigi.h"
15#include "CbmTofAddress.h"
16
17#include <algorithm>
18#include <iomanip>
19#include <iostream>
20#include <sstream>
21
23
24// ---------------------------------------------------------------------------------------------------------------------
25//
27{
28 // Description:
29 // The input array of digis is traced through until the last element. If the current digi and the next digi are
30 // close in time and have neighboring channels, a single hit is produced. Otherwise a hit is produced from a
31 // single digi. The complexity of the algorithm is O(nDigis). Requirements: digis must be sorted in time
32 Output_t res;
33 if (digis.empty()) {
34 return res;
35 }
36
37 auto& hits = std::get<0>(res);
38 auto& digiIndices = std::get<1>(res);
39 hits.reserve(digis.size());
40 digiIndices.reserve(digis.size());
41 auto itLast = std::prev(digis.end()); // iterator pointing to the last digi
42 bool bUsedWithPrevious{false}; // A flag: if the current digi was used together with the previous one
43 for (auto it = digis.begin(), in = it; it != itLast; ++it) {
44 if (bUsedWithPrevious) {
45 // skip a digi, if it was already used
46 bUsedWithPrevious = false;
47 continue;
48 }
49 in = std::next(it);
50 const auto& digiT = it->first;
51 const auto& digiN = in->first;
52 if (digiN.GetTime() - digiT.GetTime() < fParams.fdMaxTimeDist
53 && abs(digiN.GetChannel() - digiT.GetChannel()) == 1) {
54 // A hit consisting from two digis is found
55 hits.emplace_back(fParams.fAddress, digiT, digiN);
56 digiIndices.emplace_back(it->second);
57 bUsedWithPrevious = true;
58 }
59 else {
60 // A hit consisting from a single digi
61 hits.emplace_back(fParams.fAddress, digiT);
62 digiIndices.emplace_back(it->second);
63 }
64 }
65 if (!bUsedWithPrevious) {
66 // Create a hit from the last digi
67 hits.emplace_back(fParams.fAddress, itLast->first);
68 digiIndices.emplace_back(itLast->second);
69 }
70
71 return res;
72}
73
74// ---------------------------------------------------------------------------------------------------------------------
75//
76bool Clusterizer::SelectDigi(const CbmBmonDigi& digi) const
77{
78 // Dead channel cut
80 return false;
81 }
82
83 // ??? Other cuts ??? Charge threshold? Also dead strips can be accounted already on the calibrator level, together
84 // with the cuts
85
86 return true;
87}
static vector< vector< QAHit > > hits
A clusterizer algorithm for BMON.
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:31
int32_t GetAddress() const
Address.
Definition CbmBmonDigi.h:81
static int32_t GetChannelId(uint32_t address)
A clusterizer algorithm for a BMON.
bool SelectDigi(const CbmBmonDigi &digi) const
Applies selection on a digis.
ClusterizerPars fParams
parameters container
Output_t operator()(const Input_t &digisInput)
Hit building function.
std::vector< std::pair< CbmBmonDigi, int32_t > > Input_t
Input type.
std::pair< std::vector< Hit >, PODVector< int32_t > > Output_t
Output type.
uint32_t fDeadStrips
Dead strip bitmask.
double fdMaxTimeDist
Maximum time difference between two consecutive digis to form a single hit.
uint32_t fAddress
Address of the diamond (the channel bit field is 0)