Project
Loading...
Searching...
No Matches
AlpideSimResponse.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
14
15#ifndef ALICEO2_ITSSMFT_ALPIDESIMRESPONSE_H
16#define ALICEO2_ITSSMFT_ALPIDESIMRESPONSE_H
17
18#include <array>
19#include <string>
20#include <vector>
21#include <Rtypes.h>
22
24
25namespace o2
26{
27namespace itsmft
28{
29/*
30 * AlpideRespSimMat : class to access the response: probability to collect electron
31 * in MNPix*MNPix cells.
32 */
34{
35 public:
36 static int constexpr NPix = 5;
37 static int constexpr MatSize = NPix * NPix;
38 static int constexpr getNPix() { return NPix; }
39
40 AlpideRespSimMat() = default;
41 virtual ~AlpideRespSimMat() = default;
42
43 void adopt(const AlpideRespSimMat& src, bool flipRow = false, bool flipCol = false)
44 {
45 // copy constructor with option of channels flipping
46 for (int iRow = NPix; iRow--;) {
47 int rw = flipRow ? NPix - 1 - iRow : iRow;
48 for (int iCol = NPix; iCol--;) {
49 int bDest = rw * NPix + (flipCol ? NPix - 1 - iCol : iCol);
50 data[bDest] = src.data[iRow * NPix + iCol];
51 }
52 }
53 }
54
56 float getValue(int iRow, int iCol) const { return data[iRow * NPix + iCol]; }
57 float getValue(int iRow, int iCol, bool flipRow, bool flipCol) const
58 {
59 int bin = (flipRow ? NPix - 1 - iRow : iRow) * NPix + (flipCol ? NPix - 1 - iCol : iCol);
60 return data[bin];
61 }
62
64 std::array<float, MatSize>* getArray() { return &data; }
65
67 void print(bool flipRow = false, bool flipCol = false) const;
68
69 private:
70 std::array<float, MatSize> data;
71
72 ClassDef(AlpideRespSimMat, 1);
73};
74
75/*
76 * AlpideSimResponse: container for Alpide simulates parameterized response matrices
77 * Based on the Miljenko Šuljić standalone code and needs as an input text matrices
78 * from simulation.
79 * Provides for the electron injected to point X(columns direction),Y (rows direction)
80 * (with respect to pixel center) and Z (depth, with respect to epitaxial layer inner
81 * serface!!! i.e. touching the substrate) the probability to be collected in every
82 * of NPix*NPix pixels with reference pixel in the center.
83 */
84
86{
87
88 private:
89 int getColBin(float pos) const;
90 int getRowBin(float pos) const;
91 int getDepthBin(float pos) const;
92 std::string composeDataName(int colBin, int rowBin);
93
94 protected:
95 int mNBinCol = 0;
96 int mNBinRow = 0;
97 int mNBinDpt = 0;
98 int mMaxBinCol = 0;
99 int mMaxBinRow = 0;
102 float mDptMin = 0.f;
103 float mDptMax = 0.f;
104 float mDptShift = 0.f;
105 float mStepInvCol = 0;
106 float mStepInvRow = 0;
107 float mStepInvDpt = 0;
108 std::vector<AlpideRespSimMat> mData;
110 std::string mDataPath;
111 std::string mGridColName = "grid_list_x.txt";
112 std::string mGridRowName = "grid_list_y.txt";
113 std::string mColRowDataFmt = "data_pixels_%.2f_%.2f.txt";
114
115 public:
116 AlpideSimResponse() = default;
118
119 void initData(int tableNumber, std::string dataPath, const bool quiet = true);
120
121 bool getResponse(float vRow, float vCol, float cDepth, AlpideRespSimMat& dest) const;
122 const AlpideRespSimMat* getResponse(float vRow, float vCol, float vDepth, bool& flipRow, bool& flipCol) const;
123 const AlpideRespSimMat* getResponse(float vRow, float vCol, float vDepth, bool& flipRow, bool& flipCol, float rowMax, float colMax) const;
124 static int constexpr getNPix() { return AlpideRespSimMat::getNPix(); }
125 int getNBinCol() const { return mNBinCol; }
126 int getNBinRow() const { return mNBinRow; }
127 int getNBinDepth() const { return mNBinDpt; }
128 float getColMax() const { return mColMax; }
129 float getRowMax() const { return mRowMax; }
130 float getDepthMin() const { return mDptMin; }
131 float getDepthMax() const { return mDptMax; }
132 float getDepthShift() const { return mDptShift; }
133 float getStepCol() const { return mStepInvCol ? 1. / mStepInvCol : 0.f; }
134 float getStepRow() const { return mStepInvRow ? 1. / mStepInvRow : 0.f; }
135 float getStepDepth() const { return mStepInvDpt ? 1. / mStepInvDpt : 0.f; }
136 void setColMax(float v) noexcept { mColMax = v; }
137 void setRowMax(float v) noexcept { mRowMax = v; }
138 void setDataPath(const std::string pth) { mDataPath = pth; }
139 void setGridColName(const std::string nm) { mGridColName = nm; }
140 void setGridRowName(const std::string nm) { mGridRowName = nm; }
141 void setColRowDataFmt(const std::string nm) { mColRowDataFmt = nm; }
142 const std::string& getDataPath() const { return mDataPath; }
143 const std::string& getGridColName() const { return mGridColName; }
144 const std::string& getGridRowName() const { return mGridRowName; }
145 const std::string& getColRowDataFmt() const { return mColRowDataFmt; }
146 void print() const;
147
149};
150
151//-----------------------------------------------------
152inline int AlpideSimResponse::getColBin(float pos) const
153{
155 int i = pos * mStepInvCol + 0.5f;
156 return i < mNBinCol ? i : mMaxBinCol;
157}
158
159//-----------------------------------------------------
160inline int AlpideSimResponse::getRowBin(float pos) const
161{
163 int i = pos * mStepInvRow + 0.5f;
164 return i < mNBinRow ? i : mMaxBinRow;
165}
166
167//-----------------------------------------------------
168inline int AlpideSimResponse::getDepthBin(float pos) const
169{
172 int i = (mDptMax - pos) * mStepInvDpt;
173 return i < 0 ? 0 : i; // depth bin
174}
175
176} // namespace itsmft
177} // namespace o2
178
179#endif
void print() const
int32_t i
uint16_t pos
Definition RawData.h:3
Definition of the SegmentationAlpide class.
static int constexpr getNPix()
number of pixels in the quadrant
void adopt(const AlpideRespSimMat &src, bool flipRow=false, bool flipCol=false)
float getValue(int iRow, int iCol, bool flipRow, bool flipCol) const
float getValue(int iRow, int iCol) const
probability to find an electron in pixel ix,iy,iz
std::array< float, MatSize > * getArray()
pointer on underlying array
static int constexpr MatSize
side of quadrant (pixels) with non-0 response
virtual ~AlpideRespSimMat()=default
const std::string & getDataPath() const
int mMaxBinRow
max allowed Xb (to avoid subtraction)
AlpideSimResponse()=default
format to read the data for given Col,Row
float mDptShift
upper boundary of Dpt
const std::string & getColRowDataFmt() const
float mStepInvCol
shift of the depth center wrt 0
int mNBinDpt
number of bins in Y(row direction)
void setDataPath(const std::string pth)
std::vector< AlpideRespSimMat > mData
inverse step of the Dpt grid
float mRowMax
upper boundary of Col
const std::string & getGridColName() const
int mMaxBinCol
number of bins in Z(sensor dept)
bool getResponse(float vRow, float vCol, float cDepth, AlpideRespSimMat &dest) const
void setGridRowName(const std::string nm)
void setColMax(float v) noexcept
std::string mGridRowName
name of the file with grid in Col
std::string mColRowDataFmt
name of the file with grid in Row
float mColMax
max allowed Yb (to avoid subtraction)
const std::string & getGridRowName() const
float mDptMin
upper boundary of Row
void initData(int tableNumber, std::string dataPath, const bool quiet=true)
float mStepInvDpt
inverse step of the Row grid
ClassDefNV(AlpideSimResponse, 2)
float mDptMax
lower boundary of Dpt
float mStepInvRow
inverse step of the Col grid
void setRowMax(float v) noexcept
void setGridColName(const std::string nm)
std::string mDataPath
path to look for data file
static int constexpr getNPix()
int mNBinRow
number of bins in X(col direction)
void setColRowDataFmt(const std::string nm)
static constexpr float PitchCol
static constexpr float PitchRow
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...