Skip to content
Snippets Groups Projects
Commit 1f4ffd12 authored by Sergey Gorbunov's avatar Sergey Gorbunov Committed by Volker Friese
Browse files

add Sts->Tof matching efficiencies to CbmKFTrackQa task

parent 509201a1
Branches
Tags
1 merge request!1066KF: fixes in KFParticleFinder according to the new TOF geometry
......@@ -33,6 +33,7 @@
#include "TH2F.h"
#include "TMath.h"
#include "TObject.h"
#include "TProfile.h"
//c++ and std headers
#include "CbmGlobalTrack.h"
......@@ -220,7 +221,7 @@ CbmKFTrackQa::CbmKFTrackQa(const char* name, Int_t iVerbose, TString outFileName
gDirectory->mkdir("TOF");
gDirectory->cd("TOF");
{
TString histoName2D[2] = {"M2P", "M2dEdX"};
TString histoName2D[NTofHisto2D] = {"M2P", "M2dEdX"};
TString xAxisName[NTofHisto2D] = {"p [GeV/c]", "dE/dx [keV/(cm)]"};
TString yAxisName[NTofHisto2D] = {"m^{2} [GeV^{2}/c^{4}]", "m^{2} [GeV^{2}/c^{4}]"};
float xMin[NTofHisto2D] = {-15., 0.};
......@@ -230,6 +231,8 @@ CbmKFTrackQa::CbmKFTrackQa(const char* name, Int_t iVerbose, TString outFileName
float yMax[NTofHisto2D] = {14., 14.};
Int_t yBins[NTofHisto2D] = {1600, 1600};
TString profName[NTofProfiles] = {"MatchEff", "Mismatch", "No match"};
TString subdirs[14] = {"AllTracks", "e", "mu", "pi", "K", "p", "Fragments", "Mismatch", "GhostTrack",
"WrongTofPoint", "d", "t", "He3", "He4"};
......@@ -244,6 +247,11 @@ CbmKFTrackQa::CbmKFTrackQa(const char* name, Int_t iVerbose, TString outFileName
hTofHisto2D[iDir][iH]->GetYaxis()->SetTitle(yAxisName[iH]);
}
for (int iH = 0; iH < NTofProfiles; iH++) {
hTofProfiles[iDir][iH] = new TProfile(profName[iH].Data(), profName[iH].Data(), 100, 0., 15.);
hTofProfiles[iDir][iH]->GetXaxis()->SetTitle("p [GeV/c]");
}
gDirectory->cd(".."); //Tof
}
}
......@@ -276,7 +284,7 @@ InitStatus CbmKFTrackQa::Init()
}
// Get mc event list
fMcEventList = static_cast<CbmMCEventList*>(ioman->GetObject("fMcEventListBranchName"));
fMcEventList = static_cast<CbmMCEventList*>(ioman->GetObject(fMcEventListBranchName));
if (!fMcEventList) {
Warning("CbmKFTrackQa::Init", "mc event list not found!");
return kERROR;
......@@ -433,13 +441,13 @@ void CbmKFTrackQa::Exec(Option_t* /*opt*/)
if (trackMatch[iTr] > -1) pdg[iTr] = mcTracks[trackMatch[iTr]].PDG();
}
CbmKFVertex kfVertex;
CbmL1PFFitter fitter;
vector<float> vChiToPrimVtx;
vector<CbmL1PFFitter::PFFieldRegion> vField;
fitter.Fit(vRTracks, pdg);
fitter.GetChiToVertex(vRTracks, vField, vChiToPrimVtx, kfVertex, 3000000);
// CbmKFVertex kfVertex; ! the MC vertex is not at 0,0,0 any longer. !
// vector<float> vChiToPrimVtx;
// fitter.GetChiToVertex(vRTracks, vField, vChiToPrimVtx, kfVertex, 3000000);
for (unsigned int iTr = 0; iTr < vRTracks.size(); iTr++) {
if (trackMatch[iTr] < 0) continue;
......@@ -703,19 +711,75 @@ void CbmKFTrackQa::Exec(Option_t* /*opt*/)
}
}
//Check Tof quality
if (fTofHitArray && fTofHitMatchArray) {
do { // Check Tof quality.
// ( the use of "do{ .. } while(0);" let us exit the scope with the "break" operator.
// it makes the code lighter. )
if (!fTofHitArray || !fTofHitMatchArray) { break; }
Int_t tofIndex = globalTrack->GetTofHitIndex(); // for tof histo
Int_t stsIndex = globalTrack->GetStsTrackIndex();
// std::cout << "tofIndex: " << tofIndex << " stsIndex: " << stsIndex << std::endl;
if (tofIndex > -1 && stsIndex > -1) {
if (stsIndex < 0) { break; }
// check Sts -> Tof matching efficiency
bool isReconstructible = 0;
for (Int_t ih = 0; ih < fTofHitMatchArray->GetEntriesFast(); ih++) {
CbmMatch* tofHitMatch = (CbmMatch*) fTofHitMatchArray->At(ih);
CbmTofPoint* tofPoint = (CbmTofPoint*) fTofPoints->Get(tofHitMatch->GetMatchedLink());
if (!tofPoint) continue;
Int_t tofMCTrackId = tofPoint->GetTrackID();
if (tofMCTrackId == stsTrackMCIndex) {
isReconstructible = 1;
break;
}
}
if (stsTrackMCIndex < 0) { isReconstructible = 0; }
if (isReconstructible) {
bool reconstructed = 0;
bool mismatched = 0;
bool matched = 0;
if (tofIndex >= 0) {
matched = 1;
mismatched = 1;
//CbmTofHit* tofHit = (CbmTofHit*) fTofHitArray->At(tofIndex);
CbmMatch* tofHitMatch = (CbmMatch*) fTofHitMatchArray->At(tofIndex);
CbmTofPoint* tofPoint = (CbmTofPoint*) fTofPoints->Get(tofHitMatch->GetMatchedLink());
Int_t tofMCTrackId = tofPoint->GetTrackID();
if (tofMCTrackId == stsTrackMCIndex) {
reconstructed = 1;
mismatched = 0;
}
}
int iTrackCategory = GetHistoIndex(pdg[stsTrackIndex]);
hTofProfiles[0][0]->Fill(p, reconstructed);
hTofProfiles[0][1]->Fill(p, mismatched);
hTofProfiles[0][2]->Fill(p, !matched);
hTofProfiles[iTrackCategory][0]->Fill(p, reconstructed);
hTofProfiles[iTrackCategory][1]->Fill(p, mismatched);
hTofProfiles[iTrackCategory][2]->Fill(p, !matched);
}
if (tofIndex < 0) { break; }
CbmTofHit* tofHit = (CbmTofHit*) fTofHitArray->At(tofIndex);
CbmMatch* tofHitMatch = (CbmMatch*) fTofHitMatchArray->At(tofIndex);
CbmTrackMatchNew* stsMatch = (CbmTrackMatchNew*) fStsTrackMatchArray->At(stsIndex);
CbmLink tofLink = tofHitMatch->GetMatchedLink();
if (tofLink.GetFile() >= 0 && tofLink.GetEntry() >= 0) { // the mc link is needed for the event time
// a valid mc link is needed to get the event time
if (tofLink.GetFile() < 0 || tofLink.GetEntry() < 0) { break; }
double eventTime = fMcEventList->GetEventTime(tofLink);
......@@ -730,7 +794,8 @@ void CbmKFTrackQa::Exec(Option_t* /*opt*/)
hTofHisto2D[0][0]->Fill(p * q, m2);
hTofHisto2D[0][1]->Fill(eloss * 1e6, m2);
if (tofHit && tofHitMatch && stsMatch) {
if (!tofHit || !tofHitMatch || !stsMatch) { break; }
CbmTofPoint* tofPoint = (CbmTofPoint*) fTofPoints->Get(tofLink);
Int_t tofMCTrackId = tofPoint->GetTrackID();
// Double_t tofMCTime = tofPoint->GetTime();
......@@ -752,10 +817,8 @@ void CbmKFTrackQa::Exec(Option_t* /*opt*/)
hTofHisto2D[iHitCategory][0]->Fill(p * q, m2);
hTofHisto2D[iHitCategory][1]->Fill(eloss * 1e6, m2);
}
}
}
}
} while (0); // Tof quality
}
}
}
......
......@@ -22,6 +22,7 @@ class TFile;
class TDirectory;
class TH1F;
class TH2F;
class TProfile;
class TObject;
class CbmMCDataArray;
class CbmMCEventList;
......@@ -125,6 +126,10 @@ private:
[14]
[NTofHisto2D]; //All tracks, electrons, muons, pions, kaons, protons, fragments, mismatch, ghost hit, ghost tof hit, d, t, He3, He4
static const int NTofProfiles = 3;
TProfile* hTofProfiles
[14]
[NTofProfiles]; //All tracks, electrons, muons, pions, kaons, protons, fragments, mismatch, ghost hit, ghost tof hit, d, t, He3, He4
ClassDef(CbmKFTrackQa, 1);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment