]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMultReconstructor.cxx
Shadow warnings fixed
[u/mrichter/AliRoot.git] / ITS / AliITSMultReconstructor.cxx
index 8c2f1cfc6eb982c5ca42522fde5673fa9e7d6c8d..07cd5001c49b55e6c97410098d14b1df80444304 100644 (file)
@@ -1,3 +1,20 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * 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   *
+ * 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   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
 //____________________________________________________________________
 // 
 // AliITSMultReconstructor - find clusters in the pixels (theta and
 // differencies in Phi (azimuth) and Zeta (longitudinal) are inside 
 // a fiducial volume. In case of multiple candidates it is selected the
 // candidate with minimum distance in Phi. 
-// The parameter AssociationChoice allows to control if two clusters 
+// The parameter AssociationChoice allows to control if two clusters
 // in layer 2 can be associated to the same cluster in layer 1 or not.
+// (TRUE means double associations exluded; default = TRUE)
+//
+// Two methods return the number of traklets and the number of clusters 
+// in the first SPD layer (GetNTracklets GetNSingleClusters)
 //
 // -----------------------------------------------------------------
 // 
-// TODO: 
+// NOTE: The cuts on phi and zeta depend on the interacting system (p-p  
+//  or Pb-Pb). Please, check the file AliITSMultReconstructor.h and be 
+//  sure that SetPhiWindow and SetZetaWindow are defined accordingly.
 // 
-// - Introduce a rough pt estimation from the difference in phi ? 
-// - Allow for a more refined selection criterium in case of multiple 
-//   candidates (for instance by introducing weights for the difference 
-//   in Phi and Zeta). 
+//  Author :  Tiziano Virgili 
+//  
+//  Recent updates (D. Elia, INFN Bari):
+//     - multiple association forbidden (fOnlyOneTrackletPerC2 = kTRUE) 
+//     - phi definition changed to ALICE convention (0,2*TMath::pi()) 
+//     - cluster coordinates taken with GetGlobalXYZ()
 //
+//  fGeometry removed
 //____________________________________________________________________
 
-#include "AliITSMultReconstructor.h"
-
-#include "TTree.h"
-#include "TH1F.h"
-#include "TH2F.h"
+#include <TClonesArray.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TTree.h>
 
-
-#include "AliITSclusterV2.h"
+#include "AliITSMultReconstructor.h"
+#include "AliITSRecPoint.h"
 #include "AliITSgeom.h"
 #include "AliLog.h"
 
 //____________________________________________________________________
 ClassImp(AliITSMultReconstructor)
 
+
 //____________________________________________________________________
