gcc 4.3 warnings fixed
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.cxx
index dcb4abf..8c52989 100644 (file)
@@ -132,13 +132,14 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fRelativeScale(0)
   ,fThresholdClusterPRF2(15.0)
   ,fLimitChargeIntegration(kFALSE)
+  ,fFillWithZero(kFALSE)
   ,fCalibraMode(new AliTRDCalibraMode())
   ,fDebugStreamer(0)
   ,fDebugLevel(0)
   ,fDetectorPreviousTrack(-1)
   ,fMCMPrevious(-1)
   ,fROBPrevious(-1)
-  ,fNumberClusters(18)
+  ,fNumberClusters(0)
   ,fNumberClustersf(30)
   ,fProcent(6.0)
   ,fDifference(17)
@@ -152,6 +153,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fPHPlace(0x0)
   ,fPHValue(0x0)
   ,fGoodTracklet(kTRUE)
+  ,fLinearFitterTracklet(0x0)
   ,fEntriesCH(0x0)
   ,fEntriesLinearFitter(0x0)
   ,fCalibraVector(0x0)
@@ -195,6 +197,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fRelativeScale(c.fRelativeScale)
   ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
   ,fLimitChargeIntegration(c.fLimitChargeIntegration)
+  ,fFillWithZero(c.fFillWithZero)
   ,fCalibraMode(0x0)
   ,fDebugStreamer(0)
   ,fDebugLevel(c.fDebugLevel)
@@ -215,6 +218,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fPHPlace(0x0)
   ,fPHValue(0x0)
   ,fGoodTracklet(c.fGoodTracklet)
+  ,fLinearFitterTracklet(0x0)
   ,fEntriesCH(0x0)
   ,fEntriesLinearFitter(0x0)
   ,fCalibraVector(0x0)
@@ -269,6 +273,18 @@ AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
   if ( fCalDetGain )  delete fCalDetGain;
   if ( fCalROCGain )  delete fCalROCGain;
 
+  if( fLinearFitterTracklet ) { delete fLinearFitterTracklet; }
+  
+  delete [] fPHPlace;
+  delete [] fPHValue;
+  delete [] fEntriesCH;
+  delete [] fEntriesLinearFitter;
+  delete [] fAmpTotal;
+  
+  for(Int_t idet=0; idet<AliTRDgeometry::kNdet; idet++){ 
+    TLinearFitter *f = (TLinearFitter*)fLinearFitterArray.At(idet);
+    if(f) { delete f;}
+  }
   if (fGeo) {
     delete fGeo;
   }
@@ -345,12 +361,20 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos()
   fSf                 = parCom->GetSamplingFrequency();
   fRelativeScale      = 20;
   fNumberClustersf    = fTimeMax;
-  fNumberClusters     = (Int_t)(0.6*fTimeMax);
+  fNumberClusters     = (Int_t)(0.5*fTimeMax);
  
-  //calib object from database used for reconstruction
-  if(fCalDetGain) delete fCalDetGain;
-  fCalDetGain  = new AliTRDCalDet(*(cal->GetGainFactorDet()));
+  // Init linear fitter
+  if(!fLinearFitterTracklet) {
+    fLinearFitterTracklet = new TLinearFitter(2,"pol1");
+    fLinearFitterTracklet->StoreData(kFALSE);
+  }
 
+  //calib object from database used for reconstruction
+  if( fCalDetGain ){ 
+    fCalDetGain->~AliTRDCalDet();
+    new(fCalDetGain) AliTRDCalDet(*(cal->GetGainFactorDet()));
+  }else fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet()));
+  
   // Calcul Xbins Chambd0, Chamb2
   Int_t ntotal0 = CalculateTotalNumberOfBins(0);
   Int_t ntotal1 = CalculateTotalNumberOfBins(1);
@@ -535,9 +559,11 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t)
       }
       
       // Get calib objects
-      if( fCalROCGain ) delete fCalROCGain;
-      fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
-       
+      if( fCalROCGain ){ 
+        fCalROCGain->~AliTRDCalROC();
+        new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
+      }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
+      
     }
     
     // Reset the detectbjobsor
@@ -604,6 +630,12 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
   AliTRDcluster *cl      = 0x0;                // cluster attached now to the tracklet
   Bool_t         newtr   = kTRUE;              // new track
   
+  // Get cal
+  AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
+  if (!cal) {
+    AliInfo("Could not get calibDB");
+    return kFALSE;
+  }
   
   ///////////////////////////
   // loop over the tracklet
