]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCcalibLaser.cxx
1. Using merging from file
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibLaser.cxx
index 6f7b015f3487b1e000dd47ca661e6efd53a8cba0..65cc580afe780dfbeb28501dbcdcb91f96ea3a9c 100644 (file)
   // 3. The drift velocity and jitter is calculated event by event
   //    (see function drift velocity)
   //
-  //
+  // 4. The tracks are refitted at different sectors 
+  //    Fit model 
+  //      4.a) line
+  //      4.b) parabola
+  //      4.c) parabola with common P2 for inner and outer 
   //
   // To make laser scan the user interaction neccessary
   //
 #include <iostream>
 #include <sstream>
 #include "AliTPCLaserTrack.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCParam.h"
 
 using namespace std;
 
@@ -128,24 +134,63 @@ AliTPCcalibLaser::AliTPCcalibLaser():
   fDeltaPhi(336),
   fDeltaPhiP(336),
   fSignals(336),
-  fDeltaYres(336),
-  fDeltaZres(336),  
-  fPol2Par2InY(336),
-  fDiffPar1InY(336),
-  fPol2Par2OutY(336),
-  fDiffPar1OutY(336),
-  fPol2Par2InZ(336),
-  fDiffPar1InZ(336),
-  fPol2Par2OutZ(336),
-  fDiffPar1OutZ(336),
+  //
+  fHisNclIn(0),      //->Number of clusters inner
+  fHisNclOut(0),     //->Number of clusters outer
+  fHisNclIO(0),      //->Number of cluster inner outer
+  fHisLclIn(0),      //->Level arm inner
+  fHisLclOut(0),     //->Level arm outer
+  fHisLclIO(0),      //->Number of cluster inner outer
+  fHisdEdx(0),     //->dEdx histo
+  fHisdZfit(0),     //->distance to the mirror after linear fit
+  //
+  //
+  fHisChi2YIn1(0),      //->chi2 y inner - line
+  fHisChi2YOut1(0),     //->chi2 y inner - line
+  fHisChi2YIn2(0),      //->chi2 y inner - parabola
+  fHisChi2YOut2(0),     //->chi2 y inner - parabola
+  fHisChi2YIO1(0),      //->chi2 y IO    - common
+  fHisChi2ZIn1(0),      //->chi2 z inner - line
+  fHisChi2ZOut1(0),     //->chi2 z inner - line
+  fHisChi2ZIn2(0),      //->chi2 z inner - parabola
+  fHisChi2ZOut2(0),     //->chi2 z inner - parabola
+  fHisChi2ZIO1(0),      //->chi2 z IO    - common
+  //
+  //
+  fHisPy1vP0(0),     //-> delta y   P0outer-P0inner - line
+  fHisPy2vP0(0),     //-> delta y   P0outer-P0inner - parabola
+  fHisPy3vP0(0),     //-> delta y   P0outer-P0inner - common parabola
+  fHisPy1vP1(0),     //-> delta ky  P1outer-P1inner - line
+  fHisPy2vP1(0),     //-> delta ky  P1outer-P1inner - parabola
+  fHisPy3vP1(0),     //-> delta ky  P1outer-P1inner - common parabola
+  fHisPy2vP2In(0),   //-> Curv  P2inner - parabola
+  fHisPy2vP2Out(0),  //-> Curv  P2outer - parabola
+  fHisPy3vP2IO(0),   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fHisPz1vP0(0),     //-> delta z   P0outer-P0inner - line
+  fHisPz2vP0(0),     //-> delta z   P0outer-P0inner - parabola
+  fHisPz3vP0(0),     //-> delta z   P0outer-P0inner - common parabola
+  fHisPz1vP1(0),     //-> delta kz  P1outer-P1inner - line
+  fHisPz2vP1(0),     //-> delta kz  P1outer-P1inner - parabola
+  fHisPz3vP1(0),     //-> delta kz  P1outer-P1inner - common parabola
+  fHisPz2vP2In(0),   //-> Curv  P2inner - parabola
+  fHisPz2vP2Out(0),  //-> Curv  P2outer - parabola
+  fHisPz3vP2IO(0),   //-> Curv  P2outerinner - common parabola
+  //
+  fDeltaYres(336),   //->2D histo of residuals
+  fDeltaZres(336),   //->2D histo fo residuals
+  fDeltaYres2(336),   //->2D histo of residuals
+  fDeltaZres2(336),   //->2D histo fo residuals
+  //fDeltaYres3(336),   //->2D histo of residuals
+  //fDeltaZres3(336),   //->2D histo fo residuals
   fFitAside(new TVectorD(3)),
   fFitCside(new TVectorD(3)),      
-  fEdgeXcuts(5),    
-  fEdgeYcuts(5),    
+  fFitACside(new TVectorD(4)),      
+  fEdgeXcuts(3),    
+  fEdgeYcuts(3),    
   fNClCuts(5),      
-  fNcuts(0),        
-  fRun(0),
-  fEvent(0)
+  fNcuts(0)        
 {
   //
   // Constructor
@@ -161,30 +206,73 @@ AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title):
   fTracksEsd(336),
   fTracksEsdParam(336),
   fTracksTPC(336),
+  //
   fDeltaZ(336),          // array of histograms of delta z for each track
   fDeltaP3(336),          // array of histograms of delta z for each track
   fDeltaP4(336),          // array of histograms of P3 for each track
   fDeltaPhi(336),          // array of histograms of P4 for each track
   fDeltaPhiP(336),          // array of histograms of delta z for each track
   fSignals(336),           // array of dedx signals
+  //
+  //
+  fHisNclIn(0),      //->Number of clusters inner
+  fHisNclOut(0),     //->Number of clusters outer
+  fHisNclIO(0),      //->Number of cluster inner outer
+  fHisLclIn(0),      //->Level arm inner
+  fHisLclOut(0),     //->Level arm outer
+  fHisLclIO(0),      //->Number of cluster inner outer
+  fHisdEdx(0), //->dEdx histo  
+  fHisdZfit(0),     //->distance to the mirror after linear fit
+  //
+  //
+  fHisChi2YIn1(0),      //->chi2 y inner - line
+  fHisChi2YOut1(0),     //->chi2 y inner - line
+  fHisChi2YIn2(0),      //->chi2 y inner - parabola
+  fHisChi2YOut2(0),     //->chi2 y inner - parabola
+  fHisChi2YIO1(0),      //->chi2 y IO    - common
+  fHisChi2ZIn1(0),      //->chi2 z inner - line
+  fHisChi2ZOut1(0),     //->chi2 z inner - line
+  fHisChi2ZIn2(0),      //->chi2 z inner - parabola
+  fHisChi2ZOut2(0),     //->chi2 z inner - parabola
+  fHisChi2ZIO1(0),      //->chi2 z IO    - common
+  //
+  //
+  fHisPy1vP0(0),     //-> delta y   P0outer-P0inner - line
+  fHisPy2vP0(0),     //-> delta y   P0outer-P0inner - parabola
+  fHisPy3vP0(0),     //-> delta y   P0outer-P0inner - common parabola
+  fHisPy1vP1(0),     //-> delta ky  P1outer-P1inner - line
+  fHisPy2vP1(0),     //-> delta ky  P1outer-P1inner - parabola
+  fHisPy3vP1(0),     //-> delta ky  P1outer-P1inner - common parabola
+  fHisPy2vP2In(0),   //-> Curv  P2inner - parabola
+  fHisPy2vP2Out(0),  //-> Curv  P2outer - parabola
+  fHisPy3vP2IO(0),   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fHisPz1vP0(0),     //-> delta z   P0outer-P0inner - line
+  fHisPz2vP0(0),     //-> delta z   P0outer-P0inner - parabola
+  fHisPz3vP0(0),     //-> delta z   P0outer-P0inner - common parabola
+  fHisPz1vP1(0),     //-> delta kz  P1outer-P1inner - line
+  fHisPz2vP1(0),     //-> delta kz  P1outer-P1inner - parabola
+  fHisPz3vP1(0),     //-> delta kz  P1outer-P1inner - common parabola
+  fHisPz2vP2In(0),   //-> Curv  P2inner - parabola
+  fHisPz2vP2Out(0),  //-> Curv  P2outer - parabola
+  fHisPz3vP2IO(0),   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  //
   fDeltaYres(336),
   fDeltaZres(336),  
-  fPol2Par2InY(336),
-  fDiffPar1InY(336),
-  fPol2Par2OutY(336),
-  fDiffPar1OutY(336),
-  fPol2Par2InZ(336),
-  fDiffPar1InZ(336),
-  fPol2Par2OutZ(336),
-  fDiffPar1OutZ(336),
+  fDeltaYres2(336),
+  fDeltaZres2(336),  
+  //  fDeltaYres3(336),
+  //fDeltaZres3(336),  
   fFitAside(new TVectorD(3)),        // drift fit - A side
   fFitCside(new TVectorD(3)),        // drift fit - C- side
-  fEdgeXcuts(5),       // cuts in local x direction; used in the refit of the laser tracks
-  fEdgeYcuts(5),       // cuts in local y direction; used in the refit of the laser tracks
+  fFitACside(new TVectorD(4)),        // drift fit - AC- side
+  fEdgeXcuts(3),       // cuts in local x direction; used in the refit of the laser tracks
+  fEdgeYcuts(3),       // cuts in local y direction; used in the refit of the laser tracks
   fNClCuts(5),         // cuts on the number of clusters per tracklet; used in the refit of the laser tracks
-  fNcuts(0),           // number of cuts
-  fRun(0),
-  fEvent(0)
+  fNcuts(0)           // number of cuts
 {
   SetName(name);
   SetTitle(title);
@@ -194,10 +282,150 @@ AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title):
   fTracksEsdParam.SetOwner(kTRUE);
 }
 
+AliTPCcalibLaser::AliTPCcalibLaser(const AliTPCcalibLaser& calibLaser):
+  AliTPCcalibBase(calibLaser), 
+  fESD(0),
+  fESDfriend(0),
+  fTracksMirror(336),
+  fTracksEsd(336),
+  fTracksEsdParam(336),
+  fTracksTPC(336),
+  //
+  fDeltaZ(calibLaser.fDeltaZ),          // array of histograms of delta z for each track
+  fDeltaP3(((calibLaser.fDeltaP3))),          // array of histograms of delta z for each track
+  fDeltaP4(((calibLaser.fDeltaP4))),          // array of histograms of P3 for each track
+  fDeltaPhi(((calibLaser.fDeltaPhi))),          // array of histograms of P4 for each track
+  fDeltaPhiP(((calibLaser.fDeltaPhiP))),          // array of histograms of delta z for each track
+  fSignals(((calibLaser.fSignals))),           // array of dedx signals
+  //
+  //
+  fHisNclIn(new TH2F(*(calibLaser.fHisNclIn))),      //->Number of clusters inner
+  fHisNclOut(new TH2F(*(calibLaser.fHisNclOut))),     //->Number of clusters outer
+  fHisNclIO(new TH2F(*(calibLaser.fHisNclIO))),      //->Number of cluster inner outer
+  fHisLclIn(new TH2F(*(calibLaser.fHisLclIn))),      //->Level arm inner
+  fHisLclOut(new TH2F(*(calibLaser.fHisLclOut))),     //->Level arm outer
+  fHisLclIO(new TH2F(*(calibLaser.fHisLclIO))),      //->Number of cluster inner outer
+  fHisdEdx(new TH2F(*(calibLaser.fHisdEdx))),      //
+  fHisdZfit(new TH2F(*(calibLaser.fHisdZfit))),     //->distance to the mirror after linear fit
+  //
+  //
+  fHisChi2YIn1(new TH2F(*(calibLaser.fHisChi2YIn1))),      //->chi2 y inner - line
+  fHisChi2YOut1(new TH2F(*(calibLaser.fHisChi2YOut1))),     //->chi2 y inner - line
+  fHisChi2YIn2(new TH2F(*(calibLaser.fHisChi2YIn2))),      //->chi2 y inner - parabola
+  fHisChi2YOut2(new TH2F(*(calibLaser.fHisChi2YOut2))),     //->chi2 y inner - parabola
+  fHisChi2YIO1(new TH2F(*(calibLaser.fHisChi2YIO1))),      //->chi2 y IO    - common
+  fHisChi2ZIn1(new TH2F(*(calibLaser.fHisChi2ZIn1))),      //->chi2 z inner - line
+  fHisChi2ZOut1(new TH2F(*(calibLaser.fHisChi2ZOut1))),     //->chi2 z inner - line
+  fHisChi2ZIn2(new TH2F(*(calibLaser.fHisChi2ZIn2))),      //->chi2 z inner - parabola
+  fHisChi2ZOut2(new TH2F(*(calibLaser.fHisChi2ZOut2))),     //->chi2 z inner - parabola
+  fHisChi2ZIO1(new TH2F(*(calibLaser.fHisChi2ZIO1))),      //->chi2 z IO    - common
+  //
+  //
+  fHisPy1vP0(new TH2F(*(calibLaser.fHisPy1vP0))),     //-> delta y   P0outer-P0inner - line
+  fHisPy2vP0(new TH2F(*(calibLaser.fHisPy2vP0))),     //-> delta y   P0outer-P0inner - parabola
+  fHisPy3vP0(new TH2F(*(calibLaser.fHisPy3vP0))),     //-> delta y   P0outer-P0inner - common parabola
+  fHisPy1vP1(new TH2F(*(calibLaser.fHisPy1vP1))),     //-> delta ky  P1outer-P1inner - line
+  fHisPy2vP1(new TH2F(*(calibLaser.fHisPy2vP1))),     //-> delta ky  P1outer-P1inner - parabola
+  fHisPy3vP1(new TH2F(*(calibLaser.fHisPy3vP1))),     //-> delta ky  P1outer-P1inner - common parabola
+  fHisPy2vP2In(new TH2F(*(calibLaser.fHisPy2vP2In))),   //-> Curv  P2inner - parabola
+  fHisPy2vP2Out(new TH2F(*(calibLaser.fHisPy2vP2Out))),  //-> Curv  P2outer - parabola
+  fHisPy3vP2IO(new TH2F(*(calibLaser.fHisPy3vP2IO))),   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fHisPz1vP0(new TH2F(*(calibLaser.fHisPz1vP0))),     //-> delta z   P0outer-P0inner - line
+  fHisPz2vP0(new TH2F(*(calibLaser.fHisPz2vP0))),     //-> delta z   P0outer-P0inner - parabola
+  fHisPz3vP0(new TH2F(*(calibLaser.fHisPz3vP0))),     //-> delta z   P0outer-P0inner - common parabola
+  fHisPz1vP1(new TH2F(*(calibLaser. fHisPz1vP1))),     //-> delta kz  P1outer-P1inner - line
+  fHisPz2vP1(new TH2F(*(calibLaser.fHisPz2vP1))),     //-> delta kz  P1outer-P1inner - parabola
+  fHisPz3vP1(new TH2F(*(calibLaser.fHisPz3vP1))),     //-> delta kz  P1outer-P1inner - common parabola
+  fHisPz2vP2In(new TH2F(*(calibLaser.fHisPz2vP2In))),   //-> Curv  P2inner - parabola
+  fHisPz2vP2Out(new TH2F(*(calibLaser. fHisPz2vP2Out))),  //-> Curv  P2outer - parabola
+  fHisPz3vP2IO(new TH2F(*(calibLaser.fHisPz3vP2IO))),   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fDeltaYres(((calibLaser.fDeltaYres))),
+  fDeltaZres(((calibLaser.fDeltaZres))),  
+  fDeltaYres2(((calibLaser.fDeltaYres))),
+  fDeltaZres2(((calibLaser.fDeltaZres))),  
+  //  fDeltaYres3(((calibLaser.fDeltaYres))),
+  //fDeltaZres3(((calibLaser.fDeltaZres))),  
+  fFitAside(new TVectorD(3)),        // drift fit - A side
+  fFitCside(new TVectorD(3)),        // drift fit - C- side
+  fFitACside(new TVectorD(4)),        // drift fit - C- side
+  fEdgeXcuts(3),       // cuts in local x direction; used in the refit of the laser tracks
+  fEdgeYcuts(3),       // cuts in local y direction; used in the refit of the laser tracks
+  fNClCuts(5),         // cuts on the number of clusters per tracklet; used in the refit of the laser tracks
+  fNcuts(0)           // number of cuts
+{
+  //
+  // copy constructor
+  //
+}
+
+
+
+AliTPCcalibLaser & AliTPCcalibLaser::operator=(const AliTPCcalibLaser& calibLaser){
+  //
+  // assgnment operator
+  //
+  if (this != &calibLaser) {
+    new (this) AliTPCcalibLaser(calibLaser);
+  }
+  return *this;
+
+}
+
+
+
+
 AliTPCcalibLaser::~AliTPCcalibLaser() {
   //
   // destructor
   //
+  if ( fHisNclIn){
+    delete fHisNclIn;      //->Number of clusters inner
+    delete fHisNclOut;     //->Number of clusters outer
+    delete fHisNclIO;      //->Number of cluster inner outer
+    delete fHisLclIn;      //->Level arm inner
+    delete fHisLclOut;     //->Level arm outer
+    delete fHisLclIO;      //->Number of cluster inner outer
+    delete fHisdEdx;
+    delete fHisdZfit;     
+    //
+    //
+    delete fHisChi2YIn1;      //->chi2 y inner - line
+    delete fHisChi2YOut1;     //->chi2 y inner - line
+    delete fHisChi2YIn2;      //->chi2 y inner - parabola
+    delete fHisChi2YOut2;     //->chi2 y inner - parabola
+    delete fHisChi2YIO1;      //->chi2 y IO    - common
+    delete fHisChi2ZIn1;      //->chi2 z inner - line
+    delete fHisChi2ZOut1;     //->chi2 z inner - line
+    delete fHisChi2ZIn2;      //->chi2 z inner - parabola
+    delete fHisChi2ZOut2;     //->chi2 z inner - parabola
+    delete fHisChi2ZIO1;      //->chi2 z IO    - common
+    //
+    //
+    delete fHisPy1vP0;     //-> delta y   P0outer-P0inner - line
+    delete fHisPy2vP0;     //-> delta y   P0outer-P0inner - parabola
+    delete fHisPy3vP0;     //-> delta y   P0outer-P0inner - common parabola
+    delete fHisPy1vP1;     //-> delta ky  P1outer-P1inner - line
+    delete fHisPy2vP1;     //-> delta ky  P1outer-P1inner - parabola
+    delete fHisPy3vP1;     //-> delta ky  P1outer-P1inner - common parabola
+    delete fHisPy2vP2In;   //-> Curv  P2inner - parabola
+    delete fHisPy2vP2Out;  //-> Curv  P2outer - parabola
+    delete fHisPy3vP2IO;   //-> Curv  P2outerinner - common parabola
+    //
+    //
+    delete fHisPz1vP0;     //-> delta z   P0outer-P0inner - line
+    delete fHisPz2vP0;     //-> delta z   P0outer-P0inner - parabola
+    delete fHisPz3vP0;     //-> delta z   P0outer-P0inner - common parabola
+    delete fHisPz1vP1;     //-> delta kz  P1outer-P1inner - line
+    delete fHisPz2vP1;     //-> delta kz  P1outer-P1inner - parabola
+    delete fHisPz3vP1;     //-> delta kz  P1outer-P1inner - common parabola
+    delete fHisPz2vP2In;   //-> Curv  P2inner - parabola
+    delete fHisPz2vP2Out;  //-> Curv  P2outer - parabola
+    delete fHisPz3vP2IO;   //-> Curv  P2outerinner - common parabola
+  }
 }
 
 
