]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliUA1JetFinderV2.cxx
Adding OADB to CMake
[u/mrichter/AliRoot.git] / JETAN / AliUA1JetFinderV2.cxx
index f31da7019514ee72d5469cfc6a74fd9c69fc176c..76a4743728ac3f4d0358e131e7a64e27b19ebec7 100644 (file)
@@ -50,7 +50,6 @@ ClassImp(AliUA1JetFinderV2)
 AliUA1JetFinderV2::AliUA1JetFinderV2() :
   AliJetFinder(),
   fLego(0),  
-  fDebug(0),
   fOpt(0)
 {
   //
@@ -87,6 +86,7 @@ void AliUA1JetFinderV2::FindJetsC()
   AliUA1JetHeaderV1* header  = (AliUA1JetHeaderV1*) fHeader;
   TClonesArray*      lvArray = fReader->GetMomentumArray();
   Int_t              nIn     = lvArray->GetEntries();
+  fDebug   = fHeader->GetDebug();
   
   if (nIn == 0) return;
   
@@ -94,8 +94,8 @@ void AliUA1JetFinderV2::FindJetsC()
   Float_t* ptT    = new Float_t[nIn];
   Float_t* etaT   = new Float_t[nIn];
   Float_t* phiT   = new Float_t[nIn];
-  Float_t* cFlagT = new Float_t[nIn]; // Temporarily added
-  Float_t* sFlagT = new Float_t[nIn]; // Temporarily added
+  Int_t*   cFlagT = new Int_t[nIn]; // Temporarily added
+  Int_t*   sFlagT = new Int_t[nIn]; // Temporarily added
   Int_t*   injet  = new Int_t[nIn];
   
   //total energy in array
@@ -125,21 +125,21 @@ void AliUA1JetFinderV2::FindJetsC()
   Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS);
   
   // arrays to hold jets
-  Float_t* etaJet    = new Float_t[30];  // eta jet
-  Float_t* phiJet    = new Float_t[30];  // phi jet
-  Float_t* etJet     = new Float_t[30];  // et jet
-  Float_t* etsigJet  = new Float_t[30];  // signal et in jet
-  Float_t* etallJet  = new Float_t[30];  // total et in jet (tmp variable)
-  Int_t*   ncellsJet = new Int_t[30];
-  Int_t*   multJet   = new Int_t[30];
+  Float_t etaJet[30];  // eta jet
+  Float_t phiJet[30];  // phi jet
+  Float_t etJet[30];  // et jet
+  Float_t etsigJet[30];  // signal et in jet
+  Float_t etallJet[30];  // total et in jet (tmp variable)
+  Int_t   ncellsJet[30];
+  Int_t   multJet[30];
   //--- Added for jet reordering at the end of the jet finding procedure
-  Float_t* etaJetOk    = new Float_t[30];
-  Float_t* phiJetOk    = new Float_t[30];
-  Float_t* etJetOk     = new Float_t[30];
-  Float_t* etsigJetOk  = new Float_t[30];  // signal et in jet
-  Float_t* etallJetOk  = new Float_t[30];  // total et in jet (tmp variable)
-  Int_t*   ncellsJetOk = new Int_t[30];
-  Int_t*   multJetOk   = new Int_t[30];
+  Float_t etaJetOk[30];
+  Float_t phiJetOk[30];
+  Float_t etJetOk[30];
+  Float_t etsigJetOk[30];  // signal et in jet
+  Float_t etallJetOk[30];  // total et in jet (tmp variable)
+  Int_t   ncellsJetOk[30];
+  Int_t   multJetOk[30];
   //--------------------------
   Int_t nJets; // to hold number of jets found by algorithm
   Int_t nj;    // number of jets accepted
@@ -187,7 +187,7 @@ void AliUA1JetFinderV2::FindJetsC()
     if(header->GetBackgMode() == 4) //statistic
       SubtractBackgStat(nIn,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
     //calc precision
-    if(etbgTotalN != 0.0)
+    if(TMath::Abs(etbgTotalN) > 0.001)
       bgprec = (etbgTotal - etbgTotalN)/etbgTotalN;
     else
       bgprec = 0;
@@ -266,26 +266,13 @@ void AliUA1JetFinderV2::FindJetsC()
   delete[] cFlagT;
   delete[] sFlagT;
   delete[] injet;
-  delete[] hPtTotal;
-  delete[] etaJet;
-  delete[] phiJet;
-  delete[] etJet;
-  delete[] etsigJet;
-  delete[] etallJet;
-  delete[] ncellsJet;
-  delete[] multJet;
+  delete hPtTotal;
   delete[] idxjets;
+  delete[] idx;
+
   delete[] percentage;
   delete[] ncells;
   delete[] mult;
-  //--- Added for jet reordering
-  delete etaJetOk;
-  delete phiJetOk;
-  delete etJetOk;
-  delete etsigJetOk;
-  delete etallJetOk;
-  delete ncellsJetOk;
-  delete multJetOk;
   //--------------------------
 
 }
