]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCCalibCE.cxx
Use debug stream only if requested
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibCE.cxx
index febf42af3f03b55a02180b48ed671132f96cb1cb..6e1c4c81f36e433839f43b9d07e805ae3e045653 100644 (file)
@@ -275,6 +275,7 @@ END_HTML */
 #include <TFile.h>
 
 //AliRoot includes
+#include "AliLog.h"
 #include "AliRawReader.h"
 #include "AliRawReaderRoot.h"
 #include "AliRawReaderDate.h"
@@ -308,8 +309,13 @@ AliTPCCalibCE::AliTPCCalibCE() :
     fNbinsRMS(100),
     fXminRMS(0.1),
     fXmaxRMS(5.1),
+    fPeakMinus(2),
+    fPeakPlus(3),
+    fNoiseThresholdMax(5.),
+    fNoiseThresholdSum(8.),
+    fIsZeroSuppressed(kFALSE),
     fLastSector(-1),
-    fOldRCUformat(kTRUE),
+    fSecRejectRatio(.4),
     fROC(AliTPCROC::Instance()),
     fMapping(NULL),
     fParam(new AliTPCParam),
@@ -364,6 +370,7 @@ AliTPCCalibCE::AliTPCCalibCE() :
     // AliTPCSignal default constructor
     //
 //    fHTime0 = new TH1F("hTime0Event","hTime0Event",(fLastTimeBin-fFirstTimeBin)*10,fFirstTimeBin,fLastTimeBin);
+    fParam->Update();
 }
 //_____________________________________________________________________
 AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
@@ -379,8 +386,13 @@ AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
     fNbinsRMS(sig.fNbinsRMS),
     fXminRMS(sig.fXminRMS),
     fXmaxRMS(sig.fXmaxRMS),
+    fPeakMinus(sig.fPeakMinus),
+    fPeakPlus(sig.fPeakPlus),
+    fNoiseThresholdMax(sig.fNoiseThresholdMax),
+    fNoiseThresholdSum(sig.fNoiseThresholdSum),
+    fIsZeroSuppressed(sig.fIsZeroSuppressed),
     fLastSector(-1),
-    fOldRCUformat(kTRUE),
+    fSecRejectRatio(.4),
     fROC(AliTPCROC::Instance()),
     fMapping(NULL),
     fParam(new AliTPCParam),
@@ -511,6 +523,7 @@ AliTPCCalibCE::AliTPCCalibCE(const AliTPCCalibCE &sig) :
     fVEventTime.SetElements(sig.fVEventTime.GetMatrixArray());
     fVEventNumber.SetElements(sig.fVEventNumber.GetMatrixArray());
 
+    fParam->Update();
 }
 //_____________________________________________________________________
 AliTPCCalibCE& AliTPCCalibCE::operator = (const  AliTPCCalibCE &source)
@@ -570,6 +583,11 @@ Int_t AliTPCCalibCE::Update(const Int_t icsector,
     // assumes that it is looped over consecutive time bins of one pad
     //
 
+    //temp
+//    if (icsector<36) return 0;
+//    if (icsector%36>17) return 0;
+
+
   if (icRow<0) return 0;
   if (icPad<0) return 0;
   if (icTimeBin<0) return 0;
@@ -619,7 +637,7 @@ void AliTPCCalibCE::FindPedestal(Float_t part)
        }
 
        if ( fPedestalROC&&fPadNoiseROC ){
-           fPadPedestal = fPedestalROC->GetValue(fCurrentChannel);
+           fPadPedestal = fPedestalROC->GetValue(fCurrentChannel)*(Float_t)(!fIsZeroSuppressed);
            fPadNoise    = fPadNoiseROC->GetValue(fCurrentChannel);
             noPedestal   = kFALSE;
        }
@@ -629,6 +647,9 @@ void AliTPCCalibCE::FindPedestal(Float_t part)
     //if we are not running with pedestal database, or for the current sector there is no information
     //available, calculate the pedestal and noise on the fly
     if ( noPedestal ) {
+       fPadPedestal = 0;
+       fPadNoise    = 0;
+        if ( fIsZeroSuppressed ) return;
        const Int_t kPedMax = 100;  //maximum pedestal value
        Float_t  max    =  0;
        Float_t  maxPos =  0;
@@ -674,8 +695,6 @@ void AliTPCCalibCE::FindPedestal(Float_t part)
                rms  +=histo[median+idelta]*(median+idelta)*(median+idelta);
            }
        }