-AliITSMultReconstructor::AliITSMultReconstructor() {
+AliITSMultReconstructor::AliITSMultReconstructor():
+fClustersLay1(0),
+fClustersLay2(0),
+fTracklets(0),
+fSClusters(0),
+fAssociationFlag(0),
+fNClustersLay1(0),
+fNClustersLay2(0),
+fNTracklets(0),
+fNSingleCluster(0),
+fPhiWindow(0),
+fZetaWindow(0),
+fOnlyOneTrackletPerC2(0),
+fHistOn(0),
+fhClustersDPhiAcc(0),
+fhClustersDThetaAcc(0),
+fhClustersDZetaAcc(0),
+fhClustersDPhiAll(0),
+fhClustersDThetaAll(0),
+fhClustersDZetaAll(0),
+fhDPhiVsDThetaAll(0),
+fhDPhiVsDThetaAcc(0),
+fhDPhiVsDZetaAll(0),
+fhDPhiVsDZetaAcc(0),
+fhetaTracklets(0),
+fhphiTracklets(0),
+fhetaClustersLay1(0),
+fhphiClustersLay1(0){
+  // Method to reconstruct the charged particles multiplicity with the 
+  // SPD (tracklets).
 
-  fGeometry =0;
 
   SetHistOn();
   SetPhiWindow();
@@ -51,30 +105,127 @@ AliITSMultReconstructor::AliITSMultReconstructor() {
   fClustersLay1       = new Float_t*[300000];
   fClustersLay2       = new Float_t*[300000];
   fTracklets          = new Float_t*[300000];
+  fSClusters          = new Float_t*[300000];
   fAssociationFlag    = new Bool_t[300000];
 
   for(Int_t i=0; i<300000; i++) {
-    fClustersLay1[i]       = new Float_t[3];
-    fClustersLay2[i]       = new Float_t[3];
-    fTracklets[i]          = new Float_t[3];
+    fClustersLay1[i]       = new Float_t[6];
+    fClustersLay2[i]       = new Float_t[6];
+    fTracklets[i]          = new Float_t[5];
+    fSClusters[i]           = new Float_t[2];
     fAssociationFlag[i]    = kFALSE;
   }
 
   // definition of histograms
-  fhClustersDPhi   = new TH1F("dphi",  "dphi",  200,-0.1,0.1);
-  fhClustersDPhi->SetDirectory(0);
-  fhClustersDTheta = new TH1F("dtheta","dtheta",200,-0.1,0.1);
-  fhClustersDTheta->SetDirectory(0);
-  fhClustersDZeta = new TH1F("dzeta","dzeta",200,-0.2,0.2);
-  fhClustersDZeta->SetDirectory(0);
-
-  fhDPhiVsDThetaAll = new TH2F("dphiVsDthetaAll","",200,-0.1,0.1,200,-0.1,0.1);
-  fhDPhiVsDThetaAll->SetDirectory(0);
-  fhDPhiVsDThetaAcc = new TH2F("dphiVsDthetaAcc","",200,-0.1,0.1,200,-0.1,0.1);
+  fhClustersDPhiAcc   = new TH1F("dphiacc",  "dphi",  100,0.,0.1);
+  fhClustersDPhiAcc->SetDirectory(0);
+  fhClustersDThetaAcc = new TH1F("dthetaacc","dtheta",100,-0.1,0.1);
+  fhClustersDThetaAcc->SetDirectory(0);
+  fhClustersDZetaAcc = new TH1F("dzetaacc","dzeta",100,-1.,1.);
+  fhClustersDZetaAcc->SetDirectory(0);
+
+  fhDPhiVsDZetaAcc = new TH2F("dphiVsDzetaacc","",100,-1.,1.,100,0.,0.1);
+  fhDPhiVsDZetaAcc->SetDirectory(0);
+  fhDPhiVsDThetaAcc = new TH2F("dphiVsDthetaAcc","",100,-0.1,0.1,100,0.,0.1);
   fhDPhiVsDThetaAcc->SetDirectory(0);
 
+  fhClustersDPhiAll   = new TH1F("dphiall",  "dphi",  100,0.0,0.5);
+  fhClustersDPhiAll->SetDirectory(0);
+  fhClustersDThetaAll = new TH1F("dthetaall","dtheta",100,-0.5,0.5);
+  fhClustersDThetaAll->SetDirectory(0);
+  fhClustersDZetaAll = new TH1F("dzetaall","dzeta",100,-5.,5.);
+  fhClustersDZetaAll->SetDirectory(0);
+
+  fhDPhiVsDZetaAll = new TH2F("dphiVsDzetaall","",100,-5.,5.,100,0.,0.5);
+  fhDPhiVsDZetaAll->SetDirectory(0);
+  fhDPhiVsDThetaAll = new TH2F("dphiVsDthetaAll","",100,-0.5,0.5,100,0.,0.5);
+  fhDPhiVsDThetaAll->SetDirectory(0);
+
+  fhetaTracklets  = new TH1F("etaTracklets",  "eta",  100,-2.,2.);
+  fhetaTracklets->SetDirectory(0);
+  fhphiTracklets  = new TH1F("phiTracklets",  "phi",  100, 0., 2*TMath::Pi());
+  fhphiTracklets->SetDirectory(0);
+  fhetaClustersLay1  = new TH1F("etaClustersLay1",  "etaCl1",  100,-2.,2.);
+  fhetaClustersLay1->SetDirectory(0);
+  fhphiClustersLay1  = new TH1F("phiClustersLay1", "phiCl1", 100, 0., 2*TMath::Pi());
+  fhphiClustersLay1->SetDirectory(0);
+}
+
+//______________________________________________________________________
+AliITSMultReconstructor::AliITSMultReconstructor(const AliITSMultReconstructor &mr) : TObject(mr),
+fClustersLay1(mr.fClustersLay1),
+fClustersLay2(mr.fClustersLay2),
+fTracklets(mr.fTracklets),
+fSClusters(mr.fSClusters),
+fAssociationFlag(mr.fAssociationFlag),
+fNClustersLay1(mr.fNClustersLay1),
+fNClustersLay2(mr.fNClustersLay2),
+fNTracklets(mr.fNTracklets),
+fNSingleCluster(mr.fNSingleCluster),
+fPhiWindow(mr.fPhiWindow),
+fZetaWindow(mr.fZetaWindow),
+fOnlyOneTrackletPerC2(mr.fOnlyOneTrackletPerC2),
+fHistOn(mr.fHistOn),
+fhClustersDPhiAcc(mr.fhClustersDPhiAcc),
+fhClustersDThetaAcc(mr.fhClustersDThetaAcc),
+fhClustersDZetaAcc(mr.fhClustersDZetaAcc),
+fhClustersDPhiAll(mr.fhClustersDPhiAll),
+fhClustersDThetaAll(mr.fhClustersDThetaAll),
+fhClustersDZetaAll(mr.fhClustersDZetaAll),
+fhDPhiVsDThetaAll(mr.fhDPhiVsDThetaAll),
+fhDPhiVsDThetaAcc(mr.fhDPhiVsDThetaAcc),
+fhDPhiVsDZetaAll(mr.fhDPhiVsDZetaAll),
+fhDPhiVsDZetaAcc(mr.fhDPhiVsDZetaAcc),
+fhetaTracklets(mr.fhetaTracklets),
+fhphiTracklets(mr.fhphiTracklets),
+fhetaClustersLay1(mr.fhetaClustersLay1),
+fhphiClustersLay1(mr.fhphiClustersLay1) {
+  // Copy constructor
+
+}
+
+//______________________________________________________________________
+AliITSMultReconstructor& AliITSMultReconstructor::operator=(const AliITSMultReconstructor& mr){
+  // Assignment operator
+  this->~AliITSMultReconstructor();
+  new(this) AliITSMultReconstructor(mr);
+  return *this;
 }
 
+//______________________________________________________________________
+AliITSMultReconstructor::~AliITSMultReconstructor(){
+  // Destructor
+
+  // delete histograms
+  delete fhClustersDPhiAcc;
+  delete fhClustersDThetaAcc;
+  delete fhClustersDZetaAcc;
+  delete fhClustersDPhiAll;
+  delete fhClustersDThetaAll;
+  delete fhClustersDZetaAll;
+  delete fhDPhiVsDThetaAll;
+  delete fhDPhiVsDThetaAcc;
+  delete fhDPhiVsDZetaAll;
+  delete fhDPhiVsDZetaAcc;
+  delete fhetaTracklets;
+  delete fhphiTracklets;
+  delete fhetaClustersLay1;
+  delete fhphiClustersLay1;
+
+  // delete arrays
+  for(Int_t i=0; i<300000; i++) {
+    delete [] fClustersLay1[i];
+    delete [] fClustersLay2[i];
+    delete [] fTracklets[i];
+    delete [] fSClusters[i];
+  }
+  delete [] fClustersLay1;
+  delete [] fClustersLay2;
+  delete [] fTracklets;
+  delete [] fSClusters;
+
+  delete [] fAssociationFlag;
+}
 
 //____________________________________________________________________
 void
@@ -89,16 +240,14 @@ AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t*
   // After this method has been called, the clusters of the two layers
   // and the tracklets can be retrieved by calling the Get'er methods.
 
-  cout << " HEEEEEEEEEEEEEEEEEEEEE " << flush << endl;
-
   // reset counters
   fNClustersLay1 = 0;
   fNClustersLay2 = 0;
   fNTracklets = 0; 
-
+  fNSingleCluster = 0; 
   // loading the clusters 
   LoadClusterArrays(clusterTree);
-  
+
   // find the tracklets
   AliDebug(1,"Looking for tracklets... ");  
 
@@ -108,14 +257,21 @@ AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t*
     Float_t x = fClustersLay1[iC1][0] - vtx[0];
     Float_t y = fClustersLay1[iC1][1] - vtx[1];
     Float_t z = fClustersLay1[iC1][2] - vtx[2];
-    
+
     Float_t r    = TMath::Sqrt(TMath::Power(x,2) +
                               TMath::Power(y,2) +
                               TMath::Power(z,2));
     
-    fClustersLay1[iC1][0] = TMath::ACos(z/r);  // Store Theta
-    fClustersLay1[iC1][1] = TMath::ATan(y/x);  // Store Phi
-    fClustersLay1[iC1][2] = z/r;               // Store scaled z 
+    fClustersLay1[iC1][0] = TMath::ACos(z/r);                   // Store Theta
+    fClustersLay1[iC1][1] = TMath::Pi() + TMath::ATan2(-y,-x);  // Store Phi
+    fClustersLay1[iC1][2] = z/r;                                // Store scaled z
+    if (fHistOn) {
+      Float_t eta=fClustersLay1[iC1][0];
+      eta= TMath::Tan(eta/2.);
+      eta=-TMath::Log(eta);
+      fhetaClustersLay1->Fill(eta);    
+      fhphiClustersLay1->Fill(fClustersLay1[iC1][1]);
+    }      
   }
   
   // Loop on layer 2 : finding theta, phi and r   
@@ -123,16 +279,16 @@ AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t*
     Float_t x = fClustersLay2[iC2][0] - vtx[0];
     Float_t y = fClustersLay2[iC2][1] - vtx[1];
     Float_t z = fClustersLay2[iC2][2] - vtx[2];
-    
+   
     Float_t r    = TMath::Sqrt(TMath::Power(x,2) +
                               TMath::Power(y,2) +
                               TMath::Power(z,2));
     
-    fClustersLay2[iC2][0] = TMath::ACos(z/r);  // Store Theta
-    fClustersLay2[iC2][1] = TMath::ATan(y/x);  // Store Phi
-    fClustersLay2[iC2][2] = z;                 // Store z
+    fClustersLay2[iC2][0] = TMath::ACos(z/r);                   // Store Theta
+    fClustersLay2[iC2][1] = TMath::Pi() + TMath::ATan2(-y,-x);  // Store Phi
+    fClustersLay2[iC2][2] = z;                                  // Store z
 
   // this only needs to be initialized for the fNClustersLay2 first associations
+ // this only needs to be initialized for the fNClustersLay2 first associations
     fAssociationFlag[iC2] = kFALSE;
   }  
   
