]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCCalibCE.cxx
- changes due to deletion of files
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibCE.cxx
index 869cd7793e812c3f68d7f311486d2020b1ab778f..3b644b25150a9f776f9dafad5de4a247024421c7 100644 (file)
@@ -273,6 +273,7 @@ END_HTML */
 #include <TDirectory.h>
 #include <TSystem.h>
 #include <TFile.h>
+#include <TCollection.h>
 
 //AliRoot includes
 #include "AliLog.h"
@@ -352,7 +353,7 @@ AliTPCCalibCE::AliTPCCalibCE() :
   fCurrentRow(-1),
   fMaxPadSignal(-1),
   fMaxTimeBin(-1),
-  fPadSignal(1024),
+//   fPadSignal(1024),
   fPadPedestal(0),
   fPadNoise(0),
   fVTime0Offset(72),
@@ -368,6 +369,7 @@ AliTPCCalibCE::AliTPCCalibCE() :
   fFirstTimeBin=650;
   fLastTimeBin=1000;
   fParam->Update();
+  for (Int_t i=0;i<1024;++i) fPadSignal[i]=0;
 }
 //_____________________________________________________________________
 AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
@@ -426,7 +428,7 @@ AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
   fCurrentRow(-1),
   fMaxPadSignal(-1),
   fMaxTimeBin(-1),
-  fPadSignal(1024),
+//   fPadSignal(1024),
   fPadPedestal(0),
   fPadNoise(0),
   fVTime0Offset(72),
@@ -438,7 +440,8 @@ AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
   //
   // AliTPCSignal copy constructor
   //
-
+  for (Int_t i=0;i<1024;++i) fPadSignal[i]=0;
+  
   for (Int_t iSec = 0; iSec < 72; ++iSec){
     const AliTPCCalROC *calQ   = (AliTPCCalROC*)sig.fCalRocArrayQ.UncheckedAt(iSec);
     const AliTPCCalROC *calT0  = (AliTPCCalROC*)sig.fCalRocArrayT0.UncheckedAt(iSec);
@@ -565,7 +568,7 @@ AliTPCCalibCE::AliTPCCalibCE(const TMap *config) :
   fCurrentRow(-1),
   fMaxPadSignal(-1),
   fMaxTimeBin(-1),
-  fPadSignal(1024),
+//   fPadSignal(1024),
   fPadPedestal(0),
   fPadNoise(0),
   fVTime0Offset(72),
@@ -601,6 +604,8 @@ AliTPCCalibCE::AliTPCCalibCE(const TMap *config) :
   if (config->GetValue("UseL1Phase")) fUseL1Phase = (Bool_t)((TObjString*)config->GetValue("UseL1Phase"))->GetString().Atoi();
   if (config->GetValue("SecRejectRatio")) fSecRejectRatio = ((TObjString*)config->GetValue("SecRejectRatio"))->GetString().Atof();
 
+  for (Int_t i=0;i<1024;++i) fPadSignal[i]=0;
+  
   fParam->Update();
 }
 
@@ -687,7 +692,7 @@ Int_t AliTPCCalibCE::Update(const Int_t icsector,
   }
 
   //fill signals for current pad
