FairRoot/PandaRoot
Public Member Functions | Private Attributes | List of all members
PndTrkLegendreFits Class Reference

#include <PndTrkLegendreFits.h>

Inheritance diagram for PndTrkLegendreFits:

Public Member Functions

 PndTrkLegendreFits ()
 
 ~PndTrkLegendreFits ()
 
int FindMaximumInMatrix (int nRDiv, int nThetaD, UShort_t *Mat, int *iRMax, int *iTMax)
 
Short_t FitHelixCylinder (Short_t nHitsinTrack, Double_t *Xconformal, Double_t *Yconformal, Double_t *DriftRadiusconformal, Double_t *ErrorDriftRadiusconformal, Double_t rotationangle, Double_t trajectory_vertex[2], Short_t NMAX, Double_t *m, Double_t *q, Double_t *pAlfa, Double_t *pBeta, Double_t *pGamma, bool *Type, int istampa, int IVOLTE)
 
Short_t FitHelixCylinder2 (Double_t *Cosine, Short_t LEGIANDRE_NTHETADIV, Short_t LEGIANDRE_NRADIUSDIV, Short_t nHitsinTrack, Double_t *Xconformal, Double_t *Yconformal, Double_t *DriftRadiusconformal, Double_t *ErrorDriftRadiusconformal, Double_t rotationangle, Double_t *Sinus, Double_t THETAMAX, Double_t THETAMIN, Double_t trajectory_vertex[2], Short_t NMAX, Double_t *m, Double_t *q, Double_t *pAlfa, Double_t *pBeta, Double_t *pGamma, bool *Type, int istampa, int IVOLTE)
 
Short_t FitSZspace (Short_t nHitsinTrack, Double_t *S, Double_t *Z, Double_t *DriftRadius, Double_t *ErrorDriftRadius, Double_t FInot, Short_t NMAX, Double_t *emme, int PlotNumber)
 
int LoadMatrix_FindMaximum (Short_t nHitsinTrack, Double_t *X, Double_t *Y, Double_t *DriftRadius, Double_t *ErrorDriftRadiusconformal, Double_t *Rout, Double_t *Thetaout)
 
void LoadMatrix_FindMaximum2 (Double_t *Cosine, Short_t LEGIANDRE_NTHETADIV, Short_t LEGIANDRE_NRADIUSDIV, Short_t nHitsinTrack, Double_t *Sinus, Double_t THETAMAX, Double_t THETAMIN, Double_t *X, Double_t *Y, Double_t *DriftRadius, Double_t *ErrorDriftRadiusconformal, Double_t *Rout, Double_t *Thetaout)
 
 ClassDef (PndTrkLegendreFits, 1)
 

Private Attributes

int fIcounter
 
int fNThetaDiv
 
int fNRDiv
 
Double_t fDeltaT
 
Double_t fRMin
 
Double_t fThetaMax
 
Double_t fThetaMin
 

Detailed Description

Definition at line 7 of file PndTrkLegendreFits.h.

Constructor & Destructor Documentation

PndTrkLegendreFits::PndTrkLegendreFits ( )

Default constructor

Definition at line 17 of file PndTrkLegendreFits.cxx.

References fThetaMax, fThetaMin, and PI.

18 {
19  fNThetaDiv = 360, // this is one of the dimension of the accumulation Matrix;
20  fNRDiv = 100; // this is the other dimension;
21  fRMin=0.;
22  fThetaMax=2.*PI,
23  fThetaMin=0.;
25 
26  fIcounter =0;
27 };
#define PI
PndTrkLegendreFits::~PndTrkLegendreFits ( )
inline

Destructor

Definition at line 31 of file PndTrkLegendreFits.h.

31 {};

Member Function Documentation

PndTrkLegendreFits::ClassDef ( PndTrkLegendreFits  ,
 
)
int PndTrkLegendreFits::FindMaximumInMatrix ( int  nRDiv,
int  nThetaD,
UShort_t *  Mat,
int *  iRMax,
int *  iTMax 
)

Definition at line 31 of file PndTrkLegendreFits.cxx.

References i, and max().

40 {
41 
42  int i,j;
43 
44  // initializations;
45  int max = -99999;
46 
47  for(i=0;i<nRDiv;i++){
48  for(j=0;j<nThetaD;j++){
49  if(Mat[i*nThetaD+j]>max){
50  max = Mat[i*nThetaD+j];
51  *iRMax = i;
52  *iTMax = j;
53  } // end of if(Max[i*nThetaD+j]>max)
54  }
55  } // end of for(i=0;i<nRDiv;i++)
56 
57  return max;
58 
59 }
Int_t i
Definition: run_full.C:25
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
Short_t PndTrkLegendreFits::FitHelixCylinder ( Short_t  nHitsinTrack,
Double_t Xconformal,
Double_t Yconformal,
Double_t DriftRadiusconformal,
Double_t ErrorDriftRadiusconformal,
Double_t  rotationangle,
Double_t  trajectory_vertex[2],
Short_t  NMAX,
Double_t m,
Double_t q,
Double_t pAlfa,
Double_t pBeta,
Double_t pGamma,
bool *  Type,
int  istampa,
int  IVOLTE 
)

Definition at line 68 of file PndTrkLegendreFits.cxx.

References cos(), Double_t, fabs(), R, and sin().

Referenced by PndTrkCTFindTrackInXY::FindTrackInXYProjection().

