]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliHFEpidTOF.cxx
Updates for TRD HFE analysis
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEpidTOF.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 // Class for TOF PID
17 // Implements the abstract base class AliHFEpidBase
18 // IsInitialized() does the PID decision
19 // 
20 // Authors:
21 //   Markus Fasel  <M.Fasel@gsi.de>
22 //   Matus Kalisky <matus.kalisky@cern.ch>  (contact)
23 //
24
25 #include <TMath.h>
26
27 #include "AliAODTrack.h"
28 #include "AliESDtrack.h"
29 #include "AliPID.h"
30 #include "AliPIDResponse.h"
31
32 #include "AliHFEdetPIDqa.h"
33 #include "AliHFEpidTOF.h"
34 #include "AliHFEpidQAmanager.h"
35
36
37 ClassImp(AliHFEpidTOF)
38
39 //___________________________________________________________________
40 AliHFEpidTOF::AliHFEpidTOF():
41   AliHFEpidBase()
42   , fNsigmaTOF(3)
43 {
44   //
45   // Constructor
46   //
47   
48   memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12);
49   memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12);
50
51
52 //___________________________________________________________________
53 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
54   AliHFEpidBase(name)
55   , fNsigmaTOF(3)
56 {
57   //
58   // Constructor
59   //
60   memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12);
61   memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12);
62
63 }
64
65 //___________________________________________________________________
66 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
67   AliHFEpidBase("")
68   , fNsigmaTOF(3)
69 {  
70   // 
71   // Copy operator
72   //
73
74   c.Copy(*this);
75 }
76 //___________________________________________________________________
77 AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){
78   //
79   // Assignment operator
80   //
81
82   if(this != &ref){
83     ref.Copy(*this);
84   }
85
86   return *this;
87 }
88 //___________________________________________________________________
89 AliHFEpidTOF::~AliHFEpidTOF(){
90   //
91   // Destructor
92   //
93 }
94 //___________________________________________________________________
95 void AliHFEpidTOF::Copy(TObject &ref) const {
96   //
97   // Performs the copying of the object
98   //
99   AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
100
101   target.fNsigmaTOF = fNsigmaTOF;
102   memcpy(target.fSigmaBordersTOFLower, fSigmaBordersTOFLower, sizeof(Float_t) * 12);
103   memcpy(target.fSigmaBordersTOFUpper, fSigmaBordersTOFUpper, sizeof(Float_t) * 12);
104
105   AliHFEpidBase::Copy(ref);
106 }
107 //___________________________________________________________________
108 Bool_t AliHFEpidTOF::InitializePID(Int_t /*run*/){
109   //
110   // InitializePID: TOF experts have to implement code here
111   //
112   return kTRUE;
113 }
114
115 //___________________________________________________________________
116 Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const
117 {
118   //
119   // TOF PID based on n-Sigma cut
120   // Selects Protons and Kaons via n-sigma cut up to 3 GeV/c
121   // In addition histos for n-sigma before (all species) and after (only closest species) are filled
122   //
123   if(!fkPIDResponse) return 0;
124   AliDebug(2, "PID object available");
125
126   const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
127   if(!(vtrack && (vtrack->GetStatus() & AliESDtrack::kTOFpid))) return 0;
128   AliDebug(2, "Track Has TOF PID");
129
130   if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
131
132   // Fill before selection
133   Double_t sigEle = fkPIDResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron);
134   AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle));
135   Int_t pdg = 0;
136   if(TestBit(kSigmaBand)){
137     Int_t centrality = track->IsPbPb() ? track->GetCentrality() + 1 : 0;
138     AliDebug(2, Form("Centrality: %d\n", centrality));
139     if(centrality > 11) return kFALSE;
140     if(sigEle > fSigmaBordersTOFLower[centrality] && sigEle < fSigmaBordersTOFUpper[centrality]) pdg = 11;
141   } else {
142     // Fixed nsigma cut
143     if(TMath::Abs(sigEle) < fNsigmaTOF) pdg = 11;
144   }
145
146   if(pdg == 11 && pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID);
147  
148   return pdg;
149 }
150 //___________________________________________________________________
151 void AliHFEpidTOF::SetTOFnSigmaBand(Float_t lower, Float_t upper)
152 {
153   //
154   // Lower and higher cut independant of the centrality
155   //
156
157   for(Int_t k=0; k < 12; k++) {
158     fSigmaBordersTOFLower[k] = lower;
159     fSigmaBordersTOFUpper[k] = upper;
160   }
161
162   SetBit(kSigmaBand, kTRUE);
163
164 }
165 //___________________________________________________________________
166 void AliHFEpidTOF::SetTOFnSigmaBandCentrality(Float_t lower, Float_t upper, Int_t centralityBin)
167 {
168   //
169   // Lower and higher cut as function of centrality
170   //
171
172   if(centralityBin < 11) {
173     fSigmaBordersTOFLower[centralityBin+1] = lower;
174     fSigmaBordersTOFUpper[centralityBin+1] = upper;
175   }
176
177   SetBit(kSigmaBand, kTRUE);
178
179 }
180