]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSSteerPid.cxx
Inserting TMath.h where required by the new version of ROOT
[u/mrichter/AliRoot.git] / ITS / AliITSSteerPid.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 /////////////////////////////////////////////////////////////////////////
19 //Steering Class for PID in the ITS                                      //
20 //The PID is based on the likelihood of all the four ITS' layers,        //
21 //without using the truncated mean for the dE/dx. The response           //
22 //functions for each layer are convoluted Landau-Gaussian functions.     // 
23 // Origin: Elena Bruna bruna@to.infn.it, Massimo Masera masera@to.infn.it//
24 /////////////////////////////////////////////////////////////////////////
25
26 #include <TMath.h>
27
28 #include "AliITSSteerPid.h"
29
30 ClassImp(AliITSSteerPid)
31
32   //______________________________________________________________
33 AliITSSteerPid::AliITSSteerPid():
34 fClonarr2(0),
35 fVect2(0),
36 fVect2lay1(0),
37 fVect2lay2(0),
38 fVect2lay3(0),
39 fVect2lay4(0),
40 fFitTree(0),
41 fItem(0),
42 fPCenter(0),
43 fPWidth(0)
44 {
45   // default constructor
46  }
47 //______________________________________________________________
48 AliITSSteerPid::~AliITSSteerPid(){
49   // destructor
50   delete fClonarr2;
51   delete fFitTree;
52 }
53
54 //______________________________________________________________________
55 AliITSSteerPid::AliITSSteerPid(const AliITSSteerPid &ob) :TObject(ob),
56 fClonarr2(ob.fClonarr2),
57 fVect2(ob.fVect2),
58 fVect2lay1(ob.fVect2lay1),
59 fVect2lay2(ob.fVect2lay2),
60 fVect2lay3(ob.fVect2lay3),
61 fVect2lay4(ob.fVect2lay4),
62 fFitTree(ob.fFitTree),
63 fItem(ob.fItem),
64 fPCenter(ob.fPCenter),
65 fPWidth(ob.fPWidth) {
66   // Copy constructor
67 }
68
69 //______________________________________________________________________
70 AliITSSteerPid& AliITSSteerPid::operator=(const AliITSSteerPid& ob){
71   // Assignment operator
72   this->~AliITSSteerPid();
73   new(this) AliITSSteerPid(ob);
74   return *this;
75 }
76
77 //______________________________________________________________
78 void AliITSSteerPid::InitLayer(TString fileITS,TString fileFitPar){
79   // it opens the files useful for the PID 
80   TFile *fClonarr2=new TFile (fileITS,"r");
81   fVect2=(TClonesArray*)fClonarr2->Get("vectfitits_0");//truncated mean
82   fVect2lay1=(TClonesArray*)fClonarr2->Get("vectfitits_1");//lay 1
83   fVect2lay2=(TClonesArray*)fClonarr2->Get("vectfitits_2");//lay 2
84   fVect2lay3=(TClonesArray*)fClonarr2->Get("vectfitits_3");//lay 3
85   fVect2lay4=(TClonesArray*)fClonarr2->Get("vectfitits_4");//lay 4
86  
87   TFile *fFitPar=new TFile (fileFitPar);
88   fFitTree=(TTree*)fFitPar->Get("tree");
89  
90 }
91
92 //______________________________________________________________
93 AliITSPidParItem* AliITSSteerPid::GetItemLayer(Int_t nolay,Float_t mom){
94     // it gives an AliITSPidParItem object for a given momentum and ITS layer
95   if(nolay==1) return Item(fVect2lay1,mom);
96   if(nolay==2) return Item(fVect2lay2,mom);
97   if(nolay==3) return Item(fVect2lay3,mom);
98   if(nolay==4) return Item(fVect2lay4,mom);
99   if(nolay!=1&&nolay!=2&&nolay!=3&&nolay!=4) {
100     fItem=new AliITSPidParItem();
101     return fItem;
102
103   }
104   return 0;
105 }
106
107 //______________________________________________________________
108 void AliITSSteerPid::GetParFitLayer(Int_t nolay,Float_t mom,Double_t *parp,Double_t *park,Double_t *parpi){
109   //it gives the parameters of the convoluted functions (WL, MP, WG) for 
110   //protons, kaons and pions for a given momentum and ITS layer
111
112   Double_t parfit0pro[3]={0,0,0};
113   Double_t parfit1pro[3]={0,0,0};
114   Double_t parfit3pro[3]={0,0,0};
115   Double_t parfit0kao[3]={0,0,0};
116   Double_t parfit1kao[3]={0,0,0};
117   Double_t parfit3kao[3]={0,0,0};
118   Double_t parfit0pi[3]={0,0,0};
119   Double_t parfit1pi[3]={0,0,0};
120   Double_t parfit3pi[3]={0,0,0};
121  
122   fFitTree->SetBranchAddress("par0pro",parfit0pro);
123   fFitTree->SetBranchAddress("par1pro",parfit1pro);
124   fFitTree->SetBranchAddress("par3pro",parfit3pro);
125
126   fFitTree->SetBranchAddress("par0kao",parfit0kao);
127   fFitTree->SetBranchAddress("par1kao",parfit1kao);
128   fFitTree->SetBranchAddress("par3kao",parfit3kao);
129
130   fFitTree->SetBranchAddress("par0pi",parfit0pi);
131   fFitTree->SetBranchAddress("par1pi",parfit1pi);
132   fFitTree->SetBranchAddress("par3pi",parfit3pi);
133   fFitTree->GetEvent(nolay);
134  
135   GetLangausProPars(mom,parfit0pro,parfit1pro,parfit3pro,parp);
136   GetLangausKaoPars(mom,parfit0kao,parfit1kao,parfit3kao,park);
137   GetLangausPiPars(mom,parfit0pi,parfit1pi,parfit3pi,parpi);
138
139
140 }//______________________________________________________________
141 void AliITSSteerPid::GetLangausProPars(Float_t mom,Double_t *parfit0,Double_t *parfit1,Double_t *parfit3,Double_t *par){
142  
143   //It finds the parameters of the convoluted Landau-Gaussian response 
144   //function for protons (Width Landau, Most Probable, Width Gaussian)
145   par[0]=parfit0[0]+parfit0[1]/mom;
146   par[1]=parfit1[0]/(mom*mom)+parfit1[1]/(mom*mom)*TMath::Log(mom*mom)+parfit1[2];
147   par[2]=parfit3[0]/(mom*mom)+parfit3[1]/(mom*mom)*TMath::Log(mom*mom)+parfit3[2];
148 }
149 //______________________________________________________________
150 void AliITSSteerPid::GetLangausKaoPars(Float_t mom,Double_t *parfit0,Double_t *parfit1,Double_t *parfit3,Double_t *par){
151   // It finds the parameters of the convoluted Landau-Gaussian response 
152   //function for kaons (Width Landau, Most Probable, Width Gaussian)
153
154   par[0]=parfit0[0]+parfit0[1]/(mom*mom);
155   par[1]=parfit1[0]/(mom*mom)+parfit1[1]/(mom*mom)*TMath::Log(mom*mom)+parfit1[2];
156   par[2]=parfit3[0]/(mom*mom)+parfit3[1]/(mom*mom)*TMath::Log(mom*mom)+parfit3[2];
157 }
158
159 //______________________________________________________________
160 void AliITSSteerPid::GetLangausPiPars(Float_t mom,Double_t *parfit0,Double_t *parfit1,Double_t *parfit3,Double_t *par){
161   //It finds the parameters of the convoluted Landau-Gaussian response 
162   //function for pions (Width Landau, Most Probable, Width Gaussian)
163
164   par[0]=parfit0[0]/(mom*mom)+parfit0[1]/(mom*mom)*TMath::Log(mom*mom)+parfit0[2];
165   par[1]=parfit1[0]/(mom)+parfit1[1]/(mom)*TMath::Log(mom*mom)+parfit1[2];
166   par[2]=parfit3[0]/(mom*mom)+parfit3[1]/(mom*mom)*TMath::Log(mom*mom)+parfit3[2];
167 }
168
169
170
171 //______________________________________________________________
172 AliITSPidParItem* AliITSSteerPid::Item(TClonesArray *Vect,Float_t mom){
173
174   //it gives an AliITSPidParItem object taken from the TClonesArray. 
175   Int_t mybin=-1;
176
177   AliITSPidParItem* punt;
178   
179   for (Int_t a=0;a<50;a++){
180     punt=(AliITSPidParItem*)Vect->At(a);
181     Float_t centerp=punt->GetMomentumCenter(); 
182     Float_t widthp=punt->GetWidthMom();
183     if (mom>(centerp-widthp/2) && mom<=(centerp+widthp/2)) mybin=a; 
184   }
185   if (mybin!=-1) fItem=(AliITSPidParItem*)Vect->At(mybin);
186   else {
187     fPCenter=0;
188     fPWidth=0;
189     for (Int_t ii=0;ii<52;ii++) fBuff[ii]=0;
190     fItem = new AliITSPidParItem(fPCenter,fPWidth,fBuff);
191   }
192   
193   return fItem;
194
195
196
197 }