]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliHFEpidTOF.cxx
Coverity
[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(fSigmaBordersTOF, 0, sizeof(Float_t) * 2);
49
50
51 //___________________________________________________________________
52 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
53   AliHFEpidBase(name)
54   , fNsigmaTOF(3)
55 {
56   //
57   // Constructor
58   //
59
60   memset(fSigmaBordersTOF, 0, sizeof(Float_t) * 2);
61
62 }
63
64 //___________________________________________________________________
65 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
66   AliHFEpidBase("")
67   , fNsigmaTOF(3)
68 {  
69   // 
70   // Copy operator
71   //
72
73   c.Copy(*this);
74 }
75 //___________________________________________________________________
76 AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){
77   //
78   // Assignment operator
79   //
80
81   if(this != &ref){
82     ref.Copy(*this);
83   }
84
85   return *this;
86 }
87 //___________________________________________________________________
88 AliHFEpidTOF::~AliHFEpidTOF(){
89   //
90   // Destructor
91   //
92 }
93 //___________________________________________________________________
94 void AliHFEpidTOF::Copy(TObject &ref) const {
95   //
96   // Performs the copying of the object
97   //
98   AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
99
100   target.fNsigmaTOF = fNsigmaTOF;
101   memcpy(target.fSigmaBordersTOF, fSigmaBordersTOF, sizeof(Float_t) * 2);
102
103   AliHFEpidBase::Copy(ref);
104 }
105 //___________________________________________________________________
106 Bool_t AliHFEpidTOF::InitializePID(Int_t /*run*/){
107   //
108   // InitializePID: TOF experts have to implement code here
109   //
110   return kTRUE;
111 }
112
113 //___________________________________________________________________
114 Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const
115 {
116   //
117   // TOF PID based on n-Sigma cut
118   // Selects Protons and Kaons via n-sigma cut up to 3 GeV/c
119   // In addition histos for n-sigma before (all species) and after (only closest species) are filled
120   //
121   if(!fkPIDResponse) return 0;
122   AliDebug(2, "PID object available");
123
124   const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
125   if(!(vtrack && (vtrack->GetStatus() & AliESDtrack::kTOFpid))) return 0;
126   AliDebug(2, "Track Has TOF PID");
127
128   if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
129
130   // Fill before selection
131   Double_t sigEle = fkPIDResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron);
132   AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle));
133   Int_t pdg = 0;
134   if(TestBit(kSigmaBand)){
135     // Lower and Upper cut separate
136     if(sigEle > fSigmaBordersTOF[0] && sigEle < fSigmaBordersTOF[1]) pdg = 11;
137   } else {
138     // Fixed nsigma cut
139     if(TMath::Abs(sigEle) < fNsigmaTOF) pdg = 11;
140   }
141
142   if(pdg == 11 && pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID);
143  
144   return pdg;
145 }
146