]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/EBYE/PIDFluctuation/task/AliEbyEPidRatioDCA.cxx
Minor fix pr task: sjena
[u/mrichter/AliRoot.git] / PWGCF / EBYE / PIDFluctuation / task / AliEbyEPidRatioDCA.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: ALICE Offline.                                                 *
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
17 //=========================================================================//
18 //             AliEbyE Analysis for Particle Ratio Fluctuation             //
19 //                   Deepika Rathee  | Satyajit Jena                       //
20 //                   drathee@cern.ch | sjena@cern.ch                       //
21 //                  Date: Wed Jul  9 18:38:30 CEST 2014                    //
22 //          New approch to find particle ratio to reduce memory            //
23 //                             (Test Only)                                 //
24 //=========================================================================//
25
26 #include "TMath.h"
27 #include "TAxis.h"
28
29 #include "AliESDEvent.h"
30 #include "AliStack.h"
31 #include "AliMCEvent.h"
32 #include "AliESDtrackCuts.h"
33
34 #include "AliAODEvent.h"
35 #include "AliAODMCParticle.h"
36
37 #include "AliEbyEPidRatioDCA.h"
38
39 using namespace std;
40
41 ClassImp(AliEbyEPidRatioDCA)
42
43 //________________________________________________________________________
44 AliEbyEPidRatioDCA::AliEbyEPidRatioDCA() :
45   AliEbyEPidRatioBase("DCA", "DCA"),
46   fESDTrackCutsBkg(NULL),
47   fHnDCA(NULL) {
48   // Constructor   
49
50
51   AliLog::SetClassDebugLevel("AliEbyEPidRatioDCA",10);
52 }
53
54 //________________________________________________________________________
55 AliEbyEPidRatioDCA::~AliEbyEPidRatioDCA() {
56   // Destructor
57 }
58
59 //________________________________________________________________________
60 void AliEbyEPidRatioDCA::Process() {
61    Float_t etaRange[2];
62   fESDTrackCutsBkg->GetEtaRange(etaRange[0],etaRange[1]);
63
64   Float_t ptRange[2];
65   fESDTrackCutsBkg->GetPtRange(ptRange[0],ptRange[1]); 
66
67   // -- Track Loop
68   for (Int_t idxTrack = 0; idxTrack < fNTracks; ++idxTrack) {
69     
70     AliVTrack *track = (fESD) ? static_cast<AliVTrack*>(fESD->GetTrack(idxTrack)) : static_cast<AliVTrack*>(fAOD->GetTrack(idxTrack)); 
71
72     // -- Check if track is accepted for basic parameters
73     if (!fHelper->IsTrackAcceptedBasicCharged(track))
74       continue;
75     
76     // -- Check if accepted - ESD
77     if (fESD && !fESDTrackCutsBkg->AcceptTrack(dynamic_cast<AliESDtrack*>(track)))
78       continue;
79     
80     // -- Check if accepted - AOD
81     if (fAOD){
82       AliAODTrack * trackAOD = dynamic_cast<AliAODTrack*>(track);
83       
84       if (!trackAOD) {
85         AliError("Pointer to dynamic_cast<AliAODTrack*>(track) = ZERO");
86         continue;
87       }
88       if (!trackAOD->TestFilterBit(fAODtrackCutBit))
89         continue;
90
91       // -- Check if in pT and eta range (is done in ESDTrackCuts for ESDs)
92       if(!(track->Pt() > ptRange[0] && track->Pt() <= ptRange[1] && TMath::Abs(track->Eta()) <= etaRange[1]))
93         continue;
94     }
95
96     Int_t gPdgCode = 0;
97     Int_t iPid = 0;
98     Double_t pid[3];
99     if      (fHelper->IsTrackAcceptedPID(track, pid, (AliPID::kPion)))  {  iPid = 1; gPdgCode = 211;}
100     else if (fHelper->IsTrackAcceptedPID(track, pid, (AliPID::kKaon)))  {  iPid = 2; gPdgCode = 321;}
101     else if (fHelper->IsTrackAcceptedPID(track, pid, (AliPID::kProton))){  iPid = 3; gPdgCode = 2212;}
102     else { iPid = 0; gPdgCode = 0;}
103
104     //  cout << " --- DCA ---- " << iPid << "  " << gPdgCode << endl;
105     Double_t yP;
106     if (!fHelper->IsTrackAcceptedRapidity(track, yP, iPid))
107       continue;
108   
109     Bool_t isDCArAccepted = fHelper->IsTrackAcceptedDCA(track);
110
111     // -- Check if accepted with thighter DCA cuts
112     // ?!?!? How to mimic this in AODs?
113     if (fESD && !fESDTrackCuts->AcceptTrack(dynamic_cast<AliESDtrack*>(track)))
114       isDCArAccepted = kFALSE;
115     
116     // -- Check for contamination 
117     Int_t contIdx = (fIsMC) ? GetContIdxTrack(TMath::Abs(track->GetLabel()), track->Charge(), gPdgCode) : 1;
118     
119     // -- Get DCAs (dca_r, dca_z, sigma_xy, sigma_xy_z, sigma_z)
120     Float_t dca[2], cov[3]; // 
121     if (fESD)
122       (dynamic_cast<AliESDtrack*>(track))->GetImpactParameters(dca, cov);
123     else 
124       dca[0] = 1.; 
125
126     // -- Fill THnSparse 
127     
128     if(iPid != 0) {   
129       Double_t hnDCA[10] = {fCentralityBin,0,  track->Charge(), 
130                             track->Eta(), 
131                             yP, 
132                             track->Phi(), 
133                             track->Pt(), 
134                             contIdx,
135                             isDCArAccepted, 
136                             dca[0]};
137       fHnDCA->Fill(hnDCA);
138     }      
139     
140     Double_t hnDCA[10] = {fCentralityBin, iPid, track->Charge(), 
141                           track->Eta(), 
142                           yP, 
143                           track->Phi(), 
144                           track->Pt(), 
145                           contIdx,
146                           isDCArAccepted, 
147                           dca[0]};
148       fHnDCA->Fill(hnDCA);
149
150
151     } // for (Int_t idxTrack = 0; idxTrack < fNTracks; ++idxTrack) {
152
153   return;
154 }      
155
156 //________________________________________________________________________
157 void AliEbyEPidRatioDCA::CreateHistograms() {
158   Int_t    binHnDCA[10] = {AliEbyEPidRatioHelper::fgkfHistNBinsCent,4,
159                            AliEbyEPidRatioHelper::fgkfHistNBinsSign,      
160                            AliEbyEPidRatioHelper::fgkfHistNBinsEta,       
161                            AliEbyEPidRatioHelper::fgkfHistNBinsRap,  
162                            AliEbyEPidRatioHelper::fgkfHistNBinsPhi,        
163                            AliEbyEPidRatioHelper::fgkfHistNBinsPt,   
164                            4,  2,  77};      
165   
166   Double_t minHnDCA[10] = {AliEbyEPidRatioHelper::fgkfHistRangeCent[0],-0.5, 
167                            AliEbyEPidRatioHelper::fgkfHistRangeSign[0], 
168                            AliEbyEPidRatioHelper::fgkfHistRangeEta[0], 
169                            AliEbyEPidRatioHelper::fgkfHistRangeRap[0],  
170                            AliEbyEPidRatioHelper::fgkfHistRangePhi[0], 
171                            AliEbyEPidRatioHelper::fgkfHistRangePt[0],   
172                            0.5, -0.5, -3.};
173   
174   Double_t maxHnDCA[10] = {AliEbyEPidRatioHelper::fgkfHistRangeCent[1],3.5,
175                            AliEbyEPidRatioHelper::fgkfHistRangeSign[1], 
176                            AliEbyEPidRatioHelper::fgkfHistRangeEta[1], 
177                            AliEbyEPidRatioHelper::fgkfHistRangeRap[1],  
178                            AliEbyEPidRatioHelper::fgkfHistRangePhi[1], 
179                            AliEbyEPidRatioHelper::fgkfHistRangePt[1],   
180                            4.5, 1.5, 3.};
181
182
183   fHnDCA = new THnSparseD("hnDCA", "cent:pid:etaRec:yRec:phiRec:ptRec:sign:contPart:contSign:DCArAccepted:DCAr", 10, binHnDCA, minHnDCA, maxHnDCA);
184   
185   fHnDCA->Sumw2();
186
187   fHnDCA->GetAxis(0)->SetTitle("centrality");                   //  0-5|5-10|10-20|20-30|30-40|40-50|50-60|60-70|70-80|80-90 --> 10 bins
188   fHnDCA->GetAxis(1)->SetTitle("N_{ch}|N_{#pi}|N_{K}|N_{p}");   //  0 | 1 | 2 | 3 
189   fHnDCA->GetAxis(2)->SetTitle("sign");                         //  -1 | 0 | +1 
190   fHnDCA->GetAxis(3)->SetTitle("#eta_{Rec}");                   //  eta  [-0.9, 0.9]
191   fHnDCA->GetAxis(4)->SetTitle("#it{y}_{Rec}");                 //  rapidity  [-0.5, 0.5]
192   fHnDCA->GetAxis(5)->SetTitle("#varphi_{Rec} (rad)");          //  phi  [ 0. , 2Pi]
193   fHnDCA->GetAxis(6)->SetTitle("#it{p}_{T,Rec} (GeV/#it{c})");  //  pT   [ 0.2, 2.6]
194   fHnDCA->GetAxis(7)->SetTitle("contPart");                     //  1  primary | 2 missId | 3 from WeakDecay | 4 p from Material
195   fHnDCA->GetAxis(8)->SetTitle("DCArAccepted");                 //  0 not accepted | 1 accepted 
196   fHnDCA->GetAxis(9)->SetTitle("DCAr");                         //  DCAr [-3, 3]
197
198
199   fHelper->BinLogAxis(fHnDCA,  6, fESDTrackCuts);
200   fHelper->BinLogAxis(fHnDCA,  6, fESDTrackCutsBkg);
201
202   // -- Set binning for DCAr
203   Double_t binsDCAr[77] = {-3.,-2.85,-2.7,-2.55,-2.4,-2.25,-2.1,-1.95,-1.8,-1.65,-1.5,-1.35,-1.2,-1.05,-0.9,-0.75,-0.6,-0.45,-0.3,-0.285,-0.27,-0.255,-0.24,-0.225,-0.21,-0.195,-0.18,-0.165,-0.15,-0.135,-0.12,-0.105,-0.09,-0.075,-0.06,-0.045,-0.03,-0.015,0.,0.015,0.03,0.045,0.06,0.075,0.09,0.105,0.12,0.135,0.15,0.165,0.18,0.195,0.21,0.225,0.24,0.255,0.27,0.285,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.5,1.65,1.8,1.95,2.1,2.25,2.4,2.55,2.7,2.85,3.};
204   fHnDCA->GetAxis(9)->Set(76, binsDCAr);
205
206   // ------------------------------------------------------------------
207   
208   return;
209 }
210
211 //________________________________________________________________________
212 Int_t AliEbyEPidRatioDCA::GetContIdxTrack(Int_t label, Int_t sign, Int_t gPdgCode) {
213   Int_t contIdx = -1;
214
215   AliVParticle* particle = (fESD) ? fMCEvent->GetTrack(label) : static_cast<AliVParticle*>(fArrayMC->At(label));
216   if (!particle)
217     return contIdx;
218
219   Bool_t isPhysicalPrimary        = (fESD) ? fStack->IsPhysicalPrimary(label): (static_cast<AliAODMCParticle*>(particle))->IsPhysicalPrimary();
220   Bool_t isSecondaryFromWeakDecay = (fESD) ? fStack->IsSecondaryFromWeakDecay(label) : (static_cast<AliAODMCParticle*>(particle))->IsSecondaryFromWeakDecay();
221   Bool_t isSecondaryFromMaterial  = (fESD) ? fStack->IsSecondaryFromMaterial(label)  : (static_cast<AliAODMCParticle*>(particle))->IsSecondaryFromMaterial();
222   
223   if (isPhysicalPrimary) {
224     if (gPdgCode == 0) {
225       // -- Check if correctly identified 
226       if (particle->PdgCode() == (sign*gPdgCode))
227         contIdx = 1;   
228       // -- MissIdentification
229       else 
230         contIdx = 2;
231     }
232     else
233       contIdx = 1;   
234   }
235
236   // -- Check if secondaries from material or weak decay
237   else if(isSecondaryFromWeakDecay)
238     contIdx = 3;
239   else if (isSecondaryFromMaterial)
240     contIdx = 4;
241   else
242     contIdx = -1;
243
244   return contIdx;
245 }
246
247
248