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