]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliCdfJetFinder.cxx
Changes to read input jet branch from InputEvent, needs to be set in Notify
[u/mrichter/AliRoot.git] / JETAN / AliCdfJetFinder.cxx
index 4a88372f8993a5ce49953ef9554a3d7025b68fec..3da21c5cc56fafbb2810717e01335c994f0d22db 100644 (file)
@@ -4,7 +4,7 @@
  * Author: The ALICE Off-line Project.                                    *
  * Contributors are mentioned in the code where appropriate.              *
  *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
+ * Permission to usec, copy, modify and distribute this software and its   *
  * documentation strictly for non-commercial purposes is hereby granted   *
  * without fee, provided that the above copyright notice appears in all   *
  * copies and that both the copyright notice and this permission notice   *
@@ -46,7 +46,6 @@ Changelog
 
 #include "AliJetReader.h"
 #include "AliJetReaderHeader.h"
-#include "AliJet.h"
 #include "AliAODJet.h"
 #include "AliAODEvent.h"
 #include "AliJetFinder.h"
@@ -60,10 +59,10 @@ ClassImp(AliCdfJetFinder)
 AliCdfJetFinder::AliCdfJetFinder():
     AliJetFinder(),
     fHistos(0),
-    fDebug(0),
     fFromAod(0),
     fAODwrite(0),
     fAODtracksWrite(0),
+    fAnalyseJets(0),
     fRefArr (NULL),
     fNJets(-9999),
     fNPart(-9999),
@@ -79,6 +78,7 @@ AliCdfJetFinder::AliCdfJetFinder():
 //______________________________________________________________________________
 AliCdfJetFinder::~AliCdfJetFinder()
   {
+    Clean();
   // destructor
   }
 
@@ -335,12 +335,12 @@ void AliCdfJetFinder::FindJets()
 //  * Go to the next highest PT particle (not already included in a jet) and include in the "jet" all particles
 //     (not already included in a jet) within the radius R =0.7.
 //  * Continue until all particles are in a "jet".
-
+  if (fDebug) { printf("AliCDJetfinder::FindJets() %d \n", __LINE__ ); }
 AliCdfJetHeader *header = (AliCdfJetHeader*)fHeader;
 
   if (header)
     {
-    fDebug            = header->IsDebugCDF();
+    fDebug            = header->GetDebug();
     fAODwrite         = header->IsAODwrite() ;       // write jets to AOD
     fAODtracksWrite   = header->IsAODtracksWrite() ; // write jet tracks to AOD
     fRadius           = header->GetRadius();      // get Radius from jet finder header
@@ -358,17 +358,27 @@ if (fAODwrite)
 
 InitData();
 
-if (!fNPart) { if (fDebug) {cout << "entries = 0 ; Event empty !!!" << endl ;} return; } // if event empty then exit
-
-FindCones();
-
-ComputeConesWeight();
-
-if (fAODwrite) { cout << "Writing AOD" << endl ; WriteJets(); }
-
-AnalizeJets();
-
-Clean();
+ if (!fNPart) { 
+  if (fDebug) {
+    cout << "entries = 0 ; Event empty !!!" << endl ;
+  }
+  // no need to call clean, InitData does not 
+  // create pointers if npart == 0
+  return; 
+ } // if event empty then exit
+
+ FindCones();
+ ComputeConesWeight();
+ if (fAODwrite) { 
+   if(fDebug)cout << "Writing AOD" << endl ; 
+   WriteJets();
+ }
+ if (fAnalyseJets) AnalizeJets();
+ Clean();
 
 }
 
@@ -378,14 +388,12 @@ void AliCdfJetFinder::InitData()
 // initialisation of variables and data members
 
   TClonesArray * vectArray = fReader->GetMomentumArray() ;
-    if ( vectArray == 0 ) { cout << "Could not get the momentum array" << endl; return; }
+  if ( vectArray == 0 ) { cout << "Could not get the momentum array" << endl; return; }
 
   fNPart = vectArray->GetEntries()  ; // n particles in this event;
 
   if ( fNPart == 0 ) { return ; } // if event empty then exit
 
-  fJets->SetNinput ( fNPart ) ; // number of input objects
-
   fVectParticle = new varContainer* [fNPart]; // container for Particles
 
   fPtArray  = new Double_t [fNPart] ; // momentum array
@@ -430,7 +438,7 @@ void AliCdfJetFinder::FindCones()
 
   if (fDebug) { cout << "\n\n\n\n\n\n------------------\nBegin Event Analysis\n------------------\n\n" << endl ;}
 
-  cout << "fNPart = " << fNPart << endl;
+  if(fDebug)cout << "fNPart = " << fNPart << endl;
 
   TBits lkupTable ( fNPart ) ;  // bit container ; 1-to-1 corespondence with fIdxArray
 
@@ -438,7 +446,7 @@ void AliCdfJetFinder::FindCones()
     { // loop over particles in event until all flags are set
     UInt_t firstnonflagged = lkupTable.FirstNullBit() ; // set the index to the first NON flagged bit ; less conditions
 
-    cout << "\n\nfirst_non_flagged : " << firstnonflagged << endl;
+    if(fDebug)cout << "\n\nfirst_non_flagged : " << firstnonflagged << endl;
 
     ++fNJets; // incrementing the jet counter
     if (fDebug) { printf("JET %d \n", fNJets); }
@@ -583,16 +591,17 @@ for(  Int_t jetnr = 0 ; jetnr < fNJets ; jetnr++ )
   en = TMath::Sqrt ( px * px + py * py + pz * pz );
 
   AliAODJet jet (px, py, pz, en);
-  AddJet(jet);
+
 
   if (fDebug) jet.Print("");
 
   if (fFromAod && fAODtracksWrite)
     {
-    for (  Int_t jetTrack = 0; jetTrack < fNPart; jetTrack++ )
-      { if ( fVectParticle[jetTrack]->njet == jetnr ) { jet.AddTrack(fRefArr->At(jetTrack)) ; } }
+      for (  Int_t jetTrack = 0; jetTrack < fNPart; jetTrack++ )
+       { if ( fVectParticle[jetTrack]->njet == jetnr ) { jet.AddTrack(fRefArr->At(jetTrack)) ; } }
     }
-    // tracks REFs written in AOD
+  // tracks REFs written in AOD
+  AddJet(jet);
 
   }
 //jets vector parsed and written to AOD
@@ -604,6 +613,8 @@ void AliCdfJetFinder::AnalizeJets()
 {
 // analyzing of jets and filling of histograms
 
+    const Double_t kPI = TMath::Pi();
+    
   //persistent pointer to histo20
   TH1F *hR = (TH1F*)fHistos->FindObject("histo20");
 
@@ -887,10 +898,20 @@ for(  Int_t part = 0 ; part < fNPart ; part++ )
 void AliCdfJetFinder::Clean()
 {
 // CLEANING SECTION
-  delete [] fVectParticle;
-  delete [] fVectJet;
-  delete [] fPtArray;
-  delete [] fIdxArray;
+  for (  Int_t i = 0 ; i < fNPart ; i++ ){
+    delete fVectParticle[i];
+    fVectParticle[i] = 0;
+  }
+  delete [] fVectParticle;fVectParticle = 0;
+
+  for (  Int_t i = 0 ; i < fNJets ; i++ ){
+    delete fVectJet[i];
+    fVectJet[i] = 0;
+  } 
+  delete [] fVectJet;fVectJet = 0;
+
+  delete [] fPtArray;fPtArray = 0;
+  delete [] fIdxArray;fIdxArray = 0;
 
   Reset();
 }