24#include <fairlogger/Logger.h>
41 const std::string newDataPath = dataPath +
"Vbb-0.0V";
43 }
else if (tableNumber == 1)
45 const std::string newDataPath = dataPath +
"Vbb-3.0V";
50 cout <<
"Object already initialized" << endl;
55 const float kTiny = 1e-6;
62 gSystem->ExpandPathName(expandedDataPath);
65 std::ifstream inpGrid;
68 inpGrid.open(inpfname, std::ifstream::in);
70 LOG(fatal) <<
"Failed to open file " << inpfname;
78 LOG(fatal) <<
"Failed to read X(col) binning from " << inpfname;
86 inpGrid.open(inpfname, std::ifstream::in);
88 LOG(fatal) <<
"Failed to open file " << inpfname;
95 LOG(fatal) <<
"Failed to read Y(row) binning from " << inpfname;
104 float val, gx, gy, gz;
105 int lost, untrck, dead, nele;
111 for (
int ix = 0; ix <
mNBinCol; ix++) {
112 for (
int iy = 0; iy <
mNBinRow; iy++) {
113 inpfname = composeDataName(ix, iy);
114 inpGrid.open(inpfname, std::ifstream::in);
115 if (inpGrid.fail()) {
116 LOG(fatal) <<
"Failed to open file " << inpfname;
124 LOG(fatal) <<
"Mismatch in Nz slices of bin X(col): " << ix <<
" Y(row): " << iy
125 <<
" wrt bin 0,0. File " << inpfname;
129 for (
int iz = 0; iz < nz; iz++) {
132 std::array<float, AlpideRespSimMat::MatSize>* arr = mat.
getArray();
133 for (
int ip = 0; ip < npix * npix; ip++) {
138 inpGrid >> lost >> dead >> untrck >> nele >> gx >> gy >> gz;
141 LOG(fatal) <<
"Failed reading data for depth(Z) slice " << iz <<
" from "
145 LOG(fatal) <<
"Wrong normalization Nele=" << nele <<
"for depth(Z) slice "
146 << iz <<
" from " << inpfname;
157 float norm = 1.f / nele;
158 for (
int ip = npix * npix; ip--;) {
161 mData.push_back(mat);
171 LOG(fatal) <<
"Mismatch between expected " <<
dataSize <<
" and loaded " <<
mData.size()
172 <<
" number of bins";
197 printf(
"Alpide response object of %zu matrices to map chagre in xyz to %dx%d pixels\n",
205string AlpideSimResponse::composeDataName(
int colBin,
int rowBin)
214 unique_ptr<char[]> tmp(
new char[
size]);
227 LOG(fatal) <<
"response object is not initialized";
229 bool flipCol =
false, flipRow =
true;
230 if (vDepth < mDptMin || vDepth >
mDptMax) {
248 size_t bin = getDepthBin(vDepth) +
mNBinDpt * (getRowBin(vRow) +
mNBinRow * getColBin(vCol));
249 if (bin >=
mData.size()) {
251 LOG(fatal) <<
"requested bin " << bin <<
"row/col/depth: " << getRowBin(vRow) <<
":" << getColBin(vCol)
252 <<
":" << getDepthBin(vDepth) <<
")"
253 <<
">= maxBin " <<
mData.size()
254 <<
" for X(row)=" << vRow <<
" Z(col)=" << vCol <<
" Y(depth)=" << vDepth;
276 LOG(fatal) <<
"response object is not initialized";
278 if (vDepth < mDptMin || vDepth >
mDptMax) {
300 size_t bin = getDepthBin(vDepth) +
mNBinDpt * (getRowBin(vRow) +
mNBinRow * getColBin(vCol));
301 if (bin >=
mData.size()) {
303 LOG(fatal) <<
"requested bin " << bin <<
"row/col/depth: " << getRowBin(vRow) <<
":" << getColBin(vCol)
304 <<
":" << getDepthBin(vDepth) <<
")"
305 <<
">= maxBin " <<
mData.size()
306 <<
" for X(row)=" << vRow <<
" Z(col)=" << vCol <<
" Y(depth)=" << vDepth;
317 for (
int iRow = 0; iRow <
NPix; iRow++) {
318 for (
int iCol = 0; iCol <
NPix; iCol++) {
319 printf(
"%+e ",
getValue(iRow, iCol, flipRow, flipCol));
ClassImp(o2::itsmft::AlpideSimResponse)
constexpr float micron2cm
Definition of the ITSMFT Alpide simulated response parametrization.
static int constexpr getNPix()
number of pixels in the quadrant
void adopt(const AlpideRespSimMat &src, bool flipRow=false, bool flipCol=false)
static int constexpr NPix
void print(bool flipRow=false, bool flipCol=false) const
print values
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
int mMaxBinRow
max allowed Xb (to avoid subtraction)
float mDptShift
upper boundary of Dpt
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
int mMaxBinCol
number of bins in Z(sensor dept)
bool getResponse(float vRow, float vCol, float cDepth, AlpideRespSimMat &dest) const
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)
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
float mDptMax
lower boundary of Dpt
float mStepInvRow
inverse step of the Col grid
std::string mDataPath
path to look for data file
static int constexpr getNPix()
int mNBinRow
number of bins in X(col direction)
GLsizei const GLchar *const * string
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"