@@ -207,6 +435,7 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
   //
   // Loop over tracks and call  Process function
   //
+  Int_t kMinTracks=20;
   fESD = event;
   if (!fESD) {
     return;
@@ -215,14 +444,24 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
   if (!fESDfriend) {
     return;
   }
+  if (fESD->GetNumberOfTracks()<kMinTracks) return; //not enough tracks
   AliDebug(4,Form("Event number in current file: %d",event->GetEventNumberInFile()));
   fTracksTPC.Clear();
   fTracksEsd.Clear();
   fTracksEsdParam.Delete();
+  for (Int_t id=0; id<336;id++) {
+    fCounter[id]=0;
+    fClusterCounter[id]=0;
+    fClusterSatur[id]=0;
+  }
+  static Bool_t init=kFALSE;
+  if (!init){
+    init = kTRUE;  // way around for PROOF - to be investigated
+    MakeFitHistos();
+  }
   //
   Int_t n=fESD->GetNumberOfTracks();
-  Int_t run = fESD->GetRunNumber();
-  fRun = run;
+  Int_t counter=0;
   for (Int_t i=0;i<n;++i) {
     AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
     AliESDtrack *track=fESD->GetTrack(i);
@@ -231,69 +470,49 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
     for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
       if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
        break;
-    if (track&&seed) FindMirror(track,seed);
+    if (track&&seed) {
+      Int_t id = FindMirror(track,seed);
+      if (id>0) counter++;
+    }
     //
-  }
+  }  
+  if (counter<kMinTracks) return;
 
   FitDriftV();
-  MakeDistHisto();
   //
-  for (Int_t id=0; id<336; id++){
-    //
+  for (Int_t id=0; id<336; id++){    
     //
     if (!fTracksEsdParam.At(id)) continue;
+    if (fClusterSatur[id]>0.3)   continue;  // tracks in saturation
     DumpLaser(id);
-//    RefitLaser(id);
-    RefitLaserJW(id);
-
+    if ( AcceptLaser(id) && fFitZ[id]<0.5){
+      RefitLaserJW(id);    
+      MakeDistHisto(id);
+    }
   }
-//  fEvent++;
+
 }
 
