]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALJetTasks/macros/AddTaskSAQA.C
create general emcal task lib
[u/mrichter/AliRoot.git] / PWGGA / EMCALJetTasks / macros / AddTaskSAQA.C
1 // $Id: AddTaskSAQA.C 56113 2012-05-01 21:39:27Z loizides $
2
3 AliAnalysisTaskSAQA* AddTaskSAQA(
4   const char *ntracks            = "Tracks",
5   const char *nclusters          = "CaloClusters",
6   const char *njets              = "Jets",
7   const char *ntrgclusters       = "",
8   Double_t    jetradius          = 0.4,
9   Double_t    jetptcut           = 1,
10   Double_t    jetareacut         = 0.8,
11   Double_t    ptcut              = 0.15,
12   Double_t    jetBiasTrack       = 5,
13   Double_t    jetBiasClus        = 5,
14   UInt_t      type               = AliAnalysisTaskEmcal::kTPC,
15   const char *taskname           = "AliAnalysisTaskSAQA"
16 )
17 {  
18   // Get the pointer to the existing analysis manager via the static access method.
19   //==============================================================================
20   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
21   if (!mgr)
22   {
23     ::Error("AddTaskSAQA", "No analysis manager to connect to.");
24     return NULL;
25   }  
26   
27   // Check the analysis type using the event handlers connected to the analysis manager.
28   //==============================================================================
29   if (!mgr->GetInputEventHandler())
30   {
31     ::Error("AddTaskSAQA", "This task requires an input event handler");
32     return NULL;
33   }
34   
35   //-------------------------------------------------------
36   // Init the task and do settings
37   //-------------------------------------------------------
38   TString name(taskname);
39   name += "_";
40   name += njets;
41   name += "_Track";
42   name += jetBiasTrack;
43   name += "_Clus";
44   name += jetBiasClus;
45   name += "_R0";
46   name += floor(jetradius*10+0.5);
47   name += "_PtCut";
48   name += floor(ptcut*1000+0.5);
49   name += "_";
50   if (type == AliAnalysisTaskEmcal::kTPC) 
51     name += "TPC";
52   else if (type == AliAnalysisTaskEmcal::kEMCAL) 
53     name += "EMCAL";
54   else if (type == AliAnalysisTaskEmcal::kTPCSmall) 
55     name += "TPCSmall";
56   else if (type == AliAnalysisTaskEmcal::kEMCALOnly) 
57     name += "EMCALOnly";
58   AliAnalysisTaskSAQA* qaTask = new AliAnalysisTaskSAQA(name);
59   qaTask->SetTracksName(ntracks);
60   qaTask->SetClusName(nclusters);
61   qaTask->SetJetsName(njets);
62   qaTask->SetTrgClusName(ntrgclusters);
63   qaTask->SetJetRadius(jetradius);
64   qaTask->SetJetPtCut(jetptcut);
65   qaTask->SetPercAreaCut(jetareacut);
66   qaTask->SetPtCut(ptcut);
67   qaTask->SetPtBiasJetTrack(jetBiasTrack);
68   qaTask->SetPtBiasJetClus(jetBiasClus);
69   qaTask->SetAnaType(type);
70
71   //-------------------------------------------------------
72   // Final settings, pass to manager and set the containers
73   //-------------------------------------------------------
74
75   mgr->AddTask(qaTask);
76   
77   // Create containers for input/output
78   AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
79
80   TString contName(name);
81   contName += "_histos";
82   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), 
83                                                             TList::Class(),AliAnalysisManager::kOutputContainer,
84                                                             Form("%s", AliAnalysisManager::GetCommonFileName()));
85   mgr->ConnectInput  (qaTask, 0,  cinput1 );
86   mgr->ConnectOutput (qaTask, 1, coutput1 );
87
88   return qaTask;
89 }