2 // This macros compares the matches found by algorithm with the true matches
3 // found with the "SaveTrueMatchesSimple.C" macro.
4 // It saves 4 histogram, which contain the Pt distribution of:
6 // - all correctly found matches
7 // - all wrong (fake) found matches
9 // which will then be availabel for computing efficiency and contamination.
16 Int_t label; // GEANT label of particle
17 Int_t indexT; // index of track in ESD collection
18 Int_t indexC; // index of cluster in ESD collection
19 Double_t p[3]; // track momentum
20 Double_t v[3]; // track vertex
23 void MatchComparison()
26 // Initialize AliRun manager
34 // Initialize run loader and load Kinematics
36 AliRunLoader *runLoader = AliRunLoader::Open("galice.root");
37 if (!runLoader) return;
38 runLoader->LoadgAlice();
39 gAlice = runLoader->GetAliRun();
40 runLoader->LoadKinematics();
43 // Initialize histograms with their error computation
45 TH1D *hgood = new TH1D("hgood", "Well matched tracks", 20, 0.0, 10.0);
46 TH1D *hfake = new TH1D("hfake", "Fake matched tracks", 20, 0.0, 10.0);
47 TH1D *htrue = new TH1D("htrue", "True matches", 20, 0.0, 10.0);
48 TH1D *hfound = new TH1D("hfound", "Found matches", 20, 0.0, 10.0);
55 // Open file containing true matches,
56 // retrieve the Tree and link to a cursor.
58 TFile *fileTrue = TFile::Open("true-matches.root");
62 // Open file of found matches,
63 // link the modified ESD container.
65 TFile *fileFound = TFile::Open("matchESD.root");
66 TTree *treeFound = (TTree*)fileFound->Get("esdTree");
68 treeFound->SetBranchAddress("ESD", &esd);
69 Long64_t nEvents = treeFound->GetEntries();
74 Int_t im, it, ic, nTrueMatches, nTracks;
75 Int_t label, trkLabel, cluLabel;
76 for (Long64_t iev = 0; iev < nEvents; iev++) {
78 // get true matches tree of given event
79 TTree *treeTrue = (TTree*)fileTrue->Get(Form("tm_%d", iev));
80 treeTrue->SetBranchAddress("matches", &trueMatch);
81 nTrueMatches = treeTrue->GetEntries();
83 // set TTree pointers to selected event
84 runLoader->GetEvent(iev);
85 treeFound->GetEntry(iev);
86 AliStack *stack = runLoader->Stack();
87 nTracks = esd->GetNumberOfTracks();
89 // read all true pairs
90 for (im = 0; im < nTrueMatches; im++) {
91 treeTrue->GetEntry(im);
92 AliESDtrack *track = esd->GetTrack(trueMatch.indexT);
93 label = TMath::Abs(track->GetLabel());
94 TParticle *p = stack->Particle(label);
98 // compare found matches
99 for (Int_t it = 0; it < nTracks; it++) {
100 AliESDtrack *track = esd->GetTrack(it);
101 ic = track->GetEMCALcluster();
102 if (ic == AliEMCALTracker::kUnmatched) continue;
104 AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
106 trkLabel = TMath::Abs(track->GetLabel());
107 cluLabel = cl->GetPrimaryIndex();
108 if (trkLabel == cluLabel && trkLabel >= 0) {
109 TParticle *p = stack->Particle(TMath::Abs(trkLabel));
110 hgood->Fill(p->Pt());
111 hfound->Fill(p->Pt());
114 TParticle *p = stack->Particle(TMath::Abs(trkLabel));
115 hfake->Fill(p->Pt());
116 hfound->Fill(p->Pt());
121 cout << "True matches : " << htrue->GetEntries() << endl;
122 cout << "Found matches: " << hfound->GetEntries() << endl;
123 cout << "Good matches : " << hgood->GetEntries() << endl;
124 cout << "Fake matches : " << hfake->GetEntries() << endl;
126 TFile *fout = TFile::Open("match-comparison.root", "RECREATE");