FairRoot/PandaRoot
PndLmdLineTask.cxx
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Description:
4 // 3D Straight Line fitter
5 //
6 // Author List:
7 // Mathias Michel
8 //
9 //-----------------------------------------------------------
10 
11 // This Class' Header ------------------
12 #include "PndLmdLineTask.h"
13 
14 // C/C++ Headers ----------------------
15 #include <iostream>
16 
17 // Collaborating Class Headers --------
18 #include "FairRootManager.h"
19 #include "PndLinTrack.h"
20 #include "PndSdsHit.h"
21 #include "TClonesArray.h"
22 #include "TrackData/PndTrackCand.h"
24 
25 #include "TFile.h"
26 #include "TGeoManager.h"
27 #include "TGeoTrack.h"
28 #include "TLorentzVector.h"
29 
30 // Fit Classes -----------
31 #include <TMath.h>
32 #include <TRandom2.h>
33 #include <TVector3.h>
34 //#include <TStyle.h>
35 //#include <TCanvas.h>
36 #include <Math/Vector3D.h>
37 #include <TCanvas.h>
38 #include <TF2.h>
39 #include <TGraph2D.h>
40 #include <TGraph2DErrors.h>
41 #include <TH1.h>
42 #include <TLine.h>
43 #include <TMatrixDSym.h>
44 #include <TMatrixTSym.h>
45 #include <TPolyLine3D.h>
46 #include <TVirtualFitter.h>
47 //#include <PndSdsMCPoint.h>
48 #include <TMultiGraph.h>
49 #include <TPolyLine3D.h>
50 using namespace ROOT::Math;
51 using namespace std;
52 
53 // TH1 *hchi2_0 = new TH1F("hchi2_0","#chi^{2};",4,-0.1,2.);
54 // TH1 *hchi2_1 = new TH1F("hchi2_1","#chi^{2};",40,-1,20.);
55 // TH1 *hchi2_2 = new TH1F("hchi2_2","#chi^{2};",100,-1,50.);
56 // TH1 *hchi2_3 = new TH1F("hchi2_3","#chi^{2};",100,-1,50.);
57 
59  : FairTask("Connect 2 points task") {
60  fTCandBranchName = "LMDTrackCand";
61  fRecoBranchName = hitBranch;
62  fTruePointBranch = "LMDPoint"; // True Points only for drawing!
63 }
64 
66  cout << "PndLmdLineTask::~PndLmdLineTask()" << endl;
67 }
68 
69 InitStatus PndLmdLineTask::Init() {
70  // Get ROOT Manager
71  FairRootManager* ioman = FairRootManager::Instance();
72 
73  if (ioman == 0) {
74  Error("PndLmdLineTask::Init", "RootManager not instantiated!");
75  return kERROR;
76  }
77 
78  // Get input collection
79  fTCandArray = (TClonesArray*)ioman->GetObject(fTCandBranchName);
80 
81  if (fTCandArray == 0) {
82  Error("PndLmdLineTask::Init", "trackcand-array not found!");
83  return kERROR;
84  }
85 
86  fRecoArray = (TClonesArray*)ioman->GetObject(fRecoBranchName);
87 
88  if (fRecoArray == 0) {
89  Error("PndLmdLineTask::Init", "reco-array not found!");
90  return kERROR;
91  }
92 
93  fTrackArray = new TClonesArray("PndLinTrack");
94  ioman->Register("LMDTrack", "PndLmd", fTrackArray, kTRUE);
95 
96  std::cout << "-I- PndLmdLineTask: Initialisation successfull" << std::endl;
97  return kSUCCESS;
98 }
99 
100 void PndLmdLineTask::Exec(Option_t*) {
101  std::cout << "PndLmdLineTask::Exec" << std::endl;
102  // Reset output Array
103  if (fTrackArray == 0) Fatal("PndLmdLineTask::Exec", "No TrackArray");
104  fTrackArray->Delete();
105 
106  Int_t ntcand = fTCandArray->GetEntriesFast();
107 
108  // Detailed output
109  if (fVerbose > 1)
110  std::cout << " -I- PndLmdLineTask: contains " << ntcand << " RhoCandidates"
111  << std::endl;
112  if (fVerbose > 2) {
113  std::cout << " Detailed Debug info on the candidates:" << std::endl;
114  unsigned int index =
115  12345; // detid=12345, //[R.K.03/2017] unused variable
116  for (Int_t itr = 0; itr < ntcand; ++itr) {
117  PndTrackCand* trcnd = (PndTrackCand*)fTCandArray->At(itr);
118  std::cout << "TrackCand no. " << itr << " has " << trcnd->GetNHits()
119  << " hits." << std::endl;
120  std::cout << "Point: \t Index: " << std::endl;
121  for (unsigned int ihit = 0; ihit < trcnd->GetNHits();
122  ihit++) { // fill Graph
123  PndTrackCandHit theHit = trcnd->GetSortedHit(ihit); // get hit
124  index = theHit.GetHitId();
125  // detid = theHit.GetDetId(); //[R.K.03/2017] unused variable
126  std::cout << ihit << "\t" << index << std::endl;
127  }
128  }
129  }
130 
131  // Cut evil event
132  // if(ntcand>20){
133  // std::cout<<"ntcand="<<ntcand<<" Evil Event! skipping"<<std::endl;
134  // return;
135  //}
136 
137  // Fitting
138  // ----------------------------------------------------------------------------------
139  if (fVerbose > 1)
140  std::cout << " -I- PndLmdLineTask: start Fitting " << std::endl;
141  int rec_tkr = 0;
142  for (Int_t track = 0; track < ntcand; track++) {
143  PndTrackCand* trcnd = (PndTrackCand*)fTCandArray->At(track);
144  const int numPts = trcnd->GetNHits(); // read how many points in this track
145 
147  PndTrackCandHit theHit1 = trcnd->GetSortedHit(0); // get 1st hit
148  Int_t index1 = theHit1.GetHitId();
149  PndSdsHit* Hit1sds = (PndSdsHit*)fRecoArray->At(index1);
150  TVector3 posSeed = Hit1sds->GetPosition();
151  PndTrackCandHit theHit2 = trcnd->GetSortedHit(numPts - 1); // get last hit
152  Int_t index2 = theHit2.GetHitId();
153  PndSdsHit* Hit2sds = (PndSdsHit*)fRecoArray->At(index2);
154  TVector3 pos2 = Hit2sds->GetPosition();
155  TVector3 dirSeed = pos2 - posSeed;
156  dirSeed *= 1. / dirSeed.Mag();
157  // TVector3 posSeed = trcnd->getPosSeed();
158  // TVector3 dirSeed = trcnd->getDirSeed();
159  if (fVerbose > 2)
160  std::cout << "Track: " << track << " Points: " << numPts << std::endl;
162 
163  // TGraph2DErrors fitme(numPts); //new graph for fitting
164  Int_t firstHit = -1, lastHit = -1;
165  for (int ihit = 0; ihit < numPts; ihit++) { // fill Graph
166  PndTrackCandHit theHit = trcnd->GetSortedHit(ihit); // get hit
167  Int_t index = theHit.GetHitId();
168  // Int_t detId = theHit.GetDetId(); //[R.K. 01/2017] unused variable
169  // if(fVerbose>2) std::cout << "Point: "<< ihit<< " index: "<< index
170  // <<std::endl;
171 
172  if (ihit == 0)
173  firstHit = index;
174  else if (ihit == numPts - 1)
175  lastHit = index;
176  // PndSdsHit* addHit = (PndSdsHit*) fRecoArray->At(index);
177  // TVector3 addPos = addHit->GetPosition();
178  // cout<<"#"<<ihit<<" addPos:"<<endl;
179  // addPos.Print();
180  // fitme.SetPoint(ihit, addPos.X(), addPos.Y(), addPos.Z());
181  // fitme.SetPointError(ihit, addHit->GetDx(), addHit->GetDy(),
182  // addHit->GetDz());
183 
184  // PndSdsMCPoint *addHit = (PndSdsMCPoint*) fTruePointArray->At(index);
185  // //TEST ideal fit
186  // TVector3 addPos = addHit->GetPosition();
187  // fitme.SetPoint(ihit, addPos.X(), addPos.Y(), addPos.Z());
188  // PndSdsHit* recHit = (PndSdsHit*) fRecoArray->At(index);
189  // fitme.SetPointError(ihit, recHit->GetDx(), recHit->GetDy(),
190  // recHit->GetDz());
191  } // end of Hits in TCand
192 
193  /*Double_t parFit[6]; //fit-parameter
194  TMatrixDSym *COVmatrix = new TMatrixDSym(6);
195  Double_t accuracy = line3Dfit(numPts, &fitme, posSeed, dirSeed, parFit,
196  COVmatrix);*/
197 
198  // if(accuracy>0 && accuracy<1e3){
199  // start (P0, P2, P4), direction (P1, P3, P5) straight line
200  PndLinTrack* trackfit = new PndLinTrack(
201  "Lumi", posSeed.X(), dirSeed.X(), posSeed.Y(), dirSeed.Y(), posSeed.Z(),
202  posSeed.Z(), 0, firstHit, lastHit, track);
203  // PndLinTrack* trackfit = new PndLinTrack("Lumi", parFit[0], parFit[1],
204  // parFit[2], parFit[3], parFit[4], parFit[5],
205  // accuracy, firstHit, lastHit, track);
206  // trackfit->SetCovarianceMatrix(*COVmatrix);
207  new ((*fTrackArray)[rec_tkr]) PndLinTrack(*(trackfit)); // save Track
208  delete trackfit; // TEST
209  rec_tkr++;
210  // }
211  } // end of TCand's
212 
213  // Done--------------------------------------------------------------------------------------
214 
215  // TCanvas *c1 = new TCanvas("hchi2");
216  // c1->Divide(2,2);
217  // c1->cd(1);
218  // hchi2_0->Draw();
219  // c1->cd(2);
220  // hchi2_1->Draw();
221  // c1->cd(3);
222  // hchi2_2->Draw();
223  // c1->cd(4);
224  // hchi2_3->Draw();
225  // // c1->Write();
226  // gPad->WaitPrimitive();
227  std::cout << "Fitting done" << std::endl;
228  return;
229 }
230 
231 // // define the parameteric line equation
232 // void PndLmdLinFitTask::line(double t, double *p, double &x, double &y, double
233 // &z) {
234 // // a parameteric line is define from 6 parameters but 4 are independent
235 // // x0,y0,z0,z1,y1,z1 which are the coordinates of two points on the line
236 // // can choose z0 = 0 if line not parallel to x-y plane and z1 = 1;
237 // x = p[0] + p[1]*t;
238 // y = p[2] + p[3]*t;
239 // z = t;
240 // // std::cout<<"PndLmdLinFitTask::line z = "<<z<<std::endl;
241 // }
242 
243 // calculate distance line-point
244 /*double PndLmdLinFitTask::distance2(double x,double y,double z, double *p) {
245  // distance line point is D= | (xp-x0) cross ux |
246  // where ux is direction of line and x0 is a point in the line (like t = 0)
247  XYZVector xp(x,y,z);
248  // XYZVector x0(p[0], p[2], 0. );
249  // XYZVector x1(p[0] + p[1], p[2] + p[3], 1. );
250  // XYZVector x0(p[0], p[2], fz0 ); //Move origin of local coordinates to
251 first lumi plane
252  // XYZVector x1(p[0] + p[1], p[2] + p[3], fz0+1. );
253  XYZVector x0(p[0], p[2], p[4] ); //! Move origin of local coordinates to
254 first lumi plane
255  XYZVector x1(p[0] + p[1], p[2] + p[3], p[5] ); //!
256  XYZVector u = (x1-x0).Unit();
257  double d2 = ((xp-x0).Cross(u)) .Mag2();
258  return d2;
259 }*/
260 
261 // function to be minimized
262 /*void PndLmdLinFitTask::SumDistance2(int &, double *, double & sum, double *
263 par, int ) {
264  TGraph2D * gr = dynamic_cast<TGraph2D*>(
265 (TVirtualFitter::GetFitter())->GetObjectFit() );
266  assert(gr != 0);
267  double * x = gr->GetX();
268  double * y = gr->GetY();
269  double * z = gr->GetZ();
270  int npoints = gr->GetN();
271  sum = 0;
272  for (int i = 0; i < npoints; ++i) {
273  double d = distance2(x[i],y[i],z[i],par);
274  sum += d;
275  }
276  //if (firstIt && fVerbose>1)
277  // std::cout << "Total sum2 = " << sum << std::endl;
278  //firstIt = false;
279 }*/
280 
281 // calculate distance line-point in local coordinates
282 /*double PndLmdLinFitTask::distance_perp(double x,double y,double z, double
283 errx,double erry,double errz, double *p) {
284  //Double_t t_min =
285 (p[1]*(x-p[0])+p[3]*(y-p[2])+p[5]*(z-p[4]))/(p[1]*p[1]+p[3]*p[3]+p[5]*p[5]);
286  // p[5]=sqrt(1-p[1]*p[1]-p[3]*p[3]);//TEST
287  // Double_t t_min = (z-p[4])/p[5];
288  // Double_t t_min = (p[1]*(x-p[0])+p[3]*(y-p[2])+p[5]*(z-p[4])); //TEST
289  Double_t t_min = (z-p[4]);
290  Double_t fdx = pow((p[0]+p[1]*t_min-x)/errx,2);
291  Double_t fdy = pow((p[2]+p[3]*t_min-y)/erry,2);
292  // Double_t fdz = pow((p[4]+p[5]*t_min-z)/errz,2);
293  // Double_t fdz = pow((p[4]+p[5]*t_min-z)/1.,2);
294  // cout<<"fdx = pow("<<(p[0]+p[1]*t_min-x)<<"/"<<errx<<",2) = "<<fdx<<endl;
295  // cout<<"fdy = pow("<<(p[2]+p[3]*t_min-y)<<"/"<<erry<<",2) = "<<fdy<<endl;
296  // cout<<"fdz = pow("<<(p[4]+p[5]*t_min-z)<<"/"<<errz<<",2) = "<<fdz<<endl;
297  // cout<<"fdx = "<<fdx<<" fdy = "<<fdy<<" fdz = "<<fdz<<endl;
298  // Double_t fchi2 = fdx + fdy + fdz;
299  Double_t fchi2 = fdx + fdy;
300  // cout<<"fchi2 = "<<fchi2<<endl;
301  return fchi2;
302 }*/
303 
304 // calculate distance line-point in local coordinates
305 /*double PndLmdLinFitTask::distance_l(double x,double y,double z, double
306 errx,double erry,double errz, double *p) {
307  // cout<<"(p[1]*p[1]+p[3]*p[3]) = "<<(p[1]*p[1]+p[3]*p[3])<<endl;
308  // if((p[1]*p[1]+p[3]*p[3])>1) return 1e6;
309 
310  // double fdx = TMath::Power((x-(p[0] + p[1]*(z-fz0)))/errx,2);
311  // double fdy = TMath::Power((y-(p[2] + p[3]*(z-fz0)))/erry,2);
312  double fdx = TMath::Power((x-(p[0] + p[1]*(z-p[4])))/errx,2);
313  double fdy = TMath::Power((y-(p[2] + p[3]*(z-p[4])))/erry,2);
314  double fchi2 = fdx + fdy;
315  std::cout<<"z = "<<z<<" fchi2 = "<<fchi2<<" fdx = "<<fdx<<" fdy =
316 "<<fdy<<std::endl;
317  return fchi2;
318 }*/
319 
320 // function to be minimized in local coordinates
321 /*void PndLmdLinFitTask::LocalFCN(int &, double *, double & sum, double * par,
322 int ) {
323  TGraph2DErrors * gr = dynamic_cast<TGraph2DErrors*>(
324 (TVirtualFitter::GetFitter())->GetObjectFit() );
325  assert(gr != 0);
326  double * x = gr->GetX();
327  double * y = gr->GetY();
328  double * z = gr->GetZ();
329  double * errx = gr->GetEX();
330  double * erry = gr->GetEY();
331  double * errz = gr->GetEZ();
332  int npoints = gr->GetN();
333  sum = 0;
334  // double errMS[4]={0.,0.0031,0.0071,0.0119};//TEST with real MS error
335  // double errMS[4]={errx[0],0.0031,0.0071,0.0119};//TEST with real MS error
336  for (int i = 0; i < npoints; ++i) {
337  // cout<<"hit#"<<i<<endl;
338  // cout<<"Hit errors: x["<<i<<"]="<<errx[i]<<" y["<<i<<"]="<<erry[i]<<endl;
339  // double errx_new = hypot(errx[i],errMS[i]);//TEST with real MS error
340  // double erry_new = hypot(erry[i],errMS[i]);//TEST with real MS error
341  // cout<<"errx_new ="<<errx_new<<endl;
342  // cout<<"erry_new ="<<erry_new<<endl;
343  // double chi2 =
344 distance_perp(x[i],y[i],z[i],errx_new,erry_new,errz[i],par);
345 
346  double chi2 = distance_perp(x[i],y[i],z[i],errx[i],erry[i],errz[i],par);
347 
348  //double chi2 = distance_l(x[i],y[i],z[i],errx[i],erry[i],errz[i],par);
349  sum += chi2;
350  // if(i==0) hchi2_0->Fill(chi2);
351  // if(i==1) hchi2_1->Fill(chi2);
352  // if(i==2) hchi2_2->Fill(chi2);
353  // if(i==3) hchi2_3->Fill(chi2);
354  // cout<<" "<<endl;
355  }
356  // cout<<"CHI2 = "<<sum<<endl;
357 }*/
358 
359 /*double PndLmdLinFitTask::line3Dfit(Int_t nd, TGraph2DErrors* gr, Double_t*
360 fitpar, Double_t* fitparerr)
361 {
362  Int_t Npoint = gr->GetN();
363 
364  //The default minimizer is Minuit
365  TVirtualFitter::SetDefaultFitter("Minuit");
366  TVirtualFitter *min = TVirtualFitter::Fitter(0,4);
367  min->SetObjectFit(gr);
368  //min->SetFCN( *SumDistance2 );
369  min->SetFCN(*LocalFCN);//using local coordinate in FCN
370  Double_t arglist[100];
371  arglist[0] = 1;
372  min->ExecuteCommand("SET PRINT",arglist,1);
373 
374  double pStart[4] = {25.15,0.04,0.09,8.4e-5};
375  double pStartErr[4] = {4.5,0.004,4.5,0.004};
376  min->SetParameter(0,"x0",pStart[0],pStartErr[0],0,0);
377  min->SetParameter(1,"Ax",pStart[1],pStartErr[1],0,0);
378  min->SetParameter(2,"y0",pStart[2],pStartErr[2],0,0);
379  min->SetParameter(3,"Ay",pStart[3],pStartErr[3],0,0);
380 
381 
382 
383  // // //minimize step 1
384  // // arglist[0] = 100; //number of functiona calls
385  // // arglist[1] = 0.001; //tolerance
386  // // min->ExecuteCommand("HESSE", arglist ,2);
387 
388  // //minimize step 2
389  arglist[0] = 1000; //number of functiona calls
390  arglist[1] = 0.001; //tolerance
391  min->ExecuteCommand("MIGRAD", arglist ,2);
392 
393 
394  //if (minos) min->ExecuteCommand("MINOS",arglist,0);
395  int nvpar,nparx;
396  double amin,edm, errdef;
397  min->GetStats(amin,edm,errdef,nvpar,nparx);
398  if(fVerbose>1)
399  min->PrintResults(1,amin);
400  // gr->Draw("p0");
401 
402  // get fit parameters and errors
403  for (int i = 0; i <4; ++i){
404  fitpar[i] = min->GetParameter(i);
405  fitparerr[i] = min->GetParError(i);
406  }
407 
408  // return amin;
409  Double_t chi2 = amin/(2.*Npoint-4);
410  cout<<"Chi^2 = "<<chi2<<endl;
411  return chi2;
412 }*/
413 
414 /*double PndLmdLinFitTask::line3Dfit(Int_t nd, TGraph2DErrors* gr, TVector3
415 posSeed, TVector3 dirSeed, Double_t* fitpar, TMatrixDSym *covmatrix)
416 {
417  cout<<"PndLmdLinFitTask::line3Dfit with SEED is used"<<endl;
418  Int_t Npoint = gr->GetN();
419  Double_t ErrX1 = gr->GetErrorX(0);
420  Double_t ErrY1 = gr->GetErrorY(0);
421  Double_t ErrZ1 = gr->GetErrorZ(0);
422  Double_t ErrX2 = gr->GetErrorX(1);
423  Double_t ErrY2 = gr->GetErrorY(1);
424  Double_t ErrZ2 = gr->GetErrorY(1);
425 
426  Double_t errRx = TMath::Hypot(ErrX1,ErrX2);
427  Double_t errRy = TMath::Hypot(ErrY1,ErrY2);
428  Double_t errRz = TMath::Hypot(ErrZ1,ErrZ2);
429 
430  //The default minimizer is Minuit
431  TVirtualFitter::SetDefaultFitter("Minuit");
432  TVirtualFitter *min = TVirtualFitter::Fitter(0,5);
433  min->SetObjectFit(gr);
434  // min->SetFCN( *SumDistance2 );
435  min->SetFCN(*LocalFCN);//using local coordinate in FCN
436  Double_t arglist[100];
437  arglist[0] = 1;
438  min->ExecuteCommand("SET PRINT",arglist,1);
439 
440  cout<<"posSeed:"<<endl;
441  posSeed.Print();
442  cout<<"dirSeed:"<<endl;
443  dirSeed.Print();
444  double pStart[6] =
445 {posSeed.X(),dirSeed.X(),posSeed.Y(),dirSeed.Y(),posSeed.Z(),dirSeed.Z()};
446  double pStartErr[6] = {ErrX1,errRx,ErrY1,errRy,ErrZ1,errRz};
447 
448  //stupid and must be removed!
449  if(ErrX1==0 || ErrY1==0)
450  for(int k=0;k<6;k++) pStartErr[k]=0;
451 
452  min->SetParameter(0,"x0",pStart[0],pStartErr[0],0,0);
453  min->SetParameter(1,"Ax",pStart[1],pStartErr[1],0,0);
454  min->SetParameter(2,"y0",pStart[2],pStartErr[2],0,0);
455  min->SetParameter(3,"Ay",pStart[3],pStartErr[3],0,0);
456  min->SetParameter(4,"z0",pStart[4],0,0,0);
457  // min->SetParameter(5,"Az",pStart[5],0,0,0);
458  min->SetParameter(5,"Az",1.,0,0,0);
459 
460  // Now ready for minimization step
461  arglist[0] = 1500;
462  // arglist[0] = 1; //TEST
463  arglist[1] = 1.;
464  min->ExecuteCommand("MIGRAD", arglist,2);
465 
467  int nvpar,nparx;
468  double amin,edm, errdef;
469  min->GetStats(amin,edm,errdef,nvpar,nparx);
470  if(fVerbose>1)
471  min->PrintResults(1,amin);
472  // gr->Draw("p0");
473 
474  Double_t fitparerr[6];
475  // get fit parameters
476  for (int i = 0; i <6; ++i){
477  fitpar[i] = min->GetParameter(i);
478  fitparerr[i] = min->GetParError(i);
479  }
480 
481  // fitpar[5]=sqrt(1-fitpar[1]*fitpar[1]-fitpar[3]*fitpar[3]);
482  // cout<<"SEED DIR=("<<dirSeed.X()<<", "<<dirSeed.Y()<<",
483 "<<dirSeed.Z()<<")"<<endl;
484  // cout<<"RecTRK DIR=("<<fitpar[1]<<", "<<fitpar[3]<<",
485 "<<fitpar[5]<<")"<<endl;
486  for(size_t i=0;i<4;i++){
487  for(size_t j=0;j<4;j++){
488  (*covmatrix)(i,j)= min->GetCovarianceMatrixElement(i,j);
489  }
490  }
491  (*covmatrix)(4,4) = gr->GetErrorZ(0)*gr->GetErrorZ(0);
492  (*covmatrix)(4,4) += (*covmatrix)(0,0)*pow(tan(2.326*TMath::Pi()/180.),2);
493  // double dp5_dp1 = fabs(fitpar[1]/pow(fitpar[5],3));
494  // double dp5_dp3 = fabs(fitpar[3]/pow(fitpar[5],3));
495  // double errdz2 = pow(dp5_dp1,2)*(*covmatrix)(1,1) +
496 pow(dp5_dp3,2)*(*covmatrix)(3,3) +
497  // 2*dp5_dp1*dp5_dp3*(*covmatrix)(1,3);
498  // cout<<"pow(dp5_dp1,2)*(*covmatrix)(1,1) =
499 "<<pow(dp5_dp1,2)*(*covmatrix)(1,1)<<endl;
500  // cout<<"pow(dp5_dp3,2)*(*covmatrix)(3,3) =
501 "<<pow(dp5_dp3,2)*(*covmatrix)(3,3)<<endl;
502  // cout<<"2*dp5_dp1*dp5_dp3*(*covmatrix)(1,3) =
503 "<<2*dp5_dp1*dp5_dp3*(*covmatrix)(1,3)<<endl;
504  // (*covmatrix)(5,5) = errdz2;
505  //(*covmatrix)(5,5) =
506 (fitpar[1]*fitpar[1]*(*covmatrix)(1,1)+fitpar[3]*fitpar[3]*(*covmatrix)(3,3))/pow(fitpar[5],6);
507  for(size_t i=0;i<6;i++){
508  for(size_t j=0;j<6;j++){
509  cout<<(*covmatrix)(i,j)<<" ";
510  }
511  cout<<endl;
512  }
513 
514  // Double_t chi2 = amin/(3.*Npoint-6);
515  // Double_t chi2 = amin/(3.*Npoint-3);
516  // Double_t chi2 = amin/(3.*Npoint-5);
517  Double_t chi2 = amin/(2.*Npoint-4);
518  //Double_t chi2 = amin/(3.*Npoint-4);
519  //Double_t chi2 = amin;
520  cout<<"After fit: Chi^2 = "<<chi2<<endl;
522 
523  return chi2;
524 }*/
525 
int fVerbose
Definition: poormantracks.C:24
TVector3 GetPosition() const
Definition: PndSdsHit.h:93
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
virtual void Exec(Option_t *opt)
PndLmdLineTask(TString hitBranch="LMDHitsStrip")
virtual InitStatus Init()
TClonesArray * fTrackArray
TClonesArray * fRecoArray
TString fTCandBranchName
PndMCTrack * track
Definition: anaLmdCluster.C:89
TString fTruePointBranch
TString fRecoBranchName
virtual ~PndLmdLineTask()
TClonesArray * fTCandArray
UInt_t GetNHits() const
Definition: PndTrackCand.h:59
ClassImp(PndAnaContFact)
Int_t GetHitId() const