]>
Commit | Line | Data |
---|---|---|
809a4336 | 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 | * * | |
17 | * PID Steering Class * | |
18 | * Interface to the user task * | |
19 | * * | |
20 | * Authors: * | |
21 | * Markus Fasel <M.Fasel@gsi.de> * | |
22 | * * | |
23 | ************************************************************************/ | |
24 | #include <TClass.h> | |
25 | #include <TIterator.h> | |
26 | #include <TList.h> | |
27 | #include <TObjArray.h> | |
28 | #include <TObjString.h> | |
29 | #include <TString.h> | |
30 | ||
31 | #include "AliESDtrack.h" | |
32 | ||
33 | #include "AliHFEpid.h" | |
34 | #include "AliHFEpidBase.h" | |
35 | #include "AliHFEpidTPC.h" | |
36 | #include "AliHFEpidTRD.h" | |
37 | #include "AliHFEpidTOF.h" | |
38 | #include "AliHFEpidMC.h" | |
39 | ||
40 | ClassImp(AliHFEpid) | |
41 | ||
42 | //____________________________________________________________ | |
43 | AliHFEpid::AliHFEpid(): | |
44 | fEnabledDetectors(0), | |
45 | fQAlist(0x0) | |
46 | { | |
47 | // | |
48 | // Default constructor | |
49 | // | |
50 | memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID); | |
51 | } | |
52 | ||
53 | //____________________________________________________________ | |
54 | AliHFEpid::AliHFEpid(const AliHFEpid &c): | |
55 | TObject(c), | |
56 | fEnabledDetectors(c.fEnabledDetectors), | |
57 | fQAlist(0x0) | |
58 | { | |
59 | // | |
60 | // Copy Constructor | |
61 | // | |
62 | memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID); | |
63 | if(c.fDetectorPID[kMCpid]) | |
64 | fDetectorPID[kMCpid] = new AliHFEpidMC(*(dynamic_cast<AliHFEpidMC *>(c.fDetectorPID[kMCpid]))); | |
65 | if(c.fDetectorPID[kTPCpid]) | |
66 | fDetectorPID[kTPCpid] = new AliHFEpidTPC(*(dynamic_cast<AliHFEpidTPC *>(c.fDetectorPID[kTPCpid]))); | |
67 | if(c.fDetectorPID[kTRDpid]) | |
68 | fDetectorPID[kTRDpid] = new AliHFEpidTRD(*(dynamic_cast<AliHFEpidTRD *>(c.fDetectorPID[kTOFpid]))); | |
69 | if(c.fDetectorPID[kTOFpid]) | |
70 | fDetectorPID[kTOFpid] = new AliHFEpidTOF(*(dynamic_cast<AliHFEpidTOF *>(c.fDetectorPID[kTOFpid]))); | |
71 | if(c.IsQAOn()) SetQAOn(); | |
72 | if(c.HasMCData()) SetHasMCData(kTRUE); | |
73 | for(Int_t idet = 0; idet < kNdetectorPID; idet++){ | |
74 | if(c.IsQAOn() && fDetectorPID[idet]) fDetectorPID[idet]->SetQAOn(fQAlist); | |
75 | if(c.HasMCData() && fDetectorPID[idet]) fDetectorPID[idet]->SetHasMCData(kTRUE); | |
76 | } | |
77 | } | |
78 | ||
79 | //____________________________________________________________ | |
80 | AliHFEpid& AliHFEpid::operator=(const AliHFEpid &c){ | |
81 | // | |
82 | // Assignment operator | |
83 | // | |
84 | TObject::operator=(c); | |
85 | ||
86 | if(this != &c){ | |
87 | fEnabledDetectors = c.fEnabledDetectors; | |
88 | fQAlist = 0x0; | |
89 | ||
90 | memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID); | |
91 | if(c.fDetectorPID[kMCpid]) | |
92 | fDetectorPID[kMCpid] = new AliHFEpidMC(*(dynamic_cast<AliHFEpidMC *>(c.fDetectorPID[kMCpid]))); | |
93 | if(c.fDetectorPID[kTPCpid]) | |
94 | fDetectorPID[kTPCpid] = new AliHFEpidTPC(*(dynamic_cast<AliHFEpidTPC *>(c.fDetectorPID[kTPCpid]))); | |
95 | if(c.fDetectorPID[kTRDpid]) | |
96 | fDetectorPID[kTRDpid] = new AliHFEpidTRD(*(dynamic_cast<AliHFEpidTRD *>(c.fDetectorPID[kTOFpid]))); | |
97 | if(c.fDetectorPID[kTOFpid]) | |
98 | fDetectorPID[kTOFpid] = new AliHFEpidTOF(*(dynamic_cast<AliHFEpidTOF *>(c.fDetectorPID[kTOFpid]))); | |
99 | if(c.IsQAOn()) SetQAOn(); | |
100 | if(c.HasMCData()) SetHasMCData(kTRUE); | |
101 | for(Int_t idet = 0; idet < kNdetectorPID; idet++){ | |
102 | if(c.IsQAOn() && fDetectorPID[idet]) fDetectorPID[idet]->SetQAOn(fQAlist); | |
103 | if(c.HasMCData() && fDetectorPID[idet]) fDetectorPID[idet]->SetHasMCData(); | |
104 | } | |
105 | } | |
106 | return *this; | |
107 | } | |
108 | ||
109 | //____________________________________________________________ | |
110 | AliHFEpid::~AliHFEpid(){ | |
111 | // | |
112 | // Destructor | |
113 | // | |
114 | if(fQAlist) delete fQAlist; fQAlist = 0x0; // Each detector has to care about its Histograms | |
115 | for(Int_t idet = 0; idet < kNdetectorPID; idet++){ | |
116 | if(fDetectorPID[idet]) delete fDetectorPID[idet]; | |
117 | } | |
118 | } | |
119 | ||
120 | //____________________________________________________________ | |
121 | Bool_t AliHFEpid::InitializePID(TString detectors){ | |
122 | // | |
123 | // Initializes PID Object: | |
124 | // + Defines which detectors to use | |
125 | // + Initializes Detector PID objects | |
126 | // + Handles QA | |
127 | // | |
128 | fDetectorPID[kMCpid] = new AliHFEpidMC("Monte Carlo PID"); // Always there | |
129 | SETBIT(fEnabledDetectors, kMCpid); | |
130 | ||
131 | TObjArray *detsEnabled = detectors.Tokenize(":"); | |
132 | TIterator *detIterator = detsEnabled->MakeIterator(); | |
133 | TObjString *det = 0x0; | |
134 | while((det = dynamic_cast<TObjString *>(detIterator->Next()))){ | |
135 | if(det->String().CompareTo("TPC") == 0){ | |
136 | fDetectorPID[kTPCpid] = new AliHFEpidTPC("TPC PID"); | |
137 | SETBIT(fEnabledDetectors, kTPCpid); | |
138 | } else if(det->String().CompareTo("TRD") == 0){ | |
139 | fDetectorPID[kTRDpid] = new AliHFEpidTRD("TRD PID"); | |
140 | SETBIT(fEnabledDetectors, kTRDpid); | |
141 | } else if(det->String().CompareTo("TOF") == 0){ | |
142 | fDetectorPID[kTOFpid] = new AliHFEpidTOF("TOF PID"); | |
143 | SETBIT(fEnabledDetectors, kTOFpid); | |
144 | } | |
145 | // Here is still space for ESD PID | |
146 | } | |
147 | // Initialize PID Objects | |
148 | Bool_t status = kTRUE; | |
149 | for(Int_t idet = 0; idet < kNdetectorPID; idet++){ | |
150 | if(fDetectorPID[idet]){ | |
151 | status &= fDetectorPID[idet]->InitializePID(); | |
152 | if(IsQAOn() && status) fDetectorPID[idet]->SetQAOn(fQAlist); | |
153 | if(HasMCData() && status) fDetectorPID[idet]->SetHasMCData(); | |
154 | } | |
155 | } | |
156 | return status; | |
157 | } | |
158 | ||
159 | //____________________________________________________________ | |
160 | Bool_t AliHFEpid::IsSelected(AliVParticle *track){ | |
161 | // | |
162 | // Steers PID decision for single detectors respectively combined | |
163 | // PID decision | |
164 | // | |
165 | ||
166 | if(TString(track->IsA()->GetName()).CompareTo("AliMCparticle") == 0){ | |
167 | return (TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track)) == 11); | |
168 | } | |
169 | if(TString(track->IsA()->GetName()).CompareTo("AliESDtrack") == 0){ | |
170 | if(TESTBIT(fEnabledDetectors, kTPCpid) && TESTBIT(fEnabledDetectors, kTOFpid)){ | |
171 | // case TPC-TOF | |
172 | return MakePID_TPC_TOF(dynamic_cast<AliESDtrack *>(track)); | |
173 | } else if(TESTBIT(fEnabledDetectors, kTPCpid)){ | |
174 | return (TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) ==11); | |
175 | } else if(TESTBIT(fEnabledDetectors, kTRDpid)){ | |
176 | return (TMath::Abs(fDetectorPID[kTRDpid]->IsSelected(track)) ==11); | |
177 | } else if(TESTBIT(fEnabledDetectors, kTOFpid)){ | |
178 | return (TMath::Abs(fDetectorPID[kTOFpid]->IsSelected(track)) ==11); | |
179 | } | |
180 | ||
181 | } | |
182 | return kFALSE; | |
183 | } | |
184 | ||
185 | //____________________________________________________________ | |
186 | Bool_t AliHFEpid::MakePID_TPC_TOF(AliESDtrack *track){ | |
187 | // | |
188 | // Combines TPC and TOF PID decision | |
189 | // | |
190 | if(fDetectorPID[kTOFpid]->IsSelected(track)) return fDetectorPID[kTPCpid]->IsSelected(track); | |
191 | return kFALSE; | |
192 | } | |
193 | ||
194 | //____________________________________________________________ | |
195 | void AliHFEpid::SetQAOn(){ | |
196 | // | |
197 | // Switch on QA | |
198 | // | |
199 | SetBit(kIsQAOn); | |
200 | fQAlist = new TList; | |
201 | fQAlist->SetName("PIDqa"); | |
202 | } | |
203 | ||
204 | void AliHFEpid::SetMCEvent(AliMCEvent *event){ | |
205 | for(Int_t idet = 0; idet < kNdetectorPID; idet++) | |
206 | if(fDetectorPID[idet]) fDetectorPID[idet]->SetMCEvent(event); | |
207 | } |