Skip to content

Commit c122906

Browse files
KrCluster adjusted for leader pad method and no more clusters found over ROC boundaries. (#4976)
* Added new variables to KrCluster for leader pad method and no more clusters found over ROC boundaries. * KrCluster Finder can now take gain maps into account. * Changed some variable types back to unsigned int to save memory. * Changed the way to specify a CalDet file. * Included all suggestions regarding KrClusterFinder. * Search for charge maxima only in exisiting pads. * A few comments are now more precise. * Using the default constructor.
1 parent e5d8a3d commit c122906

File tree

4 files changed

+233
-53
lines changed

4 files changed

+233
-53
lines changed

Detectors/TPC/reconstruction/include/TPCReconstruction/KrBoxClusterFinder.h

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
/// the arrays are larger than a sector. For the size in row-direction, a constant is used.
5454
/// For time and pad direction, a number is set (here is room for improvements).
5555
///
56-
/// When data from a new sector is encountered, the method
56+
/// ToDo: Find an elegant way to split the huge map into four (IROC, OROC1, OROC2 and OROC3) smaller maps. Unfortunately, this seems to interfere with the rest of the code.
5757
///
5858
/// How to use:
5959
/// Load tpcdigits.root
@@ -72,6 +72,8 @@
7272
#include "TPCReconstruction/KrCluster.h"
7373
#include "TPCBase/Mapper.h"
7474

75+
#include "TPCBase/CalDet.h"
76+
7577
#include <tuple>
7678
#include <vector>
7779
#include <array>
@@ -93,7 +95,16 @@ class KrBoxClusterFinder
9395
{
9496
public:
9597
/// Constructor:
96-
explicit KrBoxClusterFinder(std::vector<o2::tpc::Digit>& eventSector); ///< Creates a 3D Map
98+
/// The constructor allocates a three dimensional array (Pad,Row,Time) which is
99+
/// later filled with the recorded charges for each digit
100+
explicit KrBoxClusterFinder() = default;
101+
102+
/// If a gain map exists, the map can be loaded with this function
103+
/// The function expects a CalDet file with a gain map (gain entry for each pad).
104+
void loadGainMapFromFile(const std::string_view calDetFileName, const std::string_view gainMapName = "GainMap");
105+
106+
/// Function used in macro to fill the map with all recorded digits
107+
void fillAndCorrectMap(std::vector<o2::tpc::Digit>& eventSector, const int sector);
97108

98109
/// After the map is created, we look for local maxima with this function:
99110
std::vector<std::tuple<int, int, int>> findLocalMaxima();
@@ -104,26 +115,39 @@ class KrBoxClusterFinder
104115

105116
private:
106117
// These variables can be varied
118+
// They were choses such that the box in each readout chamber is approx. the same size
107119
int mMaxClusterSizeTime = 3; ///< The "radius" of a cluster in time direction
108-
int mMaxClusterSizePad = 3; ///< radius in pad direction
109-
int mMaxClusterSizeRow = 2; ///< radius in row direction
120+
int mMaxClusterSizeRow; ///< The "radius" of a cluster in row direction
121+
int mMaxClusterSizePad; ///< The "radius" of a cluster in pad direction
122+
123+
int mMaxClusterSizeRowIROC = 3; ///< The "radius" of a cluster in row direction in IROC
124+
int mMaxClusterSizeRowOROC1 = 2; ///< The "radius" of a cluster in row direction in OROC1
125+
int mMaxClusterSizeRowOROC2 = 2; ///< The "radius" of a cluster in row direction in OROC2
126+
int mMaxClusterSizeRowOROC3 = 1; ///< The "radius" of a cluster in row direction in OROC3
110127

111-
// Todo: Differentiate between different ROCS:
112-
// int mMaxClusterSizeRowIROC = 3; // radius in row direction
113-
// int mMaxClusterSizeRowOROC1 = 2; // radius in row direction
114-
// int mMaxClusterSizeRowOROC2 = 2; // radius in row direction
115-
// int mMaxClusterSizeRowOROC3 = 1; // radius in row direction
128+
int mMaxClusterSizePadIROC = 5; ///< The "radius" of a cluster in pad direction in IROC
129+
int mMaxClusterSizePadOROC1 = 3; ///< The "radius" of a cluster in pad direction in OROC1
130+
int mMaxClusterSizePadOROC2 = 3; ///< The "radius" of a cluster in pad direction in OROC2
131+
int mMaxClusterSizePadOROC3 = 3; ///< The "radius" of a cluster in pad direction in OROC3
116132

117133
float mQThresholdMax = 10.0; ///< the Maximum charge in a cluster must exceed this value or it is discarded
118134
float mQThreshold = 1.0; ///< every charge which is added to a cluster must exceed this value or it is discarded
119135
int mMinNumberOfNeighbours = 1; ///< amount of direct neighbours required for a cluster maximum
120136

137+
std::unique_ptr<CalPad> mGainMap; ///< Gain map object
138+
121139
/// Maximum Map Dimensions
122140
/// Here is room for improvements
123141
static constexpr size_t MaxPads = 138; ///< Size of the map in pad-direction
124142
static constexpr size_t MaxRows = 152; ///< Size of the map in row-direction
125143
static constexpr size_t MaxTimes = 550; ///< Size of the map in time-direction
126144

145+
/// Values to define ROC boundaries
146+
static constexpr size_t MaxRowsIROC = 63; ///< Amount of rows in IROC
147+
static constexpr size_t MaxRowsOROC1 = 34; ///< Amount of rows in OROC1
148+
static constexpr size_t MaxRowsOROC2 = 30; ///< Amount of rows in OROC2
149+
static constexpr size_t MaxRowsOROC3 = 25; ///< Amount of rows in OROC3
150+
127151
/// Need an instance of Mapper to know position of pads
128152
const Mapper& mMapperInstance = o2::tpc::Mapper::instance();
129153

@@ -132,6 +156,9 @@ class KrBoxClusterFinder
132156
/// Here the map is defined where all digits are temporarily stored
133157
std::array<std::array<std::array<float, MaxPads>, MaxRows>, MaxTimes> mMapOfAllDigits{};
134158

159+
/// For each ROC, the maximum cluster size has to be chosen
160+
void setMaxClusterSize(int row);
161+
135162
/// To update the temporary cluster, i.e. all digits are added here
136163
void updateTempCluster(float tempCharge, int tempPad, int tempRow, int tempTime);
137164
/// After all digits are assigned to the cluster, the mean and sigmas are calculated here

Detectors/TPC/reconstruction/include/TPCReconstruction/KrCluster.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,37 @@ namespace tpc
2222

2323
struct KrCluster {
2424
public:
25-
float totCharge = 0; ///< Total charge of the cluster (ADC counts)
26-
float maxCharge = 0; ///< Maximum charge of the cluster (ADC counts)
27-
int size = 0; ///< Size of the cluster (TPCDigits)
28-
float meanPad = 0; ///< Center of gravity (Pad number)
29-
float meanRow = 0; ///< Center of gravity (Row number)
30-
float meanTime = 0; ///< Center of gravity (Time)
31-
float sigmaPad = 0; ///< RMS of cluster in pad direction
32-
float sigmaRow = 0; ///< RMS of cluster in row direction
33-
float sigmaTime = 0; ///< RMS of cluster in time direction
34-
int sector = 0; ///< Sector number
25+
unsigned char size = 0; ///< Size of the cluster (TPCDigits)
26+
unsigned char sector = 0; ///< Sector number
27+
unsigned char maxChargePad = 0; ///< Pad with max. charge in cluster (for leader pad method)
28+
unsigned char maxChargeRow = 0; ///< Row with max. charge in cluster (for leader pad method)
29+
float totCharge = 0; ///< Total charge of the cluster (ADC counts)
30+
float maxCharge = 0; ///< Maximum charge of the cluster (ADC counts)
31+
float meanPad = 0; ///< Center of gravity (Pad number)
32+
float meanRow = 0; ///< Center of gravity (Row number)
33+
float meanTime = 0; ///< Center of gravity (Time)
34+
float sigmaPad = 0; ///< RMS of cluster in pad direction
35+
float sigmaRow = 0; ///< RMS of cluster in row direction
36+
float sigmaTime = 0; ///< RMS of cluster in time direction
3537

3638
/// Used to set all Cluster variables to zero.
3739
void reset()
3840
{
41+
size = 0;
42+
sector = 0;
43+
maxChargePad = 0;
44+
maxChargeRow = 0;
3945
totCharge = 0;
4046
maxCharge = 0;
41-
size = 0;
4247
meanPad = 0;
4348
meanRow = 0;
4449
meanTime = 0;
4550
sigmaPad = 0;
4651
sigmaRow = 0;
4752
sigmaTime = 0;
48-
sector = 0;
4953
}
5054

51-
ClassDefNV(KrCluster, 1);
55+
ClassDefNV(KrCluster, 2);
5256
};
5357

5458
} // namespace tpc

Detectors/TPC/reconstruction/macro/findKrBoxCluster.C

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <vector>
2828
#endif
2929

30-
void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1)
30+
void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1, std::string_view gainMapFile = "")
3131
{
3232
// Read the digits:
3333
TFile* file = new TFile("tpcdigits.root");
@@ -51,22 +51,32 @@ void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1)
5151
tree->SetBranchAddress(Form("TPCDigit_%zu", iSec), &digitizedSignal[iSec]);
5252
}
5353

