Project
Loading...
Searching...
No Matches
TPCClusSelector.h
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
12// helper class for TPC clusters selection
13
14#ifndef ALICEO2_TPCCLUSSELECTOR_H
15#define ALICEO2_TPCCLUSSELECTOR_H
16
17#include <vector>
18#include <array>
19#include <Rtypes.h>
20
21namespace o2::tpc
22{
23class ClusterNativeAccess;
24
26{
27 // helper to select TPC cluster matching to certain timebin and optionally pads range
28 // example of usage:
29 /*
30 TPCClusSelector clSel;
31 o2::tpc::ClusterNativeHelper::Reader tcpClusterReader;
32 tcpClusterReader.init(native_clusters_file.c_str());
33 o2::tpc::ClusterNativeAccess tpcClusterIdxStruct;
34 std::unique_ptr<o2::tpc::ClusterNative[]> tpcClusterBuffer; ///< buffer for clusters in tpcClusterIdxStruct
35 o2::tpc::ClusterNativeHelper::ConstMCLabelContainerViewWithBuffer tpcClusterMCBuffer; ///< buffer for mc labels
36
37 tcpClusterReader.read(iTF);
38 tcpClusterReader.fillIndex(tpcClusterIdxStruct, tpcClusterBuffer, tpcClusterMCBuffer);
39
40 clSel.fill(tpcClusterIdxStruct); // Create sorted index
41 // to get i-th cluster in orderer timebins:
42 const auto& clus = tpcClusterIdxStruct.clusters[sector][row][ clSel.getIndex(sector, row, i)];
43
44 // to get sorted indices range of clusters in the tbmin:tbmax range
45 auto rng = clSel.findClustersRange(sector, row, tbmin, tbmax, tpcClusterIdxStruct);
46 if (rng.first>rng.second) { // nothing is found }
47 const auto& cln = tpcClusterIdxStruct.clusters[sector][row][clSel.getIndex(sector, row, rng.first )]; /...
48
49 // to get number of clusters in tbmin:tbmax, padmin:padmax range (and optionally get the list)
50 std::vector<int> cllist; // optional list
51 int nfnd = clSel.findClustersEntries(sector, row, tbmin, tbmax, padmin, padmax, tpcClusterIdxStruct, &cllist);
52 for (int i=0;i<nfnd;i++) {
53 const auto& cln = tpcClusterIdxStruct.clusters[sector][row][cllist[i]]; /... direct indices!
54 }
55 */
56
57 public:
58 void clear()
59 {
60 for (auto& s : mSectors)
61 s.clear();
62 }
63 size_t getIndex(int sec, int row, uint32_t icl) const { return mSectors[sec].rows[row][icl]; }
64
65 std::pair<int, int> findClustersRange(int sec, int row, float tbmin, float tbmax, const o2::tpc::ClusterNativeAccess& tpcClusterIdxStruct);
66 int findClustersEntries(int sec, int row, float tbmin, float tbmax, float padmin, float padmax, const o2::tpc::ClusterNativeAccess& tpcClusterIdxStruct, std::vector<int>* clIDDirect = nullptr);
67 void fill(const o2::tpc::ClusterNativeAccess& tpcClusterIdxStruct);
68
69 int getNThreads() const { return mNThreads; }
70 void setNThreads(int n);
71
72 private:
73 struct Sector {
74 static constexpr int NRows = 152;
75 std::array<std::vector<uint16_t>, NRows> rows;
76 void clear()
77 {
78 for (auto& r : rows)
79 r.clear();
80 }
81 };
82
83 static constexpr int NSectors = 36;
84 std::array<Sector, NSectors> mSectors{};
85 int mNThreads = 1;
86
87 ClassDefNV(TPCClusSelector, 1);
88};
89
90} // namespace o2::tpc
91
92#endif
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
size_t getIndex(int sec, int row, uint32_t icl) const
std::pair< int, int > findClustersRange(int sec, int row, float tbmin, float tbmax, const o2::tpc::ClusterNativeAccess &tpcClusterIdxStruct)
void fill(const o2::tpc::ClusterNativeAccess &tpcClusterIdxStruct)
int findClustersEntries(int sec, int row, float tbmin, float tbmax, float padmin, float padmax, const o2::tpc::ClusterNativeAccess &tpcClusterIdxStruct, std::vector< int > *clIDDirect=nullptr)
GLdouble n
Definition glcorearb.h:1982
Global TPC definitions and constants.
vec clear()
std::vector< int > row
std::vector< ReadoutWindowData > rows