@@ -633,15 +665,12 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
       }
       //Localise the detector bin
       LocalisationDetectorXbins(detector);
-      // Get cal
-      AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
-      if (!cal) {
-       AliInfo("Could not get calibDB");
-       return kFALSE;
-      }
       // Get calib objects
-      if( fCalROCGain ) delete fCalROCGain;
-      fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
+      if( fCalROCGain ){ 
+        fCalROCGain->~AliTRDCalROC();
+        new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
+      }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
+      
       // reset
       fDetectorPreviousTrack = detector;
     }
@@ -726,13 +755,11 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index
   Double_t tiltingangle               = padplane->GetTiltingAngle();        // tiltingangle of the pad      
   Float_t  tnt                        = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
   // linear fit
-  TLinearFitter linearFitterTracklet  = TLinearFitter(2,"pol1");            // TLinearFitter per tracklet
+  fLinearFitterTracklet->ClearPoints();  
   Double_t dydt                       = 0.0;                                // dydt tracklet after straight line fit
   Double_t errorpar                   = 0.0;                                // error after straight line fit on dy/dt
   Double_t pointError                 = 0.0;                                // error after straight line fit 
   Int_t     nbli                      = 0;                                  // number linear fitter points
-  linearFitterTracklet.StoreData(kFALSE);
-  linearFitterTracklet.ClearPoints();
   
   //////////////////////////////
   // loop over clusters
@@ -750,7 +777,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index
     if(k==0) rowp                     = row;
     if(row != rowp) crossrow          = 1;
 
-    linearFitterTracklet.AddPoint(&timeis,ycluster,1);
+    fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
     nbli++;
 
   }
@@ -758,14 +785,18 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index
   //////////////////////////////
   // linear fit
   //////////////////////////////
-  if(nbli <= 2) return kFALSE; 
+  if(nbli <= 2){ 
+    fLinearFitterTracklet->ClearPoints();  
+    return kFALSE; 
+  }
   TVectorD pars;
-  linearFitterTracklet.Eval();
-  linearFitterTracklet.GetParameters(pars);
-  pointError  =  TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
-  errorpar    =  linearFitterTracklet.GetParError(1)*pointError;
+  fLinearFitterTracklet->Eval();
+  fLinearFitterTracklet->GetParameters(pars);
+  pointError  =  TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
+  errorpar    =  fLinearFitterTracklet->GetParError(1)*pointError;
   dydt        = pars[1]; 
-
+  fLinearFitterTracklet->ClearPoints();  
+    
   /////////////////////////////
   // debug
   ////////////////////////////
@@ -849,7 +880,6 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   ////////////
   //Variables
   ////////////
-  TLinearFitter linearFitterTracklet  = TLinearFitter(2,"pol1");            // TLinearFitter per tracklet
   // results of the linear fit
   Double_t dydt                       = 0.0;                                // dydt tracklet after straight line fit
   Double_t errorpar                   = 0.0;                                // error after straight line fit on dy/dt
@@ -858,9 +888,8 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   Int_t    crossrow                   = 0;                                  // if it crosses a pad row
   Int_t    rowp                       = -1;                                 // if it crosses a pad row
   Float_t  tnt                        = tracklet->GetTilt();                // tan tiltingangle
-
-  linearFitterTracklet.StoreData(kFALSE);
-  linearFitterTracklet.ClearPoints();
+  fLinearFitterTracklet->ClearPoints();  
   
   ///////////////////////////////////////////
   // Take the parameters of the track
@@ -899,7 +928,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
     if(rowp==-1) rowp                 = row;
     if(row != rowp) crossrow          = 1;
 
-    linearFitterTracklet.AddPoint(&timeis,ycluster,1);
+    fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
     nbli++;  
 
   }
@@ -907,12 +936,17 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   ////////////////////////////////////
   // Do the straight line fit now
   ///////////////////////////////////
+  if(nbli <= 2){ 
+    fLinearFitterTracklet->ClearPoints();  
+    return kFALSE; 
+  }
   TVectorD pars;
-  linearFitterTracklet.Eval();
-  linearFitterTracklet.GetParameters(pars);
-  pointError  =  TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
-  errorpar    =  linearFitterTracklet.GetParError(1)*pointError;
+  fLinearFitterTracklet->Eval();
+  fLinearFitterTracklet->GetParameters(pars);
+  pointError  =  TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
+  errorpar    =  fLinearFitterTracklet->GetParError(1)*pointError;
   dydt        = pars[1]; 
+  fLinearFitterTracklet->ClearPoints();  
  
   ////////////////////////////////
   // Debug stuff
