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 ~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 ClassDefNV(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 int mNBinCol = 0;
95 int mNBinRow = 0;
96 int mNBinDpt = 0;
97 int mMaxBinCol = 0;
98 int mMaxBinRow = 0;
99 float mColMax = SegmentationAlpide::PitchCol / 2.f;
100 float mRowMax = SegmentationAlpide::PitchRow / 2.f;
101 float mDptMin = 0.f;
102 float mDptMax = 0.f;
103 float mDptShift = 0.f;
104 float mStepInvCol = 0;
105 float mStepInvRow = 0;
106 float mStepInvDpt = 0;
107 std::vector<AlpideRespSimMat> mData;
109 std::string mDataPath;
110 std::string mGridColName = "grid_list_x.txt";
111 std::string mGridRowName = "grid_list_y.txt";
112 std::string mColRowDataFmt = "data_pixels_%.2f_%.2f.txt";
113
114 public:
115 AlpideSimResponse() = default;
117
118 void initData(int tableNumber, std::string dataPath, const bool quiet = true);
119
120 bool getResponse(float vRow, float vCol, float cDepth, AlpideRespSimMat& dest) const;
121 const AlpideRespSimMat* getResponse(float vRow, float vCol, float vDepth, bool& flipRow, bool& flipCol) const;
122 const AlpideRespSimMat* getResponse(float vRow, float vCol, float vDepth, bool& flipRow, bool& flipCol, float rowMax, float colMax) const;
123 static int constexpr getNPix() { return AlpideRespSimMat::getNPix(); }
124 int getNBinCol() const { return mNBinCol; }
125 int getNBinRow() const { return mNBinRow; }
126 int getNBinDepth() const { return mNBinDpt; }
127 float getColMax() const { return mColMax; }
128 float getRowMax() const { return mRowMax; }
129 float getDepthMin() const { return mDptMin; }
130 float getDepthMax() const { return mDptMax; }
131 float getDepthShift() const { return mDptShift; }
132 float getStepCol() const { return mStepInvCol ? 1. / mStepInvCol : 0.f; }
133 float getStepRow() const { return mStepInvRow ? 1. / mStepInvRow : 0.f; }
134 float getStepDepth() const { return mStepInvDpt ? 1. / mStepInvDpt : 0.f; }
135 void setDataPath(const std::string pth) { mDataPath = pth; }
136 void setGridColName(const std::string nm) { mGridColName = nm; }
137 void setGridRowName(const std::string nm) { mGridRowName = nm; }
138 void setColRowDataFmt(const std::string nm) { mColRowDataFmt = nm; }
139 const std::string& getDataPath() const { return mDataPath; }
140 const std::string& getGridColName() const { return mGridColName; }
141 const std::string& getGridRowName() const { return mGridRowName; }
142 const std::string& getColRowDataFmt() const { return mColRowDataFmt; }
143 void print() const;
144
146};
147
148//-----------------------------------------------------
149inline int AlpideSimResponse::getColBin(float pos) const
150{
152 int i = pos * mStepInvCol + 0.5f;
153 return i < mNBinCol ? i : mMaxBinCol;
154}
155
156//-----------------------------------------------------
157inline int AlpideSimResponse::getRowBin(float pos) const
158{
160 int i = pos * mStepInvRow + 0.5f;
161 return i < mNBinRow ? i : mMaxBinRow;
162}
163
164//-----------------------------------------------------
165inline int AlpideSimResponse::getDepthBin(float pos) const
166{
169 int i = (mDptMax - pos) * mStepInvDpt;
170 return i < 0 ? 0 : i; // depth bin
171}
172
173} // namespace itsmft
174} // namespace o2
175
176#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
const std::string & getDataPath() const
ClassDefNV(AlpideSimResponse, 1)
AlpideSimResponse()=default
format to read the data for given Col,Row
const std::string & getColRowDataFmt() const
void setDataPath(const std::string pth)
const std::string & getGridColName() const
bool getResponse(float vRow, float vCol, float cDepth, AlpideRespSimMat &dest) const
void setGridRowName(const std::string nm)
const std::string & getGridRowName() const
void initData(int tableNumber, std::string dataPath, const bool quiet=true)
void setGridColName(const std::string nm)
static int constexpr getNPix()
void setColRowDataFmt(const std::string nm)
static constexpr float PitchCol
static constexpr float PitchRow
GLenum src
Definition glcorearb.h:1767
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...