795fe5b3529895f5b1e4d8896531975b5c4b648f
[u/mrichter/AliRoot.git] / PWGJE / macros / AddTaskJetResponseV2.C
1
2
3 AliAnalysisTaskJetResponseV2* AddTaskJetResponseV2(Char_t* type = "clusters", Char_t* jf = "FASTKT", Float_t radius = 0.4, UInt_t filterMask = 256 , Float_t ptTrackMin = 0.15, Int_t iBack = 1, Int_t eventClassMin = 0, Int_t eventClassMax = 4){
4
5    return AddTaskJetResponseV2(kTRUE, type, jf, radius, filterMask, ptTrackMin, iBack, eventClassMin, eventClassMax);
6
7 }
8
9
10 AliAnalysisTaskJetResponseV2* AddTaskJetResponseV2(Bool_t emb = kTRUE, Char_t* type = "clusters", Char_t* jf = "FASTKT", Float_t radius = 0.4, UInt_t filterMask = 256 , Float_t ptTrackMin = 0.15, Int_t iBack = 1, Int_t eventClassMin = 0, Int_t eventClassMax = 4, Char_t *recType = "AOD"){
11
12    Printf("adding task jet response\n");
13
14    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
15    if(!mgr){
16       ::Error("AddTaskJetResponseV2", "No analysis manager to connect to.");
17       return NULL;
18    }
19    if(!mgr->GetInputEventHandler()){
20       ::Error("AddTaskJetResponseV2", "This task requires an input event handler.");
21       return NULL;
22    }
23
24    TString branch1 = "";
25    TString branch2 = "";
26    TString suffix  = "";
27    TString suffix2 = "";
28    
29    if(emb){
30
31       // embedding in HI event
32       
33       suffix += Form("_%s", jf);
34       suffix += Form("%02d", (int)((radius+0.01)*10.));
35       suffix += Form("_B0");                                // no background subtraction for extra-only
36       suffix += Form("_Filter%05d", filterMask);
37       suffix += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
38       if(type=="clusters") suffix += Form("_Skip00");
39       
40       suffix2 += Form("_%s", jf);
41       suffix2 += Form("%02d", (int)((radius+0.01)*10.));
42       suffix2 += Form("_B%d", iBack);
43       suffix2 += Form("_Filter%05d", filterMask);
44       suffix2 += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
45       if(type=="clusters") suffix2 += Form("_Skip00");
46       
47       branch1 = Form("%s%sextraonly%s",type, recType, suffix.Data());
48       branch2 = Form("%s%sextra%s",type, recType, suffix2.Data());
49       
50    } else {
51       
52       // p-p detector response
53       suffix += Form("_%s", jf);
54       suffix += Form("%02d", (int)((radius+0.01)*10.));
55       suffix += Form("_B0");                        
56       suffix += Form("_Filter%05d", filterMask);
57       suffix += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
58       if(type=="clusters") suffix += Form("_Skip00");
59       
60       suffix2 += Form("_%s", jf);
61       suffix2 += Form("%02d", (int)((radius+0.01)*10.));
62       suffix2 += Form("_B0");
63       suffix2 += Form("_Filter%05d", filterMask);
64       suffix2 += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
65       if(type=="clusters") suffix2 += Form("_Skip02");
66       
67       branch1 = Form("%sAODMC2%s",type, suffix.Data()); // MC truth
68       branch2 = Form("%sAOD%s",type, suffix2.Data());    // MC reconstucted
69       
70    }
71    
72    AliAnalysisTaskJetResponseV2 *task = new AliAnalysisTaskJetResponseV2(Form("JetResponseV2%s", suffix2.Data()));
73    
74    Printf("Branch1: %s",branch1.Data());
75    Printf("Branch2: %s",branch2.Data());
76
77    task->SetBranchNames(branch1,branch2);
78    task->SetOfflineTrgMask(AliVEvent::kMB);
79
80    task->SetEvtClassMin(eventClassMin);
81    task->SetEvtClassMax(eventClassMax);
82    task->SetCentMin(0.);
83    task->SetCentMax(100.);
84
85    //task->SetVtxMin(-10.);
86    //task->SetVtxMax(10.);
87    
88    task->SetJetPtMin(0.);   // min jet pt is implicit a cut on delta pT!!
89
90    task->SetKeepJets(kTRUE);
91
92    //task->SetNMatchJets(1); // leading jets only
93
94    if(!emb){
95       task->SetIsPbPb(kFALSE);
96       task->SetJetPtFractionMin(0.01);
97       task->SetNMatchJets(999);
98    }
99
100
101    mgr->AddTask(task);
102
103
104    AliAnalysisDataContainer *coutputJetResponseV2 = mgr->CreateContainer(
105    Form("jetresponseV2_%s%s", type,suffix2.Data()), TList::Class(), AliAnalysisManager::kOutputContainer,
106    Form("%s:PWG4_JetResponseV2_%s%s", AliAnalysisManager::GetCommonFileName(), type, suffix2.Data()));
107
108    mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
109    mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
110    mgr->ConnectOutput(task, 1, coutputJetResponseV2);
111
112    return task;
113 }
114
115
116 AliAnalysisTaskJetResponseV2* AddTaskJetResponseV2(TString branch1 = "", TString branch2 = "", TString branch3 = "", Int_t iTask = 0, Bool_t emb = kTRUE, Int_t eventClassMin = 0, Int_t eventClassMax = 4 ,const char* nonStdFile = AliAnalysisManager::GetGlobalStr("kJetDeltaAODName", gDebug)){
117
118    Printf("adding task jet response\n");
119
120    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
121    if(!mgr){
122       ::Error("AddTaskJetResponseV2", "No analysis manager to connect to.");
123       return NULL;
124    }
125    if(!mgr->GetInputEventHandler()){
126       ::Error("AddTaskJetResponseV2", "This task requires an input event handler.");
127       return NULL;
128    }
129
130   
131
132    
133    AliAnalysisTaskJetResponseV2 *task = new AliAnalysisTaskJetResponseV2(Form("JetResponseV2_%d", iTask));
134    
135    Printf("Branch1: %s",branch1.Data());
136    Printf("Branch2: %s",branch2.Data());
137    Printf("Branch3: %s",branch3.Data());
138
139    task->SetBranchNames(branch1,branch2,branch3);
140    task->SetOfflineTrgMask(AliVEvent::kMB);
141
142    task->SetEvtClassMin(eventClassMin);
143    task->SetEvtClassMax(eventClassMax);
144    task->SetCentMin(0.);
145    task->SetCentMax(100.);
146
147    task->SetJetPtMin(0.);   // min jet pt is implicit a cut on delta pT!!
148
149    task->SetKeepJets(kTRUE);
150
151    //task->SetNMatchJets(1); // leading jets only
152
153
154    if(!emb){
155       task->SetIsPbPb(kFALSE);
156       task->SetJetPtFractionMin(0.01);
157       task->SetNMatchJets(999);
158    }
159
160    // to fetch the AOD from the AOD extension ouput 
161    if(strlen(nonStdFile)) task->SetNonStdFile(nonStdFile);
162
163    mgr->AddTask(task);
164
165
166    AliAnalysisDataContainer *coutputJetResponseV2 = mgr->CreateContainer(
167         Form("jetresponseV2_%s%s%s", branch1.Data(),branch2.Data(),branch3.Data()), 
168         TList::Class(), AliAnalysisManager::kOutputContainer,
169          Form("%s:PWG4_JetResponseV2_%s%s%s", AliAnalysisManager::GetCommonFileName(),branch1.Data(),branch2.Data(),branch3.Data()));
170
171    mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
172    mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
173    mgr->ConnectOutput(task, 1, coutputJetResponseV2);
174
175    return task;
176 }
177