calc match fraction from unsubtracted jet
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskEmcalJetMass.C
1 AliAnalysisTaskEmcalJetMass* AddTaskEmcalJetMass(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                                                  TString     tag            = "",
12                                                  TString     nJetsUnsub    = "") {
13
14   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
15   if (!mgr)
16     {
17       Error("AddTaskEmcalJetMass","No analysis manager found.");
18       return 0;
19     }
20   Bool_t ismc=kFALSE;
21   ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
22
23   // Check the analysis type using the event handlers connected to the analysis manager.
24   //==============================================================================
25   if (!mgr->GetInputEventHandler())
26     {
27       ::Error("AddTaskEmcalJetMass", "This task requires an input event handler");
28       return NULL;
29     }
30
31   TString wagonName = Form("JetMass_%s_TC%s%s",njetsBase,trigClass.Data(),tag.Data());
32
33   //Configure jet tagger task
34   AliAnalysisTaskEmcalJetMass *task = new AliAnalysisTaskEmcalJetMass(wagonName.Data());
35
36   task->SetNCentBins(4);
37   //task->SetVzRange(-10.,10.);
38
39   AliParticleContainer *trackCont  = task->AddParticleContainer(ntracks);
40   AliClusterContainer *clusterCont = task->AddClusterContainer(nclusters);
41
42   task->SetJetContainerBase(0);
43
44   TString strType(type);
45   AliJetContainer *jetContBase = task->AddJetContainer(njetsBase,strType,R);
46   if(jetContBase) {
47     jetContBase->SetRhoName(nrhoBase);
48     jetContBase->ConnectParticleContainer(trackCont);
49     jetContBase->ConnectClusterContainer(clusterCont);
50     jetContBase->SetPercAreaCut(0.6);
51   }
52   if(!nJetsUnsub.IsNull()) {
53     AliJetContainer *jetContUS = task->AddJetContainer(nJetsUnsub.Data(),strType,R);
54     if(jetContUS) {
55       jetContUS->SetRhoName(nrhoBase);
56       jetContUS->ConnectParticleContainer(trackCont);
57       jetContUS->ConnectClusterContainer(clusterCont);
58       jetContUS->SetPercAreaCut(0.6);
59     }
60   }
61
62   task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
63   task->SetCentralityEstimator(CentEst);
64   task->SelectCollisionCandidates(pSel);
65   task->SetUseAliAnaUtils(kFALSE);
66
67   mgr->AddTask(task);
68
69   //Connnect input
70   mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );
71
72   //Connect output
73   TString contName(wagonName);
74   TString outputfile = Form("%s",AliAnalysisManager::GetCommonFileName());
75   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
76   mgr->ConnectOutput(task,1,coutput1);
77
78   return task;  
79
80 }
81