54+
// Create KrBoxClusterFinder object, memory is only allocated once
55+
auto clFinder = std::make_unique<o2::tpc::KrBoxClusterFinder>();
56+
if (gainMapFile.size()) {
57+
clFinder->loadGainMapFromFile(gainMapFile);
58+
}
59+
5460
// Now everything can get processed
5561
// Loop over all events
5662
for (int iEvent = 0; iEvent < nEntries; ++iEvent) {
5763
std::cout << iEvent + 1 << "/" << nEntries << std::endl;
5864
tree->GetEntry(iEvent);
5965
// Each event consists of sectors (atm only two)
66+
6067
for (int i = 0; i < 36; i++) {
6168
auto sector = digitizedSignal[i];
6269
if (sector->size() == 0) {
6370
continue;
6471
}
65-
// Create ClusterFinder Object on Heap since creation on stack fails
66-
// Probably due to too much memory consumption
67-
auto clFinder = std::make_unique<o2::tpc::KrBoxClusterFinder>(*sector);
72+
73+
// Fill map and (if specified) correct with existing gain map
74+
clFinder->fillAndCorrectMap(*sector, i);
75+
76+
// Find all local maxima in sector
6877
std::vector<std::tuple<int, int, int>> localMaxima = clFinder->findLocalMaxima();
69-
// Loop over cluster centers
78+
79+
// Loop over cluster centers = local maxima
7080
for (const std::tuple<int, int, int>& coords : localMaxima) {
7181
int padMax = std::get<0>(coords);
7282
int rowMax = std::get<1>(coords);
@@ -78,6 +88,7 @@ void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1)
7888
// Build total cluster
7989
o2::tpc::KrCluster tempCluster = clFinder->buildCluster(padMax, rowMax, timeMax);
8090
tempCluster.sector = i;
91+
8192
clusters.emplace_back(tempCluster);
8293
}
8394
}
@@ -90,3 +101,9 @@ void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1)
90101
fOut->Close();
91102
return;
92103
}
104+
105+
int main()
106+
{
107+
findKrBoxCluster();
108+
return 0;
109+
}

0 commit comments

Comments
 (0)