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