]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/EsdQa.C
Max. angle in mag. field limited to 10deg.
[u/mrichter/AliRoot.git] / RICH / EsdQa.C
CommitLineData
a16cc3eb 1// The class definition in esdAna.h has been generated automatically
2// by the ROOT utility TTree::MakeSelector(). This class is derived
3// from the ROOT class TSelector. For more information on the TSelector
4// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
5
6// The following methods are defined in this file:
7// Begin(): called everytime a loop on the tree starts,
8// a convenient place to create your histograms.
9// SlaveBegin(): called after Begin(), when on PROOF called only on the
10// slave servers.
11// Process(): called for each event, in this function you decide what
12// to read and fill your histograms.
13// SlaveTerminate: called at the end of the loop on the tree, when on PROOF
14// called only on the slave servers.
15// Terminate(): called at the end of the loop on the tree,
16// a convenient place to draw/fit your histograms.
17//
18// To use this file, try the following session on your Tree T:
19//
20// Root > T->Process("esdAna.C")
21// Root > T->Process("esdAna.C","some options")
22// Root > T->Process("esdAna.C+")
23//
24
25#include "EsdQa.h"
26#include <AliESD.h>
27#include <TCanvas.h>
28#include <TH2F.h>
29#include <TGrid.h>
30#include <TAlienCollection.h>
31#include <TMath.h>
32
33void EsdQa::Begin(TTree *)
34{
35 // The Begin() function is called at the start of the query.
36 // When running with PROOF Begin() is only called on the client.
37 // The tree argument is deprecated (on PROOF 0 is passed).
38
39 TString option = GetOption();
40
41}
42
43void EsdQa::SlaveBegin(TTree *tree)
44{
45 // The SlaveBegin() function is called after the Begin() function.
46 // When running with PROOF SlaveBegin() is called on each slave server.
47 // The tree argument is deprecated (on PROOF 0 is passed).
48
49 Init(tree);
50
51 TString option = GetOption();
52
53 // create histograms on each slave server
54 fCkovMomH = new TH2F("CkovMomH", "Ckov angel,[rad];P [GeV]", 150, 0,15, 100 , 0, 1);
55 fsigma2 = new TH1F("sigma2","#sigma_{#theta_C}^2",2000,1e9,2e10);
56 fX = new TH1F("X","mipX[cm]",260,0,130);
57 fY = new TH1F("Y","mipY[cm]",252,0,126);
58 fdist = new TH2F("dist","dist mip-track[cm]",150,0,15,100,0,10);
59
60 fProbH[0] = new TH1F("pidE" ,"pid of e" ,100,0,1);
61 fProbH[1] = new TH1F("pidMu","pid of #mu",100,0,1);
62 fProbH[2] = new TH1F("pidPi","pid of #pi",100,0,1);
63 fProbH[3] = new TH1F("pidK" ,"pid of K" ,100,0,1);
64 fProbH[4] = new TH1F("pidP" ,"pid of p" ,100,0,1);
65}
66
67void EsdQa::Init(TTree *tree)
68{
69 // The Init() function is called when the selector needs to initialize
70 // a new tree or chain. Typically here the branch addresses of the tree
71 // will be set. It is normaly not necessary to make changes to the
72 // generated code, but the routine can be extended by the user if needed.
73 // Init() will be called many times when running with PROOF.
74
75 // Set branch addresses
76 if ( !tree )
77 return ;
78 fChain = tree ;
79 fChain->SetBranchAddress("ESD", &fEsd) ;
80}
81
82Bool_t EsdQa::Notify()
83{
84 // The Notify() function is called when a new file is opened. This
85 // can be either for a new TTree in a TChain or when when a new TTree
86 // is started when using PROOF. Typically here the branch pointers
87 // will be retrieved. It is normaly not necessary to make changes
88 // to the generated code, but the routine can be extended by the
89 // user if needed.
90
91 // Get branch pointers
92
93 return kTRUE;
94}
95
96Bool_t EsdQa::Process(Long64_t entry)
97{
98 // The Process() function is called for each entry in the tree (or possibly
99 // keyed object in the case of PROOF) to be processed. The entry argument
100 // specifies which entry in the currently loaded tree is to be processed.
101 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
102 // to read either all or the required parts of the data. When processing
103 // keyed objects with PROOF, the object is already loaded and is available
104 // via the fObject pointer.
105 //
106 // This function should contain the "body" of the analysis. It can contain
107 // simple or elaborate selection criteria, run algorithms on the data
108 // of the event and typically fill histograms.
109
110 // WARNING when a selector is used with a TChain, you must use
111 // the pointer to the current TTree to call GetEntry(entry).
112 // The entry is always the local entry number in the current tree.
113 // Assuming that fChain is the pointer to the TChain being processed,
114 // use fChain->GetTree()->GetEntry(entry).
115
116 fChain->GetTree()->GetEntry(entry);
117
118 for(Int_t iTrk=0;iTrk<fEsd->GetNumberOfTracks();iTrk++){
119 AliESDtrack *pTrk=fEsd->GetTrack(iTrk);
120
121 Float_t dx, dy;
122 pTrk->GetRICHdxdy(dx,dy);
123 Float_t r;
124 if(dx<0 && dy<0) r=999.;
125 else r = TMath::Sqrt(dx*dx+dy*dy);
126 fdist->Fill(pTrk->GetP(),r);
127 if(pTrk->GetRICHsignal()<0) continue;
128 fCkovMomH->Fill(pTrk->GetP(),pTrk->GetRICHsignal()) ;
129 Double_t pid[5];
130 pTrk->GetRICHpid(pid);
131 fProbH[0]->Fill(pid[0]); fProbH[1]->Fill(pid[1]); fProbH[2]->Fill(pid[2]); fProbH[3]->Fill(pid[3]); fProbH[4]->Fill(pid[4]);
132 fsigma2->Fill(pTrk->GetRICHchi2());
133 Float_t xmip, ymip;
134 pTrk->GetRICHmipXY(xmip,ymip);
135 fX->Fill(xmip); fY->Fill(ymip);
136 }
137
138 return kTRUE;
139}
140
141void EsdQa::SlaveTerminate()
142{
143 // The SlaveTerminate() function is called after all entries or objects
144 // have been processed. When running with PROOF SlaveTerminate() is called
145 // on each slave server.
146
147 // Add the histograms to the output on each slave server
148
149 fOutput->Add(fCkovMomH) ;
150 fOutput->Add(fsigma2) ;
151 fOutput->Add(fX) ;
152 fOutput->Add(fY) ;
153 fOutput->Add(fdist) ;
154 fOutput->Add(fProbH[0]); fOutput->Add(fProbH[1]);
155 fOutput->Add(fProbH[2]); fOutput->Add(fProbH[3]);
156 fOutput->Add(fProbH[4]);
157}
158
159void EsdQa::Terminate()
160{
161 // The Terminate() function is the last function to be called during
162 // a query. It always runs on the client, it can be used to present
163 // the results graphically or save the results to file.
164
165 fCkovMomH = dynamic_cast<TH2F*>(fOutput->FindObject("CkovMomH")) ;
166 fsigma2 = dynamic_cast<TH1F*>(fOutput->FindObject("sigma2")) ;
167 fX = dynamic_cast<TH1F*>(fOutput->FindObject("X")) ;
168 fY = dynamic_cast<TH1F*>(fOutput->FindObject("Y")) ;
169 fdist = dynamic_cast<TH2F*>(fOutput->FindObject("dist")) ;
170 fProbH[0] = dynamic_cast<TH1F*>(fOutput->FindObject("pidE")) ;
171 fProbH[1] = dynamic_cast<TH1F*>(fOutput->FindObject("pidMu")) ;
172 fProbH[2] = dynamic_cast<TH1F*>(fOutput->FindObject("pidPi")) ;
173 fProbH[3] = dynamic_cast<TH1F*>(fOutput->FindObject("pidK")) ;
174 fProbH[4] = dynamic_cast<TH1F*>(fOutput->FindObject("pidP")) ;
175
176
177 TFile * file = TFile::Open("esdAnaM.root", "RECREATE");
178 fCkovMomH->Write() ;
179 fX->Write();
180 fY->Write();
181 fdist->Write();
182 for(Int_t i=0;i<5;i++) fProbH[i] -> Write();
183 fsigma2->Write();
184// fHistNeutralMul->Write() ;
185 file->Close() ;
186 delete file ;
187 if (!gROOT->IsBatch()) {
188 TCanvas *c1 = new TCanvas("c1","Annalisa's best trial");c1->SetFillColor(10); c1->SetHighLightColor(10);
189 fCkovMomH->DrawCopy() ;
190 }
191}
192
193
194void run()
195{
196 TGrid::Connect("alien://",0,0,"t");
197 TAlienCollection *pAlienColl = new TAlienCollection("newIIcento.xml") ;
198
199 TChain* pChain = new TChain("esdTree");
200
201 pAlienColl->Reset() ;
202 while (pAlienColl->Next()) {
203 char esdFile[255] ;
204 sprintf(esdFile, "%s", pAlienColl->GetTURL("")) ;
205 Printf("Adding alien file %s", esdFile);
206 pChain->Add(esdFile) ;
207 }
208
209 EsdQa *pSel =new EsdQa;
210 pChain->Process(pSel);
211}