7 #include "../mc/CbmLitMCTrackCreator.h"
24 #include "TClonesArray.h"
29 #include <boost/assign/list_of.hpp>
36 : fIsFixedBounds(true)
41 , fOutputDir(
"./test/")
48 , fStsTrackMatches(NULL)
52 , fTrdTrackMatches(NULL)
55 , fMuchTrackMatches(NULL)
56 , fMuchPixelHits(NULL)
57 , fMuchStripHits(NULL)
63 , fMCTrackCreator(NULL)
81 static Int_t nofEvents = 0;
83 std::cout <<
"CbmLitFitQa::Exec: event=" << nofEvents << std::endl;
91 TDirectory* oldir = gDirectory;
92 TFile* outFile = FairRootManager::Instance()->GetOutFile();
93 if (outFile != NULL) {
97 gDirectory->cd(oldir->GetPath());
106 FairRootManager* ioman = FairRootManager::Instance();
107 assert(ioman != NULL);
109 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
110 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
112 fStsHits = (TClonesArray*) ioman->GetObject(
"StsHit");
113 fMvdHits = (TClonesArray*) ioman->GetObject(
"MvdHit");
114 fMuchTracks = (TClonesArray*) ioman->GetObject(
"MuchTrack");
116 fMuchPixelHits = (TClonesArray*) ioman->GetObject(
"MuchPixelHit");
117 fMuchStripHits = (TClonesArray*) ioman->GetObject(
"MuchStripHit");
118 fTrdTracks = (TClonesArray*) ioman->GetObject(
"TrdTrack");
120 fTrdHits = (TClonesArray*) ioman->GetObject(
"TrdHit");
127 <<
"CbmMatchRecoToMC::ReadAndCreateDataBranches() NULL MCDataManager.";
130 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"Event"));
146 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
163 if (mcId < 0)
return;
171 if (nofStsHits < 1)
return;
178 const FairTrackParam* lastParam = track->
GetParamLast();
184 if (nofMvdHits > 0) {
193 "htf_Sts_FirstParam_",
194 nofMvdHits + nofStsHits,
208 "htf_Sts_FirstParam_",
209 nofMvdHits + nofStsHits,
225 "htf_Sts_LastParam_",
226 nofMvdHits + nofStsHits,
238 if (mcId < 0)
return;
245 if (nofHits < 1)
return;
251 const FairTrackParam* lastParam = track->
GetParamLast();
266 "htf_Trd_FirstParam_",
291 if (mcId < 0)
return;
298 if (nofHits < 1)
return;
304 const FairTrackParam* lastParam = track->
GetParamLast();
322 "htf_Much_FirstParam_",
340 "htf_Much_LastParam_",
348 const string& histName,
352 Double_t resX = 0., resY = 0., resTx = 0., resTy = 0., resQp = 0.;
354 resX = par->GetX() - mcPoint->
GetX();
355 resY = par->GetY() - mcPoint->
GetY();
356 resTx = par->GetTx() - mcPoint->
GetTx();
357 resTy = par->GetTy() - mcPoint->
GetTy();
358 resQp = par->GetQp() - mcPoint->
GetQp();
360 resX = par->GetX() - mcPoint->
GetX();
361 resY = par->GetY() - mcPoint->
GetY();
362 resTx = par->GetTx() - mcPoint->
GetTx();
363 resTy = par->GetTy() - mcPoint->
GetTy();
364 resQp = par->GetQp() - mcPoint->
GetQp();
366 resX = par->GetX() - mcPoint->
GetXOut();
367 resY = par->GetY() - mcPoint->
GetYOut();
368 resTx = par->GetTx() - mcPoint->
GetTxOut();
369 resTy = par->GetTy() - mcPoint->
GetTyOut();
370 resQp = par->GetQp() - mcPoint->
GetQpOut();
372 resX = par->GetX() - mcPoint->
GetX();
373 resY = par->GetY() - mcPoint->
GetY();
374 resTx = par->GetTx() - mcPoint->
GetTx();
375 resTy = par->GetTy() - mcPoint->
GetTy();
376 resQp = par->GetQp() - mcPoint->
GetQp();
378 Double_t mcP = mcPoint->
GetP();
380 fHM->
H2(histName +
"Res_X")->Fill(mcP, resX);
381 fHM->
H2(histName +
"Res_Y")->Fill(mcP, resY);
382 fHM->
H2(histName +
"Res_Tx")->Fill(mcP, resTx);
383 fHM->
H2(histName +
"Res_Ty")->Fill(mcP, resTy);
384 fHM->
H2(histName +
"Res_Qp")->Fill(mcP, resQp);
390 Double_t sigmaX = (C[0] > 0.) ?
std::sqrt(C[0]) : -1.;
391 Double_t sigmaY = (C[5] > 0.) ?
std::sqrt(C[5]) : -1.;
392 Double_t sigmaTx = (C[9] > 0.) ?
std::sqrt(C[9]) : -1.;
393 Double_t sigmaTy = (C[12] > 0.) ?
std::sqrt(C[12]) : -1.;
394 Double_t sigmaQp = (C[14] > 0.) ?
std::sqrt(C[14]) : -1.;
396 fHM->
H2(histName +
"WrongCov_X")->Fill(mcP, wrongPar);
398 fHM->
H2(histName +
"Pull_X")->Fill(mcP, resX / sigmaX);
400 fHM->
H2(histName +
"WrongCov_Y")->Fill(mcP, wrongPar);
402 fHM->
H2(histName +
"Pull_Y")->Fill(mcP, resY / sigmaY);
404 fHM->
H2(histName +
"WrongCov_Tx")->Fill(mcP, wrongPar);
406 fHM->
H2(histName +
"Pull_Tx")->Fill(mcP, resTx / sigmaTx);
408 fHM->
H2(histName +
"WrongCov_Ty")->Fill(mcP, wrongPar);
410 fHM->
H2(histName +
"Pull_Ty")->Fill(mcP, resTy / sigmaTy);
412 fHM->
H2(histName +
"WrongCov_Qp")->Fill(mcP, wrongPar);
414 fHM->
H2(histName +
"Pull_Qp")->Fill(mcP, resQp / sigmaQp);
418 const FairTrackParam* par) {
419 fHM->
H1(histName +
"_X")->Fill(par->GetX());
420 fHM->
H1(histName +
"_Y")->Fill(par->GetY());
421 fHM->
H1(histName +
"_Z")->Fill(par->GetZ());
422 fHM->
H1(histName +
"_Tx")->Fill(par->GetTx());
423 fHM->
H1(histName +
"_Ty")->Fill(par->GetTy());
424 fHM->
H1(histName +
"_Qp")->Fill(par->GetQp());
425 Double_t p = (par->GetQp() != 0) ?
std::fabs(1. / par->GetQp()) : 0.;
426 fHM->
H1(histName +
"_p")->Fill(p);
429 Double_t pt =
std::sqrt(mom.X() * mom.X() + mom.Y() * mom.Y());
430 fHM->
H1(histName +
"_pt")->Fill(pt);
435 Int_t nofEvents =
fEvents->GetEntriesFast();
437 for (
int i = 0;
i < nofEvents; ++
i)
447 for (Int_t
i = 0;
i < nofTracks; ++
i) {
456 if (mcId < 0)
continue;
469 fHM->
H1(
"htf_ChiPrimary")->Fill(chiPrimary);
471 FairTrackParam vtxTrack;
474 TVector3 momMC, momRec;
476 vtxTrack.Momentum(momRec);
478 Double_t dpp = 100. * (momMC.Mag() - momRec.Mag()) / momMC.Mag();
479 fHM->
H1(
"htf_MomRes_Mom")->Fill(momMC.Mag(), dpp);
486 for (
int i = 0;
i < nofTracks; ++
i) {
499 if (mcId < 0)
continue;
513 fHM->
H1(
"htp_PrimaryVertexResidualPx")->Fill(vtxParam->
GetPx() - momMC.x());
514 fHM->
H1(
"htp_PrimaryVertexResidualPy")->Fill(vtxParam->
GetPy() - momMC.y());
515 fHM->
H1(
"htp_PrimaryVertexResidualPz")->Fill(vtxParam->
GetPz() - momMC.z());
517 fHM->
H1(
"htp_PrimaryVertexPullPx")
518 ->Fill((vtxParam->
GetPx() - momMC.x()) / vtxParam->
GetDpx());
519 fHM->
H1(
"htp_PrimaryVertexPullPy")
520 ->Fill((vtxParam->
GetPy() - momMC.y()) / vtxParam->
GetDpy());
521 fHM->
H1(
"htp_PrimaryVertexPullPz")
522 ->Fill((vtxParam->
GetPz() - momMC.z()) / vtxParam->
GetDpz());
524 fHM->
H1(
"htp_PrimaryVertexResidualTx")
525 ->Fill(vtxParam->GetTx() - mcTrack->
GetPx() / mcTrack->
GetPz());
526 fHM->
H1(
"htp_PrimaryVertexResidualTy")
527 ->Fill(vtxParam->GetTy() - mcTrack->
GetPy() / mcTrack->
GetPz());
528 fHM->
H1(
"htp_PrimaryVertexResidualQp")
529 ->Fill(vtxParam->GetQp() - 1 / mcTrack->
GetP());
532 vtxParam->CovMatrix(cov);
533 fHM->
H1(
"htp_PrimaryVertexPullTx")
534 ->Fill((vtxParam->GetTx() - mcTrack->
GetPx() / mcTrack->
GetPz())
535 / TMath::Sqrt(cov[9]));
536 fHM->
H1(
"htp_PrimaryVertexPullTy")
537 ->Fill((vtxParam->GetTy() - mcTrack->
GetPy() / mcTrack->
GetPz())
538 / TMath::Sqrt(cov[12]));
539 fHM->
H1(
"htp_PrimaryVertexPullQp")
540 ->Fill((vtxParam->GetQp() - 1 / mcTrack->
GetP()) / TMath::Sqrt(cov[14]));
555 fHM->
Add(
"htf_MomRes_Mom",
556 new TH2F(
"htf_MomRes_Mom",
557 "htf_MomRes_Mom;P [GeV/c];dP/P [%]",
566 new TH1F(
"htf_ChiPrimary",
"htf_ChiPrimary;#chi_{primary}", 100, 0, 10));
567 fHM->
Add(
"htp_PrimaryVertexResidualPx",
568 new TH1F(
"htp_PrimaryVertexResidualPx",
569 "htp_PrimaryVertexResidualPx;[cm]",
573 fHM->
Add(
"htp_PrimaryVertexResidualPy",
574 new TH1F(
"htp_PrimaryVertexResidualPy",
575 "htp_PrimaryVertexResidualPy;[cm]",
579 fHM->
Add(
"htp_PrimaryVertexResidualPz",
580 new TH1F(
"htp_PrimaryVertexResidualPz",
581 "htp_PrimaryVertexResidualPz;[cm]",
586 "htp_PrimaryVertexPullPx",
588 "htp_PrimaryVertexPullPx",
"htp_PrimaryVertexPullPx;[cm]", 200, -5., 5.));
590 "htp_PrimaryVertexPullPy",
592 "htp_PrimaryVertexPullPy",
"htp_PrimaryVertexPullPy;[cm]", 200, -5., 5.));
594 "htp_PrimaryVertexPullPz",
596 "htp_PrimaryVertexPullPz",
"htp_PrimaryVertexPullPz;[cm]", 200, -5., 5.));
598 fHM->
Add(
"htp_PrimaryVertexResidualTx",
599 new TH1F(
"htp_PrimaryVertexResidualTx",
600 "htp_PrimaryVertexResidualTx;[cm]",
604 fHM->
Add(
"htp_PrimaryVertexResidualTy",
605 new TH1F(
"htp_PrimaryVertexResidualTy",
606 "htp_PrimaryVertexResidualTy;[cm]",
610 fHM->
Add(
"htp_PrimaryVertexResidualQp",
611 new TH1F(
"htp_PrimaryVertexResidualQ[",
612 "htp_PrimaryVertexResidualQp;[cm]",
617 "htp_PrimaryVertexPullTx",
619 "htp_PrimaryVertexPullTx",
"htp_PrimaryVertexPullTx;[cm]", 200, -5., 5.));
621 "htp_PrimaryVertexPullTy",
623 "htp_PrimaryVertexPullTy",
"htp_PrimaryVertexPullTy;[cm]", 200, -5., 5.));
625 "htp_PrimaryVertexPullQp",
627 "htp_PrimaryVertexPullQp",
"htp_PrimaryVertexPullQp;[cm]", 200, -5., 5.));
631 const string& detName) {
635 string parameterNames[] = {
"X",
"Y",
"Tx",
"Ty",
"Qp"};
638 string xTitles[] = {
"Residual X [cm]",
642 "Residual q/p [(GeV/c)^{-1}]",
655 string catNames[] = {
"Res",
"Pull",
"WrongCov"};
657 vector<Int_t> bins(15, 200);
658 vector<pair<Float_t, Float_t>> bounds;
660 vector<pair<Float_t, Float_t>> tmp =
661 boost::assign::list_of(make_pair(-1., 1.))
663 (make_pair(-.01, .01))
664 (make_pair(-.01, .01))
671 (make_pair(0., 200.))
672 (make_pair(0., 200.))
673 (make_pair(0., 200.))
674 (make_pair(0., 200.))
675 (make_pair(0., 200.));
678 bounds.assign(15, make_pair(0., 0.));
681 Double_t momentumMin = 0.;
682 Double_t momentumMax = 10.;
683 Int_t nofMomentumBins = 20;
684 string momentumAxisTitle =
"P [GeV/c]";
687 for (Int_t
i = 0;
i < 2;
i++) {
688 string trackParamName = (
i == 0) ?
"FirstParam" :
"LastParam";
690 for (Int_t iCat = 0; iCat < 3; iCat++) {
691 for (Int_t iPar = 0; iPar < 5; iPar++) {
692 string histName =
"htf_" + detName +
"_" + trackParamName +
"_"
693 + catNames[iCat] +
"_" + parameterNames[iPar];
694 Int_t histId = iCat * 5 + iPar;
696 new TH2F(histName.c_str(),
697 string(histName +
";" + momentumAxisTitle + +
";"
698 + xTitles[histId] +
";Counter")
704 bounds[histId].first,
705 bounds[histId].second));
712 const string& detName) {
716 string parameterNames[] = {
"X",
"Y",
"Z",
"Tx",
"Ty",
"Qp",
"p",
"pt"};
719 string xTitles[] = {
"X [cm]",
724 "q/p [(GeV/c)^{-1}]",
728 vector<Int_t> bins(8, 200);
729 vector<pair<Float_t, Float_t>> bounds;
731 vector<pair<Float_t, Float_t>> tmp =
732 boost::assign::list_of(make_pair(-500., 500.))
733 (make_pair(-500., 500.))
734 (make_pair(-500., 500.))
742 bounds.assign(8, make_pair(0., 0.));
746 for (Int_t
i = 0;
i < 2;
i++) {
747 string trackParamName = (
i == 0) ?
"FirstParam" :
"LastParam";
748 for (Int_t iPar = 0; iPar < 8; iPar++) {
750 "htp_" + detName +
"_" + trackParamName +
"_" + parameterNames[iPar];
753 new TH1F(histName.c_str(),
754 string(histName +
";" + xTitles[iPar] +
";Counter").c_str(),
757 bounds[iPar].second));