1 // **************************************
2 // Task used for the correction of determiantion of reconstructed jet spectra
3 // Compares input (gen) and output (rec) jets
4 // *******************************************
7 /**************************************************************************
8 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
10 * Author: The ALICE Off-line Project. *
11 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
26 #include <THnSparse.h>
28 #include <TInterpreter.h>
30 #include <TLorentzVector.h>
31 #include <TRefArray.h>
32 #include "TDatabasePDG.h"
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"
44 ClassImp(AliAnalysisTaskJetBackgroundSubtract)
46 AliAnalysisTaskJetBackgroundSubtract::~AliAnalysisTaskJetBackgroundSubtract(){
48 delete fOutJetArrayList;
49 delete fInJetArrayList;
52 AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract():
57 fJBArray(new TObjArray()),
58 fBackgroundBranch(""),
60 fReplaceString1("B0"),
61 fReplaceString2("B%d"),
64 fOutJetArrayList(0x0),
71 fh2ShiftEtaLeading(0x0),
72 fh2ShiftPhiLeading(0x0),
78 AliAnalysisTaskJetBackgroundSubtract::AliAnalysisTaskJetBackgroundSubtract(const char* name):
80 AliAnalysisTaskSE(name),
84 fJBArray(new TObjArray()),
85 fBackgroundBranch(""),
87 fReplaceString1("B0"),
88 fReplaceString2("B%d"),
91 fOutJetArrayList(0x0),
98 fh2ShiftEtaLeading(0x0),
99 fh2ShiftPhiLeading(0x0),
102 DefineOutput(1, TList::Class());
107 Bool_t AliAnalysisTaskJetBackgroundSubtract::Notify()
110 fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
114 // Now we also have the Input Event Available! Fillvthe pointers in the list
116 fInJetArrayList->Clear();
117 fOutJetArrayList->Clear();
119 for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){
120 TObjString *ostr = (TObjString*)fJBArray->At(iJB);
123 TClonesArray* jarray = 0;
124 if(!jarray&&fAODOut){
125 jarray = (TClonesArray*)(fAODOut->FindListObject(ostr->GetString().Data()));
127 if(!jarray&&fAODExtension){
128 jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(ostr->GetString().Data()));
131 jarray = (TClonesArray*)(fAODIn->FindListObject(ostr->GetString().Data()));
136 Printf("%s:%d Input jet branch %s not found",(char*)__FILE__,__LINE__,ostr->GetString().Data());
141 TString newName(ostr->GetString().Data());
142 newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction));
143 TClonesArray* jarrayOut = 0;
144 if(newName.CompareTo(ostr->GetString())==0){
145 Printf("%s:%d Input and output branch would have the same name, skipping %s ",(char*)__FILE__,__LINE__,ostr->GetString().Data());
149 if(!jarrayOut&&fAODOut){
150 jarrayOut = (TClonesArray*)(fAODOut->FindListObject(newName.Data()));
152 if(!jarrayOut&&fAODExtension){
153 jarrayOut = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(newName.Data()));
158 Printf("%s:%d Output jet branch %s not found",(char*)__FILE__,__LINE__,newName.Data());
163 if(jarrayOut&&jarray){
164 fOutJetArrayList->Add(jarrayOut);
165 fInJetArrayList->Add(jarray);
171 void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects()
175 // Create the output container
179 if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects() \n");
183 if(fNonStdFile.Length()!=0){
185 // case that we have an AOD extension we need to fetch the jets from the extended output
186 // we identifay the extension aod event by looking for the branchname
187 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
189 fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0);
192 if(fDebug>1)Printf("AODExtension found for %s",fNonStdFile.Data());
195 fAODOut = AODEvent();
197 // usually we do not have the input already here
199 if(!fInJetArrayList)fInJetArrayList =new TList();
200 if(!fOutJetArrayList)fOutJetArrayList =new TList();
202 for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){
203 TObjString *ostr = (TObjString*)fJBArray->At(iJB);
204 TString newName(ostr->GetString().Data());
205 if(!newName.Contains(fReplaceString1.Data())){
206 Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(),
212 // add a new branch to the output for the background subtracted jets take the names from
213 // the input jets and replace the background flag names
214 TClonesArray *tca = new TClonesArray("AliAODJet", 0);
215 newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction));
216 if(newName.CompareTo(ostr->GetString())==0){
217 Printf("%s:%d Input and output branch would have the same name, skipping: %s ",(char*)__FILE__,__LINE__,ostr->GetString().Data());
222 Printf("%s:%d created branch \n %s from \n %s",(char*)__FILE__,__LINE__,newName.Data(),
223 ostr->GetString().Data());
225 tca->SetName(newName.Data());
226 AddAODBranch("TClonesArray",&tca,fNonStdFile.Data());
230 if(!fHistList)fHistList = new TList();
231 fHistList->SetOwner();
232 PostData(1, fHistList); // post data in any case once
236 // delta pT vs. area vs. cent vs. mult
237 const Int_t nSparseBinsDelta = 4;
238 const Int_t nBinsDelta[nSparseBinsDelta] = { 241, 10, 10, 25};
239 const Double_t xminDelta[nSparseBinsDelta] = {-120.5, 0, 0, 0};
240 const Double_t xmaxDelta[nSparseBinsDelta] = { 120.5, 1.0, 100,5000};
242 for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){
243 TObjString *ostr = (TObjString*)fJBArray->At(iJB);
244 TString oldName(ostr->GetString().Data());
245 TString newName(ostr->GetString().Data());
246 if(!newName.Contains(fReplaceString1.Data())){
247 Printf("%s:%d cannot replace string %s in %s",(char*)__FILE__,__LINE__,fReplaceString1.Data(),
251 newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction));
253 TH2F *hTmp = new TH2F(Form("h2PtInPtOut_%d",iJB),Form(";%s p_{T}; %s p_{T}",oldName.Data(),newName.Data()),200,0,200.,400,-200.,200.);
254 fHistList->Add(hTmp);
255 THnSparseF *hFTmp = new THnSparseF(Form("hnDPtAreaCentMult_%d",iJB),Form("%s delta;#delta p_{T};Area;cent;mult",newName.Data()),nSparseBinsDelta,nBinsDelta,xminDelta,xmaxDelta);
256 fHistList->Add(hFTmp);
259 Bool_t oldStatus = TH1::AddDirectoryStatus();
260 TH1::AddDirectory(kFALSE);
263 // Histogram booking, add som control histograms here
267 fh2CentvsRho = new TH2F("fh2CentvsRho","centrality vs background density", 100,0.,100.,600,0.,300.);
268 fh2CentvsSigma = new TH2F("fh2CentvsSigma","centrality vs backgroun sigma",100,0.,100.,500,0.,50.);
269 fHistList->Add(fh2CentvsRho);
270 fHistList->Add(fh2CentvsSigma);
272 fh2MultvsRho = new TH2F("fh2MultvsRho","mult vs background density", 100,0.,5000.,600,0.,300.);
273 fh2MultvsSigma = new TH2F("fh2MultvsSigma","mult vs background sigma",100,0.,5000.,500,0.,50.);
274 fHistList->Add(fh2MultvsRho);
275 fHistList->Add(fh2MultvsSigma);
277 if(fSubtraction==k4Area){
278 fh2ShiftEta = new TH2F("fh2ShiftEta","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9);
279 fh2ShiftPhi = new TH2F("fh2ShiftPhi","extended correction Phi",100,0.,6.5,100,0.,6.5);
280 fh2ShiftEtaLeading = new TH2F("fh2ShiftEtaLeading","extended correction Eta",100,-0.9,0.9,100,-0.9,0.9);
281 fh2ShiftPhiLeading = new TH2F("fh2ShiftPhiLeading","extended correction Phi",100,0.,6.5,100,0.,6.5);
282 fHistList->Add(fh2ShiftEta);
283 fHistList->Add(fh2ShiftPhi);
284 fHistList->Add(fh2ShiftEtaLeading);
285 fHistList->Add(fh2ShiftPhiLeading);
288 // =========== Switch on Sumw2 for all histos ===========
289 for (Int_t i=0; i<fHistList->GetEntries(); ++i) {
290 TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
295 THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i));
298 TH1::AddDirectory(oldStatus);
300 if(fBackgroundBranch.Length()==0)
301 AliError(Form("%s:%d No BackgroundBranch defined",(char*)__FILE__,__LINE__));
302 if(fJBArray->GetEntries()==0)
303 AliError(Form("%s:%d No Jet Branches defined defined",(char*)__FILE__,__LINE__));
306 void AliAnalysisTaskJetBackgroundSubtract::Init()
311 if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::Init() \n");
314 void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
317 if (fDebug > 1) printf("AnalysisTaskJetBackgroundSubtract::UserExec() \n");
319 if(fBackgroundBranch.Length()==0||fJBArray->GetEntries()==0){
320 if(fDebug)Printf("%s:%d No background subtraction done",(char*)__FILE__,__LINE__);
321 PostData(1,fHistList);
323 if(fJBArray->GetEntries()!=fInJetArrayList->GetEntries()){
324 if(fDebug)Printf("%s:%d different Array sizes %d %d %d",(char*)__FILE__,__LINE__,fJBArray->GetEntries(),fInJetArrayList->GetEntries(),fOutJetArrayList->GetEntries());
325 PostData(1,fHistList);
330 AliAODJetEventBackground* evBkg = 0;
331 TClonesArray* bkgClusters = 0;
332 TClonesArray* bkgClustersRC = 0;
333 TString bkgClusterName(fBackgroundBranch.Data());
334 bkgClusterName.ReplaceAll(Form("%s_",AliAODJetEventBackground::StdBranchName()),"");
335 TString bkgClusterRCName(Form("%s%s",bkgClusterName.Data(),"RandomCone"));
337 if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODOut){
338 evBkg = (AliAODJetEventBackground*)(fAODOut->FindListObject(fBackgroundBranch.Data()));
339 bkgClusters = (TClonesArray*)(fAODOut->FindListObject(bkgClusterName.Data()));
340 bkgClustersRC = (TClonesArray*)(fAODOut->FindListObject(bkgClusterRCName.Data()));
342 if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data());
343 if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data());
344 if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());
346 if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODExtension){
347 evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(fBackgroundBranch.Data()));
348 bkgClusters = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterName.Data()));
349 bkgClustersRC = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(bkgClusterRCName.Data()));
350 if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data());
351 if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data());
353 if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());
356 if(!evBkg&&!bkgClusters&&!bkgClustersRC&&fAODIn){
357 evBkg = (AliAODJetEventBackground*)(fAODIn->FindListObject(fBackgroundBranch.Data()));
358 bkgClusters = (TClonesArray*)(fAODIn->FindListObject(bkgClusterName.Data()));
359 bkgClustersRC = (TClonesArray*)(fAODIn->FindListObject(bkgClusterRCName.Data()));
361 if(fDebug&&bkgClusters)Printf("%s:%d Background cluster branch %s found",(char*)__FILE__,__LINE__,bkgClusterName.Data());
362 if(fDebug&&bkgClustersRC)Printf("%s:%d Background cluster RC branch %s found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data());
363 if(fDebug&&evBkg)Printf("%s:%d Backgroundbranch %s found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());
366 if(!evBkg&&(fSubtraction==kArea||fSubtraction==kRhoRecalc||fSubtraction==k4Area)){
368 Printf("%s:%d Backgroundbranch %s not found",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());
371 PostData(1,fHistList);
375 if(!bkgClusters&&(fSubtraction==kRhoRecalc)){
377 Printf("%s:%d Background cluster branch %s not found",(char*)__FILE__,__LINE__,bkgClusterName.Data());
380 PostData(1,fHistList);
384 if(!bkgClustersRC&&(fSubtraction==kRhoRC)){
386 Printf("%s:%d Background cluster RC branch %s not found",(char*)__FILE__,__LINE__,bkgClusterRCName.Data());
389 PostData(1,fHistList);
392 // LOOP over all jet branches and subtract the background
396 Double_t meanarea = 0;
397 TLorentzVector backgroundv;
400 if(fAODOut)cent = fAODOut->GetHeader()->GetCentrality();
401 if(fAODIn) cent = fAODIn->GetHeader()->GetCentrality();
403 if(evBkg)sigma=evBkg->GetSigma(1);
405 if(fSubtraction==kArea) rho = evBkg->GetBackground(1);
406 if(fSubtraction==k4Area){
407 rho = evBkg->GetBackground(0);
408 sigma=evBkg->GetSigma(0);
411 if(fSubtraction==kRhoRecalc){
412 meanarea=evBkg->GetMeanarea(1);
413 rho =RecalcRho(bkgClusters,meanarea);
415 if(fSubtraction==kRhoRC) rho=RhoRC(bkgClustersRC);
418 for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){
419 TClonesArray* jarray = (TClonesArray*)fInJetArrayList->At(iJB);
421 TString tmp(jarray->GetName());
422 if(tmp.Contains("cluster")){
423 mult = MultFromJetRefs(jarray);
429 fh2CentvsRho->Fill(cent,rho);
430 fh2CentvsSigma->Fill(cent,sigma);
432 fh2MultvsRho->Fill(mult,rho);
433 fh2MultvsSigma->Fill(mult,sigma);
435 for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){
436 TClonesArray* jarray = (TClonesArray*)fInJetArrayList->At(iJB);
437 TClonesArray* jarrayOut = (TClonesArray*)fOutJetArrayList->At(iJB);
439 if(!jarray||!jarrayOut){
440 Printf("%s:%d Array not found %d: %p %p",(char*)__FILE__,__LINE__,iJB,jarray,jarrayOut);
443 TH2F* h2PtInOut = (TH2F*)fHistList->FindObject(Form("h2PtInPtOut_%d",iJB));
444 THnSparseF* hnDPtAreaCentMult = (THnSparseF*)fHistList->FindObject(Form("hnDPtAreaCentMult_%d",iJB));
445 // loop over all jets
452 for(int i = 0;i < jarray->GetEntriesFast();i++){
453 AliAODJet *jet = (AliAODJet*)jarray->At(i);
454 AliAODJet tmpNewJet(*jet);
459 if(fSubtraction==kArea){
460 Double_t background = rho * jet->EffectiveAreaCharged();
461 ptSub = jet->Pt() - background;
463 Printf("%s:%d Jet %d %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub);
466 // optionally rescale it and keep??
467 bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
470 bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
472 // add background estimates to the new jet object
473 // allows to recover old p_T and rho...
474 tmpNewJet.SetBgEnergy(background,0);
476 else if(fSubtraction==kRhoRecalc){
477 Double_t background = rho * jet->EffectiveAreaCharged();
478 ptSub = jet->Pt() - background;
480 Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);}
482 // optionally rescale it and keep??
483 bAdd = false;// RescaleJetMomentum(&tmpNewJet,0.1);
486 bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
488 // add background estimates to the new jet object
489 // allows to recover old p_T and rho...
490 tmpNewJet.SetBgEnergy(background,0);
492 else if(fSubtraction==kRhoRC){
493 Double_t background = rho * jet->EffectiveAreaCharged();
494 ptSub = jet->Pt() - background;
495 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);}
497 // optionally rescale it and keep??
498 bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
501 bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
503 // add background estimates to the new jet object
504 // allows to recover old p_T and rho...
505 tmpNewJet.SetBgEnergy(background,0);
509 else if(fSubtraction==k4Area&&jet->VectorAreaCharged()){
510 backgroundv.SetPxPyPzE(rho*(jet->VectorAreaCharged())->Px(),rho*(jet->VectorAreaCharged())->Py(),rho*(jet->VectorAreaCharged())->Pz(),rho*(jet->VectorAreaCharged())->E());
511 ptSub = jet->Pt()-backgroundv.Pt();
512 if((backgroundv.E()>jet->E())&&(backgroundv.Pt()>jet->Pt())){
513 // optionally rescale it and keep??
514 bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
517 bAdd = RescaleJet4vector(&tmpNewJet,backgroundv);
519 // add background estimates to the new jet object
520 // allows to recover old p_T and rho...
521 tmpNewJet.SetBgEnergy(backgroundv.P(),0);
531 AliAODJet *newJet = new ((*jarrayOut)[nOut++]) AliAODJet(tmpNewJet);
532 // what about track references, clear for now...
533 if(fSubtraction==k4Area){
534 fh2ShiftEta->Fill(jet->Eta(),newJet->Eta());
535 fh2ShiftPhi->Fill(jet->Phi(),newJet->Phi());
536 if(i==0){fh2ShiftEtaLeading->Fill(jet->Eta(),newJet->Eta());
537 fh2ShiftPhiLeading->Fill(jet->Phi(),newJet->Phi());}}
539 // set the references
540 newJet->GetRefTracks()->Clear();
541 TRefArray *refs = jet->GetRefTracks();
542 for(Int_t ir=0;ir<refs->GetEntriesFast();ir++){
543 AliVParticle *vp = dynamic_cast<AliVParticle*>(refs->At(ir));
544 if(vp)newJet->AddTrack(vp);
547 if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
548 if(hnDPtAreaCentMult){
550 deltaPt[1] = jet->EffectiveAreaCharged();
551 hnDPtAreaCentMult->Fill(deltaPt);
554 if(jarrayOut)jarrayOut->Sort();
557 PostData(1, fHistList);
560 void AliAnalysisTaskJetBackgroundSubtract::Terminate(Option_t */*option*/)
562 // Terminate analysis
564 if (fDebug > 1) printf("AnalysisJetBackgroundSubtract: Terminate() \n");
567 Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJetMomentum(AliAODJet *jet,Float_t pT){
568 // keep the direction and the jet mass
569 if(pT<=0)return kFALSE;
570 Double_t pTold = jet->Pt();
571 Double_t scale = pT/pTold;
572 Double_t mass = jet->M();
573 Double_t pNew = jet->P() * scale;
574 jet->SetPxPyPzE(scale*jet->Px(),scale*jet->Py(),scale*jet->Pz(),TMath::Sqrt(mass*mass+pNew*pNew));
581 Bool_t AliAnalysisTaskJetBackgroundSubtract::RescaleJet4vector(AliAODJet *jet,TLorentzVector backgroundv){
583 if(backgroundv.Pt()<0.) return kFALSE;
584 jet->SetPxPyPzE(jet->Px()-backgroundv.Px(),jet->Py()-backgroundv.Py(),jet->Pz()-backgroundv.Pz(),jet->E()-backgroundv.E());
596 Double_t AliAnalysisTaskJetBackgroundSubtract::RecalcRho(TClonesArray* bkgClusters,Double_t meanarea){
601 const Double_t Rlimit2=0.8*0.8; //2*jet radius.
602 TClonesArray* jarray=0;
604 for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){
605 TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB);
606 TString jetref=ostr->GetString().Data();
607 if(jetref.Contains("ANTIKT04")){
608 jarray = (TClonesArray*)fInJetArrayList->At(iJB);
611 if(!jarray)return rho;
612 if(jarray->GetEntries()>=2){
613 AliAODJet *first = (AliAODJet*)(jarray->At(0));
614 AliAODJet *second= (AliAODJet*)(jarray->At(1));
615 for(Int_t k=0;k<bkgClusters->GetEntriesFast();k++){
616 AliAODJet *clus = (AliAODJet*)(bkgClusters->At(k));
617 if(TMath::Abs(clus->Eta())>0.5) continue;
618 if((clus->EffectiveAreaCharged())<0.1*meanarea) continue;
619 Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+
620 (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi());
621 Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+
622 (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi());
623 if((distance1<Rlimit2)||(distance2<Rlimit2)) continue;
624 ptarea=ptarea+clus->Pt()/clus->EffectiveAreaCharged();
626 if(count!=0) rho=ptarea/count;
631 Double_t AliAnalysisTaskJetBackgroundSubtract::RhoRC(TClonesArray* bkgClustersRC){
636 const Double_t Rlimit2=0.8*0.8; //2*jet radius.
637 TClonesArray* jarray=0;
638 for(int iJB = 0;iJB<fInJetArrayList->GetEntries();iJB++){
639 TObjString *ostr = (TObjString*)fInJetArrayList->At(iJB);
640 TString jetref=ostr->GetString().Data();
641 if(jetref.Contains("ANTIKT04")){
642 jarray = (TClonesArray*)fInJetArrayList->At(iJB);
645 if(!jarray)return rho;
647 if(jarray->GetEntries()>=2){
648 AliAODJet *first = (AliAODJet*)(jarray->At(0));
649 AliAODJet *second=(AliAODJet*)(jarray->At(1));
650 for(Int_t k=0;k<bkgClustersRC->GetEntriesFast();k++){
651 AliAODJet *clus = (AliAODJet*)(bkgClustersRC->At(k));
652 if(TMath::Abs(clus->Eta())>0.5) continue;
653 Double_t distance1=(first->Eta()-clus->Eta())*(first->Eta()-clus->Eta())+
654 (first->Phi()-clus->Phi())*(first->Phi()-clus->Phi());
655 Double_t distance2= (second->Eta()-clus->Eta())*(second->Eta()-clus->Eta())+
656 (second->Phi()-clus->Phi())*(second->Phi()-clus->Phi());
657 if((distance1<Rlimit2)||(distance2<Rlimit2)) continue;
658 ptarea=ptarea+clus->Pt()/clus->EffectiveAreaCharged();
660 if(count!=0) rho=ptarea/count; }
672 void AliAnalysisTaskJetBackgroundSubtract::ResetOutJets(){
673 if(!fOutJetArrayList)return;
674 for(int iJB = 0;iJB<fOutJetArrayList->GetEntries();iJB++){
675 TClonesArray* jarray = (TClonesArray*)fOutJetArrayList->At(iJB);
676 if(jarray)jarray->Delete();
681 void AliAnalysisTaskJetBackgroundSubtract::PrintAODContents(){
683 Printf("%s:%d >>>>>> Input",(char*)__FILE__,__LINE__);
687 Printf("%s:%d >>>>>> Extenstion",(char*)__FILE__,__LINE__);
688 fAODExtension->GetAOD()->Print();
691 Printf("%s:%d >>>>>> Output",(char*)__FILE__,__LINE__);
696 Int_t AliAnalysisTaskJetBackgroundSubtract::MultFromJetRefs(TClonesArray* jets){
700 for(int ij = 0;ij < jets->GetEntries();++ij){
701 AliAODJet* jet = (AliAODJet*)jets->At(ij);
703 TRefArray *refs = jet->GetRefTracks();
705 refMult += refs->GetEntries();