-void AliTPCcalibLaser::MakeDistHisto(){
+void AliTPCcalibLaser::MakeDistHisto(Int_t id){
   //
   //
   //
-  for (Int_t id=0; id<336; id++){
+  //  for (Int_t id=0; id<336; id++){
     //
     //
-    if (!fTracksEsdParam.At(id)) continue;
-    if (!AcceptLaser(id)) continue;
+    if (!fTracksEsdParam.At(id)) return;
+    if (!AcceptLaser(id)) return;
     //
     //
     TH1F * hisdz = (TH1F*)fDeltaZ.At(id);
+    if (!hisdz) MakeFitHistos();
+    hisdz = (TH1F*)fDeltaZ.At(id);
     TH1F * hisP3 = (TH1F*)fDeltaP3.At(id);
     TH1F * hisP4 = (TH1F*)fDeltaP4.At(id);
-
     TH1F * hisdphi = (TH1F*)fDeltaPhi.At(id);
     TH1F * hisdphiP = (TH1F*)fDeltaPhiP.At(id);
     TH1F * hisSignal = (TH1F*)fSignals.At(id);
-
-    if (!hisdz){
-      hisdz = new TH1F(Form("hisdz%d",id),Form("hisdz%d",id),1000,-10,10);
-      hisdz->SetDirectory(0);
-      fDeltaZ.AddAt(hisdz,id);
-
-      hisP3 = new TH1F(Form("hisPar3v%d",id),Form("hisPar3v%d",id),400,-0.06,0.06);
-      hisP3->SetDirectory(0);
-      fDeltaP3.AddAt(hisP3,id);
-      //
-      hisP4 = new TH1F(Form("hisPar4v%d",id),Form("hisPar4v%d",id),200,-0.06,0.06);
-      hisP4->SetDirectory(0);
-      fDeltaP4.AddAt(hisP4,id);
-
-      //
-      hisdphi = new TH1F(Form("hisdphi%d",id),Form("hisdphi%d",id),1000,-1,1);
-      hisdphi->SetDirectory(0);
-      fDeltaPhi.AddAt(hisdphi,id);
-      //
-      hisdphiP = new TH1F(Form("hisdphiP%d",id),Form("hisdphiP%d",id),1000,-0.01,0.01);
-      hisdphiP->SetDirectory(0);
-      fDeltaPhiP.AddAt(hisdphiP,id);
-      hisSignal = new TH1F(Form("hisSignal%d",id),Form("hisSignal%d",id),100,0,300);
-      hisSignal->SetDirectory(0);
-      fSignals.AddAt(hisSignal,id);
-    }
+    //
 
     AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
     AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
@@ -319,74 +538,225 @@ void AliTPCcalibLaser::MakeDistHisto(){
     if (hisdphi) hisdphi->Fill(dphi);
     if (hisdphiP) hisdphiP->Fill(dphiP);
     if (hisSignal) hisSignal->Fill(TMath::Sqrt(TMath::Abs(track->GetTPCsignal())));
-  }
+    // }
 }
 
 void AliTPCcalibLaser::FitDriftV(){
   //
-  // Fit drift velocity - linear approximation in the z and global y
-  //
+  // Fit corrections to the drift velocity - linear approximation in the z and global y
+  //The transfromatiom from the drift time to the z position done in AliTPCTracnsform class
+  // 
+  /*
+    Formulas:
+    
+    z  = s* (z0 - vd*(t-t0))
+    
+    s  - side -1 and +1 
+    t0 - time 0
+    vd - nominal drift velocity
+    zs - miscalibrated position
+    
+    zs = s*(z0 - vd*(1+vr)*(t-(t0+dt))
+    vr  - relative change of the drift velocity
+    dzt - vd*dt
+    dr  = zz0-s*z
+    ..
+    ==>
+    zs ~ z - s*vr*(z0-s*z)+s*dzt
+    --------------------------------
+    1. Correction function vr constant:
+    
+    
+    dz = zs-z = -s*vr *(z0-s*z)+s*dzt         
+    dzs/dl = dz/dl +s*s*vr*dz/dl 
+    d(dz/dl) = vr*dz/dl     
+  */
+
+  const Float_t kZCut        = 240;    // remove the closest laser beam
+  const Float_t kSaturCut    = 0.05;   // remove saturated lasers - cut on fraction of saturated 
+  const Float_t kDistCut     = 3;    // distance sigma cut
+  const Float_t kDistCutAbs  = 0.25;  
+  const Float_t kMinClusters = 60;  // minimal amount of the clusters
+  const Float_t kMinSignal   = 16;  // minimal mean height of the signal
+  const Float_t kChi2Cut     = 0.1; // chi2 cut to accept drift fit
   static TLinearFitter fdriftA(3,"hyp2");
   static TLinearFitter fdriftC(3,"hyp2");
-  fdriftA.ClearPoints();
-  fdriftC.ClearPoints();
+  static TLinearFitter fdriftAC(4,"hyp3");
+  TVectorD fitA(3),fitC(3),fitAC(4);
+  
+  AliTPCcalibDB*  calib=AliTPCcalibDB::Instance();
+  AliTPCParam  * tpcparam    = calib->GetParameters(); 
+   
   //
-  for (Int_t id=0; id<336; id++){
-    if (!fTracksEsdParam.At(id)) continue;
-    if (!AcceptLaser(id)) continue;
-    AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
-    AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
-    Double_t xyz[3];
-    Double_t pxyz[3];
-    Double_t lxyz[3];
-    Double_t lpxyz[3];
-    param->GetXYZ(xyz);
-    param->GetPxPyPz(pxyz);
-    ltrp->GetXYZ(lxyz);
-    ltrp->GetPxPyPz(lpxyz);
-    Double_t xxx[2] = {lxyz[2],lxyz[1]};
-    if (ltrp->GetSide()==0){
-      fdriftA.AddPoint(xxx,xyz[2],1);
-    }else{
-      fdriftC.AddPoint(xxx,xyz[2],1);
-    }
-  }
-  Float_t chi2A = 0;
-  Float_t chi2C = 0;
+  for (Int_t id=0; id<336; id++) fFitZ[id]=0;
+
+  Float_t chi2A = 10;
+  Float_t chi2C = 10;
+  Float_t chi2AC = 10;
   Int_t npointsA=0;
   Int_t npointsC=0;
-  //
-  if (fdriftA.GetNpoints()>10){
-    fdriftA.Eval();
-    fdriftA.EvalRobust(0.8);
-    fdriftA.GetParameters(*fFitAside);
-    npointsA= fdriftA.GetNpoints();
-    chi2A = fdriftA.GetChisquare()/fdriftA.GetNpoints();
-  }
-  if (fdriftC.GetNpoints()>10){
-    fdriftC.Eval();
-    fdriftC.EvalRobust(0.8);
-    fdriftC.GetParameters(*fFitCside);
-    npointsC= fdriftC.GetNpoints();
-    chi2C = fdriftC.GetChisquare()/fdriftC.GetNpoints();
-  }
+  Int_t npointsAC=0;
 
-  if (fStreamLevel>0){
-    TTreeSRedirector *cstream = GetDebugStreamer();
-    Int_t time = fESD->GetTimeStamp();
-    if (cstream){
-      (*cstream)<<"driftv"<<
-       "driftA.="<<fFitAside<<
-       "driftC.="<<fFitCside<<
-       "chi2A="<<chi2A<<
-       "chi2C="<<chi2C<<
-       "nA="<<npointsA<<
-       "nC="<<npointsC<<
-       "time="<<time<<
-       "\n";
+
+  for (Int_t iter=0; iter<3; iter++){
+    fdriftA.ClearPoints();
+    fdriftC.ClearPoints();
+    fdriftAC.ClearPoints();
+    //
+    for (Int_t id=0; id<336; id++){
+      if (!fTracksEsdParam.At(id)) continue;
+      if (!AcceptLaser(id)) continue;
+      if ( fClusterSatur[id]>kSaturCut)  continue;
+      if ( fClusterCounter[id]<kMinClusters)  continue;
+      AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
+      if (track->GetTPCsignal()<kMinSignal) continue;
+      AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
+      AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
+
+      Double_t xyz[3];
+      Double_t pxyz[3];
+      Double_t lxyz[3];
+      Double_t lpxyz[3];
+      param->GetXYZ(xyz);
+      param->GetPxPyPz(pxyz);
+      ltrp->GetXYZ(lxyz);
+      ltrp->GetPxPyPz(lpxyz);
+      if (TMath::Abs(lxyz[2])>kZCut) continue;
+      Float_t sz = (ltrp->GetSide()==0) ? TMath::Sqrt(chi2A): TMath::Sqrt(chi2C);
+      if (npointsAC>0) sz =TMath::Sqrt(chi2AC); 
+      if (TMath::Abs(fFitZ[id])>sz*kDistCut) continue;
+      if (iter>0 && TMath::Abs(fFitZ[id])>kDistCutAbs) continue;
+
+      // drift distance
+      Double_t zlength =  tpcparam->GetZLength(0);
+      Double_t ldrift = zlength-TMath::Abs(lxyz[2]);
+      Double_t mdrift = zlength-TMath::Abs(xyz[2]);
+      Double_t xxx[2] = {ldrift,lxyz[1]*ldrift/(zlength*250.)};
+      if (ltrp->GetSide()==0){
+       fdriftA.AddPoint(xxx,mdrift,1);
+      }else{
+       fdriftC.AddPoint(xxx,mdrift,1);
+      }
+      Double_t xxx2[3] = {ltrp->GetSide(), ldrift,lxyz[1]*ldrift/(zlength*250.)};
+      fdriftAC.AddPoint(xxx2,mdrift,1);
+    }
+    //
+    if (fdriftA.GetNpoints()>10){
+      //
+      fdriftA.Eval();
+      if (iter==0) fdriftA.EvalRobust(0.7);
+      else fdriftA.EvalRobust(0.8);
+      fdriftA.GetParameters(fitA);
+      npointsA= fdriftA.GetNpoints();
+      chi2A = fdriftA.GetChisquare()/fdriftA.GetNpoints();
+      if (chi2A<kChi2Cut ||(*fFitAside)[0]==0 ) (*fFitAside) = fitA;
+    }
+    if (fdriftC.GetNpoints()>10){
+      fdriftC.Eval();
+      if (iter==0) fdriftC.EvalRobust(0.7);
+      else fdriftC.EvalRobust(0.8);
+      //
+      fdriftC.GetParameters(fitC);
+      npointsC= fdriftC.GetNpoints();
+      chi2C = fdriftC.GetChisquare()/fdriftC.GetNpoints();
+      if (chi2C<kChi2Cut||(*fFitCside)[0]==0) (*fFitCside) = fitC;
+    }
+
+    if (fdriftAC.GetNpoints()>10&&fdriftC.GetNpoints()>10&&fdriftA.GetNpoints()>10){
+      fdriftAC.Eval();
+      if (iter==0) fdriftAC.EvalRobust(0.7);
+      else fdriftAC.EvalRobust(0.8);
+      //
+      fdriftAC.GetParameters(fitAC);
+      npointsAC= fdriftAC.GetNpoints();
+      chi2AC = fdriftAC.GetChisquare()/fdriftAC.GetNpoints();
+      if (chi2AC<kChi2Cut||(*fFitACside)[0]==0) (*fFitACside) = fitAC;
+    }
+    
+    for (Int_t id=0; id<336; id++){
+      if (!fTracksEsdParam.At(id)) continue;
+      //
+      AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
+      AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
+      Double_t xyz[3];
+      Double_t pxyz[3];
+      Double_t lxyz[3];
+      Double_t lpxyz[3];
+      param->GetXYZ(xyz);
+      param->GetPxPyPz(pxyz);
+      ltrp->GetXYZ(lxyz);
+      ltrp->GetPxPyPz(lpxyz); 
+      Double_t zlength =  tpcparam->GetZLength(0);
+      Double_t ldrift = zlength-TMath::Abs(lxyz[2]);
+      Double_t mdrift = zlength-TMath::Abs(xyz[2]);
+
+      Float_t fz =0;
+      if (ltrp->GetSide()==0){
+       fz = (fitA)[0]+(fitA)[1]*ldrift+(fitA)[2]*lxyz[1]*ldrift/(zlength*250.);
+      }else{
+       fz = (fitC)[0]+(fitC)[1]*ldrift+(fitC)[2]*lxyz[1]*ldrift/(zlength*250.);        
+      }
+      if (npointsAC>10){
+       fz = (fitAC)[0]+(fitAC)[1]*ltrp->GetSide()+(fitAC)[2]*ldrift+(fitAC)[3]*lxyz[1]*ldrift/(zlength*250.);
+      }
+      fFitZ[id]=mdrift-fz;
+    }
+    if (fStreamLevel>0){
+      TTreeSRedirector *cstream = GetDebugStreamer();
+      if (cstream){
+       (*cstream)<<"driftv"<<
+         "run="<<fRun<<              //  run number
+         "event="<<fEvent<<          //  event number
+         "time="<<fTime<<            //  time stamp of event
+         "trigger="<<fTrigger<<      //  trigger
+         "mag="<<fMagF<<             //  magnetic field
+         "iter="<<iter<<
+         "driftA.="<<fFitAside<<
+         "driftC.="<<fFitCside<<
+         "driftAC.="<<fFitACside<<
+         "chi2A="<<chi2A<<
+         "chi2C="<<chi2C<<
+         "chi2AC="<<chi2AC<<
+         "nA="<<npointsA<<
+         "nC="<<npointsC<<
+         "nAC="<<npointsAC<<
+         "\n";
+      }
     }
   }
+}
+
+Float_t AliTPCcalibLaser::GetDistance(AliExternalTrackParam *param, AliTPCLaserTrack *ltrp){
+  //
+  // get distance between mirror and laser track
+  //
+  //
+  Double_t xyz[3];
+  Double_t lxyz[3];
+  param->GetXYZ(xyz);
+  ltrp->GetXYZ(lxyz);
+  //
+  //
+  Double_t dist = 0;
+  //radial distance
+  dist+=TMath::Abs((TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(lxyz[1],lxyz[0]))*param->GetX());
+  //
+  // z distance
+  // apply drift correction if already exist
+  //
+  Float_t dz = 0;
+  if (ltrp->GetSide()==0){
+    if ((*fFitAside)[1]>0.) dz = ((*fFitAside)[0]+(*fFitAside)[1]*lxyz[2]+(*fFitAside)[2]*lxyz[1])-xyz[2];
+  }else{
+    if ((*fFitCside)[1]>0.) dz = ((*fFitCside)[0]+(*fFitCside)[1]*lxyz[2]+(*fFitCside)[2]*lxyz[1])-xyz[2];
+  }
+  if (TMath::Abs(dz)>3*(TMath::Abs(lxyz[2]-xyz[2])+1)) dz= TMath::Abs(lxyz[2]-xyz[2]);
+  dist+=TMath::Abs(dz);
   //
+  // phi dist - divergence on 50 cm
+  //
+  dist = TMath::Abs((param->GetParameter()[2]-ltrp->GetParameter()[2])*50);
+  return dist;
 }
 
 
@@ -395,7 +765,7 @@ Bool_t  AliTPCcalibLaser::AcceptLaser(Int_t id){
   //
   //
   /*
-  TCut cutP0("cutP0","abs(atan2(x1,x0)-atan2(lx1,lx0))<0.03");
+  TCut cutP0("cutP0","abs((atan2(x1,x0)-atan2(lx1,lx0))*254)<1.5");
   TCut cutP1("cutP1","abs(LTr.fP[1]-Tr.fP[1])<30");
   TCut cutP2("cutP2","abs(LTr.fP[2]-Tr.fP[2])<0.03");
   TCut cutP3("cutP3","abs(Tr.fP[3])<0.05");
@@ -410,7 +780,7 @@ Bool_t  AliTPCcalibLaser::AcceptLaser(Int_t id){
   Double_t lxyz[3];
   param->GetXYZ(xyz);
   ltrp->GetXYZ(lxyz);
-  if (TMath::Abs(TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(lxyz[1],lxyz[0]))>0.03) return kFALSE; //cut y- P0
+  if (TMath::Abs((TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(lxyz[1],lxyz[0]))*254)>1.5) return kFALSE; //cut y- P0
   if (TMath::Abs(param->GetParameter()[1]-ltrp->GetParameter()[1])>30) return kFALSE;    // cutZ -P1
   if (TMath::Abs(param->GetParameter()[2]-ltrp->GetParameter()[2])>0.03) return kFALSE;  // cut -P2
   if (TMath::Abs(param->GetParameter()[3])>0.05) return kFALSE;   // cut Tl -P3
@@ -425,9 +795,11 @@ Int_t  AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
   //
   // Find corresponding mirror
   // add the corresponding tracks
-  //
-  Float_t kRadius0 = 252;
-  Float_t kRadius  = 253.4;
+
+  Float_t kRadius0  = 252;
+  Float_t kRadius   = 253.4;
+
   if (!track->GetOuterParam()) return -1;
   AliExternalTrackParam param(*(track->GetOuterParam()));
   AliTracker::PropagateTrackTo(&param,kRadius0,0.10566,3,kTRUE);
@@ -445,20 +817,49 @@ Int_t  AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
   else
     ltrp=&ltr;
 
-
-  if (id>=0){
-    //
-    //
-    Float_t radius=TMath::Abs(ltrp->GetX());
-    AliTracker::PropagateTrackTo(&param,radius,0.10566,0.01,kTRUE);
-    //
-    if (!fTracksMirror.At(id)) fTracksMirror.AddAt(ltrp,id);
+  if (id<0) return id;
+  fCounter[id]++;
+  //
+  //
+  //
+  Int_t countercl=0;
+  Float_t counterSatur=0;
+  for (Int_t irow=158;irow>-1;--irow) {
+    AliTPCclusterMI *c=seed->GetClusterPointer(irow);
+    if (!c) continue;
+    Double_t pedgeY = c->GetX()*TMath::DegToRad()*(10)-TMath::Abs(c->GetY());
+    Double_t pedgeX = TMath::Min((irow)*0.75, (159.-irow)*1.5);
+    if (pedgeY<3) continue;
+    if (pedgeX<3) continue;
+    countercl++;
+    if (c->GetMax()>900) counterSatur++;
+  }
+  counterSatur/=(countercl+1);
+  //
+  if (counterSatur>fClusterSatur[id]) fClusterSatur[id]=counterSatur;
+  //
+  //
+  Float_t radius=TMath::Abs(ltrp->GetX());
+  AliTracker::PropagateTrackTo(&param,radius,0.10566,0.01,kTRUE);
+  //
+  if (!fTracksMirror.At(id)) fTracksMirror.AddAt(ltrp,id);
+  Bool_t accept=kTRUE;  
+  //
+  // choose closer track
+  //
+  AliExternalTrackParam * param0  = (AliExternalTrackParam *)fTracksEsdParam.At(id);
+  if (param0){
+    Float_t dist0=GetDistance(param0,ltrp);
+    Float_t dist1=GetDistance(&param,ltrp);
+    if (dist0<dist1)    accept=kFALSE;       
+  }
+  
+  if (accept){
+    fClusterCounter[id]=countercl;
     fTracksEsdParam.AddAt(param.Clone(),id);
     fTracksEsd.AddAt(track,id);
     fTracksTPC.AddAt(seed,id);
-    //
   }
-
   return id;
 }
 
@@ -482,19 +883,38 @@ void AliTPCcalibLaser::DumpLaser(Int_t id) {
   param->GetPxPyPz(pxyz);
   ltrp->GetXYZ(lxyz);
   ltrp->GetPxPyPz(lpxyz);
-
+  Float_t dist3D   = GetDistance(param,ltrp);
+  Float_t dist0    = (TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(lxyz[1],lxyz[0]))*param->GetX();
+  Float_t distphi  = (param->GetParameter()[2]-ltrp->GetParameter()[2])*50;
+  
+  
   if (fStreamLevel>0){
     TTreeSRedirector *cstream = GetDebugStreamer();
     Int_t time = fESD->GetTimeStamp();
     Bool_t accept = AcceptLaser(id);
     if (cstream){
       (*cstream)<<"Track"<<
-       "run="<<fRun<<
+       //
+       "run="<<fRun<<              //  run number
+       "event="<<fEvent<<          //  event number
+       "time="<<fTime<<            //  time stamp of event
+       "trigger="<<fTrigger<<      //  trigger
+       "mag="<<fMagF<<             //  magnetic field
+
        "id="<<id<<
        "accept="<<accept<<
        "driftA.="<<fFitAside<<
        "driftC.="<<fFitCside<<
        "time="<<time<<
+       "dist3D="<<dist3D<<
+       "dist0="<<dist0<<
+       "distphi="<<distphi<<
+       //
+       //
+       "counter="<<fCounter[id]<<
+       "clcounter="<<fClusterCounter[id]<<
+       "satur="<<fClusterSatur[id]<<
+       "fz="<<fFitZ[id]<<
        //
         "LTr.="<<ltrp<<
        "Esd.="<<track<<
@@ -526,6 +946,20 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
   // 4. Per track offset for each sector, linear for each sector, common quadratic
   // store x, y, z information for all models and the cluster to calculate the residuals
   //
+  
+  // The clusters which do not fulfill given  criteria are skipped
+  //
+  // Cluters removed from fit
+  //  1. Extended shape     > kShapeCut
+  //  2. In saturation  Max > kMax
+  //  3. Distance to edge   < cutEdge
+  //
+  // Clusters not used for the calibration:
+  //
+  //  1. Extended shape     > kShapeCut
+  //  2. In saturation  Max > kMax
+
+
   AliTPCseed *track      = (AliTPCseed*)fTracksTPC.At(id);
   AliExternalTrackParam *extparam=(AliExternalTrackParam*)fTracksEsdParam.At(id);
   AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
@@ -533,7 +967,13 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
   AliTPCclusterMI dummyCl;
 
   //two tracklets
-  Int_t kMaxTracklets=2;
+  Int_t kMaxTracklets=2;  
+  Float_t kShapeCut = 1.3;
+  Float_t kRatioCut = 2.;
+
+  Float_t kMax      = 900.;
+
+
   //=============================================//
   // Linear Fitters for the Different Approaches //
   //=============================================//
@@ -563,6 +1003,14 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
   // Loop over all Tracklet Cuts //
   //=============================//
   for (Int_t icut=0; icut<fNcuts; icut++){
+    Float_t xinMin = 2500, xinMax=-90;
+    Float_t xoutMin=2500, xoutMax=-90;
+    Float_t msigmaYIn=0;
+    Float_t msigmaYOut=0;
+    Float_t mqratioIn=0;
+    Float_t mqratioOut=0;
+
+
       AliDebug(4,Form("Processing cut %d for track with ID %d",icut,id));
       //cut parameters
       Double_t edgeCutX = fEdgeXcuts[icut];
@@ -579,6 +1027,10 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       TVectorD vecy2resOuter(3),vecz2resOuter(3); //pol2 fit parameters outer
       TVectorD vecy4res(5),vecz4res(5);
       // cluster and track positions for each row - used for residuals
+      TVectorD vecgX(159);        // global X
+      TVectorD vecgY(159);        // global Y
+      TVectorD vecgZ(159);        // global Z
+
       TVectorD vecX(159);        // x is the same for all (row center)
       TVectorD vecYkalman(159);  // y from kalman fit
       TVectorD vecZkalman(159);  // z from kalman fit
@@ -591,17 +1043,18 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       TVectorD vecClY(159);      // y cluster position
       TVectorD vecClZ(159);      // z cluster position
       TVectorD vecSec(159);      // sector for each row
+      TVectorD  isReject(159);    // flag - cluster to be rejected 
       //chi2 of fits
-      Double_t chi2I1z=-1;       // chi2 of pol1 fit in z (inner)
-      Double_t chi2I1y=-1;       // chi2 of pol1 fit in y (inner)
-      Double_t chi2O1z=-1;       // chi2 of pol1 fit in z (outer)
-      Double_t chi2O1y=-1;       // chi2 of pol1 fit in y (outer)
-      Double_t chi2I2z=-1;       // chi2 of pol2 fit in z (inner)
-      Double_t chi2I2y=-1;       // chi2 of pol2 fit in y (inner)
-      Double_t chi2O2z=-1;       // chi2 of pol2 fit in z (outer)
-      Double_t chi2O2y=-1;       // chi2 of pol2 fit in y (outer)
-      Double_t chi2IOz=-1;       // chi2 of hyp4 fit in z (inner+outer)
-      Double_t chi2IOy=-1;       // chi2 of hyp4 fit in y (inner+outer)
+      Double_t chi2I1z=0;       // chi2 of pol1 fit in z (inner)
+      Double_t chi2I1y=0;       // chi2 of pol1 fit in y (inner)
+      Double_t chi2O1z=0;       // chi2 of pol1 fit in z (outer)
+      Double_t chi2O1y=0;       // chi2 of pol1 fit in y (outer)
+      Double_t chi2I2z=0;       // chi2 of pol2 fit in z (inner)
+      Double_t chi2I2y=0;       // chi2 of pol2 fit in y (inner)
+      Double_t chi2O2z=0;       // chi2 of pol2 fit in z (outer)
+      Double_t chi2O2y=0;       // chi2 of pol2 fit in y (outer)
+      Double_t chi2IOz=0;       // chi2 of hyp4 fit in z (inner+outer)
+      Double_t chi2IOy=0;       // chi2 of hyp4 fit in y (inner+outer)
       //more
       Int_t innerSector = -1;    // number of inner sector
       Int_t outerSector = -1;    // number of outer sector
@@ -661,14 +1114,36 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       // fill fitters with cluster information //
       //=======================================//
       AliDebug(3,"Filing Cluster Information");
+
+      //
+      //
+
       for (Int_t irow=158;irow>-1;--irow) {
          AliTPCclusterMI *c=track->GetClusterPointer(irow);
          AliTPCclusterMI &cl = (AliTPCclusterMI&) (*arrCl[irow]);
          cl=dummyCl;
+         vecX[irow]   = 0;
+         vecClY[irow] = 0;
+         vecClZ[irow] = 0;
+         Float_t meanY=0, sumY=0;
+         for (Int_t drow=-1;drow<=1;drow++) {
+           if (irow+drow<0) continue;
+           if (irow+drow>158) continue;
+           AliTPCclusterMI *c=track->GetClusterPointer(irow);
+           if (!c) continue;
+           Int_t roc = static_cast<Int_t>(c->GetDetector());
+           if ( roc!=innerSector && roc!=outerSector ) continue;
+           if (c->GetX()<10) continue;
+           if (c->GetY()==0) continue;
+           meanY+=c->GetY();
+           sumY++;
+         }
+         if (sumY>0)  meanY/=sumY; 
+        
           //
           vecSec[irow]=-1;
          if (!c) continue;
-         Double_t pedgeY = c->GetX()*TMath::DegToRad()*(10)-TMath::Abs(c->GetY());
+         Double_t pedgeY = c->GetX()*TMath::Tan(TMath::DegToRad()*(10))-TMath::Abs(meanY);
          Double_t pedgeX = TMath::Min((irow)*0.75, (159.-irow)*1.5);
          
           //
@@ -676,11 +1151,20 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
          if ( roc!=innerSector && roc!=outerSector ) continue;
           vecSec[irow]=roc;
          //store clusters in clones array
-         cl=*c;
+         cl=*c;          
+         //
+         if (c->GetMax()<4)   continue;  // noise cluster?
+         if (TMath::Abs(c->GetY())<0.0001)   continue;  // noise cluster?
          //cluster position
          vecX[irow]   = c->GetX();
          vecClY[irow] = c->GetY();
          vecClZ[irow] = c->GetZ();
+         //
+         Float_t gxyz[3];
+         c->GetGlobalXYZ(gxyz);
+         vecgX[irow]   = gxyz[0];
+         vecgY[irow]   = gxyz[1];
+         vecgZ[irow]   = gxyz[2];
           //
           Double_t x = vecX[irow]-133.4; //reference is between IROC and OROC
           Double_t y = vecClY[irow];
@@ -697,6 +1181,7 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
          x4[3]=x*x;   //common parabolic shape
          if (pedgeX < fEdgeXcuts[icut]) continue;
          if (pedgeY < fEdgeYcuts[icut]) continue;
+         if (c->GetMax()>900) continue;  // cluster in saturation        
           //
          if ( roc==innerSector ){
              fy1I.AddPoint(x2,y);
@@ -704,6 +1189,12 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
              fy2I.AddPoint(x2,y);
              fz2I.AddPoint(x2,z);
               ++nclI;
+             if (c->GetX()<xinMin) xinMin=c->GetX();
+             if (c->GetX()>xinMax) xinMax=c->GetX();
+
+             msigmaYIn +=TMath::Sqrt(c->GetSigmaY2());
+             mqratioIn +=c->GetMax()/c->GetQ();
+
          }
          if ( roc==outerSector ){
              fy1O.AddPoint(x2,y);
@@ -711,10 +1202,23 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
              fy2O.AddPoint(x2,y);
              fz2O.AddPoint(x2,z);
               ++nclO;
+             if (c->GetX()<xoutMin) xoutMin=c->GetX();
+             if (c->GetX()>xoutMax) xoutMax=c->GetX();
+             msigmaYOut +=TMath::Sqrt(c->GetSigmaY2());
+             mqratioOut +=c->GetMax()/c->GetQ();
+
          }
          fy4.AddPoint(x4,y);
          fz4.AddPoint(x4,z);
       }
+      if (nclI>0)  {
+       msigmaYIn/=nclI;
+       mqratioIn/=nclI;
+      }
+      if (nclO>0)  {
+       msigmaYOut/=nclO;
+       mqratioOut/=nclO;
+      }
       //======================================//
       // Evaluate and retrieve fit parameters //
       //======================================//
@@ -773,6 +1277,29 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       //==============================//
       AliDebug(4,"Calculate tracklet positions");
       for (Int_t irow=158;irow>-1;--irow) {
+       isReject[irow]=0;
+        AliTPCclusterMI *c=track->GetClusterPointer(irow);
+        if ( vecSec[irow]!=innerSector && vecSec[irow]!=outerSector ) { // no cluster in given sectors
+          isReject[irow]+=1;
+        }
+
+        if (!c) { //no cluster    
+          isReject[irow]+=2;
+        }else{
+          if (c->GetMax()>kMax){   //saturation
+            isReject[irow]+=4;
+          }
+          if ( vecSec[irow] == outerSector ) {   //extended shape
+            if (c->GetMax()/c->GetQ()> mqratioOut*kRatioCut)                isReject[irow]+=8;
+            if (TMath::Sqrt(c->GetSigmaY2())>msigmaYOut*kShapeCut)    isReject[irow]+=16;
+          }else{
+            if (c->GetMax()/c->GetQ()> mqratioIn*kRatioCut)                isReject[irow]+=8;
+            if (TMath::Sqrt(c->GetSigmaY2())>msigmaYIn*kShapeCut)    isReject[irow]+=16;
+          }       
+        }
+
+
+
          if ( vecSec[irow]==-1 ) continue;  //no cluster info
           if ( vecSec[irow]!=innerSector && vecSec[irow]!=outerSector ) continue;
          tr=&dummy;
@@ -820,6 +1347,10 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
              vecYkalman[irow]=xyz[1];
              vecZkalman[irow]=xyz[2];
          }
+         //
+         //
+         //
+        
       }
       //=====================================================================//
       // write results from the different tracklet fits with debug streamers //
@@ -827,42 +1358,56 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       if (fStreamLevel>4){
          TTreeSRedirector *cstream = GetDebugStreamer();
          if (cstream){
-             Float_t dedx = track->GetdEdx();
-             (*cstream)<<"FitModels"<<
-                 "cutNr="      << icut <<
-                  "edgeCutX="   << edgeCutX <<
-                 "edgeCutY="   << edgeCutY <<
-                 "nclCut="     << nclCut <<
-                  "innerSector="<< innerSector <<
-                 "outerSector="<< outerSector <<
-                  "dEdx="       << dedx <<
-                 "LTr.="       << ltrp <<
-                 "Tr.="        << extparam <<
-                  "yPol1In.="   << &vecy1resInner <<
-                  "zPol1In.="   << &vecz1resInner <<
-                  "yPol2In.="   << &vecy2resInner <<
-                  "zPol2In.="   << &vecz2resInner <<
-                  "yPol1Out.="  << &vecy1resOuter <<
-                  "zPol1Out.="  << &vecz1resOuter <<
-                  "yPol2Out.="  << &vecy2resOuter <<
-                  "zPol2Out.="  << &vecz2resOuter <<
-                 "yInOut.="    << &vecy4res <<
-                 "zInOut.="    << &vecz4res <<
-                  "chi2y1In="   << chi2I1y <<
-                  "chi2z1In="   << chi2I1z <<
-                  "chi2y1Out="  << chi2O1y <<
-                  "chi2z1Out="  << chi2O1z <<
-                  "chi2y2In="   << chi2I2y <<
-                  "chi2z2In="   << chi2I2z <<
-                  "chi2y2Out="  << chi2O2y <<
-                  "chi2z2Out="  << chi2O2z <<
-                  "chi2yInOut=" << chi2IOy <<
-                  "chi2zInOut=" << chi2IOz <<
-                 "trletIn.="   << trInner <<
-                 "trletOut.="  << trOuter <<
-                 "nclI="       << nclI <<
-                  "nclO="       << nclO <<
-                 "\n";
+           Float_t dedx = track->GetdEdx();
+           (*cstream)<<"FitModels"<<
+             "run="<<fRun<<              //  run number
+             "event="<<fEvent<<          //  event number
+             "time="<<fTime<<            //  time stamp of event
+             "trigger="<<fTrigger<<      //  trigger
+             "mag="<<fMagF<<             //  magnetic field          
+             //
+             "cutNr="      << icut <<
+             "edgeCutX="   << edgeCutX <<
+             "edgeCutY="   << edgeCutY <<
+             "nclCut="     << nclCut <<
+             "innerSector="<< innerSector <<
+             "outerSector="<< outerSector <<
+             "dEdx="       << dedx <<
+             "LTr.="       << ltrp <<
+             "Tr.="        << extparam <<
+             "yPol1In.="   << &vecy1resInner <<
+             "zPol1In.="   << &vecz1resInner <<
+             "yPol2In.="   << &vecy2resInner <<
+             "zPol2In.="   << &vecz2resInner <<
+             "yPol1Out.="  << &vecy1resOuter <<
+             "zPol1Out.="  << &vecz1resOuter <<
+             "yPol2Out.="  << &vecy2resOuter <<
+             "zPol2Out.="  << &vecz2resOuter <<
+             "yInOut.="    << &vecy4res <<
+             "zInOut.="    << &vecz4res <<
+             "chi2y1In="   << chi2I1y <<
+             "chi2z1In="   << chi2I1z <<
+             "chi2y1Out="  << chi2O1y <<
+             "chi2z1Out="  << chi2O1z <<
+             "chi2y2In="   << chi2I2y <<
+             "chi2z2In="   << chi2I2z <<
+             "chi2y2Out="  << chi2O2y <<
+             "chi2z2Out="  << chi2O2z <<
+             "chi2yInOut=" << chi2IOy <<
+             "chi2zInOut=" << chi2IOz <<
+             "trletIn.="   << trInner <<
+             "trletOut.="  << trOuter <<
+             "nclI="       << nclI <<
+             "nclO="       << nclO <<
+             "xinMin="     << xinMin<<
+             "xinMax="     << xinMax<<
+             "xoutMin="    << xoutMin<<
+             "xoutMax="     << xoutMax<<
+             "msigmaYIn=" <<msigmaYIn<<
+             "msigmaYOut=" <<msigmaYOut<<
+             "mqratioIn=" <<mqratioIn<<
+             "mqratioOut=" <<  mqratioOut      <<
+             "\n";
          }
       }
 
@@ -870,242 +1415,176 @@ void AliTPCcalibLaser::RefitLaserJW(Int_t id){
       if (fStreamLevel>5){
          TTreeSRedirector *cstream = GetDebugStreamer();
          if (cstream){
-             Float_t dedx = track->GetdEdx();
-             (*cstream)<<"Residuals"<<
-                 "cutNr="      << icut <<
-                  "edgeCutX="   << edgeCutX <<
-                 "edgeCutY="   << edgeCutY <<
-                 "nclCut="     << nclCut   <<
-                 "LTr.="       << ltrp <<
-                 "Tr.="        << extparam<<
-                 "dEdx="       << dedx <<
-                 "Cl.="        << &arrCl <<
-                 "TrX.="       << &vecX <<
-                 "TrYpol1.="   << &vecY1 <<
-                 "TrZpol1.="   << &vecZ1 <<
-                 "TrYpol2.="   << &vecY2 <<
-                 "TrZpol2.="   << &vecZ2 <<
-                 "TrYInOut.="  << &vecY4 <<
-                 "TrZInOut.="  << &vecZ4 <<
-                 "ClY.="       << &vecClY <<
-                 "ClZ.="       << &vecClZ <<
-                  "sec.="       << &vecSec <<
-                 "nclI="       << nclI <<
-                  "nclO="       << nclO <<
-                 "yInOut.="    << &vecy4res <<
-                 "zInOut.="    << &vecz4res <<
-                  "chi2y1In="   << chi2I1y <<
-                  "chi2z1In="   << chi2I1z <<
-                  "chi2y1Out="  << chi2O1y <<
-                  "chi2z1Out="  << chi2O1z <<
-                  "chi2y2In="   << chi2I2y <<
-                  "chi2z2In="   << chi2I2z <<
-                  "chi2y2Out="  << chi2O2y <<
-                  "chi2z2Out="  << chi2O2z <<
-                  "chi2yInOut=" << chi2IOy <<
-                  "chi2zInOut=" << chi2IOz <<
-                 "\n";
+           Float_t dedx = track->GetdEdx();
+           (*cstream)<<"Residuals"<<
+             "run="<<fRun<<              //  run number
+             "event="<<fEvent<<          //  event number
+             "time="<<fTime<<            //  time stamp of event
+             "trigger="<<fTrigger<<      //  trigger
+             "mag="<<fMagF<<             //  magnetic field          
+             //
+             "cutNr="      << icut <<
+             "edgeCutX="   << edgeCutX <<
+             "edgeCutY="   << edgeCutY <<
+             "nclCut="     << nclCut   <<
+             "LTr.="       << ltrp <<
+             "Tr.="        << extparam<<
+             "dEdx="       << dedx <<
+             "Cl.="        << &arrCl <<
+             "vX.="        << &vecgX<<   // global x
+             "vY.="        << &vecgY<<   // global y
+             "vZ.="        << &vecgZ<<   // global z
+             "TrX.="       << &vecX <<
+             "TrYpol1.="   << &vecY1 <<
+             "TrZpol1.="   << &vecZ1 <<
+             "TrYpol2.="   << &vecY2 <<
+             "TrZpol2.="   << &vecZ2 <<
+             "TrYInOut.="  << &vecY4 <<
+             "TrZInOut.="  << &vecZ4 <<
+             "ClY.="       << &vecClY <<
+             "ClZ.="       << &vecClZ <<
+             "isReject.="  << &isReject<<
+             "sec.="       << &vecSec <<
+             "nclI="       << nclI <<
+             "nclO="       << nclO <<
+             "xinMin="     << xinMin<<
+             "xinMax="     << xinMax<<
+             "xoutMin="    << xoutMin<<
+             "xoutMax="     << xoutMax<<
+             "msigmaYIn=" <<msigmaYIn<<
+             "msigmaYOut=" <<msigmaYOut<<
+             "mqratioIn=" <<mqratioIn<<
+             "mqratioOut=" <<  mqratioOut      <<
+             "yInOut.="    << &vecy4res <<
+             "zInOut.="    << &vecz4res <<
+             //chi2s
+             "chi2y1In="   << chi2I1y <<    //
+             "chi2z1In="   << chi2I1z <<
+             "chi2y1Out="  << chi2O1y <<
+             "chi2z1Out="  << chi2O1z <<
+             "chi2y2In="   << chi2I2y <<
+             "chi2z2In="   << chi2I2z <<
+             "chi2y2Out="  << chi2O2y <<
+             "chi2z2Out="  << chi2O2z <<
+             "chi2yInOut=" << chi2IOy <<
+             "chi2zInOut=" << chi2IOz <<
+             // fit parameters
+             "yPol1In.="   << &vecy1resInner <<
+             "zPol1In.="   << &vecz1resInner <<
+             "yPol2In.="   << &vecy2resInner <<
+             "zPol2In.="   << &vecz2resInner <<
+             "yPol1Out.="  << &vecy1resOuter <<
+             "zPol1Out.="  << &vecz1resOuter <<
+             "yPol2Out.="  << &vecy2resOuter <<
+             "zPol2Out.="  << &vecz2resOuter <<
+
+             "\n";
 
          }
       }
       //==========================//
       // Fill Residual Histograms //
       //==========================//
-      TProfile *profy = (TProfile*)fDeltaYres.UncheckedAt(id);
-      TProfile *profz = (TProfile*)fDeltaZres.UncheckedAt(id);
-      if (!profy){
-       profy=new TProfile(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d",id),115,80,250);
-       profy->SetDirectory(0);
-       fDeltaYres.AddAt(profy,id);
-      }
-      if (!profz){
-       profz=new TProfile(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d",id),115,80,250);
-       profz->SetDirectory(0);
-       fDeltaZres.AddAt(profz,id);
-      }
+      if (!fHisNclIn) MakeFitHistos(); 
+
+      TH2F *profy = (TH2F*)fDeltaYres.UncheckedAt(id);
+      TH2F *profz = (TH2F*)fDeltaZres.UncheckedAt(id);
+      TH2F *profy2 = (TH2F*)fDeltaYres2.UncheckedAt(id);
+      TH2F *profz2 = (TH2F*)fDeltaZres2.UncheckedAt(id);
+      //      TH2F *profy3 = (TH2F*)fDeltaYres3.UncheckedAt(id);
+      //TH2F *profz3 = (TH2F*)fDeltaZres3.UncheckedAt(id);
+      //
       for (Int_t irow=158;irow>-1;--irow) {
-       if (vecSec[irow]==-1)continue; //no cluster info
+       if (vecSec[irow]==-1)continue; // no cluster info
+       if (isReject[irow]>0.5) continue;  // 
        Double_t x    = vecX[irow];
        Double_t ycl  = vecClY[irow];
        Double_t yfit = vecY1[irow];
+       Double_t yfit2 = vecY2[irow];
+       Double_t yfit3 = vecY2[irow];
        Double_t zcl  = vecClZ[irow];
        Double_t zfit = vecZ1[irow];
-       if (profy) 
-         if (profy->GetEntries()<1000000) 
-           profy->Fill(x,yfit-ycl);
-       if (profz) 
-         if (profz->GetEntries()<1000000) 
-           profz->Fill(x,zfit-zcl);
-      }
-      //===============================//
-      // Fill Fit Parameter Histograms //
-      //===============================//
-      TH1F *pol2InnerY =(TH1F*)fPol2Par2InY.UncheckedAt(id);
-      TH1F *diff1InnerY=(TH1F*)fDiffPar1InY.UncheckedAt(id);
-      TH1F *pol2OuterY =(TH1F*)fPol2Par2OutY.UncheckedAt(id);
-      TH1F *diff1OuterY=(TH1F*)fDiffPar1OutY.UncheckedAt(id);
-      TH1F *pol2InnerZ =(TH1F*)fPol2Par2InZ.UncheckedAt(id);
-      TH1F *diff1InnerZ=(TH1F*)fDiffPar1InZ.UncheckedAt(id);
-      TH1F *pol2OuterZ =(TH1F*)fPol2Par2OutZ.UncheckedAt(id);
-      TH1F *diff1OuterZ=(TH1F*)fDiffPar1OutZ.UncheckedAt(id);
-      //create histograms if the do not already exist
-      if (!pol2InnerY){
-         pol2InnerY =new TH1F(Form("pol2par2inY%03d",id),
-                              Form("2nd derivative from pol2 fit in Y for Laser beam %03d (inner sector)",id),
-                              500,-.005,.005);
-         pol2InnerY->SetDirectory(0);
-         pol2OuterY =new TH1F(Form("pol2par2outY%03d",id),
-                              Form("2nd derivative from pol2 fit in Y for Laser beam %03d (outer sector)",id),
-                              500,0.01,.01);
-         pol2OuterY->SetDirectory(0);
-
-         diff1InnerY=new TH1F(Form("diff1inY%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Y fit for Laser beam %03d (inner sector)",id),
-                              500,-.5,.5);
-         diff1InnerY->SetDirectory(0);
-
-         diff1OuterY=new TH1F(Form("diff1outY%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Yfit for Laser beam %03d (outer sector)",id),
-                              500,-1,1);
-         diff1OuterY->SetDirectory(0);
-
-         pol2InnerZ =new TH1F(Form("pol2par2inZ%03d",id),
-                              Form("2nd derivative from pol2 fit in Z for Laser beam %03d (inner sector)",id),
-                              500,-.002,.002);
-         pol2InnerZ->SetDirectory(0);
-
-         pol2OuterZ =new TH1F(Form("pol2par2outZ%03d",id),
-                              Form("2nd derivative from pol2 fit in Z for Laser beam %03d (outer sector)",id),
-                              500,-.005,.005);
-         pol2OuterZ->SetDirectory(0);
-         diff1InnerZ=new TH1F(Form("diff1inZ%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Z fit for Laser beam %03d (inner sector)",id),
-                              500,-.02,.02);
-         diff1InnerZ->SetDirectory(0);
-         diff1OuterZ=new TH1F(Form("diff1outZ%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Zfit for Laser beam %03d (outer sector)",id),
-                              500,-.03,.03);
-         diff1OuterZ->SetDirectory(0);
-          //add
-         fPol2Par2InY.AddAt(pol2InnerY,id);
-         fDiffPar1InY.AddAt(diff1InnerY,id);
-         fPol2Par2OutY.AddAt(pol2OuterY,id);
-         fDiffPar1OutY.AddAt(diff1OuterY,id);
-         fPol2Par2InZ.AddAt(pol2InnerZ,id);
-         fDiffPar1InZ.AddAt(diff1InnerZ,id);
-         fPol2Par2OutZ.AddAt(pol2OuterZ,id);
-         fDiffPar1OutZ.AddAt(diff1OuterZ,id);
+       Double_t zfit2 = vecZ2[irow];
+       Double_t zfit3 = vecZ2[irow];
+
+       if (TMath::Abs(yfit-ycl)<2&&TMath::Abs(zfit-zcl)<2){
+         if (profy){       
+             profy->Fill(irow,ycl-yfit);
+             profy2->Fill(irow,ycl-yfit2);
+             //              profy3->Fill(irow,ycl-yfit3);
+         }
+         if (profz) {
+             profz->Fill(irow,zcl-zfit);
+             profz2->Fill(irow,zcl-zfit2);
+             //profz3->Fill(irow,zcl-zfit3);
+         }
+       }
       }
-      //fill histograms
-      pol2InnerY ->Fill(vecy2resInner[2]);
-      pol2OuterY ->Fill(vecy2resOuter[2]);
-      diff1InnerY->Fill(vecy2resInner[1]-vecy1resInner[1]);
-      diff1OuterY->Fill(vecy2resOuter[1]-vecy1resOuter[1]);
-      pol2InnerZ ->Fill(vecz2resInner[2]);
-      pol2OuterZ ->Fill(vecz2resOuter[2]);
-      diff1InnerZ->Fill(vecz2resInner[1]-vecz1resInner[1]);
-      diff1OuterZ->Fill(vecz2resOuter[1]-vecz1resOuter[1]);
-
-
-
-  }
-}
-
-
-void AliTPCcalibLaser::RefitLaser(Int_t id){
-  //
-  // Refit the track store residuals
-  //
-
-  AliTPCseed *track    = (AliTPCseed*)fTracksTPC.At(id);
-  AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
-  AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
-
-  //linear fit model in y and z per sector
-  static TLinearFitter fy1(2,"hyp1");
-  static TLinearFitter fz1(2,"hyp1");
-  //quadratic fit model in y and z per sector
-  static TLinearFitter fy2(3,"hyp2");
-  static TLinearFitter fz2(3,"hyp2");
-  static TVectorD vecy2,vecz2,vecy1,vecz1;
-
-  const Int_t kMinClusters=20;
-  Int_t nclusters[72];
-  //
-  for (Int_t i=0;i<72;++i) nclusters[i]=0;
-
-  for (Int_t i=0;i<160;++i) {
-    AliTPCclusterMI *c=track->GetClusterPointer(i);
-    if (c) nclusters[c->GetDetector()]++;
-  }
-
-  for (Int_t isec=0; isec<72;isec++){
-    if (nclusters[isec]<kMinClusters) continue;
-    fy2.ClearPoints();
-    fz2.ClearPoints();
-    fy1.ClearPoints();
-    fz1.ClearPoints();
-    //
-    for (Int_t irow=0;irow<160;++irow) {
-      AliTPCclusterMI *c=track->GetClusterPointer(irow);
-      //if (c && RejectCluster(c)) continue;
-      Double_t xd = c->GetX()-133.4; // reference x is beteen iroc and oroc
-      if (c&&c->GetDetector()==isec) {
-       Double_t x[2]={xd,xd*xd};
-       fy2.AddPoint(x,c->GetY());
-       fz2.AddPoint(x,c->GetZ());
+      //
+      //
+      // Fill laser fit histograms
+      //
+      Float_t dedx = track->GetdEdx();
+      if (nclI>20&&nclO>20){
+       fHisNclIn->Fill(id,nclI);      //->Number of clusters inner
+       fHisNclOut->Fill(id,nclO);     //->Number of clusters outer
+       fHisNclIO->Fill(id,nclI+nclO);      //->Number of cluster inner outer
+       //
+       fHisLclIn->Fill(id,xinMax-xinMin);        //->Level arm inner
+       fHisLclOut->Fill(id,xoutMax-xoutMin);     //->Level arm outer
+       fHisLclIO->Fill(id,xoutMax-xinMin);       //->Number of cluster inner outer
+       //
+       fHisdEdx->Fill(id,TMath::Sqrt(TMath::Abs(dedx)));
+       fHisdZfit->Fill(id,fFitZ[id]);
+       // 
+       //
+       fHisChi2YIn1->Fill(id,TMath::Sqrt(chi2I1y));      //->chi2 y inner - line
+       fHisChi2YOut1->Fill(id,TMath::Sqrt(chi2O1y));     //->chi2 y inner - line
+       fHisChi2YIn2->Fill(id,TMath::Sqrt(chi2I2y));      //->chi2 y inner - parabola
+       fHisChi2YOut2->Fill(id,TMath::Sqrt(chi2O2y));     //->chi2 y inner - parabola
+       fHisChi2YIO1->Fill(id,TMath::Sqrt(chi2IOy));      //->chi2 y IO    - common
+       
+       
+       fHisChi2ZIn1->Fill(id,TMath::Sqrt(chi2I1z));      //->chi2 z inner - line
+       fHisChi2ZOut1->Fill(id,TMath::Sqrt(chi2O1z));     //->chi2 z inner - line
+       fHisChi2ZIn2->Fill(id,TMath::Sqrt(chi2O2y));      //->chi2 z inner - parabola
+       fHisChi2ZOut2->Fill(id,TMath::Sqrt(chi2O2z));     //->chi2 z inner - parabola
+       fHisChi2ZIO1->Fill(id,TMath::Sqrt(chi2IOz));      //->chi2 z IO    - common
+       //
+       //
+       fHisPy1vP0->Fill(id,vecy1resOuter[0]-vecy1resInner[0]);     //-> delta y   P0outer-P0inner - line
+       fHisPy2vP0->Fill(id,vecy2resOuter[0]-vecy2resInner[0]);     //-> delta y   P0outer-P0inner - parabola
+       fHisPy3vP0->Fill(id,vecy4res[1]);                           //-> delta y   P0outer-P0inner - common parabola
+       //
+       fHisPy1vP1->Fill(id,vecy1resOuter[1]-vecy1resInner[1]);     //-> delta ky  P1outer-P1inner - line
+       fHisPy2vP1->Fill(id,vecy2resOuter[1]-vecy2resInner[1]);     //-> delta ky  P1outer-P1inner - parabola
+       fHisPy3vP1->Fill(id,vecy4res[3]-vecy4res[2]);               //-> delta ky  P1outer-P1inner - common parabola
+       //
+       fHisPy3vP2IO->Fill(id,vecy4res[4]);        //-> Curv  P2outerinner - common parabola
+       fHisPz1vP0->Fill(id,vecz1resOuter[0]-vecz1resInner[0]);     //-> delta z   P0outer-P0inner - line
+       fHisPz2vP0->Fill(id,vecz2resOuter[0]-vecz2resInner[0]);     //-> delta z   P0outer-P0inner - parabola
+       fHisPz3vP0->Fill(id,vecz4res[1]);                           //-> delta z   P0outer-P0inner - common parabola
        //
-       fy1.AddPoint(x,c->GetY());
-       fz1.AddPoint(x,c->GetZ());
+       fHisPz1vP1->Fill(id,vecz1resOuter[1]-vecz1resInner[1]);     //-> delta kz  P1outer-P1inner - line
+       fHisPz2vP1->Fill(id,vecz2resOuter[1]-vecz2resInner[1]);     //-> delta kz  P1outer-P1inner - parabola
+       fHisPz3vP1->Fill(id,vecz4res[3]-vecz4res[2]);               //-> delta kz  P1outer-P1inner - common parabola
+       fHisPz3vP2IO->Fill(id,vecz4res[4]);        //-> Curv  P2outerinner - common parabola
       }
-    }
-    fy2.Eval();
-    fz2.Eval();
-    fy1.Eval();
-    fz1.Eval();
-    fy1.GetParameters(vecy1);
-    fy2.GetParameters(vecy2);
-    fz1.GetParameters(vecz1);
-    fz2.GetParameters(vecz2);
-
-    if (fStreamLevel>0){
-      TTreeSRedirector *cstream = GetDebugStreamer();
-      if (cstream){
-       Float_t dedx = track->GetdEdx();
-       (*cstream)<<"Tracklet"<<
-         "LTr.="<<ltrp<<
-         "Tr.="<<param<<
-         "sec="<<isec<<
-         "ncl="<<nclusters[isec]<<
-         "dedx="<<dedx<<
-         "dedx="<<dedx<<
-         "vy1.="<<&vecy1<<
-         "vy2.="<<&vecy2<<
-         "vz1.="<<&vecz1<<
-         "vz2.="<<&vecz2<<
-         "\n";
+      if(nclI>20){
+       fHisPy2vP2In->Fill(id,vecy2resInner[2]);   //-> Curv  P2inner - parabola
+       fHisPz2vP2In->Fill(id,vecz2resInner[2]);   //-> Curv  P2inner - parabola
       }
-    }
+      //
+      if (nclO>20){
+       fHisPz2vP2Out->Fill(id,vecz2resOuter[2]);  //-> Curv  P2outer - parabola
+       fHisPy2vP2Out->Fill(id,vecy2resOuter[2]);  //-> Curv  P2outer - parabola
+      }
+      
   }
-  //
-  //
-  //
-  //   for (Int_t irow=0;irow<160;++irow) {
-  //       AliTPCclusterMI *c=track->GetClusterPointer(irow);
-  //       if (c && RejectCluster(c)) continue;
-  //       if (c&&c->GetDetector()==isec) {
-  //   Double_t x[2]={c->GetX(),c->GetX()*c->GetX()};
-  //   fy2.AddPoint(&x,c->GetY());
-  //   fz2.AddPoint(&x,c->GetZ());
-  //   //
-  //   fy1.AddPoint(&x,c->GetY());
-  //   fz1.AddPoint(&x,c->GetZ());
-  //       }
-  //     }
-
 }
 
 
+
 void AliTPCcalibLaser::DumpMeanInfo(Float_t bfield, Int_t run, Int_t minEntries){
   //
   //  Dump information about laser beams
@@ -1135,9 +1614,9 @@ void AliTPCcalibLaser::DumpMeanInfo(Float_t bfield, Int_t run, Int_t minEntries)
     TH1F * hisP3    = (TH1F*)laser->fDeltaP3.At(id);
     TH1F * hisP4    = (TH1F*)laser->fDeltaP4.At(id);
     TH1F * hisS    = (TH1F*)laser->fSignals.At(id);
-    if (!hisphi) continue;;
-    Double_t entries = hisphi->GetEntries();
-    if (entries<minEntries) continue;
+    //if (!hisphi) continue;
+    Double_t entries = (hisphi==0)? 0: hisphi->GetEntries();
+    //if (entries<minEntries) continue;
     //
     AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
     if (!ltrp) {
@@ -1189,18 +1668,281 @@ void AliTPCcalibLaser::DumpMeanInfo(Float_t bfield, Int_t run, Int_t minEntries)
     if (rmsphi>krmsCut0) if (gphi2/rmsphi>kmultiCut) isOK=kFALSE;   // multi peak structure
     if (gphiP2>kcutP0) isOK=kFALSE;
     //
-    if (run<=0) run=fRun;
+    //
+    //
+    TH1 *his =0;
+    //
+    his = fHisNclIn->ProjectionY("aaa",id+1,id+1);
+    Float_t mnclIn =  his->GetMean();
+    delete his;
+    his = fHisNclOut->ProjectionY("aaa",id+1,id+1);
+    Float_t mnclOut =  his->GetMean();
+    delete his;
+    his = fHisNclIO->ProjectionY("aaa",id+1,id+1);
+    Float_t mnclIO =  his->GetMean();
+    delete his;
+    his = fHisLclIn->ProjectionY("aaa",id+1,id+1);
+    Float_t mLclIn =  his->GetMean();
+    delete his;
+    his = fHisLclOut->ProjectionY("aaa",id+1,id+1);
+    Float_t mLclOut =  his->GetMean();
+    delete his;
+    his = fHisLclIO->ProjectionY("aaa",id+1,id+1);
+    Float_t mLclIO =  his->GetMean();
+    delete his;
+    //
+    his = fHisdEdx->ProjectionY("aaa",id+1,id+1);
+    Float_t mdEdx =  his->GetMean();
+    delete his;
+    //
+    //
+    //
+    //
+    his = fHisChi2YIn1->ProjectionY("aaa",id+1,id+1);      //->chi2 y inner - line
+    Float_t  mChi2YIn1=  his->GetMean();
+    delete his;
+    his = fHisChi2YOut1->ProjectionY("aaa",id+1,id+1);     //->chi2 y inner - line
+    Float_t mChi2YOut1 =  his->GetMean();
+    delete his;
+    his = fHisChi2YIn2->ProjectionY("aaa",id+1,id+1);      //->chi2 y inner - parabola
+    Float_t mChi2YIn2 =  his->GetMean();
+    delete his;
+    his = fHisChi2YOut2->ProjectionY("aaa",id+1,id+1);     //->chi2 y inner - parabola
+    Float_t mChi2YOut2 =  his->GetMean();
+    delete his;
+    his = fHisChi2YIO1->ProjectionY("aaa",id+1,id+1);      //->chi2 y IO    - common
+    Float_t mChi2YIO1 =  his->GetMean();
+    delete his;
+    his = fHisChi2ZIn1->ProjectionY("aaa",id+1,id+1);      //->chi2 z inner - line
+    Float_t mChi2ZIn1 =  his->GetMean();
+    delete his;
+    his = fHisChi2ZOut1->ProjectionY("aaa",id+1,id+1);     //->chi2 z inner - line
+    Float_t mChi2ZOut1 =  his->GetMean();
+    delete his;
+    his = fHisChi2ZIn2->ProjectionY("aaa",id+1,id+1);      //->chi2 z inner - parabola
+    Float_t mChi2ZIn2 =  his->GetMean();
+    delete his;
+    his = fHisChi2ZOut2->ProjectionY("aaa",id+1,id+1);     //->chi2 z inner - parabola
+    Float_t mChi2ZOut2 =  his->GetMean();
+    delete his;
+    his = fHisChi2ZIO1->ProjectionY("aaa",id+1,id+1);      //->chi2 z IO    - common
+    Float_t mChi2ZIO1 =  his->GetMean();
+    delete his;
+    //
+    // fit res. histos
+    // 
+    his = fHisdZfit->ProjectionY("aaa",id+1,id+1);
+    Float_t  edZfit  = his->GetEntries();
+    Float_t  mdZfit =  his->GetMean();
+    Float_t  rdZfit  = his->GetRMS();
+    delete his;
+
+    his = fHisPy1vP0->ProjectionY("aaa",id+1,id+1);     //-> delta y   P0outer-P0inner - line
+    Float_t  ePy1vP0  = his->GetEntries();
+    Float_t  mPy1vP0  = his->GetMean();
+    Float_t  rPy1vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy2vP0->ProjectionY("aaa",id+1,id+1);     //-> delta y   P0outer-P0inner - parabola
+    Float_t  ePy2vP0  = his->GetEntries();
+    Float_t  mPy2vP0  = his->GetMean();
+    Float_t  rPy2vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy3vP0->ProjectionY("aaa",id+1,id+1);     //-> delta y   P0outer-P0inner - common parabola
+    Float_t  ePy3vP0  = his->GetEntries();
+    Float_t  mPy3vP0  = his->GetMean();
+    Float_t  rPy3vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy1vP1->ProjectionY("aaa",id+1,id+1);     //-> delta ky  P1outer-P1inner - line
+    Float_t  ePy1vP1  = his->GetEntries();
+    Float_t  mPy1vP1  = his->GetMean();
+    Float_t  rPy1vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy2vP1->ProjectionY("aaa",id+1,id+1);     //-> delta ky  P1outer-P1inner - parabola
+    Float_t  ePy2vP1  = his->GetEntries();
+    Float_t  mPy2vP1  = his->GetMean();
+    Float_t  rPy2vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy3vP1->ProjectionY("aaa",id+1,id+1);     //-> delta ky  P1outer-P1inner - common parabola
+    Float_t  ePy3vP1  = his->GetEntries();
+    Float_t  mPy3vP1  = his->GetMean();
+    Float_t  rPy3vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy2vP2In->ProjectionY("aaa",id+1,id+1);   //-> Curv  P2inner - parabola
+    Float_t  ePy2vP2In  = his->GetEntries();
+    Float_t  mPy2vP2In  = his->GetMean();
+    Float_t  rPy2vP2In  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy2vP2Out->ProjectionY("aaa",id+1,id+1);  //-> Curv  P2outer - parabola
+    Float_t  ePy2vP2Out  = his->GetEntries();
+    Float_t  mPy2vP2Out  = his->GetMean();
+    Float_t  rPy2vP2Out  = his->GetRMS();
+    delete his;
+    
+    his = fHisPy3vP2IO->ProjectionY("aaa",id+1,id+1);   //-> Curv  P2outerinner - common parabola
+    Float_t  ePy3vP2IO  = his->GetEntries();
+    Float_t  mPy3vP2IO  = his->GetMean();
+    Float_t  rPy3vP2IO  = his->GetRMS();
+    delete his;
+    
+    //
+    //
+    his = fHisPz1vP0->ProjectionY("aaa",id+1,id+1);     //-> delta z   P0outer-P0inner - line
+    Float_t  ePz1vP0  = his->GetEntries();
+    Float_t  mPz1vP0  = his->GetMean();
+    Float_t  rPz1vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz2vP0->ProjectionY("aaa",id+1,id+1);     //-> delta z   P0outer-P0inner - parabola
+    Float_t  ePz2vP0  = his->GetEntries();
+    Float_t  mPz2vP0  = his->GetMean();
+    Float_t  rPz2vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz3vP0->ProjectionY("aaa",id+1,id+1);     //-> delta z   P0outer-P0inner - common parabola
+    Float_t  ePz3vP0  = his->GetEntries();
+    Float_t  mPz3vP0  = his->GetMean();
+    Float_t  rPz3vP0  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz1vP1->ProjectionY("aaa",id+1,id+1);     //-> delta kz  P1outer-P1inner - line
+    Float_t  ePz1vP1  = his->GetEntries();
+    Float_t  mPz1vP1  = his->GetMean();
+    Float_t  rPz1vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz2vP1->ProjectionY("aaa",id+1,id+1);     //-> delta kz  P1outer-P1inner - parabola
+    Float_t  ePz2vP1  = his->GetEntries();
+    Float_t  mPz2vP1  = his->GetMean();
+    Float_t  rPz2vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz3vP1->ProjectionY("aaa",id+1,id+1);     //-> delta kz  P1outer-P1inner - common parabola
+    Float_t  ePz3vP1  = his->GetEntries();
+    Float_t  mPz3vP1  = his->GetMean();
+    Float_t  rPz3vP1  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz2vP2In->ProjectionY("aaa",id+1,id+1);   //-> Curv  P2inner - parabola
+    Float_t  ePz2vP2In  = his->GetEntries();
+    Float_t  mPz2vP2In  = his->GetMean();
+    Float_t  rPz2vP2In  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz2vP2Out->ProjectionY("aaa",id+1,id+1);  //-> Curv  P2outer - parabola
+    Float_t  ePz2vP2Out  = his->GetEntries();
+    Float_t  mPz2vP2Out  = his->GetMean();
+    Float_t  rPz2vP2Out  = his->GetRMS();
+    delete his;
+    
+    his = fHisPz3vP2IO->ProjectionY("aaa",id+1,id+1);   //-> Curv  P2outerinner - common parabola
+    Float_t  ePz3vP2IO  = his->GetEntries();
+    Float_t  mPz3vP2IO  = his->GetMean();
+    Float_t  rPz3vP2IO  = his->GetRMS();
+    delete his;
+    
+    //
     (*pcstream)<<"Mean"<<
-      "run="<<run<<              //
-      "isOK="<<isOK<<
-      "entries="<<entries<<      // number of entries
-      "bz="<<bfield<<            // bfield
+      "run="<<run<<               //
+      "isOK="<<isOK<<             //
+      "id="<<id<<                 // track id
+      "entries="<<entries<<       // number of entries
+      "bz="<<bfield<<             // bfield
       "LTr.="<<ltrp<<             // refernece track
       //
-      "lx0="<<lxyz[0]<<          // reference x
-      "lx1="<<lxyz[1]<<          // reference y
-      "lx2="<<lxyz[2]<<          // refernece z
-      "lpx0="<<lpxyz[0]<<          // reference x
+      "mnclIn="<<mnclIn<<         // mean number of clusters in inner
+      "mnclOut="<<mnclOut<<       // mean number of clusters in outer
+      "mnclIO="<<mnclIO<<         // mean number of clusters in inner+outer
+      "mLclIn="<<mLclIn<<         // mean number of clusters in inner
+      "mLclOut="<<mLclOut<<       // mean number of clusters in outer
+      "mLclIO="<<mLclIO<<         // mean number of clusters in inner+outer
+      "mdEdx="<<mdEdx<<           // mean dEdx
+      "edZfit="<<edZfit<<           // entries z fit
+      "mdZfit="<<mdZfit<<           // mean z fit
+      "rdZfit="<<rdZfit<<           // RMS z fit
+      //
+      //
+      "mChi2YIn1="<<mChi2YIn1<<       //->chi2 y inner - line
+      "mChi2YOut1="<<mChi2YOut1<<     //->chi2 y inner - line
+      "mChi2YIn2="<<mChi2YIn2<<       //->chi2 y inner - parabola
+      "mChi2YOut2="<<mChi2YOut2<<     //->chi2 y inner - parabola
+      "mChi2YIO1="<<mChi2YIO1<<       //->chi2 y IO    - common
+      "mChi2ZIn1="<<mChi2ZIn1<<       //->chi2 z inner - line
+      "mChi2ZOut1="<<mChi2ZOut1<<     //->chi2 z inner - line
+      "mChi2ZIn2="<<mChi2ZIn2<<       //->chi2 z inner - parabola
+      "mChi2ZOut2="<<mChi2ZOut2<<     //->chi2 z inner - parabola
+      "mChi2ZIO1="<<mChi2ZIO1<<       //->chi2 z IO    - common
+      //
+      //
+      "ePy1vP0="<<ePy1vP0<<
+      "mPy1vP0="<<mPy1vP0<<
+      "rPy1vP0="<<rPy1vP0<<
+      "ePy2vP0="<<ePy2vP0<<
+      "mPy2vP0="<<mPy2vP0<<
+      "rPy2vP0="<<rPy2vP0<<      
+      "ePy3vP0="<<ePy3vP0<<
+      "mPy3vP0="<<mPy3vP0<<
+      "rPy3vP0="<<rPy3vP0<<
+      "ePy1vP1="<<ePy1vP1<<
+      "mPy1vP1="<<mPy1vP1<<
+      "rPy1vP1="<<rPy1vP1<<
+      "ePy2vP1="<<ePy2vP1<<
+      "mPy2vP1="<<mPy2vP1<<
+      "rPy2vP1="<<rPy2vP1<<
+      "ePy3vP1="<<ePy3vP1<<
+      "mPy3vP1="<<mPy3vP1<<
+      "rPy3vP1="<<rPy3vP1<<
+      "ePy2vP2In="<<ePy2vP2In<<
+      "mPy2vP2In="<<mPy2vP2In<<
+      "rPy2vP2In="<<rPy2vP2In<<
+      "ePy2vP2Out="<<ePy2vP2Out<<
+      "mPy2vP2Out="<<mPy2vP2Out<<
+      "rPy2vP2Out="<<rPy2vP2Out<<
+      "ePy3vP2IO="<<ePy3vP2IO<<
+      "mPy3vP2IO="<<mPy3vP2IO<<
+      "rPy3vP2IO="<<rPy3vP2IO<<
+      //
+      //
+      "ePz1vP0="<<ePz1vP0<<
+      "mPz1vP0="<<mPz1vP0<<
+      "rPz1vP0="<<rPz1vP0<<
+      "ePz2vP0="<<ePz2vP0<<
+      "mPz2vP0="<<mPz2vP0<<
+      "rPz2vP0="<<rPz2vP0<<
+      "ePz3vP0="<<ePz3vP0<<
+      "mPz3vP0="<<mPz3vP0<<
+      "rPz3vP0="<<rPz3vP0<<
+      "ePz1vP1="<<ePz1vP1<<
+      "mPz1vP1="<<mPz1vP1<<
+      "rPz1vP1="<<rPz1vP1<<
+      "ePz2vP1="<<ePz2vP1<<
+      "mPz2vP1="<<mPz2vP1<<
+      "rPz2vP1="<<rPz2vP1<<
+      "ePz3vP1="<<ePz3vP1<<
+      "mPz3vP1="<<mPz3vP1<<
+      "rPz3vP1="<<rPz3vP1<<
+      "ePz2vP2In="<<ePz2vP2In<<
+      "mPz2vP2In="<<mPz2vP2In<<
+      "rPz2vP2In="<<rPz2vP2In<<
+      "ePz2vP2Out="<<ePz2vP2Out<<
+      "mPz2vP2Out="<<mPz2vP2Out<<
+      "rPz2vP2Out="<<rPz2vP2Out<<
+      "ePz3vP2IO="<<ePz3vP2IO<<  
+      "mPz3vP2IO="<<mPz3vP2IO<<
+      "rPz3vP2IO="<<rPz3vP2IO<<     
+      //
+      //
+      //
+      "lx0="<<lxyz[0]<<            // reference x
+      "lx1="<<lxyz[1]<<            // reference y
+      "lx2="<<lxyz[2]<<            // refernece z
+      "lpx0="<<lpxyz[0]<<           // reference x
       "lpx1="<<lpxyz[1]<<          // reference y
       "lpx2="<<lpxyz[2]<<          // refernece z
       //
@@ -1229,6 +1971,14 @@ void AliTPCcalibLaser::DumpMeanInfo(Float_t bfield, Int_t run, Int_t minEntries)
       "\n";
   }
   delete pcstream;
+  /*
+    Browse the content
+    TFile fmean("laserMean.root");
+    
+
+   */
+
+
 }
 
 
@@ -1399,25 +2149,22 @@ Long64_t AliTPCcalibLaser::Merge(TCollection *li) {
 
   TIterator* iter = li->MakeIterator();
   AliTPCcalibLaser* cal = 0;
-
+  static Int_t counter0=0;
   while ((cal = (AliTPCcalibLaser*)iter->Next())) {
     if (!cal->InheritsFrom(AliTPCcalibLaser::Class())) {
       Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
       return -1;
     }
+    printf("Marging number %d\n", counter0);
+    counter0++;
     //
-   //  fHistNTracks->Add(cal->fHistNTracks);
-//     fClusters->Add(cal->fClusters);
-//     fModules->Add(cal->fModules);
-//     fHistPt->Add(cal->fHistPt);
-//     fPtResolution->Add(cal->fPtResolution);
-//     fDeDx->Add(cal->fDeDx);
-
-
+    MergeFitHistos(cal);
     TH1F *h=0x0;
     TH1F *hm=0x0;
-    TProfile *hp=0x0;
-    TProfile *hpm=0x0;
+    TH2F *h2=0x0;
+    TH2F *h2m=0x0;
+    //    TProfile *hp=0x0;
+    //TProfile *hpm=0x0;
 
     for (Int_t id=0; id<336; id++){
       // merge fDeltaZ histograms
@@ -1478,96 +2225,303 @@ Long64_t AliTPCcalibLaser::Merge(TCollection *li) {
       if (hm) h->Add(hm);
       //
       //
-      // merge ProfileY histograms
-      hpm = (TProfile*)cal->fDeltaYres.At(id);
-      hp  = (TProfile*)fDeltaYres.At(id);
-      if (!hp) {
-       hp=new TProfile(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d",id),115,80,250);
-       hp->SetDirectory(0);
-       fDeltaYres.AddAt(hp,id);
-      }
-      if (hpm) hp->Add(hpm);
+      // merge ProfileY histograms -0
+      h2m = (TH2F*)cal->fDeltaYres.At(id);
+      h2  = (TH2F*)fDeltaYres.At(id);
+      if (h2m) h2->Add(h2m);
       //
-      hpm = (TProfile*)cal->fDeltaZres.At(id);
-      hp  = (TProfile*)fDeltaZres.At(id);
-      if (!hp) {
-       hp=new TProfile(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d",id),115,80,250);
-       hp->SetDirectory(0);
-       fDeltaZres.AddAt(hp,id);
-      }
-      if (hpm) hp->Add(hpm);
+      h2m = (TH2F*)cal->fDeltaZres.At(id);
+      h2  = (TH2F*)fDeltaZres.At(id);
+      if (h2m) h->Add(h2m);
+      // merge ProfileY histograms - 2
+      h2m = (TH2F*)cal->fDeltaYres2.At(id);
+      h2  = (TH2F*)fDeltaYres2.At(id);
+      if (h2m) h2->Add(h2m);
+      //
+      h2m = (TH2F*)cal->fDeltaZres2.At(id);
+      h2  = (TH2F*)fDeltaZres2.At(id);
+      if (h2m) h->Add(h2m);
+      // merge ProfileY histograms - 3
+      //h2m = (TH2F*)cal->fDeltaYres3.At(id);
+      //h2  = (TH2F*)fDeltaYres3.At(id);
+      //if (h2m) h2->Add(h2m);
+      //
+      //h2m = (TH2F*)cal->fDeltaZres3.At(id);
+      //h2  = (TH2F*)fDeltaZres3.At(id);
+      //if (h2m) h->Add(h2m);
       //
       //
-      //merge fit param histograms
-      //local hists
-      TH1F *pol2InnerY =(TH1F*)fPol2Par2InY.UncheckedAt(id);
-      TH1F *diff1InnerY=(TH1F*)fDiffPar1InY.UncheckedAt(id);
-      TH1F *pol2OuterY =(TH1F*)fPol2Par2OutY.UncheckedAt(id);
-      TH1F *diff1OuterY=(TH1F*)fDiffPar1OutY.UncheckedAt(id);
-      TH1F *pol2InnerZ =(TH1F*)fPol2Par2InZ.UncheckedAt(id);
-      TH1F *diff1InnerZ=(TH1F*)fDiffPar1InZ.UncheckedAt(id);
-      TH1F *pol2OuterZ =(TH1F*)fPol2Par2OutZ.UncheckedAt(id);
-      TH1F *diff1OuterZ=(TH1F*)fDiffPar1OutZ.UncheckedAt(id);
-      //hists to merge
-      TH1F *pol2InnerYm =(TH1F*)cal->fPol2Par2InY.UncheckedAt(id);
-      TH1F *diff1InnerYm=(TH1F*)cal->fDiffPar1InY.UncheckedAt(id);
-      TH1F *pol2OuterYm =(TH1F*)cal->fPol2Par2OutY.UncheckedAt(id);
-      TH1F *diff1OuterYm=(TH1F*)cal->fDiffPar1OutY.UncheckedAt(id);
-      TH1F *pol2InnerZm =(TH1F*)cal->fPol2Par2InZ.UncheckedAt(id);
-      TH1F *diff1InnerZm=(TH1F*)cal->fDiffPar1InZ.UncheckedAt(id);
-      TH1F *pol2OuterZm =(TH1F*)cal->fPol2Par2OutZ.UncheckedAt(id);
-      TH1F *diff1OuterZm=(TH1F*)cal->fDiffPar1OutZ.UncheckedAt(id);
-      //create histos if they do not exist
-      if (!pol2InnerY){
-          pol2InnerY =new TH1F(Form("pol2par2inY%03d",id),
-                              Form("2nd derivative from pol2 fit in Y for Laser beam %03d (inner sector)",id),
-                              500,-.005,.005);
-         pol2InnerY->SetDirectory(0);
-
-         pol2OuterY =new TH1F(Form("pol2par2outY%03d",id),
-                              Form("2nd derivative from pol2 fit in Y for Laser beam %03d (outer sector)",id),
-                              500,0.01,.01);
-         pol2OuterY->SetDirectory(0);
-         diff1InnerY=new TH1F(Form("diff1inY%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Y fit for Laser beam %03d (inner sector)",id),
-                              500,-.5,.5);
-         diff1OuterY=new TH1F(Form("diff1outY%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Yfit for Laser beam %03d (outer sector)",id),
-                              500,-1,1);
-         diff1InnerY->SetDirectory(0);
-
-
-         pol2InnerZ =new TH1F(Form("pol2par2inZ%03d",id),
-                              Form("2nd derivative from pol2 fit in Z for Laser beam %03d (inner sector)",id),
-                              500,-.002,.002);
-         pol2InnerZ->SetDirectory(0);
-
-         pol2OuterZ =new TH1F(Form("pol2par2outZ%03d",id),
-                              Form("2nd derivative from pol2 fit in Z for Laser beam %03d (outer sector)",id),
-                              500,-.005,.005);
-         pol2OuterZ->SetDirectory(0);
-         diff1InnerZ=new TH1F(Form("diff1inZ%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Z fit for Laser beam %03d (inner sector)",id),
-                              500,-.02,.02);
-         diff1InnerZ->SetDirectory(0);
-         diff1OuterZ=new TH1F(Form("diff1outZ%03d",id),
-                              Form("diff of 1st derivative from pol1 and pol2 in Zfit for Laser beam %03d (outer sector)",id),
-                              500,-.03,.03);
-         diff1OuterZ->SetDirectory(0);
-      }
-      pol2InnerYm =(TH1F*)cal->fPol2Par2InY.UncheckedAt(id);
-      diff1InnerYm=(TH1F*)cal->fDiffPar1InY.UncheckedAt(id);
-      pol2OuterYm =(TH1F*)cal->fPol2Par2OutY.UncheckedAt(id);
-      diff1OuterYm=(TH1F*)cal->fDiffPar1OutY.UncheckedAt(id);
-      pol2InnerZm =(TH1F*)cal->fPol2Par2InZ.UncheckedAt(id);
-      diff1InnerZm=(TH1F*)cal->fDiffPar1InZ.UncheckedAt(id);
-      pol2OuterZm =(TH1F*)cal->fPol2Par2OutZ.UncheckedAt(id);
-      diff1OuterZm=(TH1F*)cal->fDiffPar1OutZ.UncheckedAt(id);
     }
   }
   return 0;
 }
 
+void   AliTPCcalibLaser::MakeFitHistos(){
+  //
+  // Make a fit histograms
+  // 
+  // Number of clusters
+  //
+  //TH2F           *fHisNclIn;      //->Number of clusters inner
+  //TH2F           *fHisNclOut;     //->Number of clusters outer
+  //TH2F           *fHisNclIO;      //->Number of cluster inner outer
+  // TH2F           *fHisdEdx;       //->dEdx histo
+  fHisNclIn = new TH2F("HisNclIn","HisNclIn",336,0,336,64,10,64);
+  fHisNclOut = new TH2F("HisNclOut","HisNclOut",336,0,336,100,10,100);
+  fHisNclIO = new TH2F("HisNclIO","HisNclIO",336,0,336,160,10,160);
+  //
+  fHisLclIn  = new TH2F("HisLclIn","HisLclIn",336,0,336,64,10,64);
+  fHisLclOut = new TH2F("HisLclOut","HisLclOut",336,0,336,100,10,150);
+  fHisLclIO  = new TH2F("HisLclIO","HisLclIO",336,0,336,160,10,160);
+  //
+  fHisdEdx = new TH2F("HisdEdx","HisdEdx",336,0,336,160,1,50);
+  fHisdZfit = new TH2F("HisdZfit","HisdZfit",336,0,336,300,-0.3,0.3);
+  
+  //
+  //  Chi2
+  //
+  //   TH2F           *fHisChi2YIn1;      //->chi2 y inner - line
+  //   TH2F           *fHisChi2YOut1;     //->chi2 y inner - line
+  //   TH2F           *fHisChi2YIn2;      //->chi2 y inner - parabola
+  //   TH2F           *fHisChi2YOut2;     //->chi2 y inner - parabola
+  //   TH2F           *fHisChi2YIO1;      //->chi2 y IO    - common
+  fHisChi2YIn1   = new TH2F("Chi2YIn1","Chi2YIn1",336,0,336,500,0.001,0.5);
+  fHisChi2YOut1  = new TH2F("Chi2YOut1","Chi2YOut1",336,0,336,500,0.001,0.5);
+  fHisChi2YIn2   = new TH2F("Chi2YIn2","Chi2YIn2",336,0,336,500,0.001,0.5);
+  fHisChi2YOut2  = new TH2F("Chi2YOut2","Chi2YOut2",336,0,336,500,0.001,0.5);
+  fHisChi2YIO1   = new TH2F("Chi2YIO1","Chi2YIO1",336,0,336,500,0.001,0.5);
+  //   TH2F           *fHisChi2ZIn1;      //->chi2 z inner - line
+  //   TH2F           *fHisChi2ZOut1;     //->chi2 z inner - line
+  //   TH2F           *fHisChi2ZIn2;      //->chi2 z inner - parabola
+  //   TH2F           *fHisChi2ZOut2;     //->chi2 z inner - parabola
+  //   TH2F           *fHisChi2ZIO1;      //->chi2 z IO    - common
+  fHisChi2ZIn1   = new TH2F("Chi2ZIn1","Chi2ZIn1",336,0,336,500,0.001,0.5);
+  fHisChi2ZOut1  = new TH2F("Chi2ZOut1","Chi2ZOut1",336,0,336,500,0.001,0.5);
+  fHisChi2ZIn2   = new TH2F("Chi2ZIn2","Chi2ZIn2",336,0,336,500,0.001,0.5);
+  fHisChi2ZOut2  = new TH2F("Chi2ZOut2","Chi2ZOut2",336,0,336,500,0.001,0.5);
+  fHisChi2ZIO1   = new TH2F("Chi2ZIO1","Chi2ZIO1",336,0,336,500,0.001,0.5);
+  //
+  // Fit
+  //
+  //
+  //   TH2F           *fHisPy1vP0;     //-> delta y   P0outer-P0inner - line
+  //   TH2F           *fHisPy2vP0;     //-> delta y   P0outer-P0inner - parabola
+  //   TH2F           *fHisPy3vP0;     //-> delta y   P0outer-P0inner - common parabola
+  //   TH2F           *fHisPy1vP1;     //-> delta ky  P1outer-P1inner - line
+  //   TH2F           *fHisPy2vP1;     //-> delta ky  P1outer-P1inner - parabola
+  //   TH2F           *fHisPy3vP1;     //-> delta ky  P1outer-P1inner - common parabola
+  //   TH2F           *fHisPy2vP2In;   //-> Curv  P2inner - parabola
+  //   TH2F           *fHisPy2vP2Out;  //-> Curv  P2outer - parabola
+  //   TH2F           *fHisPy3vP2IO;   //-> Curv  P2outerinner - common parabola
+  fHisPy1vP0   = new TH2F("HisPy1vP0",   "HisPy1vP0",336,0,336,500,-0.3,0.3);
+  fHisPy2vP0   = new TH2F("HisPy2vP0",   "HisPy2vP0",336,0,336,500,-0.3,0.3);
+  fHisPy3vP0   = new TH2F("HisPy3vP0",   "HisPy3vP0",336,0,336,500,-0.3,0.3);
+  fHisPy1vP1   = new TH2F("HisPy1vP1",   "HisPy1vP1",336,0,336,500,-0.01,0.01);
+  fHisPy2vP1   = new TH2F("HisPy2vP1",   "HisPy2vP1",336,0,336,500,-0.01,0.01);
+  fHisPy3vP1   = new TH2F("HisPy3vP1",   "HisPy3vP1",336,0,336,500,-0.01,0.01);
+  fHisPy2vP2In = new TH2F("HisPy2vP2In", "HisPy2vP2In",336,0,336,500,-0.0003,0.0003);
+  fHisPy2vP2Out= new TH2F("HisPy2vP2Out","HisPy2vP2Out",336,0,336,500,-0.0003,0.0003);
+  fHisPy3vP2IO = new TH2F("HisPy3vP2IO", "HisPy3vP2IO",336,0,336,500,-0.0003,0.0003);
+  //
+  //
+  //   TH2F           *fHisPz1vP0;     //-> delta z   P0outer-P0inner - line
+  //   TH2F           *fHisPz2vP0;     //-> delta z   P0outer-P0inner - parabola
+  //   TH2F           *fHisPz3vP0;     //-> delta z   P0outer-P0inner - common parabola
+  //   TH2F           *fHisPz1vP1;     //-> delta kz  P1outer-P1inner - line
+  //   TH2F           *fHisPz2vP1;     //-> delta kz  P1outer-P1inner - parabola
+  //   TH2F           *fHisPz3vP1;     //-> delta kz  P1outer-P1inner - common parabola
+  //   TH2F           *fHisPz2vP2In;   //-> Curv  P2inner - parabola
+  //   TH2F           *fHisPz2vP2Out;  //-> Curv  P2outer - parabola
+  //   TH2F           *fHisPz3vP2IO;   //-> Curv  P2outerinner - common parabola
+  fHisPz1vP0   = new TH2F("HisPz1vP0",   "HisPz1vP0",336,0,336,500,-0.3,0.3);
+  fHisPz2vP0   = new TH2F("HisPz2vP0",   "HisPz2vP0",336,0,336,500,-0.3,0.3);
+  fHisPz3vP0   = new TH2F("HisPz3vP0",   "HisPz3vP0",336,0,336,500,-0.3,0.3);
+  fHisPz1vP1   = new TH2F("HisPz1vP1",   "HisPz1vP1",336,0,336,500,-0.01,0.01);
+  fHisPz2vP1   = new TH2F("HisPz2vP1",   "HisPz2vP1",336,0,336,500,-0.01,0.01);
+  fHisPz3vP1   = new TH2F("HisPz3vP1",   "HisPz3vP1",336,0,336,500,-0.01,0.01);
+  fHisPz2vP2In = new TH2F("HisPz2vP2In", "HisPz2vP2In",336,0,336,500,-0.0003,0.0003);
+  fHisPz2vP2Out= new TH2F("HisPz2vP2Out","HisPz2vP2Out",336,0,336,500,-0.0002,0.0002);
+  fHisPz3vP2IO = new TH2F("HisPz3vP2IO", "HisPz3vP2IO",336,0,336,500,-0.0002,0.0002);
+  
+  fHisNclIn->SetDirectory(0);      //->Number of clusters inner
+  fHisNclOut->SetDirectory(0);     //->Number of clusters outer
+  fHisNclIO->SetDirectory(0);      //->Number of cluster inner outer
+  fHisLclIn->SetDirectory(0);      //->Level arm inner
+  fHisLclOut->SetDirectory(0);     //->Level arm outer
+  fHisLclIO->SetDirectory(0);      //->Number of cluster inner outer
+  fHisdEdx->SetDirectory(0);      //->Number of cluster inner outer
+  fHisdZfit->SetDirectory(0);      //->Number of cluster inner outer
+  //
+  //
+  fHisChi2YIn1->SetDirectory(0);      //->chi2 y inner - line
+  fHisChi2YOut1->SetDirectory(0);     //->chi2 y inner - line
+  fHisChi2YIn2->SetDirectory(0);      //->chi2 y inner - parabola
+  fHisChi2YOut2->SetDirectory(0);     //->chi2 y inner - parabola
+  fHisChi2YIO1->SetDirectory(0);      //->chi2 y IO    - common
+  fHisChi2ZIn1->SetDirectory(0);      //->chi2 z inner - line
+  fHisChi2ZOut1->SetDirectory(0);     //->chi2 z inner - line
+  fHisChi2ZIn2->SetDirectory(0);      //->chi2 z inner - parabola
+  fHisChi2ZOut2->SetDirectory(0);     //->chi2 z inner - parabola
+  fHisChi2ZIO1->SetDirectory(0);      //->chi2 z IO    - common
+  //
+  //
+  fHisPy1vP0->SetDirectory(0);     //-> delta y   P0outer-P0inner - line
+  fHisPy2vP0->SetDirectory(0);     //-> delta y   P0outer-P0inner - parabola
+  fHisPy3vP0->SetDirectory(0);     //-> delta y   P0outer-P0inner - common parabola
+  fHisPy1vP1->SetDirectory(0);     //-> delta ky  P1outer-P1inner - line
+  fHisPy2vP1->SetDirectory(0);     //-> delta ky  P1outer-P1inner - parabola
+  fHisPy3vP1->SetDirectory(0);     //-> delta ky  P1outer-P1inner - common parabola
+  fHisPy2vP2In->SetDirectory(0);   //-> Curv  P2inner - parabola
+  fHisPy2vP2Out->SetDirectory(0);  //-> Curv  P2outer - parabola
+  fHisPy3vP2IO->SetDirectory(0);   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fHisPz1vP0->SetDirectory(0);     //-> delta z   P0outer-P0inner - line
+  fHisPz2vP0->SetDirectory(0);     //-> delta z   P0outer-P0inner - parabola
+  fHisPz3vP0->SetDirectory(0);     //-> delta z   P0outer-P0inner - common parabola
+  fHisPz1vP1->SetDirectory(0);     //-> delta kz  P1outer-P1inner - line
+  fHisPz2vP1->SetDirectory(0);     //-> delta kz  P1outer-P1inner - parabola
+  fHisPz3vP1->SetDirectory(0);     //-> delta kz  P1outer-P1inner - common parabola
+  fHisPz2vP2In->SetDirectory(0);   //-> Curv  P2inner - parabola
+  fHisPz2vP2Out->SetDirectory(0);  //-> Curv  P2outer - parabola
+  fHisPz3vP2IO->SetDirectory(0);   //-> Curv  P2outerinner - common parabola
+
+
+  //
+  //
+  //
+  for (Int_t id=0; id<336;id++){
+    TH2F *profy = (TH2F*)fDeltaYres.UncheckedAt(id);
+    TH2F *profz = (TH2F*)fDeltaZres.UncheckedAt(id);
+    TH2F *profy2 = (TH2F*)fDeltaYres2.UncheckedAt(id);
+    TH2F *profz2 = (TH2F*)fDeltaZres2.UncheckedAt(id);
+    //    TH2F *profy3 = (TH2F*)fDeltaYres3.UncheckedAt(id);
+    //TH2F *profz3 = (TH2F*)fDeltaZres3.UncheckedAt(id);
+    if (!profy){
+      profy=new TH2F(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d -Linear",id),160,0,160,50,-0.5,0.5);
+      profy->SetDirectory(0);
+      fDeltaYres.AddAt(profy,id);
+      profy2=new TH2F(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d -Parabolic",id),160,0,160,50,-0.5,0.5);
+      profy2->SetDirectory(0);
+      fDeltaYres2.AddAt(profy2,id);
+      //profy3=new TH2F(Form("pry%03d",id),Form("Y Residuals for Laser Beam %03d- Parabolic2",id),160,0,160,100,-0.5,0.5);
+      //profy3->SetDirectory(0);
+      //fDeltaYres3.AddAt(profy3,id);
+    }
+    if (!profz){
+      profz=new TH2F(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d Linear",id),160,0,160,50,-0.5,0.5);
+      profz->SetDirectory(0);
+      fDeltaZres.AddAt(profz,id);
+      profz2=new TH2F(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d - Parabolic",id),160,0,160,50,-0.5,0.5);
+      profz2->SetDirectory(0);
+      fDeltaZres2.AddAt(profz2,id);
+      //profz3=new TH2F(Form("prz%03d",id),Form("Z Residuals for Laser Beam %03d- Parabolic2",id),160,0,160,100,-0.5,0.5);
+      //profz3->SetDirectory(0);
+      //fDeltaZres3.AddAt(profz3,id);
+    }
+  }
+  //
+  //
+  for (Int_t id=0; id<336;id++){
+    TH1F * hisdz = (TH1F*)fDeltaZ.At(id);
+    TH1F * hisP3 = (TH1F*)fDeltaP3.At(id);
+    TH1F * hisP4 = (TH1F*)fDeltaP4.At(id);
+    
+    TH1F * hisdphi = (TH1F*)fDeltaPhi.At(id);
+    TH1F * hisdphiP = (TH1F*)fDeltaPhiP.At(id);
+    TH1F * hisSignal = (TH1F*)fSignals.At(id);
+
+    if (!hisdz){
+      hisdz = new TH1F(Form("hisdz%d",id),Form("hisdz%d",id),1000,-10,10);
+      hisdz->SetDirectory(0);
+      fDeltaZ.AddAt(hisdz,id);
+
+      hisP3 = new TH1F(Form("hisPar3v%d",id),Form("hisPar3v%d",id),400,-0.06,0.06);
+      hisP3->SetDirectory(0);
+      fDeltaP3.AddAt(hisP3,id);
+      //
+      hisP4 = new TH1F(Form("hisPar4v%d",id),Form("hisPar4v%d",id),200,-0.06,0.06);
+      hisP4->SetDirectory(0);
+      fDeltaP4.AddAt(hisP4,id);
+
+      //
+      hisdphi = new TH1F(Form("hisdphi%d",id),Form("hisdphi%d",id),1000,-1,1);
+      hisdphi->SetDirectory(0);
+      fDeltaPhi.AddAt(hisdphi,id);
+      //
+      hisdphiP = new TH1F(Form("hisdphiP%d",id),Form("hisdphiP%d",id),1000,-0.01,0.01);
+      hisdphiP->SetDirectory(0);
+      fDeltaPhiP.AddAt(hisdphiP,id);
+      hisSignal = new TH1F(Form("hisSignal%d",id),Form("hisSignal%d",id),100,0,300);
+      hisSignal->SetDirectory(0);
+      fSignals.AddAt(hisSignal,id);
+    }
+  }
+}
+
+void AliTPCcalibLaser::MergeFitHistos(AliTPCcalibLaser * laser){
+  //
+  // Merge content of histograms 
+  //
+  // Only first histogram is checked - all other should be the same
+  if (!laser->fHisNclIn) return;  // empty histograms
+  if (!fHisNclIn) MakeFitHistos();
+  //
+  
+  fHisNclIn->Add(laser->fHisNclIn  );      //->Number of clusters inner
+  fHisNclOut->Add(laser->fHisNclOut  );     //->Number of clusters outer
+  fHisNclIO->Add(laser->fHisNclIO  );      //->Number of cluster inner outer
+  fHisLclIn->Add(laser->fHisLclIn  );      //->Level arm inner
+  fHisLclOut->Add(laser->fHisLclOut  );     //->Level arm outer
+  fHisLclIO->Add(laser->fHisLclIO  );      //->Number of cluster inner outer
+  fHisdEdx->Add(laser->fHisdEdx  );      //->dedx
+  fHisdZfit->Add(laser->fHisdZfit  );      //->dedx
+  //
+  //
+  fHisChi2YIn1->Add(laser->fHisChi2YIn1  );      //->chi2 y inner - line
+  fHisChi2YOut1->Add(laser->fHisChi2YOut1  );     //->chi2 y inner - line
+  fHisChi2YIn2->Add(laser->fHisChi2YIn2  );      //->chi2 y inner - parabola
+  fHisChi2YOut2->Add(laser->fHisChi2YOut2  );     //->chi2 y inner - parabola
+  fHisChi2YIO1->Add(laser->fHisChi2YIO1  );      //->chi2 y IO    - common
+  fHisChi2ZIn1->Add(laser->fHisChi2ZIn1  );      //->chi2 z inner - line
+  fHisChi2ZOut1->Add(laser->fHisChi2ZOut1  );     //->chi2 z inner - line
+  fHisChi2ZIn2->Add(laser->fHisChi2ZIn2  );      //->chi2 z inner - parabola
+  fHisChi2ZOut2->Add(laser->fHisChi2ZOut2  );     //->chi2 z inner - parabola
+  fHisChi2ZIO1->Add(laser->fHisChi2ZIO1  );      //->chi2 z IO    - common
+  //
+  //
+  fHisPy1vP0->Add(laser->fHisPy1vP0  );     //-> delta y   P0outer-P0inner - line
+  fHisPy2vP0->Add(laser->fHisPy2vP0  );     //-> delta y   P0outer-P0inner - parabola
+  fHisPy3vP0->Add(laser->fHisPy3vP0  );     //-> delta y   P0outer-P0inner - common parabola
+  fHisPy1vP1->Add(laser->fHisPy1vP1  );     //-> delta ky  P1outer-P1inner - line
+  fHisPy2vP1->Add(laser->fHisPy2vP1  );     //-> delta ky  P1outer-P1inner - parabola
+  fHisPy3vP1->Add(laser->fHisPy3vP1  );     //-> delta ky  P1outer-P1inner - common parabola
+  fHisPy2vP2In->Add(laser-> fHisPy2vP2In  );   //-> Curv  P2inner - parabola
+  fHisPy2vP2Out->Add(laser->fHisPy2vP2Out  );  //-> Curv  P2outer - parabola
+  fHisPy3vP2IO->Add(laser->fHisPy3vP2IO  );   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  fHisPz1vP0->Add(laser->fHisPz1vP0  );     //-> delta z   P0outer-P0inner - line
+  fHisPz2vP0->Add(laser->fHisPz2vP0  );     //-> delta z   P0outer-P0inner - parabola
+  fHisPz3vP0->Add(laser->fHisPz3vP0  );     //-> delta z   P0outer-P0inner - common parabola
+  fHisPz1vP1->Add(laser->fHisPz1vP1  );     //-> delta kz  P1outer-P1inner - line
+  fHisPz2vP1->Add(laser->fHisPz2vP1  );     //-> delta kz  P1outer-P1inner - parabola
+  fHisPz3vP1->Add(laser->fHisPz3vP1  );     //-> delta kz  P1outer-P1inner - common parabola
+  fHisPz2vP2In->Add(laser->fHisPz2vP2In  );   //-> Curv  P2inner - parabola
+  fHisPz2vP2Out->Add(laser->fHisPz2vP2Out  );  //-> Curv  P2outer - parabola
+  fHisPz3vP2IO->Add(laser->fHisPz3vP2IO  );   //-> Curv  P2outerinner - common parabola
+  //
+  //
+  //
+  
+
+
+
+}
+
+
+
+
 void AliTPCcalibLaser::DumpFitInfo(TTree * chainFit,Int_t id){
   //
   // Dump fit information - collect information from the streamers 
@@ -1583,6 +2537,10 @@ void AliTPCcalibLaser::DumpFitInfo(TTree * chainFit,Int_t id){
     chainTrack = tool.MakeChain("laser.txt","Track",0,10200);
     chainTrack->Lookup();
     chainTrack->SetProof(kTRUE);
+    chainDrift = tool.MakeChain("laser.txt","driftv",0,10200);
+    chainDrift->Lookup();
+    chainDrift->SetProof(kTRUE);
     chain = tool.MakeChain("laser.txt","Residuals",0,10200);
     chain->Lookup();
     chainFit = tool.MakeChain("laser.txt","FitModels",0,10200);
@@ -1607,7 +2565,7 @@ void AliTPCcalibLaser::DumpFitInfo(TTree * chainFit,Int_t id){
   TCut cutdEdx("sqrt(dEdx)>3");
   TCut cutDY("abs(yPol2In.fElements[2]*nclI*nclI/4.)<3");
   TCut cutN("nclO>20&&nclI>20");
-  TCut cutA = cutChi2YOut+cutChi2ZOut+cutChi2YIn+cutChi2ZIn+cutN+cutdEdx+cutPx;
+  TCut cutA = cutChi2YOut+cutChi2ZOut+cutChi2YIn+cutChi2ZIn+cutN+cutdEdx+cutPx+"accept";
   //
   // Cluster cuts
   //