]>
Commit | Line | Data |
---|---|---|
61adb9bd | 1 | // ROOT includes |
2 | #include "TBranch.h" | |
3 | #include "TClonesArray.h" | |
4 | #include "TLorentzVector.h" | |
5 | #include "TFile.h" | |
6 | #include "TH1.h" | |
7 | #include "TParticle.h" | |
8 | #include "TTree.h" | |
9 | ||
10 | // STEER includes | |
11 | #include "AliRun.h" | |
12 | #include "AliRunLoader.h" | |
13 | #include "AliHeader.h" | |
14 | #include "AliLoader.h" | |
15 | #include "AliStack.h" | |
16 | ||
17 | // MUON includes | |
18 | #include "AliMUON.h" | |
19 | #include "AliMUONData.h" | |
20 | #include "AliMUONHit.h" | |
21 | #include "AliMUONConstants.h" | |
22 | #include "AliMUONDigit.h" | |
23 | #include "AliMUONRawCluster.h" | |
24 | #include "AliMUONGlobalTrigger.h" | |
25 | #include "AliMUONLocalTrigger.h" | |
26 | #include "AliMUONTrack.h" | |
27 | #include "AliMUONTrackParam.h" | |
28 | #include "AliESDMuonTrack.h" | |
29 | ||
30 | // | |
31 | // Macro MUONmassPlot.C for new I/O | |
32 | // Ch. Finck, Subatech, Jan. 2004 | |
33 | // | |
34 | ||
35 | // macro to make invariant mass plots | |
36 | // for combinations of 2 muons with opposite charges, | |
37 | // from root file "MUON.tracks.root" containing the result of track reconstruction. | |
38 | // Histograms are stored on the "MUONmassPlot.root" file. | |
39 | // introducing TLorentzVector for parameter calculations (Pt, P,rap,etc...) | |
40 | // using Invariant Mass for rapidity. | |
41 | ||
42 | // Arguments: | |
43 | // FirstEvent (default 0) | |
44 | // LastEvent (default 0) | |
45 | // ResType (default 553) | |
46 | // 553 for Upsilon, anything else for J/Psi | |
47 | // Chi2Cut (default 100) | |
48 | // to keep only tracks with chi2 per d.o.f. < Chi2Cut | |
49 | // PtCutMin (default 1) | |
50 | // to keep only tracks with transverse momentum > PtCutMin | |
51 | // PtCutMax (default 10000) | |
52 | // to keep only tracks with transverse momentum < PtCutMax | |
53 | // massMin (default 9.17 for Upsilon) | |
54 | // & massMax (default 9.77 for Upsilon) | |
55 | // to calculate the reconstruction efficiency for resonances with invariant mass | |
56 | // massMin < mass < massMax. | |
57 | ||
58 | // Add parameters and histograms for analysis | |
59 | ||
60 | void MUONmassPlot(char* filename="galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 0, Int_t ResType = 553, | |
61 | Float_t Chi2Cut = 100., Float_t PtCutMin = 1., Float_t PtCutMax = 10000., | |
62 | Float_t massMin = 9.17,Float_t massMax = 9.77) | |
63 | { | |
64 | cout << "MUONmassPlot " << endl; | |
65 | cout << "FirstEvent " << FirstEvent << endl; | |
66 | cout << "LastEvent " << LastEvent << endl; | |
67 | cout << "ResType " << ResType << endl; | |
68 | cout << "Chi2Cut " << Chi2Cut << endl; | |
69 | cout << "PtCutMin " << PtCutMin << endl; | |
70 | cout << "PtCutMax " << PtCutMax << endl; | |
71 | cout << "massMin " << massMin << endl; | |
72 | cout << "massMax " << massMax << endl; | |
73 | ||
74 | ||
75 | //Reset ROOT and connect tree file | |
76 | gROOT->Reset(); | |
77 | ||
78 | ||
79 | // File for histograms and histogram booking | |
80 | TFile *histoFile = new TFile("MUONmassPlot.root", "RECREATE"); | |
81 | TH1F *hPtMuon = new TH1F("hPtMuon", "Muon Pt (GeV/c)", 100, 0., 20.); | |
82 | TH1F *hPMuon = new TH1F("hPMuon", "Muon P (GeV/c)", 100, 0., 200.); | |
83 | TH1F *hChi2PerDof = new TH1F("hChi2PerDof", "Muon track chi2/d.o.f.", 100, 0., 20.); | |
84 | TH1F *hInvMassAll = new TH1F("hInvMassAll", "Mu+Mu- invariant mass (GeV/c2)", 480, 0., 12.); | |
85 | TH1F *hInvMassRes; | |
86 | ||
87 | if (ResType == 553) { | |
88 | hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around Upsilon", 60, 8., 11.); | |
89 | } else { | |
90 | hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around J/Psi", 80, 0., 5.); | |
91 | } | |
92 | ||
93 | TH1F *hNumberOfTrack = new TH1F("hNumberOfTrack","nb of track /evt ",20,-0.5,19.5); | |
94 | TH1F *hRapMuon = new TH1F("hRapMuon"," Muon Rapidity",50,-4.5,-2); | |
95 | TH1F *hRapResonance = new TH1F("hRapResonance"," Resonance Rapidity",50,-4.5,-2); | |
96 | TH1F *hPtResonance = new TH1F("hPtResonance", "Resonance Pt (GeV/c)", 100, 0., 20.); | |
97 | ||
98 | ||
99 | // settings | |
100 | Int_t EventInMass = 0; | |
101 | Float_t muonMass = 0.105658389; | |
102 | // Float_t UpsilonMass = 9.46037; | |
103 | // Float_t JPsiMass = 3.097; | |
104 | ||
105 | Double_t bendingSlope, nonBendingSlope, pYZ; | |
106 | Double_t fPxRec1, fPyRec1, fPzRec1, fZRec1, fE1; | |
107 | Double_t fPxRec2, fPyRec2, fPzRec2, fZRec2, fE2; | |
108 | Int_t fCharge, fCharge2; | |
109 | ||
110 | Int_t ntrackhits, nevents; | |
111 | Double_t fitfmin; | |
112 | ||
113 | TClonesArray * recTracksArray; | |
114 | TLorentzVector fV1, fV2, fVtot; | |
115 | ||
116 | // Creating Run Loader and openning file containing Hits | |
117 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); | |
118 | if (RunLoader == 0x0) { | |
119 | printf(">>> Error : Error Opening %s file \n",filename); | |
120 | return; | |
121 | } | |
122 | ||
123 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); | |
124 | MUONLoader->LoadTracks("READ"); | |
125 | ||
126 | // Creating MUON data container | |
127 | AliMUONData muondata(MUONLoader,"MUON","MUON"); | |
128 | ||
129 | nevents = RunLoader->GetNumberOfEvents(); | |
130 | ||
131 | AliMUONTrack * rectrack; | |
132 | AliMUONTrackParam *trackParam; | |
133 | ||
134 | // Loop over events | |
135 | for (Int_t ievent = FirstEvent; ievent <= TMath::Min(LastEvent, nevents - 1); ievent++) { | |
136 | ||
137 | // get current event | |
138 | RunLoader->GetEvent(ievent); | |
139 | ||
140 | muondata.SetTreeAddress("RT"); | |
141 | muondata.GetRecTracks(); | |
142 | recTracksArray = muondata.RecTracks(); | |
143 | ||
144 | Int_t nrectracks = (Int_t) recTracksArray->GetEntriesFast(); // | |
145 | ||
146 | printf("\n Nb of events analysed: %d\r",ievent); | |
147 | // cout << " number of tracks: " << nrectracks <<endl; | |
148 | ||
149 | // loop over all reconstructed tracks (also first track of combination) | |
150 | for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++) { | |
151 | ||
152 | rectrack = (AliMUONTrack*) recTracksArray->At(irectracks); | |
153 | ||
154 | trackParam = rectrack->GetTrackParamAtVertex(); | |
155 | bendingSlope = trackParam->GetBendingSlope(); | |
156 | nonBendingSlope = trackParam->GetNonBendingSlope(); | |
157 | ||
158 | pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum()); | |
159 | fPzRec1 = - pYZ / TMath::Sqrt(1.0 + bendingSlope * bendingSlope); // spectro. (z<0) | |
160 | fPxRec1 = fPzRec1 * nonBendingSlope; | |
161 | fPyRec1 = fPzRec1 * bendingSlope; | |
162 | fZRec1 = trackParam->GetZ(); | |
163 | fCharge = Int_t(TMath::Sign(1., trackParam->GetInverseBendingMomentum())); | |
164 | ||
165 | fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1); | |
166 | fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1); | |
167 | ||
168 | ntrackhits = rectrack->GetNTrackHits(); | |
169 | fitfmin = rectrack->GetFitFMin(); | |
170 | ||
171 | // transverse momentum | |
172 | Float_t pt1 = fV1.Pt(); | |
173 | ||
174 | // total momentum | |
175 | Float_t p1 = fV1.P(); | |
176 | ||
177 | // Rapidity | |
178 | Float_t rapMuon1 = fV1.Rapidity(); | |
179 | ||
180 | // chi2 per d.o.f. | |
181 | Float_t ch1 = fitfmin / (2.0 * ntrackhits - 5); | |
182 | // printf(" px %f py %f pz %f NHits %d Norm.chi2 %f charge %d\n", | |
183 | // fPxRec1, fPyRec1, fPzRec1, ntrackhits, ch1, fCharge); | |
184 | ||
185 | // condition for good track (Chi2Cut and PtCut) | |
186 | ||
187 | if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) { | |
188 | ||
189 | // fill histos hPtMuon and hChi2PerDof | |
190 | hPtMuon->Fill(pt1); | |
191 | hPMuon->Fill(p1); | |
192 | hChi2PerDof->Fill(ch1); | |
193 | hRapMuon->Fill(rapMuon1); | |
194 | ||
195 | // loop over second track of combination | |
196 | for (Int_t irectracks2 = irectracks + 1; irectracks2 < nrectracks; irectracks2++) { | |
197 | ||
198 | rectrack = (AliMUONTrack*) recTracksArray->At(irectracks2); | |
199 | ||
200 | trackParam = rectrack->GetTrackParamAtVertex(); | |
201 | bendingSlope = trackParam->GetBendingSlope(); | |
202 | nonBendingSlope = trackParam->GetNonBendingSlope(); | |
203 | ||
204 | pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum()); | |
205 | fPzRec2 = - pYZ / TMath::Sqrt(1.0 + bendingSlope * bendingSlope); // spectro. (z<0) | |
206 | fPxRec2 = fPzRec2 * nonBendingSlope; | |
207 | fPyRec2 = fPzRec2 * bendingSlope; | |
208 | fZRec2 = trackParam->GetZ(); | |
209 | fCharge2 = Int_t(TMath::Sign(1., trackParam->GetInverseBendingMomentum())); | |
210 | ||
211 | fE2 = TMath::Sqrt(muonMass * muonMass + fPxRec2 * fPxRec2 + fPyRec2 * fPyRec2 + fPzRec2 * fPzRec2); | |
212 | fV2.SetPxPyPzE(fPxRec2, fPyRec2, fPzRec2, fE2); | |
213 | ||
214 | ntrackhits = rectrack->GetNTrackHits(); | |
215 | fitfmin = rectrack->GetFitFMin(); | |
216 | ||
217 | // transverse momentum | |
218 | Float_t pt2 = fV2.Pt(); | |
219 | ||
220 | // chi2 per d.o.f. | |
221 | Float_t ch2 = fitfmin / (2.0 * ntrackhits - 5); | |
222 | ||
223 | // condition for good track (Chi2Cut and PtCut) | |
224 | if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) { | |
225 | ||
226 | // condition for opposite charges | |
227 | if ((fCharge * fCharge2) == -1) { | |
228 | ||
229 | // invariant mass | |
230 | fVtot = fV1 + fV2; | |
231 | Float_t invMass = fVtot.M(); | |
232 | ||
233 | // fill histos hInvMassAll and hInvMassRes | |
234 | hInvMassAll->Fill(invMass); | |
235 | hInvMassRes->Fill(invMass); | |
236 | ||
237 | if (invMass > massMin && invMass < massMax) { | |
238 | EventInMass++; | |
239 | hRapResonance->Fill(fVtot.Rapidity()); | |
240 | hPtResonance->Fill(fVtot.Pt()); | |
241 | } | |
242 | ||
243 | } // if (fCharge * fCharge2) == -1) | |
244 | } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) | |
245 | } // for (Int_t irectracks2 = irectracks + 1; irectracks2 < irectracks; irectracks2++) | |
246 | } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) ) | |
247 | } // for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++) | |
248 | ||
249 | hNumberOfTrack->Fill(nrectracks); | |
250 | } // for (Int_t ievent = FirstEvent; | |
251 | ||
252 | histoFile->Write(); | |
253 | histoFile->Close(); | |
254 | ||
255 | cout << "MUONmassPlot " << endl; | |
256 | cout << "FirstEvent " << FirstEvent << endl; | |
257 | cout << "LastEvent " << LastEvent << endl; | |
258 | cout << "ResType " << ResType << endl; | |
259 | cout << "Chi2Cut " << Chi2Cut << endl; | |
260 | cout << "PtCutMin " << PtCutMin << endl; | |
261 | cout << "PtCutMax " << PtCutMax << endl; | |
262 | cout << "massMin " << massMin << endl; | |
263 | cout << "massMax " << massMax << endl; | |
264 | cout << "EventInMass " << EventInMass << endl; | |
265 | } | |
266 |