]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALJetFinder.cxx
Reduced convention violations
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetFinder.cxx
index 27ad49ced2a3ebb99f8ed538b8bd75c955f24b81..d438bc7d5777024fb2394b995e1173d2ddb5618f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.38  2003/01/28 16:08:11  morsch
-Particle loading according to generator type.
-
-Revision 1.37  2003/01/23 11:50:04  morsch
-- option for adding energy of all particles (ich == 2)
-- provisions for principle component analysis
-(M. Horner)
-
-Revision 1.36  2003/01/15 19:05:44  morsch
-Updated selection in ReadFromTracks()
-
-Revision 1.35  2003/01/15 04:59:38  morsch
-- TPC eff. from AliEMCALFast
-- Correction in PropagatePhi()
-
-Revision 1.34  2003/01/14 10:50:18  alibrary
-Cleanup of STEER coding conventions
-
-Revision 1.33  2003/01/10 10:48:19  morsch
-SetSamplingFraction() removed from constructor.
-
-Revision 1.32  2003/01/10 10:26:40  morsch
-Sampling fraction initialized from geometry class.
-
-Revision 1.31  2003/01/08 17:13:41  schutz
-added the HCAL section
-
-Revision 1.30  2002/12/09 16:26:28  morsch
-- Nummber of particles per jet increased to 1000
-- Warning removed.
-
-Revision 1.29  2002/11/21 17:01:40  alibrary
-Removing AliMCProcess and AliMC
-
-Revision 1.28  2002/11/20 14:13:16  morsch
-- FindChargedJets() added.
-- Destructor corrected.
-- Geometry cuts taken from AliEMCALGeometry.
-
-Revision 1.27  2002/11/15 17:39:10  morsch
-GetPythiaParticleName removed.
-
-Revision 1.26  2002/10/14 14:55:35  hristov
-Merging the VirtualMC branch to the main development branch (HEAD)
-
-Revision 1.20.4.3  2002/10/10 15:07:49  hristov
-Updating VirtualMC to v3-09-02
-
-Revision 1.25  2002/09/13 10:24:57  morsch
-idem
-
-Revision 1.24  2002/09/13 10:21:13  morsch
-No cast to AliMagFCM.
-
-Revision 1.23  2002/06/27 09:24:26  morsch
-Uncomment the TH1::AddDirectory statement.
-
-Revision 1.22  2002/05/22 13:48:43  morsch
-Pdg code added to track list.
-
-Revision 1.21  2002/04/27 07:43:08  morsch
-Calculation of fDphi corrected (Renan Cabrera)
-
-Revision 1.20  2002/03/12 01:06:23  pavlinov
-Testin output from generator
-
-Revision 1.19  2002/02/27 00:46:33  pavlinov
-Added method FillFromParticles()
-
-Revision 1.18  2002/02/21 08:48:59  morsch
-Correction in FillFromHitFlaggedTrack. (Jennifer Klay)
-
-Revision 1.17  2002/02/14 08:52:53  morsch
-Major updates by Aleksei Pavlinov:
-FillFromPartons, FillFromTracks, jetfinder configuration.
-
-Revision 1.16  2002/02/08 11:43:05  morsch
-SetOutputFileName(..) allows to specify an output file to which the
-reconstructed jets are written. If not set output goes to input file.
-Attention call Init() before processing.
-
-Revision 1.15  2002/02/02 08:37:18  morsch
-Formula for rB corrected.
-
-Revision 1.14  2002/02/01 08:55:30  morsch
-Fill map with Et and pT.
-
-Revision 1.13  2002/01/31 09:37:36  morsch
-Geometry parameters in constructor and call of SetCellSize()
-
-Revision 1.12  2002/01/23 13:40:23  morsch
-Fastidious debug print statement removed.
-
-Revision 1.11  2002/01/22 17:25:47  morsch
-Some corrections for event mixing and bg event handling.
-
-Revision 1.10  2002/01/22 10:31:44  morsch
-Some correction for bg mixing.
-
-Revision 1.9  2002/01/21 16:28:42  morsch
-Correct sign of dphi.
-
-Revision 1.8  2002/01/21 16:05:31  morsch
-- different phi-bin for hadron correction
-- provisions for background mixing.
-
-Revision 1.7  2002/01/21 15:47:18  morsch
-Bending radius correctly in cm.
-
-Revision 1.6  2002/01/21 12:53:50  morsch
-authors
-
-Revision 1.5  2002/01/21 12:47:47  morsch
-Possibility to include K0long and neutrons.
-
-Revision 1.4  2002/01/21 11:03:21  morsch
-Phi propagation introduced in FillFromTracks.
-
-Revision 1.3  2002/01/18 05:07:56  morsch
-- hadronic correction
-- filling of digits
-- track selection upon EMCAL information
-
-*/
+/* $Id$ */
 
 //*-- Authors: Andreas Morsch   (CERN)
 //*            J.L. Klay        (LBL)
 //*            Aleksei Pavlinov (WSU) 
