2 // This macro generates a simple TTree containing
3 // all true matches collected from one event.
5 // For each match it is stored:
6 // - label ID of the track
7 // - label ID of the EMCAL cluster
8 // - momentum (3D) of the track
9 // - vertex (3D) of the track
11 // All tracks which come from kinks are excluded
12 // from this computation, and fake tracks are collected.
13 // If desired, it is possible to change these settings
14 // operating on the Bool_t variables listed below.
17 Bool_t rejectKinks = kTRUE; // switch to TRUE to include kinks in computation
18 Bool_t rejectFakes = kFALSE; // switch to TRUE to include fake tracks in computation
24 Int_t label; // GEANT label of particle
25 Int_t indexT; // index of track in ESD collection
26 Int_t indexC; // index of cluster in ESD collection
27 Double_t p[3]; // track momentum
28 Double_t v[3]; // track vertex
32 // Read AliESDs.root file and saves all true pairs of trak-cluster.
34 void SaveTrueMatchesSimple(const char *outFileName="true-matches.root")
37 // open ESD file, retrieve tree and link to branch cursor
39 TFile *srcFile = TFile::Open("AliESDs.root");
41 TTree *srcTree = (TTree*)srcFile->Get("esdTree");
44 AliESDEvent* esd = new AliESDEvent();
45 esd->ReadFromTree(srcTree);
46 Long64_t nEvents = srcTree->GetEntries();
49 // Open output file and create output tree
51 TFile *outFile = new TFile(outFileName, "RECREATE");
55 // Loop on events and store true matches
58 Int_t label, count, nTracks, firstCluster, lastCluster;
59 for (Long64_t iev = 0; iev < nEvents; iev++) {
61 srcTree->GetEntry(iev);
62 cout << "Event " << iev + 1 << " of " << nEvents << ": " << endl;
64 nTracks = esd->GetNumberOfTracks();
66 lastCluster = esd->GetNumberOfCaloClusters();
67 cout << "Tracks found : " << nTracks << endl;
68 cout << "EMC clusters found: " << lastCluster - firstCluster << endl;
70 // create new matches tree
71 TTree *outTree = new TTree(Form("tm_%d", iev), Form("True matches from event %d", iev));
72 outTree->Branch("matches", &match, "label/I:indexT/I:indexC/I:p[3]/D:v[3]/D");
74 // external loop on tracks
75 for (Int_t it = 0; it < nTracks; it++) {
76 AliESDtrack *esdTrack = esd->GetTrack(it);
77 // start check to reject kinks
80 for (Int_t i = 0; i < 3; i++) {
81 if (esdTrack->GetKinkIndex(i) > 0) isKink = kTRUE;
85 // get track GEANT label (to be checked for match)
86 label = esdTrack->GetLabel();
88 if (label < 0) continue;
91 label = TMath::Abs(label);
93 // store track data into candidate match variable
94 // anyway, it will be stored in the tree only
95 // if it matches a cluster
97 esdTrack->GetPxPyPz(match.p);
98 esdTrack->GetXYZ(match.v);
99 // internal loop on clusters
100 // a counter counts how many true matches are
101 // generated for the same track
103 for (Int_t ic = firstCluster; ic < lastCluster; ic++) {
104 AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
105 if (!cl->IsEMCAL()) continue;
106 if (cl->GetLabel() != label) continue;
107 // if the method reaches this point, we
108 // have found a match to be stored
114 // alert for multiple matches
116 cout << "Found " << count << " clusters which match track " << it << " in ESD";
117 if (count > 1) cout << " --> MULTIPLE MATCH";
120 } // end loop on tracks