FairRoot/PandaRoot
PndFTSCAGlobalPerformance.cxx
Go to the documentation of this file.
1 // $Id: PndFTSCAGlobalPerformance.cxx,v 1.11 2010/08/18 20:46:09 ikulakov Exp $
2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
5 // *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
9 // *
10 // Developed by: Igor Kulakov <I.Kulakov@gsi.de> *
11 // Mykhailo Pugach <M.Pugach@gsi.de> *
12 // Maksym Zyzak <M.Zyzak@gsi.de> *
13 // *
14 // Permission to use, copy, modify and distribute this software and its *
15 // documentation strictly for non-commercial purposes is hereby granted *
16 // without fee, provided that the above copyright notice appears in all *
17 // copies and that both the copyright notice and this permission notice *
18 // appear in the supporting documentation. The authors make no claims *
19 // about the suitability of this software for any purpose. It is *
20 // provided "as is" without express or implied warranty. *
21 // *
22 //***************************************************************************
23 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
24 
25 #define USE_CA_FIT
26 
27 #include "PndFTSCounters.h"
28 
29 #include "PndFTSCAPerformance.h"
32 
33 
34 #include "PndFTSCAGBHit.h"
35 #include "PndFTSCAMCTrack.h"
36 #ifndef HLTCA_STANDALONE
37 #include "PndFTSCAMCPoint.h"
38 #endif
39 #include "PndFTSCAGBTrack.h"
40 #include "PndFTSCAGBTracker.h"
41 
42 #include "PndFTSCADisplay.h"
43 
44 #ifdef DRAW
45 #define DRAW_GLOBALPERF
46 #endif
47 
48 #ifdef DRAW_GLOBALPERF
49 #include "PndFTSCADisplay.h"
50 #include "PndFTSCAPerformance.h"
51 #endif
52 
53 #include "TMath.h"
54 #include "TROOT.h"
55 #include "Riostream.h"
56 #include "TFile.h"
57 #include "TH1.h"
58 #include "TH2.h"
59 #include "TProfile.h"
60 #include "TStyle.h"
61 
66 {
67  PndFTSCATrackPerformanceBase::SetNewEvent(tracker, hitLabels, mcTracks, localMCPoints);
68 
69 
70  nRecoTracks = fTracker->NTracks();
71 
72 
73 } // void PndFTSCAGlobalPerformance::SetNewEvent
74 
76 {
77 
78  for ( int imc = 0; imc < nMCTracks; imc++ ) (*fMCTracks)[imc].SetNHits( 0 );
79 
80  for ( int ih = 0; ih < fTracker->NHits(); ih++ ) { // TODO: do we need to calculate consequtive hits??
81  const PndFTSCAGBHit &hit = fTracker->Hit( ih );
82  const PndFTSCAHitLabel &l = (*fHitLabels)[hit.ID()];
83  /*if( hit.IsLeft() ){
84  cout<<" mirrored hit in array, something wrong!! "<<endl;
85  continue;
86  }*/
87  //cout<<ih<<" "<<hit.ID()<<" "<<l<<endl;
88  if ( l.fLab[0] >= 0 ) (*fMCTracks)[l.fLab[0]].SetNHits( (*fMCTracks)[l.fLab[0]].NHits() + 1 );
89  if ( l.fLab[1] >= 0 ) (*fMCTracks)[l.fLab[1]].SetNHits( (*fMCTracks)[l.fLab[1]].NHits() + 1 );
90  if ( l.fLab[2] >= 0 ) (*fMCTracks)[l.fLab[2]].SetNHits( (*fMCTracks)[l.fLab[2]].NHits() + 1 );
91  }
92 
93  /*for ( int ih = 0; ih < (*fHitLabels).Size(); ih++ ) { // TODO: do we need to calculate consequtive hits??
94  const PndFTSCAHitLabel &l = (*fHitLabels)[ih];
95  if ( l.fLab[0] >= 0 ) (*fMCTracks)[l.fLab[0]].SetNHits( (*fMCTracks)[l.fLab[0]].NHits() + 1 );
96  if ( l.fLab[1] >= 0 ) (*fMCTracks)[l.fLab[1]].SetNHits( (*fMCTracks)[l.fLab[1]].NHits() + 1 );
97  if ( l.fLab[2] >= 0 ) (*fMCTracks)[l.fLab[2]].SetNHits( (*fMCTracks)[l.fLab[2]].NHits() + 1 );
98  }
99  */
100  mcData.resize(nMCTracks);
101  //cout<<"nMCTracks "<<nMCTracks<<endl;
102  for ( int imc = 0; imc < nMCTracks; imc++ ) {
103  PndFTSCAMCTrack &mc = (*fMCTracks)[imc];
104  //cout<<"MCTrack PDG NHits x y "<<mc.PDG()<<" "<<mc.NHits()<<" "<<mc.X()<<" "<<mc.Y()<<endl;
105  PndFTSCAPerformanceMCTrackData &mcTrackData = mcData[imc];
106  mc.SetSet( 0 );
107  mc.SetNReconstructed( 0 );
108  mc.SetNTurns( 1 );
109  if ( ( mc.NHitRows() >= PParameters::MinimumHitsForMCTrack ) &&
110 #ifndef DRIFT_TUBES
111  // ( mc.NHits() == mc.NHitRows() ) &&
112 #else
115 #endif
116  // ( mc.NMCPoints() >= PParameters::MinimumMCPointsForMCTrack ) &&
118  ( mc.IsForwardTrack() )
119 
120  )
121  mcTrackData.SetAsReconstructable();
122 
123  // sets of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
124  if ( mc.P() >= PParameters::ExtraThreshold ) {
125  if ( mc.P() >= PParameters::RefThreshold ) {
126  mc.SetSet( 2 );
127  mcTrackData.SetSet( 2 );
128  if ( mc.MotherId() != -1 ) {
129  mc.SetSet( 5 );
130  mcTrackData.SetSet( 5 );
131 
132  }
133  else {
134  mc.SetSet( 6 );
135  mcTrackData.SetSet( 6 );
136  if ( mc.NHits() == fTracker->NStations() ) {
137  mc.SetSet( 7 );
138  mcTrackData.SetSet( 7 );
139  }
140  }
141  }
142  else{
143  mc.SetSet( 1 );
144  mcTrackData.SetSet( 1 );
145  if ( mc.MotherId() != -1 ) {
146  mc.SetSet( 3 );
147  mcTrackData.SetSet( 3 );
148 
149  }
150  else {
151  mc.SetSet( 4 );
152  mcTrackData.SetSet( 4 );
153  }
154  }
155  }
156  } // for iMC
157 
158 } // void PndFTSCAGlobalPerformance::CheckMCTracks()
159 
160 
162 {
163  recoData.resize(nRecoTracks);
164  for ( int itr = 0; itr < nRecoTracks; itr++ ) {
165  int traLabels = -1;
166  double traPurity = 0;
167  const PndFTSCAGBTrack &tCA = fTracker->Track( itr );
168  const int nhits = tCA.NHits();
169  int *lb = new int[nhits*3];
170  int nla = 0;
171  for ( int ihit = 0; ihit < nhits; ihit++ ) {
172  const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
173  const PndFTSCAHitLabel &l = (*fHitLabels)[fTracker->Hit( index ).ID()];
174  if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
175  if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
176  if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
177  }
178  std::sort( lb, lb + nla );
179  int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
180  for ( int i = 0; i < nla; i++ ) {
181  if ( lb[i] != labcur ) {
182  if ( labcur >= 0 && lmax < lcurr ) {
183  lmax = lcurr;
184  labmax = labcur;
185  }
186  labcur = lb[i];
187  lcurr = 0;
188  }
189  lcurr++;
190  }
191  if ( labcur >= 0 && lmax < lcurr ) {
192  lmax = lcurr;
193  labmax = labcur;
194  }
195  lmax = 0;
196  for ( int ihit = 0; ihit < nhits; ihit++ ) {
197  const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
198  const PndFTSCAHitLabel &l = (*fHitLabels)[fTracker->Hit( index ).ID()];
199  if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
200  ) lmax++;
201  }
202  traLabels = labmax;
203  traPurity = ( ( nhits > 0 ) ? double( lmax ) / double( nhits ) : 0 );
204  if ( lb ) delete[] lb;
205 
206  recoData[itr].SetMCTrack(traLabels, traPurity, nhits);
207  if ( recoData[itr].IsReco(PParameters::MinTrackPurity, PParameters::MinimumHitsForRecoTrack) ) mcData[traLabels].AddReconstructed(itr);
208  } // for iReco
209 } // void PndFTSCAGlobalPerformance::MatchTracks()
210 
211 
213 {
214  for ( int iRTr = 0; iRTr < nRecoTracks; iRTr++ ) {
215  if ( recoData[iRTr].IsGhost(PParameters::MinTrackPurity) )
216  fEff.ghosts++;
217  }
218 
219  for ( int iMCTr = 0; iMCTr < nMCTracks; iMCTr++ ) {
220  PndFTSCAPerformanceMCTrackData &mc = mcData[iMCTr];
221  if ( !mc.IsReconstructable() ) continue;
222  const bool reco = mc.IsReconstructed();
223  const int nclones = mc.GetNClones();
224 
225  bool killed = 0; // isn't used
226  double ratio_length = 0;
227  double ratio_fakes = 0;
228  const vector<int>& rTIds = mc.RecoTrackIds();
229  if (reco){
230  double mc_length = (*fMCTracks)[iMCTr].NMCRows();
231  for (unsigned int irt = 0; irt < rTIds.size(); irt++) {
232  PndFTSCAPerformanceRecoTrackData& rd = recoData[rTIds[irt]];
233  ratio_length += static_cast<double>( rd.NHits() )*rd.GetPurity() / mc_length;
234  ratio_fakes += 1 - rd.GetPurity();
235  }
236  }
237 
238  if ( mc.GetSet() == 0){ // rest, out track
239  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "rest");
240  }
241  else{ // good
242  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "total");
243  switch( mc.GetSet() ){
244  case 1:
245  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "extra");
246  break;
247  case 2:
248  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref");
249  break;
250  case 3:
251  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "extra");
252  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "extra_sec");
253  break;
254  case 4:
255  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "extra");
256  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "extra_prim");
257  break;
258  case 5:
259  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref");
260  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref_sec");
261  break;
262  case 6:
263  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref");
264  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref_prim");
265  break;
266  break;
267  case 7:
268  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref");
269  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref_prim");
270  fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones, "ref_prim_long");
271  break;
272  }
273  }
274  } // for iMCTr
275 
276  PndFTSCATrackPerformanceBase::EfficiencyPerformance();
277 } // void PndFTSCAGlobalPerformance::EfficiencyPerformance( )
278 
280 {
281  PndFTSCATrackPerformanceBase::FillHistos();
282 
283  const int NMCTracks = (*fMCTracks).Size();
284  vector<int> mcTrackNRecoHits;
285  vector<int> nHitsVsRow;
286  vector<int> nMCPointsVsRow;
287  const int Multiplicity = (*fMCTracks).Size();
288 
289  mcTrackNRecoHits.resize(NMCTracks, 0);
290  nHitsVsRow.resize(fTracker->NStations());
291  nMCPointsVsRow.resize(fTracker->NStations());
292  for(int iH=0; iH < fTracker->NHits(); iH++){
293  const PndFTSCAGBHit &hit = fTracker->Hit( iH );
294 
295  nHitsVsRow[hit.IRow()]++;
296 
297  const PndFTSCAHitLabel &l = (*fHitLabels)[hit.ID()];
298  if ( l.fLab[0] >= 0 ) mcTrackNRecoHits[l.fLab[0]]++;
299  if ( l.fLab[1] >= 0 ) mcTrackNRecoHits[l.fLab[1]]++;
300  if ( l.fLab[2] >= 0 ) mcTrackNRecoHits[l.fLab[2]]++;
301  }
302  for(int i=0; i < NMCTracks; i++){
303  PndFTSCAMCTrack &mcT = (*fMCTracks)[i];
304 
305  GetHisto("mcTrackNRecoHits")->Fill( mcTrackNRecoHits[i] );
306  GetHisto("nMCPointsVsMCMom")->Fill( mcT.P(), mcT.NMCPoints() );
307 
308  if ( mcT.NMCPoints() > 0 ) {
309  double mcEx = mcT.Px();
310  double mcEy = mcT.Py();
311  double mcEz = mcT.Pz();
312  double mcEt = TMath::Sqrt( mcEx * mcEx + mcEy * mcEy );
313 
314  const double dZdS = mcEz/mcEt;
315 
316  GetHisto("nHitsOverNMCPointsVsMCMom")->Fill( mcT.P(), float(mcTrackNRecoHits[i])/float(mcT.NMCPoints()) );
317  GetHisto("nHitsOverNMCPointsVsMCDzDs")->Fill( dZdS, float(mcTrackNRecoHits[i])/float(mcT.NMCPoints()) );
318  }
319  }
320 
321  for(int i=0; i < (*fLocalMCPoints).Size(); i++){
322  nMCPointsVsRow[(*fLocalMCPoints)[i].IRow()]++;
323  }
324  for(int i=0; i < fTracker->NStations(); i++){
325  if ( nMCPointsVsRow[i] > 0 ) {
326  GetHisto("nHitsOverNMCPointsVsRow")->Fill( i, float(nHitsVsRow[i])/float(nMCPointsVsRow[i]) );
327  GetHisto("nHitsOverNMCPointsVsNMCTracks")->Fill( Multiplicity, float(nHitsVsRow[i])/float(nMCPointsVsRow[i]) );
328  }
329  }
330 
331  for(int iRTr=0; iRTr < nRecoTracks; iRTr++){ // TODO: make common
332  PndFTSCAPerformanceRecoTrackData &recoD = recoData[iRTr];
333 
334  const PndFTSCAGBTrack &recoTr = fTracker->Track( iRTr ); // TODO: make common
335  PndFTSCAMCTrack &mcTr = (*fMCTracks)[ recoD.GetMCTrackId() ];
336 
337  // if ( mcTr.MotherId() == -1 ) continue;
338  // if ( (*fMCTracks)[mcTr.MotherId()].PDG() != 310 ) continue;
339  // if ( mcTr.NHits() != fTracker->NStations() ) continue;
340  // if ( abs(mcTr.Pt()) < 1 ) continue;
341  // if ( abs(mcTr.DzDs()) < 0.5 ) continue;
342 
343 #ifdef USE_CA_FIT // use 3 iterational fit, which ends on inner station
344 // PndFTSCATrackParam param = recoTr.OuterParam();
345  PndFTSCATrackParam param = recoTr.InnerParam();
346 #else
347  PndFTSCATrackParam param = recoTr.InnerParam();
348 // PndFTSCATrackParam param = recoTr.OuterParam();
349 #endif
350 
351 #if !defined(PANDA_FTS)
352  double RecoPt = 1. / fabs(param.QPt());
353  double RecoMom = RecoPt * sqrt(1. + param.DzDs()*param.DzDs());
354 #endif
355  // fNVsMom->Fill( param.Y());
356  // fLengthVsMom->Fill( param.Y(), t.NHits());
357  double prob = param.Chi2() != -1 ? TMath::Prob( param.Chi2(), param.NDF() ) : -1;
358 
359  GetHisto("purity")->Fill( recoData[iRTr].GetPurity() );
360  if ( recoD.IsGhost(PParameters::MinTrackPurity) ) {
361 #if !defined(PANDA_FTS)
362  GetHisto("ghostsRMom")->Fill( RecoMom );
363  GetHisto("ghostsRPt")->Fill( RecoPt );
364  GetHisto("ghostsMCPt")->Fill( mcTr.Pt() );
365  GetHisto("ghostsLengthAndRMom")->Fill( recoTr.NHits(), RecoMom );
366 #endif
367  GetHisto("ghostsLength")->Fill( recoTr.NHits() );
368  GetHisto("ghostsMCMom")->Fill( mcTr.P() );
369  GetHisto("ghostsLengthAndMCMom")->Fill( recoTr.NHits(), mcTr.P() );
370  GetHisto("ghostsChi2")->Fill( param.Chi2() );
371  GetHisto("ghostsProb")->Fill( prob );
372  }
373  else {
374 #if !defined(PANDA_FTS)
375  GetHisto("recosRMom")->Fill( RecoMom );
376  GetHisto("recosRPt")->Fill( RecoPt );
377  GetHisto("recosMCPt")->Fill( mcTr.Pt() );
378  GetHisto("recosLengthAndRMom")->Fill( recoTr.NHits() , RecoMom );
379 #endif
380  GetHisto("recosLength")->Fill( recoTr.NHits() );
381  GetHisto("recosMCMom")->Fill( mcTr.P() );
382  GetHisto("recosLengthAndMCMom")->Fill( recoTr.NHits() , mcTr.P() );
383 // GetHisto("recosChi2")->Fill( param.Chi2()/param.NDF() );
384 // GetHisto("recosProb")->Fill( prob );
385  if ( abs(mcTr.P()) > PParameters::RefThreshold )
386  GetHisto("recosRefProb")->Fill( prob );
387  if( mcTr.P() > 0.5 ) GetHisto("nHitsRecoTOverNHitsMCT")->Fill( float(recoTr.NHits()) / mcTrackNRecoHits[recoD.GetMCTrackId()] );
388  }
389  }
390 
391 
392 /*
393  for(int iRTr=0; iRTr < nRecoTracks; iRTr++){ // TODO: make common
394  PndFTSCAPerformanceRecoTrackData &recoD = recoData[iRTr];
395 
396  const PndFTSCAGBTrack &recoTr = fTracker->Track( iRTr ); // TODO: make common
397  PndFTSCAMCTrack &mcTr = (*fMCTracks)[ recoD.GetMCTrackId() ];
398 
399  // if ( mcTr.MotherId() == -1 ) continue;
400  // if ( (*fMCTracks)[mcTr.MotherId()].PDG() != 310 ) continue;
401  // if ( mcTr.NHits() != fTracker->NStations() ) continue;
402  // if ( abs(mcTr.Pt()) < 1 ) continue;
403  // if ( abs(mcTr.DzDs()) < 0.5 ) continue;
404 
405 */
406 
407  // global tracker performance
408  {
409  //cout<<"checkpoint #0 \n";
410 
411 
412  for ( int itr = 0; itr < nRecoTracks; itr++ ) {
413  const int iMC = recoData[itr].GetMCTrackId();
414  if ( recoData[itr].IsGhost(PParameters::MinTrackPurity) ) continue;
415  //PndFTSCAMCTrack &mc = (*fMCTracks)[iMC]; //[R.K. 9/2018] unused
416 
417  // if ( mc.MotherId() == -1 ) continue;
418  // if ( (*fMCTracks)[mc.MotherId()].PDG() != 310 ) continue;
419  // if ( mc.NHits() != fTracker->NStations() ) continue;
420 
421 #ifdef PANDA_FTS
422 #endif
424  // if ( abs(mc.DzDs()) < 0.5 ) continue;
425  //cout<<"checkpoint #1 \n";
426  //int nFirstMC = mc.FirstMCPointID(); //[R.K. 9/2018] unused
427  //int nMCPoints = mc.NMCPoints(); //[R.K. 9/2018] unused
428 
429  //PndFTSCALocalMCPoint *points = &((*fLocalMCPoints).Data()[nFirstMC]); //[R.K. 9/2018] unused
430 
431  const PndFTSCAGBTrack &t = fTracker->Track( itr );
432 #ifdef USE_CA_FIT
433 // PndFTSCATrackParam p = t.OuterParam();
435 #else
436 // PndFTSCATrackParam p = t.OuterParam();
438 #endif
439  //cout<<"checkpoint #2 \n";
441  int nHits = t.NHits();
442  if(nHits < 6) continue;
443 // int nHits = t.NHits();
444 // std::cout << "hits:" << std::endl;
445 // for(int iH=0; iH<nHits; iH++)
446 // std::cout << fTracker->Hit( fTracker->TrackHit(t.FirstHitRef() + iH) ).X() << " " <<
447 // fTracker->Hit( fTracker->TrackHit(t.FirstHitRef() + iH) ).Y() << " " <<
448 // fTracker->Hit( fTracker->TrackHit(t.FirstHitRef() + iH) ).Z() << " " << std::endl;
449 // std::cout << "MCPoints:" << std::endl;
450 // for(int iMCPoint=0; iMCPoint<nMCPoints; iMCPoint++)
451 // std::cout << points[iMCPoint].X() << " " <<
452 // points[iMCPoint].Y() << " " <<
453 // points[iMCPoint].Z() << " " << std::endl;
454 //
455 // std::cout << "track:" << std::endl;
456 // std::cout << p.X() << " " << p.Y() << " " << p.Z() << std::endl;
457 
458 
459  //21.09 take mc-value for the last hit
460  const int hitIndex = fTracker->TrackHit( t.FirstHitRef() /*+nHits-1*/ );
461 
462  const PndFTSCAGBHit &hit = fTracker->Hit( hitIndex );
463 
464  // int trackID = recoD.GetMCTrackId();
465 
466  int trackID = iMC;
467  //cout << " iMC " << trackID << " hit. Track_ID " << hit.Track_ID << endl;
468 
469  if (trackID!=hit.Track_ID) continue;
470 
471 
472  int nHits_track = t.NHits();
473 
474  //cout << "nHits_track " << nHits_track << endl;
475 
476  if (nHits_track < 22) continue;
477 
478  float Tx_mc = hit.point_Px/hit.point_Pz;
479  float Ty_mc = hit.point_Py/hit.point_Pz;
480 
481  /*
482  cout << " p.Chi2() " << p.Chi2() << " p.NDF() " << p.NDF() << endl;
483  cout<<"p.X1() p.X2() p.Tx1() p.Tx2() p.QP()"<<p.X1()<<" "<<p.X2()<<" "<<p.Tx1()<<" "<<p.Tx2()<<" " << p.QP() << endl;
484  cout << " hit.point_X " << hit.point_X << " hit.point_Y " << hit.point_Y << " Tx_mc " << Tx_mc << endl;
485  cout << " p.X1() - hit.point_X " << p.X1() - hit.point_X << endl;
486  cout << " p.Tx1() - Tx_mc " << p.Tx1() - Tx_mc << endl;*/
487 
488  if(p.Chi2() < 0 || p.NDF() <= 0) continue;
489 
490 
491  //cout << "p.Chi2() " << p.Chi2() << " p.NDF() " << p.NDF() << endl;
492  while ( true ) {
493 
494  //GetHisto("resX1")->Fill( p.X1() - mcX1 );
495 
496  GetHisto("resX1")->Fill( p.X1() - hit.point_X );
497 // if ( p.Err2X1() > 0 ) GetHisto("pullX1")->Fill( ( p.X1() - mcX1 ) / TMath::Sqrt( p.Err2X1() ) );
498  if ( p.Err2X1() > 0 )
499  GetHisto("pullX1")->Fill( ( p.X1() - hit.point_X ) / TMath::Sqrt( p.Err2X1() ) );
500 
501  GetHisto("resX2")->Fill( p.X2() - hit.point_Y );
502  if ( p.Err2X2() > 0 )
503  GetHisto("pullX2")->Fill( ( p.X2() - hit.point_Y ) / TMath::Sqrt( p.Err2X2() ) );
504 
505 #ifdef PANDA_FTS
506  // double qP = -p.QP(); // TODO: undestand why
507  double qP = p.QP(); // TODO: undestand why
508 
509 // GetHisto("resTx1")->Fill( p.Tx1() - mcTx1 );
510 
511  GetHisto("resTx1")->Fill( p.Tx1() - Tx_mc );
512  GetHisto("resTx2")->Fill( p.Tx2() - Ty_mc );
513  if(CAMath::Abs(qP) > 1.e-7)
514  {
515  GetHisto("resP")->Fill( (qP - hit.point_Qp)/hit.point_Qp );
516  }
517  //compare in terminal the mc and reco parameter values (dbg)
518  /*cout<<"p.X1() p.X2() p.Tx1() p.Tx2() p.QP()"<<p.X1()<<" "<<p.X2()<<" "<<p.Tx1()<<" "<<p.Tx2()<<" " << p.QP() << endl;
519  cout<<"mcX mcY mcTx mcTy mcQP "<<hit.point_X<<" "<<hit.point_Y<<" "<<Tx_mc<<" "<<Ty_mc<<" " << hit.point_Qp << endl;
520  cout << "p.X1() - mcX " << p.X1() - hit.point_X << endl;
521  cout << "p.Tx1() - mcTx " << p.Tx1() - Tx_mc << endl;*/
522 
523 // cout << "err " <<TMath::Sqrt( p.Err2X1())<< " " <<TMath::Sqrt( p.Err2X2()) <<" "<< TMath::Sqrt( p.Err2Tx1() ) << " " << TMath::Sqrt( p.Err2Tx2() ) << " " <<
524 // TMath::Sqrt(p.Err2QP()) << std::endl;
525 
526 // if ( p.Err2Tx1() > 0 ) GetHisto("pullTx1")->Fill( ( p.Tx1() - mcTx1 ) / TMath::Sqrt( p.Err2Tx1() ) );
527 
528  if ( p.Err2Tx1() > 0 )
529  GetHisto("pullTx1")->Fill( ( p.Tx1() - Tx_mc) / TMath::Sqrt( p.Err2Tx1() ) );
530 
531  if ( p.Err2Tx2() > 0 )
532  GetHisto("pullTx2")->Fill( ( p.Tx2() - Ty_mc ) / TMath::Sqrt( p.Err2Tx2() ) );
533  if(CAMath::Abs(qP) > 1.e-7 && p.Err2QP() > 0 )
534  GetHisto("pullQP")->Fill( (qP - hit.point_Qp)/TMath::Sqrt(p.Err2QP()) );
535 
536  if ( p.Chi2() < 1.e-7 ) continue;
537 
538 
539  double prob = p.Chi2() != -1 ? TMath::Prob( p.Chi2(), p.NDF() ) : -1;
540  GetHisto("recosChi2")->Fill( p.Chi2()/p.NDF() );
541  GetHisto("recosProb")->Fill( prob );
542 #else // PANDA_FTS
543 
544  double qPt = p.QPt();
545 
546  GetHisto("resSinPhi")->Fill( p.SinPhi() - mcSinPhi );
547  GetHisto("resDzDs")->Fill( p.DzDs() - mcDzDs );
548  if(CAMath::Abs(qPt) > 1.e-7){
549  GetHisto("resPt")->Fill( (qPt - mcQPt)/mcQPt );
550  GetHisto("resPtVsP")->Fill( TMath::Abs(mcQP), (1.f/qPt - 1.f/mcQPt)*mcQPt );
551  GetHisto("resPVsP")->Fill( TMath::Abs(mcQP), (TMath::Abs(1.f/p.QP()) - TMath::Abs(1.f/mcQP))*TMath::Abs(mcQP) );
552  // cout << setprecision(5) << qPt << " " << mcQPt << " " << TMath::Sqrt(p.Err2QPt()) << endl;
553  }
554 
555  if ( p.Err2SinPhi() > 0 ) GetHisto("pullSinPhi")->Fill( ( p.SinPhi() - mcSinPhi ) / TMath::Sqrt( p.Err2SinPhi() ) );
556  if ( p.Err2DzDs() > 0 ) GetHisto("pullDzDs")->Fill( ( p.DzDs() - mcDzDs ) / TMath::Sqrt( p.Err2DzDs() ) );
557  if(CAMath::Abs(qPt) > 1.e-7 && p.Err2QPt()>0 ) GetHisto("pullQPt")->Fill( (qPt - mcQPt)/TMath::Sqrt(p.Err2QPt()) );
558 #endif // PANDA_FTS
559 
560  break;
561  }
562  }
563 
564  }
565 
566  // hits pulls
567  { // TODO
568  const int nHits = fTracker->NHits();
569  for ( int ih = 0; ih < nHits; ih++ ) {
570  const PndFTSCAGBHit &hit = fTracker->Hit( ih );
571  float x0HLoc, x1HLoc, x2HLoc;
572  PndFTSCAParameters::GlobalToCALocal( hit.X(), hit.Y(), hit.Z(), hit.Angle(), x0HLoc, x1HLoc, x2HLoc );
573 
574  const int iMCP = PndFTSCAPerformance::Instance().GetMCPoint(hit);
575  if (iMCP == -1) continue;
576  const PndFTSCALocalMCPoint& point = fLocalMCPoints->Data()[iMCP];
577 
578  float x0PLoc, x1PLoc, x2PLoc;
579  PndFTSCAParameters::GlobalToCALocal( point.X(), point.Y(), point.Z(), hit.Angle(), x0PLoc, x1PLoc, x2PLoc );
580  float px0PLoc, px1PLoc, px2PLoc;
581  PndFTSCAParameters::GlobalToCALocal( point.Px(), point.Py(), point.Pz(), hit.Angle(), px0PLoc, px1PLoc, px2PLoc );
582  const float t1 = px1PLoc/px0PLoc, t2 = px2PLoc/px0PLoc;
583  x1PLoc += t1*( x0HLoc - x0PLoc );
584  x2PLoc += t2*( x0HLoc - x0PLoc );
585  x0PLoc = x0HLoc;
586 
587  GetHisto("resXHit")->Fill( x0HLoc - x0PLoc );
588  GetHisto("resYHit")->Fill( x1HLoc - x1PLoc );
589  GetHisto("resZHit")->Fill( x2HLoc - x2PLoc );
590  GetHisto("resXHitVsZ")->Fill( hit.Z(), x0HLoc - x0PLoc );
591  GetHisto("resYHitVsZ")->Fill( hit.Z(), x1HLoc - x1PLoc );
592  GetHisto("resZHitVsZ")->Fill( hit.Z(), x2HLoc - x2PLoc );
593  GetHisto("resXHitVsX")->Fill( hit.X(), x0HLoc - x0PLoc );
594  GetHisto("resYHitVsX")->Fill( hit.X(), x1HLoc - x1PLoc );
595  GetHisto("resZHitVsX")->Fill( hit.X(), x2HLoc - x2PLoc );
596 
597  GetHisto("xMCPoint")->Fill( point.X() );
598  GetHisto("rMCPoint")->Fill( sqrt(point.Y()*point.Y() + point.X()*point.X()) );
599 
600  // get errors
601 
602  // GetHisto("pullXHit")->Fill( hit.X() - point.X() );
603  GetHisto("pullYHit")->Fill( (x1HLoc - x1PLoc)/sqrt(hit.Err2X1()) );
604  GetHisto("pullZHit")->Fill( (x2HLoc - x2PLoc)/sqrt(hit.Err2X2()) );
605 
606 #ifdef DRIFT_TUBES
607  const float dist = hit.DistanceFromWireToPoint( point.X(), point.Y(), point.Z() );
608  GetHisto("resRHit")->Fill( hit.R() - dist );
609  GetHisto("pullRHit")->Fill( (hit.R() - dist)/sqrt(hit.Err2R()) );
610 #endif
611  }
612  }
613 
614 
615 
616 
617 
618 
619 
620 } // void PndFTSCAGlobalPerformance::FillHistos()
621 
623 {
624 #ifdef DRAW_GLOBALPERF
625  // PndFTSCAPerformance::Instance().Init();
626  PndFTSCAPerformance& gbPerfo = PndFTSCAPerformance::Instance();
628  // disp.SetGB( gbPerfo.GetTracker() );
629  disp.ClearView();
630  disp.SetTPC( fTracker->GetParameters() );
631  //disp.DrawTPC();
632  disp.DrawGBHits( *gbPerfo.GetTracker(), kGreen+2, 0.8 );
633 
634  for ( int imc = 0; imc < nMCTracks; imc++ ) {
635  PndFTSCAPerformanceMCTrackData &mc = mcData[imc];
636  bool doDraw = true;
637 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
638  //doDraw &= (mc.GetSet() == 7); // long ref prim
639  doDraw &= (*fMCTracks)[imc].P() > 1;
640  //doDraw &= mc.IsReconstructable();
641  // doDraw &= mc.IsReconstructed();
642  if ( doDraw ) disp.DrawMCTrack( imc, kRed+2, 0 );
643 #else
644  doDraw &= mc.IsReconstructable();
645  if ( doDraw ) disp.DrawMCTrack( imc, kRed+2, 0 );
646 #endif
647  }
648 
649  cout << "NRecoTracks = " << nRecoTracks << endl;
650  for( int iT = 0; iT < nRecoTracks; ++iT ) {
651  PndFTSCAPerformanceRecoTrackData &r = recoData[iT];
652  const bool IsGhost = r.IsGhost(PParameters::MinTrackPurity);
653  if ( IsGhost ) {
654  const int imc = r.GetMCTrackId();
655  PndFTSCAPerformanceMCTrackData &mc = mcData[imc];
656  UNUSED_PARAM1(mc);
657  bool doDraw = true;
658 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
659  //doDraw &= (mc.GetSet() == 7); // long ref prim
660  //doDraw &= (*fMCTracks)[imc].P() > 1;
661  //doDraw &= mc.IsReconstructable();
662  if ( doDraw ) disp.DrawRecoTrack( iT, kGreen+1, 0 );
663 
664 #else
665  //doDraw &= (mc.GetSet() == 7); // long ref prim
666  //doDraw &= (*fMCTracks)[imc].P() > 1;
667  //doDraw &= mc.IsReconstructable();
668  if ( doDraw ) disp.DrawRecoTrack( iT, kGreen+1, 0.4 );
669 #endif
670  //disp.Ask();
671  }
672  else {
673  const int imc = r.GetMCTrackId();
674  PndFTSCAPerformanceMCTrackData &mc = mcData[imc];
675  UNUSED_PARAM1(mc);
676  bool doDraw = true;
677  //doDraw &= (mc.GetSet() == 7); // long ref prim
678 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
679  doDraw &= (*fMCTracks)[imc].P() > 1;
680  //doDraw &= mc.IsReconstructable();
681  // doDraw &= mc.IsReconstructed();
682  if ( doDraw ) disp.DrawRecoTrack( iT, kBlue+1, 0 );
683 #else
684  //doDraw &= (*fMCTracks)[imc].P() > 1;
685  //doDraw &= mc.IsReconstructable();
686  // doDraw &= mc.IsReconstructed();
687  if ( doDraw ) disp.DrawRecoTrack( iT, kGreen+1, 0.4 );
688 #endif
689  }
690  }
691 
692  disp.SaveCanvasToFile( "DrawGlobalPerformance.pdf" );
693  disp.Ask();
694 
695 #endif // DRAW_GLOBALPERF
696 } // void PndFTSCAGlobalPerformance::Draw()
697 
698 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
699 
int NHitRows() const
static const float ExtraThreshold
Double_t p
Definition: anasim.C:58
static const float MinTrackPurity
Int_t t2
Definition: hist-t7.C:106
void SetTPC(const PndFTSCAParam &tpcParam)
double r
Definition: RiemannTest.C:14
void DrawRecoTrack(int itr, int color=-1, int width=-1)
virtual void SetNewEvent(const PndFTSCAGBTracker *const Tracker, PndFTSResizableArray< PndFTSCAHitLabel > *hitLabels, PndFTSResizableArray< PndFTSCAMCTrack > *mcTracks, PndFTSResizableArray< PndFTSCALocalMCPoint > *localMCPoints)
Int_t i
Definition: run_full.C:25
float Pz() const
int NMCPoints() const
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
float Err2QPt() const
float P() const
int IRow() const
Definition: PndFTSCAGBHit.h:56
float Z() const
Definition: PndFTSCAGBHit.h:43
virtual void CheckMCTracks()
Efficiency.
int FirstHitRef() const
static PndFTSCADisplay & Instance()
bool IsForwardTrack() const
Int_t t1
Definition: hist-t7.C:106
float Y() const
Definition: PndFTSCAGBHit.h:42
int NMCRows() const
static T Abs(const T &x)
Definition: PndCAMath.h:39
const std::vector< int > & RecoTrackIds() const
int NHits() const
void DrawMCTrack(int itr, int color=-1, int width=-1)
int MotherId() const
static void GlobalToCALocal(T x, T y, T angle, T &x0, T &x1)
int nHits
Definition: RiemannTest.C:16
void SetNTurns(int v)
float Angle() const
virtual void EfficiencyPerformance()
int NHitContRows() const
TFile * f
Definition: bump_analys.C:12
void SaveCanvasToFile(TString fileName)
Information about reconstruction of Reconstructed Track.
virtual void FillHistos()
Histograms.
int ID() const
Definition: PndFTSCAGBHit.h:57
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
float Py() const
float X() const
Definition: PndFTSCAGBHit.h:41
const PndFTSCATrackParam & InnerParam() const
int NMCContRows() const
float Err2DzDs() const
virtual void MatchTracks()
int reco()
int NHits() const
void SetNReconstructed(int v)
float Err2X1() const
Definition: PndFTSCAGBHit.h:52
float Px() const
float Pt() const
TTree * t
Definition: bump_analys.C:13
void SetSet(int v)
bool IsGhost(float minPurity=0)
Information about reconstruction of MCTrack.
PndSdsMCPoint * hit
Definition: anasim.C:70
float Err2X2() const
Definition: PndFTSCAGBHit.h:54
float Err2SinPhi() const
void DrawGBHits(const FTSCAHitsV &all)
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72
static const float RefThreshold