13 #include <digparticle.h>
25 #include <TClonesArray.h>
27 #include <TProfile2D.h>
33 #include "digtransport.h"
37 extern Int_t GlobalSeed;
41 Double_t Lorentz2D(Double_t *x, Double_t *par){
49 Double_t Pi = 3.141592653;
50 return par[3]*par[0]/Pi/((x[0]-par[1])*(x[0]-par[1])+(x[1]-par[2])*(x[1]-par[2])+par[0]*par[0]) ;
57 Double_t SumGaus2D(Double_t *x, Double_t *par){
68 if((par[2]!=0.0) && (par[4]!=0.0) && (par[7]!=0.0) && (par[9]!=0.0)){
69 double rx = (x[0]-par[1])/par[2];
70 double ry = (x[1]-par[3])/par[4];
71 double rx2 = (x[0]-par[6])/par[7];
72 double ry2 = (x[1]-par[8])/par[9];
73 return par[0]*( TMath::Exp(-(rx*rx+ry*ry)/2.0)+par[5]*TMath::Exp(-(rx2*rx2+ry2*ry2)/2.0) ) ;
75 return par[0]+par[1]+par[2]+par[3]+par[4]+par[5]+par[6]+par[7]+par[8]+par[9];
81 Double_t SumGausLorentz2D(Double_t *x, Double_t *par){
95 Double_t Pi = 3.141592653;
96 if((par[2]!=0.0) && (par[4]!=0.0) ){
97 double rx = (x[0]-par[1])/par[2];
98 double ry = (x[1]-par[3])/par[4];
99 return par[0]*( TMath::Exp(-(rx*rx+ry*ry)/2.0)
100 +par[8]*par[5]/Pi/((x[0]-par[6])*(x[0]-par[6])+(x[1]-par[7])*(x[1]-par[7])+par[5]*par[5])
108 Double_t SumGausLorentz2Dnew(Double_t *x, Double_t *par){
125 Double_t Pi = 3.141592653;
126 if((par[2]!=0.0) && (par[4]!=0.0) ){
127 double rx = (x[0]-par[1])/par[2];
128 double ry = (x[1]-par[3])/par[4];
130 double rx2 = (x[0])/par[10];
131 double ry2 = (x[1])/par[10];
134 if( TMath::Sqrt(x[0]*x[0]+x[1]*x[1])<200.0 ){
135 return par[0]*( TMath::Exp(-(rx*rx+ry*ry)/2.0)
136 +par[8]*par[5]/Pi/((x[0]-par[6])*(x[0]-par[6])+(x[1]-par[7])*(x[1]-par[7])+par[5]*par[5])
137 +par[9]*TMath::Exp(-(rx2*rx2+ry2*ry2)/2.0)
140 return par[0]*( TMath::Exp(-(rx*rx+ry*ry)/2.0)
141 +par[8]*par[5]/Pi/((x[0]-par[6])*(x[0]-par[6])+(x[1]-par[7])*(x[1]-par[7])+par[5]*par[5])
152 Double_t SumGausLorentz1D(Double_t *x, Double_t *par){
167 Double_t Pi = 3.141592653;
169 Double_t rx = (x[0]-par[1])/par[2];
171 tempoutput= par[0]*( TMath::Exp(-(rx*rx)/2.0)
172 +par[5]*par[3]/Pi/ ((x[0]-par[4])*(x[0]-par[4]) +par[3]*par[3])
192 DIGParticle::DIGParticle(Float_t EntryX, Float_t EntryY, Float_t EntryZ,
193 Float_t ExitX, Float_t ExitY, Float_t ExitZ, Float_t Energy_deposited)
201 fEnergy_deposited = Energy_deposited;
206 fSegmentCharge.clear();
210 fAnalogChargeMap.clear();
211 fDigitalChargeMap.clear();
216 DIGParticle::DIGParticle(
DIGParticle & adigparticle) : TObject()
218 fEntryX = adigparticle.GetEntryX();
219 fEntryY = adigparticle.GetEntryY();
220 fEntryZ = adigparticle.GetEntryZ();
221 fExitX = adigparticle.GetExitX();
222 fExitY = adigparticle.GetExitY();
223 fExitZ = adigparticle.GetExitZ();
224 fEnergy_deposited = adigparticle.GetEnergy_deposited();
225 fNSegment =adigparticle.GetNSegment();
226 fSegmentX.resize(fNSegment);
227 fSegmentY.resize(fNSegment);
228 fSegmentZ.resize(fNSegment);
229 fSegmentCharge.resize(fNSegment);
231 for (Int_t i=0 ; i<fNSegment ; i++){
232 fSegmentX[i] = adigparticle.GetSegmentX()[i];
233 fSegmentY[i] = adigparticle.GetSegmentY()[i];
234 fSegmentZ[i] = adigparticle.GetSegmentZ()[i];
235 fSegmentCharge[i] = adigparticle.GetSegmentCharge()[i];
237 fNpixels = adigparticle.GetNpixels();
238 fPixelMap.resize(fNpixels);
239 fAnalogChargeMap.resize(fNpixels);
240 fDigitalChargeMap.resize(fNpixels);
241 for (Int_t i=0 ; i<fNpixels ; i++){
242 fPixelMap[i] = adigparticle.GetPixelMap()[i];
243 fAnalogChargeMap[i] = adigparticle.GetAnalogCharge()[i];
244 fDigitalChargeMap[i] = adigparticle.GetDigitalCharge()[i];
251 DIGParticle::~DIGParticle() {
258 void DIGParticle::Clear(
const Option_t *)
264 void DIGParticle::ComputeChargeDeposition(Float_t StartingSegmentSize, Float_t MaximumSegmentSize,
265 Float_t MaximumChargePerSegment)
267 Float_t SegmentSize = StartingSegmentSize;
268 Float_t TotalLength = TMath::Sqrt((fExitX-fEntryX)*(fExitX-fEntryX)
269 +(fExitY-fEntryY)*(fExitY-fEntryY)
270 +(fExitZ-fEntryZ)*(fExitZ-fEntryZ));
272 Float_t ChargePerSegment = 0.0;
276 fNSegment = int(TotalLength*1.000001/SegmentSize) ;
280 SegmentSize = TotalLength/float(fNSegment);
281 ChargePerSegment = fEnergy_deposited / float(fNSegment);
283 while((SegmentSize>MaximumSegmentSize)&&(ChargePerSegment > MaximumChargePerSegment)){
284 Int_t newNSegment = int(fNSegment *1.1);
285 if(newNSegment==fNSegment){fNSegment++;}
286 SegmentSize = TotalLength/float(fNSegment);
287 ChargePerSegment = fEnergy_deposited / float(fNSegment);
289 Float_t xstep = fExitX-fEntryX;
290 Float_t ystep = fExitY-fEntryY;
291 Float_t zstep = fExitZ-fEntryZ;
294 for (Int_t i=0 ; i<fNSegment ; i++){
295 fSegmentX.push_back(fEntryX + (
float(i+0.5)* xstep/
float(fNSegment)) );
296 fSegmentY.push_back(fEntryY + (
float(i+0.5)* ystep/
float(fNSegment)) );
297 fSegmentZ.push_back(fEntryZ + (
float(i+0.5)* zstep/
float(fNSegment)) );
298 fSegmentCharge.push_back(ChargePerSegment );
306 void DIGParticle::PrintInfo() {
307 std::cout<<
"---------Particle properties------------- "<<endl;
308 std::cout<<
"fEntryX fEntryY fEntryZ"<<endl;
309 std::cout<<fEntryX<<
" "<< fEntryY<<
" "<<fEntryZ<<endl;
310 std::cout<<
"fExitX fExitY fExitZ fEnergy_deposited"<<endl;
311 std::cout<<fExitX <<
" "<<fExitY <<
" "<<fExitZ <<
" "<<fEnergy_deposited <<endl;
312 std::cout<<fNSegment<<
" Segments X Y Z Charge"<<endl;
316 cout<<
" size vectors "<< fPixelMap.size()<<
" "<<fAnalogChargeMap.size()<<
" "<<fDigitalChargeMap.size()<<endl;
317 std::cout<<fNpixels<<
" fNpixels map analog digital "<<endl;
318 for (Int_t i=0 ; i<fNpixels ; i++){
319 std::cout<<i<<
" "<<fPixelMap[i]<<
" "<<fAnalogChargeMap[i]<<
" "<<fDigitalChargeMap[i]<<endl;
326 Float_t pitchX = aDIGPlane->GetPitchX();
327 Float_t pitchY = aDIGPlane->GetPitchY();
329 Float_t lorentz2Dmodel_Cp0 = aDIGTransport->GetLorentz2DModel_Cp0();
330 Float_t lorentz2Dmodel_Cp1 = aDIGTransport->GetLorentz2DModel_Cp1();
331 Float_t rangelimit_inpitchunit = aDIGTransport->GetRangeLimit_InPitchUnit();
333 Int_t ChargeModel = aDIGTransport->GetChargeModel();
335 Float_t Gauss2DModel_sigma1_Cp0 = aDIGTransport->GetGauss2DModel_sigma1_Cp0();
336 Float_t Gauss2DModel_sigma1_Cp1 = aDIGTransport->GetGauss2DModel_sigma1_Cp1();
337 Float_t Gauss2DModel_sigma2_Cp0 = aDIGTransport->GetGauss2DModel_sigma2_Cp0();
338 Float_t Gauss2DModel_sigma2_Cp1 = aDIGTransport->GetGauss2DModel_sigma2_Cp1();
339 Float_t Gauss2DModel_weight = aDIGTransport->GetGauss2DModel_weight();
341 Float_t LorGaussModel_Norm1_Cp0 = aDIGTransport->GetLorGaussModel_Norm1_Cp0();
342 Float_t LorGaussModel_Norm1_Cp1 = aDIGTransport->GetLorGaussModel_Norm1_Cp1();
343 Float_t LorGaussModel_Norm1_Cp2 = aDIGTransport->GetLorGaussModel_Norm1_Cp2();
344 Float_t LorGaussModel_sigma_Cp0 = aDIGTransport->GetLorGaussModel_sigma_Cp0();
345 Float_t LorGaussModel_sigma_Cp1 = aDIGTransport->GetLorGaussModel_sigma_Cp1();
346 Float_t LorGaussModel_C_Cp0 = aDIGTransport->GetLorGaussModel_C_Cp0();
347 Float_t LorGaussModel_C_Cp1 = aDIGTransport->GetLorGaussModel_C_Cp1();
348 Float_t LorGaussModel_Norm_Cp0 = aDIGTransport->GetLorGaussModel_Norm_Cp0();
349 Float_t LorGaussModel_Norm_Cp1 = aDIGTransport->GetLorGaussModel_Norm_Cp1();
351 Float_t lorlorgausModel_Norm1_Cp0 = aDIGTransport->GetlorlorgausModel_Norm1_Cp0() ;
352 Float_t lorlorgausModel_Norm1_Cp1 = aDIGTransport->GetlorlorgausModel_Norm1_Cp1() ;
353 Float_t lorlorgausModel_x01_Cp0 = aDIGTransport->GetlorlorgausModel_x01_Cp0() ;
354 Float_t lorlorgausModel_x01_Cp1 = aDIGTransport->GetlorlorgausModel_x01_Cp1() ;
355 Float_t lorlorgausModel_sigmax1_Cp0 = aDIGTransport->GetlorlorgausModel_sigmax1_Cp0();
356 Float_t lorlorgausModel_sigmax1_Cp1 = aDIGTransport->GetlorlorgausModel_sigmax1_Cp1();
357 Float_t lorlorgausModel_y01_Cp0 = aDIGTransport->GetlorlorgausModel_y01_Cp0();
358 Float_t lorlorgausModel_y01_Cp1 = aDIGTransport->GetlorlorgausModel_y01_Cp1() ;
359 Float_t lorlorgausModel_sigmay1_Cp0 = aDIGTransport->GetlorlorgausModel_sigmay1_Cp0();
360 Float_t lorlorgausModel_sigmay1_Cp1 = aDIGTransport->GetlorlorgausModel_sigmay1_Cp1();
361 Float_t lorlorgausModel_Gamma_Cp0 = aDIGTransport->GetlorlorgausModel_Gamma_Cp0() ;
362 Float_t lorlorgausModel_Gamma_Cp1 = aDIGTransport->GetlorlorgausModel_Gamma_Cp1() ;
363 Float_t lorlorgausModel_x0_Cp0 = aDIGTransport->GetlorlorgausModel_x0_Cp0() ;
364 Float_t lorlorgausModel_x0_Cp1 = aDIGTransport->GetlorlorgausModel_x0_Cp1() ;
365 Float_t lorlorgausModel_y0_Cp0 = aDIGTransport->GetlorlorgausModel_y0_Cp0() ;
366 Float_t lorlorgausModel_y0_Cp1 = aDIGTransport->GetlorlorgausModel_y0_Cp1() ;
367 Float_t lorlorgausModel_norm_Cp0 = aDIGTransport->GetlorlorgausModel_norm_Cp0() ;
368 Float_t lorlorgausModel_norm_Cp1 = aDIGTransport->GetlorlorgausModel_norm_Cp1() ;
369 Float_t lorlorgausModel_normgaus2_Cp0 = aDIGTransport->GetlorlorgausModel_normgaus2_Cp0();
370 Float_t lorlorgausModel_normgaus2_Cp1 = aDIGTransport->GetlorlorgausModel_normgaus2_Cp1() ;
371 Float_t lorlorgausModel_sigma2_Cp0 = aDIGTransport->GetlorlorgausModel_sigma2_Cp0() ;
372 Float_t lorlorgausModel_sigma2_Cp1 = aDIGTransport->GetlorlorgausModel_sigma2_Cp1() ;
374 Float_t l1dimgauslor_Norm_g_1st = aDIGTransport->Getf1dimgauslor_Norm_g_1st();
375 Float_t l1dimgauslor_x0_g_1st = aDIGTransport->Getf1dimgauslor_x0_g_1st();
376 Float_t l1dimgauslor_sigma_g_1st = aDIGTransport->Getf1dimgauslor_sigma_g_1st();
377 Float_t l1dimgauslor_Gamma_lor_1st = aDIGTransport->Getf1dimgauslor_Gamma_lor_1st();
378 Float_t l1dimgauslor_x0_lor_1st = aDIGTransport->Getf1dimgauslor_x0_lor_1st();
379 Float_t l1dimgauslor_norm_lor_1st = aDIGTransport->Getf1dimgauslor_norm_lor_1st();
380 Float_t l1dimgauslor_Norm_g_2nd = aDIGTransport->Getf1dimgauslor_Norm_g_2nd();
381 Float_t l1dimgauslor_x0_g_2nd = aDIGTransport->Getf1dimgauslor_x0_g_2nd();
382 Float_t l1dimgauslor_sigma_g_2nd = aDIGTransport->Getf1dimgauslor_sigma_g_2nd();
383 Float_t l1dimgauslor_Gamma_lor_2nd = aDIGTransport->Getf1dimgauslor_Gamma_lor_2nd();
384 Float_t l1dimgauslor_x0_lor_2nd = aDIGTransport->Getf1dimgauslor_x0_lor_2nd();
385 Float_t l1dimgauslor_norm_lor_2nd = aDIGTransport->Getf1dimgauslor_norm_lor_2nd();
389 TRandom3 *r3 =
new TRandom3(GlobalSeed);
390 r3->SetSeed(GlobalSeed);
393 TF1 *mymodel1D_1st=0;
394 TF1 *mymodel1D_2nd=0;
403 Double_t Cvalue= lorentz2Dmodel_Cp0 + pitchX * lorentz2Dmodel_Cp1 ;
405 mymodel2D =
new TF2(
"funlor2d",Lorentz2D,-rangelimit_inpitchunit*pitchX,rangelimit_inpitchunit*pitchX,
406 -rangelimit_inpitchunit*pitchY,rangelimit_inpitchunit*pitchY,4);
407 mymodel2D->SetParNames(
"C",
"X_{0}",
"Y_{0}",
"Norm");
408 Double_t params1[] = {Cvalue,0.,0.,1.0};
409 mymodel2D->SetParameters(params1);
411 }
else if(ChargeModel==2){
426 Double_t Gsigma1 = Gauss2DModel_sigma1_Cp0 + pitchX * Gauss2DModel_sigma1_Cp1 ;
427 Double_t Gsigma2 = Gauss2DModel_sigma2_Cp0 + pitchX * Gauss2DModel_sigma2_Cp1 ;
429 mymodel2D =
new TF2(
"funlor2d",SumGaus2D,-rangelimit_inpitchunit*pitchX,rangelimit_inpitchunit*pitchX,
430 -rangelimit_inpitchunit*pitchY,rangelimit_inpitchunit*pitchY,10);
431 mymodel2D->SetParNames(
"Norm_1",
"x0_1",
"sigma_x_1",
"y0_1",
"sigma_y_1",
"Norm_2",
"x0_2",
"sigma_x_2",
"y0_2",
"sigma_y_2");
432 Double_t params1[] = {1.0,0.0,Gsigma1,0.0,Gsigma1,Gauss2DModel_weight,0.0,Gsigma2,0.0,Gsigma2,0.0};
433 mymodel2D->SetParameters(params1);
434 }
else if(ChargeModel==3){
447 Double_t Norm1Value = LorGaussModel_Norm1_Cp0 + pitchX * LorGaussModel_Norm1_Cp1 + pitchX *pitchX * LorGaussModel_Norm1_Cp2;
448 Double_t sigmaValue = LorGaussModel_sigma_Cp0 + pitchX *LorGaussModel_sigma_Cp1;
449 Double_t Cvalue= LorGaussModel_C_Cp0 + pitchX *LorGaussModel_C_Cp1;
450 Double_t NormValue =LorGaussModel_Norm_Cp0 + pitchX * LorGaussModel_Norm_Cp1;
451 mymodel2D =
new TF2(
"funlor2d",SumGausLorentz2D,-rangelimit_inpitchunit*pitchX,rangelimit_inpitchunit*pitchX,
452 -rangelimit_inpitchunit*pitchY,rangelimit_inpitchunit*pitchY,9);
453 mymodel2D->SetParNames(
"Norm_1",
"x0_1",
"sigma_x_1",
"y0_1",
"sigma_y_1",
"Gamma",
"x0",
"y0",
"norm");
454 Double_t params1[] = {Norm1Value,0.0,sigmaValue,0.0,sigmaValue,Cvalue,0.0,0.0,NormValue};
455 mymodel2D->SetParameters(params1);
456 }
else if(ChargeModel==4){
474 Double_t Norm1Value = lorlorgausModel_Norm1_Cp0 + pitchX * lorlorgausModel_Norm1_Cp1;
475 Double_t x0_1Value = lorlorgausModel_x01_Cp0 + pitchX * lorlorgausModel_x01_Cp1;
476 Double_t sigma_x_1Value = lorlorgausModel_sigmax1_Cp0 + pitchX * lorlorgausModel_sigmax1_Cp1;
477 Double_t y0_1Value = lorlorgausModel_y01_Cp0 + pitchX * lorlorgausModel_y01_Cp1;
478 Double_t sigma_y_1Value = lorlorgausModel_sigmay1_Cp0 + pitchX * lorlorgausModel_sigmay1_Cp1;
479 Double_t GammaValue = lorlorgausModel_Gamma_Cp0 + pitchX * lorlorgausModel_Gamma_Cp1;
480 Double_t x0Value = lorlorgausModel_x0_Cp0 + pitchX * lorlorgausModel_x0_Cp1;
481 Double_t y0Value = lorlorgausModel_y0_Cp0 + pitchX * lorlorgausModel_y0_Cp1;
482 Double_t normValue = lorlorgausModel_norm_Cp0 + pitchX * lorlorgausModel_norm_Cp1;
483 Double_t normgaus2Value = lorlorgausModel_normgaus2_Cp0 + pitchX * lorlorgausModel_normgaus2_Cp1;
484 Double_t sigma_2Value = lorlorgausModel_sigma2_Cp0 + pitchX * lorlorgausModel_sigma2_Cp1;
485 mymodel2D =
new TF2(
"funlor2d",SumGausLorentz2Dnew,-rangelimit_inpitchunit*pitchX,rangelimit_inpitchunit*pitchX,
486 -rangelimit_inpitchunit*pitchY,rangelimit_inpitchunit*pitchY,11);
487 mymodel2D->SetParNames(
"Norm_1",
"x0_1",
"sigma_x_1",
"y0_1",
"sigma_y_1",
"Gamma",
"x0",
"y0",
"norm",
"normgaus2",
"sigma_2");
488 Double_t params1[] = {Norm1Value,x0_1Value,sigma_x_1Value,y0_1Value,
489 sigma_y_1Value,GammaValue,x0Value,y0Value,normValue,normgaus2Value,sigma_2Value};
490 mymodel2D->SetParameters(params1);
491 }
else if(ChargeModel==5){
497 Double_t Norm_g_1st =l1dimgauslor_Norm_g_1st ;
498 Double_t x0_g_1st =l1dimgauslor_x0_g_1st ;
499 Double_t sigma_g_1st =l1dimgauslor_sigma_g_1st ;
500 Double_t Gamma_lor_1st =l1dimgauslor_Gamma_lor_1st ;
501 Double_t x0_lor_1st =l1dimgauslor_x0_lor_1st ;
502 Double_t norm_lor_1st =l1dimgauslor_norm_lor_1st ;
503 Double_t Norm_g_2nd =l1dimgauslor_Norm_g_2nd ;
504 Double_t x0_g_2nd =l1dimgauslor_x0_g_2nd ;
505 Double_t sigma_g_2nd =l1dimgauslor_sigma_g_2nd ;
506 Double_t Gamma_lor_2nd =l1dimgauslor_Gamma_lor_2nd ;
507 Double_t x0_lor_2nd =l1dimgauslor_x0_lor_2nd ;
508 Double_t norm_lor_2nd =l1dimgauslor_norm_lor_2nd ;
511 mymodel1D_1st =
new TF1(
"namemodel1D_1st",SumGausLorentz1D,0,4.0*pitchX,6);
512 mymodel1D_2nd =
new TF1(
"namemodel1D_2nd",SumGausLorentz1D,0,4.0*pitchX,6);
513 mymodel1D_1st->SetParNames(
"Norm_g",
"x0_g",
"sigma_g",
"Gamma_lor",
"x0_lor",
"norm_lor");
514 mymodel1D_2nd->SetParNames(
"Norm_g",
"x0_g",
"sigma_g",
"Gamma_lor",
"x0_lor",
"norm_lor");
515 Double_t params1[] = {Norm_g_1st,x0_g_1st,sigma_g_1st, Gamma_lor_1st,x0_lor_1st,norm_lor_1st};
516 Double_t params2[] = {Norm_g_2nd,x0_g_2nd,sigma_g_2nd, Gamma_lor_2nd,x0_lor_2nd,norm_lor_2nd};
517 mymodel1D_1st->SetParameters(params1);
518 mymodel1D_2nd->SetParameters(params2);
526 Double_t Gsigma1 = Gauss2DModel_sigma1_Cp0 + pitchX * Gauss2DModel_sigma1_Cp1 ;
527 Double_t Gsigma2 = Gauss2DModel_sigma2_Cp0 + pitchX * Gauss2DModel_sigma2_Cp1 ;
529 mymodel2D =
new TF2(
"funlor2d",SumGaus2D,-rangelimit_inpitchunit*pitchX,rangelimit_inpitchunit*pitchX,
530 -rangelimit_inpitchunit*pitchY,rangelimit_inpitchunit*pitchY,10);
531 mymodel2D->SetParNames(
"Norm_1",
"x0_1",
"sigma_x_1",
"y0_1",
"sigma_y_1",
"Norm_2",
"x0_2",
"sigma_x_2",
"y0_2",
"sigma_y_2");
532 Double_t params1[] = {1.0,0.0,Gsigma1,0.0,Gsigma1,Gauss2DModel_weight,0.0,Gsigma2,0.0,Gsigma2,0.0};
533 mymodel2D->SetParameters(params1);
582 for (Int_t i=0 ; i<fNSegment ; i++){
584 Int_t PixelReached = GetPixelNumber(aDIGPlane, fSegmentX[i], fSegmentY[i]);
585 Float_t xdpos, ydpos;
586 GetXYPixelCenter(xdpos, ydpos, aDIGPlane, PixelReached);
588 GetXYPixelNumber( xpixn,ypixn, aDIGPlane, PixelReached);
590 Float_t TotalProba=0.0;
592 Float_t PixelposX[Npix];
593 Float_t PixelposY[Npix];
594 Float_t Pixelproba[Npix];
595 Int_t Pixelnumber[Npix];
596 for (Int_t j=0 ; j<Npix ; j++){
603 for (Int_t j=0 ; j<Npix ; j++){
606 Float_t xeval = -(fSegmentX[i]-(xpixn+0.5)*pitchX) + (
float(xi)-2.0)*pitchX ;
607 Float_t yeval = -(fSegmentY[i]-(ypixn+0.5)*pitchY) + (
float(yi)-2.0)*pitchY ;
608 Float_t xydist = TMath::Sqrt(xeval*xeval+yeval*yeval);
613 if((ChargeModel==1)||(ChargeModel==2)||(ChargeModel==3)||(ChargeModel==4)){
614 Pixelproba[j]=mymodel2D->Eval(xeval,yeval);
615 }
else if(ChargeModel==5){
617 if((fabs(xeval)<=pitchX)&&(fabs(yeval)<=pitchY)){
618 Pixelproba[j]=mymodel1D_1st->Eval(xydist);
620 Pixelproba[j]=mymodel1D_2nd->Eval(xydist);
623 TotalProba+=Pixelproba[j];
624 PixelposX[j]= xdpos + (float(xi)-2.0)*pitchX;
625 PixelposY[j]= ydpos + (float(yi)-2.0)*pitchY;
626 if( (PixelposX[j]<=0.0)||
627 (PixelposX[j]>=aDIGPlane->GetXdimension())||
628 (PixelposY[j]<=0.0)||
629 (PixelposY[j]>=aDIGPlane->GetYdimension())){
632 Pixelnumber[j] = GetPixelNumber(aDIGPlane, PixelposX[j], PixelposY[j]);
642 Double_t rando = r3->Rndm()*TotalProba;
643 Bool_t reached =
false;
644 Double_t incrprob = 0.0;
646 while((!reached)&&(icounter<Npix)){
647 incrprob+=Pixelproba[icounter];
655 if(Pixelnumber[icounter]>=0){
656 UpdatePixel(fSegmentCharge[i],Pixelnumber[icounter]);
664 void DIGParticle::AddPixel(Float_t AnalogCharge, Int_t PixelNumber){
666 fPixelMap.push_back(PixelNumber);
667 fAnalogChargeMap.push_back(AnalogCharge);
668 fDigitalChargeMap.push_back(0);
673 void DIGParticle::UpdatePixel(Float_t AnalogCharge, Int_t PixelNumber){
674 Bool_t found =
false;
676 while((!found)&&(i<fNpixels)){
677 if(PixelNumber==fPixelMap[i]){
679 fAnalogChargeMap[i]+=AnalogCharge;
684 AddPixel(AnalogCharge, PixelNumber);
690 void DIGParticle::AddRandomNoise(
DIGPlane *myDIGPlane){
691 Double_t Noisefix = myDIGPlane->GetNoiseElectrons();
693 for (Int_t i = 0; i < fNpixels ; i++){
694 Noise = GaussianLaw(0.0, Noisefix);
695 fAnalogChargeMap[i]+=Noise;
700 void DIGParticle::AnalogToDigitalconversion(
DIGADC *myDIGADC,
DIGPlane *myDIGPlane ){
701 Float_t Noisefix = myDIGPlane->GetNoiseElectrons();
703 std::cout <<
"<---- DIGParticle::AnalogToDigitalconversion --->"<<endl;
704 std::cout<<
"WARNING negative or null Noise is not physical, please correct the input file"<<endl;
707 Float_t *myADCthreshold = 0;
708 myADCthreshold = myDIGADC->GetADC_thresholds();
709 for (Int_t i = 0; i < fNpixels ; i++){
710 if (fAnalogChargeMap[i]<=0.0){
711 fDigitalChargeMap[i]=0;
713 Bool_t thresholdfound =
false;
715 fDigitalChargeMap[i]=0;
716 while((thresholdfound==
false)&&(ithres< (myDIGADC->GetNThresholds()) )){
717 if( (fAnalogChargeMap[i]/Noisefix) < myADCthreshold[ithres] ){
718 thresholdfound =
true;
720 fDigitalChargeMap[i]++;
729 Int_t DIGParticle::GetPixelNumber(
DIGPlane *myDIGPlane, Float_t Xpos, Float_t Ypos){
730 Int_t XPixelnumber = int(Xpos/(myDIGPlane->GetPitchX()));
731 Int_t YPixelnumber = int(Ypos/(myDIGPlane->GetPitchY()));
732 Int_t PixelNumber = XPixelnumber + (myDIGPlane->GetNpixelsX())*YPixelnumber;
736 (Xpos>myDIGPlane->GetXdimension())||
738 (Ypos>myDIGPlane->GetYdimension())){
747 void DIGParticle::GetXYPixelNumber(Int_t &Xpix, Int_t &Ypix,
DIGPlane *myDIGPlane, Int_t PixelNumber){
749 Xpix = PixelNumber%(myDIGPlane->GetNpixelsX());
750 Ypix = PixelNumber/(myDIGPlane->GetNpixelsX());
755 void DIGParticle::GetXYPixelCenter(Float_t &Xpix, Float_t &Ypix,
DIGPlane *myDIGPlane, Int_t PixelNumber){
757 Xpix = (myDIGPlane->GetPitchY()) * (0.5+PixelNumber%(myDIGPlane->GetNpixelsX()));
758 Ypix = (myDIGPlane->GetPitchX()) * (0.5+PixelNumber/(myDIGPlane->GetNpixelsX()));
763 Double_t DIGParticle::GaussianLaw(Double_t mean, Double_t sigma)
766 TRandom3 *r3 =
new TRandom3(0);
768 r3->SetSeed(GlobalSeed);
770 x = r3->Gaus(mean,sigma);
777 Float_t DIGParticle::GetTotalAnalogCharge(){
778 Float_t TotalCharge = 0;
779 for (Int_t i=0 ; i<fNpixels ; i++){
780 TotalCharge+=fAnalogChargeMap[i];
786 Int_t DIGParticle::GetTotalDigitalCharge(){
787 Int_t TotalCharge = 0;
788 for (Int_t i=0 ; i<fNpixels ; i++){
789 TotalCharge+=fDigitalChargeMap[i];