+//--
+//--
+//
 
 #include <stdio.h>
 // From root ...
@@ -181,8 +59,10 @@ Revision 1.3  2002/01/18 05:07:56  morsch
 #include "AliMagFCM.h"
 #include "AliRun.h"
 #include "AliGenerator.h"
+#include "AliEMCALGetter.h"
 // Interface to FORTRAN
 #include "Ecommon.h"
+#include "AliMC.h"
 
 
 ClassImp(AliEMCALJetFinder)
@@ -349,9 +229,11 @@ void AliEMCALJetFinder::Init()
 //
 //
 //  Geometry 
-    AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
-    AliEMCALGeometry* geom = 
-    AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
+  //AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
+  //  AliEMCALGeometry* geom = 
+  //  AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
+  AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+  AliEMCALGeometry* geom = gime->EMCALGeometry() ;  
 
 //    SetSamplingFraction(geom->GetSampling());
 
@@ -375,15 +257,15 @@ void AliEMCALJetFinder::Init()
 //
 }
 
-void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncell_tot, Float_t etc[30000], 
+void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncelltot, Float_t etc[30000], 
                             Float_t etac[30000], Float_t phic[30000],
-                            Float_t min_move, Float_t max_move, Int_t mode, 
-                            Float_t prec_bg,  Int_t   ierror)
+                            Float_t minmove, Float_t maxmove, Int_t mode, 
+                            Float_t precbg,  Int_t   ierror)
 {
 // Wrapper for fortran coded jet finder
 // Full argument list
-    jet_finder_ua1(ncell, ncell_tot, etc, etac, phic, 
-                  min_move, max_move, mode, prec_bg, ierror);
+    jet_finder_ua1(ncell, ncelltot, etc, etac, phic, 
+                  minmove, maxmove, mode, precbg, ierror);
     // Write result to output
     if(fWrite) WriteJets();
     fEvent++;
@@ -394,15 +276,15 @@ void AliEMCALJetFinder::Find()
 // Wrapper for fortran coded jet finder using member data for 
 // argument list
 
-    Float_t min_move = fMinMove;
-    Float_t max_move = fMaxMove;
+    Float_t minmove = fMinMove;
+    Float_t maxmove = fMaxMove;
     Int_t   mode     = fMode;
-    Float_t prec_bg  = fPrecBg;
+    Float_t precbg  = fPrecBg;
     Int_t   ierror;
     ResetJets(); // 4-feb-2002 by PAI
 
     jet_finder_ua1(fNcell, fNtot, fEtCell, fEtaCell, fPhiCell, 
-                  min_move, max_move, mode, prec_bg, ierror);
+                  minmove, maxmove, mode, precbg, ierror);
     fError = ierror;
     // Write result to output
     Int_t njet = Njets();
@@ -424,7 +306,6 @@ void AliEMCALJetFinder::Find()
         fJetT[nj]->SetIsWeightedEnergy(fWeightingMethod); 
         fJetT[nj]->SetEMCALEnergy( EMCALConeEnergy(JetEtaW(nj),JetPhiW(nj)) ); 
         fJetT[nj]->SetTrackEnergy(TrackConeEnergy( JetEtaW(nj),JetPhiW(nj)  )); 
-        fJetT[nj]->SetHCEnergy(HCConeEnergy( JetEtaW(nj),JetPhiW(nj)  )); 
        
     }
 