@@ -141,8 +297,11 @@ AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t*
   for (Int_t iC1=0; iC1<fNClustersLay1; iC1++) {    
 
     // reset of variables for multiple candidates
-    Int_t   iC2WithBestPhi = 0;     // reset 
-    Float_t dPhimin        = 100.;  // just to put a huge number! 
+    Int_t  iC2WithBestDist = 0;     // reset 
+    Float_t distmin        = 100.;  // just to put a huge number! 
+    Float_t dPhimin        = 0.;  // Used for histograms only! 
+    Float_t dThetamin      = 0.;  // Used for histograms only! 
+    Float_t dZetamin       = 0.;  // Used for histograms only! 
     
     // Loop on layer 2 
     for (Int_t iC2=0; iC2<fNClustersLay2; iC2++) {      
@@ -152,47 +311,122 @@ AliITSMultReconstructor::Reconstruct(TTree* clusterTree, Float_t* vtx, Float_t*
        
        // find the difference in angles
        Float_t dTheta = fClustersLay2[iC2][0] - fClustersLay1[iC1][0];
-       Float_t dPhi   = fClustersLay2[iC2][1] - fClustersLay1[iC1][1];
-       
+       Float_t dPhi   = TMath::Abs(fClustersLay2[iC2][1] - fClustersLay1[iC1][1]);
+        // take into account boundary condition
+        if (dPhi>TMath::Pi()) dPhi=2.*TMath::Pi()-dPhi;        
+
        // find the difference in z (between linear projection from layer 1
        // and the actual point: Dzeta= z1/r1*r2 -z2)   
-       Float_t r2     = fClustersLay2[iC2][2]/TMath::Cos(fClustersLay2[iC2][0]);
-       Float_t dZeta  = fClustersLay2[iC1][2]*r2 - fClustersLay2[iC2][2]; 
-       
-       if (fHistOn) {
-         fhClustersDPhi->Fill(dPhi);    
-         fhClustersDTheta->Fill(dTheta);    
-         fhClustersDZeta->Fill(dZeta);    
+       Float_t r2   = fClustersLay2[iC2][2]/TMath::Cos(fClustersLay2[iC2][0]);
+        Float_t dZeta  = fClustersLay1[iC1][2]*r2 - fClustersLay2[iC2][2];
+
+       if (fHistOn) {
+         fhClustersDPhiAll->Fill(dPhi);    
+         fhClustersDThetaAll->Fill(dTheta);    
+         fhClustersDZetaAll->Fill(dZeta);    
          fhDPhiVsDThetaAll->Fill(dTheta, dPhi);
+         fhDPhiVsDZetaAll->Fill(dZeta, dPhi);
        }
        // make "elliptical" cut in Phi and Zeta! 
        Float_t d = TMath::Sqrt(TMath::Power(dPhi/fPhiWindow,2) + TMath::Power(dZeta/fZetaWindow,2));
+
        if (d>1) continue;      
        
-       //look for the minimum distance in Phi: the minimum is in iC2WithBestPhi
-       if (TMath::Abs(dPhi) < dPhimin) {
-         dPhimin = TMath::Abs(dPhi);
-         iC2WithBestPhi = iC2;
+       //look for the minimum distance: the minimum is in iC2WithBestDist
+               if (TMath::Sqrt(dZeta*dZeta+(r2*dPhi*r2*dPhi)) < distmin ) {
+         distmin=TMath::Sqrt(dZeta*dZeta + (r2*dPhi*r2*dPhi));
+         dPhimin = dPhi;
+         dThetamin = dTheta;
+         dZetamin = dZeta; 
+         iC2WithBestDist = iC2;
        }
       } 
     } // end of loop over clusters in layer 2 
     
-    if (dPhimin<100) { // This means that a cluster in layer 2 was found that mathes with iC1
+    if (distmin<100) { // This means that a cluster in layer 2 was found that mathes with iC1
+
+      if (fHistOn) {
+       fhClustersDPhiAcc->Fill(dPhimin);
+       fhClustersDThetaAcc->Fill(dThetamin);    
+       fhClustersDZetaAcc->Fill(dZetamin);    
+       fhDPhiVsDThetaAcc->Fill(dThetamin, dPhimin);
+       fhDPhiVsDZetaAcc->Fill(dZetamin, dPhimin);
+      }
       
-      if (fOnlyOneTrackletPerC2) fAssociationFlag[iC2WithBestPhi] = kTRUE; // flag the association
+      if (fOnlyOneTrackletPerC2) fAssociationFlag[iC2WithBestDist] = kTRUE; // flag the association
       
       // store the tracklet
       
-      // use the average theta from the clusters in the two layers
-      fTracklets[fNTracklets][0] = 0.5*(fClustersLay1[iC1][0]+fClustersLay2[iC2WithBestPhi][0]);
-      // use the phi from the clusters in the first layer 
+      // use the theta from the clusters in the first layer
+      fTracklets[fNTracklets][0] = fClustersLay1[iC1][0];
+      // use the phi from the clusters in the first layer
       fTracklets[fNTracklets][1] = fClustersLay1[iC1][1];
-      // Store the difference between phi1 and phi2
-      fTracklets[fNTracklets][2] = fClustersLay1[iC1][1] - fClustersLay2[iC2WithBestPhi][1];         
-      fNTracklets++;
+      // store the difference between phi1 and phi2
+      fTracklets[fNTracklets][2] = fClustersLay1[iC1][1] - fClustersLay2[iC2WithBestDist][1];
+
+      // define dphi in the range [0,pi] with proper sign (track charge correlated)
+      if (fTracklets[fNTracklets][2] > TMath::Pi()) 
+          fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]-2.*TMath::Pi();
+      if (fTracklets[fNTracklets][2] < -TMath::Pi()) 
+          fTracklets[fNTracklets][2] = fTracklets[fNTracklets][2]+2.*TMath::Pi();
+
+      // find label
+      // if equal label in both clusters found this label is assigned
+      // if no equal label can be found the first labels of the L1 AND L2 cluster are assigned
+      Int_t label1 = 0;
+      Int_t label2 = 0;
+      while (label2 < 3)
+      {
+        if ((Int_t) fClustersLay1[iC1][3+label1] != -2 && (Int_t) fClustersLay1[iC1][3+label1] == (Int_t) fClustersLay2[iC2WithBestDist][3+label2])
+          break;
+        label1++;
+        if (label1 == 3)
+        {
+          label1 = 0;
+          label2++;
+        }
+      }
+
+      if (label2 < 3)
+      {
+        AliDebug(AliLog::kDebug, Form("Found label %d == %d for tracklet candidate %d\n", (Int_t) fClustersLay1[iC1][3+label1], (Int_t) fClustersLay2[iC2WithBestDist][3+label2], fNTracklets));
+        fTracklets[fNTracklets][3] = fClustersLay1[iC1][3+label1];
+        fTracklets[fNTracklets][4] = fClustersLay2[iC2WithBestDist][3+label2];
+      }
+      else
+      {
+        AliDebug(AliLog::kDebug, Form("Did not find label %d %d %d %d %d %d for tracklet candidate %d\n", (Int_t) fClustersLay1[iC1][3], (Int_t) fClustersLay1[iC1][4], (Int_t) fClustersLay1[iC1][5], (Int_t) fClustersLay2[iC2WithBestDist][3], (Int_t) fClustersLay2[iC2WithBestDist][4], (Int_t) fClustersLay2[iC2WithBestDist][5], fNTracklets));
+        fTracklets[fNTracklets][3] = fClustersLay1[iC1][3];
+        fTracklets[fNTracklets][4] = fClustersLay2[iC2WithBestDist][3];
+      }
+
+      if (fHistOn) {
+       Float_t eta=fTracklets[fNTracklets][0];
+       eta= TMath::Tan(eta/2.);
+       eta=-TMath::Log(eta);
+       fhetaTracklets->Fill(eta);    
+       fhphiTracklets->Fill(fTracklets[fNTracklets][1]);    
+      }
       
-      AliDebug(1,Form(" Adding tracklet candidate %d (cluster %d  of layer 1 and %d  of layer 2)", fNTracklets, iC1));
+      AliDebug(1,Form(" Adding tracklet candidate %d ", fNTracklets));
+      AliDebug(1,Form(" Cl. %d of Layer 1 and %d of Layer 2", iC1, 
+                     iC2WithBestDist));
+      fNTracklets++;
     }
+
+    // Delete the following else if you do not want to save Clusters! 
+
+    else { // This means that the cluster has not been associated
+
+      // store the cluster
+       
+      fSClusters[fNSingleCluster][0] = fClustersLay1[iC1][0];
+      fSClusters[fNSingleCluster][1] = fClustersLay1[iC1][1];
+      AliDebug(1,Form(" Adding a single cluster %d (cluster %d  of layer 1)",
+                     fNSingleCluster, iC1));
+      fNSingleCluster++;
+    }
+
   } // end of loop over clusters in layer 1
   
   AliDebug(1,Form("%d tracklets found", fNTracklets));
@@ -211,12 +445,14 @@ AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree) {
   fNClustersLay1 = 0;
   fNClustersLay2 = 0;
   
-  TClonesArray* itsClusters = new TClonesArray("AliITSclusterV2");
-  TBranch* itsClusterBranch=itsClusterTree->GetBranch("Clusters");
+  TClonesArray* itsClusters = new TClonesArray("AliITSRecPoint");
+  TBranch* itsClusterBranch=itsClusterTree->GetBranch("ITSRecPoints");
+
   itsClusterBranch->SetAddress(&itsClusters);
-  
+
   Int_t nItsSubs = (Int_t)itsClusterTree->GetEntries();  
-  
+  Float_t cluGlo[3]={0.,0.,0.};
   // loop over the its subdetectors
   for (Int_t iIts=0; iIts < nItsSubs; iIts++) {
     
@@ -225,65 +461,70 @@ AliITSMultReconstructor::LoadClusterArrays(TTree* itsClusterTree) {
     
     Int_t nClusters = itsClusters->GetEntriesFast();
     
-    // stuff needed to get the global coordinates
-    Double_t rot[9];   fGeometry->GetRotMatrix(iIts,rot);
-    Int_t lay,lad,det; fGeometry->GetModuleId(iIts,lay,lad,det);
-    Float_t tx,ty,tz;  fGeometry->GetTrans(lay,lad,det,tx,ty,tz);
-    
-    // Below:
-    // "alpha" is the angle from the global X-axis to the
-    //         local GEANT X'-axis  ( rot[0]=cos(alpha) and rot[1]=sin(alpha) )
-    // "phi" is the angle from the global X-axis to the
-    //       local cluster X"-axis
-    
-    Double_t alpha   = TMath::ATan2(rot[1],rot[0])+TMath::Pi();
-    Double_t itsPhi = TMath::Pi()/2+alpha;
-    
-    if (lay==1) itsPhi+=TMath::Pi();
-    Double_t cp=TMath::Cos(itsPhi), sp=TMath::Sin(itsPhi);
-    Double_t r=tx*cp+ty*sp;
-    
     // loop over clusters
     while(nClusters--) {
-      AliITSclusterV2* cluster = (AliITSclusterV2*)itsClusters->UncheckedAt(nClusters);        
+      AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
       
       if (cluster->GetLayer()>1) 
        continue;            
       
-      Float_t x = r*cp - cluster->GetY()*sp;
-      Float_t y = r*sp + cluster->GetY()*cp;
-      Float_t z = cluster->GetZ();      
+      cluster->GetGlobalXYZ(cluGlo);
+      Float_t x = cluGlo[0];
+      Float_t y = cluGlo[1];
+      Float_t z = cluGlo[2];      
       
       if (cluster->GetLayer()==0) {
        fClustersLay1[fNClustersLay1][0] = x;
        fClustersLay1[fNClustersLay1][1] = y;
        fClustersLay1[fNClustersLay1][2] = z;
+       for (Int_t i=0; i<3; i++)
+               fClustersLay1[fNClustersLay1][3+i] = cluster->GetLabel(i);
        fNClustersLay1++;
       }
-      if (cluster->GetLayer()==1) {    
+      if (cluster->GetLayer()==1) {
        fClustersLay2[fNClustersLay2][0] = x;
        fClustersLay2[fNClustersLay2][1] = y;
        fClustersLay2[fNClustersLay2][2] = z;
+       for (Int_t i=0; i<3; i++)
+               fClustersLay2[fNClustersLay2][3+i] = cluster->GetLabel(i);
        fNClustersLay2++;
       }
       
     }// end of cluster loop
   } // end of its "subdetector" loop  
   
+  if (itsClusters) {
+    itsClusters->Delete();
+    delete itsClusters;
+    itsClusters = 0;
+  }
   AliDebug(1,Form("(clusters in layer 1 : %d,  layer 2: %d)",fNClustersLay1,fNClustersLay2));
 }
 //____________________________________________________________________
 void
 AliITSMultReconstructor::SaveHists() {
+  // This method save the histograms on the output file
+  // (only if fHistOn is TRUE). 
   
   if (!fHistOn)
     return;
 
-  cout << "Saving histograms" << endl;
-
-  fhClustersDPhi->Write();
-  fhClustersDTheta->Write();
-  fhClustersDZeta->Write();
+  fhClustersDPhiAll->Write();
+  fhClustersDThetaAll->Write();
+  fhClustersDZetaAll->Write();
   fhDPhiVsDThetaAll->Write();
+  fhDPhiVsDZetaAll->Write();
+
+  fhClustersDPhiAcc->Write();
+  fhClustersDThetaAcc->Write();
+  fhClustersDZetaAcc->Write();
   fhDPhiVsDThetaAcc->Write();
+  fhDPhiVsDZetaAcc->Write();
+
+  fhetaTracklets->Write();
+  fhphiTracklets->Write();
+  fhetaClustersLay1->Write();
+  fhphiClustersLay1->Write();
 }
+
+