AliPhysics  720d1f3 (720d1f3)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddTaskVertexingHF.C
Go to the documentation of this file.
1 AliAnalysisTaskSEVertexingHF *AddTaskVertexingHF(Int_t collisionSystem,TString localdir="",TString configfilename="",Int_t runnumber=-1, TString strPeriod="",const char* fname="AliAOD.VertexingHF.root") {
2  //
3  // Creates a task for heavy flavour vertexing and adds it to the analysis manager.
4  // andrea.dainese@lnl.infn.it
5  //
6 
7  // Get the pointer to the existing analysis manager via the static access method.
8  //==============================================================================
9  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
10  if (!mgr) {
11  ::Error("AddTaskVertexingHF", "No analysis manager to connect to.");
12  return NULL;
13  }
14 
15  // This task requires an ESD or AOD input handler and an AOD output handler.
16  // Check this using the analysis manager.
17  //===============================================================================
18  TString type = mgr->GetInputEventHandler()->GetDataType();
19  if (!type.Contains("ESD") && !type.Contains("AOD")) {
20  ::Error("AddTaskVertexingHF", "HF vertexing task needs the manager to have an ESD or AOD input handler.");
21  return NULL;
22  }
23  // Check if AOD output handler exist.
24  AliAODHandler *aodh = (AliAODHandler*)mgr->GetOutputEventHandler();
25  if (!aodh) {
26  ::Error("AddTaskVertexingHF", "HF vertexing task needs the manager to have an AOD output handler.");
27  return NULL;
28  }
29  // Copy the needed Config file in the current directory
30  if(configfilename.IsNull()){
31  TString configPWG3d2h="$ALICE_PHYSICS/PWGHF/vertexingHF/ConfigVertexingHF.C";// default value: file for pp collisions
32  if(collisionSystem==1){
33  configPWG3d2h="$ALICE_PHYSICS/PWGHF/vertexingHF/ConfigVertexingHF_Pb_AllCent_NoLS_PIDLc_PtDepSel_LooseIP.C";
34  }
35  else if(collisionSystem!=0){
36  ::Error("AddTaskVertexingHF","Value of collision system not valid");
37  }
38  TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", localdir.Data()));
39  }
40  else{
41  TFile::Cp(gSystem->ExpandPathName(configfilename.Data()), Form("%s/ConfigVertexingHF.C", localdir.Data()));
42  }
43 
44  // Create the task, add it to the manager and configure it.
45  //===========================================================================
46  AliAnalysisTaskSEVertexingHF *hfTask = new AliAnalysisTaskSEVertexingHF("vertexing HF");
47  hfTask->SetDeltaAODFileName(fname);
48  mgr->AddTask(hfTask);
49 
50  //
51  // Create containers for input/output
52  AliAnalysisDataContainer *coutputListOfCuts = mgr->CreateContainer("ListOfCuts",TList::Class(),AliAnalysisManager::kOutputContainer,hfTask->GetDeltaAODFileName()); //cuts
53 
54  mgr->ConnectInput(hfTask,0,mgr->GetCommonInputContainer());
55  mgr->ConnectOutput(hfTask,0,mgr->GetCommonOutputContainer());
56  mgr->ConnectOutput(hfTask,1,coutputListOfCuts);
57 
58  return hfTask;
59 }
AliAnalysisTaskSEVertexingHF * AddTaskVertexingHF(Int_t collisionSystem, TString localdir="", TString configfilename="", Int_t runnumber=-1, TString strPeriod="", const char *fname="AliAOD.VertexingHF.root")
TSystem * gSystem
int Int_t
Definition: External.C:63