@@ -1010,10 +1044,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
     dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
   }
   // linear fitter
-  TLinearFitter fitter(2,"pol1");
-  fitter.StoreData(kFALSE);
-  fitter.ClearPoints();
-
+  fLinearFitterTracklet->ClearPoints();
 
   ///////////////////////////
   // calcul the tnp group
@@ -1032,8 +1063,10 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
       }
     }
   }
-  if(echec) return kFALSE;
-  
+  if(echec) {
+    delete [] padPositions;
+    return kFALSE;
+  }
 
   //////////////////////
   // loop clusters
@@ -1042,7 +1075,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
     //Take the cluster
     AliTRDcluster *cl  = (AliTRDcluster *) t->GetCluster(k+index0);
     Short_t  *signals  = cl->GetSignals();
-    Double_t     time  = cl->GetPadTime();
+    Double_t     time  = cl->GetLocalTimeBin();
     //Calculate x if possible 
     Float_t xcenter    = 0.0;    
     Bool_t  echec1      = kTRUE;   
@@ -1070,19 +1103,26 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
     Double_t       padPosition = xcenter +  cl->GetPadCol();
     padPositions[k]            = padPosition;
     nb3pc++;
-    fitter.AddPoint(&time, padPosition,1);
+    fLinearFitterTracklet->AddPoint(&time, padPosition,1);
   }//clusters loop
 
 
   /////////////////////////////
   // fit
   ////////////////////////////
-  if(nb3pc < 3) return kFALSE;
-  fitter.Eval();
+  if(nb3pc < 3) {
+    delete [] padPositions;
+    fLinearFitterTracklet->ClearPoints();  
+    return kFALSE;
+  }
+  fLinearFitterTracklet->Eval();
   TVectorD line(2);
-  fitter.GetParameters(line);
+  fLinearFitterTracklet->GetParameters(line);
   Float_t  pointError  = -1.0;
-  pointError  =  TMath::Sqrt(fitter.GetChisquare()/nb3pc);
+  if( fLinearFitterTracklet->GetChisquare()>=0.0) {
+    pointError  =  TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
+  }
+  fLinearFitterTracklet->ClearPoints();  
   
   /////////////////////////////////////////////////////
   // Now fill the PRF: second loop over clusters
@@ -1091,7 +1131,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
     //Take the cluster
     AliTRDcluster *cl      = (AliTRDcluster *) t->GetCluster(k+index0);
     Short_t  *signals      = cl->GetSignals();              // signal
-    Double_t     time      = cl->GetPadTime();              // time bin
+    Double_t     time      = cl->GetLocalTimeBin();              // time bin
     Float_t padPosTracklet = line[0]+line[1]*time;          // reconstruct position from fit
     Float_t padPos         = cl->GetPadCol();               // middle pad
     Double_t dpad          = padPosTracklet - padPos;       // reconstruct position relative to middle pad from fit 
@@ -1273,6 +1313,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I
       }
     }
   }
+  delete [] padPositions;
   return kTRUE;
   
 }
@@ -1339,10 +1380,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   for(Int_t k = 0; k < AliTRDseed::knTimebins; k++){
     padPositions[k] = 0.0;
   } 
-  TLinearFitter fitter(2,"pol1");  // TLinearFitter for the linear fit in the drift region
-  fitter.StoreData(kFALSE);
-  fitter.ClearPoints();
-
+  fLinearFitterTracklet->ClearPoints();  
+  
   //printf("loop clusters \n");
   ////////////////////////////
   // loop over the clusters
@@ -1351,7 +1390,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
     if(!(cl = tracklet->GetClusters(ic))) continue;
     
-    Double_t     time  = cl->GetPadTime();
+    Double_t     time  = cl->GetLocalTimeBin();
     if((time<=7) || (time>=21)) continue;
     Short_t  *signals  = cl->GetSignals(); 
     Float_t xcenter    = 0.0;    
@@ -1386,7 +1425,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
     Double_t       padPosition = xcenter +  cl->GetPadCol();
     padPositions[ic]            = padPosition;
     nb3pc++;
-    fitter.AddPoint(&time, padPosition,1);
+    fLinearFitterTracklet->AddPoint(&time, padPosition,1);
 
 
   }//clusters loop
@@ -1395,15 +1434,21 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   //////////////////////////////
   // fit with a straight line
   /////////////////////////////
