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_compiled(const char *outFileName)
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 srcTree->SetBranchAddress("ESD", &esd);
45 Long64_t nEvents = srcTree->GetEntries();
48 // Open output file and create output tree
50 TFile *outFile = new TFile(outFileName, "RECREATE");
54 // Loop on events and store true matches
57 Int_t label, count, nTracks, firstCluster, lastCluster;
58 for (Long64_t iev = 0; iev < nEvents; iev++) {
60 srcTree->GetEntry(iev);
61 cout << "Event " << iev + 1 << " of " << nEvents << ": " << endl;
63 nTracks = esd->GetNumberOfTracks();
64 firstCluster = esd->GetFirstEMCALCluster();
65 lastCluster = esd->GetFirstEMCALCluster() + esd->GetNumberOfEMCALClusters();
66 cout << "Tracks found : " << nTracks << endl;
67 cout << "EMC clusters found: " << lastCluster - firstCluster << endl;
69 // create new matches tree
70 TTree *outTree = new TTree(Form("tm_%d", iev), Form("True matches from event %d", iev));
71 outTree->Branch("matches", &match, "label/I:indexT/I:indexC/I:p[3]/D:v[3]/D");
73 // external loop on tracks
74 for (Int_t it = 0; it < nTracks; it++) {
75 AliESDtrack *esdTrack = esd->GetTrack(it);
76 // start check to reject kinks
79 for (Int_t i = 0; i < 3; i++) {
80 if (esdTrack->GetKinkIndex(i) > 0) isKink = kTRUE;
84 // get track GEANT label (to be checked for match)
85 label = esdTrack->GetLabel();
87 if (label < 0) continue;
90 label = TMath::Abs(label);
92 // store track data into candidate match variable
93 // anyway, it will be stored in the tree only
94 // if it matches a cluster
96 esdTrack->GetPxPyPz(match.p);
97 esdTrack->GetXYZ(match.v);
98 // internal loop on clusters
99 // a counter counts how many true matches are
100 // generated for the same track
102 for (Int_t ic = firstCluster; ic < lastCluster; ic++) {
103 AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
104 // reject pseudo-clusters & unmatched clusters
105 if (cl->GetClusterType() != AliESDCaloCluster::kClusterv1) continue;
106 if (cl->GetPrimaryIndex() != 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