#include "PndSdsCalcPixelDif.h" #include #include "TRandom.h" PndSdsCalcPixelDif::PndSdsCalcPixelDif() : fPixels(), fActivePixel(), fPixelSizeX(0.), fPixelSizeY(0.), fThreshold(0.), fNoise(0.), fQspread(0.), fEnergy(0.), fVerboseLevel(0) {} PndSdsCalcPixelDif::PndSdsCalcPixelDif(Double_t lx, Double_t ly, Double_t qspread,Double_t threshold, Double_t noise) : fPixels(), fActivePixel(), fPixelSizeX(lx), fPixelSizeY(ly), fThreshold(threshold), fNoise(noise), fQspread(qspread), fEnergy(0.), fVerboseLevel(0) {} Int_t PndSdsCalcPixelDif::GetPixelsAlternative(Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy, std::vector& cols, std::vector& rows, std::vector& charges) { std::vector pixels = GetPixels(inx,iny,outx,outy,energy); Int_t npix=pixels.size(); for(Int_t i=0;i2) Info("PndSdsCalcPixelDif::GetPixelsAlternative()","pass this pixel: i=%i, c=%i, r=%i, q=%f",i,pixels[i].GetCol(),pixels[i].GetRow(),pixels[i].GetCharge()); cols.push_back(pixels[i].GetCol()); rows.push_back(pixels[i].GetRow()); charges.push_back(pixels[i].GetCharge()); } return npix; } std::vector PndSdsCalcPixelDif::GetPixels(Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t dE) { fPixels.clear(); if(0>=fPixelSizeX || 0>=fPixelSizeY){ Error("PndSdsCalcPixelDif::GetPixels()","Invalid Pixel sizes: fPixelSizeX=%g,fPixelSizeY=%g",fPixelSizeX,fPixelSizeY); return fPixels; } // Do charge diffusion integrated analytically over a path length // 0.5*(1+erf(x)) is the integral over a gauss from -inf to x // factor 0.5 is applied last, the +1 terms cancel in the difference // the 2 Dimensions are trated equally inx/=fPixelSizeX; outx/=fPixelSizeX; iny/=fPixelSizeY; outy/=fPixelSizeY; Double_t Q = ChargeFromEloss(dE); if(outxfNrx || j>fNry) return; // TODO put max. pixel number here? Double_t smearedCharge = SmearCharge(charge); if (smearedCharge<=fThreshold) return; if(fVerboseLevel>3) Info("PndSdsCalcPixelDif::InjectPixelCharge","i=%i, j=%i,charge=%f",i,j,charge); fActivePixel.SetCol(i); // x axis fActivePixel.SetRow(j); // y axis fActivePixel.SetCharge(charge); fPixels.push_back(fActivePixel); // fActivePixel content will be copied return; } //______________________________________________________________________________ Double_t PndSdsCalcPixelDif::SmearCharge(Double_t charge) { Double_t smeared = gRandom->Gaus(charge,fNoise); if (fVerboseLevel > 3) std::cout<<" charge = "<