Some clean up in addTask macros, added centrality selection and event classes to...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJetSpectrum2.C
CommitLineData
f4132e7d 1AliAnalysisTaskJetSpectrum2 *AddTaskJetSpectrum2(const char* bRec = "jets",const char* bGen = "jetsAODMC_UA104",const char* bBkg="",UInt_t filterMask = 32, Int_t iPhysicsSelectionFlag = AliVEvent::kMB,UInt_t iEventSelectionMask = 0,Bool_t kBackground=kTRUE,Int_t iFillCorrBkg = 0,Int_t iCl = 0);\r
6bd3fdae 2\r
3\r
f4132e7d 4AliAnalysisTaskJetSpectrum2 *AddTaskJetSpectrum2Delta(UInt_t filterMask = 32,Bool_t kUseAODMC = kFALSE,Int_t iPhysicsSelectionFlag = AliVEvent::kMB,UInt_t iFlag = 0xfffffff, UInt_t iEventSelectionMask = 0,Bool_t kBackground = kTRUE,char* back = ""){\r
599338e5 5\r
f4132e7d 6 TString cBack = back;\r
599338e5 7\r
599338e5 8 AliAnalysisTaskJetSpectrum2 *js = 0;\r
c2785065 9 if(kUseAODMC){\r
6bd3fdae 10 if(iFlag&(1<<0)){ // UA104\r
39e7e8ab 11 js = AddTaskJetSpectrum2("jets","jetsAODMC_UA104",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
12 js = AddTaskJetSpectrum2("jets","jetsAODMC2_UA104",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
6bd3fdae 13 }\r
14 if(iFlag&(1<<1)){ // ANTIKT 04\r
39e7e8ab 15 js = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
16 js = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC2_FASTJET04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
6bd3fdae 17 // cross check MC only background subtration\r
39e7e8ab 18 js = AddTaskJetSpectrum2("jetsAODMC2_FASTJET04","jetsAODMC_FASTJET04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
6bd3fdae 19 }\r
20 if(iFlag&(1<<2)){ // KT 04\r
39e7e8ab 21 js = AddTaskJetSpectrum2("jetsAOD_FASTKT04","jetsAODMC_FASTKT04",cBack.Data(),filterMask,iPhysicsSelectionFlag,iEventSelectionMask,kBackground);\r
22 js = AddTaskJetSpectrum2("jetsAOD_FASTKT04","jetsAODMC2_FASTKT04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
6bd3fdae 23 }\r
24 if(iFlag&(1<<3)){ // SISCONE 04\r
39e7e8ab 25 js = AddTaskJetSpectrum2("jetsAOD_SISCONE04","jetsAODMC_SISCONE04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
26 js = AddTaskJetSpectrum2("jetsAOD_SISCONE04","jetsAODMC2_SISCONE04",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground);\r
6bd3fdae 27 }\r
28 // here can go other radii\r
29 }\r
30 else { // only the data ... no MC\r
31 if(iFlag&(1<<0)){ // UA104\r
f4132e7d 32 js = AddTaskJetSpectrum2("jets","",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground,1);\r
6bd3fdae 33 }\r
34 if(iFlag&(1<<1)){ // ANTIKT 04\r
f4132e7d 35 js = AddTaskJetSpectrum2("jetsAOD_FASTJET04","",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground,1);\r
6bd3fdae 36 }\r
37 if(iFlag&(1<<2)){ // KT 04\r
f4132e7d 38 js = AddTaskJetSpectrum2("jetsAOD_FASTKT04","",cBack.Data(),filterMask,iPhysicsSelectionFlag,iEventSelectionMask,kBackground,1);\r
6bd3fdae 39 }\r
40 if(iFlag&(1<<3)){ // SISCONE 04\r
f4132e7d 41 js = AddTaskJetSpectrum2("jetsAOD_SISCONE04","",cBack.Data(),filterMask,iPhysicsSelectionFlag, iEventSelectionMask,kBackground,1);\r
c2785065 42 }\r
92bbb45d 43 }\r
599338e5 44 return js;\r
45}\r
46\r
47\r
f4132e7d 48AliAnalysisTaskJetSpectrum2 *AddTaskJetSpectrum2(const char* bRec,const char* bGen ,const char* bBkg,UInt_t filterMask,Int_t iPhysicsSelectionFlag,UInt_t iEventSelectionMask,Bool_t kBackground,Int_t iFillCorrBkg,Int_t iCl)\r
3b7ffecf 49{\r
f4132e7d 50 // Creates a jet fider task, configures it and adds it to the analysis manager.\r
51 // Get the pointer to the existing analysis manager via the static access method.\r
52 //==============================================================================\r
53 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
54 if (!mgr) {\r
55 ::Error("AddTaskJetSpectrum2", "No analysis manager to connect to.");\r
56 return NULL;\r
3b7ffecf 57 } \r
f4132e7d 58 \r
59 // Check the analysis type using the event handlers connected to the analysis manager.\r
60 //==============================================================================\r
61 if (!mgr->GetInputEventHandler()) {\r
62 ::Error("AddTaskJetSpectrum2", "This task requires an input event handler");\r
63 return NULL;\r
64 }\r
65 \r
66 TString type = mgr->GetInputEventHandler()->GetDataType();\r
67 TString typeRec(bRec);\r
68 TString typeGen(bGen);\r
69 typeGen.ToUpper();\r
70 typeRec.ToUpper();\r
71 \r
6bd3fdae 72 TString bBkgName = bBkg;\r
73 if(kBackground&&bBkgName.Length()==0){\r
f4132e7d 74 // default\r
0ec9289e 75 if(typeRec.Contains("AODMC2"))bBkgName = "jeteventbackground_clustersAODMC2_KT06";\r
6bd3fdae 76 else bBkgName = "jeteventbackground_clustersAOD_KT06";\r
77 }\r
78\r
3b7ffecf 79 // Create the task and configure it.\r
80 //===========================================================================\r
6bd3fdae 81\r
82 if(iFillCorrBkg)bGen = Form("SubBkg%d",iFillCorrBkg); \r
f4132e7d 83 AliAnalysisTaskJetSpectrum2* pwg4spec = new AliAnalysisTaskJetSpectrum2(Form("JetSpectrum2%s-%s_%010d_Class%02d",bRec,bGen,iEventSelectionMask,iCl));\r
0ec9289e 84 pwg4spec->SetFillCorrBkg(iFillCorrBkg);\r
f4132e7d 85 if(iCl)pwg4spec->SetEventClass(iCl);\r
39e7e8ab 86\r
87 // add the filter mask for non default jets branches\r
88 TString cAdd("");\r
89 cAdd += Form("_Filter%05d",filterMask);\r
90\r
6bd3fdae 91 if(iFillCorrBkg)pwg4spec->SetBranchGen(""); \r
39e7e8ab 92 else {\r
93 pwg4spec->SetBranchGen(bGen); \r
f4132e7d 94 if(typeGen.Contains("JETSAOD")&&!typeGen.Contains("MC"))pwg4spec->SetBranchGen(Form("%s%s",bGen,cAdd.Data())); \r
39e7e8ab 95 }\r
b03b08a3 96 pwg4spec->SetBranchRec(bRec); \r
cb76764e 97 if(typeRec.Contains("JETSAOD")&&!typeRec.Contains("MC")) pwg4spec->SetBranchRec(Form("%s%s",bRec,cAdd.Data())); \r
6bd3fdae 98\r
99 if(bBkgName.Length()>0)pwg4spec->SetBranchBkg(bBkgName.Data());\r
100\r
b03b08a3 101\r
5010a3f7 102 pwg4spec->SetFilterMask(filterMask); \r
8ecc6719 103 pwg4spec->SetUseGlobalSelection(kTRUE); \r
82ebd295 104 pwg4spec->SetMinJetPt(5.);\r
6bd3fdae 105 pwg4spec->SetBkgSubtraction(kBackground);\r
106\r
8ecf60e0 107\r
5010a3f7 108 if(type == "AOD"){\r
565584e8 109 // Assume all jet are produced already\r
110 pwg4spec->SetAODJetInput(kTRUE);\r
111 pwg4spec->SetAODTrackInput(kTRUE);\r
112 pwg4spec->SetAODMCInput(kTRUE);\r
113 }\r
c2785065 114 else{\r
115 if(mgr->GetMCtruthEventHandler()){\r
116 pwg4spec-> SetAnalysisType(AliAnalysisTaskJetSpectrum2::kAnaMCESD);\r
117 }\r
118 }\r
565584e8 119\r
120 if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
121 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetSpectrum2::kTrackAODMCChargedAcceptance);\r
122 }\r
123 else if (typeRec.Contains("AODMC2")){\r
124 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetSpectrum2::kTrackAODMCCharged);\r
125 }\r
126 else if (typeRec.Contains("AODMC")){\r
d2e6cdd5 127 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetSpectrum2::kTrackAODMCAll);\r
565584e8 128 }\r
d2e6cdd5 129 else { // catch akk use AOD\r
565584e8 130 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetSpectrum2::kTrackAOD);\r
5010a3f7 131 }\r
3b7ffecf 132\r
565584e8 133 if(typeGen.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
134 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetSpectrum2::kTrackAODMCChargedAcceptance);\r
135 }\r
136 else if (typeGen.Contains("AODMC2")){\r
3ae212a1 137 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetSpectrum2::kTrackAODMCCharged);\r
138 }\r
565584e8 139 else if (typeGen.Contains("AODMC")){\r
d2e6cdd5 140 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetSpectrum2::kTrackAODMCAll);\r
3ae212a1 141 }\r
b03b08a3 142 else if (typeGen.Length()>0){ // catch all use AOD\r
565584e8 143 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetSpectrum2::kTrackAOD);\r
3ae212a1 144 }\r
565584e8 145\r
39e7e8ab 146 if(iPhysicsSelectionFlag)pwg4spec->SelectCollisionCandidates(iPhysicsSelectionFlag);\r
f2dd0695 147 if(iEventSelectionMask)pwg4spec->SetEventSelectionMask(iEventSelectionMask);\r
42f4e4b8 148\r
39e7e8ab 149 // pwg4spec->SetDebugLevel(10);\r
150\r
5010a3f7 151 mgr->AddTask(pwg4spec);\r
152 \r
3b7ffecf 153 // Create ONLY the output containers for the data produced by the task.\r
154 // Get and connect other common input/output containers via the manager as below\r
155 //==============================================================================\r
f4132e7d 156 AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer(Form("pwg4spec2_%s_%s_%010d_Class%02d",bRec,bGen,iEventSelectionMask,iCl),TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_spec2_%s_%s_%010d_Class%02d",AliAnalysisManager::GetCommonFileName(),bRec,bGen,iEventSelectionMask,iCl));\r
3b7ffecf 157\r
158 mgr->ConnectInput (pwg4spec, 0, mgr->GetCommonInputContainer());\r
159 mgr->ConnectOutput (pwg4spec, 0, mgr->GetCommonOutputContainer());\r
160 mgr->ConnectOutput (pwg4spec, 1, coutput1_Spec );\r
161 \r
162 return pwg4spec;\r
163}\r