]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ShowSPDESDs.C
Initialize magnetic field in RunLego as it is done in Run in case we get
[u/mrichter/AliRoot.git] / ITS / ShowSPDESDs.C
1 //////////////////////////////////////////////////////////////////
2 // Macro to check ESD info provided by the 2 SPD layers         //
3 // Provides:                                                    //
4 //  1 canvas with                                               //
5 //      - distribution of the SPD vertex Z-coord                //
6 //      - SPD vertex Z-coord and sigma for each event           //
7 //  1 canvas for tracklets with                                 //
8 //      - #tracklets                                            //
9 //      - #tracklets vs #clusters (inner layer)                 //
10 //      - deltaPhi                                              //
11 //      - Phi                                                   //
12 //  1 canvas for clusters (inner layer) not associated with     //
13 //      - #single clusters                                      // 
14 //      - Phi                                                   //
15 //      - Theta                                                 //
16 //                                                              //
17 //  Maria.Nicassio@ba.infn.it                                   //
18 //  Domenico.Elia@ba.infn.it                                    //
19 //////////////////////////////////////////////////////////////////
20                                                                                                                          
21 #if !defined(__CINT__) || defined(__MAKECINT__)
22
23 #include <Riostream.h>
24 #include "TFile.h"
25 #include "TTree.h"
26 #include "TH1.h"
27 #include "TH2.h"
28 #include "TCanvas.h"                                                                                                               
29 #include "AliESD.h"                                                                                                               
30 #include "AliESDEvent.h"
31 #include "AliESDHeader.h"
32 #include "AliESDVertex.h"
33 #include "AliESDtrack.h"
34 #include "AliMultiplicity.h"
35 #endif
36
37 /* $Id$ */
38 void ShowSPDESDs (Int_t RunStart, Int_t RunStop) {
39
40   Char_t fileName[256];
41
42   Char_t* dir = "/home/elia/alice/pp/data/first";            
43
44   TH1F* hSPDVertex = new TH1F("SPDVertex","",80,-20.,20.);
45   TH1F* hSPDVertexPerEvent = new TH1F("SPDVertexPerEvent","",100,0.,100.);
46
47   TH1F* hnTracklets = new TH1F("nTracklets","",200,0.,200.);
48   TH2F* hnTracklets_nCl1 = new TH2F("nTracklets_nCl1","",200,0.,200.,200,0.,200.);
49   TH1F* hDePhiTracklets = new TH1F("DePhiTracklets","",200,-0.2,0.2);
50   TH1F* hPhiTracklets = new TH1F("PhiTracklets","",600,0.,2*TMath::Pi());
51   TH1F* hThetaTracklets = new TH1F("ThetaTracklets","",300,0.,TMath::Pi());
52   TH1F* hnSingleClustersLay1 = new TH1F("nSingleClustersLay1","",200,0.,200.);
53   TH1F* hPhiSingleClustersLay1 = new TH1F("PhiSingleClustersLay1","",600,0.,2*TMath::Pi());
54   TH1F* hThetaSingleClustersLay1 = new TH1F("ThetaSingleClustersLay1","",600,0.,TMath::Pi());
55
56   // Loop over runs ...
57   for (Int_t run=RunStart; run<RunStop+1; run++) {
58
59     sprintf(fileName,"%s/AliESDsRAW_%04d.root",dir,run);
60
61     // Open input file and get the TTree
62     TFile inFile(fileName, "READ");
63   
64     TTree *esdTree = (TTree*)inFile.Get("esdTree");
65     AliESDEvent *esd = new AliESDEvent();
66     esd->ReadFromTree(esdTree);
67   
68     // Loop over events
69     Int_t nESDEvents = esdTree->GetEntries();
70     for (Int_t iEv = 0; iEv < nESDEvents; iEv++) {
71 //    cout << "Event: " << iEv+1 << "/" << nESDEvents << endl;
72
73       // Read events
74       esdTree->GetEvent(iEv);      
75
76       // Get the ESD vertex
77       const AliESDVertex* vtxESD = esd->GetVertex();
78
79       Double_t ESDvtx[3];
80       Double_t sigmaESDvtx[3];
81       vtxESD->GetXYZ(ESDvtx);
82       vtxESD->GetSigmaXYZ(sigmaESDvtx);
83 //    cout<<"SPD vtx: x="<<ESDvtx[0]<<" y="<<ESDvtx[1]<<" z="<<ESDvtx[2]<<endl;
84 //    cout<<"sigma SPD vtx: x="<<sigmaESDvtx[0]<<" y="<<sigmaESDvtx[1]<<" z="<<sigmaESDvtx[2]<<endl;
85       hSPDVertex->Fill(ESDvtx[2]);          
86       if (ESDvtx[2]!=0.) hSPDVertexPerEvent->SetBinError(iEv,sigmaESDvtx[2]);         
87       hSPDVertexPerEvent->Fill(iEv,ESDvtx[2]);                                         
88
89       // Get the SPD reconstructed multiplicity
90       const AliMultiplicity* SPDMult = esd->GetMultiplicity();
91
92       Int_t nTracklets = SPDMult->GetNumberOfTracklets();
93       // Loop over tracklets
94       for (Int_t itr=0; itr<nTracklets; ++itr) {
95         Float_t thetaTr = SPDMult->GetTheta(itr);
96         Float_t phiTr = SPDMult->GetPhi(itr);
97         Float_t dePhiTr = SPDMult->GetDeltaPhi(itr);
98         hPhiTracklets->Fill(phiTr);
99         hDePhiTracklets->Fill(dePhiTr);
100         hThetaTracklets->Fill(thetaTr);
101       }
102
103       Int_t nSingleCl1 = SPDMult->GetNumberOfSingleClusters();
104       Int_t nCl1 = nSingleCl1 + nTracklets;
105       // Loop over unassociated clusters
106       for (Int_t icl=0; icl<nSingleCl1; ++icl) {
107         Float_t phiSing = SPDMult->GetPhiSingle(icl);
108         Float_t thetaSing = SPDMult->GetThetaSingle(icl);
109         hPhiSingleClustersLay1->Fill(phiSing);
110         hThetaSingleClustersLay1->Fill(thetaSing);
111       }   
112       hnTracklets_nCl1->Fill(nCl1,nTracklets);
113       hnTracklets->Fill(nTracklets);
114       hnSingleClustersLay1->Fill(nSingleCl1);
115
116     } // end loop over events
117   } // end loop over runs
118   
119   TFile* fout = new TFile("out_ShowSPDESDs.root","RECREATE");
120   
121   TCanvas *cVertex = new TCanvas("cVertex","SPD vertex");
122   cVertex->Divide(1,2);
123   cVertex->cd(1);
124   hSPDVertex->GetYaxis()->SetTitle("Entries");
125   hSPDVertex->GetXaxis()->SetTitle("Reconstructed vertex [cm]");
126   hSPDVertex->Draw();
127   cVertex->cd(2);
128   hSPDVertexPerEvent->SetMarkerStyle(21);
129   hSPDVertexPerEvent->SetMarkerColor(2);
130   hSPDVertexPerEvent->SetMarkerSize(0.4);
131   hSPDVertexPerEvent->GetXaxis()->SetTitle("Event number");
132   hSPDVertexPerEvent->GetYaxis()->SetTitle("Reconstructed vertex [cm]");
133   hSPDVertexPerEvent->Draw("p");                                                                                            
134   TCanvas *cTracklets = new TCanvas("cTracklets","SPD Tracklets");
135   cTracklets->Divide(2,2);
136   cTracklets->cd(1);
137   hnTracklets->GetXaxis()->SetTitle("Number of tracklets");
138   hnTracklets->GetYaxis()->SetTitle("Entries");
139   hnTracklets->Draw();
140   cTracklets->cd(2);
141   hnTracklets_nCl1->GetXaxis()->SetTitle("# clusters (inner layer)");
142   hnTracklets_nCl1->GetYaxis()->SetTitle("# tracklets");
143   hnTracklets_nCl1->Draw();
144   cTracklets->cd(3);
145   hDePhiTracklets->GetXaxis()->SetTitle("#Delta#phi [rad]");
146   hDePhiTracklets->GetYaxis()->SetTitle("Entries");
147   hDePhiTracklets->Draw(); 
148   cTracklets->cd(4);
149   hPhiTracklets->GetXaxis()->SetTitle("#phi [rad]");
150   hPhiTracklets->GetYaxis()->SetTitle("Entries");
151   hPhiTracklets->Draw();
152
153   TCanvas *cSingleClusters = new TCanvas("cSingleClusters","Unassociated clusters");
154   cSingleClusters->Divide(2,2);
155   cSingleClusters->cd(1);
156   hnSingleClustersLay1->GetXaxis()->SetTitle("# clusters (inner layer)");
157   hnSingleClustersLay1->GetYaxis()->SetTitle("Entries");
158   hnSingleClustersLay1->Draw();
159   cSingleClusters->cd(2);
160   hPhiSingleClustersLay1->GetXaxis()->SetTitle("#phi [rad]");
161   hPhiSingleClustersLay1->GetYaxis()->SetTitle("Entries");
162   hPhiSingleClustersLay1->Draw();
163   cSingleClusters->cd(3);
164   hThetaSingleClustersLay1->GetXaxis()->SetTitle("#theta [rad]");
165   hThetaSingleClustersLay1->GetYaxis()->SetTitle("Entries");
166   hThetaSingleClustersLay1->Draw();
167
168   hSPDVertex->Write();
169   hSPDVertexPerEvent->Write();
170   hnTracklets_nCl1->Write();
171   hnTracklets->Write();
172
173   hDePhiTracklets->Write();
174   hPhiTracklets->Write();
175   hThetaTracklets->Write();
176   hnSingleClustersLay1->Write(); 
177   hPhiSingleClustersLay1->Write(); 
178   hThetaSingleClustersLay1->Write();
179
180   fout->Close(); 
181   return;
182
183 }