Undoing some unwanted method renames
[u/mrichter/AliRoot.git] / PWGJE / macros / AddTaskJetCluster.C
CommitLineData
fa7c34ba 1AliAnalysisTaskJetCluster *AddTaskJetCluster(char* bRec = "AOD",char* bGen = "",UInt_t filterMask = 16, UInt_t iPhysicsSelectionFlag = AliVEvent::kAny,Char_t *jf = "KT", Float_t radius = 0.4,Int_t nSkip = 0,Int_t kWriteAOD = kFALSE,char* deltaFile = "",Float_t ptTrackCut = 0.15, Float_t etaTrackWindow = 0.9,Float_t vertexWindow = 10.,Int_t nSkipCone = 2,Int_t dice=0,Int_t smear=0,Bool_t useOADB=kFALSE,Double_t changeEfficiencyFraction=0.);
353203e1 2AliAnalysisTaskJetCluster *AddTaskJetClusterDelta(UInt_t filterMask = 16,Bool_t kUseAODMC = kFALSE,UInt_t iPhysicsSelectionFlag = AliVEvent::kMB,Char_t *jf = "KT", UInt_t iFlag);
a1d44e31 3
aa1ee58e 4Int_t kBackgroundModeCl = 0;
5Float_t kPtTrackCutCl = 0.15;
6Float_t kTrackEtaWindowCl = 0.8;
7Float_t kVertexWindowCl = 10;
a1d44e31 8
353203e1 9AliAnalysisTaskJetCluster *AddTaskJetClusterDelta(UInt_t filterMask,Bool_t kUseAODMC,UInt_t iPhysicsSelectionFlag,Char_t *jf, UInt_t iFlag){
a1d44e31 10 AliAnalysisTaskJetCluster *js = 0;
11 if(kUseAODMC&&false){// do not use the MC info yet
12 if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.00001);
13 if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.1);
14 if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.2);
15 if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.4);
16 if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.6);
17 if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,0.8);
18 if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelectionFlag,jf,1.0);
19 }
20 else{
21 if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.00001);
22 if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.1);
23 if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.2);
24 if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.4);
25 if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.6);
26 if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,0.8);
27 if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelectionFlag,jf,1.0);
28 }
29
30 return js;
31 }
32
33
fa7c34ba 34AliAnalysisTaskJetCluster *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,Float_t etaTrackWindow,Float_t vertexWindow,Int_t nSkipCone,Int_t dice,Int_t smear,Bool_t useOADB,Double_t changeEfficiencyFraction)
a1d44e31 35 {
36 // Creates a jet fider task, configures it and adds it to the analysis manager.
aa1ee58e 37 kPtTrackCutCl = ptTrackCut;
38 kTrackEtaWindowCl = etaTrackWindow;
39 kVertexWindowCl = vertexWindow;
a1d44e31 40
41 TString outputFile(deltaFile);
42 // Get the pointer to the existing analysis manager via the static access method.
43 //==============================================================================
44 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
45 if (!mgr) {
46 ::Error("AddTaskJetCluster", "No analysis manager to connect to.");
47 return NULL;
48 }
49
50 // Check the analysis type using the event handlers connected to the analysis manager.
51 //==============================================================================
52 if (!mgr->GetInputEventHandler()) {
53 ::Error("AddTaskJetCluster", "This task requires an input event handler");
54 return NULL;
55 }
56
57 TString type = mgr->GetInputEventHandler()->GetDataType();
58 TString typeRec(bRec);
59 TString typeGen(bGen);
90a9080d 60 if(!typeRec.Contains("AODextra") && !typeRec.Contains("AODMCextra")) {
a1d44e31 61 typeGen.ToUpper();
62 typeRec.ToUpper();
63 }
64 cout << "typeRec: " << typeRec << endl;
65 // Create the task and configure it.
66 //===========================================================================
67
68
69
70
71 TString cAdd = "";
72 cAdd += Form("%02d_",(int)((radius+0.01)*10.));
aa1ee58e 73 cAdd += Form("B%d",(int)kBackgroundModeCl);
a1d44e31 74 cAdd += Form("_Filter%05d",filterMask);
aa1ee58e 75 cAdd += Form("_Cut%05d",(int)(1000.*kPtTrackCutCl));
a1d44e31 76 cAdd += Form("_Skip%02d",nSkip);
28c36b48 77 if(dice>0 || smear>0)
fa7c34ba 78 cAdd += Form("Detector%d%dFr%d",dice,smear,(int)(changeEfficiencyFraction*100.));
79
28c36b48 80
81 Printf("%s %E %d %d",cAdd.Data(),kPtTrackCutCl,dice,smear);
5c4489e2 82 AliAnalysisTaskJetCluster* clus = new AliAnalysisTaskJetCluster(Form("JetCluster%s_%s%s",bRec,jf,cAdd.Data()));
a1d44e31 83
84 // or a config file
5c4489e2 85 // clus->SetAnalysisType(AliAnalysisTaskJetCluster::kAnaMC);
86 // if(iAODanalysis)clus->SetAODInput(kTRUE);
87 // clus->SetDebugLevel(11);
88 clus->SetFilterMask(filterMask);
89 // clus->SetUseGlobalSelection(kTRUE);
aa1ee58e 90 clus->SetVtxCuts(kVertexWindowCl,1);
a1d44e31 91 if(type == "AOD"){
92 // Assume all jet are produced already
5c4489e2 93 clus->SetAODTrackInput(kTRUE);
94 clus->SetAODMCInput(kTRUE);
a1d44e31 95 }
96
d8589aad 97 if (typeRec.Contains("AODMCHF")){
98 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCHF);
99 clus->SetTrackPtCut(kPtTrackCutCl);
100 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
101 }
102 else if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD
5c4489e2 103 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);
aa1ee58e 104 clus->SetTrackPtCut(kPtTrackCutCl);
105 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
a1d44e31 106 }
107 else if (typeRec.Contains("AODMC2")){
5c4489e2 108 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCCharged);
aa1ee58e 109 clus->SetTrackPtCut(kPtTrackCutCl);
5c4489e2 110 clus->SetTrackEtaWindow(5);
a1d44e31 111 }
8ad1ea82 112 else if (typeRec.Contains("AODMCextraonly")) {
113 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCextraonly);
114 clus->SetTrackPtCut(kPtTrackCutCl);
115 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
116 }
117 else if (typeRec.Contains("AODMCextra")) {
118 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCextra);
119 clus->SetTrackPtCut(kPtTrackCutCl);
120 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
121 }
a1d44e31 122 else if (typeRec.Contains("AODMC")){
5c4489e2 123 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCAll);
aa1ee58e 124 clus->SetTrackPtCut(kPtTrackCutCl);
5c4489e2 125 clus->SetTrackEtaWindow(5);
a1d44e31 126 }
127 else if (typeRec.Contains("AODextraonly")) {
5c4489e2 128 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODextraonly);
aa1ee58e 129 clus->SetTrackPtCut(kPtTrackCutCl);
130 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
a1d44e31 131 }
132 else if (typeRec.Contains("AODextra")) {
5c4489e2 133 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODextra);
aa1ee58e 134 clus->SetTrackPtCut(kPtTrackCutCl);
135 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
a1d44e31 136 }
137 else if (typeRec.Contains("AOD")) {
5c4489e2 138 clus->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAOD);
aa1ee58e 139 clus->SetTrackPtCut(kPtTrackCutCl);
140 clus->SetTrackEtaWindow(kTrackEtaWindowCl);
a1d44e31 141 }
142
5c4489e2 143 clus->SetRparam(radius);
144 clus->SetGhostArea(0.005);
aa1ee58e 145 clus->SetGhostEtamax(kTrackEtaWindowCl);
a1d44e31 146
147 switch (jf) {
148 case "ANTIKT":
5c4489e2 149 clus->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh
a1d44e31 150 break;
151 case "CA":
5c4489e2 152 clus->SetAlgorithm(1); // CA from fastjet/JetDefinition.hh
a1d44e31 153 break;
154 case "KT":
5c4489e2 155 clus->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh
a1d44e31 156 break;
157 default:
158 ::Error("AddTaskJetCluster", "Wrong jet finder selected\n");
159 return 0;
160 }
161
162
163 if(kWriteAOD){
5c4489e2 164 if(outputFile.Length())clus->SetJetOutputFile(outputFile);
165 clus->SetJetOutputBranch(Form("clusters%s_%s%s",bRec,jf,cAdd.Data()));
166 clus->SetJetOutputMinPt(0); // store only jets / clusters above a certain threshold
a1d44e31 167 }
168
5c4489e2 169 clus->SetNSkipLeadingRan(nSkip);
170 clus->SetNSkipLeadingCone(nSkipCone);
a1d44e31 171
5c4489e2 172 if(iPhysicsSelectionFlag)clus->SelectCollisionCandidates(iPhysicsSelectionFlag);
a1d44e31 173
fa7c34ba 174 if(useOADB) {
175 clus->SetUseTrResolutionFromOADB();
176 clus->SetUseTrEfficiencyFromOADB();
177 clus->SetChangeEfficiencyFraction(changeEfficiencyFraction);
178 }
179
5c4489e2 180 mgr->AddTask(clus);
a1d44e31 181
182 // Create ONLY the output containers for the data produced by the task.
183 // Get and connect other common input/output containers via the manager as below
184 //==============================================================================
28c36b48 185 AliAnalysisDataContainer *coutput1_clus = mgr->CreateContainer(Form("cluster_%s_%s_%s%s",bRec,bGen,jf,cAdd.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWGJE_cluster_%s_%s_%s%s",AliAnalysisManager::GetCommonFileName(),bRec,bGen,jf,cAdd.Data()));
a1d44e31 186
5c4489e2 187 mgr->ConnectInput (clus, 0, mgr->GetCommonInputContainer());
188 mgr->ConnectOutput (clus, 0, mgr->GetCommonOutputContainer());
28c36b48 189 mgr->ConnectOutput (clus, 1, coutput1_clus );
a1d44e31 190
5c4489e2 191 return clus;
a1d44e31 192}