23 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
36 #ifndef HLTCA_STANDALONE
45 #define DRAW_GLOBALPERF
48 #ifdef DRAW_GLOBALPERF
55 #include "Riostream.h"
67 PndFTSCATrackPerformanceBase::SetNewEvent(tracker, hitLabels, mcTracks, localMCPoints);
70 nRecoTracks = fTracker->NTracks();
78 for (
int imc = 0; imc < nMCTracks; imc++ ) (*fMCTracks)[imc].SetNHits( 0 );
80 for (
int ih = 0; ih < fTracker->NHits(); ih++ ) {
82 const PndFTSCAHitLabel &l = (*fHitLabels)[hit.
ID()];
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 );
100 mcData.resize(nMCTracks);
102 for (
int imc = 0; imc < nMCTracks; imc++ ) {
136 if ( mc.
NHits() == fTracker->NStations() ) {
163 recoData.resize(nRecoTracks);
164 for (
int itr = 0; itr < nRecoTracks; itr++ ) {
166 double traPurity = 0;
169 int *lb =
new int[nhits*3];
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];
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 ) {
191 if ( labcur >= 0 && lmax < lcurr ) {
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
203 traPurity = ( ( nhits > 0 ) ?
double( lmax ) / double( nhits ) : 0 );
204 if ( lb )
delete[] lb;
206 recoData[itr].SetMCTrack(traLabels, traPurity, nhits);
214 for (
int iRTr = 0; iRTr < nRecoTracks; iRTr++ ) {
219 for (
int iMCTr = 0; iMCTr < nMCTracks; iMCTr++ ) {
226 double ratio_length = 0;
227 double ratio_fakes = 0;
230 double mc_length = (*fMCTracks)[iMCTr].NMCRows();
231 for (
unsigned int irt = 0; irt < rTIds.size(); irt++) {
233 ratio_length +=
static_cast<double>( rd.
NHits() )*rd.
GetPurity() / mc_length;
239 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"rest");
242 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"total");
245 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
248 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
251 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
252 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra_sec");
255 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
256 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra_prim");
259 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
260 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_sec");
263 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
264 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_prim");
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");
276 PndFTSCATrackPerformanceBase::EfficiencyPerformance();
281 PndFTSCATrackPerformanceBase::FillHistos();
283 const int NMCTracks = (*fMCTracks).Size();
284 vector<int> mcTrackNRecoHits;
285 vector<int> nHitsVsRow;
286 vector<int> nMCPointsVsRow;
287 const int Multiplicity = (*fMCTracks).Size();
289 mcTrackNRecoHits.resize(NMCTracks, 0);
290 nHitsVsRow.resize(fTracker->NStations());
291 nMCPointsVsRow.resize(fTracker->NStations());
292 for(
int iH=0; iH < fTracker->NHits(); iH++){
295 nHitsVsRow[hit.
IRow()]++;
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]]++;
302 for(
int i=0;
i < NMCTracks;
i++){
305 GetHisto(
"mcTrackNRecoHits")->Fill( mcTrackNRecoHits[
i] );
306 GetHisto(
"nMCPointsVsMCMom")->Fill( mcT.
P(), mcT.
NMCPoints() );
309 double mcEx = mcT.
Px();
310 double mcEy = mcT.
Py();
311 double mcEz = mcT.
Pz();
312 double mcEt =
TMath::Sqrt( mcEx * mcEx + mcEy * mcEy );
314 const double dZdS = mcEz/mcEt;
316 GetHisto(
"nHitsOverNMCPointsVsMCMom")->Fill( mcT.
P(), float(mcTrackNRecoHits[i])/float(mcT.
NMCPoints()) );
317 GetHisto(
"nHitsOverNMCPointsVsMCDzDs")->Fill( dZdS,
float(mcTrackNRecoHits[i])/
float(mcT.
NMCPoints()) );
321 for(
int i=0; i < (*fLocalMCPoints).Size(); i++){
322 nMCPointsVsRow[(*fLocalMCPoints)[
i].IRow()]++;
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]) );
331 for(
int iRTr=0; iRTr < nRecoTracks; iRTr++){
343 #ifdef USE_CA_FIT // use 3 iterational fit, which ends on inner station
351 #if !defined(PANDA_FTS)
352 double RecoPt = 1. /
fabs(param.
QPt());
353 double RecoMom = RecoPt *
sqrt(1. + param.
DzDs()*param.
DzDs());
357 double prob = param.
Chi2() != -1 ? TMath::Prob( param.
Chi2(), param.
NDF() ) : -1;
359 GetHisto(
"purity")->Fill( recoData[iRTr].GetPurity() );
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 );
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 );
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 );
380 GetHisto(
"recosLength")->Fill( recoTr.
NHits() );
381 GetHisto(
"recosMCMom")->Fill( mcTr.
P() );
382 GetHisto(
"recosLengthAndMCMom")->Fill( recoTr.
NHits() , mcTr.
P() );
386 GetHisto(
"recosRefProb")->Fill( prob );
387 if( mcTr.
P() > 0.5 ) GetHisto(
"nHitsRecoTOverNHitsMCT")->Fill(
float(recoTr.
NHits()) / mcTrackNRecoHits[recoD.
GetMCTrackId()] );
412 for (
int itr = 0; itr < nRecoTracks; itr++ ) {
413 const int iMC = recoData[itr].GetMCTrackId();
442 if(nHits < 6)
continue;
460 const int hitIndex = fTracker->TrackHit( t.
FirstHitRef() );
469 if (trackID!=hit.
Track_ID)
continue;
472 int nHits_track = t.
NHits();
476 if (nHits_track < 22)
continue;
488 if(p.
Chi2() < 0 || p.
NDF() <= 0)
continue;
496 GetHisto(
"resX1")->Fill( p.
X1() - hit.
point_X );
501 GetHisto(
"resX2")->Fill( p.
X2() - hit.
point_Y );
511 GetHisto(
"resTx1")->Fill( p.Tx1() - Tx_mc );
512 GetHisto(
"resTx2")->Fill( p.Tx2() - Ty_mc );
528 if ( p.Err2Tx1() > 0 )
529 GetHisto(
"pullTx1")->Fill( ( p.Tx1() - Tx_mc) /
TMath::Sqrt( p.Err2Tx1() ) );
531 if ( p.Err2Tx2() > 0 )
532 GetHisto(
"pullTx2")->Fill( ( p.Tx2() - Ty_mc ) /
TMath::Sqrt( p.Err2Tx2() ) );
536 if ( p.
Chi2() < 1.e-7 )
continue;
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 );
544 double qPt = p.
QPt();
546 GetHisto(
"resSinPhi")->Fill( p.
SinPhi() - mcSinPhi );
547 GetHisto(
"resDzDs")->Fill( p.
DzDs() - mcDzDs );
549 GetHisto(
"resPt")->Fill( (qPt - mcQPt)/mcQPt );
550 GetHisto(
"resPtVsP")->Fill(
TMath::Abs(mcQP), (1.
f/qPt - 1.
f/mcQPt)*mcQPt );
568 const int nHits = fTracker->NHits();
569 for (
int ih = 0; ih <
nHits; ih++ ) {
571 float x0HLoc, x1HLoc, x2HLoc;
574 const int iMCP = PndFTSCAPerformance::Instance().GetMCPoint(hit);
575 if (iMCP == -1)
continue;
578 float x0PLoc, x1PLoc, x2PLoc;
580 float px0PLoc, px1PLoc, px2PLoc;
582 const float t1 = px1PLoc/px0PLoc,
t2 = px2PLoc/px0PLoc;
583 x1PLoc += t1*( x0HLoc - x0PLoc );
584 x2PLoc += t2*( x0HLoc - x0PLoc );
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 );
597 GetHisto(
"xMCPoint")->Fill( point.
X() );
598 GetHisto(
"rMCPoint")->Fill(
sqrt(point.
Y()*point.
Y() + point.
X()*point.
X()) );
603 GetHisto(
"pullYHit")->Fill( (x1HLoc - x1PLoc)/
sqrt(hit.
Err2X1()) );
604 GetHisto(
"pullZHit")->Fill( (x2HLoc - x2PLoc)/
sqrt(hit.
Err2X2()) );
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()) );
624 #ifdef DRAW_GLOBALPERF
626 PndFTSCAPerformance& gbPerfo = PndFTSCAPerformance::Instance();
630 disp.
SetTPC( fTracker->GetParameters() );
632 disp.
DrawGBHits( *gbPerfo.GetTracker(), kGreen+2, 0.8 );
634 for (
int imc = 0; imc < nMCTracks; imc++ ) {
637 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
639 doDraw &= (*fMCTracks)[imc].P() > 1;
649 cout <<
"NRecoTracks = " << nRecoTracks << endl;
650 for(
int iT = 0; iT < nRecoTracks; ++iT ) {
658 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
678 #if !(defined(PANDA_STT) || defined(PANDA_FTS))
679 doDraw &= (*fMCTracks)[imc].P() > 1;
695 #endif // DRAW_GLOBALPERF
698 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
static const float ExtraThreshold
static const float MinTrackPurity
void SetTPC(const PndFTSCAParam &tpcParam)
void DrawRecoTrack(int itr, int color=-1, int width=-1)
friend F32vec4 sqrt(const F32vec4 &a)
static T Sqrt(const T &x)
static PndFTSCADisplay & Instance()
bool IsForwardTrack() const
void DrawMCTrack(int itr, int color=-1, int width=-1)
static void GlobalToCALocal(T x, T y, T angle, T &x0, T &x1)
void SaveCanvasToFile(TString fileName)
friend F32vec4 fabs(const F32vec4 &a)
const PndFTSCATrackParam & InnerParam() const
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
void SetNReconstructed(int v)
void DrawGBHits(const FTSCAHitsV &all)
static const float RefThreshold