@@ -436,6 +317,7 @@ void AliEMCALJetFinder::Find()
 
 Float_t AliEMCALJetFinder::EMCALConeEnergy(Float_t eta, Float_t phi)
 {
+// Calculate the energy in the cone    
 Float_t newenergy = 0.0;
 Float_t bineta,binphi;
 TAxis *x = fhLegoEMCAL->GetXaxis();
@@ -457,6 +339,7 @@ return newenergy;
 
 Float_t AliEMCALJetFinder::TrackConeEnergy(Float_t eta, Float_t phi)
 {
+// Calculate the track energy in the cone      
 Float_t newenergy = 0.0;
 Float_t bineta,binphi;
 TAxis *x = fhLegoTracks->GetXaxis();
@@ -476,36 +359,11 @@ for (Int_t i = 0 ; i < fNbinEta  ; i++) // x coord
 return newenergy;
 }
 
-Float_t AliEMCALJetFinder::HCConeEnergy(Float_t eta, Float_t phi)
-{
-//Float_t newenergy = 0.0;
-//Float_t bineta,binphi;
-//TAxis *x = fhLegoTracks->GetXaxis();
-//TAxis *y = fhLegoTracks->GetYaxis();
-//for (Int_t i = 0 ; i < fNbinEta  ; i++) // x coord
-//   {
-//      for (Int_t j = 0 ; j < fNbinPhi  ; j++)  // y coord
-//      {
-//        bineta = x->GetBinCenter(i);
-//        binphi = y->GetBinCenter(j);
-//        if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
-//        {
-//            newenergy += fhLegoTracks->GetBinContent(i,j);
-//         }
-//    }
-//}
-//return newenergy;
-       
-return 0.0;    
-       
-}
-
-
 
 Float_t AliEMCALJetFinder::WeightedJetEnergy(Float_t eta, Float_t phi)
 {
-
-
+// Calculate the weighted jet energy
+        
 Float_t newenergy = 0.0;
 Float_t bineta,binphi;
 TAxis *x = fhLegoEMCAL->GetXaxis();
@@ -530,38 +388,38 @@ return newenergy;
 }
 
        
-Int_t AliEMCALJetFinder::Njets()
+Int_t AliEMCALJetFinder::Njets() const
 {
 // Get number of reconstructed jets
     return EMCALJETS.njet;
 }
 
-Float_t AliEMCALJetFinder::JetEnergy(Int_t i)
+Float_t AliEMCALJetFinder::JetEnergy(Int_t i) const
 {
 // Get reconstructed jet energy
     return EMCALJETS.etj[i];
 }
 
-Float_t AliEMCALJetFinder::JetPhiL(Int_t i)
+Float_t AliEMCALJetFinder::JetPhiL(Int_t i) const
 {
 // Get reconstructed jet phi from leading particle
     return EMCALJETS.phij[0][i];
 }
 
-Float_t AliEMCALJetFinder::JetPhiW(Int_t i)
+Float_t AliEMCALJetFinder::JetPhiW(Int_t i) const
 {
 // Get reconstructed jet phi from weighting
     return EMCALJETS.phij[1][i];
 }
 
-Float_t  AliEMCALJetFinder::JetEtaL(Int_t i)
+Float_t  AliEMCALJetFinder::JetEtaL(Int_t i) const
 {
 // Get reconstructed jet eta from leading particles
     return EMCALJETS.etaj[0][i];
 }
 
 
-Float_t  AliEMCALJetFinder::JetEtaW(Int_t i)  
+Float_t  AliEMCALJetFinder::JetEtaW(Int_t i)  const
 {
 // Get reconstructed jet eta from weighting
     return EMCALJETS.etaj[1][i];
@@ -614,22 +472,22 @@ void AliEMCALJetFinder::Test()
 //
 // Test the finder call
 //
-    const Int_t nmax = 30000;
+    const Int_t knmax = 30000;
     Int_t ncell      = 10;
-    Int_t ncell_tot  = 100;
+    Int_t ncelltot  = 100;
 
-    Float_t etc[nmax];
-    Float_t etac[nmax];
-    Float_t phic[nmax];
-    Float_t min_move = 0;
-    Float_t max_move = 0;
+    Float_t etc[knmax];
+    Float_t etac[knmax];
+    Float_t phic[knmax];
+    Float_t minmove = 0;
+    Float_t maxmove = 0;
     Int_t   mode = 0;
-    Float_t prec_bg = 0;
+    Float_t precbg = 0;
     Int_t   ierror = 0;
 
     
-    Find(ncell, ncell_tot, etc, etac, phic, 
-        min_move, max_move, mode, prec_bg, ierror);
+    Find(ncell, ncelltot, etc, etac, phic, 
+        minmove, maxmove, mode, precbg, ierror);
 
 }
 
@@ -672,43 +530,52 @@ void AliEMCALJetFinder::WriteJets()
     }
 
 // I/O
