1 #if !defined(__CINT__) || defined(__MAKECINT__)
8 #include <TClonesArray.h>
9 #include <TLorentzVector.h>
13 #include "AliESDEvent.h"
14 #include "AliESDMuonTrack.h"
15 #include "AliCDBManager.h"
18 #include "AliMUONCDB.h"
19 #include "AliMUONTrack.h"
20 #include "AliMUONVTrackStore.h"
21 #include "AliMUONTrackParam.h"
22 #include "AliMUONRecoCheck.h"
23 #include "AliMUONVCluster.h"
24 #include "AliMUONRecoParam.h"
28 /// \file DIMUONFakes.C
30 /// \author Ph. Pillot, Subatech, March. 2009
32 /// Macro to study the effects of fake tracks on the dimuon spectra
33 /// Results are saved in the root file DiFakes.root
34 /// Results are relevent provided that you use the same recoParams as for the reconstruction
36 Double_t sigmaCut = -1.;
38 //-----------------------------------------------------------------------
39 void DIMUONFakes(Bool_t useLabel = kFALSE, Int_t FirstEvent = 0, Int_t LastEvent = -1,
40 const TString esdFileName = "AliESDs.root", const TString SimDir = "./generated/",
41 const TString ocdbPath = "local://$ALICE_ROOT/OCDB")
44 //Reset ROOT and connect tree file
47 // File for histograms and histogram booking
48 TFile *histoFile = new TFile("DiFakes.root", "RECREATE");
50 TH1F *hMass = new TH1F("hMass", "Dimuon mass distribution (GeV/c^{2})", 100, 0., 12.);
51 TH1F *hMassM = new TH1F("hMassM", "matched track mass distribution (GeV/c^{2})", 100, 0., 12.);
52 TH1F *hMassF = new TH1F("hMassF", "fake track mass distribution (GeV/c^{2})", 100, 0., 12.);
53 TH1F *hP = new TH1F("hP", "Dimuon P distribution (GeV/c)", 100, 0., 200.);
54 TH1F *hPM = new TH1F("hPM", "matched track P distribution (GeV/c)", 100, 0., 200.);
55 TH1F *hPF = new TH1F("hPF", "fake track P distribution (GeV/c)", 100, 0., 200.);
56 TH1F *hPt = new TH1F("hPt", "Dimuon Pt distribution (GeV/c)", 100, 0., 20.);
57 TH1F *hPtM = new TH1F("hPtM", "matched track Pt distribution (GeV/c)", 100, 0., 20.);
58 TH1F *hPtF = new TH1F("hPtF", "fake track Pt distribution (GeV/c)", 100, 0., 20.);
59 TH1F *hY = new TH1F("hY"," Dimuon rapidity distribution",100,-10,0);
60 TH1F *hYM = new TH1F("hYM"," matched track rapidity distribution",100,-10,0);
61 TH1F *hYF = new TH1F("hYF"," fake track rapidity distribution",100,-10,0);
62 TH1F *hEta = new TH1F("hEta"," Dimuon pseudo-rapidity distribution",100,-10,0);
63 TH1F *hEtaM = new TH1F("hEtaM"," matched track pseudo-rapidity distribution",100,-10,0);
64 TH1F *hEtaF = new TH1F("hEtaF"," fake track pseudo-rapidity distribution",100,-10,0);
65 TH1F *hPhi = new TH1F("hPhi"," Dimuon phi distribution",100,-1.,9.);
66 TH1F *hPhiM = new TH1F("hPhiM"," matched track phi distribution",100,-1.,9.);
67 TH1F *hPhiF = new TH1F("hPhiF"," fake track phi distribution",100,-1.,9.);
69 // link to reconstructed and simulated tracks
70 AliMUONRecoCheck rc(esdFileName, SimDir);
72 // load necessary data from OCDB
73 AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
74 AliCDBManager::Instance()->SetRun(rc.GetRunNumber());
75 AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
76 if (!recoParam) return;
78 // get sigma cut from recoParam to associate clusters with TrackRefs in case the label are not used
79 sigmaCut = (recoParam->ImproveTracks()) ? recoParam->GetSigmaCutForImprovement() : recoParam->GetSigmaCutForTracking();
81 TLorentzVector vMu1, vMu2, vDiMu;
83 // Loop over ESD events
84 FirstEvent = TMath::Max(0, FirstEvent);
85 LastEvent = (LastEvent>=0) ? TMath::Min(rc.NumberOfEvents() - 1, LastEvent) : rc.NumberOfEvents() - 1;
86 for (Int_t iEvent = FirstEvent; iEvent <= LastEvent; iEvent++) {
88 // get reconstructed and simulated tracks
89 AliMUONVTrackStore* muonTrackStore = rc.ReconstructedTracks(iEvent, kFALSE);
90 AliMUONVTrackStore* trackRefStore = rc.TrackRefs(iEvent);
91 if (!muonTrackStore || !trackRefStore) continue;
93 // loop over ESD tracks and flag them
94 const AliESDEvent* esd = rc.GetESDEvent();
95 Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ;
96 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
98 AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
101 if (!esdTrack->ContainTrackerData()) continue;
103 // find the corresponding MUON track
104 AliMUONTrack* muonTrack = (AliMUONTrack*) muonTrackStore->FindObject(esdTrack->GetUniqueID());
106 // try to match the reconstructed track with a simulated one
107 Int_t nMatchClusters = 0;
108 AliMUONTrack* matchedTrackRef = rc.FindCompatibleTrack(*muonTrack, *trackRefStore, nMatchClusters, useLabel, sigmaCut);
110 // take actions according to matching result
111 if (matchedTrackRef) {
113 // flag matched tracks
114 esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
116 // remove already matched trackRefs
117 trackRefStore->Remove(*matchedTrackRef);
122 esdTrack->SetLabel(-1);
128 // double loop over ESD tracks, build pairs and fill histograms according to their label
129 for (Int_t iTrack1 = 0; iTrack1 < nTracks; iTrack1++) {
130 AliESDMuonTrack* muonTrack1 = esd->GetMuonTrack(iTrack1);
133 if (!muonTrack1->ContainTrackerData()) continue;
136 Short_t charge1 = muonTrack1->Charge();
137 Int_t label1 = muonTrack1->GetLabel();
138 muonTrack1->LorentzP(vMu1);
140 for (Int_t iTrack2 = iTrack1+1; iTrack2 < nTracks; iTrack2++) {
141 AliESDMuonTrack* muonTrack2 = esd->GetMuonTrack(iTrack2);
144 if (!muonTrack2->ContainTrackerData()) continue;
146 // keep only opposite sign pairs
147 Short_t charge2 = muonTrack2->Charge();
148 if (charge1*charge2 > 0) continue;
151 Int_t label2 = muonTrack2->GetLabel();
152 muonTrack2->LorentzP(vMu2);
154 // compute kinematics of the pair
156 Float_t mass = vDiMu.M();
157 Float_t p = vDiMu.P();
158 Float_t pt = vDiMu.Pt();
159 Float_t y = vDiMu.Rapidity();
160 Float_t eta = vDiMu.Eta();
161 Float_t phi = vDiMu.Phi();
162 if (phi < 0) phi += 2.*TMath::Pi();
164 // fill global histograms
172 // fill histograms according to labels
173 if (label1 >= 0 && label2 >= 0) {
197 } // end of loop over events
200 TCanvas cDiFakesSummary("cDiFakesSummary","cDiFakesSummary",900,600);
201 cDiFakesSummary.Divide(3,2);
202 cDiFakesSummary.cd(1);
203 cDiFakesSummary.GetPad(1)->SetLogy();
205 hMass->SetMinimum(0.5);
206 hMassM->Draw("same");
207 hMassM->SetLineColor(4);
208 hMassF->Draw("same");
209 hMassF->SetLineColor(2);
210 hMassF->SetFillColor(2);
211 hMassF->SetFillStyle(3017);
212 cDiFakesSummary.cd(2);
213 cDiFakesSummary.GetPad(3)->SetLogy();
217 hPM->SetLineColor(4);
219 hPF->SetLineColor(2);
220 hPF->SetFillColor(2);
221 hPF->SetFillStyle(3017);
222 cDiFakesSummary.cd(3);
223 cDiFakesSummary.GetPad(4)->SetLogy();
225 hPt->SetMinimum(0.5);
227 hPtM->SetLineColor(4);
229 hPtF->SetLineColor(2);
230 hPtF->SetFillColor(2);
231 hPtF->SetFillStyle(3017);
232 cDiFakesSummary.cd(4);
233 cDiFakesSummary.GetPad(2)->SetLogy();
237 hYM->SetLineColor(4);
239 hYF->SetLineColor(2);
240 hYF->SetFillColor(2);
241 hYF->SetFillStyle(3017);
242 cDiFakesSummary.cd(5);
243 cDiFakesSummary.GetPad(5)->SetLogy();
245 hEta->SetMinimum(0.5);
247 hEtaM->SetLineColor(4);
249 hEtaF->SetLineColor(2);
250 hEtaF->SetFillColor(2);
251 hEtaF->SetFillStyle(3017);
252 cDiFakesSummary.cd(6);
253 cDiFakesSummary.GetPad(6)->SetLogy();
255 hPhi->SetMinimum(0.5);
257 hPhiM->SetLineColor(4);
259 hPhiF->SetLineColor(2);
260 hPhiF->SetFillColor(2);
261 hPhiF->SetFillStyle(3017);
266 cDiFakesSummary.Write();