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