+    AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
     if (!fOutFileName) {
 //
 // output written to input file
 //
-       AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
-       TTree* pK = gAlice->TreeK();
-       file = (pK->GetCurrentFile())->GetName();
+      AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
+      TTree* pK = gAlice->TreeK();
+      file = (pK->GetCurrentFile())->GetName();
+      TBranch * jetBranch ;  
        if (fDebug > 1)
            printf("Make Branch - TreeR address %p %p\n",gAlice->TreeR(), pEMCAL);
-       if (fJets && gAlice->TreeR()) {
-           pEMCAL->MakeBranchInTree(gAlice->TreeR(), 
-                                    "EMCALJets", 
-                                    &fJets, 
-                                    kBufferSize, 
-                                    file);
+       //if (fJets && gAlice->TreeR()) {
+       if (fJets && gime->TreeR()) {
+         // pEMCAL->MakeBranchInTree(gAlice->TreeR(), 
+          jetBranch = gime->TreeR()->Branch("EMCALJets", &fJets, kBufferSize, 0) ; 
+         //pEMCAL->MakeBranchInTree(gime->TreeR(), 
+         //                         "EMCALJets", 
+         //                         &fJets, 
+         //                         kBufferSize, 
+         //                         file);
+         
+         //Int_t nev = gAlice->GetHeader()->GetEvent();
+         //gAlice->TreeR()->Fill();
+         jetBranch->Fill();
+         //char hname[30];
+         //sprintf(hname,"TreeR%d", nev);
+         //gAlice->TreeR()->Write(hname);
+         //gAlice->TreeR()->Reset();
+         gime->WriteRecPoints("OVERWRITE");
        }
-       Int_t nev = gAlice->GetHeader()->GetEvent();
-       gAlice->TreeR()->Fill();
-       char hname[30];
-       sprintf(hname,"TreeR%d", nev);
-       gAlice->TreeR()->Write(hname);
-       gAlice->TreeR()->Reset();
     } else {
 //
 // Output written to user specified output file
 //
-       TTree* pK = gAlice->TreeK();
-       fInFile  = pK->GetCurrentFile();
-
-       fOutFile->cd();
-       char hname[30];
-       sprintf(hname,"TreeR%d", fEvent);
-       TTree* treeJ = new TTree(hname, "EMCALJets");
-       treeJ->Branch("EMCALJets", &fJets, kBufferSize);
-       treeJ->Fill();
-       treeJ->Write(hname);
-       fInFile->cd();
+      //TTree* pK = gAlice->TreeK();
+      TTree* pK = gAlice->TreeK();
+      fInFile  = pK->GetCurrentFile();
+
+      fOutFile->cd();
+      char hname[30];
+      sprintf(hname,"TreeR%d", fEvent);
+      TTree* treeJ = new TTree(hname, "EMCALJets");
+      treeJ->Branch("EMCALJets", &fJets, kBufferSize);
+      treeJ->Fill();
+      treeJ->Write(hname);
+      fInFile->cd();
     }
     ResetJets();        
 }
@@ -783,8 +650,8 @@ void AliEMCALJetFinder::DumpLego()
 // Dump lego histo into array
 //
     fNcell = 0;
-    TAxis* Xaxis = fLego->GetXaxis();
-    TAxis* Yaxis = fLego->GetYaxis();
+    TAxis* xaxis = fLego->GetXaxis();
+    TAxis* yaxis = fLego->GetYaxis();
     //    fhCellEt->Clear();
     Float_t e, eH;
     for (Int_t i = 1; i <= fNbinEta; i++) {
@@ -799,8 +666,8 @@ void AliEMCALJetFinder::DumpLego()
            }
            if (e > 0.0) e -= fMinCellEt;
            if (e < 0.0) e = 0.;
-           Float_t eta  = Xaxis->GetBinCenter(i);
-           Float_t phi  = Yaxis->GetBinCenter(j);          
+           Float_t eta  = xaxis->GetBinCenter(i);
+           Float_t phi  = yaxis->GetBinCenter(j);          
            fEtCell[fNcell]  = e;
            fEtaCell[fNcell] = eta;
            fPhiCell[fNcell] = phi;
