Fix Coverity 24835
[u/mrichter/AliRoot.git] / PWG / DevNanoAOD / AliESEHelpers.cxx
1 #include "AliESEHelpers.h"
2 #include "AliAODEvent.h"
3 #include "AliNanoAODTrackMapping.h"
4 #include "AliAnalysisManager.h"
5 #include "AliInputEventHandler.h"
6 #include "AliVParticle.h"
7 #include "AliPIDResponse.h"
8 #include "AliNanoAODTrack.h"
9 #include "AliNanoAODHeader.h"
10
11 ClassImp(AliESEEvtCut)
12 ClassImp(AliESETrkCut)
13 ClassImp(AliAnalysisESESetter)
14
15
16 void AliAnalysisESESetter::SetNanoAODHeader(const AliAODEvent */* event*/   , AliNanoAODHeader * head  ) {
17
18   // if(fHelperPID->GetPIDType()==kBayes)fHelperPID->GetPIDCombined()->SetDefaultTPCPriors();//FIXME maybe this can go in the UserCreateOutputObject?
19
20   //  if(!isMC){
21   Double_t QvecA=fEventCuts->GetqV0A();
22   Double_t QvecC=fEventCuts->GetqV0C();
23     //  }
24
25   Double_t Cent = fEventCuts->GetCent();
26   // TODO: MAPPING FOR HEADERS!
27   head->SetVar(0, QvecA);
28   head->SetVar(1, QvecC);
29   head->SetVar(2, Cent);
30
31
32 }
33
34 void AliAnalysisESESetter::SetNanoAODTrack (const AliAODTrack * aodTrack, AliNanoAODTrack * spTrack) {
35   // Set custom variables in the special track
36   // 1. Cache the indexes
37   
38   static  Int_t kcstNSigmaTPCPi  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTPCPi");
39   static  Int_t kcstNSigmaTPCKa  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTPCKa");
40   static  Int_t kcstNSigmaTPCPr  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTPCPr");
41
42   static  Int_t kcstNSigmaTOFPi  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTOFPi");
43   static  Int_t kcstNSigmaTOFKa  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTOFKa");
44   static  Int_t kcstNSigmaTOFPr  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstNSigmaTOFPr");
45
46   // TODO: set Bayes vars in special track
47
48   // static const Int_t kcstBayesTPCPi  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("kcstBayesTPCPi");
49   // static const Int_t kcstBayesTPCKa  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("kcstBayesTPCKa");
50   // static const Int_t kcstBayesTPCPr  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("kcstBayesTPCPr");
51
52   // static const Int_t kcstBayesTOFPi  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstBayesTOFPi");
53   // static const Int_t kcstBayesTOFKa  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstBayesTOFKa");
54   // static const Int_t kcstBayesTOFPr  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstBayesTOFPr");
55
56   // Get the PID info
57   static AliPIDResponse * pidResponse = 0;
58   if(!pidResponse) {
59     AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
60     AliInputEventHandler* inputHandler = (AliInputEventHandler*)(man->GetInputEventHandler());
61     pidResponse = inputHandler->GetPIDResponse();
62   }
63
64   const AliVParticle *inEvHMain = dynamic_cast<const AliVParticle *>(aodTrack);
65
66   Double_t nsigmaTPCkProton = pidResponse->NumberOfSigmasTPC(inEvHMain, AliPID::kProton);
67   Double_t nsigmaTPCkKaon   = pidResponse->NumberOfSigmasTPC(inEvHMain, AliPID::kKaon); 
68   Double_t nsigmaTPCkPion   = pidResponse->NumberOfSigmasTPC(inEvHMain, AliPID::kPion); 
69
70   Double_t nsigmaTOFkProton = pidResponse->NumberOfSigmasTOF(inEvHMain, AliPID::kProton);
71   Double_t nsigmaTOFkKaon   = pidResponse->NumberOfSigmasTOF(inEvHMain, AliPID::kKaon); 
72   Double_t nsigmaTOFkPion   = pidResponse->NumberOfSigmasTOF(inEvHMain, AliPID::kPion); 
73
74
75
76   
77
78   spTrack->SetVar(kcstNSigmaTPCPi, nsigmaTPCkPion);
79   spTrack->SetVar(kcstNSigmaTPCKa, nsigmaTPCkKaon);
80   spTrack->SetVar(kcstNSigmaTPCPr, nsigmaTPCkProton);
81
82   spTrack->SetVar(kcstNSigmaTOFPi, nsigmaTOFkPion);
83   spTrack->SetVar(kcstNSigmaTOFKa, nsigmaTOFkKaon);
84   spTrack->SetVar(kcstNSigmaTOFPr, nsigmaTOFkProton);
85   //TODO: set the bayes vars
86   
87
88 }