]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDanalysis.C
Moving the efficiency calculations before the cleanup (Guiseppe)
[u/mrichter/AliRoot.git] / STEER / AliESDanalysis.C
CommitLineData
ae982df3 1//********************************************************************
8c6a71ab 2// Example (very naive for the moment) of the data analysis
ae982df3 3// using the ESD classes
0717295b 4// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
ae982df3 5//********************************************************************
6
c630aafd 7#if !defined( __CINT__) || defined(__MAKECINT__)
ae982df3 8 #include <Riostream.h>
8b462fd8 9 #include <TTree.h>
ae982df3 10 #include "TFile.h"
c630aafd 11 #include "TH1F.h"
ae982df3 12 #include "TCanvas.h"
0717295b 13 #include "TStyle.h"
ae982df3 14 #include "TStopwatch.h"
15
86ad5fcb 16 #include "AliESDEvent.h"
ae982df3 17#endif
18
0717295b 19extern TStyle *gStyle;
20
21Int_t AliESDanalysis() {
22 TStopwatch timer;
23
24 gStyle->SetOptStat(111110);
25 gStyle->SetOptFit(1);
26
27 Double_t V0mass=0.497672, V0width=0.020, V0window=0.05;
28 Double_t mmin=V0mass-V0window, mmax=V0mass+V0window;
29 TH1F *hm =new TH1F("hm","K0s",40, mmin, mmax);
30 hm->SetXTitle("Mass (GeV/c**2)"); hm->SetLineColor(2);
31 TH1F *hp =new TH1F("hp","Momentum of the positive daughter",40, 0, 2);
32 hp->SetXTitle("P (GeV/c)"); hp->SetLineColor(4);
c630aafd 33
0717295b 34//****** File with the ESD
ae982df3 35 TFile *ef=TFile::Open("AliESDs.root");
0717295b 36 if (!ef || !ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
86ad5fcb 37 AliESDEvent* event = new AliESDEvent();
8b462fd8 38 TTree* tree = (TTree*) ef->Get("esdTree");
39 if (!tree) {cerr<<"no ESD tree found\n"; return 1;};
86ad5fcb 40 event->ReadFromTree(tree);
ae982df3 41
0717295b 42 Int_t n=0;
ae982df3 43
0717295b 44//******* The loop over events
8b462fd8 45 while (tree->GetEvent(n)) {
0717295b 46 cout<<endl<<"Processing event number : "<<n++<<endl;
c630aafd 47
ae982df3 48 Int_t ntrk=event->GetNumberOfTracks();
0717295b 49 cout<<"Number of ESD tracks : "<<ntrk<<endl;
50 Int_t nv0=event->GetNumberOfV0s();
51 cout<<"Number of ESD V0s : "<<nv0<<endl;
52 Int_t ncas=event->GetNumberOfCascades();
53 cout<<"Number of ESD cascades : "<<ncas<<endl;
c630aafd 54
0717295b 55 //****** The loop over tracks
56 Int_t nk=0;
ae982df3 57 while (ntrk--) {
0717295b 58 AliESDtrack *track=event->GetTrack(ntrk);
59 UInt_t status=track->GetStatus();
60
61 //select only tracks with the "combined PID"
62 if ((status&AliESDtrack::kESDpid)==0) continue;
63
64 Double_t w[10]; track->GetESDpid(w);
65 //count only "Kaon-like" tracks
66 if (w[3]>w[4] && w[3]>w[2] && w[3]>w[1] && w[3]>w[0]) nk++;
67 }
68 cout<<"Number of \"Kaon-like\" tracks : "<<nk<<endl;
69
70 //****** The loop over V0s
71 while (nv0--) {
72 AliESDv0 *v0=event->GetV0(nv0);
73 v0->ChangeMassHypothesis(310); // K0s
74 Double_t mass=v0->GetEffMass();
75 hm->Fill(mass);
76
77 Int_t pidx=v0->GetPindex(); // now let's get an access
78 AliESDtrack *track=event->GetTrack(pidx); // to the positive daughter
79 Double_t p=track->GetP();
80 hp->Fill(p);
81 }
82
83 //****** The loop over cascades
84 while (ncas--) {
85 AliESDcascade *cas=event->GetCascade(ncas);
86 Double_t q; //"quality" of the associated Lambda
87 cas->ChangeMassHypothesis(q,3312); // Xi-
88 // Here you do something with your Xis
89 // ...
90 // You can get the access to the daughters
91 }
92
ae982df3 93 }
c630aafd 94
8b462fd8 95 delete event;
96 ef->Close();
97
ae982df3 98 timer.Stop(); timer.Print();
99
100 TCanvas *c1=new TCanvas("c1","",0,0,600,1200);
0717295b 101 c1->Divide(1,2);
ae982df3 102
103 c1->cd(1);
0717295b 104 hm->Fit("gaus","","",V0mass-V0width,V0mass+V0width);
c630aafd 105
ae982df3 106 c1->cd(2);
0717295b 107 hp->Fit("expo","","",0.3,2);
108
109 return 0;
ae982df3 110}