AliPhysics  ef3b16e (ef3b16e)
AddTaskLambdacTMVA.C
Go to the documentation of this file.
1 AliAnalysisTaskSE *AddTaskLambdacTMVA(TString finname,Int_t storeNtuple,Bool_t readMC,Bool_t MCPid,Bool_t realPid,Bool_t resPid,Bool_t keepLcNoQuark,Bool_t isHijing,
2 Int_t syst=0, Int_t bit=0, TString postname="",Int_t useNtrkWeight = 0,Int_t storeNtupleReco = 0)
3 {
4  //==============================================================================
5  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
6  if (!mgr) {
7  ::Error("AddTaskLambdac", "No analysis manager to connect to.");
8  return NULL;
9  }
10 
11 
12  Bool_t stdcuts=kFALSE;
13  TFile* filecuts;
14  if( finname.EqualTo("") ) {
15  stdcuts=kTRUE;
16  } else {
17  filecuts=TFile::Open(finname.Data());
18  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
19  AliFatal("Input file not found : check your cut object");
20  }
21  }
22  AliRDHFCutsLctopKpi *analysiscuts = new AliRDHFCutsLctopKpi();
23  // syst = 0 : pp, syst = 1: PbPb, syst = 2 : pPb
24  if(stdcuts) {
25  if(syst==0) analysiscuts->SetStandardCutsPP2010();
26  if(syst==1) analysiscuts->SetStandardCutsPbPb2011();
27  if(syst==2) analysiscuts->SetStandardCutsPPb2013();
28  }
29  else analysiscuts = (AliRDHFCutsLctopKpi*)filecuts->Get("LctopKpiAnalysisCuts");
30  analysiscuts->SetName("LctopKpiAnalysisCuts");
31  analysiscuts->SetMinPtCandidate(-1.);
32  analysiscuts->SetMaxPtCandidate(10000.);
33 
34  // Analysis task
35  AliAnalysisTaskSELambdacTMVA *lambdacTask = new AliAnalysisTaskSELambdacTMVA("LambdacAnalysis",storeNtuple,storeNtupleReco,analysiscuts);
36  //if(storeNtuple<0 || storeNtuple>2) {AliFatal("Invalid storeNtuple argument - check value");}
37  lambdacTask->SetReadMC(readMC);
38  lambdacTask->SetKeepLcNotFromQuark(keepLcNoQuark);
39  lambdacTask->SetCollisionSystem(syst);
40  if(MCPid) lambdacTask->SetMCPid();
41  if(resPid) lambdacTask->SetResonantPid();
42  if(realPid) lambdacTask->SetRealPid();
43  if(isHijing) lambdacTask->SetIsHijing();
44  lambdacTask->SetAnalysis(kTRUE);
45 
46  //bit:0 nocut, 1:LcCut, 2:LcPID, 3: Both
47  lambdacTask->SetUseFilterBitCut(bit==1||bit==3?1:0);
48  lambdacTask->SetUseFilterBitPID(bit>1?1:0);
49 
50  lambdacTask->SetDebugLevel(0);
51  mgr->AddTask(lambdacTask);
52 
53  if(useNtrkWeight>0){
54  TH1F *hNchPrimaries;
55  if(useNtrkWeight==1) hNchPrimaries = (TH1F*)filecuts->Get("hNtrUnCorrEvWithD");
56  else if(useNtrkWeight==2) hNchPrimaries = (TH1F*)filecuts->Get("hNtrUnCorrEvWithCand");
57  else if(useNtrkWeight==3) hNchPrimaries = (TH1F*)filecuts->Get("hNtrUnCorrEvSel");
58  else if(useNtrkWeight==4) hNchPrimaries = (TH1F*)filecuts->Get("hNtrUnCorrPSSel");
59  else {
60  AliFatal("useNtrkWeight value not a valid option - choice from 1-4");
61  return 0x0;
62  }
63  if(hNchPrimaries){
64  lambdacTask->SetUseNchWeight(kTRUE);
65  lambdacTask->SetMCNchHisto(hNchPrimaries);
66  }
67  else {
68  AliFatal("Histogram for multiplicity weights not found");
69  return 0x0;
70  }
71  }
72 
73 
74  //
75  // Create containers for input/output
76  TString outputfile = AliAnalysisManager::GetCommonFileName();
77  outputfile += ":PWG3_D2H_InvMassLambdac";
78 
79  TString finDirname="pp";
80  TString inname = "cinputLc";
81  TString outname = "coutputLc";
82  TString cutsname = "coutputLcCuts";
83  TString normname = "coutputLcNorm";
84  TString normnament = "coutputLcNormNt";
85  TString ntuplename = "fNtupleLambdac";
86  TString ntuplenamereco = "fNtupleLambdacReco";
87  TString nev2 = "coutputNev";
88  TString outname2 = "coutputLambdacMC";
89  TString aPrioriname = "coutputAPriori";
90  TString multiplicityname = "coutputMultiplicity";
91  inname += finDirname.Data();
92  outname += finDirname.Data();
93  cutsname += finDirname.Data();
94  normname += finDirname.Data();
95  normnament += finDirname.Data();
96  nev2 += finDirname.Data();
97  outname2 += finDirname.Data();
98  aPrioriname += finDirname.Data();
99  multiplicityname += finDirname.Data();
100 
101  inname += postname.Data();
102  outname += postname.Data();
103  cutsname += postname.Data();
104  normname += postname.Data();
105  normnament += postname.Data();
106  ntuplename += postname.Data();
107  ntuplenamereco += postname.Data();
108  nev2 += postname.Data();
109  outname2 += postname.Data();
110 
111 
112  //input container
113  AliAnalysisDataContainer *cinputLambdac = mgr->CreateContainer(inname,TChain::Class(),
114  AliAnalysisManager::kInputContainer);
115  mgr->ConnectInput(lambdacTask,0,mgr->GetCommonInputContainer());
116 
117 
118  AliAnalysisDataContainer *coutputLambdacCuts = mgr->CreateContainer(cutsname,TList::Class(),
119  AliAnalysisManager::kOutputContainer,outputfile.Data());
120  mgr->ConnectOutput(lambdacTask,2,coutputLambdacCuts);
121 
122  AliAnalysisDataContainer *coutputLambdac = mgr->CreateContainer(outname,TList::Class(),
123  AliAnalysisManager::kOutputContainer,outputfile.Data());
124  mgr->ConnectOutput(lambdacTask,1,coutputLambdac);
125 
126  AliAnalysisDataContainer *coutputLambdacNev = mgr->CreateContainer(nev2,TH1F::Class(),
127  AliAnalysisManager::kOutputContainer,outputfile.Data());
128  mgr->ConnectOutput(lambdacTask,3,coutputLambdacNev);
129 
130 
131  AliAnalysisDataContainer *coutputLambdacNorm = mgr->CreateContainer(normname,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
132 
133  mgr->ConnectOutput(lambdacTask,4,coutputLambdacNorm);
134 
135  TString foutname = Form("InvMassLambdac_nt1.root",postname.Data());
136  if (storeNtuple) {
137  AliAnalysisDataContainer *coutputLambdac2 = mgr->CreateContainer(ntuplename,TNtuple::Class(),
138  AliAnalysisManager::kOutputContainer,foutname);
139  coutputLambdac2->SetSpecialOutput();
140  mgr->ConnectOutput(lambdacTask,5,coutputLambdac2);
141 
142  coutputLambdacNorm = mgr->CreateContainer(normnament,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer,foutname);
143  mgr->ConnectOutput(lambdacTask,4,coutputLambdacNorm);
144  }
145  if(storeNtupleReco>0){
146  AliAnalysisDataContainer *coutputLambdac3 = mgr->CreateContainer(ntuplenamereco,TNtuple::Class(),
147  AliAnalysisManager::kOutputContainer,foutname);
148  coutputLambdac3->SetSpecialOutput();
149  mgr->ConnectOutput(lambdacTask,6,coutputLambdac3);
150  }
151 
152 
153  return lambdacTask;
154 }
AliAnalysisTaskSE * AddTaskLambdacTMVA(TString finname, Int_t storeNtuple, Bool_t readMC, Bool_t MCPid, Bool_t realPid, Bool_t resPid, Bool_t keepLcNoQuark, Bool_t isHijing, Int_t syst=0, Int_t bit=0, TString postname="", Int_t useNtrkWeight=0, Int_t storeNtupleReco=0)
virtual void SetStandardCutsPbPb2011()
virtual void SetStandardCutsPPb2013()
virtual void SetStandardCutsPP2010()
void SetMaxPtCandidate(Double_t ptCand=1000.)
Definition: AliRDHFCuts.h:221
int Int_t
Definition: External.C:63
void SetIsHijing(Bool_t isHijing=kTRUE)
void SetMinPtCandidate(Double_t ptCand=-1.)
Definition: AliRDHFCuts.h:220
bool Bool_t
Definition: External.C:53
void SetKeepLcNotFromQuark(Bool_t keep=kTRUE)
void SetAnalysis(Bool_t analysis=kTRUE)