27 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
37 #ifndef HLTCA_STANDALONE
47 #include "Riostream.h"
55 vector<PndCAHitLabel> *hitLabels,
56 vector<PndCAMCTrack> *mcTracks,
57 vector<PndCALocalMCPoint> *localMCPoints)
59 PndCATrackPerformanceBase::SetNewEvent(tracker, hitLabels, mcTracks, localMCPoints);
62 nRecoTracks = fTracker->NTracks();
69 for (
int imc = 0; imc < nMCTracks; imc++ ) (*fMCTracks)[imc].SetNHits( 0 );
70 cout<<
"nHits "<<fTracker->NHits()<<
" n labels "<<(*fHitLabels).size()<<endl;
72 for (
int ih = 0; ih < fTracker->NHits(); ih++ ) {
74 const PndCAHitLabel &l = (*fHitLabels)[hit.
ID()];
76 cout<<
" mirrored hit in array, something wrong!! "<<endl;
80 if ( l.fLab[0] >= 0 ) (*fMCTracks)[l.fLab[0]].SetNHits( (*fMCTracks)[l.fLab[0]].NHits() + 1 );
81 if ( l.fLab[1] >= 0 ) (*fMCTracks)[l.fLab[1]].SetNHits( (*fMCTracks)[l.fLab[1]].NHits() + 1 );
82 if ( l.fLab[2] >= 0 ) (*fMCTracks)[l.fLab[2]].SetNHits( (*fMCTracks)[l.fLab[2]].NHits() + 1 );
84 mcData.resize(nMCTracks);
85 for (
int imc = 0; imc < nMCTracks; imc++ ) {
110 if ( mc.
NHits() == fTracker->NStations() ) {
137 cout<<
"n reco trcks: "<<nRecoTracks<<
" "<<fTracker->NTracks()<<endl;
138 recoData.resize(nRecoTracks);
139 for (
int itr = 0; itr < nRecoTracks; itr++ ) {
141 double traPurity = 0;
144 int *lb =
new int[nhits*3];
146 for (
int ihit = 0; ihit <
nhits; ihit++ ) {
147 const int index = fTracker->TrackHit( tCA.
FirstHitRef() + ihit );
148 const PndCAHitLabel &l = (*fHitLabels)[fTracker->Hit( index ).ID()];
149 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
150 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
151 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
153 std::sort( lb, lb + nla );
154 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0;
155 for (
int i = 0;
i < nla;
i++ ) {
156 if ( lb[
i] != labcur ) {
157 if ( labcur >= 0 && lmax < lcurr ) {
166 if ( labcur >= 0 && lmax < lcurr ) {
171 for (
int ihit = 0; ihit <
nhits; ihit++ ) {
172 const int index = fTracker->TrackHit( tCA.
FirstHitRef() + ihit );
173 const PndCAHitLabel &l = (*fHitLabels)[fTracker->Hit( index ).ID()];
174 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
178 traPurity = ( ( nhits > 0 ) ?
double( lmax ) / double( nhits ) : 0 );
179 if ( lb )
delete[] lb;
181 recoData[itr].SetMCTrack(traLabels, traPurity, nhits);
189 for (
int iRTr = 0; iRTr < nRecoTracks; iRTr++ ) {
194 for (
int iMCTr = 0; iMCTr < nMCTracks; iMCTr++ ) {
201 double ratio_length = 0;
202 double ratio_fakes = 0;
205 double mc_length = (*fMCTracks)[iMCTr].NMCRows();
206 for (
unsigned int irt = 0; irt < rTIds.size(); irt++) {
208 ratio_length +=
static_cast<double>( rd.
NHits() )*rd.
GetPurity() / mc_length;
214 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"rest");
217 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"total");
220 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
223 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
226 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
227 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra_sec");
230 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra");
231 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"extra_prim");
234 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
235 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_sec");
238 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
239 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_prim");
243 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref");
244 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_prim");
245 fEff.Inc(reco, killed, ratio_length, ratio_fakes, nclones,
"ref_prim_long");
250 PndCATrackPerformanceBase::EfficiencyPerformance();
255 PndCATrackPerformanceBase::FillHistos();
259 const int NMCTracks = (*fMCTracks).size();
260 vector<int> mcTrackNRecoHits;
261 vector<int> nHitsVsRow;
262 vector<int> nMCPointsVsRow;
263 const int Multiplicity = (*fMCTracks).size();
265 mcTrackNRecoHits.resize(NMCTracks, 0);
266 nHitsVsRow.resize(fTracker->NStations());
267 nMCPointsVsRow.resize(fTracker->NStations());
268 for(
int iH=0; iH < fTracker->NHits(); iH++){
271 nHitsVsRow[hit.
IRow()]++;
273 const PndCAHitLabel &l = (*fHitLabels)[hit.
ID()];
274 if ( l.fLab[0] >= 0 ) mcTrackNRecoHits[l.fLab[0]]++;
275 if ( l.fLab[1] >= 0 ) mcTrackNRecoHits[l.fLab[1]]++;
276 if ( l.fLab[2] >= 0 ) mcTrackNRecoHits[l.fLab[2]]++;
279 for(
int i=0;
i < NMCTracks;
i++){
282 GetHisto(
"mcTrackNRecoHits")->Fill( mcTrackNRecoHits[
i] );
283 GetHisto(
"nMCPointsVsMCMom")->Fill( mcT.
P(), mcT.
NMCPoints() );
286 double mcEx = mcT.
Px();
287 double mcEy = mcT.
Py();
288 double mcEz = mcT.
Pz();
289 double mcEt =
TMath::Sqrt( mcEx * mcEx + mcEy * mcEy );
291 const double dZdS = mcEz/mcEt;
293 GetHisto(
"nHitsOverNMCPointsVsMCMom")->Fill( mcT.
P(), float(mcTrackNRecoHits[i])/float(mcT.
NMCPoints()) );
294 GetHisto(
"nHitsOverNMCPointsVsMCDzDs")->Fill( dZdS,
float(mcTrackNRecoHits[i])/
float(mcT.
NMCPoints()) );
298 for(
unsigned int i=0; i < (*fLocalMCPoints).size(); i++){
299 nMCPointsVsRow[(*fLocalMCPoints)[
i].IRow()]++;
301 for(
int i=0; i < fTracker->NStations(); i++){
302 if ( nMCPointsVsRow[i] > 0 ) {
303 GetHisto(
"nHitsOverNMCPointsVsRow")->Fill( i,
float(nHitsVsRow[i])/
float(nMCPointsVsRow[i]) );
304 GetHisto(
"nHitsOverNMCPointsVsNMCTracks")->Fill( Multiplicity,
float(nHitsVsRow[i])/
float(nMCPointsVsRow[i]) );
308 for(
int iRTr=0; iRTr < nRecoTracks; iRTr++){
314 #ifdef USE_CA_FIT // use 3 iterational fit, which ends on inner station
322 double RecoPt = 1. /
fabs(param.
QPt());
323 double RecoMom = RecoPt *
sqrt(1. + param.
DzDs()*param.
DzDs());
328 GetHisto(
"purity")->Fill( recoData[iRTr].GetPurity() );
330 GetHisto(
"ghostsLength")->Fill( recoTr.
NHits() );
331 GetHisto(
"ghostsRMom")->Fill( RecoMom );
332 GetHisto(
"ghostsMCMom")->Fill( mcTr.
P() );
333 GetHisto(
"ghostsRPt")->Fill( RecoPt );
334 GetHisto(
"ghostsMCPt")->Fill( mcTr.
Pt() );
335 GetHisto(
"ghostsLengthAndMCMom")->Fill( recoTr.
NHits(), mcTr.
P() );
336 GetHisto(
"ghostsLengthAndRMom")->Fill( recoTr.
NHits(), RecoMom );
337 GetHisto(
"ghostsChi2")->Fill( param.
GetChi2() );
338 GetHisto(
"ghostsProb")->Fill( prob );
341 GetHisto(
"recosLength")->Fill( recoTr.
NHits() );
342 GetHisto(
"recosRMom")->Fill( RecoMom );
343 GetHisto(
"recosMCMom")->Fill( mcTr.
P() );
344 GetHisto(
"recosRPt")->Fill( RecoPt );
345 GetHisto(
"recosMCPt")->Fill( mcTr.
Pt() );
346 GetHisto(
"recosLengthAndMCMom")->Fill( recoTr.
NHits() , mcTr.
P() );
347 GetHisto(
"recosLengthAndRMom")->Fill( recoTr.
NHits() , RecoMom );
348 GetHisto(
"recosChi2")->Fill( param.
GetChi2() );
349 GetHisto(
"recosProb")->Fill( prob );
351 GetHisto(
"recosRefProb")->Fill( prob );
352 if( mcTr.
P() > 0.5 ) GetHisto(
"nHitsRecoTOverNHitsMCT")->Fill(
float(recoTr.
NHits()) / mcTrackNRecoHits[recoD.
GetMCTrackId()] );
357 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
static const float ExtraThreshold
static const float MinTrackPurity
friend F32vec4 sqrt(const F32vec4 &a)
static T Sqrt(const T &x)
void SetNReconstructed(int v)
friend F32vec4 fabs(const F32vec4 &a)
const PndCATrackParam & InnerParam() const
static const float RefThreshold