86 {
87 
88  int result;
89 
90  Double_t
91  cosT,
92  sinT,
93  R, // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
94  Theta; // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
95 
96 fIcounter=IVOLTE;
97  result = LoadMatrix_FindMaximum(
98  nHitsinTrack, // input
99  Xconformal, // X position (in conformal or SZ or whatever);
100  Yconformal, // Y position (in conformal or SZ or whatever);
101  DriftRadiusconformal, // negative if Mvd hit or similar;
102  ErrorDriftRadiusconformal, // for the Mvd this is the Radius of the circumference
103  // translated with the Conformal transformation,
104  // which is, in the XY space : a) centered on the Pixel
105  // or Strip; with radius = 0.01 cm --> therefore encompassing
106  // completely the Pixel or Stip hit.
107 
108  &R, // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
109  &Theta // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
110  );
111 
112  if (result<0) { *Type=false; return result;}
113 
114 
115  cosT = cos(Theta);
116  sinT = sin(Theta);
117 
118  //------------------------- final summary of the fit results; load output variables;
119 
120  *pGamma = 0.;
121 
122  // R != 0 --> normal case : the trajectory is a circle in XY passing for the origin;
123  if( fabs( R ) > 1.e-10) {
124  *pAlfa = -cosT/R;
125  *pBeta = -sinT/R;
126  *Type=true;
127  } else {
128  // in this case the trajectory is a straight line : Y*sin(Theta) + X*cos(Theta) = 0
129  // in XY;
130  *Type=false;
131  return 1; // the fit did not fail anyway, so return value>0 ;
132  }
133 
134 
135 
136 // now take into account the displacement and correct
137  *pGamma += (trajectory_vertex[0]*trajectory_vertex[0]+
138  trajectory_vertex[1]*trajectory_vertex[1]
139  -*pAlfa*trajectory_vertex[0]-*pBeta*trajectory_vertex[1]);
140  *pAlfa -= 2.*trajectory_vertex[0];
141  *pBeta -= 2.*trajectory_vertex[1];
142 
143 
144 // calculate *emme and *qu using the newly calculated *pAlfa, *pBeta, *pGamma of the
145 // circular trajectory in XY. Assuming also that *pGamma ~ 0, that is the circumference
146 // goes thru the origin.
147 
148  if( abs(*pBeta)>1e-10) {
149  // normal case of a straight line in UV that can be put in the V = m*U +q form;
150  *emme = -(*pAlfa)/(*pBeta);
151  *qu = -1./(*pBeta);
152  return 1;
153  } else {
154  *emme = -(*pAlfa)/1e-10;
155  *qu = -1./1e-10;
156  return 99;
157  }
158 
159 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
Double_t
int LoadMatrix_FindMaximum(Short_t nHitsinTrack, Double_t *X, Double_t *Y, Double_t *DriftRadius, Double_t *ErrorDriftRadiusconformal, Double_t *Rout, Double_t *Thetaout)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Double_t R
Definition: checkhelixhit.C:61
Short_t PndTrkLegendreFits::FitHelixCylinder2 ( Double_t Cosine,
Short_t  LEGIANDRE_NTHETADIV,
Short_t  LEGIANDRE_NRADIUSDIV,
Short_t  nHitsinTrack,
Double_t Xconformal,
Double_t Yconformal,
Double_t DriftRadiusconformal,
Double_t ErrorDriftRadiusconformal,
Double_t  rotationangle,
Double_t Sinus,
Double_t  THETAMAX,
Double_t  THETAMIN,
Double_t  trajectory_vertex[2],
Short_t  NMAX,
Double_t m,
Double_t q,
Double_t pAlfa,
Double_t pBeta,
Double_t pGamma,
bool *  Type,
int  istampa,
int  IVOLTE 
)

Definition at line 168 of file PndTrkLegendreFits.cxx.

References cos(), Double_t, fabs(), R, and sin().

Referenced by PndTrkCTFindTrackInXY2::FindTrackInXYProjection().

192 {
193 
194 
195  Double_t
196  cosT,
197  sinT,
198  R, // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
199  Theta; // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
200 
201  fIcounter=IVOLTE;
202 
203 /*
204  LoadMatrix_FindMaximum(
205  nHitsinTrack, // input
206  Xconformal, // X position (in conformal or SZ or whatever);
207  Yconformal, // Y position (in conformal or SZ or whatever);
208  DriftRadiusconformal, // negative if Mvd hit or similar;
209  ErrorDriftRadiusconformal, // for the Mvd this is the Radius of the circumference
210  // translated with the Conformal transformation,
211  // which is, in the XY space : a) centered on the Pixel
212  // or Strip; with radius = 0.01 cm --> therefore encompassing
213  // completely the Pixel or Stip hit.
214 
215  &R, // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
216  &Theta // output parameter of the straight line; Xcos(Theta)+Y*sin(Theta)=R;
217  );
218 
219 
220 */
222  Cosine, // input, the precalculated values of cosine;
223  LEGIANDRE_NTHETADIV, // input, the theta divisions;
224  LEGIANDRE_NRADIUSDIV, // input, the radius divisions;
225  nHitsinTrack, // input
226  Sinus, // input, the precalculated values of sinus;
227  THETAMAX,
228  THETAMIN,
229  Xconformal, // X position (in conformal or SZ or whatever);
230  Yconformal, // Y position (in conformal or SZ or whatever);
231  DriftRadiusconformal, // negative if Mvd hit or similar;
232  ErrorDriftRadiusconformal, // for the Mvd this is the Radius of the circumference
233  // translated with the Conformal transformation,
234  // which is, in the XY space : a) centered on the Pixel
235  // or Strip; with radius = 0.01 cm --> therefore encompassing
236  // completely the Pixel or Stip hit.
237 
238  &R, // output parameter of the straight line; X*cos(Theta)+Y*sin(Theta)=R;
239  &Theta // output parameter of the straight line; X*cos(Theta)+Y*sin(Theta)=R;
240  );
241 
242 
243  cosT = cos(Theta);
244  sinT = sin(Theta);
245 
246  //------------------------- final summary of the fit results; load output variables;
247 
248  *pGamma = 0.;
249 
250  // R != 0 --> normal case : the trajectory is a circle in XY passing for the origin;
251  if( fabs( R ) > 1.e-10) {
252  *pAlfa = -cosT/R;
253  *pBeta = -sinT/R;
254  *Type=true;
255  } else {
256  // in this case the trajectory is a straight line : Y*sin(Theta) + X*cos(Theta) = 0
257  // in XY;
258  *Type=false;
259  return 1; // the fit did not fail anyway, so return value>0 ;
260  }
261 
262 
263 
264 // now take into account the displacement and correct
265  *pGamma += (trajectory_vertex[0]*trajectory_vertex[0]+
266  trajectory_vertex[1]*trajectory_vertex[1]
267  -*pAlfa*trajectory_vertex[0]-*pBeta*trajectory_vertex[1]);
268  *pAlfa -= 2.*trajectory_vertex[0];
269  *pBeta -= 2.*trajectory_vertex[1];
270 
271 
272 // calculate *emme and *qu using the newly calculated *pAlfa, *pBeta, *pGamma of the
273 // circular trajectory in XY. Assuming also that *pGamma ~ 0, that is the circumference
274 // goes thru the origin.
275 
276  if( abs(*pBeta)>1e-10) {
277  // normal case of a straight line in UV that can be put in the V = m*U +q form;
278  *emme = -(*pAlfa)/(*pBeta);
279  *qu = -1./(*pBeta);
280  return 1;
281  } else {
282  *emme = -(*pAlfa)/1e-10;
283  *qu = -1./1e-10;
284  return 99;
285  }
286 
287 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
void LoadMatrix_FindMaximum2(Double_t *Cosine, Short_t LEGIANDRE_NTHETADIV, Short_t LEGIANDRE_NRADIUSDIV, Short_t nHitsinTrack, Double_t *Sinus, Double_t THETAMAX, Double_t THETAMIN, Double_t *X, Double_t *Y, Double_t *DriftRadius, Double_t *ErrorDriftRadiusconformal, Double_t *Rout, Double_t *Thetaout)
Double_t
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
static const Double_t THETAMAX
Double_t R
Definition: checkhelixhit.C:61
static const Double_t THETAMIN
Short_t PndTrkLegendreFits::FitSZspace ( Short_t  nHitsinTrack,
Double_t S,
Double_t Z,
Double_t DriftRadius,
Double_t ErrorDriftRadius,
Double_t  FInot,
Short_t  NMAX,
Double_t emme,
int  PlotNumber 
)

Definition at line 292 of file PndTrkLegendreFits.cxx.

References Double_t, fabs(), i, max(), and PI.

303 {
304 
305  const int
306  ThetaDiv = 20;
307 
308  int
309  i,
310  icount,
311  CellMax,
312  ncell,
313  nMvdHits,
314  nSttHits;
315  //result; //[R.K. 01/2017] unused variable?
316 
317  UShort_t
318  Matrix[ThetaDiv];
319 
320  Double_t
321  Amax,
322  Amin,
323  delta,
324  max,
325  ThetaMax;
326 
327 
328  if(nHitsinTrack<1) return -1;
329 
330  // this fit in SZ is a fit with only 1 variable : S = kappa * Z + fi0 with kappa
331  // the variable, and fi0 = FInot is fixed (obtained by the previous XY fit);
332  // therefore here it is calculated an 'accumulation' plot in only 1 dimension.
333  // The variable chosen is Theta --> tan(Theta) = kappa; in this way Theta is a
334  // variable bound between 0 and PI; the equation is then
335  // S = tan(Theta) * Z + fi0.
336  // For each Stt Skew hit I calculate 2 entries (only 2 are the possible tangents to
337  // drift elipsoid, having a fixed fi0) in the accumulation plot and onl;y 1 entry for
338  // the Mvd and SciTil hits.
339 
340 
341 
342  // reset the Matrix;
343  size_t len;
344  len = sizeof(Matrix);
345  memset (Matrix,0,len);
346 
347 
348 
349  // count the number of Stt hits (2 entries in the accumulation plot each)
350  // and the Mvd/SciTil number of hits (1 entry only);
351  nMvdHits = 0;
352  nSttHits = 0;
353  for(i=0;i<nHitsinTrack;i++){
354  if(DriftRadiusProjected[i]<=0.) nMvdHits ++; else nSttHits++;
355  }
356 
357  // now the array containing the list of Angles can be declared;
358 
359  Double_t AngleArray[nMvdHits + 2*nSttHits];
360 
361  // filling the AngleArray and finding the range of extension of the Angles;
362 
363  for(i=0, icount=0, Amax = -99999., Amin = 9999999.;i<nHitsinTrack;i++){
364  if(DriftRadiusProjected[i]>0.){
365  // Stt hit : 2 possible tangent;
366 
367  // calculation of the first possible tangent;
368  if( abs(Z[i]+DriftRadiusProjected[i])>1.e-10){
369  AngleArray[icount] = atan( (S[i]-FInot)/(Z[i]+DriftRadiusProjected[i]) );
370  } else {
371  AngleArray[icount] = PI/2.;
372  }
373  if(AngleArray[icount]<Amin) Amin=AngleArray[icount];
374  if(AngleArray[icount]>Amax) Amax=AngleArray[icount];
375  icount++;
376  // calculation of the second possible tangent;
377  if( abs(Z[i]-DriftRadiusProjected[i])>1.e-10){
378  AngleArray[icount] = atan( (S[i]-FInot)/(Z[i]-DriftRadiusProjected[i]) );
379  } else {
380  AngleArray[icount] = PI/2.;
381  }
382  if(AngleArray[icount]<Amin) Amin=AngleArray[icount];
383  if(AngleArray[icount]>Amax) Amax=AngleArray[icount];
384  icount++;
385 
386  } else { // continuation of if(DriftRadiusProjected[i]>0.)
387 
388  // Mvd or SciTil hit : only 1 tangent is possible;
389  // calculation of the only possible tangent;
390  if( abs(Z[i])>1.e-10){
391  AngleArray[icount] = atan( (S[i]-FInot)/Z[i] );
392  } else {
393  AngleArray[icount] = PI/2.;
394  }
395  if(AngleArray[icount]<Amin) Amin=AngleArray[icount];
396  if(AngleArray[icount]>Amax) Amax=AngleArray[icount];
397  icount++;
398 
399  } // end of if(DriftRadiusProjected[i]>0.)
400 
401  } // end of for(i=0, icount=0, Amax ....
402 
403 
404  // fix the case when Amin=Amax (for instance when there is only one hit to fit);
405  if(Amin >= Amax ) Amin = Amax - 0.1*fabs(Amax);
406  // add a 10% slac to the range of the Angles;
407  delta = 0.1*(Amax - Amin);
408  Amax += delta;
409  Amin -= delta;
410  delta = (Amax-Amin)/ThetaDiv ;
411 
412 
413 
414  char titolo[100];
415  sprintf(titolo,"KAPPA%d",PlotNumber);
416  TH1F * hKAPPAPlot = new TH1F(titolo, "",ThetaDiv, Amin, Amax );
417 
418  // filling the Matrix;
419 
420  for(i=0 ;i<icount;i++){
421 
422  ncell = (int) ( (AngleArray[i] - Amin)/delta );
423 // if(ncell <0) { ncell=0; } else if (ncell>=ThetaDiv) {ncell = ThetaDiv-1;}
424  Matrix[ncell]++;
425 
426  hKAPPAPlot->Fill(AngleArray[i]);
427 
428  } // end of for(i=0 ;i<icount;i++)
429 
430 
431 
432  hKAPPAPlot->Write();
433  delete hKAPPAPlot;
434 
435  // find the cell of the maximum in the Matrix;
436  max = Matrix[0];
437  CellMax = 0;
438  for(i=1;i<ThetaDiv;i++){
439  if(max<Matrix[i]) { max = Matrix[i]; CellMax = i; }
440  } // end of for(i=0;i<ThetaDiv;i++)
441 
442  //------------------------- final summary of the fit results; load output variables;
443 
444  ThetaMax = Amin + (CellMax+0.5) * delta;
445 
446  if (abs(PI/2. - ThetaMax) < 1.e-5){
447  (*emme) = 9999999.;
448  } else {
449  (*emme) = tan(ThetaMax);
450  }
451 
452  return 1;
453 
454 
455 }
Int_t i
Definition: run_full.C:25
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
Double_t
#define PI
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Definition: matrix.h:50
double Z
Definition: anaLmdDigi.C:68
int PndTrkLegendreFits::LoadMatrix_FindMaximum ( Short_t  nHitsinTrack,
Double_t X,
Double_t Y,
Double_t DriftRadius,
Double_t ErrorDriftRadiusconformal,
Double_t Rout,
Double_t Thetaout 
)

Definition at line 460 of file PndTrkLegendreFits.cxx.

References cos(), Double_t, fabs(), fThetaMax, fThetaMin, i, PI, R, sin(), and sqrt().

475 {
476  const int MAXCONTENT= 30000;
477 
478  int IndexR,
479  IndexT,
480  i,
481  iRMax,
482  iTMax,
483  j,
484  maxval;
485 
486  UShort_t
488 
489  Double_t
490  DeltaR,
491  Drift[nHitsinTrack],
492  HistoRmax,
493  R,
494  Theta;
495 
496 
497  // initialization of the Matrix that will be loaded with points;
498 
499  size_t len;
500  len = sizeof(Matrix);
501  memset (Matrix,0,len);
502  // the following HistoRmax corresponds to 1/R**2 in XY plane with R=40 (approximately
503  // the radius of a outer axial Stt hit).
504  HistoRmax = 0.000625;
505 
506 
507  // find the maximum R of the 'histogram';
508  for (i=0; i<nHitsinTrack; i++){
509  R = sqrt(X[i]*X[i]+Y[i]*Y[i]);
510 
511  if( DriftRadius[i]<0. ) { // this is a Mvd point; the Pixel/Strip
512  // in the Conformal plane is approximately contained in
513  // a circle centered in X[i], Y[i] of radius ErrorDriftRadiusconformal[i];
514  if(HistoRmax < R){ HistoRmax=R+ErrorDriftRadiusconformal[i]; }
515  Drift[i] = 0;
516  } else { // this is a Stt axial hit;
517  // take into consideration also the drift radius;
518  R += DriftRadius[i];
519  if(HistoRmax < R){ HistoRmax=R; }
520  Drift[i] = DriftRadius[i];
521  }
522  } // end of for (i=0; nHitsinTrack; i++)
523  DeltaR = (HistoRmax-fRMin)/fNRDiv;
524 
525  // fill the Matrix;
526 
527 // char titolo[100];
528 // sprintf(titolo,"Legendre%d",fIcounter);
529 // TH2F * hMatrixPlot = new TH2F(titolo, "",fNRDiv, 0. , HistoRmax
530 // , fNThetaDiv, fThetaMin, fThetaMax);
531 
532 
533 
534  for (i=0; i<nHitsinTrack; i++){
535  // for now the number of Theta generated are one per Theta bin;
536  for(j=0;j<fNThetaDiv;j++) {
537  // generate the Theta in the middle of the bin;
538  Theta = fThetaMin + (j+0.5)*fDeltaT;
539  R = X[i]*cos(Theta) + Y[i]*sin(Theta)+Drift[i];
540  IndexR = (int) ((fabs(R)-fRMin)/DeltaR);
541  if(IndexR>=fNRDiv) IndexR=fNRDiv-1;
542  // the following is an essential calculation for Theta,
543  // because it changes by 180 degrees when
544  // X[i]*cos(Theta) + Y[i]*sin(Theta)+DriftRadius[i]<0;
545  if( R <0.) {
546  Theta += PI;
547  if(Theta>2.*PI){ Theta -= 2.*PI; }
548  IndexT = (int)((Theta-fThetaMin)/fDeltaT) ;
549  if(IndexT>=fNThetaDiv) IndexT=fNThetaDiv-1;
550  } else {
551  IndexT = j;
552  }
553  if( Matrix[IndexR][IndexT] < MAXCONTENT ){
554  Matrix[IndexR][IndexT]++;
555  }
556  if(Theta == fThetaMax) Theta -= 1e-10;
557 // hMatrixPlot->Fill( fabs(R),Theta);
558  }
559  } // end of for (i=0; nHitsinTrack; i++)
560 
561 
562 // hMatrixPlot->Write();
563 // delete hMatrixPlot;
564 
565  // find maximum in the Matrix;
566  maxval = FindMaximumInMatrix(
567  fNRDiv, // input
568  fNThetaDiv, // input
569  &Matrix[0][0], // input
570 
571  &iRMax, // output
572  &iTMax // output
573  );
574 
575  // fit failed
576  if(maxval < 0) return -5;
577  // the found parameters;
578  *Rout = (iRMax+0.5) *DeltaR + fRMin;
579  *Thetaout = (iTMax+0.5) *fDeltaT + fThetaMin;
580 
581 
582  return 1;
583 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
double Y
Definition: anaLmdDigi.C:68
Double_t
#define PI
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Definition: matrix.h:50
double X
Definition: anaLmdDigi.C:68
int FindMaximumInMatrix(int nRDiv, int nThetaD, UShort_t *Mat, int *iRMax, int *iTMax)
Double_t R
Definition: checkhelixhit.C:61
void PndTrkLegendreFits::LoadMatrix_FindMaximum2 ( Double_t Cosine,
Short_t  LEGIANDRE_NTHETADIV,
Short_t  LEGIANDRE_NRADIUSDIV,
Short_t  nHitsinTrack,
Double_t Sinus,
Double_t  THETAMAX,
Double_t  THETAMIN,
Double_t X,
Double_t Y,
Double_t DriftRadius,
Double_t ErrorDriftRadiusconformal,
Double_t Rout,
Double_t Thetaout 
)

Definition at line 590 of file PndTrkLegendreFits.cxx.

References Double_t, fabs(), i, PndTrkMergeSort::Merge_Sort3(), R, sqrt(), and THETAMIN.

611 {
612 
613  //const int MAXCONTENT= 30000; //[R.K. 01/2017] unused variable?
614 
615 
616 
617  bool previously_filled[LEGIANDRE_NRADIUSDIV][LEGIANDRE_NTHETADIV];
618  memset(previously_filled,false,sizeof(previously_filled));
619 
620  Short_t
621  i,
622  IndexR,
623  IndexT,
624  iRMax,
625  iTMax,
626  j,
627  List_filled_cells_IndexR[nHitsinTrack*LEGIANDRE_NTHETADIV],
628  List_filled_cells_IndexT[nHitsinTrack*LEGIANDRE_NTHETADIV],
629  //maxval, //[R.K. 01/2017] unused variable?
630  n_filled_cells;
631 
632  Int_t Matrix[LEGIANDRE_NRADIUSDIV][LEGIANDRE_NTHETADIV];
633 
634 
635  Double_t
636  DeltaR,
637  Drift[nHitsinTrack],
638  HistoRmax,
639  R;
640  //Theta; //[R.K. 01/2017] unused variable?
641 
642 
643  PndTrkMergeSort MergerSorter;
644 
645 
646  // initialization of the Matrix that will be loaded with points;
647 
648  size_t len;
649  len = sizeof(Matrix);
650  memset (Matrix,0,len);
651  // the following HistoRmax corresponds to 1/R**2 in XY plane with R=40 (approximately
652  // the radius of a outer axial Stt hit).
653  HistoRmax = 0.000625;
654 
655 
656  // find the maximum R of the 'histogram';
657  for (i=0; i<nHitsinTrack; i++){
658  R = sqrt(X[i]*X[i]+Y[i]*Y[i]);
659 
660  if( DriftRadius[i]<0. ) { // this is a Mvd point; the Pixel/Strip
661  // in the Conformal plane is approximately contained in
662  // a circle centered in X[i], Y[i] of radius ErrorDriftRadiusconformal[i];
663  if(HistoRmax < R){ HistoRmax=R+ErrorDriftRadiusconformal[i]; }
664  Drift[i] = 0;
665  } else { // this is a Stt axial hit;
666  // take into consideration also the drift radius;
667  R += DriftRadius[i];
668  if(HistoRmax < R){ HistoRmax=R; }
669  Drift[i] = DriftRadius[i];
670  }
671  } // end of for (i=0; nHitsinTrack; i++)
672  DeltaR = (HistoRmax-fRMin)/LEGIANDRE_NRADIUSDIV;
673 
674  // fill the Matrix;
675 
676 
677  // the Theta (angle with respect to the center of the straw tube center)
678  // is the angle generated uniformly between 0 1nd 360;
679 
680  // LEGIANDRE_NTHETADIV is a Short_t const MULTIPLE OF 2, defined in PndTrkTracking2.h; it is the divisions of
681  // the full 360 degrees angle;
682 
683 
684  n_filled_cells = 0;
685  for (i=0; i<nHitsinTrack; i++){
686  // for now the number of Theta generated are one per Theta bin;
687  for(j=0;j<LEGIANDRE_NTHETADIV;j++) {
688  // generate the Theta in the middle of the bin; from 0. to 360 degrees;
689  R = X[i]*Cosine[j] + Y[i]*Sinus[j]+Drift[i];
690  IndexR = (Short_t) ((fabs(R)-fRMin)/DeltaR);
691  if(IndexR>=LEGIANDRE_NRADIUSDIV) IndexR=LEGIANDRE_NRADIUSDIV-1;
692  // the following is an essential calculation for Theta,
693  // because it changes by 180 degrees when
694  // X[i]*Cosine[j] + Y[i]*sin(Theta)+DriftRadius[i]<0;
695  if( R <0.) {
696  IndexT = j + LEGIANDRE_NTHETADIV /2 ;
697  if( IndexT >= LEGIANDRE_NTHETADIV ) IndexT -= LEGIANDRE_NTHETADIV;
698  if( IndexT >= LEGIANDRE_NTHETADIV ) IndexT = LEGIANDRE_NTHETADIV;
699  } else {
700  IndexT = j;
701  }
702 
703 
704 
705 
706  if( ! previously_filled[IndexR][IndexT] ){
707  previously_filled[IndexR][IndexT]= true;
708  n_filled_cells ++;
709  List_filled_cells_IndexR[n_filled_cells-1] = IndexR;
710  List_filled_cells_IndexT[n_filled_cells-1] = IndexT;
711  Matrix[IndexR][IndexT]=0;
712  }
713 
714  Matrix[IndexR][IndexT]++;
715  }
716 
717  } // end of for (i=0; nHitsinTrack; i++)
718 
719 
720  Short_t index_array[n_filled_cells];
721  Int_t input_array[n_filled_cells];
722 
723  for(i=0;i<n_filled_cells;i++){
724  IndexR = List_filled_cells_IndexR[i];
725  IndexT = List_filled_cells_IndexT[i];
726  input_array[i] = Matrix[IndexR][IndexT];
727  index_array[i] = i;
728  } // end of for(i=0;i<n_filled_cells;i++)
729  // find maximum in the Matrix by sorting first (from lower to bigger) and then taking the last element;
730 
731 
732 
733  MergerSorter.Merge_Sort3(
734  n_filled_cells,
735  input_array,
736  index_array
737  );
738 
739  iRMax = List_filled_cells_IndexR[ index_array[n_filled_cells-1] ];
740  iTMax = List_filled_cells_IndexT[ index_array[n_filled_cells-1] ];
741 
742  // the found parameters;
743  *Rout = (iRMax+0.5) *DeltaR + fRMin;
744  // to be coherent with the formula adopted for the straight line : X*cos(theta) + Y*sin(theta) = R
745  // it is necessary to take the complementary angle (consequently the PI/4 - );
746  *Thetaout = (iTMax+0.5) *(THETAMAX-THETAMIN)/LEGIANDRE_NTHETADIV + THETAMIN;
747 
748 
749 
750  return ;
751 }
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
void Merge_Sort3(Short_t n_ele, Int_t *array, Short_t *ind)
double Y
Definition: anaLmdDigi.C:68
Double_t
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Definition: matrix.h:50
static const Double_t THETAMAX
double X
Definition: anaLmdDigi.C:68
Double_t R
Definition: checkhelixhit.C:61
static const Double_t THETAMIN

Member Data Documentation

Double_t PndTrkLegendreFits::fDeltaT
private

Definition at line 18 of file PndTrkLegendreFits.h.

int PndTrkLegendreFits::fIcounter
private

Definition at line 12 of file PndTrkLegendreFits.h.

int PndTrkLegendreFits::fNRDiv
private

Definition at line 14 of file PndTrkLegendreFits.h.

int PndTrkLegendreFits::fNThetaDiv
private

Definition at line 14 of file PndTrkLegendreFits.h.

Double_t PndTrkLegendreFits::fRMin
private

Definition at line 18 of file PndTrkLegendreFits.h.

Double_t PndTrkLegendreFits::fThetaMax
private

Definition at line 18 of file PndTrkLegendreFits.h.

Double_t PndTrkLegendreFits::fThetaMin
private

Definition at line 18 of file PndTrkLegendreFits.h.


The documentation for this class was generated from the following files: