1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 /************************************************************************
17 * PID Steering Class *
18 * Interface to the user task *
21 * Markus Fasel <M.Fasel@gsi.de> *
23 ************************************************************************/
25 #include <TIterator.h>
27 #include <TObjArray.h>
28 #include <TObjString.h>
31 #include "AliESDtrack.h"
33 #include "AliHFEpid.h"
34 #include "AliHFEpidBase.h"
35 #include "AliHFEpidTPC.h"
36 #include "AliHFEpidTRD.h"
37 #include "AliHFEpidTOF.h"
38 #include "AliHFEpidMC.h"
42 //____________________________________________________________
43 AliHFEpid::AliHFEpid():
48 // Default constructor
50 memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID);
53 //____________________________________________________________
54 AliHFEpid::AliHFEpid(const AliHFEpid &c):
56 fEnabledDetectors(c.fEnabledDetectors),
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);
79 //____________________________________________________________
80 AliHFEpid& AliHFEpid::operator=(const AliHFEpid &c){
82 // Assignment operator
84 TObject::operator=(c);
87 fEnabledDetectors = c.fEnabledDetectors;
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();
109 //____________________________________________________________
110 AliHFEpid::~AliHFEpid(){
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];
120 //____________________________________________________________
121 Bool_t AliHFEpid::InitializePID(TString detectors){
123 // Initializes PID Object:
124 // + Defines which detectors to use
125 // + Initializes Detector PID objects
128 fDetectorPID[kMCpid] = new AliHFEpidMC("Monte Carlo PID"); // Always there
129 SETBIT(fEnabledDetectors, kMCpid);
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);
145 // Here is still space for ESD PID
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();
159 //____________________________________________________________
160 Bool_t AliHFEpid::IsSelected(AliVParticle *track){
162 // Steers PID decision for single detectors respectively combined
166 if(TString(track->IsA()->GetName()).CompareTo("AliMCparticle") == 0){
167 return (TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track)) == 11);
169 if(TString(track->IsA()->GetName()).CompareTo("AliESDtrack") == 0){
170 if(TESTBIT(fEnabledDetectors, kTPCpid) && TESTBIT(fEnabledDetectors, kTOFpid)){
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);
185 //____________________________________________________________
186 Bool_t AliHFEpid::MakePID_TPC_TOF(AliESDtrack *track){
188 // Combines TPC and TOF PID decision
190 if(fDetectorPID[kTOFpid]->IsSelected(track)) return fDetectorPID[kTPCpid]->IsSelected(track);
194 //____________________________________________________________
195 void AliHFEpid::SetQAOn(){
201 fQAlist->SetName("PIDqa");
204 void AliHFEpid::SetMCEvent(AliMCEvent *event){
205 for(Int_t idet = 0; idet < kNdetectorPID; idet++)
206 if(fDetectorPID[idet]) fDetectorPID[idet]->SetMCEvent(event);