2767c32f7dd7077415f164010e6e1b848fd869a5
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliRDHFCutsJpsitoee.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2010, 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 //
20 // Class for cuts on AOD reconstructed Jpsi->ee
21 //
22 // Author: A.Dainese, andrea.dainese@pd.infn.it
23 /////////////////////////////////////////////////////////////
24
25 #include <TDatabasePDG.h>
26 #include <Riostream.h>
27
28 #include "AliRDHFCutsJpsitoee.h"
29 #include "AliAODRecoDecayHF2Prong.h"
30 #include "AliAODTrack.h"
31 #include "AliESDtrack.h"
32
33 ClassImp(AliRDHFCutsJpsitoee)
34
35 //--------------------------------------------------------------------------
36 AliRDHFCutsJpsitoee::AliRDHFCutsJpsitoee(const char* name) : 
37 AliRDHFCuts(name)
38 {
39   //
40   // Default Constructor
41   //
42   Int_t nvars=9;
43   SetNVars(nvars);
44   TString varNames[9]={"inv. mass [GeV]",   
45                        "dca [cm]",
46                        "cosThetaStar", // negative electron 
47                        "pTP [GeV/c]",
48                        "pTN [GeV/c]",
49                        "d0P [cm]",
50                        "d0N [cm]",
51                        "d0d0 [cm^2]",
52                        "cosThetaPoint"};
53   Bool_t isUpperCut[9]={kTRUE,
54                         kTRUE,
55                         kTRUE,
56                         kFALSE,
57                         kFALSE,
58                         kTRUE,
59                         kTRUE,
60                         kTRUE,
61                         kFALSE};
62   SetVarNames(nvars,varNames,isUpperCut);
63   Bool_t forOpt[9]={kFALSE,
64                     kTRUE,
65                     kTRUE,
66                     kFALSE,
67                     kFALSE,
68                     kFALSE,
69                     kFALSE,
70                     kTRUE,
71                     kTRUE};
72   SetVarsForOpt(4,forOpt);
73   Float_t limits[2]={0,999999999.};
74   SetPtBins(2,limits);
75 }
76 //--------------------------------------------------------------------------
77 AliRDHFCutsJpsitoee::AliRDHFCutsJpsitoee(const AliRDHFCutsJpsitoee &source) :
78   AliRDHFCuts(source)
79 {
80   //
81   // Copy constructor
82   //
83
84 }
85 //--------------------------------------------------------------------------
86 AliRDHFCutsJpsitoee &AliRDHFCutsJpsitoee::operator=(const AliRDHFCutsJpsitoee &source)
87 {
88   //
89   // assignment operator
90   //
91   if(&source == this) return *this;
92
93   AliRDHFCuts::operator=(source);
94
95   return *this;
96 }
97
98
99 //---------------------------------------------------------------------------
100 void AliRDHFCutsJpsitoee::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
101   // 
102   // Fills in vars the values of the variables 
103   //
104
105   if(nvars!=fnVarsForOpt) {
106     printf("AliRDHFCutsJpsitoee::GetCutsVarsForOpt: wrong number of variables\n");
107     return;
108   }
109
110   AliAODRecoDecayHF2Prong *dd = (AliAODRecoDecayHF2Prong*)d;
111  
112   Int_t iter=-1;
113   if(fVarsForOpt[0]){
114     iter++;
115     vars[iter]=dd->InvMassJPSIee();
116   }
117   if(fVarsForOpt[1]){
118     iter++;
119     vars[iter]=dd->GetDCA();
120   }
121   if(fVarsForOpt[2]){
122     iter++;
123     vars[iter] = dd->CosThetaStarJPSI();
124   }
125   if(fVarsForOpt[3]){
126     iter++;
127     if(pdgdaughters[0]==11) vars[iter]=dd->PtProng(0);
128   }
129   if(fVarsForOpt[4]){
130     iter++;
131     if(pdgdaughters[1]==11) vars[iter]=dd->PtProng(1);
132   }
133   if(fVarsForOpt[5]){
134     iter++;
135     vars[iter]=dd->Getd0Prong(0);
136   }
137   if(fVarsForOpt[6]){
138     iter++;
139     vars[iter]=dd->Getd0Prong(1);
140   }
141   if(fVarsForOpt[7]){
142     iter++;
143     vars[iter]= dd->Prodd0d0();
144   }
145   if(fVarsForOpt[8]){
146     iter++;
147     vars[iter]=dd->CosPointingAngle();
148   }
149   
150   return;
151 }
152 //---------------------------------------------------------------------------
153 Int_t AliRDHFCutsJpsitoee::IsSelected(TObject* obj,Int_t selectionLevel) {
154   //
155   // Apply selection
156   //
157
158   if(!fCutsRD){
159     cout<<"Cut matrix not inizialized. Exit..."<<endl;
160     return 0;
161   }
162   //PrintAll();
163   AliAODRecoDecayHF2Prong* d=(AliAODRecoDecayHF2Prong*)obj;
164
165   if(!d){
166     cout<<"AliAODRecoDecayHF2Prong null"<<endl;
167     return 0;
168   }
169
170   if(d->HasBadDaughters()) return 0;
171
172
173   // selection on daughter tracks 
174   if(selectionLevel==AliRDHFCuts::kAll || 
175      selectionLevel==AliRDHFCuts::kTracks) {
176     if(!AreDaughtersSelected(d)) return 0;
177   }
178
179
180   // selection on candidate
181   if(selectionLevel==AliRDHFCuts::kAll || 
182      selectionLevel==AliRDHFCuts::kCandidate) {
183     
184     Double_t pt=d->Pt();
185     Double_t mJPsi,ctsJPsi;
186
187     Double_t mJPSIPDG = TDatabasePDG::Instance()->GetParticle(443)->Mass();
188     
189     Int_t ptbin=PtBin(pt);
190
191     if(d->PtProng(1) < fCutsRD[GetGlobalIndex(3,ptbin)] || d->PtProng(0) < fCutsRD[GetGlobalIndex(4,ptbin)]) return 0;
192
193     if(TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(5,ptbin)] ||
194        TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;
195
196   
197     if(d->GetDCA() > fCutsRD[GetGlobalIndex(1,ptbin)]) return 0;
198
199     mJPsi=d->InvMassJPSIee();
200     if(TMath::Abs(mJPsi-mJPSIPDG)    > fCutsRD[GetGlobalIndex(0,ptbin)]) return 0;
201
202     ctsJPsi=d->CosThetaStarJPSI();
203     if(TMath::Abs(ctsJPsi)    > fCutsRD[GetGlobalIndex(2,ptbin)]) return 0;
204
205     if(d->Prodd0d0() > fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
206     
207     if(d->CosPointingAngle()   < fCutsRD[GetGlobalIndex(8,ptbin)]) return 0;
208   }
209
210   return 1;
211 }
212 //---------------------------------------------------------------------------