1 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include "TClonesArray.h"
5 #include "TLorentzVector.h"
13 #include "AliRunLoader.h"
14 #include "AliHeader.h"
15 #include "AliLoader.h"
20 #include "AliMUONData.h"
21 #include "AliMUONHit.h"
22 #include "AliMUONConstants.h"
23 #include "AliMUONDigit.h"
24 #include "AliMUONRawCluster.h"
25 #include "AliMUONGlobalTrigger.h"
26 #include "AliMUONLocalTrigger.h"
27 #include "AliMUONTrack.h"
28 #include "AliMUONTrackParam.h"
29 #include "AliESDMuonTrack.h"
32 // Macro MUONmassPlot.C for new I/O
33 // Ch. Finck, Subatech, Jan. 2004
36 // macro to make invariant mass plots
37 // for combinations of 2 muons with opposite charges,
38 // from root file "MUON.tracks.root" containing the result of track reconstruction.
39 // Histograms are stored on the "MUONmassPlot.root" file.
40 // introducing TLorentzVector for parameter calculations (Pt, P,rap,etc...)
41 // using Invariant Mass for rapidity.
44 // FirstEvent (default 0)
45 // LastEvent (default 0)
46 // ResType (default 553)
47 // 553 for Upsilon, anything else for J/Psi
48 // Chi2Cut (default 100)
49 // to keep only tracks with chi2 per d.o.f. < Chi2Cut
50 // PtCutMin (default 1)
51 // to keep only tracks with transverse momentum > PtCutMin
52 // PtCutMax (default 10000)
53 // to keep only tracks with transverse momentum < PtCutMax
54 // massMin (default 9.17 for Upsilon)
55 // & massMax (default 9.77 for Upsilon)
56 // to calculate the reconstruction efficiency for resonances with invariant mass
57 // massMin < mass < massMax.
59 // Add parameters and histograms for analysis
61 void MUONmassPlot(char* filename="galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 0, Int_t ResType = 553,
62 Float_t Chi2Cut = 100., Float_t PtCutMin = 1., Float_t PtCutMax = 10000.,
63 Float_t massMin = 9.17,Float_t massMax = 9.77)
65 cout << "MUONmassPlot " << endl;
66 cout << "FirstEvent " << FirstEvent << endl;
67 cout << "LastEvent " << LastEvent << endl;
68 cout << "ResType " << ResType << endl;
69 cout << "Chi2Cut " << Chi2Cut << endl;
70 cout << "PtCutMin " << PtCutMin << endl;
71 cout << "PtCutMax " << PtCutMax << endl;
72 cout << "massMin " << massMin << endl;
73 cout << "massMax " << massMax << endl;
76 //Reset ROOT and connect tree file
80 // File for histograms and histogram booking
81 TFile *histoFile = new TFile("MUONmassPlot.root", "RECREATE");
82 TH1F *hPtMuon = new TH1F("hPtMuon", "Muon Pt (GeV/c)", 100, 0., 20.);
83 TH1F *hPMuon = new TH1F("hPMuon", "Muon P (GeV/c)", 100, 0., 200.);
84 TH1F *hChi2PerDof = new TH1F("hChi2PerDof", "Muon track chi2/d.o.f.", 100, 0., 20.);
85 TH1F *hInvMassAll = new TH1F("hInvMassAll", "Mu+Mu- invariant mass (GeV/c2)", 480, 0., 12.);
89 hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around Upsilon", 60, 8., 11.);
91 hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around J/Psi", 80, 0., 5.);
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.);
101 Int_t EventInMass = 0;
102 Float_t muonMass = 0.105658389;
103 // Float_t UpsilonMass = 9.46037;
104 // Float_t JPsiMass = 3.097;
106 Double_t bendingSlope, nonBendingSlope, pYZ;
107 Double_t fPxRec1, fPyRec1, fPzRec1, fZRec1, fE1;
108 Double_t fPxRec2, fPyRec2, fPzRec2, fZRec2, fE2;
109 Int_t fCharge, fCharge2;
111 Int_t ntrackhits, nevents;
114 TClonesArray * recTracksArray;
115 TLorentzVector fV1, fV2, fVtot;
117 // Creating Run Loader and openning file containing Hits
118 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
119 if (RunLoader == 0x0) {
120 printf(">>> Error : Error Opening %s file \n",filename);
124 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
125 MUONLoader->LoadTracks("READ");
127 // Creating MUON data container
128 AliMUONData muondata(MUONLoader,"MUON","MUON");
130 nevents = RunLoader->GetNumberOfEvents();
132 AliMUONTrack * rectrack;
133 AliMUONTrackParam *trackParam;
136 for (Int_t ievent = FirstEvent; ievent <= TMath::Min(LastEvent, nevents - 1); ievent++) {
139 RunLoader->GetEvent(ievent);
141 muondata.SetTreeAddress("RT");
142 muondata.GetRecTracks();
143 recTracksArray = muondata.RecTracks();
145 Int_t nrectracks = (Int_t) recTracksArray->GetEntriesFast(); //
147 printf("\n Nb of events analysed: %d\r",ievent);
148 // cout << " number of tracks: " << nrectracks <<endl;
150 // loop over all reconstructed tracks (also first track of combination)
151 for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++) {
153 rectrack = (AliMUONTrack*) recTracksArray->At(irectracks);
155 trackParam = rectrack->GetTrackParamAtVertex();
156 bendingSlope = trackParam->GetBendingSlope();
157 nonBendingSlope = trackParam->GetNonBendingSlope();
159 pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum());
160 fPzRec1 = - pYZ / TMath::Sqrt(1.0 + bendingSlope * bendingSlope); // spectro. (z<0)
161 fPxRec1 = fPzRec1 * nonBendingSlope;
162 fPyRec1 = fPzRec1 * bendingSlope;
163 fZRec1 = trackParam->GetZ();
164 fCharge = Int_t(TMath::Sign(1., trackParam->GetInverseBendingMomentum()));
166 fE1 = TMath::Sqrt(muonMass * muonMass + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1);
167 fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1);
169 ntrackhits = rectrack->GetNTrackHits();
170 fitfmin = rectrack->GetFitFMin();
172 // transverse momentum
173 Float_t pt1 = fV1.Pt();
176 Float_t p1 = fV1.P();
179 Float_t rapMuon1 = fV1.Rapidity();
182 Float_t ch1 = fitfmin / (2.0 * ntrackhits - 5);
183 // printf(" px %f py %f pz %f NHits %d Norm.chi2 %f charge %d\n",
184 // fPxRec1, fPyRec1, fPzRec1, ntrackhits, ch1, fCharge);
186 // condition for good track (Chi2Cut and PtCut)
188 if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) {
190 // fill histos hPtMuon and hChi2PerDof
193 hChi2PerDof->Fill(ch1);
194 hRapMuon->Fill(rapMuon1);
196 // loop over second track of combination
197 for (Int_t irectracks2 = irectracks + 1; irectracks2 < nrectracks; irectracks2++) {
199 rectrack = (AliMUONTrack*) recTracksArray->At(irectracks2);
201 trackParam = rectrack->GetTrackParamAtVertex();
202 bendingSlope = trackParam->GetBendingSlope();
203 nonBendingSlope = trackParam->GetNonBendingSlope();
205 pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum());
206 fPzRec2 = - pYZ / TMath::Sqrt(1.0 + bendingSlope * bendingSlope); // spectro. (z<0)
207 fPxRec2 = fPzRec2 * nonBendingSlope;
208 fPyRec2 = fPzRec2 * bendingSlope;
209 fZRec2 = trackParam->GetZ();
210 fCharge2 = Int_t(TMath::Sign(1., trackParam->GetInverseBendingMomentum()));
212 fE2 = TMath::Sqrt(muonMass * muonMass + fPxRec2 * fPxRec2 + fPyRec2 * fPyRec2 + fPzRec2 * fPzRec2);
213 fV2.SetPxPyPzE(fPxRec2, fPyRec2, fPzRec2, fE2);
215 ntrackhits = rectrack->GetNTrackHits();
216 fitfmin = rectrack->GetFitFMin();
218 // transverse momentum
219 Float_t pt2 = fV2.Pt();
222 Float_t ch2 = fitfmin / (2.0 * ntrackhits - 5);
224 // condition for good track (Chi2Cut and PtCut)
225 if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) {
227 // condition for opposite charges
228 if ((fCharge * fCharge2) == -1) {
232 Float_t invMass = fVtot.M();
234 // fill histos hInvMassAll and hInvMassRes
235 hInvMassAll->Fill(invMass);
236 hInvMassRes->Fill(invMass);
238 if (invMass > massMin && invMass < massMax) {
240 hRapResonance->Fill(fVtot.Rapidity());
241 hPtResonance->Fill(fVtot.Pt());
244 } // if (fCharge * fCharge2) == -1)
245 } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax))
246 } // for (Int_t irectracks2 = irectracks + 1; irectracks2 < irectracks; irectracks2++)
247 } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) )
248 } // for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++)
250 hNumberOfTrack->Fill(nrectracks);
251 } // for (Int_t ievent = FirstEvent;
256 cout << "MUONmassPlot " << endl;
257 cout << "FirstEvent " << FirstEvent << endl;
258 cout << "LastEvent " << LastEvent << endl;
259 cout << "ResType " << ResType << endl;
260 cout << "Chi2Cut " << Chi2Cut << endl;
261 cout << "PtCutMin " << PtCutMin << endl;
262 cout << "PtCutMax " << PtCutMax << endl;
263 cout << "massMin " << massMin << endl;
264 cout << "massMax " << massMax << endl;
265 cout << "EventInMass " << EventInMass << endl;