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