]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
* fixed bug while getting leading jet candidate
authorjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Jun 2009 18:19:42 +0000 (18:19 +0000)
committerjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Jun 2009 18:19:42 +0000 (18:19 +0000)
* better protection for grid indices

HLT/JET/cone/AliHLTJETConeFinder.cxx

index 79dcc2bcdefbfcdb2b2095de80997b17f581ad43..4a134dea8064597f1a585945b30642f7e612b18c 100644 (file)
@@ -215,26 +215,31 @@ Int_t AliHLTJETConeFinder::FindConeLeading() {
 
   // -- Pick up jet reader
   AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader);
-  
+
   // -- Pick up jet canidates
   TClonesArray* jetCandidates = reader->GetJetCandidates();
   
-  // -- Sort jet candidates with seed pt 
-  jetCandidates->Sort();
-  // -- Use leading seed only
-  //    Keep index 0, remove the others
-  if ( (dynamic_cast<AliHLTJETConeHeader*> (fHeader))->GetUseLeading() ) {
+  // -- Check for more than 1 jet candidate
+  if ( reader->GetNJetCandidates() > 1 ) {
     
-    for ( Int_t iter = 1; iter < reader->GetNJetCandidates(); iter++ )
-      jetCandidates->RemoveAt(iter);
+    // -- Sort jet candidates with seed pt 
+    jetCandidates->Sort();
     
-    reader->SetNJetCandidates(1);
-  }
-  
+    // -- Use leading seed only
+    //    Keep index 0, remove the others
+    if ( (dynamic_cast<AliHLTJETConeHeader*> (fHeader))->GetUseLeading() ) {
+      
+      for ( Int_t iter = 1; iter < reader->GetNJetCandidates(); iter++ )
+       jetCandidates->RemoveAt(iter);
+      
+      reader->SetNJetCandidates(1);
+    }
+
+  } // if ( reader->GetNJetCandidates() > 1 ) {
+
   // -- Resize the seed TClonesArray
   jetCandidates->Compress();
-
+  
   return 0;
 }
 
@@ -261,7 +266,7 @@ Int_t AliHLTJETConeFinder::FindConeJets() {
     Int_t cellIdx = 0;
     
     // -- Loop over cells around ssed
-    while ( (cellIdx = fGrid->NextCell() ) != -1 && !iResult) {
+    while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) {
 
       AliHLTJETConeEtaPhiCell* cell = NULL;
       if ( ! (cell = reinterpret_cast<AliHLTJETConeEtaPhiCell*>(fGrid->UncheckedAt(cellIdx))) )
@@ -271,7 +276,7 @@ Int_t AliHLTJETConeFinder::FindConeJets() {
        HLTError( "Error adding cell %d to jet candiate %d", cellIdx, iter);
        continue;
       }
-    } // while ( (cellIdx = fGrid->NextCell() ) != -1 && !iResult) {
+    } // while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) {
     
   } // for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) {