-       fPadPedestal = 0;
-       fPadNoise    = 0;
        if ( count > 0 ) {
            mean/=count;
            rms    = TMath::Sqrt(TMath::Abs(rms/count-mean*mean));
@@ -695,7 +714,7 @@ void AliTPCCalibCE::FindCESignal(TVectorD &param, Float_t &qSum, const TVectorF
 
     Float_t ceQmax  =0, ceQsum=0, ceTime=0, ceRMS=0;
     Int_t   cemaxpos       = 0;
-    Float_t ceSumThreshold = 8.*fPadNoise;  // threshold for the signal sum
+    Float_t ceSumThreshold = fNoiseThresholdSum*fPadNoise;  // threshold for the signal sum
     const Int_t    kCemin  = 4;             // range for the analysis of the ce signal +- channels from the peak
     const Int_t    kCemax  = 7;
 
@@ -770,12 +789,12 @@ void AliTPCCalibCE::FindLocalMaxima(TVectorF &maxima)
     //
     // Find local maxima on the pad signal and Histogram them
     //
-  Float_t ceThreshold = 5.*TMath::Max(fPadNoise,Float_t(1.));  // threshold for the signal
+  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-tplus-1; i>=fFirstTimeBin+tminus; --i){
-       if ( (fPadSignal[i]-fPadPedestal)>ceThreshold && IsPeak(i,tminus,tplus) ){
+//    Int_t   tminus      = 2;
+//    Int_t   tplus       = 3;
+    for (Int_t i=fLastTimeBin-fPeakPlus-1; i>=fFirstTimeBin+fPeakMinus; --i){
+       if ( (fPadSignal[i]-fPadPedestal)>ceThreshold && IsPeak(i,fPeakMinus,fPeakPlus) ){
          if (count<maxima.GetNrows()){
            maxima.GetMatrixArray()[count++]=i;
            GetHistoTmean(fCurrentSector,kTRUE)->Fill(i);
@@ -797,6 +816,8 @@ void AliTPCCalibCE::ProcessPad()
     FindLocalMaxima(maxima);
     if ( (fNevents == 0) || (fOldRunNumber!=fRunNumber) ) return;  // return because we don't have Time0 info for the CE yet
 
+    if ( !GetTMeanEvents(fCurrentSector) ) 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);
@@ -837,6 +858,8 @@ void AliTPCCalibCE::EndEvent()
     //check if last pad has allready been processed, if not do so
     if ( fMaxTimeBin>-1 ) ProcessPad();
 
+    AliDebug(3, Form("EndEvent() - Start; Event: %05d", fNevents));
+
     TVectorD param(3);
     TMatrixD dummy(3,3);
 //    TVectorF vMeanTime(72);
@@ -861,12 +884,14 @@ void AliTPCCalibCE::EndEvent()
     Int_t nSecMeanT=0;
     //loop over all ROCs, fill CE Time histogram corrected for the mean Time0 of each ROC
     for ( Int_t iSec = 0; iSec<72; ++iSec ){
+       AliDebug(4,Form("Processing sector '%02d'\n",iSec));
       //find median and then calculate the mean around it
        TH1S *hMeanT    = GetHistoTmean(iSec); //histogram with local maxima position information
        if ( !hMeanT ) continue;
         //continue if not enough data is filled in the meanT histogram. This is the case if we do not have a laser event.
-        if ( hMeanT->GetEntries() < fROC->GetNChannels(iSec)*2/3 ){
-          hMeanT->Reset();
+       if ( hMeanT->GetEntries() < fROC->GetNChannels(iSec)*fSecRejectRatio ){
+           hMeanT->Reset();
+           AliDebug(3,Form("Skipping sec. '%02d': Not enough statistics\n",iSec));
           continue;
         }
 
@@ -1053,6 +1078,7 @@ void AliTPCCalibCE::EndEvent()
 
     delete calIroc;
     delete calOroc;
+    AliDebug(3, Form("EndEvent() - End; Event: %05d", fNevents));
 }
 //_____________________________________________________________________
 Bool_t AliTPCCalibCE::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
@@ -1063,24 +1089,24 @@ Bool_t AliTPCCalibCE::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
   ResetEvent();
   Bool_t withInput = kFALSE;
   while ( rawStreamFast->NextDDL() ){
-      while ( rawStreamFast->NextChannel() ){
-         Int_t isector  = rawStreamFast->GetSector();                       //  current sector
-         Int_t iRow     = rawStreamFast->GetRow();                          //  current row
-         Int_t iPad     = rawStreamFast->GetPad();                          //  current pad
-
-         while ( rawStreamFast->NextBunch() ){
-            Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
-            Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
-            for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){
-                 Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin];
-                 Update(isector,iRow,iPad,iTimeBin+1,signal);
-                 withInput = kTRUE;
-             }
-         }
+    while ( rawStreamFast->NextChannel() ){
+      Int_t isector  = rawStreamFast->GetSector();                       //  current sector
+      Int_t iRow     = rawStreamFast->GetRow();                          //  current row
+      Int_t iPad     = rawStreamFast->GetPad();                          //  current pad
+
+      while ( rawStreamFast->NextBunch() ){
+        Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
+        Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
+        for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){
+          Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin];
+         Update(isector,iRow,iPad,iTimeBin+1,signal);
+         withInput = kTRUE;
+       }
       }
+    }
   }
   if (withInput){
-      EndEvent();
+    EndEvent();
   }
   return withInput;
 }
@@ -1114,8 +1140,6 @@ Bool_t AliTPCCalibCE::ProcessEvent(AliTPCRawStream *rawStream)
   // The Function 'SetTimeStamp' should be called for each event to set the event time stamp!!!
   //
 
-  rawStream->SetOldRCUFormat(fOldRCUformat);
-
   ResetEvent();
 
   Bool_t withInput = kFALSE;