]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliAnalysisTaskJetCluster.cxx
Fixes for reading from AOD, fetch the branches for each event, reduce printout
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJetCluster.cxx
index e4600ba7a566ff18c03f7fbe4f014aae9aacfb15..fc6112685b02cf57708ba2257a6ab2cd25833d2a 100644 (file)
@@ -84,7 +84,7 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(): AliAnalysisTaskSE(),
   fTrackTypeRec(kTrackUndef),
   fTrackTypeGen(kTrackUndef),  
   fNSkipLeadingRan(0),
-  fNRandomCones(5),
+  fNRandomCones(0),
   fAvgTrials(1),
   fExternalWeight(1),    
   fRecEtaWindow(0.5),
@@ -129,6 +129,9 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(): AliAnalysisTaskSE(),
   fh1CentralityPhySel(0x0), 
   fh1Centrality(0x0), 
   fh1CentralitySelect(0x0),
+  fh1ZPhySel(0x0), 
+  fh1Z(0x0), 
+  fh1ZSelect(0x0),
   fh2NRecJetsPt(0x0),
   fh2NRecTracksPt(0x0),
   fh2NConstPt(0x0),
@@ -183,7 +186,7 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(const char* name):
   fTrackTypeRec(kTrackUndef),
   fTrackTypeGen(kTrackUndef),
   fNSkipLeadingRan(0),
-  fNRandomCones(5),
+  fNRandomCones(0),
   fAvgTrials(1),
   fExternalWeight(1),    
   fRecEtaWindow(0.5),
@@ -228,6 +231,9 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(const char* name):
   fh1CentralityPhySel(0x0), 
   fh1Centrality(0x0), 
   fh1CentralitySelect(0x0),
+  fh1ZPhySel(0x0), 
+  fh1Z(0x0), 
+  fh1ZSelect(0x0),
   fh2NRecJetsPt(0x0),
   fh2NRecTracksPt(0x0),
   fh2NConstPt(0x0),
@@ -314,21 +320,22 @@ void AliAnalysisTaskJetCluster::UserCreateOutputObjects()
       tcaran->SetName(Form("%s_%s",fNonStdBranch.Data(),"random"));
       AddAODBranch("TClonesArray",&tcaran,fNonStdFile.Data());
 
-
       if(fUseBackgroundCalc){
        if(!AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){
          AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
          evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()));
          AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data());  
        }
-       // create the branch for the random cones with the same R 
-       TString cName = Form("%sRandomCone",fNonStdBranch.Data());
+      }
+      // create the branch for the random cones with the same R 
+      TString cName = Form("%sRandomCone",fNonStdBranch.Data());
+
+      if(fNRandomCones>0){
        if(!AODEvent()->FindListObject(cName.Data())){
          TClonesArray *tcaC = new TClonesArray("AliAODJet", 0);
          tcaC->SetName(cName.Data());
          AddAODBranch("TClonesArray",&tcaC,fNonStdFile.Data());
        }
-       
        // create the branch with the random for the random cones on the random event
        cName = Form("%sRandomCone_random",fNonStdBranch.Data());
        if(!AODEvent()->FindListObject(cName.Data())){
@@ -337,7 +344,7 @@ void AliAnalysisTaskJetCluster::UserCreateOutputObjects()
          AddAODBranch("TClonesArray",&tcaCran,fNonStdFile.Data());
        }
       }
