AliPhysics  master (3d17d9d)
AddTaskDmesonPIDSysProp.C
Go to the documentation of this file.
3  TString cutfilename = "",
4  TString cutobjname = "AnalysisCuts",
5  TString PIDsystfilename = "",
6  TString postname = "")
7 {
8 
9  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
10  if (!mgr) {
11  ::Error("AddTask", "No analysis manager to connect to.");
12  }
13 
14  // Check the analysis type using the event handlers connected to the analysis manager.
15  //==============================================================================
16  if (!mgr->GetInputEventHandler()) {
17  ::Error("AddTaskImpParDistrib", "This task requires an input event handler");
18  return NULL;
19  }
20 
21 
22  Bool_t stdcuts=kFALSE;
23  TFile* filecuts = NULL;
24  if( cutfilename.EqualTo("") ) {
25  stdcuts=kTRUE;
26  }
27  else {
28  filecuts=TFile::Open(cutfilename.Data());
29  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
30  ::Fatal("AddTaskSingleTrackPIDSysPropagation", "Cut object not found: analysis will not start!\n");
31  }
32  else printf("Cut object correctly found\n");
33  }
34 
35  //Analysis Task
36  AliRDHFCuts* analysiscuts = (AliRDHFCuts*)filecuts->Get(cutobjname.Data());
37  if(analysiscuts) Printf("Cut file found!");
38 
39  TFile* PIDsystfile = TFile::Open(PIDsystfilename.Data());
40  if(!PIDsystfile ||(PIDsystfile && !PIDsystfile->IsOpen())){
41  ::Fatal("AddTaskSingleTrackPIDSysPropagation", "Impossible to load single-track systematic file, check if it is correct! Exit.\n");
42  }
43  else printf("Single-track systematic file correctly found\n");
44 
46  Task->SetDebugLevel(1);
47  Task->SetPIDStrategy(pid);
48  bool loadfile = Task->LoadEffSystFile(PIDsystfile);
49  if(!loadfile) {
50  ::Fatal("AddTaskSingleTrackPIDSysPropagation", "Histos with single-track systematic not found: analysis will not start!\n");
51  }
52  mgr->AddTask(Task);
53 
54  // Create containers for input/output
55  TString mesonname = "";
56  if(ch == AliAnalysisTaskSEDmesonPIDSysProp::kD0toKpi) mesonname = "D0";
57  else if(ch == AliAnalysisTaskSEDmesonPIDSysProp::kDplustoKpipi) mesonname = "Dplus";
58  else if(ch == AliAnalysisTaskSEDmesonPIDSysProp::kDstartoKpipi) mesonname = "Dstar";
59  else if(ch == AliAnalysisTaskSEDmesonPIDSysProp::kDstoKKpi) mesonname = "Ds";
60  TString PIDname = "";
61  if(pid == AliAnalysisTaskSEDmesonPIDSysProp::kStrongPID) PIDname = "strongPID";
62  else if(pid == AliAnalysisTaskSEDmesonPIDSysProp::kConservativePID) PIDname = "conservativePID";
63  else if(pid == AliAnalysisTaskSEDmesonPIDSysProp::knSigmaPID) PIDname = "nSigmaPID";
64 
65  TString outputFileName = AliAnalysisManager::GetCommonFileName();
66  outputFileName += Form(":PWGHF_D2H_PIDeffsyst_%s_%s_%s",mesonname.Data(),PIDname.Data(),postname.Data());
67 
68  AliAnalysisDataContainer *coutput =0x0;
69  coutput = mgr->CreateContainer(Form("systUnc_%s_%s_%s",mesonname.Data(),PIDname.Data(),postname.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName );
70 
71  mgr->ConnectInput(Task,0,mgr->GetCommonInputContainer());
72  mgr->ConnectOutput(Task,1,coutput);
73 
74  return Task;
75 }
AliAnalysisTaskSEDmesonPIDSysProp * AddTaskDmesonPIDSysProp(int ch=AliAnalysisTaskSEDmesonPIDSysProp::kDstoKKpi, int pid=AliAnalysisTaskSEDmesonPIDSysProp::kStrongPID, TString cutfilename="", TString cutobjname="AnalysisCuts", TString PIDsystfilename="", TString postname="")
bool Bool_t
Definition: External.C:53