@@ -316,7 +303,6 @@ void AliUA1JetFinderV2::FindJets()
   Int_t              nIn      = fUnit->GetEntries();
   Float_t            ptMin   = fReader->GetReaderHeader()->GetPtCut();
 
-  fDebug   = fReader->GetReaderHeader()->GetDebug();
   if (nIn == 0) return;
 
   Int_t nCandidateCut = 0;
@@ -333,9 +319,9 @@ void AliUA1JetFinderV2::FindJets()
   Int_t*     detT      = new Int_t[nCandidate]; 
   Float_t*   etaT      = new Float_t[nCandidate];
   Float_t*   phiT      = new Float_t[nCandidate];
-  Float_t*   cFlagT    = new Float_t[nCandidate];
-  Float_t*   cFlag2T   = new Float_t[nCandidate];
-  Float_t*   sFlagT    = new Float_t[nCandidate];
+  Int_t*     cFlagT    = new Int_t[nCandidate];
+  Int_t*     cFlag2T   = new Int_t[nCandidate];
+  Int_t*     sFlagT    = new Int_t[nCandidate];
   Float_t*   cClusterT = new Float_t[nCandidate];
   Int_t*     vectT     = new Int_t[nCandidate];
   Int_t      loop1     = 0;
@@ -517,21 +503,21 @@ void AliUA1JetFinderV2::FindJets()
   Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS);
 
   // arrays to hold jets
-  Float_t* etaJet    = new Float_t[30];
-  Float_t* phiJet    = new Float_t[30];
-  Float_t* etJet     = new Float_t[30];
-  Float_t* etsigJet  = new Float_t[30]; //signal et in jet
-  Float_t* etallJet  = new Float_t[30];  // total et in jet (tmp variable)
-  Int_t*   ncellsJet = new Int_t[30];
-  Int_t*   multJet   = new Int_t[30];
+  Float_t etaJet[30];
+  Float_t phiJet[30];
+  Float_t etJet[30];
+  Float_t etsigJet[30]; //signal et in jet
+  Float_t etallJet[30];  // total et in jet (tmp variable)
+  Int_t   ncellsJet[30];
+  Int_t   multJet[30];
   //--- Added by me for jet reordering at the end of the jet finding procedure
-  Float_t* etaJetOk    = new Float_t[30];
-  Float_t* phiJetOk    = new Float_t[30];
-  Float_t* etJetOk     = new Float_t[30];
-  Float_t* etsigJetOk  = new Float_t[30]; //signal et in jet
-  Float_t* etallJetOk  = new Float_t[30];  // total et in jet (tmp variable)
-  Int_t*   ncellsJetOk = new Int_t[30];
-  Int_t*   multJetOk   = new Int_t[30];
+  Float_t etaJetOk[30];
+  Float_t phiJetOk[30];
+  Float_t etJetOk[30];
+  Float_t etsigJetOk[30]; //signal et in jet
+  Float_t etallJetOk[30];  // total et in jet (tmp variable)
+  Int_t   ncellsJetOk[30];
+  Int_t   multJetOk[30];
   //--------------------------
   Int_t    nJets; // to hold number of jets found by algorithm
   Int_t    nj;    // number of jets accepted
@@ -690,68 +676,55 @@ void AliUA1JetFinderV2::FindJets()
 
 
   //delete
-  delete ptT;
-  delete en2T;
-  delete pt2T;
-  delete etaT;
-  delete phiT;
+  delete [] ptT;
+  delete [] en2T;
+  delete [] pt2T;
+  delete [] etaT;
+  delete [] phiT;
+  delete [] detT;
+  delete [] cFlagT;
+  delete [] cFlag2T;
+  delete [] sFlagT;
+  delete [] cClusterT;
+  delete [] vectT;
+  delete [] injet;
+  delete [] sflag;
   trackRef->Delete();
   delete trackRef;
-  delete detT;
-  delete cFlagT;
-  delete cFlag2T;
-  delete sFlagT;
-  delete cClusterT;
-  delete vectT;
-  delete injet;
-  delete sflag;
+
   delete hPtTotal;