-
+    
       if(fNonStdFile.Length()!=0){
        // 
        // case that we have an AOD extension we need to fetch the jets from the extended output
@@ -444,6 +451,10 @@ void AliAnalysisTaskJetCluster::UserCreateOutputObjects()
   fh1CentralitySelect = new TH1F("fh1CentralitySelect",";cent (%)",111,-0.5,110.5);
   fh1CentralityPhySel = new TH1F("fh1CentralityPhySel",";cent (%)",111,-0.5,110.5);
 
+  fh1Z = new TH1F("fh1Z",";zvtx",100,-25,25);
+  fh1ZSelect = new TH1F("fh1ZSelect",";zvtx",100,-25,25);
+  fh1ZPhySel = new TH1F("fh1ZPhySel",";zvtx",100,-25,25);
+
   fh2NRecJetsPt = new TH2F("fh2NRecJetsPt","Number of jets above threshhold;p_{T,cut} (GeV/c);N_{jets}",nBinPt,binLimitsPt,50,-0.5,49.5);
   fh2NRecJetsPtRan = new TH2F("fh2NRecJetsPtRan","Number of jets above threshhold;p_{T,cut} (GeV/c);N_{jets}",nBinPt,binLimitsPt,50,-0.5,49.5);
   fh2NRecTracksPt = new TH2F("fh2NRecTracksPt","Number of tracks above threshhold;p_{T,cut} (GeV/c);N_{tracks}",nBinPt,binLimitsPt,50,-0.5,49.5);
@@ -503,12 +514,13 @@ void AliAnalysisTaskJetCluster::UserCreateOutputObjects()
                                       nBinPhi,binLimitsPhi,nBinPt,binLimitsPt);
 
 