@@ -893,18 +760,18 @@ void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
 
     // this is for Pythia ??
     for (Int_t part = 0; part < npart; part++) {
-       TParticle *MPart = gAlice->Particle(part);
-       Int_t mpart   = MPart->GetPdgCode();
-       Int_t child1  = MPart->GetFirstDaughter();
-       Float_t pT    = MPart->Pt();
-       Float_t p     = MPart->P();
-       Float_t phi   = MPart->Phi();
+       TParticle *mPart = gAlice->GetMCApp()->Particle(part);
+       Int_t mpart   = mPart->GetPdgCode();
+       Int_t child1  = mPart->GetFirstDaughter();
+       Float_t pT    = mPart->Pt();
+       Float_t p     = mPart->P();
+       Float_t phi   = mPart->Phi();
        Float_t eta   = -100.;
-       if(pT > 0.001) eta   = MPart->Eta();
-       Float_t theta = MPart->Theta(); 
-        if  (fDebug>=2 && MPart->GetStatusCode()==1) { 
+       if(pT > 0.001) eta   = mPart->Eta();
+       Float_t theta = mPart->Theta(); 
+        if  (fDebug>=2 && mPart->GetStatusCode()==1) { 
           printf("ind %7i part %7i -> child1 %5i child2 %5i Status %5i\n", 
-           part, mpart, child1, MPart->GetLastDaughter(), MPart->GetStatusCode());
+           part, mpart, child1, mPart->GetLastDaughter(), mPart->GetStatusCode());
         }
        
        if (fDebug >= 2 && genType == kPythia) {
@@ -924,7 +791,7 @@ void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
 //     final state particles only
 
        if (genType == kPythia) {
-           if (MPart->GetStatusCode() != 1) continue;
+           if (mPart->GetStatusCode() != 1) continue;
        } else if (genType == kHijing) {
            if (child1 >= 0 && child1 < npart) continue;
        }
@@ -932,7 +799,7 @@ void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
        
        TParticlePDG* pdgP = 0;
 // charged or neutral 
-       pdgP  = MPart->GetPDG();
+       pdgP  = mPart->GetPDG();
         chTmp = pdgP->Charge() / 3.; // 13-feb-2001!!  
 
        if (ich == 0) {
@@ -1081,7 +948,8 @@ void AliEMCALJetFinder::FillFromHits(Int_t flag)
 //
 // Access hit information    
     AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
-    TTree *treeH = gAlice->TreeH();
+    AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+    TTree *treeH = gime->TreeH();
     Int_t ntracks = (Int_t) treeH->GetEntries();
 //
 //   Loop over tracks
@@ -1149,7 +1017,7 @@ void AliEMCALJetFinder::FillFromDigits(Int_t flag)
     
     if (!fLego) BookLego();
     if (flag == 0) fLego->Reset();
-    Int_t nbytes;
+    Int_t nbytes=0;
     
 
 //
@@ -1178,12 +1046,8 @@ void AliEMCALJetFinder::FillFromDigits(Int_t flag)
     nbytes += branchDr->GetEntry(0);
 //
 //  Get digitizer parameters
-    Float_t preADCped = digr->GetPREpedestal();
-    Float_t preADCcha = digr->GetPREchannel();
-    Float_t ecADCped  = digr->GetECpedestal();
-    Float_t ecADCcha  = digr->GetECchannel();
-    Float_t hcADCped  = digr->GetHCpedestal();
-    Float_t hcADCcha  = digr->GetHCchannel();
+    Float_t ecADCped  = digr->GetECApedestal();
+    Float_t ecADCcha  = digr->GetECAchannel();
 
     AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
     AliEMCALGeometry* geom = 
@@ -1191,8 +1055,8 @@ void AliEMCALJetFinder::FillFromDigits(Int_t flag)
     
     if (fDebug) {
        Int_t   ndig = digs->GetEntries();
-       Info("FillFromDigits","Number of Digits: %d %d\n Parameters: PRE : %f %f EC: %f %f HC: %f %f\n Geometry: %d %d", 
-            ndig, nent, preADCped, preADCcha, ecADCped, ecADCcha, hcADCped, hcADCcha, geom->GetNEta(), geom->GetNPhi());
+               Info("FillFromDigits","Number of Digits: %d %d\n Parameters: EC: %f %f\n Geometry: %d %d", 
+            ndig, nent, ecADCped, ecADCcha, geom->GetNEta(), geom->GetNPhi());
     }
     
 //
@@ -1203,18 +1067,10 @@ void AliEMCALJetFinder::FillFromDigits(Int_t flag)
     {
        Double_t pedestal = 0.;
        Double_t channel  = 0.;
-       if (geom->IsInPRE(sdg->GetId())) {
-         pedestal = preADCped;
-         channel  = preADCcha; 
-       } 
-       else if (geom->IsInECAL(sdg->GetId()))  {
+       if (geom->IsInECA(sdg->GetId()))  {
          pedestal = ecADCped;
          channel  = ecADCcha; 
-       }
-       else if (geom->IsInHCAL(sdg->GetId()))  {
-         pedestal = hcADCped;
-         channel  = hcADCcha; 
-       }
+               }
        else 
          Fatal("FillFromDigits", "unexpected digit is number!") ; 
        
@@ -1269,16 +1125,16 @@ void AliEMCALJetFinder::FillFromHitFlaggedTracks(Int_t flag)
     fNtS  = 0;
     
     for (Int_t track = 0; track < ntracks; track++) {
-         TParticle *MPart = gAlice->Particle(track);
-         Float_t pT    = MPart->Pt();
-         Float_t phi   = MPart->Phi();
-         Float_t eta   = MPart->Eta();
+         TParticle *mPart = gAlice->GetMCApp()->Particle(track);
+         Float_t pT    = mPart->Pt();
+         Float_t phi   = mPart->Phi();
+         Float_t eta   = mPart->Eta();
 
        if(fTrackList[track]) {
          fPtT[track]       = pT;
          fEtaT[track]      = eta;
          fPhiT[track]      = phi;
-         fPdgT[track]      = MPart->GetPdgCode();
+         fPdgT[track]      = mPart->GetPdgCode();
          
          if (track < 2) continue;      //Colliding particles?
          if (pT == 0 || pT < fPtCut) continue;
@@ -1294,7 +1150,7 @@ void AliEMCALJetFinder::FillFromParticles()
 // 26-feb-2002 PAI - for checking all chain
 // Work on particles level; accept all particle (not neutrino )
     
-    Double_t PX=0, PY=0, PZ=0, E=0; // checking conservation law 
+    Double_t pX=0, pY=0, pZ=0, energy=0; // checking conservation law 
     fNChTpc = 0;
 
     ResetMap();
@@ -1314,23 +1170,23 @@ void AliEMCALJetFinder::FillFromParticles()
 //  Go through the particles
     Int_t mpart, child1, child2, geantPdg;
     Float_t pT, phi, eta, e=0, px=0, py=0, pz=0;
-    TParticle *MPart=0;
+    TParticle *mPart=0;
     for (Int_t part = 0; part < npart; part++) {
 
        fTrackList[part] = 0;
 
-       MPart   = gAlice->Particle(part);
-       mpart   = MPart->GetPdgCode();
-       child1  = MPart->GetFirstDaughter();
-       child2  = MPart->GetLastDaughter();
-       pT      = MPart->Pt();
-       phi     = MPart->Phi();
-       eta     = MPart->Eta();
+       mPart   = gAlice->GetMCApp()->Particle(part);
+       mpart   = mPart->GetPdgCode();
+       child1  = mPart->GetFirstDaughter();
+       child2  = mPart->GetLastDaughter();
+       pT      = mPart->Pt();
+       phi     = mPart->Phi();
+       eta     = mPart->Eta();
 
-        px      = MPart->Px();
-        py      = MPart->Py();
-        pz      = MPart->Pz();
-        e       = MPart->Energy();
+        px      = mPart->Px();
+        py      = mPart->Py();
+        pz      = mPart->Pz();
+        e       = mPart->Energy();
 
 // see pyedit in Pythia's text
         geantPdg = mpart;
@@ -1357,10 +1213,10 @@ void AliEMCALJetFinder::FillFromParticles()
 
        //        printf("%4i -> %5i(%3i) px %6.1f py %6.1f pz %7.1f e %8.2f child1 %5i %s\n", 
        //        part, mpart, geantPdg, px, py, pz, e, child1, name.Data());
-        PX += px; 
-        PY += py; 
-        PZ += pz;
-        E  += e; 
+        pX += px; 
+        pY += py; 
+        pZ += pz;
+        energy  += e; 
 
         
        if (TMath::Abs(eta) <= 0.9) fNChTpc++;
@@ -1376,7 +1232,7 @@ void AliEMCALJetFinder::FillFromParticles()
 
     } // primary loop
     printf("\n                PX %8.2f  PY %8.2f  PZ %8.2f  E %8.2f \n", 
-    PX, PY, PZ, E);
+    pX, pY, pZ, energy);
     DumpLego();
     if(fhChPartMultInTpc) fhChPartMultInTpc->Fill(fNChTpc);
 }
@@ -1403,15 +1259,15 @@ void AliEMCALJetFinder::FillFromPartons()
 //  Go through the partons
     Int_t statusCode=0;
     for (Int_t part = 8; part < npart; part++) {
-       TParticle *MPart = gAlice->Particle(part);
-       Int_t mpart   = MPart->GetPdgCode();
+       TParticle *mPart = gAlice->GetMCApp()->Particle(part);
+       Int_t mpart   = mPart->GetPdgCode();
        //      Int_t child1  = MPart->GetFirstDaughter();
-       Float_t pT    = MPart->Pt();
+       Float_t pT    = mPart->Pt();
        //      Float_t p     = MPart->P();
-       Float_t phi   = MPart->Phi();
-       Float_t eta   = MPart->Eta();
+       Float_t phi   = mPart->Phi();
+       Float_t eta   = mPart->Eta();
        //      Float_t theta = MPart->Theta();
-        statusCode    = MPart->GetStatusCode();
+        statusCode    = mPart->GetStatusCode();
        
 // accept partons (21 - gluon, 92 - string) 
        if (!(TMath::Abs(mpart) <= 6 || mpart == 21 ||mpart == 92)) continue;
@@ -1444,8 +1300,8 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
 // Access hit information    
     AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
     
-    TTree *TK = gAlice->TreeK();               // Get the number of entries in the kine tree
-    Int_t nKTrks = (Int_t) TK->GetEntries();   // (Number of particles created somewhere)
+    TTree *treeK = gAlice->TreeK();            // Get the number of entries in the kine tree
+    Int_t nKTrks = (Int_t) treeK->GetEntries();        // (Number of particles created somewhere)
     
     if(fTrackList) delete[] fTrackList;                //Make sure we get rid of the old one
     fTrackList = new Int_t[nKTrks];            //before generating a new one
@@ -1454,8 +1310,10 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
        fTrackList[i] = 0;
     }
     
-    TTree *treeH = gAlice->TreeH();
-    Int_t ntracks = (Int_t) treeH->GetEntries();
+    AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+    // TTree *treeH = gAlice->TreeH();
+    TTree *treeH = gime->TreeH();
+   Int_t ntracks = (Int_t) treeH->GetEntries();
 //
 //   Loop over tracks
 //
@@ -1477,7 +1335,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                Int_t   idprim =    mHit->GetPrimary();  // primary particle
                
                //Determine the origin point of this particle - it made a hit in the EMCAL
-               TParticle         *trkPart = gAlice->Particle(iTrk);
+               TParticle         *trkPart = gAlice->GetMCApp()->Particle(iTrk);
                TParticlePDG  *trkPdg  = trkPart->GetPDG();
                Int_t      trkCode = trkPart->GetPdgCode();
                Double_t           trkChg;
@@ -1494,7 +1352,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                //Loop through the ancestry of the EMCAL entrance particles
                Int_t ancestor = trkPart->GetFirstMother();  //Get track's Mother
                while (ancestor != -1) {
-                   TParticle     *ancPart = gAlice->Particle(ancestor);  //get particle info on ancestor
+                   TParticle     *ancPart = gAlice->GetMCApp()->Particle(ancestor);  //get particle info on ancestor
                    TParticlePDG  *ancPdg  = ancPart->GetPDG();
                    Int_t             ancCode = ancPart->GetPdgCode();
                    Double_t       ancChg;
@@ -1511,7 +1369,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
                }
                
                //Determine the origin point of the primary particle associated with the hit
-               TParticle     *primPart = gAlice->Particle(idprim);
+               TParticle     *primPart = gAlice->GetMCApp()->Particle(idprim);
                TParticlePDG  *primPdg  = primPart->GetPDG();
                Int_t      primCode = primPart->GetPdgCode();
                Double_t           primChg;
@@ -1531,7 +1389,7 @@ void AliEMCALJetFinder::BuildTrackFlagTable() {
 
 Int_t AliEMCALJetFinder
 ::SetTrackFlag(Float_t radius, Int_t code, Double_t charge) {
-
+// Set the flag for the track
     Int_t flag    = 0; 
     Int_t parton  = 0; 
     Int_t neutral = 0;
@@ -1768,23 +1626,33 @@ Float_t AliEMCALJetFinder::PropagatePhi(Float_t pt, Float_t charge, Bool_t& curl
     return dPhi;
 }
 
-void hf1(Int_t& id, Float_t& x, Float_t& wgt)
+void hf1(Int_t& , Float_t& , Float_t& )
 {
 // dummy for hbook calls
     ;
 }
 
 void AliEMCALJetFinder::DrawLego(Char_t *opt) 
-{if(fLego) fLego->Draw(opt);}
+{
+// Draw lego
+       if(fLego) fLego->Draw(opt);
+}
 
-void  AliEMCALJetFinder::DrawLegoBackground(Char_t *opt="lego") 
-{if(fLegoB) fLegoB->Draw(opt);}
+void  AliEMCALJetFinder::DrawLegoBackground(Char_t *opt) 
+{
+// Draw background lego
+       if(fLegoB) fLegoB->Draw(opt);
+}
 
 void AliEMCALJetFinder::DrawLegoEMCAL(Char_t *opt) 
-{if(fhLegoEMCAL) fhLegoEMCAL->Draw(opt);}
+{
+// Draw EMCAL Lego
+       if(fhLegoEMCAL) fhLegoEMCAL->Draw(opt);
+}
 
 void AliEMCALJetFinder::DrawHistsForTuning(Int_t mode)
 { 
+// Draw all hists      
   static TPaveText *varLabel=0;
   if(!fC1) {
     fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
@@ -1825,6 +1693,8 @@ void AliEMCALJetFinder::DrawHistsForTuning(Int_t mode)
 
 void AliEMCALJetFinder::PrintParameters(Int_t mode)
 {
+// Print all parameters out    
+       
   FILE *file=0;
   if(mode==0) file = stdout; // output to terminal
   else {
@@ -1857,6 +1727,7 @@ void AliEMCALJetFinder::PrintParameters(Int_t mode)
 
 void AliEMCALJetFinder::DrawLegos()
 { 
+// Draw all legos      
   if(!fC1) {
     fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
   }
@@ -1894,6 +1765,7 @@ void AliEMCALJetFinder::DrawLegos()
 
 const Char_t* AliEMCALJetFinder::GetFileNameForParameters(Char_t* dir)
 {
+// Get paramters from a file   
   static TString tmp;
   if(strlen(dir)) tmp = dir;
   tmp += GetTitle();
@@ -1902,7 +1774,8 @@ const Char_t* AliEMCALJetFinder::GetFileNameForParameters(Char_t* dir)
 }
 
 void AliEMCALJetFinder::RearrangeParticlesMemory(Int_t npart)
-{ // See FillFromTracks() - npart must be positive
+{ 
+       // See FillFromTracks() - npart must be positive
     if (fTrackList) delete[] fTrackList;
     if (fPtT)       delete[] fPtT;
     if (fEtaT)      delete[] fEtaT;
@@ -1922,6 +1795,7 @@ void AliEMCALJetFinder::RearrangeParticlesMemory(Int_t npart)
 
 Bool_t AliEMCALJetFinder::IsThisPartonsOrDiQuark(Int_t pdg)
 {
+// Return quark info   
   Int_t absPdg = TMath::Abs(pdg);
   if(absPdg<=6) return kTRUE; // quarks
   if(pdg == 21) return kTRUE; // gluon 
@@ -2066,17 +1940,20 @@ void AliEMCALJetFinder::FindChargedJet()
 // 16-jan-2003 - just for convenience
 void AliEMCALJetFinder::Browse(TBrowser* b)
 {
+// Add to browser      
    if(fHistsList)  b->Add((TObject*)fHistsList);
 }
 
 Bool_t AliEMCALJetFinder::IsFolder() const
 {
+// Return folder status        
   if(fHistsList) return kTRUE;
   else           return kFALSE;
 }
 
 const Char_t* AliEMCALJetFinder::GetNameOfVariant()
-{// generate the literal string with info about jet finder
+{
+       // generate the literal string with info about jet finder
   Char_t name[200];
   sprintf(name, "jF_R%3.2fMinCell%4.1fPtCut%4.1fEtSeed%4.1fMinEt%4.1fBGSubtr%iSF%4.1f",
          fConeRadius,fMinCellEt,fPtCut,fEtSeed,fMinJetEt, fMode, fSamplingF);