]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliLeading.cxx
coding conventions, compilation warnings, code cleanup
[u/mrichter/AliRoot.git] / JETAN / AliLeading.cxx
index b354faa29c55c3bd651120a9a1689bd4800ddb2a..b49b0c7676d72b02eb4c32ba64232506cc33b6ba 100644 (file)
@@ -32,15 +32,16 @@ ClassImp(AliLeading)
 
 ////////////////////////////////////////////////////////////////////////
 
-AliLeading::AliLeading() 
+AliLeading::AliLeading():
+  fNassoc(0),
+  fLeading(0),
+  fCorr(0),
+  fnBin(45),
+  fLow(-TMath::Pi()/2.0),
+  fFound(kFALSE)
 {
-  //
   // Constructor
-  //
-  fNassoc =  0;
   fLeading = new TLorentzVector(0.,0.,0.,0.);
-  fLow     = -TMath::Pi()/2.0;
-  fnBin    = 45;
   fCorr    = TArrayI(fnBin);
 }
 
@@ -48,59 +49,62 @@ AliLeading::AliLeading()
 
 AliLeading::~AliLeading()
 {
-  //
   // Destructor
-  //
   delete fLeading;
 }
 
 ////////////////////////////////////////////////////////////////////////
 
 void AliLeading::FindLeading(AliJetReader *reader)
-
 {
-  //
   // find leading particle in the array of lorentz vectors
   // lvArray and fill the correlation histogram
-  //
-
-    
+  
   AliJetReaderHeader* header = reader->GetReaderHeader();
-    
+  
   TClonesArray* lvArray = reader->GetMomentumArray();
   Int_t nIn = lvArray->GetEntries();
-  fNassoc = nIn-1;
-
-  if (fNassoc < 0) return;
-
+  
   // find max
   Double_t ptMax = 0.0;
   Int_t idxMax = -1;
   for (Int_t i = 0; i < nIn; i++){
-      TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
-      if (lv->Pt()   > ptMax                       && 
-         lv->Eta()  > header->GetFiducialEtaMin() &&
-         lv->Eta()  < header->GetFiducialEtaMax()) 
-      {
-         ptMax  = lv->Pt();
-         idxMax = i;
-      }
+    TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
+    if ((reader->GetCutFlag(i) == 1)             &&
+       lv->Pt()   > ptMax                       && 
+       lv->Eta()  > header->GetFiducialEtaMin() &&
+       lv->Eta()  < header->GetFiducialEtaMax()){
+      ptMax  = lv->Pt();
+      idxMax = i;
+    }
   }
   
-  if (idxMax == -1) return;
+  if (idxMax == -1) {
+    fFound = kFALSE;
+    Reset();
+    return;
+  }
   
   // fill correlation array
-  fLeading = (TLorentzVector*) lvArray->At(idxMax);
+  *fLeading = *((TLorentzVector*) lvArray->At(idxMax));
+  fFound = kTRUE;
+  
+  fNassoc = 0;  
   for (Int_t i = 0; i < nIn; i++) {
-      if (i == idxMax) continue;
-      TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
+    if (i == idxMax) continue;
+    TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
+    if ( (reader->GetCutFlag(i) == 1) &&
+        lv->Eta()  > header->GetFiducialEtaMin() &&
+        lv->Eta()  < header->GetFiducialEtaMax()) {
       Double_t dphi = fLeading->DeltaPhi(*lv);
       if (dphi < fLow) dphi = 2.0 * TMath::Pi() + dphi;
       // find bin and fill array
-      
-      Int_t iBin = (Int_t) TMath::Floor((dphi - fLow)
-                                       *((Double_t) fnBin) / (2.0 * TMath::Pi()));
+      Int_t iBin = (Int_t) 
+       TMath::Floor((dphi - fLow)
+                    *((Double_t) fnBin) / (2.0 * TMath::Pi()));
       fCorr.AddAt(fCorr.At(iBin)+1,iBin);
+      fNassoc++;
+    }
   }
 }
 
@@ -109,7 +113,7 @@ void AliLeading::FindLeading(AliJetReader *reader)
 void AliLeading::Reset()
 
 {
-// Reset leding particle information
+// Reset leading particle information
   fLeading->SetPxPyPzE(0., 0., 0., 0.);
   fNassoc=0;
   fCorr.Reset();
@@ -118,7 +122,6 @@ void AliLeading::Reset()
 ////////////////////////////////////////////////////////////////////////
 
 void AliLeading::PrintLeading()
-
 {
 // Print leading particle information
   if (fNassoc<0) {
@@ -133,3 +136,35 @@ void AliLeading::PrintLeading()
        << fLeading->Eta() << "," << fLeading->Phi() << ")" << endl;
   cout << "    " << fNassoc << " associated particles." << endl;
 }
+
+////////////////////////////////////////////////////////////////////////
+Double_t AliLeading::GetE()
+{
+  return fLeading->E();
+}
+////////////////////////////////////////////////////////////////////////
+Double_t AliLeading::GetPt()
+{
+  return fLeading->Pt();
+}
+////////////////////////////////////////////////////////////////////////
+Double_t AliLeading::GetEta()
+{
+  return fLeading->Eta();
+}
+////////////////////////////////////////////////////////////////////////
+Double_t AliLeading::GetPhi()
+{
+  // get phi of leading
+  return ( (fLeading->Phi() < 0) ? 
+          (fLeading->Phi()) + 2. * TMath::Pi() : 
+          fLeading->Phi());
+}
+