AliPhysics  eb0e5d9 (eb0e5d9)
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 
30  TString ConfigMode = "";
31  if(gSystem->Getenv("CONFIG_MODE"))ConfigMode = gSystem->Getenv("CONFIG_MODE");
32 
33  // Copy the needed Config file in the current directory
34  if(configfilename.IsNull()){
35  TString configPWG3d2h="$ALICE_PHYSICS/PWGHF/vertexingHF/ConfigVertexingHF.C";// default value: file for pp collisions
36  if(collisionSystem==1){
37  configPWG3d2h="$ALICE_PHYSICS/PWGHF/vertexingHF/ConfigVertexingHF_Pb_AllCent_NoLS_PIDLc_PtDepSel_LooseIP.C";
38 
39  if(ConfigMode.Contains("Run3")) configPWG3d2h="$ALICE_PHYSICS/PWGHF/vertexingHF/upgrade/ConfigVertexingHF_Pb_Upgrade2018.C";
40  }
41  else if(collisionSystem!=0){
42  ::Error("AddTaskVertexingHF","Value of collision system not valid");
43  }
44  TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", localdir.Data()));
45  }
46  else{
47  TFile::Cp(gSystem->ExpandPathName(configfilename.Data()), Form("%s/ConfigVertexingHF.C", localdir.Data()));
48  }
49 
50  // Create the task, add it to the manager and configure it.
51  //===========================================================================
52  AliAnalysisTaskSEVertexingHF *hfTask = new AliAnalysisTaskSEVertexingHF("vertexing HF");
53  hfTask->SetDeltaAODFileName(fname);
54  mgr->AddTask(hfTask);
55 
56  //
57  // Create containers for input/output
58  AliAnalysisDataContainer *coutputListOfCuts = mgr->CreateContainer("ListOfCuts",TList::Class(),AliAnalysisManager::kOutputContainer,hfTask->GetDeltaAODFileName()); //cuts
59 
60  mgr->ConnectInput(hfTask,0,mgr->GetCommonInputContainer());
61  mgr->ConnectOutput(hfTask,0,mgr->GetCommonOutputContainer());
62  mgr->ConnectOutput(hfTask,1,coutputListOfCuts);
63 
64  return hfTask;
65 }
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