-  delete etCell;
-  delete etaCell;
-  delete phiCell;
-  delete flagCell;
-  delete etCell2;
-  delete etaCell2;
-  delete phiCell2;
-  delete flagCell2;
-  delete etaJet;
-  delete phiJet;
-  delete etJet;
-  delete etsigJet;
-  delete etallJet;
-  delete ncellsJet;
-  delete multJet;
-  //--- Added for jet reordering
-  delete etaJetOk;
-  delete phiJetOk;
-  delete etJetOk;
-  delete etsigJetOk;
-  delete etallJetOk;
-  delete ncellsJetOk;
-  delete multJetOk;
+  delete [] etCell;
+  delete [] etaCell;
+  delete [] phiCell;
+  delete [] flagCell;
+  delete [] etCell2;
+  delete [] etaCell2;
+  delete [] phiCell2;
+  delete [] flagCell2;
   //--------------------------
-  delete trackinjet;
-  delete idxjets;
-  delete percentage;
-  delete ncells;
-  delete mult;
+  delete [] idxjets;
+  delete [] idx;
+  delete [] trackinjet;
+
+  delete [] percentage;
+  delete [] ncells;
+  delete [] mult;
 
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliUA1JetFinderV2::RunAlgoritm(Int_t nIn, Float_t* etCell, Float_t* etaCell, Float_t* phiCell, 
-                                   Int_t* flagCell, const Float_t* etCell2, const Float_t* etaCell2, 
-                                   const Float_t* phiCell2, const Int_t* flagCell2, Float_t etbgTotal, 
-                                   Double_t dEtTotal, Int_t& nJets, Float_t* etJet,Float_t* etaJet, 
-                                   Float_t* phiJet, Float_t* etallJet, Int_t* ncellsJet)
+void AliUA1JetFinderV2::RunAlgoritm(Int_t nIn, Float_t* etCell, Float_t* const etaCell, Float_t* phiCell, 
+                  Int_t* const flagCell, const Float_t* etCell2, const Float_t* etaCell2, const Float_t* phiCell2, 
+                  const Int_t* flagCell2, Float_t etbgTotal, Double_t dEtTotal, 
+                  Int_t& nJets, Float_t* const etJet, Float_t* const etaJet, Float_t* const phiJet,
+                  Float_t* const etallJet, Int_t* const ncellsJet)
 {
   //
   // Main method for jet finding
   // UA1 base cone finder
   //
 
-  Int_t nCell  = nIn; 
-  fDebug = fReader->GetReaderHeader()->GetDebug();
+  Int_t nCell  = nIn;
 
   // Dump lego
   // Check enough space! *to be done*
@@ -932,14 +905,14 @@ void AliUA1JetFinderV2::RunAlgoritm(Int_t nIn, Float_t* etCell, Float_t* etaCell
     }
 
   //delete
-  delete index;
+  delete[] index;
 
 }
 
 ////////////////////////////////////////////////////////////////////////
 void AliUA1JetFinderV2::RunAlgoritmC(Float_t etbgTotal, Double_t dEtTotal, Int_t& nJets,
-                                  Float_t* etJet,Float_t* etaJet, Float_t* phiJet,
-                                  Float_t* etallJet, Int_t* ncellsJet)
+                  Float_t* const etJet,Float_t* const etaJet, Float_t* const phiJet,
+                  Float_t* const etallJet, Int_t* const ncellsJet)
 {
   // Dump lego
   // Check enough space! *to be done*
@@ -1136,16 +1109,16 @@ void AliUA1JetFinderV2::RunAlgoritmC(Float_t etbgTotal, Double_t dEtTotal, Int_t
     }
   
   //delete
-  delete index;
-  delete idx;
+  delete [] index;
+  delete [] idx;
 
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliUA1JetFinderV2::SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t&etbgTotalN, const Float_t* ptT, 
-                                     const Int_t*vectT, const Float_t* etaT, const Float_t* phiT, const Float_t* cFlagT, 
-                                     const Float_t* cFlag2T, const Float_t* sFlagT, Float_t* etJet, const Float_t* etaJet, 
-                                     const Float_t* phiJet, Float_t* etsigJet, Int_t* multJet, Int_t* injet)
+void AliUA1JetFinderV2::SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t& etbgTotalN, const Float_t* ptT, const Int_t* vectT, 
+                                     const Float_t* etaT, const Float_t* phiT, const Int_t* cFlagT, const Int_t* cFlag2T, 
+                                     const Int_t* sFlagT, Float_t* const etJet, const Float_t* etaJet, const Float_t* phiJet, 
+                                     Float_t* const etsigJet, Int_t* const multJet, Int_t* const injet)
 {
   //
   // Background subtraction using cone method but without correction in dE/deta distribution
@@ -1155,7 +1128,6 @@ void AliUA1JetFinderV2::SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t&
   //calculate energy inside and outside cones
   AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
   fOpt = fReader->GetReaderHeader()->GetDetector();
-  fDebug = fReader->GetReaderHeader()->GetDebug();
   Float_t rc= header->GetRadius();
   Float_t etIn[30];
   Float_t etOut = 0;
@@ -1349,9 +1321,9 @@ void AliUA1JetFinderV2::SubtractBackg(const Int_t& nIn, const Int_t&nJ, Float_t&
 
 ////////////////////////////////////////////////////////////////////////
 void AliUA1JetFinderV2::SubtractBackgC(const Int_t& nIn, const Int_t&nJ, Float_t&etbgTotalN,
-                                      const Float_t* ptT, const Float_t* etaT, const Float_t* phiT,
-                                      Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet,
-                                      Int_t* multJet, Int_t* injet)
+                      const Float_t* ptT, const Float_t* etaT, const Float_t* phiT,
+                      Float_t* const etJet, const Float_t* etaJet, const Float_t* phiJet,
+                      Float_t* const etsigJet,Int_t* const multJet, Int_t* const injet)
 {
   //background subtraction using cone method but without correction in dE/deta distribution
   
@@ -1415,9 +1387,9 @@ void AliUA1JetFinderV2::SubtractBackgC(const Int_t& nIn, const Int_t&nJ, Float_t
 
 ////////////////////////////////////////////////////////////////////////
 void AliUA1JetFinderV2::SubtractBackgStat(const Int_t& nIn, const Int_t&nJ,Float_t&etbgTotalN,
-                     const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, const Float_t* cFlagT, 
-                     const Float_t* sFlagT, Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, 
-                     Float_t* etsigJet, Int_t* multJet, Int_t* injet)
+                                         const Float_t* ptT, const Float_t* etaT, const Float_t* phiT, const Int_t* cFlagT, 
+                                         const Int_t* sFlagT, Float_t* const etJet, const Float_t* etaJet, const Float_t* phiJet,
+                                         Float_t* const etsigJet, Int_t* const multJet, Int_t* const injet)
 {
 
   //background subtraction using statistical method
@@ -1479,10 +1451,10 @@ void AliUA1JetFinderV2::SubtractBackgStat(const Int_t& nIn, const Int_t&nJ,Float
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliUA1JetFinderV2::SubtractBackgCone(const Int_t& nIn, const Int_t&nJ,Float_t& etbgTotalN, Float_t* ptT,
-                                         Float_t* etaT, const Float_t* phiT, const Float_t* cFlagT, const Float_t* sFlagT,
-                                         Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet,
-                                         Int_t* multJet, Int_t* injet)
+void AliUA1JetFinderV2::SubtractBackgCone(const Int_t& nIn, const Int_t&nJ,Float_t& etbgTotalN,
+                      Float_t* ptT, Float_t* etaT, const Float_t* phiT, const Int_t* cFlagT, const Int_t* sFlagT,
+                      Float_t* const etJet, const Float_t* etaJet, const Float_t* phiJet,
+                      Float_t* const etsigJet, Int_t* const multJet, Int_t* const injet)
 {
   // Cone background subtraction method taking into acount dEt/deta distribution
   AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
@@ -1594,9 +1566,9 @@ void AliUA1JetFinderV2::SubtractBackgCone(const Int_t& nIn, const Int_t&nJ,Float
 
 ////////////////////////////////////////////////////////////////////////
 void AliUA1JetFinderV2::SubtractBackgRatio(const Int_t& nIn, const Int_t&nJ,Float_t& etbgTotalN,
-                     Float_t* ptT, Float_t* etaT, const Float_t* phiT, const Float_t* cFlagT, const Float_t* sFlagT,
-                     Float_t* etJet, const Float_t* etaJet, const Float_t* phiJet, Float_t* etsigJet,
-                     Int_t* multJet, Int_t* injet)
+                      Float_t* ptT, Float_t* etaT, const Float_t* phiT, const Int_t* cFlagT, const Int_t* sFlagT,
+                      Float_t* const etJet, const Float_t* etaJet, const Float_t* phiJet,
+                      Float_t* const etsigJet, Int_t* const multJet, Int_t* const injet)
 {
   // Ratio background subtraction method taking into acount dEt/deta distribution
   AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
@@ -1715,7 +1687,7 @@ void AliUA1JetFinderV2::Reset()
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliUA1JetFinderV2::WriteJHeaderToFile()
+void AliUA1JetFinderV2::WriteJHeaderToFile() const
 {
   AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
   header->Write();
@@ -1733,7 +1705,7 @@ void AliUA1JetFinderV2::InitTask(TChain* tree)
                   header->GetLegoEtaMax(),  header->GetLegoNbinPhi(),
                   header->GetLegoPhiMin(),  header->GetLegoPhiMax());
   
-  fDebug = fReader->GetReaderHeader()->GetDebug();
+  fDebug = fHeader->GetDebug();
   fOpt = fReader->GetReaderHeader()->GetDetector();
   
   // Tasks initialization