-  if(fUseBackgroundCalc){
+  if(fNRandomCones>0&&fUseBackgroundCalc){
     for(int i = 0;i<3;i++){
       fh1BiARandomCones[i] = new TH1F(Form("fh1BiARandomCones%d",i),";B_{i}^{A} (GeV/c)",200,-100,100);
       fh1BiARandomConesRan[i] =  new TH1F(Form("fh1BiARandomConesRan%d",i),";B_{i}^{A} (GeV/c)",200,-100,100);
     }
   }
+
   for(int i = 0;i < kMaxCent;i++){
     fh2JetsLeadingPhiPtC[i] = (TH2F*)fh2JetsLeadingPhiPt->Clone(Form("%s_C%02d",fh2JetsLeadingPhiPt->GetName(),i+1));
     fh2JetsLeadingPhiPtWC[i]= (TH2F*)fh2JetsLeadingPhiPtW->Clone(Form("%s_C%02d",fh2JetsLeadingPhiPtW->GetName(),i+1));
@@ -539,7 +551,10 @@ void AliAnalysisTaskJetCluster::UserCreateOutputObjects()
     fHistList->Add(fh1Centrality);
     fHistList->Add(fh1CentralitySelect);
     fHistList->Add(fh1CentralityPhySel);
-    if(fUseBackgroundCalc){
+    fHistList->Add(fh1Z);
+    fHistList->Add(fh1ZSelect);
+    fHistList->Add(fh1ZPhySel);
+    if(fNRandomCones&&fUseBackgroundCalc){
       for(int i = 0;i<3;i++){
        fHistList->Add(fh1BiARandomCones[i]);
        fHistList->Add(fh1BiARandomConesRan[i]);
@@ -635,7 +650,9 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
       if(AODEvent())evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
       if(!evBkg)  evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
       if(evBkg)evBkg->Reset(); 
-      
+    }
+
+    if(fNRandomCones>0){
       TString cName = Form("%sRandomCone",fNonStdBranch.Data());
       if(AODEvent())rConeArray = (TClonesArray*)(AODEvent()->FindListObject(cName.Data()));
       if(!rConeArray)rConeArray =  (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(cName.Data()));
@@ -648,9 +665,10 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
     }
   }
 
-  static AliAODJetEventBackground* externalBackground = 0;
+  AliAODJetEventBackground* externalBackground = 0;
   if(!externalBackground&&fBackgroundBranch.Length()){
     externalBackground =  (AliAODJetEventBackground*)(AODEvent()->FindListObject(fBackgroundBranch.Data()));
+    if(!externalBackground)Printf("%s:%d Background branch not found %s",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());;
   }
   //
   // Execute analysis for current event
@@ -680,24 +698,32 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
   Bool_t physicsSelection = true;// handled by the framework(fInputHandler->IsEventSelected()&AliVEvent::kMB)==AliVEvent::kMB;
 
   Float_t cent = 0;
+  Float_t zVtx  = 0;
   Int_t cenClass = -1;
   if(fAOD){
     const AliAODVertex *vtxAOD = fAOD->GetPrimaryVertex();
     TString vtxTitle(vtxAOD->GetTitle());
+    zVtx = vtxAOD->GetZ();
+
     cent = fAOD->GetHeader()->GetCentrality();
     if(cent<10)cenClass = 0;
     else if(cent<30)cenClass = 1;
     else if(cent<50)cenClass = 2;
     else if(cent<80)cenClass = 3;
-    if(physicsSelection)fh1CentralityPhySel->Fill(cent);
+    if(physicsSelection){
+      fh1CentralityPhySel->Fill(cent);
+      fh1ZPhySel->Fill(zVtx);
+    }
+
 
     if(vtxAOD->GetNContributors()>2&&!vtxTitle.Contains("TPCVertex")){
-       Float_t zvtx = vtxAOD->GetZ();
        Float_t yvtx = vtxAOD->GetY();
        Float_t xvtx = vtxAOD->GetX();
        Float_t r2   = yvtx*yvtx+xvtx*xvtx;  
-       if(TMath::Abs(zvtx)<20.&&r2<1.){ // apply vertex cut later on
-         if(physicsSelection)selectEvent = true;
+       if(TMath::Abs(zVtx)<8.&&r2<1.){ // apply vertex cut later on
+         if(physicsSelection){
+           selectEvent = true;
+         }
        }
     }
     if(fCentCutUp>0){
@@ -712,6 +738,7 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
     return;
   }
   fh1Centrality->Fill(cent);  
+  fh1Z->Fill(zVtx);
   fh1Trials->Fill("#sum{ntrials}",1);
   
 
@@ -737,31 +764,6 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
 
   vector<fastjet::PseudoJet> inputParticlesRec;
   vector<fastjet::PseudoJet> inputParticlesRecRan;
-
-
-  // create a random jet within the acceptance
-
-  if(fUseBackgroundCalc){
-    Double_t etaMax = 0.9 - fRparam;
-    Int_t nCone = 0;
-    Int_t nConeRan = 0;
-    Double_t pT = 1; // small number
-    for(int ir = 0;ir < fNRandomCones;ir++){
-      Double_t eta = etaMax*2.*(fRandom->Rndm()-0.5); // +- etamax
-      Double_t phi = fRandom->Rndm()*2.*TMath::Pi(); // 0 - 2pi
-      // massless jet
-      Double_t theta = 2.*TMath::ATan(TMath::Exp(-eta));  
-      Double_t pZ = pT/TMath::Tan(theta);
-      Double_t pX = pT * TMath::Cos(phi);
-      Double_t pY = pT * TMath::Sin(phi);
-      Double_t p  = TMath::Sqrt(pT*pT+pZ*pZ); 
-      AliAODJet tmpRec (pX,pY,pZ, p); 
-      tmpRec.SetBgEnergy(0,0); // this is use as temporary storage of the summed p_T below
-      if(rConeArrayRan)new ((*rConeArrayRan)[nConeRan++]) AliAODJet(tmpRec);
-      if(rConeArray)new ((*rConeArray)[nCone++]) AliAODJet(tmpRec);
-    }
-  }
-
   
   // Generate the random cones
   
@@ -774,15 +776,6 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
     jInp.set_user_index(i);
     inputParticlesRec.push_back(jInp);
 
-    if(fUseBackgroundCalc&&rConeArray){
-      for(int ir = 0;ir < fNRandomCones;ir++){
-       AliAODJet *jC = (AliAODJet*)rConeArray->At(ir);  
-       if(jC&&jC->DeltaR(vp)<fRparam){
-         jC->SetBgEnergy(jC->ChargedBgEnergy()+vp->Pt(),0);
-       }
-      }  
-    }
-
     // the randomized input changes eta and phi, but keeps the p_T
     if(i>=fNSkipLeadingRan){// eventually skip the leading particles
       Double_t pT = vp->Pt();
@@ -800,15 +793,6 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
       jInpRan.set_user_index(i);
       inputParticlesRecRan.push_back(jInpRan);
       vTmpRan.SetPxPyPzE(pX,pY,pZ,p);
-
-      if(fUseBackgroundCalc&&rConeArrayRan){
-       for(int ir = 0;ir < fNRandomCones;ir++){
-         AliAODJet *jC = (AliAODJet*)rConeArrayRan->At(ir);  
-         if(jC&&jC->DeltaR(&vTmpRan)<fRparam){
-           jC->SetBgEnergy(jC->ChargedBgEnergy()+vTmpRan.Pt(),0);
-         }
-       }  
-      }
     }
 
     // fill the tref array, only needed when we write out jets
@@ -820,47 +804,6 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
       fRef->Add(vp);
     }
   }// recparticles
-  if(fUseBackgroundCalc){
-    Float_t jetArea = fRparam*fRparam*TMath::Pi();
-    for(int ir = 0;ir < fNRandomCones;ir++){
-      // rescale the momntum vectors for the random cones
-      if(!rConeArray)continue;
-      AliAODJet *rC = (AliAODJet*)rConeArray->At(ir);
-      if(rC){
-       Double_t eta = rC->Eta();
-       Double_t phi = rC->Phi();
-       // massless jet, unit vector
-       Double_t pT = rC->ChargedBgEnergy();
-       if(pT<=0)pT = 0.1; // for almost empty events
-       Double_t theta = 2.*TMath::ATan(TMath::Exp(-eta));  
-       Double_t pZ = pT/TMath::Tan(theta);
-       Double_t pX = pT * TMath::Cos(phi);
-       Double_t pY = pT * TMath::Sin(phi);
-       Double_t p  = TMath::Sqrt(pT*pT+pZ*pZ); 
-       rC->SetPxPyPzE(pX,pY,pZ, p); 
-       rC->SetBgEnergy(0,0);
-       rC->SetEffArea(jetArea,0);
-      }
-      rC = (AliAODJet*)rConeArrayRan->At(ir);
-      // same wit random
-      if(rC){
-       Double_t eta = rC->Eta();
-       Double_t phi = rC->Phi();
-       // massless jet, unit vector
-       Double_t pT = rC->ChargedBgEnergy();
-       if(pT<=0)pT = 0.1;// for almost empty events
-       Double_t theta = 2.*TMath::ATan(TMath::Exp(-eta));  
-       Double_t pZ = pT/TMath::Tan(theta);
-       Double_t pX = pT * TMath::Cos(phi);
-       Double_t pY = pT * TMath::Sin(phi);
-       Double_t p  = TMath::Sqrt(pT*pT+pZ*pZ); 
-       rC->SetPxPyPzE(pX,pY,pZ, p); 
-       rC->SetBgEnergy(0,0);
-       rC->SetEffArea(jetArea,0);
-      }
-    }
-  }
-
 
   if(inputParticlesRec.size()==0){
     if(fDebug)Printf("%s:%d No input particles found, skipping event",(char*)__FILE__,__LINE__);
@@ -960,28 +903,160 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
     
    
     
-   for(int j = 0; j < nRec;j++){
-     AliAODJet tmpRec (sortedJets[j].px(), sortedJets[j].py(), sortedJets[j].pz(), sortedJets[j].E());
-     aodOutJet = 0;
-     nAodOutTracks = 0;
-     Float_t tmpPt = tmpRec.Pt();  
-     fh1PtJetsRecIn->Fill(tmpPt);
-     // Fill Spectra with constituents
-     vector<fastjet::PseudoJet> constituents = clustSeq.constituents(sortedJets[j]);
-     fh1NConstRec->Fill(constituents.size());
-     fh2PtNch->Fill(nCh,tmpPt);
-     fh2PtNchN->Fill(nCh,tmpPt,constituents.size());
-     fh2NConstPt->Fill(tmpPt,constituents.size());
-     // loop over constiutents and fill spectrum
-
-     // Add the jet information and the track references to the output AOD
-     
-     if(tmpPt>fJetOutputMinPt&&jarray){
-       aodOutJet =  new ((*jarray)[nAodOutJets++]) AliAODJet(tmpRec);
-       Double_t area1 = clustSeq.area(sortedJets[j]);
-       aodOutJet->SetEffArea(area1,0);
-     }
+    for(int j = 0; j < nRec;j++){
+      AliAODJet tmpRec (sortedJets[j].px(), sortedJets[j].py(), sortedJets[j].pz(), sortedJets[j].E());
+      aodOutJet = 0;
+      nAodOutTracks = 0;
+      Float_t tmpPt = tmpRec.Pt();  
+      
+      if(tmpPt>fJetOutputMinPt&&jarray){// cut on the non-background subtracted...
+       aodOutJet =  new ((*jarray)[nAodOutJets++]) AliAODJet(tmpRec);
+       Double_t area1 = clustSeq.area(sortedJets[j]);
+       aodOutJet->SetEffArea(area1,0);
+      }
+
 
+      Float_t tmpPtBack = 0;
+      if(externalBackground){
+       // carefull has to be filled in a task before
+       // todo, ReArrange to the botom
+       tmpPtBack = externalBackground->GetBackground(2)*tmpRec.EffectiveAreaCharged();
+      }
+      tmpPt = tmpPt - tmpPtBack;
+      if(tmpPt<0)tmpPt = 0; // avoid negative weights...
+      
+      fh1PtJetsRecIn->Fill(tmpPt);
+      // Fill Spectra with constituents
+      vector<fastjet::PseudoJet> constituents = clustSeq.constituents(sortedJets[j]);
+
+      fh1NConstRec->Fill(constituents.size());
+      fh2PtNch->Fill(nCh,tmpPt);
+      fh2PtNchN->Fill(nCh,tmpPt,constituents.size());
+      fh2NConstPt->Fill(tmpPt,constituents.size());
+      // loop over constiutents and fill spectrum
+      
+      // Add the jet information and the track references to the output AOD
+            
+
+      if(fNRandomCones>0){       
+       // create a random jet within the acceptance
+       Double_t etaMax = 0.8 - fRparam;
+       Int_t nCone = 0;
+       Int_t nConeRan = 0;
+       Double_t pTC = 1; // small number
+       for(int ir = 0;ir < fNRandomCones;ir++){
+         Double_t etaC = etaMax*2.*(fRandom->Rndm()-0.5); // +- etamax
+         Double_t phiC = fRandom->Rndm()*2.*TMath::Pi(); // 0 - 2pi
+         // massless jet
+         Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));  
+         Double_t pZC = pTC/TMath::Tan(thetaC);
+         Double_t pXC = pTC * TMath::Cos(phiC);
+         Double_t pYC = pTC * TMath::Sin(phiC);
+         Double_t pC  = TMath::Sqrt(pTC*pTC+pZC*pZC); 
+         AliAODJet tmpRecC (pXC,pYC,pZC, pC); 
+         bool skip = false;
+         for(int jj = 0; jj < TMath::Min(nRec,2);jj++){// test for overlap with leading jets
+           AliAODJet jet (sortedJets[jj].px(), sortedJets[jj].py(), sortedJets[jj].pz(), sortedJets[jj].E());
+           if(jet.DeltaR(& tmpRecC)<2.*fRparam+0.2){
+             skip = true;
+             break;
+           }
+         }
+         // test for overlap with previous cones to avoid double counting
+         for(int iic = 0;iic<ir;iic++){
+           AliAODJet *iicone = (AliAODJet*)rConeArray->At(iic);
+           if(iicone){
+             if(iicone->DeltaR(&tmpRecC)<2.*fRparam){
+               skip = true;
+               break;
+             }
+           }
+         }
+         if(skip)continue;
+         tmpRecC.SetBgEnergy(0,0); // this is use as temporary storage of the summed p_T below
+         if(rConeArrayRan)new ((*rConeArrayRan)[nConeRan++]) AliAODJet(tmpRecC);
+         if(rConeArray)new ((*rConeArray)[nCone++]) AliAODJet(tmpRecC);
+       }// random cones
+
+
+       // loop over the reconstructed particles and add up the pT in the random cones
+       // maybe better to loop over randomized particles not in the real jets...
+       // but this by definition brings dow average energy in the whole  event
+       AliAODJet vTmpRanR(1,0,0,1);
+       for(int i = 0; i < recParticles.GetEntries(); i++){
+         AliVParticle *vp = (AliVParticle*)recParticles.At(i);
+         if(rConeArray){
+           for(int ir = 0;ir < fNRandomCones;ir++){
+             AliAODJet *jC = (AliAODJet*)rConeArray->At(ir);  
+             if(jC&&jC->DeltaR(vp)<fRparam){
+               jC->SetBgEnergy(jC->ChargedBgEnergy()+vp->Pt(),0);
+             }
+           }  
+         }// add up energy in cone
+      
+         // the randomized input changes eta and phi, but keeps the p_T
+         if(i>=fNSkipLeadingRan){// eventually skip the leading particles
+           Double_t pTR = vp->Pt();
+           Double_t etaR = 1.8 * fRandom->Rndm() - 0.9;
+           Double_t phiR = 2.* TMath::Pi() * fRandom->Rndm();
+           
+           Double_t thetaR = 2.*TMath::ATan(TMath::Exp(-etaR));  
+           Double_t pZR = pTR/TMath::Tan(thetaR);
+       
+           Double_t pXR = pTR * TMath::Cos(phiR);
+           Double_t pYR = pTR * TMath::Sin(phiR);
+           Double_t pR  = TMath::Sqrt(pTR*pTR+pZR*pZR); 
+           vTmpRanR.SetPxPyPzE(pXR,pYR,pZR,pR);
+           if(rConeArrayRan){
+             for(int ir = 0;ir < fNRandomCones;ir++){
+               AliAODJet *jC = (AliAODJet*)rConeArrayRan->At(ir);  
+               if(jC&&jC->DeltaR(&vTmpRanR)<fRparam){
+                 jC->SetBgEnergy(jC->ChargedBgEnergy()+vTmpRanR.Pt(),0);
+               }
+             }  
+           }
+         }
+       }// loop over recparticles
+    
+       Float_t jetArea = fRparam*fRparam*TMath::Pi();
+       for(int ir = 0;ir < fNRandomCones;ir++){
+         // rescale the momntum vectors for the random cones
+         if(!rConeArray)continue;
+         AliAODJet *rC = (AliAODJet*)rConeArray->At(ir);
+         if(rC){
+           Double_t etaC = rC->Eta();
+           Double_t phiC = rC->Phi();
+           // massless jet, unit vector
+           pTC = rC->ChargedBgEnergy();
+           if(pTC<=0)pTC = 0.1; // for almost empty events
+           Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));  
+           Double_t pZC = pTC/TMath::Tan(thetaC);
+           Double_t pXC = pTC * TMath::Cos(phiC);
+           Double_t pYC = pTC * TMath::Sin(phiC);
+           Double_t pC  = TMath::Sqrt(pTC*pTC+pZC*pZC); 
+           rC->SetPxPyPzE(pXC,pYC,pZC, pC); 
+           rC->SetBgEnergy(0,0);
+           rC->SetEffArea(jetArea,0);
+         }
+         rC = (AliAODJet*)rConeArrayRan->At(ir);
+         // same wit random
+         if(rC){
+           Double_t etaC = rC->Eta();
+           Double_t phiC = rC->Phi();
+           // massless jet, unit vector
+           pTC = rC->ChargedBgEnergy();
+           if(pTC<=0)pTC = 0.1;// for almost empty events
+           Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));  
+           Double_t pZC = pTC/TMath::Tan(thetaC);
+           Double_t pXC = pTC * TMath::Cos(phiC);
+           Double_t pYC = pTC * TMath::Sin(phiC);
+           Double_t pC  = TMath::Sqrt(pTC*pTC+pZC*pZC); 
+           rC->SetPxPyPzE(pXC,pYC,pZC, pC); 
+           rC->SetBgEnergy(0,0);
+           rC->SetEffArea(jetArea,0);
+         }
+       }
+      }// if(fUseBackgroundCalc
      
      for(unsigned int ic = 0; ic < constituents.size();ic++){
        AliVParticle *part = (AliVParticle*)recParticles.At(constituents[ic].user_index());
@@ -995,17 +1070,7 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
      // correlation
      Float_t tmpPhi =  tmpRec.Phi();
      Float_t tmpEta =  tmpRec.Eta();
-     if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.;    
-     
-     Float_t tmpPtBack = 0;
-     if(externalBackground){
-       // carefull has to be filled in a task before
-       // todo, ReArrange to the botom
-       tmpPtBack = externalBackground->GetBackground(2)*tmpRec.EffectiveAreaCharged();
-     }
-     tmpPt = tmpPt - tmpPtBack;
-     if(tmpPt<0)tmpPt = 0; // avoid negative weights...
-
+     if(tmpPhi<0)tmpPhi+=TMath::Pi()*2.;        
      if(j==0){
        fh1PtJetsLeadingRecIn->Fill(tmpPt);
        fh2LeadingJetPhiEta->Fill(tmpPhi,tmpEta);
@@ -1027,11 +1092,12 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
        fh2JetsLeadingPhiPtWC[cenClass]->Fill(dPhi,pt,tmpPt);
      }
      fh2JetsLeadingPhiPtW->Fill(dPhi,pt,tmpPt);
-   }
+    }
    delete recIter;
   
    //background estimates:all bckg jets(0) & wo the 2 hardest(1)
  
