]>
Commit | Line | Data |
---|---|---|
5473f16a | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | // ROOT includes | |
48d6b312 | 3 | #include "TTree.h" |
5473f16a | 4 | #include "TBranch.h" |
5 | #include "TClonesArray.h" | |
6 | #include "TLorentzVector.h" | |
7 | #include "TFile.h" | |
8 | #include "TH1.h" | |
ac3c5325 | 9 | #include "TH2.h" |
5473f16a | 10 | #include "TParticle.h" |
11 | #include "TTree.h" | |
12 | #include <Riostream.h> | |
13 | ||
14 | // STEER includes | |
15 | #include "AliRun.h" | |
16 | #include "AliRunLoader.h" | |
17 | #include "AliHeader.h" | |
18 | #include "AliLoader.h" | |
19 | #include "AliStack.h" | |
20 | #include "AliESD.h" | |
21 | ||
22 | // MUON includes | |
23 | #include "AliESDMuonTrack.h" | |
24 | #endif | |
25 | // | |
26 | // Macro MUONmassPlot.C for ESD | |
27 | // Ch. Finck, Subatech, April. 2004 | |
28 | // | |
29 | ||
30 | // macro to make invariant mass plots | |
31 | // for combinations of 2 muons with opposite charges, | |
32 | // from root file "MUON.tracks.root" containing the result of track reconstruction. | |
33 | // Histograms are stored on the "MUONmassPlot.root" file. | |
34 | // introducing TLorentzVector for parameter calculations (Pt, P,rap,etc...) | |
35 | // using Invariant Mass for rapidity. | |
36 | ||
37 | // Arguments: | |
38 | // FirstEvent (default 0) | |
39 | // LastEvent (default 0) | |
40 | // ResType (default 553) | |
41 | // 553 for Upsilon, anything else for J/Psi | |
42 | // Chi2Cut (default 100) | |
43 | // to keep only tracks with chi2 per d.o.f. < Chi2Cut | |
44 | // PtCutMin (default 1) | |
45 | // to keep only tracks with transverse momentum > PtCutMin | |
46 | // PtCutMax (default 10000) | |
47 | // to keep only tracks with transverse momentum < PtCutMax | |
48 | // massMin (default 9.17 for Upsilon) | |
49 | // & massMax (default 9.77 for Upsilon) | |
50 | // to calculate the reconstruction efficiency for resonances with invariant mass | |
51 | // massMin < mass < massMax. | |
52 | ||
53 | // Add parameters and histograms for analysis | |
54 | ||
55 | Bool_t MUONmassPlot(char* filename = "galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 10000, | |
56 | char* esdFileName = "AliESDs.root", Int_t ResType = 553, | |
57 | Float_t Chi2Cut = 100., Float_t PtCutMin = 1., Float_t PtCutMax = 10000., | |
58 | Float_t massMin = 9.17,Float_t massMax = 9.77) | |
59 | { | |
60 | cout << "MUONmassPlot " << endl; | |
61 | cout << "FirstEvent " << FirstEvent << endl; | |
62 | cout << "LastEvent " << LastEvent << endl; | |
63 | cout << "ResType " << ResType << endl; | |
64 | cout << "Chi2Cut " << Chi2Cut << endl; | |
65 | cout << "PtCutMin " << PtCutMin << endl; | |
66 | cout << "PtCutMax " << PtCutMax << endl; | |
67 | cout << "massMin " << massMin << endl; | |
68 | cout << "massMax " << massMax << endl; | |
69 | ||
70 | ||
71 | //Reset ROOT and connect tree file | |
72 | gROOT->Reset(); | |
73 | ||
74 | ||
75 | // File for histograms and histogram booking | |
76 | TFile *histoFile = new TFile("MUONmassPlot.root", "RECREATE"); | |
77 | TH1F *hPtMuon = new TH1F("hPtMuon", "Muon Pt (GeV/c)", 100, 0., 20.); | |
ac3c5325 | 78 | TH1F *hPtMuonPlus = new TH1F("hPtMuonPlus", "Muon+ Pt (GeV/c)", 100, 0., 20.); |
79 | TH1F *hPtMuonMinus = new TH1F("hPtMuonMinus", "Muon- Pt (GeV/c)", 100, 0., 20.); | |
5473f16a | 80 | TH1F *hPMuon = new TH1F("hPMuon", "Muon P (GeV/c)", 100, 0., 200.); |
81 | TH1F *hChi2PerDof = new TH1F("hChi2PerDof", "Muon track chi2/d.o.f.", 100, 0., 20.); | |
82 | TH1F *hInvMassAll = new TH1F("hInvMassAll", "Mu+Mu- invariant mass (GeV/c2)", 480, 0., 12.); | |
ac3c5325 | 83 | TH1F *hInvMassBg = new TH1F("hInvMassBg", "Mu+Mu- invariant mass BG(GeV/c2)", 480, 0., 12.); |
84 | TH2F *hInvMassAll_vs_Pt = new TH2F("hInvMassAll_vs_Pt","hInvMassAll_vs_Pt",480,0.,12.,80,0.,20.); | |
85 | TH2F *hInvMassBgk_vs_Pt = new TH2F("hInvMassBgk_vs_Pt","hInvMassBgk_vs_Pt",480,0.,12.,80,0.,20.); | |
86 | TH1F *hInvMassRes; | |
5473f16a | 87 | |
88 | if (ResType == 553) { | |
89 | hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around Upsilon", 60, 8., 11.); | |
90 | } else { | |
91 | hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around J/Psi", 80, 0., 5.); | |
92 | } | |
93 | ||
94 | TH1F *hNumberOfTrack = new TH1F("hNumberOfTrack","nb of track /evt ",20,-0.5,19.5); | |
95 | TH1F *hRapMuon = new TH1F("hRapMuon"," Muon Rapidity",50,-4.5,-2); | |
96 | TH1F *hRapResonance = new TH1F("hRapResonance"," Resonance Rapidity",50,-4.5,-2); | |
97 | TH1F *hPtResonance = new TH1F("hPtResonance", "Resonance Pt (GeV/c)", 100, 0., 20.); | |
ac3c5325 | 98 | TH2F *hThetaPhiPlus = new TH2F("hThetaPhiPlus", "Theta vs Phi +", 760, -190., 190., 400, 160., 180.); |
99 | TH2F *hThetaPhiMinus = new TH2F("hThetaPhiMinus", "Theta vs Phi -", 760, -190., 190., 400, 160., 180.); | |
5473f16a | 100 | |
101 | ||
102 | // settings | |
103 | Int_t EventInMass = 0; | |
104 | Float_t muonMass = 0.105658389; | |
105 | // Float_t UpsilonMass = 9.46037; | |
106 | // Float_t JPsiMass = 3.097; | |
107 | ||
108 | Double_t thetaX, thetaY, pYZ; | |
109 | Double_t fPxRec1, fPyRec1, fPzRec1, fE1; | |
110 | Double_t fPxRec2, fPyRec2, fPzRec2, fE2; | |
111 | Int_t fCharge, fCharge2; | |
112 | ||
113 | Int_t ntrackhits, nevents; | |
114 | Double_t fitfmin; | |
115 | ||
116 | ||
117 | TLorentzVector fV1, fV2, fVtot; | |
118 | ||
119 | // open run loader and load gAlice, kinematics and header | |
120 | AliRunLoader* runLoader = AliRunLoader::Open(filename); | |
121 | if (!runLoader) { | |
122 | Error("MUONmass_ESD", "getting run loader from file %s failed", | |
123 | filename); | |
124 | return kFALSE; | |
125 | } | |
126 | ||
127 | runLoader->LoadgAlice(); | |
128 | gAlice = runLoader->GetAliRun(); | |
129 | if (!gAlice) { | |
130 | Error("MUONmass_ESD", "no galice object found"); | |
131 | return kFALSE; | |
132 | } | |
133 | ||
134 | ||
135 | // open the ESD file | |
136 | TFile* esdFile = TFile::Open(esdFileName); | |
137 | if (!esdFile || !esdFile->IsOpen()) { | |
138 | Error("MUONmass_ESD", "opening ESD file %s failed", esdFileName); | |
139 | return kFALSE; | |
140 | } | |
141 | ||
48d6b312 | 142 | AliESD* esd = new AliESD(); |
143 | TTree* tree = (TTree*) esdFile->Get("esdTree"); | |
144 | if (!tree) { | |
145 | Error("CheckESD", "no ESD tree found"); | |
146 | return kFALSE; | |
147 | } | |
148 | tree->SetBranchAddress("ESD", &esd); | |
149 | ||
5473f16a | 150 | runLoader->LoadHeader(); |
151 | nevents = runLoader->GetNumberOfEvents(); | |
152 | ||
153 | // Loop over events | |
154 | for (Int_t iEvent = FirstEvent; iEvent <= TMath::Min(LastEvent, nevents - 1); iEvent++) { | |
155 | ||
156 | // get current event | |
157 | runLoader->GetEvent(iEvent); | |
48d6b312 | 158 | |
5473f16a | 159 | // get the event summary data |
48d6b312 | 160 | tree->GetEvent(iEvent); |
5473f16a | 161 | if (!esd) { |
48d6b312 | 162 | Error("CheckESD", "no ESD object found for event %d", iEvent); |
5473f16a | 163 | return kFALSE; |
164 | } | |
165 | ||
48d6b312 | 166 | Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ; |
5473f16a | 167 | |
168 | // printf("\n Nb of events analysed: %d\r",iEvent); | |
48d6b312 | 169 | // cout << " number of tracks: " << nTracks <<endl; |
5473f16a | 170 | |
171 | // loop over all reconstructed tracks (also first track of combination) | |
172 | for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) { | |
173 | ||
174 | AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack); | |
175 | ||
176 | thetaX = muonTrack->GetThetaX(); | |
177 | thetaY = muonTrack->GetThetaY(); | |
178 | ||
179 | pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum()); | |
180 | fPzRec1 = - pYZ / TMath::Sqrt(1.0 + TMath::Tan(thetaY)*TMath::Tan(thetaX)); | |
181 | fPxRec1 = fPzRec1 * TMath::Tan(thetaX); | |
182 | fPyRec1 = fPzRec1 * TMath::Tan(thetaY); | |
183 | fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum())); | |
184 | ||
185 | fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1); | |
186 | fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1); | |
187 | ||
188 | ntrackhits = muonTrack->GetNHit(); | |
189 | fitfmin = muonTrack->GetChi2(); | |
190 | ||
191 | // transverse momentum | |
192 | Float_t pt1 = fV1.Pt(); | |
193 | ||
194 | // total momentum | |
195 | Float_t p1 = fV1.P(); | |
196 | ||
197 | // Rapidity | |
198 | Float_t rapMuon1 = fV1.Rapidity(); | |
199 | ||
200 | // chi2 per d.o.f. | |
201 | Float_t ch1 = fitfmin / (2.0 * ntrackhits - 5); | |
202 | // printf(" px %f py %f pz %f NHits %d Norm.chi2 %f charge %d\n", | |
203 | // fPxRec1, fPyRec1, fPzRec1, ntrackhits, ch1, fCharge); | |
204 | ||
205 | // condition for good track (Chi2Cut and PtCut) | |
206 | ||
207 | if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) { | |
208 | ||
209 | // fill histos hPtMuon and hChi2PerDof | |
210 | hPtMuon->Fill(pt1); | |
211 | hPMuon->Fill(p1); | |
212 | hChi2PerDof->Fill(ch1); | |
213 | hRapMuon->Fill(rapMuon1); | |
ac3c5325 | 214 | if (fCharge > 0) { |
215 | hPtMuonPlus->Fill(pt1); | |
216 | hThetaPhiPlus->Fill(TMath::ATan2(fPyRec1,fPxRec1)*180./TMath::Pi(),TMath::ATan2(pt1,fPzRec1)*180./3.1415); | |
217 | } else { | |
218 | hPtMuonMinus->Fill(pt1); | |
219 | hThetaPhiMinus->Fill(TMath::ATan2(fPyRec1,fPxRec1)*180./TMath::Pi(),TMath::ATan2(pt1,fPzRec1)*180./3.1415); | |
220 | } | |
5473f16a | 221 | // loop over second track of combination |
222 | for (Int_t iTrack2 = iTrack + 1; iTrack2 < nTracks; iTrack2++) { | |
223 | ||
224 | AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack2); | |
225 | ||
226 | thetaX = muonTrack->GetThetaX(); | |
227 | thetaY = muonTrack->GetThetaY(); | |
228 | ||
229 | pYZ = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum()); | |
230 | fPzRec2 = - pYZ / TMath::Sqrt(1.0 + TMath::Tan(thetaY)*TMath::Tan(thetaX)); | |
231 | fPxRec2 = fPzRec2 * TMath::Tan(thetaX); | |
232 | fPyRec2 = fPzRec2 * TMath::Tan(thetaY); | |
233 | fCharge2 = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum())); | |
234 | ||
235 | fE2 = TMath::Sqrt(muonMass * muonMass + fPxRec2 * fPxRec2 + fPyRec2 * fPyRec2 + fPzRec2 * fPzRec2); | |
236 | fV2.SetPxPyPzE(fPxRec2, fPyRec2, fPzRec2, fE2); | |
237 | ||
238 | ntrackhits = muonTrack->GetNHit(); | |
239 | fitfmin = muonTrack->GetChi2(); | |
240 | ||
241 | // transverse momentum | |
242 | Float_t pt2 = fV2.Pt(); | |
243 | ||
244 | // chi2 per d.o.f. | |
245 | Float_t ch2 = fitfmin / (2.0 * ntrackhits - 5); | |
246 | ||
247 | // condition for good track (Chi2Cut and PtCut) | |
248 | if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) { | |
249 | ||
250 | // condition for opposite charges | |
251 | if ((fCharge * fCharge2) == -1) { | |
252 | ||
253 | // invariant mass | |
254 | fVtot = fV1 + fV2; | |
255 | Float_t invMass = fVtot.M(); | |
256 | ||
257 | // fill histos hInvMassAll and hInvMassRes | |
258 | hInvMassAll->Fill(invMass); | |
259 | hInvMassRes->Fill(invMass); | |
ac3c5325 | 260 | hInvMassAll_vs_Pt->Fill(invMass,fVtot.Pt()); |
5473f16a | 261 | if (invMass > massMin && invMass < massMax) { |
262 | EventInMass++; | |
263 | hRapResonance->Fill(fVtot.Rapidity()); | |
264 | hPtResonance->Fill(fVtot.Pt()); | |
265 | } | |
266 | ||
267 | } // if (fCharge * fCharge2) == -1) | |
268 | } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) | |
269 | } // for (Int_t iTrack2 = iTrack + 1; iTrack2 < iTrack; iTrack2++) | |
270 | } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) ) | |
271 | } // for (Int_t iTrack = 0; iTrack < nrectracks; iTrack++) | |
272 | ||
273 | hNumberOfTrack->Fill(nTracks); | |
48d6b312 | 274 | // esdFile->Delete(); |
5473f16a | 275 | } // for (Int_t iEvent = FirstEvent; |
276 | ||
ac3c5325 | 277 | // Loop over events for bg event |
278 | ||
279 | Double_t thetaPlus, phiPlus; | |
280 | Double_t thetaMinus, phiMinus; | |
281 | Float_t PtMinus, PtPlus; | |
282 | ||
283 | for (Int_t iEvent = 0; iEvent < hInvMassAll->Integral(); iEvent++) { | |
284 | ||
285 | hThetaPhiPlus->GetRandom2(phiPlus, thetaPlus); | |
286 | hThetaPhiMinus->GetRandom2(phiMinus,thetaMinus); | |
287 | PtPlus = hPtMuonPlus->GetRandom(); | |
288 | PtMinus = hPtMuonMinus->GetRandom(); | |
289 | ||
290 | fPxRec1 = PtPlus * TMath::Cos(TMath::Pi()/180.*phiPlus); | |
291 | fPyRec1 = PtPlus * TMath::Sin(TMath::Pi()/180.*phiPlus); | |
292 | fPzRec1 = PtPlus / TMath::Tan(TMath::Pi()/180.*thetaPlus); | |
293 | ||
294 | fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1); | |
295 | fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1); | |
296 | ||
297 | fPxRec2 = PtMinus * TMath::Cos(TMath::Pi()/180.*phiMinus); | |
298 | fPyRec2 = PtMinus * TMath::Sin(TMath::Pi()/180.*phiMinus); | |
299 | fPzRec2 = PtMinus / TMath::Tan(TMath::Pi()/180.*thetaMinus); | |
300 | ||
301 | fE2 = TMath::Sqrt(muonMass * muonMass + fPxRec2 * fPxRec2 + fPyRec2 * fPyRec2 + fPzRec2 * fPzRec2); | |
302 | fV2.SetPxPyPzE(fPxRec2, fPyRec2, fPzRec2, fE2); | |
303 | ||
304 | // invariant mass | |
305 | fVtot = fV1 + fV2; | |
306 | ||
307 | // fill histos hInvMassAll and hInvMassRes | |
308 | hInvMassBg->Fill(fVtot.M()); | |
309 | hInvMassBgk_vs_Pt->Fill( fVtot.M(), fVtot.Pt() ); | |
310 | } | |
311 | ||
5473f16a | 312 | histoFile->Write(); |
313 | histoFile->Close(); | |
314 | ||
315 | cout << "MUONmassPlot " << endl; | |
316 | cout << "FirstEvent " << FirstEvent << endl; | |
317 | cout << "LastEvent " << LastEvent << endl; | |
318 | cout << "ResType " << ResType << endl; | |
319 | cout << "Chi2Cut " << Chi2Cut << endl; | |
320 | cout << "PtCutMin " << PtCutMin << endl; | |
321 | cout << "PtCutMax " << PtCutMax << endl; | |
322 | cout << "massMin " << massMin << endl; | |
323 | cout << "massMax " << massMax << endl; | |
324 | cout << "EventInMass " << EventInMass << endl; | |
325 | ||
326 | return kTRUE; | |
327 | } | |
328 |