23#include <fairlogger/Logger.h>
40 const std::string newDataPath = dataPath +
"Vbb-0.0V";
42 }
else if (tableNumber == 1)
44 const std::string newDataPath = dataPath +
"Vbb-3.0V";
49 cout <<
"Object already initialized" << endl;
54 const float kTiny = 1e-6;
62 std::ifstream inpGrid;
65 inpGrid.open(inpfname, std::ifstream::in);
67 LOG(fatal) <<
"Failed to open file " << inpfname;
75 LOG(fatal) <<
"Failed to read X(col) binning from " << inpfname;
83 inpGrid.open(inpfname, std::ifstream::in);
85 LOG(fatal) <<
"Failed to open file " << inpfname;
92 LOG(fatal) <<
"Failed to read Y(row) binning from " << inpfname;
101 float val, gx, gy, gz;
102 int lost, untrck, dead, nele;
108 for (
int ix = 0; ix <
mNBinCol; ix++) {
109 for (
int iy = 0; iy <
mNBinRow; iy++) {
110 inpfname = composeDataName(ix, iy);
111 inpGrid.open(inpfname, std::ifstream::in);
112 if (inpGrid.fail()) {
113 LOG(fatal) <<
"Failed to open file " << inpfname;
121 LOG(fatal) <<
"Mismatch in Nz slices of bin X(col): " << ix <<
" Y(row): " << iy
122 <<
" wrt bin 0,0. File " << inpfname;
126 for (
int iz = 0; iz < nz; iz++) {
129 std::array<float, AlpideRespSimMat::MatSize>* arr = mat.
getArray();
130 for (
int ip = 0; ip < npix * npix; ip++) {
135 inpGrid >> lost >> dead >> untrck >> nele >> gx >> gy >> gz;
138 LOG(fatal) <<
"Failed reading data for depth(Z) slice " << iz <<
" from "
142 LOG(fatal) <<
"Wrong normalization Nele=" << nele <<
"for depth(Z) slice "
143 << iz <<
" from " << inpfname;
154 float norm = 1.f / nele;
155 for (
int ip = npix * npix; ip--;) {
158 mData.push_back(mat);
168 LOG(fatal) <<
"Mismatch between expected " <<
dataSize <<
" and loaded " <<
mData.size()
169 <<
" number of bins";
194 printf(
"Alpide response object of %zu matrices to map chagre in xyz to %dx%d pixels\n",
202string AlpideSimResponse::composeDataName(
int colBin,
int rowBin)
211 unique_ptr<char[]> tmp(
new char[
size]);
224 LOG(fatal) <<
"response object is not initialized";
226 bool flipCol =
false, flipRow =
true;
227 if (vDepth < mDptMin || vDepth >
mDptMax) {
245 size_t bin = getDepthBin(vDepth) +
mNBinDpt * (getRowBin(vRow) +
mNBinRow * getColBin(vCol));
246 if (bin >=
mData.size()) {
248 LOG(fatal) <<
"requested bin " << bin <<
"row/col/depth: " << getRowBin(vRow) <<
":" << getColBin(vCol)
249 <<
":" << getDepthBin(vDepth) <<
")"
250 <<
">= maxBin " <<
mData.size()
251 <<
" for X(row)=" << vRow <<
" Z(col)=" << vCol <<
" Y(depth)=" << vDepth;
273 LOG(fatal) <<
"response object is not initialized";
275 if (vDepth < mDptMin || vDepth >
mDptMax) {
297 size_t bin = getDepthBin(vDepth) +
mNBinDpt * (getRowBin(vRow) +
mNBinRow * getColBin(vCol));
298 if (bin >=
mData.size()) {
300 LOG(fatal) <<
"requested bin " << bin <<
"row/col/depth: " << getRowBin(vRow) <<
":" << getColBin(vCol)
301 <<
":" << getDepthBin(vDepth) <<
")"
302 <<
">= maxBin " <<
mData.size()
303 <<
" for X(row)=" << vRow <<
" Z(col)=" << vCol <<
" Y(depth)=" << vDepth;
314 for (
int iRow = 0; iRow <
NPix; iRow++) {
315 for (
int iCol = 0; iCol <
NPix; iCol++) {
316 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
Defining DataPointCompositeObject explicitly as copiable.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"