+
    if(evBkg){
      vector<fastjet::PseudoJet> jets2=sortedJets;
      if(jets2.size()>2) jets2.erase(jets2.begin(),jets2.begin()+2); 
@@ -1233,17 +1299,18 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
  // do the event selection if activated
  if(fJetTriggerPtCut>0){
    bool select = false;
-   Float_t minPt = 9999999;
+   Float_t minPt = fJetTriggerPtCut;
+   /*
    // hard coded for now ...
-   // 54.50 44.5 29.5 18.5 for anti-kt rejection 10E-3
+   // 54.50 44.5 29.5 18.5 for anti-kt rejection 1E-3
    if(cent<10)minPt = 50;
    else if(cent<30)minPt = 42;
    else if(cent<50)minPt = 28;
    else if(cent<80)minPt = 18;
-   
+   */
    float rho = 0;
    if(externalBackground)rho = externalBackground->GetBackground(2);
-   if(jarray&&cent<80){
+   if(jarray){
      for(int i = 0;i < jarray->GetEntriesFast();i++){
        AliAODJet *jet = (AliAODJet*)jarray->At(i);
        Float_t ptSub = jet->Pt() - rho *jet->EffectiveAreaCharged();
@@ -1257,6 +1324,7 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
    if(select){
      static AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
      fh1CentralitySelect->Fill(cent);
+     fh1ZSelect->Fill(zVtx);
      aodH->SetFillAOD(kTRUE);
    }
  }