-  fPadSignal.GetMatrixArray()[icTimeBin]=csignal;
+  fPadSignal[icTimeBin]=csignal;
   if ( csignal > fMaxPadSignal ){
     fMaxPadSignal = csignal;
     fMaxTimeBin   = icTimeBin;
@@ -739,7 +744,7 @@ void AliTPCCalibCE::FindPedestal(Float_t part)
 
         //fill pedestal histogram
     for (Int_t i=fFirstTimeBin; i<=fLastTimeBin; ++i){
-      padSignal = fPadSignal.GetMatrixArray()[i];
+      padSignal = fPadSignal[i];
       if (padSignal<=0) continue;
       if (padSignal>max && i>10) {
         max = padSignal;
@@ -825,10 +830,10 @@ void AliTPCCalibCE::FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF
   }
 //   printf("L1 phase TB: %f\n",GetL1PhaseTB());
   if (cemaxpos!=0){
-    ceQmax = fPadSignal.GetMatrixArray()[cemaxpos]-fPadPedestal;
+    ceQmax = fPadSignal[cemaxpos]-fPadPedestal;
     for (Int_t i=cemaxpos-kCemin; i<=cemaxpos+kCemax; ++i){
       if ( (i>fFirstTimeBin) && (i<fLastTimeBin) ){
-        Float_t signal = fPadSignal.GetMatrixArray()[i]-fPadPedestal;
+        Float_t signal = fPadSignal[i]-fPadPedestal;
         if (signal>0) {
           ceTime+=signal*(i+0.5);
           ceRMS +=signal*(i+0.5)*(i+0.5);
@@ -870,8 +875,8 @@ void AliTPCCalibCE::FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF
 Bool_t AliTPCCalibCE::IsPeak(Int_t pos, Int_t tminus, Int_t tplus) const
 {
   //
-    // Check if 'pos' is a Maximum. Consider 'tminus' timebins before
-    // and 'tplus' timebins after 'pos'
+  // Check if 'pos' is a Maximum. Consider 'tminus' timebins before
+  // and 'tplus' timebins after 'pos'
   //
   if ( (pos-tminus)<fFirstTimeBin || (pos+tplus)>fLastTimeBin ) return kFALSE;
   for (Int_t iTime = pos; iTime>pos-tminus; --iTime)
@@ -891,13 +896,14 @@ void AliTPCCalibCE::FindLocalMaxima(TVectorF &maxima)
   //
   Float_t ceThreshold = fNoiseThresholdMax*TMath::Max(fPadNoise,Float_t(1.));  // threshold for the signal
   Int_t   count       = 0;
-//    Int_t   tminus      = 2;
-//    Int_t   tplus       = 3;
-  for (Int_t i=fLastTimeBin-fPeakDetPlus-1; i>=fFirstTimeBin+fPeakDetMinus; --i){
-    if ( (fPadSignal[i]-fPadPedestal)>ceThreshold && IsPeak(i,fPeakDetMinus,fPeakDetPlus) ){
+  
+  for (Int_t i=fLastTimeBin-fPeakDetPlus+1; i>=fFirstTimeBin+fPeakDetMinus; --i){
+    if ( (fPadSignal[i]-fPadPedestal)<ceThreshold ) continue;
+    if (IsPeak(i,fPeakDetMinus,fPeakDetPlus) ){
       if (count<maxima.GetNrows()){
         maxima.GetMatrixArray()[count++]=i;
         GetHistoTmean(fCurrentSector,kTRUE)->Fill(i);
+        i-=(fPeakDetMinus+fPeakDetPlus-1); // next peak cannot be at bin  fPeakDetMinus+fPeakDetPlus-1
       }
     }
   }
@@ -917,7 +923,7 @@ void AliTPCCalibCE::ProcessPad()
   if ( (fNevents == 0) || (fOldRunNumber!=fRunNumber) ) return;  // return because we don't have Time0 info for the CE yet
   
   UpdateCETimeRef();                       // update the time refenrence for the current sector
-  if ( fCurrentCETimeRef==0 ) return;      //return if we don't have time 0 info, eg if only one side has laser
+  if ( fCurrentCETimeRef<1e-30 ) return;      //return if we don't have time 0 info, eg if only one side has laser
   TVectorD param(3);
   Float_t  qSum;
   FindCESignal(param, qSum, maxima);
@@ -1051,11 +1057,11 @@ void AliTPCCalibCE::EndEvent()
            //set values for temporary roc calibration class
       if ( iSec < 36 ) {
         calIroc->SetValue(iChannel, time);
-        if ( time == 0 ) calIrocOutliers.SetValue(iChannel,1);
+        if ( TMath::Abs(time) < 1e-30 ) calIrocOutliers.SetValue(iChannel,1);
 
       } else {
         calOroc->SetValue(iChannel, time);
-        if ( time == 0 ) calOrocOutliers.SetValue(iChannel,1);
+        if ( TMath::Abs(time) < 1e-30 ) calOrocOutliers.SetValue(iChannel,1);
       }
 
       if ( (fNevents>0) && (fOldRunNumber==fRunNumber) )
@@ -1120,44 +1126,48 @@ void AliTPCCalibCE::EndEvent()
       //-----------------------------  Debug end  ------------------------------
     }// end channel loop
 
-    TVectorD paramPol1(3);
-    TVectorD paramPol2(6);
-    TMatrixD matPol1(3,3);
-    TMatrixD matPol2(6,6);
-    Float_t  chi2Pol1=0;
-    Float_t  chi2Pol2=0;
-
-    if ( (fNevents>0) && (fOldRunNumber==fRunNumber) ){
-      if ( iSec < 36 ){
-        calIroc->GlobalFit(&calIrocOutliers,0,paramPol1,matPol1,chi2Pol1,0);
-        calIroc->GlobalFit(&calIrocOutliers,0,paramPol2,matPol2,chi2Pol2,1);
-      } else {
-        calOroc->GlobalFit(&calOrocOutliers,0,paramPol1,matPol1,chi2Pol1,0);
-        calOroc->GlobalFit(&calOrocOutliers,0,paramPol2,matPol2,chi2Pol2,1);
-      }
-
-      GetParamArrayPol1(iSec,kTRUE)->AddAtAndExpand(new TVectorD(paramPol1), fNevents);
-      GetParamArrayPol2(iSec,kTRUE)->AddAtAndExpand(new TVectorD(paramPol2), fNevents);
-    }
 
-       //-------------------------------  Debug start  ------------------------------
-    if ( GetStreamLevel()>0 ){
-      TTreeSRedirector *streamer=GetDebugStreamer();
-      if ( streamer ) {
-        (*streamer) << "DataRoc" <<
-//             "Event=" << fEvent <<
-          "RunNumber=" << fRunNumber <<
-          "TimeStamp="   << fTimeStamp <<
-          "Sector="<< iSec <<
-          "hMeanT.=" << hMeanT <<
-          "median=" << median <<
-          "paramPol1.=" << &paramPol1 <<
-          "paramPol2.=" << &paramPol2 <<
-          "matPol1.="   << &matPol1 <<
-          "matPol2.="   << &matPol2 <<
-          "chi2Pol1="   << chi2Pol1 <<
-          "chi2Pol2="   << chi2Pol2 <<
-          "\n";
+    //do fitting now only in debug mode
+    if (GetDebugLevel()>0){
+      TVectorD paramPol1(3);
+      TVectorD paramPol2(6);
+      TMatrixD matPol1(3,3);
+      TMatrixD matPol2(6,6);
+      Float_t  chi2Pol1=0;
+      Float_t  chi2Pol2=0;
+      
+      if ( (fNevents>0) && (fOldRunNumber==fRunNumber) ){
+        if ( iSec < 36 ){
+          calIroc->GlobalFit(&calIrocOutliers,0,paramPol1,matPol1,chi2Pol1,0);
+          calIroc->GlobalFit(&calIrocOutliers,0,paramPol2,matPol2,chi2Pol2,1);
+        } else {
+          calOroc->GlobalFit(&calOrocOutliers,0,paramPol1,matPol1,chi2Pol1,0);
+          calOroc->GlobalFit(&calOrocOutliers,0,paramPol2,matPol2,chi2Pol2,1);
+        }
+        
+        GetParamArrayPol1(iSec,kTRUE)->AddAtAndExpand(new TVectorD(paramPol1), fNevents);
+        GetParamArrayPol2(iSec,kTRUE)->AddAtAndExpand(new TVectorD(paramPol2), fNevents);
+      }
+      
+  //-------------------------------  Debug start  ------------------------------
+      if ( GetStreamLevel()>0 ){
+        TTreeSRedirector *streamer=GetDebugStreamer();
+        if ( streamer ) {
+          (*streamer) << "DataRoc" <<
+//    "Event=" << fEvent <<
+            "RunNumber=" << fRunNumber <<
+            "TimeStamp="   << fTimeStamp <<
+            "Sector="<< iSec <<
+            "hMeanT.=" << hMeanT <<
+            "median=" << median <<
+            "paramPol1.=" << &paramPol1 <<
+            "paramPol2.=" << &paramPol2 <<
+            "matPol1.="   << &matPol1 <<
+            "matPol2.="   << &matPol2 <<
+            "chi2Pol1="   << chi2Pol1 <<
+            "chi2Pol2="   << chi2Pol2 <<
+            "\n";
+        }
       }
     }
        //-------------------------------  Debug end  ------------------------------
@@ -1487,124 +1497,157 @@ void AliTPCCalibCE::ResetPad()
     //  Reset pad infos -- Should be called after a pad has been processed
     //
     for (Int_t i=fFirstTimeBin; i<fLastTimeBin+1; ++i)
-       fPadSignal.GetMatrixArray()[i] = 0;
+      fPadSignal[i] = 0;
     fMaxTimeBin   = -1;
     fMaxPadSignal = -1;
     fPadPedestal  = -1;
     fPadNoise     = -1;
 }
 //_____________________________________________________________________
-void AliTPCCalibCE::Merge(AliTPCCalibCE *ce)
+void AliTPCCalibCE::Merge(AliTPCCalibCE * const ce)
 {
-    //
-    //  Merge ce to the current AliTPCCalibCE
-    //
-
-    //merge histograms
-    for (Int_t iSec=0; iSec<72; ++iSec){
-       TH2S *hRefQmerge   = ce->GetHistoQ(iSec);
-       TH2S *hRefT0merge  = ce->GetHistoT0(iSec);
-       TH2S *hRefRMSmerge = ce->GetHistoRMS(iSec);
-
-
-       if ( hRefQmerge ){
-           TDirectory *dir = hRefQmerge->GetDirectory(); hRefQmerge->SetDirectory(0);
-           TH2S *hRefQ   = GetHistoQ(iSec);
-           if ( hRefQ ) hRefQ->Add(hRefQmerge);
-           else {
-               TH2S *hist = new TH2S(*hRefQmerge);
-                hist->SetDirectory(0);
-               fHistoQArray.AddAt(hist, iSec);
-           }
-           hRefQmerge->SetDirectory(dir);
-       }
-       if ( hRefT0merge ){
-           TDirectory *dir = hRefT0merge->GetDirectory(); hRefT0merge->SetDirectory(0);
-           TH2S *hRefT0  = GetHistoT0(iSec);
-           if ( hRefT0 ) hRefT0->Add(hRefT0merge);
-           else {
-               TH2S *hist = new TH2S(*hRefT0merge);
-                hist->SetDirectory(0);
-               fHistoT0Array.AddAt(hist, iSec);
-           }
-           hRefT0merge->SetDirectory(dir);
-       }
-       if ( hRefRMSmerge ){
-           TDirectory *dir = hRefRMSmerge->GetDirectory(); hRefRMSmerge->SetDirectory(0);
-           TH2S *hRefRMS = GetHistoRMS(iSec);
-           if ( hRefRMS ) hRefRMS->Add(hRefRMSmerge);
-           else {
-               TH2S *hist = new TH2S(*hRefRMSmerge);
-                hist->SetDirectory(0);
-               fHistoRMSArray.AddAt(hist, iSec);
-           }
-           hRefRMSmerge->SetDirectory(dir);
-       }
-
+  //
+  //  Merge ce to the current AliTPCCalibCE
+  //
+  
+  //merge histograms
+  for (Int_t iSec=0; iSec<72; ++iSec){
+    TH2S *hRefQmerge   = ce->GetHistoQ(iSec);
+    TH2S *hRefT0merge  = ce->GetHistoT0(iSec);
+    TH2S *hRefRMSmerge = ce->GetHistoRMS(iSec);
+    
+    
+    if ( hRefQmerge ){
+      TDirectory *dir = hRefQmerge->GetDirectory(); hRefQmerge->SetDirectory(0);
+      TH2S *hRefQ   = GetHistoQ(iSec);
+      if ( hRefQ ) hRefQ->Add(hRefQmerge);
+      else {
+        TH2S *hist = new TH2S(*hRefQmerge);
+        hist->SetDirectory(0);
+        fHistoQArray.AddAt(hist, iSec);
+      }
+      hRefQmerge->SetDirectory(dir);
     }
-
+    if ( hRefT0merge ){
+      TDirectory *dir = hRefT0merge->GetDirectory(); hRefT0merge->SetDirectory(0);
+      TH2S *hRefT0  = GetHistoT0(iSec);
+      if ( hRefT0 ) hRefT0->Add(hRefT0merge);
+      else {
+        TH2S *hist = new TH2S(*hRefT0merge);
+        hist->SetDirectory(0);
+        fHistoT0Array.AddAt(hist, iSec);
+      }
+      hRefT0merge->SetDirectory(dir);
+    }
+    if ( hRefRMSmerge ){
+      TDirectory *dir = hRefRMSmerge->GetDirectory(); hRefRMSmerge->SetDirectory(0);
+      TH2S *hRefRMS = GetHistoRMS(iSec);
+      if ( hRefRMS ) hRefRMS->Add(hRefRMSmerge);
+      else {
+        TH2S *hist = new TH2S(*hRefRMSmerge);
+        hist->SetDirectory(0);
+        fHistoRMSArray.AddAt(hist, iSec);
+      }
+      hRefRMSmerge->SetDirectory(dir);
+    }
+    
+  }
+  
     // merge time information
-
-
-    Int_t nCEevents = ce->GetNeventsProcessed();
-    for (Int_t iSec=0; iSec<72; ++iSec){
-       TObjArray *arrPol1CE  = ce->GetParamArrayPol1(iSec);
-       TObjArray *arrPol2CE  = ce->GetParamArrayPol2(iSec);
-       TVectorF *vMeanTimeCE = ce->GetTMeanEvents(iSec);
-       TVectorF *vMeanQCE    = ce->GetQMeanEvents(iSec);
-
-       TObjArray *arrPol1  = 0x0;
-       TObjArray *arrPol2  = 0x0;
-       TVectorF *vMeanTime = 0x0;
-       TVectorF *vMeanQ    = 0x0;
-
-       //resize arrays
-       if ( arrPol1CE && arrPol2CE ){
-           arrPol1 = GetParamArrayPol1(iSec,kTRUE);
-           arrPol2 = GetParamArrayPol2(iSec,kTRUE);
-           arrPol1->Expand(fNevents+nCEevents);
-            arrPol2->Expand(fNevents+nCEevents);
-       }
-       if ( vMeanTimeCE && vMeanQCE ){
-           vMeanTime = GetTMeanEvents(iSec,kTRUE);
-           vMeanQ    = GetQMeanEvents(iSec,kTRUE);
-           vMeanTime->ResizeTo(fNevents+nCEevents);
-           vMeanQ->ResizeTo(fNevents+nCEevents);
-       }
-
-
-       for (Int_t iEvent=0; iEvent<nCEevents; ++iEvent){
-           if ( arrPol1CE && arrPol2CE ){
-               TVectorD *paramPol1 = (TVectorD*)(arrPol1CE->UncheckedAt(iEvent));
-               TVectorD *paramPol2 = (TVectorD*)(arrPol2CE->UncheckedAt(iEvent));
-               if ( paramPol1 && paramPol2 ){
-                   GetParamArrayPol1(iSec,kTRUE)->AddAt(new TVectorD(*paramPol1), fNevents+iEvent);
-                   GetParamArrayPol2(iSec,kTRUE)->AddAt(new TVectorD(*paramPol2), fNevents+iEvent);
-               }
-           }
-           if ( vMeanTimeCE && vMeanQCE ){
-               vMeanTime->GetMatrixArray()[fNevents+iEvent]=vMeanTimeCE->GetMatrixArray()[iEvent];
-                vMeanQ->GetMatrixArray()[fNevents+iEvent]=vMeanQCE->GetMatrixArray()[iEvent];
-           }
-       }
+  
+  
+  Int_t nCEevents = ce->GetNeventsProcessed();
+  for (Int_t iSec=0; iSec<72; ++iSec){
+    TObjArray *arrPol1CE  = ce->GetParamArrayPol1(iSec);
+    TObjArray *arrPol2CE  = ce->GetParamArrayPol2(iSec);
+    TVectorF *vMeanTimeCE = ce->GetTMeanEvents(iSec);
+    TVectorF *vMeanQCE    = ce->GetQMeanEvents(iSec);
+    
+    TObjArray *arrPol1  = 0x0;
+    TObjArray *arrPol2  = 0x0;
+    TVectorF *vMeanTime = 0x0;
+    TVectorF *vMeanQ    = 0x0;
+    
+  //resize arrays
+    if ( arrPol1CE && arrPol2CE ){
+      arrPol1 = GetParamArrayPol1(iSec,kTRUE);
+      arrPol2 = GetParamArrayPol2(iSec,kTRUE);
+      arrPol1->Expand(fNevents+nCEevents);
+      arrPol2->Expand(fNevents+nCEevents);
+    }
+    if ( vMeanTimeCE && vMeanQCE ){
+      vMeanTime = GetTMeanEvents(iSec,kTRUE);
+      vMeanQ    = GetQMeanEvents(iSec,kTRUE);
+      vMeanTime->ResizeTo(fNevents+nCEevents);
+      vMeanQ->ResizeTo(fNevents+nCEevents);
+    }
+    
+    
+    for (Int_t iEvent=0; iEvent<nCEevents; ++iEvent){
+      if ( arrPol1CE && arrPol2CE ){
+        TVectorD *paramPol1 = (TVectorD*)(arrPol1CE->UncheckedAt(iEvent));
+        TVectorD *paramPol2 = (TVectorD*)(arrPol2CE->UncheckedAt(iEvent));
+        if ( paramPol1 && paramPol2 ){
+          GetParamArrayPol1(iSec,kTRUE)->AddAt(new TVectorD(*paramPol1), fNevents+iEvent);
+          GetParamArrayPol2(iSec,kTRUE)->AddAt(new TVectorD(*paramPol2), fNevents+iEvent);
+        }
+      }
+      if ( vMeanTimeCE && vMeanQCE ){
+        vMeanTime->GetMatrixArray()[fNevents+iEvent]=vMeanTimeCE->GetMatrixArray()[iEvent];
+        vMeanQ->GetMatrixArray()[fNevents+iEvent]=vMeanQCE->GetMatrixArray()[iEvent];
+      }
     }
+  }
+  
+  
+  
+  const TVectorD&  eventTimes  = ce->fVEventTime;
+  const TVectorD&  eventIds    = ce->fVEventNumber;
+  const TVectorF&  time0SideA  = ce->fVTime0SideA;
+  const TVectorF&  time0SideC  = ce->fVTime0SideC;
+  fVEventTime.ResizeTo(fNevents+nCEevents);
+  fVEventNumber.ResizeTo(fNevents+nCEevents);
+  fVTime0SideA.ResizeTo(fNevents+nCEevents);
+  fVTime0SideC.ResizeTo(fNevents+nCEevents);
+  
+  for (Int_t iEvent=0; iEvent<nCEevents; ++iEvent){
+    Double_t evTime     = eventTimes.GetMatrixArray()[iEvent];
+    Double_t evId       = eventIds.GetMatrixArray()[iEvent];
+    Float_t  t0SideA    = time0SideA.GetMatrixArray()[iEvent];
+    Float_t  t0SideC    = time0SideC.GetMatrixArray()[iEvent];
+    
+    fVEventTime.GetMatrixArray()[fNevents+iEvent]   = evTime;
+    fVEventNumber.GetMatrixArray()[fNevents+iEvent] = evId;
+    fVTime0SideA.GetMatrixArray()[fNevents+iEvent]  = t0SideA;
+    fVTime0SideC.GetMatrixArray()[fNevents+iEvent]  = t0SideC;
+  }
+  fNevents+=nCEevents; //increase event counter
+}
 
+//_____________________________________________________________________
+Long64_t AliTPCCalibCE::Merge(TCollection * const list)
+{
+  //
+  // Merge all objects of this type in list
+  //
 
+  Long64_t nmerged=1;
 
-    TVectorD*  eventTimes  = ce->GetEventTimes();
-    TVectorD*  eventIds  = ce->GetEventIds();
-    fVEventTime.ResizeTo(fNevents+nCEevents);
-    fVEventNumber.ResizeTo(fNevents+nCEevents);
+  TIter next(list);
+  AliTPCCalibCE *ce=0;
+  TObject *o=0;
 
-    for (Int_t iEvent=0; iEvent<nCEevents; ++iEvent){
-       Double_t evTime     = eventTimes->GetMatrixArray()[iEvent];
-        Double_t evId       = eventIds->GetMatrixArray()[iEvent];
-       fVEventTime.GetMatrixArray()[fNevents+iEvent] = evTime;
-       fVEventNumber.GetMatrixArray()[fNevents+iEvent] = evId;
+  while ( (o=next()) ){
+    ce=dynamic_cast<AliTPCCalibCE*>(o);
+    if (ce){
+      Merge(ce);
+      ++nmerged;
     }
-    fNevents+=nCEevents; //increase event counter
+  }
 
+  return nmerged;
 }
+
 //_____________________________________________________________________
 TGraph *AliTPCCalibCE::MakeGraphTimeCE(Int_t sector, Int_t xVariable, Int_t fitType, Int_t fitParameter)
 {
@@ -1626,13 +1669,13 @@ TGraph *AliTPCCalibCE::MakeGraphTimeCE(Int_t sector, Int_t xVariable, Int_t fitT
   TObjArray *aType = 0x0;
   Int_t npoints=0;
 
-    // sanity checks
-  if ( !GetHistoT0(sector) )            return 0x0; //Sector has not been filled 
-  if ( (sector<-2) || (sector>71) )      return 0x0;
-  if ( (xVariable<0) || (xVariable>2) ) return 0x0;
-  if ( (fitType<0) || (fitType>3) )     return 0x0;
-  if ( sector>=0&&!GetTMeanEvents(sector) )        return 0x0; //no mean time information available
-  if ( sector<0 && fitType!=2) return 0x0;
+  // sanity checks
+  if ( (sector<-2)   || (sector>71)   ) return 0x0;  //sector outside valid range
+  if ( (xVariable<0) || (xVariable>2) ) return 0x0;  //invalid x-variable
+  if ( (fitType<0)   || (fitType>3)   ) return 0x0;  //invalid fit type
+  if ( sector>=0 && fitType==2 && !GetTMeanEvents(sector) ) return 0x0; //no mean time information available
+  if ( sector>=0 && fitType==3 && !GetQMeanEvents(sector) ) return 0x0; //no mean charge information available
+  if ( sector<0 && fitType!=2) return 0x0;  //for side wise information only mean time is available
 
   if (sector>=0){
     if ( fitType==0 ){