]>
Commit | Line | Data |
---|---|---|
fb10c4b8 | 1 | // ************************************** |
2 | // Task used for the correction of determiantion of reconstructed jet spectra | |
3 | // Compares input (gen) and output (rec) jets | |
4 | // ******************************************* | |
5 | ||
6 | ||
7 | /************************************************************************** | |
8 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
9 | * * | |
10 | * Author: The ALICE Off-line Project. * | |
11 | * Contributors are mentioned in the code where appropriate. * | |
12 | * * | |
13 | * Permission to use, copy, modify and distribute this software and its * | |
14 | * documentation strictly for non-commercial purposes is hereby granted * | |
15 | * without fee, provided that the above copyright notice appears in all * | |
16 | * copies and that both the copyright notice and this permission notice * | |
17 | * appear in the supporting documentation. The authors make no claims * | |
18 | * about the suitability of this software for any purpose. It is * | |
19 | * provided "as is" without express or implied warranty. * | |
20 | **************************************************************************/ | |
21 | ||
22 | ||
23 | #include <TROOT.h> | |
24 | #include <TH1F.h> | |
d9c0c425 | 25 | #include <TH2F.h> |
fb10c4b8 | 26 | #include <THnSparse.h> |
27 | #include <TSystem.h> | |
28 | #include <TInterpreter.h> | |
29 | #include <TList.h> | |
30 | #include <TLorentzVector.h> | |
d9c0c425 | 31 | #include <TRefArray.h> |
fb10c4b8 | 32 | #include "TDatabasePDG.h" |
33 | ||
34 | #include "AliAnalysisTaskJetBackgroundSubtract.h" | |
35 | #include "AliAnalysisManager.h" | |
36 | #include "AliAODHandler.h" | |
37 | #include "AliAODTrack.h" | |
38 | #include "AliAODJet.h" | |
39 | #include "AliAODEvent.h" | |
40 | #include "AliInputEventHandler.h" | |
41 | #include "AliAODJetEventBackground.h" | |
42 | ||
43 | ||
44 | ClassImp(AliAnalysisTaskJetBackgroundSubtract) | |
45 | ||
46 | AliAnalysisTaskJetBackgroundSubtract::~AliAnalysisTaskJetBackgroundSubtract(){ | |
47 | delete fJBArray; | |
48 | delete fOutJetArrayList; | |
49 | delete fInJetArrayList; | |
50 | } | |
51 | ||
52 | AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract(): | |
53 | AliAnalysisTaskSE(), | |
54 | fAODOut(0x0), | |
55 | fAODIn(0x0), | |
56 | fAODExtension(0x0), | |
57 | fJBArray(new TObjArray()), | |
58 | fBackgroundBranch(""), | |
59 | fNonStdFile(""), | |
60 | fReplaceString1("B0"), | |
61 | fReplaceString2("B%d"), | |
d73e1768 | 62 | fSubtraction(k4Area), |
fb10c4b8 | 63 | fInJetArrayList(0x0), |
64 | fOutJetArrayList(0x0), | |
d73e1768 | 65 | fh2CentvsRho(0x0), |
66 | fh2CentvsSigma(0x0), | |
67 | fh2ShiftEta(0x0), | |
68 | fh2ShiftPhi(0x0), | |
69 | fh2ShiftEtaLeading(0x0), | |
70 | fh2ShiftPhiLeading(0x0), | |
fb10c4b8 | 71 | fHistList(0x0) |
72 | { | |
73 | ||
74 | } | |
75 | ||
76 | AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract(const char* name): | |
77 | ||
78 | AliAnalysisTaskSE(name), | |
79 | fAODOut(0x0), | |
80 | fAODIn(0x0), | |
81 | fAODExtension(0x0), | |
82 | fJBArray(new TObjArray()), | |
83 | fBackgroundBranch(""), | |
84 | fNonStdFile(""), | |
85 | fReplaceString1("B0"), | |
86 | fReplaceString2("B%d"), | |
d73e1768 | 87 | fSubtraction(k4Area), |
fb10c4b8 | 88 | fInJetArrayList(0x0), |
89 | fOutJetArrayList(0x0), | |
d73e1768 | 90 | fh2CentvsRho(0x0), |
91 | fh2CentvsSigma(0x0), | |
92 | fh2ShiftEta(0x0), | |
93 | fh2ShiftPhi(0x0), | |
94 | fh2ShiftEtaLeading(0x0), | |
95 | fh2ShiftPhiLeading(0x0), | |
fb10c4b8 | 96 | fHistList(0x0) |
97 | { | |
98 | DefineOutput(1, TList::Class()); | |
99 | } | |
100 | ||
101 | ||
102 | ||
103 | Bool_t AliAnalysisTaskJetBackgroundSubtract::Notify() | |
104 | { | |
105 | // | |
1c21a0e7 | 106 | fAODIn = dynamic_cast<AliAODEvent*>(InputEvent()); |
107 | ||
108 | ResetOutJets(); | |
109 | ||
110 | // Now we also have the Input Event Available! Fillvthe pointers in the list | |
111 | ||
112 | fInJetArrayList->Clear(); | |
113 | fOutJetArrayList->Clear(); | |
114 | ||
115 | for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){ | |
116 | TObjString *ostr = (TObjString*)fJBArray->At(iJB); | |
a18eedbb | 117 | |
118 | ||
1c21a0e7 | 119 | TClonesArray* jarray = 0; |
120 | if(!jarray&&fAODOut){ | |
121 | jarray = (TClonesArray*)(fAODOut->FindListObject(ostr->GetString().Data())); | |
122 | } | |
123 | if(!jarray&&fAODExtension){ | |
124 | jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(ostr->GetString().Data())); | |
125 | } | |
126 | if(!jarray&&fAODIn){ | |
127 | jarray = (TClonesArray*)(fAODIn->FindListObject(ostr->GetString().Data())); | |
128 | } | |
129 | ||
130 | if(!jarray){ | |
131 | if(fDebug){ | |
132 | Printf("%s:%d Input jet branch %s not found",(char*)__FILE__,__LINE__,ostr->GetString().Data()); | |
133 | } | |
134 | continue; | |
135 | } | |
136 | ||
137 | TString newName(ostr->GetString().Data()); | |
138 | newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); | |
139 | TClonesArray* jarrayOut = 0; | |
140 | if(!jarrayOut&&fAODOut){ | |
141 | jarrayOut = (TClonesArray*)(fAODOut->FindListObject(newName.Data())); | |
142 | } | |
143 | if(!jarrayOut&&fAODExtension){ | |
144 | jarrayOut = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(newName.Data())); | |
145 | } | |
146 | ||
147 | if(!jarrayOut){ | |
148 | if(fDebug){ | |
149 | Printf("%s:%d Output jet branch %s not found",(char*)__FILE__,__LINE__,newName.Data()); | |
150 | PrintAODContents(); | |
151 | } | |
152 | continue; | |
153 | } | |
154 | if(jarrayOut&&jarray){ | |
155 | fOutJetArrayList->Add(jarrayOut); | |
156 | fInJetArrayList->Add(jarray); | |
157 | } | |
158 | } | |
fb10c4b8 | 159 | return kTRUE; |
160 | } | |
161 | ||
162 | void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects() | |
163 | { | |
164 | ||
165 | // | |
166 | // Create the output container | |
167 | // | |
168 | // Connect the AOD | |
169 | ||
fb10c4b8 | 170 | if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects() \n"); |
171 | if(fNonStdFile.Length()!=0){ | |
a18eedbb | 172 | |
fb10c4b8 | 173 | // case that we have an AOD extension we need to fetch the jets from the extended output |
174 | // we identifay the extension aod event by looking for the branchname | |
175 | AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); | |
176 | fAODExtension = aodH->GetExtension(fNonStdFile.Data()); | |
177 | ||
178 | if(!fAODExtension){ | |
179 | if(fDebug>1)Printf("AODExtension found for %s",fNonStdFile.Data()); | |
180 | } | |
181 | } | |
182 | fAODOut = AODEvent(); | |
fb10c4b8 | 183 | |
1c21a0e7 | 184 | // usually we do not have the input already here |
fb10c4b8 | 185 | |
186 | if(!fInJetArrayList)fInJetArrayList =new TList(); | |
187 | if(!fOutJetArrayList)fOutJetArrayList =new TList(); | |
188 | ||
189 | for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){ | |
fb10c4b8 | 190 | TObjString *ostr = (TObjString*)fJBArray->At(iJB); |
1c21a0e7 | 191 | TString newName(ostr->GetString().Data()); |
fb10c4b8 | 192 | if(!newName.Contains(fReplaceString1.Data())){ |
193 | Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(), | |
1c21a0e7 | 194 | newName.Data()); |
fb10c4b8 | 195 | continue; |
196 | } | |
197 | ||
fb10c4b8 | 198 | // add a new branch to the output for the background subtracted jets take the names from |
199 | // the input jets and replace the background flag names | |
200 | TClonesArray *tca = new TClonesArray("AliAODJet", 0); | |
fb10c4b8 | 201 | newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); |
202 | if(fDebug){ | |
203 | Printf("%s:%d created branch \n %s from \n %s",(char*)__FILE__,__LINE__,newName.Data(), | |
1c21a0e7 | 204 | ostr->GetString().Data()); |
fb10c4b8 | 205 | } |
206 | tca->SetName(newName.Data()); | |
207 | AddAODBranch("TClonesArray",&tca,fNonStdFile.Data()); | |
fb10c4b8 | 208 | } |
209 | ||
210 | ||
fb10c4b8 | 211 | if(!fHistList)fHistList = new TList(); |
212 | fHistList->SetOwner(); | |
213 | ||
1c21a0e7 | 214 | for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){ |
215 | TObjString *ostr = (TObjString*)fJBArray->At(iJB); | |
216 | TString oldName(ostr->GetString().Data()); | |
217 | TString newName(ostr->GetString().Data()); | |
218 | if(!newName.Contains(fReplaceString1.Data())){ | |
219 | Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(), | |
220 | newName.Data()); | |
221 | continue; | |
222 | } | |
223 | newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction)); | |
224 | TH2F *hTmp = new TH2F(Form("h2PtInPtOut_%d",iJB),Form(";%s p_{T}; %s p_{T}",oldName.Data(),newName.Data()),200,0,200.,200,0.,200.); | |
d9c0c425 | 225 | fHistList->Add(hTmp); |
226 | } | |
227 | ||
fb10c4b8 | 228 | Bool_t oldStatus = TH1::AddDirectoryStatus(); |
229 | TH1::AddDirectory(kFALSE); | |
230 | ||
231 | // | |
232 | // Histogram booking, add som control histograms here | |
233 | // | |
234 | ||
d73e1768 | 235 | |
236 | fh2CentvsRho = new TH2F("fh2CentvsRho","centrality vs background density",100,0.,100.,100,0.,150.); | |
237 | fh2CentvsSigma = new TH2F("fh2CentvsSigma","centrality vs backgroun sigma",100,0.,100.,100,0.,150.); | |
238 | fHistList->Add(fh2CentvsRho); | |
239 | fHistList->Add(fh2CentvsSigma); | |
240 | ||
241 | if(fSubtraction==k4Area){ | |
242 | fh2ShiftEta = new TH2F("fh2ShiftEta","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9); | |
243 | fh2ShiftPhi = new TH2F("fh2ShiftPhi","extended correction Phi",100,0.,6.5,100,0.,6.5); | |
244 | fh2ShiftEtaLeading = new TH2F("fh2ShiftEtaLeading","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9); | |
245 | fh2ShiftPhiLeading = new TH2F("fh2ShiftPhiLeading","extended correction Phi",100,0.,6.5,100,0.,6.5); | |
246 | fHistList->Add(fh2ShiftEta); | |
247 | fHistList->Add(fh2ShiftPhi); | |
248 | fHistList->Add(fh2ShiftEtaLeading); | |
249 | fHistList->Add(fh2ShiftPhiLeading); | |
250 | } | |
251 | ||
252 | ||
fb10c4b8 | 253 | // =========== Switch on Sumw2 for all histos =========== |
254 | for (Int_t i=0; i<fHistList->GetEntries(); ++i) { | |
255 | TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i)); | |
256 | if (h1){ | |
257 | h1->Sumw2(); | |
258 | continue; | |
259 | } | |
260 | THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i)); | |
261 | if(hn)hn->Sumw2(); | |
262 | } | |
263 | TH1::AddDirectory(oldStatus); | |
264 | ||
265 | if(fBackgroundBranch.Length()==0) | |
266 | AliError(Form("%s:%d No BackgroundBranch defined",(char*)__FILE__,__LINE__)); | |
267 | if(fJBArray->GetEntries()==0) | |
268 | AliError(Form("%s:%d No Jet Branches defined defined",(char*)__FILE__,__LINE__)); | |
269 | } | |
270 | ||
271 | void AliAnalysisTaskJetBackgroundSubtract::Init() | |
272 | { | |
273 | // | |
274 | // Initialization | |
275 | // | |
276 | if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::Init() \n"); | |
277 | } | |
278 | ||
279 | void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/) | |
280 | { | |
281 | ||
1c21a0e7 | 282 | if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserExec() \n"); |
fb10c4b8 | 283 | ResetOutJets(); |
284 | if(fBackgroundBranch.Length()==0||fJBArray->GetEntries()==0){ | |
1c21a0e7 | 285 | if(fDebug)Printf("%s:%d No background subtraction done",(char*)__FILE__,__LINE__); |
fb10c4b8 | 286 | PostData(1,fHistList); |
287 | } | |
1c21a0e7 | 288 | if(fJBArray->GetEntries()!=fInJetArrayList->GetEntries()){ |
289 | if(fDebug)Printf("%s:%d different Array sizes %d %d %d",(char*)__FILE__,__LINE__,fJBArray->GetEntries(),fInJetArrayList->GetEntries(),fOutJetArrayList->GetEntries()); | |
290 | PostData(1,fHistList); | |
291 | } | |
292 | ||
fb10c4b8 | 293 | |
294 | ||
a18eedbb | 295 | AliAODJetEventBackground* evBkg = 0; |
296 | TClonesArray* bkgClusters = 0; | |
297 | TClonesArray* bkgClustersRC = 0; | |
298 | TString bkgClusterName(fBackgroundBranch.Data()); | |
1c21a0e7 | 299 | bkgClusterName.ReplaceAll(Form("%s_",AliAODJetEventBackground::StdBranchName()),""); |
a18eedbb | 300 | TString bkgClusterRCName(Form("%s%s",bkgClusterName.Data(),"RandomCone")); |
301 | ||
302 | if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODOut){ | |
fb10c4b8 | 303 | evBkg = (AliAODJetEventBackground*)(fAODOut->FindListObject(fBackgroundBranch.Data())); |
d9c0c425 | 304 | bkgClusters = (TClonesArray*)(fAODOut->FindListObject(bkgClusterName.Data())); |
a18eedbb | 305 | bkgClustersRC = (TClonesArray*)(fAODOut->FindListObject(bkgClusterRCName.Data())); |
306 | ||
1c21a0e7 | 307 | if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); |
a18eedbb | 308 | if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); |
1c21a0e7 | 309 | if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); |
fb10c4b8 | 310 | } |
a18eedbb | 311 | if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODExtension){ |
fb10c4b8 | 312 | evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(fBackgroundBranch.Data())); |
d9c0c425 | 313 | bkgClusters = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterName.Data())); |
a18eedbb | 314 | bkgClustersRC = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterRCName.Data())); |
1c21a0e7 | 315 | if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); |
a18eedbb | 316 | if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); |
317 | ||
1c21a0e7 | 318 | if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); |
fb10c4b8 | 319 | } |
1c21a0e7 | 320 | |
a18eedbb | 321 | if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODIn){ |
fb10c4b8 | 322 | evBkg = (AliAODJetEventBackground*)(fAODIn->FindListObject(fBackgroundBranch.Data())); |
1c21a0e7 | 323 | bkgClusters = (TClonesArray*)(fAODIn->FindListObject(bkgClusterName.Data())); |
a18eedbb | 324 | bkgClustersRC = (TClonesArray*)(fAODIn->FindListObject(bkgClusterRCName.Data())); |
325 | ||
1c21a0e7 | 326 | if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); |
a18eedbb | 327 | if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); |
1c21a0e7 | 328 | if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); |
fb10c4b8 | 329 | } |
330 | ||
8a56597f | 331 | if(!evBkg&&(fSubtraction==kArea||fSubtraction==kRhoRecalc)){ |
1c21a0e7 | 332 | if(fDebug){ |
333 | Printf("%s:%d Backgroundbranch %s not found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data()); | |
334 | PrintAODContents(); | |
335 | } | |
fb10c4b8 | 336 | PostData(1,fHistList); |
d9c0c425 | 337 | return; |
338 | } | |
339 | ||
8a56597f | 340 | if(!bkgClusters&&(fSubtraction==kRhoRecalc)){ |
1c21a0e7 | 341 | if(fDebug){ |
342 | Printf("%s:%d Background cluster branch %s not found",(char*)__FILE__,__LINE__,bkgClusterName.Data()); | |
343 | PrintAODContents(); | |
344 | } | |
d9c0c425 | 345 | PostData(1,fHistList); |
346 | return; | |
fb10c4b8 | 347 | } |
348 | ||
8a56597f | 349 | if(!bkgClustersRC&&(fSubtraction==kRhoRC)){ |
a18eedbb | 350 | if(fDebug){ |
351 | Printf("%s:%d Background cluster RC branch %s not found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data()); | |
352 | PrintAODContents(); | |
353 | } | |
354 | PostData(1,fHistList); | |
355 | return; | |
356 | } | |
fb10c4b8 | 357 | // LOOP over all jet branches and subtract the background |
358 | ||
a18eedbb | 359 | Float_t rho = 0; |
d73e1768 | 360 | Float_t sigma=0.; |
a18eedbb | 361 | Double_t meanarea = 0; |
d73e1768 | 362 | TLorentzVector backgroundv; |
363 | Float_t cent=0.; | |
364 | cent = fAODOut->GetHeader()->GetCentrality(); | |
365 | sigma=evBkg->GetSigma(1); | |
366 | ||
367 | if(fSubtraction==kArea) rho = evBkg->GetBackground(1); | |
368 | if(fSubtraction==k4Area){ | |
369 | rho = evBkg->GetBackground(0); | |
370 | sigma=evBkg->GetSigma(0);} | |
371 | ||
a18eedbb | 372 | if(fSubtraction==kRhoRecalc){ |
d73e1768 | 373 | meanarea=evBkg->GetMeanarea(1); |
a18eedbb | 374 | rho =RecalcRho(bkgClusters,meanarea); |
d73e1768 | 375 | } |
376 | if(fSubtraction==kRhoRC) rho=RhoRC(bkgClustersRC); | |
377 | fh2CentvsRho->Fill(cent,rho); | |
378 | fh2CentvsSigma->Fill(cent,sigma); | |
a18eedbb | 379 | |
d73e1768 | 380 | for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){ |
fb10c4b8 | 381 | TClonesArray* jarray = (TClonesArray*)fInJetArrayList->At(iJB); |
382 | TClonesArray* jarrayOut = (TClonesArray*)fOutJetArrayList->At(iJB); | |
1c21a0e7 | 383 | |
384 | if(!jarray||!jarrayOut){ | |
a18eedbb | 385 | Printf("%s:%d Array not found %d: %p %p",(char*)__FILE__,__LINE__,iJB,jarray->GetName(),jarrayOut->GetName()); |
386 | continue; | |
387 | } | |
d9c0c425 | 388 | TH2F* h2PtInOut = (TH2F*)fHistList->FindObject(Form("h2PtInPtOut_%d",iJB)); |
fb10c4b8 | 389 | // loop over all jets |
390 | Int_t nOut = 0; | |
a18eedbb | 391 | |
392 | ||
fb10c4b8 | 393 | for(int i = 0;i < jarray->GetEntriesFast();i++){ |
394 | AliAODJet *jet = (AliAODJet*)jarray->At(i); | |
395 | AliAODJet tmpNewJet(*jet); | |
396 | Bool_t bAdd = false; | |
d73e1768 | 397 | |
a18eedbb | 398 | |
fb10c4b8 | 399 | if(fSubtraction==kArea){ |
d9c0c425 | 400 | Double_t background = rho * jet->EffectiveAreaCharged(); |
401 | Float_t ptSub = jet->Pt() - background; | |
fb10c4b8 | 402 | if(fDebug>2){ |
403 | Printf("%s:%d Jet %d %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub); | |
404 | } | |
405 | if(ptSub<0){ | |
406 | // optionally rescale it and keep?? | |
407 | bAdd = RescaleJetMomentum(&tmpNewJet,0.1); | |
d9c0c425 | 408 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),0.1); |
fb10c4b8 | 409 | } |
410 | else{ | |
411 | bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); | |
d9c0c425 | 412 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub); |
fb10c4b8 | 413 | } |
d9c0c425 | 414 | // add background estimates to the new jet object |
415 | // allows to recover old p_T and rho... | |
416 | tmpNewJet.SetBgEnergy(background,0); | |
fb10c4b8 | 417 | }// kAREA |
a18eedbb | 418 | else if(fSubtraction==kRhoRecalc){ |
419 | Double_t background = rho * jet->EffectiveAreaCharged(); | |
420 | Float_t ptSub = jet->Pt() - background; | |
421 | if(fDebug>2){ | |
422 | Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);} | |
423 | if(ptSub<0){ | |
424 | // optionally rescale it and keep?? | |
425 | bAdd = RescaleJetMomentum(&tmpNewJet,0.1); | |
426 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),0.1); | |
427 | } | |
428 | else{ | |
429 | bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); | |
430 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub); | |
431 | } | |
432 | // add background estimates to the new jet object | |
433 | // allows to recover old p_T and rho... | |
434 | tmpNewJet.SetBgEnergy(background,0); | |
435 | ||
436 | }//kRhoRecalc | |
437 | else if(fSubtraction==kRhoRC){ | |
438 | Double_t background = rho * jet->EffectiveAreaCharged(); | |
439 | Float_t ptSub = jet->Pt() - background; | |
440 | if(fDebug>2){ Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);} | |
441 | if(ptSub<0){ | |
442 | // optionally rescale it and keep?? | |
443 | bAdd = RescaleJetMomentum(&tmpNewJet,0.1); | |
444 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),0.1); | |
445 | } | |
446 | else{ | |
447 | bAdd = RescaleJetMomentum(&tmpNewJet,ptSub); | |
448 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub); | |
449 | } | |
450 | // add background estimates to the new jet object | |
451 | // allows to recover old p_T and rho... | |
452 | tmpNewJet.SetBgEnergy(background,0); | |
453 | ||
454 | }//kRhoRC | |
fb10c4b8 | 455 | |
c0ec1c44 | 456 | else if(fSubtraction==k4Area&&jet->VectorAreaCharged()){ |
d73e1768 | 457 | |
c0ec1c44 | 458 | |
459 | backgroundv.SetPxPyPzE(rho*(jet->VectorAreaCharged())->Px(),rho*(jet->VectorAreaCharged())->Py(),rho*(jet->VectorAreaCharged())->Pz(),rho*(jet->VectorAreaCharged())->E()); | |
460 | if((backgroundv.E()>jet->E())&&(backgroundv.Pt()>jet->Pt())){ | |
461 | ||
462 | // optionally rescale it and keep?? | |
463 | bAdd = RescaleJetMomentum(&tmpNewJet,0.1); | |
464 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),0.1); | |
465 | } | |
466 | else{ | |
467 | bAdd = RescaleJet4vector(&tmpNewJet,backgroundv); | |
468 | } | |
469 | // add background estimates to the new jet object | |
470 | // allows to recover old p_T and rho... | |
471 | tmpNewJet.SetBgEnergy(backgroundv.P(),0); | |
472 | ||
d73e1768 | 473 | }//kArea4vector |
474 | ||
475 | ||
476 | ||
477 | ||
478 | ||
479 | ||
fb10c4b8 | 480 | if(bAdd){ |
d9c0c425 | 481 | AliAODJet *newJet = new ((*jarrayOut)[nOut++]) AliAODJet(tmpNewJet); |
482 | // what about track references, clear for now... | |
d73e1768 | 483 | if(fSubtraction==k4Area){ |
484 | if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),jet->Pt()-newJet->Pt()); | |
485 | fh2ShiftEta->Fill(jet->Eta(),newJet->Eta()); | |
486 | fh2ShiftPhi->Fill(jet->Phi(),newJet->Phi()); | |
487 | if(i==0){fh2ShiftEtaLeading->Fill(jet->Eta(),newJet->Eta()); | |
488 | fh2ShiftPhiLeading->Fill(jet->Phi(),newJet->Phi());}} | |
489 | ||
490 | ||
d9c0c425 | 491 | newJet->GetRefTracks()->Clear(); |
fb10c4b8 | 492 | } |
493 | ||
a18eedbb | 494 | |
495 | ||
496 | ||
497 | ||
498 | ||
499 | } | |
fb10c4b8 | 500 | |
501 | ||
502 | ||
503 | // subtract the background | |
504 | ||
505 | ||
506 | // remove jets?? | |
507 | ||
508 | // sort jets... | |
509 | ||
510 | } | |
511 | PostData(1, fHistList); | |
512 | } | |
513 | ||
514 | void AliAnalysisTaskJetBackgroundSubtract::Terminate(Option_t */*option*/) | |
515 | { | |
516 | // Terminate analysis | |
517 | // | |
518 | if (fDebug > 1) printf("AnalysisJetBackgroundSubtract: Terminate() \n"); | |
519 | } | |
520 | ||
521 | Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJetMomentum(AliAODJet *jet,Float_t pT){ | |
522 | // keep the direction and the jet mass | |
523 | if(pT<=0)return kFALSE; | |
524 | Double_t pTold = jet->Pt(); | |
525 | Double_t scale = pT/pTold; | |
526 | Double_t mass = jet->M(); | |
527 | Double_t pNew = jet->P() * scale; | |
528 | jet->SetPxPyPzE(scale*jet->Px(),scale*jet->Py(),scale*jet->Pz(),TMath::Sqrt(mass*mass+pNew*pNew)); | |
d73e1768 | 529 | |
530 | ||
531 | ||
fb10c4b8 | 532 | return kTRUE; |
533 | } | |
534 | ||
d73e1768 | 535 | Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJet4vector(AliAODJet *jet,TLorentzVector backgroundv){ |
536 | ||
537 | if(backgroundv.Pt()<0.) return kFALSE; | |
538 | jet->SetPxPyPzE(jet->Px()-backgroundv.Px(),jet->Py()-backgroundv.Py(),jet->Pz()-backgroundv.Pz(),jet->E()-backgroundv.E()); | |
539 | ||
540 | return kTRUE; | |
541 | } | |
542 | ||
543 | ||
544 | ||
545 | ||
546 | ||
547 | ||
548 | ||
549 | ||
a18eedbb | 550 | Double_t AliAnalysisTaskJetBackgroundSubtract::RecalcRho(TClonesArray* bkgClusters,Double_t meanarea){ |
551 | ||
552 | Double_t ptarea=0.; | |
553 | Int_t count=0; | |
554 | Double_t rho=0.; | |
555 | const Double_t Rlimit2=0.8*0.8; //2*jet radius. | |
556 | TClonesArray* jarray=0; | |
557 | ||
558 | for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){ | |
559 | TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB); | |
560 | TString jetref=ostr->GetString().Data(); | |
561 | if(jetref.Contains("ANTIKT04")){ | |
562 | jarray = (TClonesArray*)fInJetArrayList->At(iJB);}} | |
563 | if(jarray->GetEntries()>=2){ | |
564 | AliAODJet *first = (AliAODJet*)(jarray->At(0)); | |
565 | AliAODJet *second= (AliAODJet*)(jarray->At(1)); | |
566 | for(Int_t k=0;k<bkgClusters->GetEntriesFast();k++){ | |
567 | AliAODJet *clus = (AliAODJet*)(bkgClusters->At(k)); | |
568 | if(TMath::Abs(clus->Eta())>0.5) continue; | |
569 | if((clus->EffectiveAreaCharged())<0.1*meanarea) continue; | |
570 | Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+ | |
571 | (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi()); | |
572 | Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+ | |
573 | (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi()); | |
574 | if((distance1<Rlimit2)||(distance2<Rlimit2)) continue; | |
575 | ptarea=ptarea+clus->Pt()/clus->EffectiveAreaCharged(); | |
576 | count=count+1;} | |
577 | if(count!=0) rho=ptarea/count; | |
578 | } | |
579 | return rho; | |
580 | } | |
581 | ||
582 | Double_t AliAnalysisTaskJetBackgroundSubtract::RhoRC(TClonesArray* bkgClustersRC){ | |
583 | ||
584 | Double_t ptarea=0.; | |
585 | Int_t count=0; | |
586 | Double_t rho=0.; | |
587 | const Double_t Rlimit2=0.8*0.8; //2*jet radius. | |
588 | TClonesArray* jarray=0; | |
589 | for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){ | |
590 | TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB); | |
591 | TString jetref=ostr->GetString().Data(); | |
592 | if(jetref.Contains("ANTIKT04")){ | |
593 | jarray = (TClonesArray*)fInJetArrayList->At(iJB);}} | |
594 | if(jarray->GetEntries()>=2){ | |
595 | AliAODJet *first = (AliAODJet*)(jarray->At(0)); | |
596 | AliAODJet *second=(AliAODJet*)(jarray->At(1)); | |
597 | for(Int_t k=0;k<bkgClustersRC->GetEntriesFast();k++){ | |
598 | AliAODJet *clus = (AliAODJet*)(bkgClustersRC->At(k)); | |
599 | if(TMath::Abs(clus->Eta())>0.5) continue; | |
600 | Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+ | |
601 | (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi()); | |
602 | Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+ | |
603 | (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi()); | |
604 | if((distance1<Rlimit2)||(distance2<Rlimit2)) continue; | |
605 | ptarea=ptarea+clus->Pt()/clus->EffectiveAreaCharged(); | |
606 | count=count+1;} | |
607 | if(count!=0) rho=ptarea/count; } | |
608 | return rho; | |
609 | } | |
610 | ||
611 | ||
612 | ||
613 | ||
614 | ||
615 | ||
616 | ||
617 | ||
618 | ||
fb10c4b8 | 619 | void AliAnalysisTaskJetBackgroundSubtract::ResetOutJets(){ |
620 | if(!fOutJetArrayList)return; | |
621 | for(int iJB = 0;iJB<fOutJetArrayList->GetEntries();iJB++){ | |
622 | TClonesArray* jarray = (TClonesArray*)fOutJetArrayList->At(iJB); | |
623 | if(jarray)jarray->Delete(); | |
624 | } | |
625 | } | |
1c21a0e7 | 626 | |
627 | ||
628 | void AliAnalysisTaskJetBackgroundSubtract::PrintAODContents(){ | |
629 | if(fAODIn){ | |
630 | Printf("%s:%d >>>>>> Input",(char*)__FILE__,__LINE__); | |
631 | fAODIn->Print(); | |
632 | } | |
633 | if(fAODExtension){ | |
634 | Printf("%s:%d >>>>>> Extenstion",(char*)__FILE__,__LINE__); | |
635 | fAODExtension->GetAOD()->Print(); | |
636 | } | |
637 | if(fAODOut){ | |
638 | Printf("%s:%d >>>>>> Output",(char*)__FILE__,__LINE__); | |
639 | fAODOut->Print(); | |
640 | } | |
641 | } |