-  if(nb3pc < 3) return kFALSE;
-  fitter.Eval();
+  if(nb3pc < 3){ 
+    delete [] padPositions;
+    fLinearFitterTracklet->ClearPoints();  
+    delete [] padPositions;
+    return kFALSE;
+  }
+  fLinearFitterTracklet->Eval();
   TVectorD line(2);
-  fitter.GetParameters(line);
+  fLinearFitterTracklet->GetParameters(line);
   Float_t  pointError  = -1.0;
-  if(fitter.GetChisquare()>=0.0) {
-  pointError  =  TMath::Sqrt(fitter.GetChisquare()/nb3pc);
+  if( fLinearFitterTracklet->GetChisquare()>=0.0) {
+  pointError  =  TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
   }
-
+  fLinearFitterTracklet->ClearPoints();  
   //printf("PRF second loop \n");
   ////////////////////////////////////////////////
   // Fill the PRF: Second loop over clusters
@@ -1412,7 +1457,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
     if(!(cl = tracklet->GetClusters(ic))) continue;
 
     Short_t  *signals      = cl->GetSignals();              // signal
-    Double_t     time      = cl->GetPadTime();              // time bin
+    Double_t     time      = cl->GetLocalTimeBin();         // time bin
     Float_t padPosTracklet = line[0]+line[1]*time;          // reconstruct position from fit
     Float_t padPos         = cl->GetPadCol();               // middle pad
     Double_t dpad          = padPosTracklet - padPos;       // reconstruct position relative to middle pad from fit 
@@ -1451,6 +1496,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
     Float_t   signal4      = (Float_t)signals[4];                       // signal
     Float_t   signal5      = (Float_t)signals[5];                       // signal at the border
    
+
+
     /////////////////////
     // Debug stuff
     ////////////////////
@@ -1603,6 +1650,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
   } // second loop over clusters
 
 
+  delete [] padPositions;
   return kTRUE;
   
 }
@@ -1893,7 +1941,7 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
       fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
       if (fHisto2d) {
        FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
-       //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
+       //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
       }
       if (fVector2d) {
        fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
@@ -2011,11 +2059,17 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
       fNumberUsedPh[0]++;
       for (Int_t i = 0; i < fTimeMax; i++) {
        if (fHisto2d) {
-         fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+         if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+         else {
+           if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+             }
          //printf("Fill the time bin %d with %f\n",i,fPHValue[i]);
        }
        if (fVector2d) {
-         fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+         if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+         else {
+           if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);  
+         }
        }
       }
       break;
@@ -2028,10 +2082,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
          fNumberUsedPh[1]++;
          for (Int_t i = 0; i < fTimeMax; i++) {
            if (fHisto2d) {
-             fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+             if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+             else {
+               if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 }
            }
            if (fVector2d) {
-             fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+             if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+             else {
+               if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 }
            }
          }
        }
@@ -2040,10 +2100,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
          fNumberUsedPh[1]++;
          for (Int_t i = 0; i < fTimeMax; i++) {
            if (fHisto2d) {
-             fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+             if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+             else {
+               if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+             }
            }
          if (fVector2d) {
-           fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+           if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+           else {
+             if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+           }
          }
          }
        }
@@ -2059,10 +2125,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
              fNumberUsedPh[1]++;
              for (Int_t i = 0; i < fTimeMax; i++) {
                if (fHisto2d) {
-                 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 }
                }
                if (fVector2d) {
-                 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 }
                }
              }
            }
@@ -2071,10 +2143,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
              fNumberUsedPh[1]++;
              for (Int_t i = 0; i < fTimeMax; i++) {
                if (fHisto2d) {
-                 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 }
                }
                if (fVector2d) {
-                 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 }
                }
              }
            }
@@ -2090,10 +2168,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
              fNumberUsedPh[1]++;
              for (Int_t i = 0; i < fTimeMax; i++) {
                if (fHisto2d) {
-                 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
+                 }
                }
                if (fVector2d) {
-                 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
+                 }
                }
              }
            }
@@ -2102,10 +2186,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
              fNumberUsedPh[1]++;
              for (Int_t i = 0; i < fTimeMax; i++) {
                if (fHisto2d) {
-                 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
+                 }
                }
                if (fVector2d) {
-                 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 else {
+                   if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
+                 }
                }
              }
            }
@@ -2874,7 +2964,10 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
   //if((TMath::RMS(fTimeMax,sum) <= 10.0) && (sum[0] > 200.0)) return 1;
   if(used == 0){
     for(Int_t it = 0; it < fTimeMax; it++){
-      UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);  
+      if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); 
+      else{
+       if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); 
+      } 
     }