]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliDAJetFinder.cxx
added protection for missing AODEvent in cases we write only delta AOD (Andrei G.)
[u/mrichter/AliRoot.git] / JETAN / AliDAJetFinder.cxx
index c4613db59c617ff190fe85691ca3937b34e7b254..deb3b5c7e3b9faa55955635215113911bb124465 100644 (file)
@@ -60,6 +60,7 @@ void AliDAJetFinder::FindJets()
 // Find the jets in current event
 // 
        Float_t betaStop=100.;
+    fDebug = fHeader->GetDebug();
 
        Double_t dEtSum=0;
        Double_t *xData[2];
@@ -455,16 +456,19 @@ void AliDAJetFinder::StoreJets(Int_t nk,Double_t **xData,  Int_t *xx,  TMatrixD
        delete [] surf;
        
 //now add selected jets to the list
-       Int_t *inJet = new Int_t[fNin];
+       Int_t *iSort = new Int_t[nk];
+    TMath::Sort(nk,etNoBg,iSort,true);
+    Int_t iCl = 0;
        TRefArray *refs = 0;
        Bool_t fromAod = !strcmp(fReader->ClassName(),"AliJetAODReader");
        if (fromAod) refs = fReader->GetReferences();
        for (Int_t iClust=0; iClust<nk; iClust++){                                                                      //clusters loop
-               if (isJet[iClust]){                                                                                                             //choose cluster
+               iCl=iSort[iClust];
+               if (isJet[iCl]){                                                                                                                //choose cluster
                        Float_t px,py,pz,en;
-                       px = (*mY)(3,iClust)*TMath::Cos((*mY)(1,iClust));
-                       py = (*mY)(3,iClust)*TMath::Sin((*mY)(1,iClust));
-                       pz = (*mY)(3,iClust)/TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-(*mY)(0,iClust))));
+                       px = (*mY)(3,iCl)*TMath::Cos((*mY)(1,iCl));
+                       py = (*mY)(3,iCl)*TMath::Sin((*mY)(1,iCl));
+                       pz = (*mY)(3,iCl)/TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-(*mY)(0,iCl))));
                        en = TMath::Sqrt(px * px + py * py + pz * pz);
                        AliAODJet jet(px, py, pz, en);
                        if (fromAod){
@@ -472,18 +476,18 @@ void AliDAJetFinder::StoreJets(Int_t nk,Double_t **xData,  Int_t *xx,  TMatrixD
                                Int_t nEntr = fReader->GetMomentumArray()->GetEntries();
                                for (Int_t iEn=0; iEn<nEntr; iEn++){
                                        if (fReader->GetCutFlag(iEn)==0) continue;
-                                       if (xx[iIn]==iClust) jet.AddTrack(refs->At(iEn));
+                                       if (xx[iIn]==iCl) jet.AddTrack(refs->At(iEn));
                                        iIn++;
                                }
                        }
                        AddJet(jet);
-                       printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iClust,jet.Eta(),jet.Phi(),jet.Pt());
+                       if (fDebug > 0) printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iCl,jet.Eta(),jet.Phi(),jet.Pt());
                }
        }
        delete [] dDeltaEta; delete [] dDeltaPhi;
        delete [] etNoBg;
        delete [] isJet;
-       delete [] inJet;
+       delete [] iSort;
 }
 
 //-----------------------------------------------------------------------------------