]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/RichAna.C
Updating MUON code with the new class AliMUONTrackExtrap (Philippe Pillot)
[u/mrichter/AliRoot.git] / RICH / RichAna.C
1 //This script is a skeleton for RICH analisys. It consequently reads events in a givent set of directories and provides
2 //resulting RANA.root file in home directory which contains all the requested hists. 
3 #if !defined( __CINT__) || defined(__MAKECINT__)
4 #include <TCanvas.h>
5 #include <TTree.h>
6 #include <TH2F.h>
7 #include <AliESD.h>
8 #include <AliESDtrack.h>
9 #include <TFile.h>
10 #endif
11
12
13 TH2F *pMassLen2;
14
15 void HistBook()
16 {
17   pMassLen2=new TH2F("masslen","Particle mass versus track length;cm;GeV",200,0,600,200,0,1.2);
18 }
19 //__________________________________________________________________________________________________
20 void HistFill(AliESDtrack *pTrack)
21 {
22   pMassLen2->Fill(pTrack->GetIntegratedLength(),pTrack->GetMass());  
23   
24 }
25 //__________________________________________________________________________________________________
26 void HistOut()
27 {
28   TCanvas *pC=new TCanvas("RICH analisys");
29   pMassLen2->Draw();
30
31   TFile outFile("~/RANA.root","RECREATE");   pC->Write();   outFile.Close();
32 }
33 //__________________________________________________________________________________________________
34 void Analyse(char *sDirName)
35 {
36 //Analyse info from single directory   
37   ::Info("","Tring to open from %s",sDirName);
38   TFile *pFile=TFile::Open(Form("%s/AliESDs.root",sDirName));if(!pFile || !pFile->IsOpen()) return;//open AliESDs.root                                                                    
39   TTree* pTree = (TTree*) pFile->Get("esdTree");             if(!pTree)                     return;//get ESD tree
40                                                                  
41   AliESD *pESD=new AliESD;  pTree->SetBranchAddress("ESD", &pESD);
42   
43   Int_t iNevents=pTree->GetEntries();   //how many events in this given directory
44   ::Info("","have %i events",iNevents);
45   for(Int_t iEventN=0;iEventN<iNevents;iEventN++){//ESD events loop
46     pTree->GetEvent(iEventN);
47     Int_t iNtracks=pESD->GetNumberOfTracks();    
48     for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
49       HistFill(pESD->GetTrack(iTrackN));
50     }//ESD tracks loop
51   }//ESD events loop
52   
53   delete pESD;  pFile->Close();//close AliESDs.root
54 }   
55 //__________________________________________________________________________________________________
56 void RichAna(Int_t iDirFirst=1,Int_t iDirLast=4)
57 {
58   gBenchmark->Start("RICHanalisys"); 
59   
60   HistBook();
61   
62   for(Int_t iDirN=iDirFirst;iDirN<=iDirLast;iDirN++) Analyse(Form("Ev%04i",iDirN));  //analise for single directory
63   
64   HistOut();
65
66   gBenchmark->Stop("RICHanalisys");
67   gBenchmark->Show("RICHanalisys"); 
68 }