2638bbffaba9e3f821f88f242140b99de3914ecd
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJetCluster.C
1 AliAnalysisTaskJetCluster *AddTaskJetCluster(char* bRec = "AOD",char* bGen = "",UInt_t filterMask = 16, Int_t iPhysicsSelection = 1,Char_t *jf = "KT", Float_t radius = 0.4,Int_t nSkip = 0);\r
2 \r
3 \r
4 AliAnalysisTaskJetCluster *AddTaskJetClusterDelta(UInt_t filterMask = 16,Bool_t kUseAODMC = kFALSE,Int_t iPhysicsSelection = 1,Char_t *jf = "KT", UInt_t iFlag){\r
5   AliAnalysisTaskJetCluster *js = 0;\r
6   if(kUseAODMC&&false){// do not use the MC info yet\r
7     if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.00001);\r
8     if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.1);\r
9     if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.2);\r
10     if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.4);\r
11     if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.6);\r
12     if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.8);\r
13     if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,1.0);\r
14   }\r
15   else{\r
16     if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.00001);\r
17     if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.1);\r
18     if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.2);\r
19     if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.4);\r
20     if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.6);\r
21     if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.8);\r
22     if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,1.0);\r
23   }\r
24   \r
25   return js;\r
26 }\r
27 \r
28 \r
29 AliAnalysisTaskJetCluster *AddTaskJetCluster(char* bRec,char* bGen ,UInt_t filterMask,Int_t iPhysicsSelection,Char_t *jf,Float_t radius,Int_t nSkip)\r
30 {\r
31 // Creates a jet fider task, configures it and adds it to the analysis manager.\r
32 \r
33    // Get the pointer to the existing analysis manager via the static access method.\r
34    //==============================================================================\r
35    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
36    if (!mgr) {\r
37       ::Error("AddTaskJetCluster", "No analysis manager to connect to.");\r
38       return NULL;\r
39    }  \r
40    \r
41    // Check the analysis type using the event handlers connected to the analysis manager.\r
42    //==============================================================================\r
43    if (!mgr->GetInputEventHandler()) {\r
44      ::Error("AddTaskJetCluster", "This task requires an input event handler");\r
45       return NULL;\r
46    }\r
47 \r
48    TString type = mgr->GetInputEventHandler()->GetDataType();\r
49    TString typeRec(bRec);\r
50    TString typeGen(bGen);\r
51    typeGen.ToUpper();\r
52    typeRec.ToUpper();\r
53    // Create the task and configure it.\r
54    //===========================================================================\r
55 \r
56 \r
57    char *cRadius = "";\r
58    if(radius>0)cRadius = Form("%02d",(int)((radius+0.01)*10.));\r
59 \r
60    \r
61    AliAnalysisTaskJetCluster* pwg4spec = new  AliAnalysisTaskJetCluster(Form("JetCluster_%s_%s_skip%d",jf,cRadius,nSkip));\r
62       \r
63    // or a config file\r
64    // pwg4spec->SetAnalysisType(AliAnalysisTaskJetCluster::kAnaMC);\r
65    // if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);\r
66    // pwg4spec->SetDebugLevel(11); \r
67    pwg4spec->SetFilterMask(filterMask); \r
68    //   pwg4spec->SetUseGlobalSelection(kTRUE); \r
69 \r
70    if(type == "AOD"){\r
71      // Assume all jet are produced already\r
72      pwg4spec->SetAODTrackInput(kTRUE);\r
73      pwg4spec->SetAODMCInput(kTRUE);\r
74    }\r
75 \r
76    if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
77      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
78    }\r
79    else if (typeRec.Contains("AODMC2")){\r
80      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
81    }\r
82    else if (typeRec.Contains("AODMC")){\r
83      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
84    }\r
85    else if (typeRec.Contains("AOD")) {\r
86      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAOD);\r
87      pwg4spec->SetTrackPtCut(0.15);\r
88    }\r
89 \r
90 \r
91    if(typeGen.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
92      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
93    }\r
94    else if (typeGen.Contains("AODMC2")){\r
95      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
96    }\r
97    else if (typeGen.Contains("AODMC")){\r
98      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
99    }\r
100    else if (typeGen.Contains("AOD")) {\r
101      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAOD);\r
102    }\r
103 \r
104 \r
105 \r
106    pwg4spec->SetRparam(radius);\r
107 \r
108    switch (jf) {\r
109    case "ANTIKT":\r
110      pwg4spec->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh\r
111      break;\r
112    case "CA":\r
113      pwg4spec->SetAlgorithm(1); // CA from fastjet/JetDefinition.hh\r
114      break;\r
115    case "KT":\r
116      pwg4spec->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh\r
117      break;\r
118    default:\r
119      ::Error("AddTaskJetCluster", "Wrong jet finder selected\n");\r
120      return 0;\r
121    }\r
122 \r
123    \r
124    if(TMath::Abs(radius-0.4)<0.01){\r
125      pwg4spec->SetJetOutputBranch(Form("clusters%s_%s%s",bRec,jf,cRadius));\r
126      pwg4spec->SetJetOutputMinPt(1); // store only jets / clusters above a certain threshold\r
127    }\r
128 \r
129    pwg4spec->SetNSkipLeadingRan(nSkip);\r
130 \r
131    if(iPhysicsSelection)pwg4spec->SelectCollisionCandidates();\r
132 \r
133    mgr->AddTask(pwg4spec);\r
134 \r
135    // Create ONLY the output containers for the data produced by the task.\r
136    // Get and connect other common input/output containers via the manager as below\r
137    //==============================================================================\r
138    AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer(Form("pwg4cluster_%s_%s_%s_%s_skip%d",bRec,bGen,jf,cRadius,nSkip), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_cluster_%s_%s_%s_%s_skip%d",AliAnalysisManager::GetCommonFileName(),bRec,bGen,jf,cRadius,nSkip));\r
139 \r
140    mgr->ConnectInput  (pwg4spec, 0, mgr->GetCommonInputContainer());\r
141    mgr->ConnectOutput (pwg4spec, 0, mgr->GetCommonOutputContainer());\r
142    mgr->ConnectOutput (pwg4spec,  1, coutput1_Spec );\r
143    \r
144    return pwg4spec;\r
145 }\r