]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEpid.cxx
Minor fix for software triggers.
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEpid.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 // PID Steering Class 
17 // Interface to the user task
18 // Several strategies for Electron identification implemented.
19 // In addition users can combine different detectors or use
20 // single detector PID
21 // 
22 // Authors:
23 //   Markus Fasel <M.Fasel@gsi.de>
24 //
25 #include <TAxis.h>
26 #include <TClass.h>
27 #include <TF1.h>
28 #include <THnSparse.h>
29 #include <TIterator.h>
30 #include <TList.h>
31 #include <TObjArray.h>
32 #include <TObjString.h>
33 #include <TString.h>
34
35 #include "AliESDpid.h"
36 #include "AliESDtrack.h"
37 #include "AliLog.h"
38 #include "AliPID.h"
39
40 #include "AliHFEpid.h"
41 #include "AliHFEpidBase.h"
42 #include "AliHFEpidITS.h"
43 #include "AliHFEpidTPC.h"
44 #include "AliHFEpidTRD.h"
45 #include "AliHFEpidTOF.h"
46 #include "AliHFEpidMC.h"
47
48 ClassImp(AliHFEpid)
49
50 //____________________________________________________________
51 AliHFEpid::AliHFEpid():
52   TNamed(),
53   fEnabledDetectors(0),
54   fPIDstrategy(kUndefined),
55   fQAlist(0x0),
56   fDebugLevel(0),
57   fCommonObjects(NULL)
58 {
59   //
60   // Default constructor
61   //
62   memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID);
63 }
64
65 //____________________________________________________________
66 AliHFEpid::AliHFEpid(const Char_t *name):
67   TNamed(name, ""),
68   fEnabledDetectors(0),
69   fPIDstrategy(kUndefined),
70   fQAlist(NULL),
71   fDebugLevel(0),
72   fCommonObjects(NULL)
73 {
74   //
75   // Default constructor
76   // Create PID objects for all detectors
77   //
78   memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID);
79   fDetectorPID[kMCpid] = new AliHFEpidMC("MCPID");
80   fDetectorPID[kTPCpid] = new AliHFEpidTPC("TRDPID");
81   fDetectorPID[kTRDpid] = new AliHFEpidTRD("TRDPID");
82   fDetectorPID[kTOFpid] = new AliHFEpidTOF("TOFPID");
83
84 }
85
86 //____________________________________________________________
87 AliHFEpid::AliHFEpid(const AliHFEpid &c):
88   TNamed(c),
89   fEnabledDetectors(c.fEnabledDetectors),
90   fPIDstrategy(kUndefined),
91   fQAlist(NULL),
92   fDebugLevel(c.fDebugLevel),
93   fCommonObjects(NULL)
94 {
95   //
96   // Copy Constructor
97   //
98   memset(fDetectorPID, 0, sizeof(AliHFEpidBase *) * kNdetectorPID);
99   c.Copy(*this);
100 }
101
102 //____________________________________________________________
103 AliHFEpid& AliHFEpid::operator=(const AliHFEpid &c){
104   //
105   // Assignment operator
106   //
107   if(&c != this) c.Copy(*this);
108   return *this;
109 }
110
111 //____________________________________________________________
112 AliHFEpid::~AliHFEpid(){
113   //
114   // Destructor
115   //
116   for(Int_t idet = 0; idet < kNdetectorPID; idet++)
117     if(fDetectorPID[idet]) delete fDetectorPID[idet];
118   if(fQAlist) delete fQAlist; fQAlist = NULL;  // Each detector has to care about its Histograms
119   ClearCommonObjects();
120 }
121
122 //____________________________________________________________
123 void AliHFEpid::Copy(TObject &o) const{
124   //
125   // Make copy
126   //
127   
128   TNamed::Copy(o);
129   AliHFEpid &target = dynamic_cast<AliHFEpid &>(o);
130   target.ClearCommonObjects();
131
132   target.fEnabledDetectors = fEnabledDetectors;
133   target.fPIDstrategy = fPIDstrategy;
134   if(target.fQAlist){
135     delete target.fQAlist; target.fQAlist = NULL;
136   }
137   if(fQAlist) target.fQAlist = new TList;
138   target.fQAlist = 0x0;
139   target.fDebugLevel = fDebugLevel;
140  
141   // Copy detector PIDs
142   for(Int_t idet = 0; idet < kNdetectorPID; idet++){
143     //Cleanup pointers in case of assignment
144     if(target.fDetectorPID[idet])  
145       delete target.fDetectorPID[idet];     
146     if(fDetectorPID[idet]) 
147       target.fDetectorPID[idet] = dynamic_cast<AliHFEpidBase *>(fDetectorPID[idet]->Clone());
148   }
149 }
150
151 //____________________________________________________________
152 void AliHFEpid::AddCommonObject(TObject * const o){
153   //
154   // Add common object to the garbage collection
155   //
156   if(!fCommonObjects) fCommonObjects = new TObjArray;
157   fCommonObjects->Add(o);
158 }
159
160 //____________________________________________________________
161 void AliHFEpid::ClearCommonObjects(){
162   //
163   // empty garbage collection
164   //
165   if(fCommonObjects){
166     fCommonObjects->Delete();
167     delete fCommonObjects;
168     fCommonObjects = NULL;
169   }
170 }
171
172 //____________________________________________________________
173 Bool_t AliHFEpid::InitializePID(TString arg){
174   //
175   // Initializes PID Object:
176   // + Defines which detectors to use
177   // + Initializes Detector PID objects
178   // + Handles QA
179   //
180   
181   Bool_t initFail = kFALSE;
182   if(arg.BeginsWith("Strategy")){
183     // Initialize detector PIDs according to PID Strategies
184     arg.ReplaceAll("Strategy", "");
185     fPIDstrategy = arg.Atoi();
186     AliDebug(1, Form("%s - PID Strategy %d enabled", GetName(), fPIDstrategy));
187     switch(fPIDstrategy){
188       case 0: SwitchOnDetector(kMCpid); break;    // Pure MC PID - only valid in MC mode
189       case 1: InitStrategy1(); break;
190       case 2: InitStrategy2(); break;
191       case 3: InitStrategy3(); break;
192       case 4: InitStrategy4(); break;
193       case 5: InitStrategy5(); break;
194       case 6: InitStrategy6(); break;
195       case 7: InitStrategy7(); break;
196       case 8: InitStrategy8(); break;
197       default: initFail = kFALSE;
198     }
199   } else {
200     // No Strategy defined, Initialize according to detectors specified
201     AliDebug(1, Form("%s - Doing InitializePID for Detectors %s end", GetName(), arg.Data()));
202   
203     TObjArray *detsEnabled = arg.Tokenize(":");
204     TIterator *detIterator = detsEnabled->MakeIterator();
205     TObjString *det = NULL;
206     Int_t detector = -1;
207     TString detectors[kNdetectorPID] = {"MC", "ESD", "ITS", "TPC", "TRD", "TOF"};
208     Int_t nDetectors = 0;
209     while((det = dynamic_cast<TObjString *>(detIterator->Next()))){
210       TString &detstring = det->String();
211       detector = -1;
212       for(Int_t idet = 0; idet < kNdetectorPID; idet++){
213         if(!detstring.CompareTo(detectors[idet])){
214           detector = idet;
215           break;
216         }
217       }
218       if(detector > -1){
219         SwitchOnDetector(detector);
220         nDetectors++;
221       } else AliError(Form("Detector %s not implemented (yet)", detstring.Data()));
222     }
223     if(!nDetectors) initFail = kTRUE;
224   }
225   if(initFail){
226     AliError("Initializaion of the PID Failed");
227     return kFALSE;
228   }
229
230   // Initialize PID Objects
231   Bool_t status = kTRUE;
232   for(Int_t idet = 0; idet < kNdetectorPID; idet++){
233     if(!IsDetectorOn(idet)) continue;
234     if(fDetectorPID[idet]){ 
235       status &= fDetectorPID[idet]->InitializePID();
236       if(IsQAOn() && status) fDetectorPID[idet]->SetQAOn(fQAlist);
237       if(HasMCData() && status) fDetectorPID[idet]->SetHasMCData();
238     }
239   }
240   PrintStatus();
241   return status;
242   AliDebug(1, Form("%s - Done", GetName()));
243 }
244
245 //____________________________________________________________
246 Bool_t AliHFEpid::IsSelected(AliHFEpidObject *track){
247   //
248   // Steers PID decision for single detectors respectively combined
249   // PID decision
250   //
251   if(!track->fRecTrack){
252     // MC Event
253     return (TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track)) == 11);
254   }
255   if(fPIDstrategy < 9){
256     AliDebug(1, Form("%s - PID Strategy %d", GetName(), fPIDstrategy));
257     Int_t pid = 0;
258     switch(fPIDstrategy){
259       case 0: pid = IdentifyStrategy0(track); break;
260       case 1: pid = IdentifyStrategy1(track); break;
261       case 2: pid = IdentifyStrategy2(track); break;
262       case 3: pid = IdentifyStrategy3(track); break;
263       case 4: pid = IdentifyStrategy4(track); break;
264       case 5: pid = IdentifyStrategy5(track); break;
265       case 6: pid = IdentifyStrategy6(track); break;
266       case 7: pid = IdentifyStrategy7(track); break;
267       case 8: pid = IdentifyStrategy8(track); break;
268       default: break;
269     }
270     return pid;
271   }
272   if(TESTBIT(fEnabledDetectors, kTPCpid)){
273     if(IsQAOn() && fDebugLevel > 1){ 
274       AliInfo("Filling QA plots");
275       MakePlotsItsTpc(track);  // First fill the QA histograms
276     }
277     if(TESTBIT(fEnabledDetectors, kTOFpid)){
278       // case TPC-TOF
279       return MakePidTpcTof(track);
280     } else if(TESTBIT(fEnabledDetectors, kTRDpid)){
281       // case TPC-TRD with low level detector Signals
282       return MakePidTpcTrd(track);
283     } else
284       return (TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) ==11);
285   } else if(TESTBIT(fEnabledDetectors, kTRDpid)){
286     return (TMath::Abs(fDetectorPID[kTRDpid]->IsSelected(track)) ==11);
287   } else if(TESTBIT(fEnabledDetectors, kTOFpid)){
288     return (TMath::Abs(fDetectorPID[kTOFpid]->IsSelected(track)) ==11);
289   }
290   
291   return kFALSE;
292 }
293
294 //____________________________________________________________
295 Bool_t AliHFEpid::MakePidTpcTof(AliHFEpidObject *track){
296   //
297   // Combines TPC and TOF PID decision
298   //
299   if(track->fAnalysisType != AliHFEpidObject::kESDanalysis) return kFALSE;
300
301   AliHFEpidTOF *tofPID = dynamic_cast<AliHFEpidTOF*>(fDetectorPID[kTOFpid]);
302   if(!tofPID){
303     AliWarning("TOF pid object is NULL");
304     return kFALSE;
305   }
306
307   AliHFEpidTPC *tpcPID = dynamic_cast<AliHFEpidTPC*>(fDetectorPID[kTPCpid]);
308   if(!tpcPID){
309     AliWarning("TPC pid object is NULL");
310     return kFALSE;
311   }
312   
313   // Use TOF PID to select particles with a sigma to the electron line > defined in initialize PID
314   if(TMath::Abs(tofPID->IsSelected(track)) != 11) return kFALSE;
315   // request TOF PID information, reject if no TOF information is available or if TOF identified as Proton or Kaon
316   // apply cut only up to certain upper momentum cut
317   /*Int_t pidTOF = tofPID->IsSelected(track);
318   Bool_t isRejected = kFALSE;
319   switch(TMath::Abs(pidTOF)){
320     case 321:   if(track->fRecTrack->P() < 1.5) isRejected = kTRUE; break;
321     case 2212:  if(track->fRecTrack->P() < 3) isRejected = kTRUE; break;
322     case 0:     if(track->fRecTrack->P() < 3) isRejected = kTRUE; break;  // No TOF information available
323     default: break;
324   };
325   if(isRejected) return kFALSE;*/
326
327   // Particle passed TOF, let TPC decide, no line crossings defined anymore
328  
329   // request the tpc PID information
330   return (TMath::Abs(tpcPID->IsSelected(track)) == 11);
331 }
332
333 //____________________________________________________________
334 Bool_t AliHFEpid::MakePidTpcTrd(AliHFEpidObject *track){
335   //
336   // Combination of TPC and TRD PID
337   // Fills Histograms TPC Signal vs. TRD signal for different
338   // momentum slices
339   //
340   if(track->fAnalysisType != AliHFEpidObject::kESDanalysis) return kFALSE; //AOD based detector PID combination not yet implemented
341   AliDebug(1, "Analysis Type OK, do PID");
342   AliESDtrack *esdTrack = dynamic_cast<AliESDtrack *>(track->fRecTrack);
343   AliHFEpidTRD *trdPid = dynamic_cast<AliHFEpidTRD *>(fDetectorPID[kTRDpid]);
344   Int_t pdg = TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track));
345   Int_t pid = -1;
346   switch(pdg){
347     case 11:    pid = AliPID::kElectron; break;
348     case 13:    pid = AliPID::kMuon; break;
349     case 211:   pid = AliPID::kPion; break;
350     case 321:   pid = AliPID::kKaon; break;
351     case 2212:  pid = AliPID::kProton; break;
352     default:    pid = -1;
353   };
354   Double_t content[10];
355   content[0] = pid;
356   content[1] = esdTrack->P();
357   content[2] = esdTrack->GetTPCsignal();
358   content[3] = trdPid->GetTRDSignalV1(esdTrack, pid);
359   if(IsQAOn() && fDebugLevel > 1){
360     content[4] = trdPid->GetTRDSignalV2(esdTrack, pid);
361     AliDebug(1, Form("Momentum: %f, TRD Signal: Method 1[%f], Method 2[%f]", content[1], content[3], content[4]));
362     (dynamic_cast<THnSparseF *>(fQAlist->At(kTRDSignal)))->Fill(content);
363   }
364   if(content[1] > 2){ // perform combined
365     AliDebug(1, "Momentum bigger 2 GeV/c, doing combined PID"); 
366     if(content[2] > 65 && content[3] > 500) return kTRUE;
367     else return kFALSE;
368   }
369   else {
370     AliDebug(1, "Momentum smaller 2GeV/c, doing TPC alone PID");
371     return fDetectorPID[kTPCpid]->IsSelected(track) == 11;
372   }
373 }
374
375 //____________________________________________________________
376 void AliHFEpid::MakePlotsItsTpc(AliHFEpidObject *track){
377   //
378   // Make a plot ITS signal - TPC signal for several momentum bins
379   //
380   if(track->fAnalysisType != AliHFEpidObject::kESDanalysis) return; //AOD based detector PID combination not yet implemented
381   AliESDtrack * esdTrack = dynamic_cast<AliESDtrack *>(track->fRecTrack);
382    // Fill My Histograms for MC PID
383   Int_t pdg = TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track));
384   Int_t pid = -1;
385   switch(pdg){
386     case 11:    pid = AliPID::kElectron; break;
387     case 13:    pid = AliPID::kMuon; break;
388     case 211:   pid = AliPID::kPion; break;
389     case 321:   pid = AliPID::kKaon; break;
390     case 2212:  pid = AliPID::kProton; break;
391     default:    pid = -1;
392   };
393   if(IsQAOn() && fDebugLevel > 0){
394     Double_t content[10];
395     content[0] = pid;
396     content[1] = esdTrack->GetTPCInnerParam() ? esdTrack->GetTPCInnerParam()->P() : esdTrack->P();
397     content[2] = (dynamic_cast<AliHFEpidITS *>(fDetectorPID[kITSpid]))->GetITSSignalV1(track->fRecTrack, pid);
398     content[3] = esdTrack->GetTPCsignal();
399     AliDebug(1, Form("Momentum %f, TPC Signal %f, ITS Signal %f", content[1], content[2], content[3]));
400     (dynamic_cast<THnSparseF *>(fQAlist->At(kITSSignal)))->Fill(content);
401   }
402 }
403
404 //____________________________________________________________
405 void AliHFEpid::SetESDpid(AliESDpid *pid){
406   //
407   // Set ESD PID to the Detector PID objects
408   //
409   for(Int_t idet = 0; idet < kNdetectorPID; idet++){
410     if(fDetectorPID[idet]) fDetectorPID[idet]->SetESDpid(pid);
411   }
412 }
413
414 //____________________________________________________________
415 void AliHFEpid::SetQAOn(){
416   //
417   // Switch on QA
418   //
419   SetBit(kIsQAOn, kTRUE);
420   AliInfo("QA switched on");
421   if(fQAlist) return;
422   fQAlist = new TList;
423   fQAlist->SetName("PIDqa");
424   THnSparseF *histo = NULL;
425
426   // Prepare axis for QA histograms
427   const Int_t kMomentumBins = 41;
428   const Double_t kPtMin = 0.1;
429   const Double_t kPtMax = 10.;
430   Double_t momentumBins[kMomentumBins];
431   for(Int_t ibin = 0; ibin < kMomentumBins; ibin++)
432     momentumBins[ibin] = static_cast<Double_t>(TMath::Power(10,TMath::Log10(kPtMin) + (TMath::Log10(kPtMax)-TMath::Log10(kPtMin))/(kMomentumBins-1)*static_cast<Double_t>(ibin)));
433
434   // Add Histogram for combined TPC-TRD PID
435   if(fDebugLevel > 1){
436     AliDebug(1, "Adding histogram for ITS-TPC investigation");
437     const Int_t kDimensionsTRDsig = 5;
438     Int_t kNbinsTRDsig[kDimensionsTRDsig] = {AliPID::kSPECIES + 1, kMomentumBins - 1, 200, 3000, 3000};
439     Double_t binMinTRDsig[kDimensionsTRDsig] = {-1., 0.1, 0, 0, 0};
440     Double_t binMaxTRDsig[kDimensionsTRDsig] = {AliPID::kSPECIES, 10., 200., 3000., 3000.};
441     fQAlist->AddAt((histo = new THnSparseF("fCombTPCTRDpid", "Combined TPC-TRD PID", kDimensionsTRDsig, kNbinsTRDsig, binMinTRDsig, binMaxTRDsig)), kTRDSignal);
442     histo->GetAxis(1)->Set(kMomentumBins - 1, momentumBins);
443     histo->GetAxis(0)->SetTitle("Particle Species");
444     histo->GetAxis(1)->SetTitle("p / GeV/c");
445     histo->GetAxis(2)->SetTitle("TPC Signal / a.u.");
446     histo->GetAxis(3)->SetTitle("TRD Signal / a.u.");
447     histo->GetAxis(4)->SetTitle("TRD Signal / a.u.");
448   }
449
450   // Add Histogram for combined TPC-ITS PID
451   if(fDebugLevel > 0){
452     AliDebug(1, "Adding histogram for TPC-TRD investigation");
453     const Int_t kDimensionsITSsig = 4;
454     Int_t kNbinsITSsig[kDimensionsITSsig] = {AliPID::kSPECIES + 1, kMomentumBins - 1, 300, 3000};
455     Double_t binMinITSsig[kDimensionsITSsig] = {-1., 0.1, 0., 0.};
456     Double_t binMaxITSsig[kDimensionsITSsig] = {AliPID::kSPECIES, 10., 300., 300.};
457     fQAlist->AddAt((histo = new THnSparseF("fCombTPCITSpid", "Combined TPC-ITS PID", kDimensionsITSsig, kNbinsITSsig, binMinITSsig, binMaxITSsig)), kITSSignal);
458     histo->GetAxis(1)->Set(kMomentumBins - 1, momentumBins);
459     histo->GetAxis(0)->SetTitle("Particle Species");
460     histo->GetAxis(1)->SetTitle("p / GeV/c");
461     histo->GetAxis(2)->SetTitle("ITS Signal / a.u.");
462     histo->GetAxis(3)->SetTitle("TPC Signal / a.u.");
463   }
464 }
465
466 //____________________________________________________________
467 void AliHFEpid::InitStrategy1(){
468   //
469   // TPC alone, 3-sigma cut
470   //
471   AliHFEpidTPC *pid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
472   pid->SetTPCnSigma(1);
473   SwitchOnDetector(kTPCpid);
474 }
475
476 //____________________________________________________________
477 void AliHFEpid::InitStrategy2(){
478   //
479   // TPC alone, symmetric 3 sigma cut and asymmetric sigma cut in the momentum region between 2GeV/c and 10 GeV/c and sigma between -1 and 100
480   //
481   AliHFEpidTPC *pid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
482   pid->SetTPCnSigma(3);
483   pid->SetAsymmetricTPCsigmaCut(2., 10., 0., 4.);
484   SwitchOnDetector(kTPCpid);
485 }
486
487 //____________________________________________________________
488 void AliHFEpid::InitStrategy3(){
489   //
490   // TPC alone, symmetric 3 sigma cut and 2 - -100 sigma pion rejection
491   //   
492   AliHFEpidTPC *pid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
493   pid->SetTPCnSigma(3);
494   pid->SetRejectParticle(AliPID::kPion, 0., -100., 10., 1.);
495   SwitchOnDetector(kTPCpid);
496 }
497
498 //____________________________________________________________
499 void AliHFEpid::InitStrategy4(){
500   //
501   // TPC and TRD combined, TPC 3 sigma cut and TRD NN 90% el efficiency level above 2 GeV/c
502   //
503   InitStrategy1();
504   AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fDetectorPID[kTRDpid]);
505   trdpid->SetPIDMethod(AliHFEpidTRD::kLQ);
506   trdpid->SetElectronEfficiency(0.71);
507   SwitchOnDetector(kTRDpid);
508 }
509
510 //____________________________________________________________
511 void AliHFEpid::InitStrategy5(){
512   //
513   // TPC and TRD combined, TPC 3 sigma cut and TRD NN 90% el efficiency level above 2 GeV/c
514   //
515   InitStrategy1();
516   SwitchOnDetector(kTRDpid);
517 }
518
519 //____________________________________________________________
520 void AliHFEpid::InitStrategy6(){
521   //
522   // Combined TPC-TOF PID, combination is discribed in the funtion MakePidTpcTof
523   //
524   AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
525   AliHFEpidTOF *tofpid = dynamic_cast<AliHFEpidTOF *>(fDetectorPID[kTOFpid]);
526   tpcpid->SetTPCnSigma(2);
527   tofpid->SetTOFnSigma(3);
528   //TF1 *upperCut = new TF1("upperCut", "[0] * TMath::Exp([1]*x)", 0, 20);
529   TF1 *upperCut = new TF1("upperCut", "[0]", 0, 20); // Use constant upper cut
530   TF1 *lowerCut = new TF1("lowerCut", "[0] * TMath::Exp([1]*x) + [2]", 0, 20);
531   upperCut->SetParameter(0, 5.);
532   //upperCut->SetParameter(0, 2.7);
533   //upperCut->SetParameter(1, -0.4357);
534   lowerCut->SetParameter(0, -2.65);
535   lowerCut->SetParameter(1, -0.8757);
536 //  lowerCut->SetParameter(2, -1);
537   if(HasMCData()) lowerCut->SetParameter(2, -0.997);
538   else lowerCut->SetParameter(2, -0.9);
539   tpcpid->SetUpperSigmaCut(upperCut);
540   tpcpid->SetLowerSigmaCut(lowerCut);
541   AddCommonObject(upperCut);
542   AddCommonObject(lowerCut);
543   SwitchOnDetector(kTPCpid);
544   SwitchOnDetector(kTOFpid);
545 }
546
547 //____________________________________________________________
548 void AliHFEpid::InitStrategy7(){
549   //
550   // TPC alone, symmetric 3 sigma cut and 2 - -100 sigma pion rejection
551   //   
552   AliHFEpidTPC *pid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
553   pid->SetTPCnSigma(2);
554   pid->SetRejectParticle(AliPID::kProton, 0., -3., 10., 3.);
555   pid->SetRejectParticle(AliPID::kKaon, 0., -3., 10., 3.);
556   SwitchOnDetector(kTPCpid);
557 }
558
559 //____________________________________________________________
560 void AliHFEpid::InitStrategy8(){
561   //
562   // TOF, TRD and TPC together
563   // 
564   AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fDetectorPID[kTPCpid]);
565   AliHFEpidTOF *tofpid = dynamic_cast<AliHFEpidTOF *>(fDetectorPID[kTOFpid]);
566   AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fDetectorPID[kTRDpid]);
567
568   tpcpid->SetTPCnSigma(3);
569   tofpid->SetTOFnSigma(3);
570   trdpid->SetPIDMethod(AliHFEpidTRD::kLQ);
571   trdpid->SetElectronEfficiency(0.71);
572   SwitchOnDetector(kTPCpid);
573   SwitchOnDetector(kTOFpid);
574   SwitchOnDetector(kTRDpid);
575 }
576
577
578 //____________________________________________________________
579 Bool_t AliHFEpid::IdentifyStrategy0(AliHFEpidObject *track){
580   return TMath::Abs(fDetectorPID[kMCpid]->IsSelected(track)) == 11;
581 }
582
583 //____________________________________________________________
584 Bool_t AliHFEpid::IdentifyStrategy1(AliHFEpidObject *track){
585   return TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11;
586 }
587
588 //____________________________________________________________
589 Bool_t AliHFEpid::IdentifyStrategy2(AliHFEpidObject *track){
590   return TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11;
591 }
592
593 //____________________________________________________________
594 Bool_t AliHFEpid::IdentifyStrategy3(AliHFEpidObject *track){
595   return TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11;
596 }
597
598 //____________________________________________________________
599 Bool_t AliHFEpid::IdentifyStrategy4(AliHFEpidObject *track){
600   Int_t trdpid = TMath::Abs(fDetectorPID[kTRDpid]->IsSelected(track));
601   return (trdpid == 0 || trdpid == 11) && (TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11);
602 }
603
604 //____________________________________________________________
605 Bool_t AliHFEpid::IdentifyStrategy5(AliHFEpidObject *track){
606   return MakePidTpcTrd(track);
607 }
608
609 //____________________________________________________________
610 Bool_t AliHFEpid::IdentifyStrategy6(AliHFEpidObject *track){
611   return MakePidTpcTof(track);
612 }
613
614 //____________________________________________________________
615 Bool_t AliHFEpid::IdentifyStrategy7(AliHFEpidObject *track){
616   //
617   // Do PID in strategy 7: Proton and Kaon rejection and 
618   // lower cut on TPC Signal
619   //
620   if(!(TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11))
621     return kFALSE;
622   return kTRUE;
623 }
624
625 //____________________________________________________________
626 Bool_t AliHFEpid::IdentifyStrategy8(AliHFEpidObject *track){
627   // 
628   // Identify TPC, TRD, TOF
629   //
630   if(TMath::Abs(fDetectorPID[kTOFpid]->IsSelected(track)) != 11) return kFALSE;
631   Int_t trdpid = TMath::Abs(fDetectorPID[kTRDpid]->IsSelected(track));
632   return (trdpid == 0 || trdpid == 11) && (TMath::Abs(fDetectorPID[kTPCpid]->IsSelected(track)) == 11);
633 }
634
635 //____________________________________________________________
636 void AliHFEpid::PrintStatus() const {
637   //
638   // Print the PID configuration
639   //
640   printf("\n%s: Printing configuration\n", GetName());
641   printf("===============================================\n");
642   printf("PID Strategy: %d\n", fPIDstrategy);
643   printf("PID Detectors: \n");
644   Int_t npid = 0;
645   TString detectors[kNdetectorPID] = {"MC", "ESD", "ITS", "TPC", "TRD", "TOF"};
646   for(Int_t idet = 0; idet < kNdetectorPID; idet++){
647     if(IsDetectorOn(idet)){
648       printf("\t%s\n", detectors[idet].Data());
649       npid++;
650     }
651   }
652   if(!npid) printf("\tNone\n");
653   printf("\n");
654 }