add pythia particle selector for RC
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskEmcalJetMassBkg.C
1 AliAnalysisTaskEmcalJetMassBkg* AddTaskEmcalJetMassBkg(const char * njetsBase, 
2                                                        const Double_t R,
3                                                        const char * nrhoBase, 
4                                                        const char * ntracks, 
5                                                        const char * nclusters,  
6                                                        const char *type,                                             
7                                                        const char *CentEst,
8                                                        Int_t       pSel,
9                                                        TString     trigClass,
10                                                        TString     kEmcalTriggers) {
11
12   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
13   if (!mgr)
14     {
15       Error("AddTaskEmcalJetMassBkg","No analysis manager found.");
16       return 0;
17     }
18   Bool_t ismc=kFALSE;
19   ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
20
21   // Check the analysis type using the event handlers connected to the analysis manager.
22   //==============================================================================
23   if (!mgr->GetInputEventHandler())
24     {
25       ::Error("AddTaskEmcalJetMassBkg", "This task requires an input event handler");
26       return NULL;
27     }
28
29   TString wagonName = Form("JetMassBkg_%s_TC%s",njetsBase,trigClass.Data());
30
31   //Configure jet tagger task
32   AliAnalysisTaskEmcalJetMassBkg *task = new AliAnalysisTaskEmcalJetMassBkg(wagonName.Data());
33
34   task->SetNCentBins(4);
35   task->SetConeRadius(R);
36
37   if (strcmp(type,"TPC")==0)
38     task->SetConeEtaPhiTPC();
39   else if (strcmp(type,"EMCAL")==0)
40     task->SetConeEtaPhiEMCAL();
41
42   AliParticleContainer *trackCont  = task->AddParticleContainer(ntracks);
43   AliClusterContainer *clusterCont = task->AddClusterContainer(nclusters);
44
45   TString strJetsBase(njetsBase);
46   if(strJetsBase.Contains("JetPythia")) {
47     if(trackCont)   trackCont->SetTrackBitMap(TObject::kBitMask);
48     if(clusterCont) clusterCont->SetClusterBitMap(TObject::kBitMask);
49   }
50
51   task->SetJetContainerBase(0);
52
53   TString strType(type);
54   AliJetContainer *jetContBase = task->AddJetContainer(njetsBase,strType,R);
55   if(jetContBase) {
56     jetContBase->SetRhoName(nrhoBase);
57     jetContBase->ConnectParticleContainer(trackCont);
58     jetContBase->ConnectClusterContainer(clusterCont);
59     jetContBase->SetZLeadingCut(0.98,0.98);
60     task->SetPercAreaCut(0.6, 0);
61   }
62
63   task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
64   task->SetCentralityEstimator(CentEst);
65   task->SelectCollisionCandidates(pSel);
66   task->SetUseAliAnaUtils(kFALSE);
67
68   mgr->AddTask(task);
69
70   //Connnect input
71   mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );
72
73   //Connect output
74   TString contName(wagonName);
75   TString outputfile = Form("%s",AliAnalysisManager::GetCommonFileName());
76   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
77   mgr->ConnectOutput(task,1,coutput1);
78
79   return task;  
80 }