]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibPadStatus.cxx
AliDCSClient "multiSplit" option added in the DCS configuration
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibPadStatus.cxx
index 0308a6aa6e2b6e3bb4aaf841c7c9cc309abb7f92..b72b78dafd7bcdc3efce52c8afad20172d258bf0 100644 (file)
@@ -16,7 +16,7 @@
 /* $Id$ */
 
 /*
- example: fill pedestal with gausschen noise
+ example: fill pedestal with Gaussian noise
  AliTRDCalibPadStatus ped;
  ped.TestEvent(numberofevent);
  // Method without histo
@@ -62,28 +62,30 @@ histo->Draw();
 #include <TRandom.h>
 #include <TDirectory.h>
 #include <TFile.h>
-#include <AliMathBase.h>
-#include "TTreeStream.h"
+#include <TTreeStream.h>
 
 //AliRoot includes
+#include <AliMathBase.h>
 #include "AliRawReader.h"
 #include "AliRawReaderRoot.h"
 #include "AliRawReaderDate.h"
 
-#include "AliTRDRawStream.h"
+//header file
+#include "AliTRDCalibPadStatus.h"
+#include "AliTRDRawStreamV2.h"
 #include "AliTRDarrayF.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDCommonParam.h"
 #include "./Cal/AliTRDCalROC.h"
 #include "./Cal/AliTRDCalPadStatus.h"
+#include "./Cal/AliTRDCalDet.h"
+#include "./Cal/AliTRDCalPad.h"
 #include "./Cal/AliTRDCalSingleChamberStatus.h"
 
 #ifdef ALI_DATE
 #include "event.h"
 #endif
 
-//header file
-#include "AliTRDCalibPadStatus.h"
-
 ClassImp(AliTRDCalibPadStatus) /*FOLD00*/
 
 //_____________________________________________________________________
@@ -154,12 +156,10 @@ AliTRDCalibPadStatus::AliTRDCalibPadStatus(const AliTRDCalibPadStatus &ped) : /*
        }
        
     }
-
     if (fGeo) {
       delete fGeo;
     }
     fGeo = new AliTRDgeometry();
-
 }
 
 //_____________________________________________________________________
@@ -180,11 +180,9 @@ AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/
   //
   // destructor
   //
-
   if (fGeo) {
     delete fGeo;
   }
-  
 }
 
 //_____________________________________________________________________
@@ -223,6 +221,7 @@ Int_t AliTRDCalibPadStatus::Update(const Int_t icdet, /*FOLD00*/
     
     return 0;
 }
+
 //_____________________________________________________________________
 Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
                                       const Int_t icRow,
@@ -246,20 +245,23 @@ Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
   
   return 0;
 }
+
 //_____________________________________________________________________
-Bool_t AliTRDCalibPadStatus::ProcessEvent(AliTRDRawStream *rawStream, Bool_t nocheck)
+Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDRawStreamV2 *rawStream, Bool_t nocheck)
 {
   //
-  // Event Processing loop - AliTRDRawStream
-  //
+  // Event Processing loop - AliTRDRawStreamV2
+  // 0 time bin problem or zero suppression
+  // 1 no input
+  // 2 input
+  //  
 
-
-  Bool_t withInput = kFALSE;
+  Int_t withInput = 1;
 
   if(!nocheck) {
     while (rawStream->Next()) {
       Int_t rawversion = rawStream->GetRawVersion();                     //  current raw version
-      if(rawversion != 2) return kFALSE;
+      if(rawversion != 2) return 0;
       Int_t idetector  = rawStream->GetDet();                            //  current detector
       Int_t iRow       = rawStream->GetRow();                            //  current row
       Int_t iRowMax    = rawStream->GetMaxRow();                         //  current rowmax
@@ -268,7 +270,7 @@ Bool_t AliTRDCalibPadStatus::ProcessEvent(AliTRDRawStream *rawStream, Bool_t noc
       Int_t *signal    = rawStream->GetSignals();                        //  current ADC signal
       Int_t nbtimebin  = rawStream->GetNumberOfTimeBins();               //  number of time bins read from data
 
-      if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) return kFALSE;
+      if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) return 0;
       fNumberOfTimeBins = nbtimebin;
       
       Int_t fin        = TMath::Min(nbtimebin,(iTimeBin+3));
@@ -279,7 +281,7 @@ Bool_t AliTRDCalibPadStatus::ProcessEvent(AliTRDRawStream *rawStream, Bool_t noc
        n++;
       }
       
-      withInput = kTRUE;
+      withInput = 2;
     }
   }
   else {
@@ -300,28 +302,30 @@ Bool_t AliTRDCalibPadStatus::ProcessEvent(AliTRDRawStream *rawStream, Bool_t noc
        n++;
       }
       
-      withInput = kTRUE;
+      withInput = 2;
     }
   }
   
   return withInput;
 }
+
 //_____________________________________________________________________
-Bool_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
+Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
 {
   //
   //  Event processing loop - AliRawReader
   //
 
 
-  AliTRDRawStream rawStream(rawReader);
+  AliTRDRawStreamV2 rawStream(rawReader);
 
   rawReader->Select("TRD");
 
   return ProcessEvent(&rawStream, nocheck);
 }
+
 //_________________________________________________________________________
-Bool_t AliTRDCalibPadStatus::ProcessEvent(
+Int_t AliTRDCalibPadStatus::ProcessEvent(
 #ifdef ALI_DATE
                                          eventHeaderStruct *event,
                                          Bool_t nocheck
@@ -346,8 +350,9 @@ Bool_t AliTRDCalibPadStatus::ProcessEvent(
 #endif
 
 }
+
 //_____________________________________________________________________
-Bool_t AliTRDCalibPadStatus::TestEvent(Int_t nevent) /*FOLD00*/
+Bool_t AliTRDCalibPadStatus::TestEvent(Int_t nevent, Int_t sm) /*FOLD00*/
 {
   //
   //  Test event loop
@@ -356,13 +361,13 @@ Bool_t AliTRDCalibPadStatus::TestEvent(Int_t nevent) /*FOLD00*/
 
   gRandom->SetSeed(0);
 
-    for (Int_t ism=0; ism<18; ism++){
+    for (Int_t ism=sm; ism<sm+1; ism++){
                for (Int_t ich=0; ich < 5; ich++){
            for (Int_t ipl=0; ipl < 6; ipl++){
              for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
                for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
                  for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
-                   Int_t signal=(Int_t)(ich+8+gRandom->Gaus(0,1.2));
+                   Int_t signal=(Int_t)(gRandom->Gaus(10.0,1.2));
                    if ( signal>0 )Update((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism));
                  }
                }
@@ -372,8 +377,9 @@ Bool_t AliTRDCalibPadStatus::TestEvent(Int_t nevent) /*FOLD00*/
     }
     return kTRUE;
 }
+
 //_____________________________________________________________________
-Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent) /*FOLD00*/
+Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm) /*FOLD00*/
 {
   //
   //  Test event loop
@@ -382,13 +388,13 @@ Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent) /*FOLD00*/
 
   gRandom->SetSeed(0);
 
-    for (Int_t ism=0; ism<18; ism++){
+    for (Int_t ism=sm; ism<sm+1; ism++){
                for (Int_t ich=0; ich < 5; ich++){
            for (Int_t ipl=0; ipl < 6; ipl++){
              for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
                for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
                  for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
-                   Int_t signal=(Int_t)(ich+8+gRandom->Gaus(0,1.2));
+                   Int_t signal=(Int_t)(gRandom->Gaus(10.0,1.2));
                    if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism));
                  }
                }
@@ -398,6 +404,7 @@ Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent) /*FOLD00*/
     }
     return kTRUE;
 }
+
 //_____________________________________________________________________
 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
                                  Int_t nbinsY, Float_t ymin, Float_t ymax,
@@ -416,8 +423,8 @@ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
     sprintf(name,"hCalib%s%.2d",type,det);
     sprintf(title,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
 
-    Int_t nbchannels = fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))
-                     * fGeo->GetColMax(GetPlane(det));
+   
+    Int_t nbchannels = fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))*fGeo->GetColMax(GetPlane(det));
 
     // new histogram with calib information. One value for each pad!
     TH2F* hist = new TH2F(name,title,
@@ -428,6 +435,7 @@ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
     arr->AddAt(hist,det);
     return hist;
 }
+
 //_____________________________________________________________________
 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -438,6 +446,7 @@ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/
     TObjArray *arr = &fHistoArray;
     return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin, fAdcMax, "Pedestal", force);
 }
+
 //_____________________________________________________________________
 AliTRDarrayF* AliTRDCalibPadStatus::GetCal(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/
 {
@@ -450,8 +459,8 @@ AliTRDarrayF* AliTRDCalibPadStatus::GetCal(Int_t det, TObjArray* arr, Bool_t for
 
     // if we are forced and histogram doesn't yes exist create it
     AliTRDarrayF *croc = new AliTRDarrayF();
-    Int_t nbpad = fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))
-                * fGeo->GetColMax(GetPlane(det));
+    Int_t nbpad = fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))*fGeo->GetColMax(GetPlane(det));
 
     // new AliTRDCalROC. One value for each pad!
     croc->Expand(nbpad);
@@ -461,6 +470,7 @@ AliTRDarrayF* AliTRDCalibPadStatus::GetCal(Int_t det, TObjArray* arr, Bool_t for
     arr->AddAt(croc,det);
     return croc;
 }
+
 //_____________________________________________________________________
 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/
 {
@@ -478,6 +488,7 @@ AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t
     arr->AddAt(croc,det);
     return croc;
 }
+
 //_____________________________________________________________________
 AliTRDarrayF* AliTRDCalibPadStatus::GetCalEntries(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -488,6 +499,7 @@ AliTRDarrayF* AliTRDCalibPadStatus::GetCalEntries(Int_t det, Bool_t force) /*FOL
     TObjArray *arr = &fCalArrayEntries;
     return GetCal(det, arr, force);
 }
+
 //_____________________________________________________________________
 AliTRDarrayF* AliTRDCalibPadStatus::GetCalMean(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -498,6 +510,7 @@ AliTRDarrayF* AliTRDCalibPadStatus::GetCalMean(Int_t det, Bool_t force) /*FOLD00
     TObjArray *arr = &fCalArrayMean;
     return GetCal(det, arr, force);
 }
+
 //_____________________________________________________________________
 AliTRDarrayF* AliTRDCalibPadStatus::GetCalSquares(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -508,6 +521,7 @@ AliTRDarrayF* AliTRDCalibPadStatus::GetCalSquares(Int_t det, Bool_t force) /*FOL
     TObjArray *arr = &fCalArraySquares;
     return GetCal(det, arr, force);
 }
+
 //_____________________________________________________________________
 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -518,6 +532,7 @@ AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOL
     TObjArray *arr = &fCalRocArrayMean;
     return GetCalRoc(det, arr, force);
 }
+
 //_____________________________________________________________________
 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD00*/
 {
@@ -528,6 +543,7 @@ AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD
     TObjArray *arr = &fCalRocArrayRMS;
     return GetCalRoc(det, arr, force);
 }
+
 //_________________________________________________________________________
 void AliTRDCalibPadStatus::Analyse() /*FOLD00*/
 {
@@ -566,6 +582,7 @@ void AliTRDCalibPadStatus::Analyse() /*FOLD00*/
     }
   }
 }
+
 //_____________________________________________________________________
 void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
 {
@@ -597,7 +614,7 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
             Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
            Double_t ret = AliMathBase::FitGaus(array_hP+offset,nbinsAdc,fAdcMin,fAdcMax,&param,&dummy);
             // if the fitting failed set noise and pedestal to 0
-           if ((ret == -4) || (ret == -1)) {
+           if ((ret==-4) || (ret==-1) || (ret==-2)) {
                param[1]=0.0;
                param[2]=0.0;
            }
@@ -609,11 +626,12 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
     }
    
 }
+
 //_______________________________________________________________________________________
 AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
 {
   //
-  //
+  // Create Pad Status out of Mean and RMS values
   //
 
   AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus");
@@ -623,7 +641,6 @@ AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
       AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet);
 
       //Take the stuff
-      fCalEntries = ((AliTRDarrayF *)GetCalEntries(idet));
       AliTRDCalROC *calRocMean    = ((AliTRDCalROC *)GetCalRocMean(idet));
       AliTRDCalROC *calRocRMS     = ((AliTRDCalROC *)GetCalRocRMS(idet));
 
@@ -631,49 +648,74 @@ AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
        for(Int_t k = 0; k < calROC->GetNchannels(); k++){
          calROC->SetStatus(k,AliTRDCalPadStatus::kMasked);
        }
-       //printf("no fCalRocMean for %d\n",idet);
        continue;
       }
-
+      
       //Range
       Int_t channels = calROC->GetNchannels();
-          
-
-      //Mean 
-      Float_t meanentries = 0.0;
-      if(!fCalEntries){
-       if(GetHisto(idet)){
-         meanentries = GetHisto(idet)->GetEntries()/(channels);
-       }
-      }
-      else meanentries       = TMath::Mean(channels,((TArrayF *)fCalEntries)->GetArray());
-      //Double_t meanmean      = calRocMean->GetMean()*10.0;
-      //Double_t meansquares   = calRocRMS->GetMean()*10.0;
+      
+      Double_t rmsmean       = calRocMean->GetRMS()*10.0;
+      Double_t meanmean      = calRocMean->GetMean()*10.0;
+      Double_t meansquares   = calRocRMS->GetMean()*10.0;
 
 
       for(Int_t ich = 0; ich < channels; ich++){
        
-       Float_t entries = 0.0;
-       if(!fCalEntries){
-         if(GetHisto(idet)){
-           for(Int_t bin = 0; bin < (fAdcMax-fAdcMin); bin++){
-             entries += GetHisto(idet)->GetArray()[(ich+1)*(fAdcMax-fAdcMin+2)+(bin+1)];
-           }
-         }
-       }
-       else entries     = fCalEntries->At(ich);
-       //Float_t mean     = calRocMean->GetValue(ich)*10.0;
+       Float_t mean     = calRocMean->GetValue(ich)*10.0;
        Float_t rms      = calRocRMS->GetValue(ich)*10.0;
-       if(ich > 1720) printf("rms %f\n",rms);
-               
-       //if((entries < 0.3*meanentries) || (TMath::Abs(rms-meansquares) > ((Float_t)(fAdcMax-fAdcMin)/2.0)) || (rms == 0.0)) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
-       if(rms <= 0.01) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
-       }
+       
+       if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
+      
+      }
+    }
+  
+  return obj;
+  
+}
+
+//_______________________________________________________________________________________
+AliTRDCalPad* AliTRDCalibPadStatus::CreateCalPad()
+{
+  //
+  // Create Pad Noise out of RMS values
+  //
+
+  AliTRDCalPad* obj = new AliTRDCalPad("PadNoise", "PadNoise");
+  
+  
+  for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det)  {
+    
+    AliTRDCalROC *calROC22 = obj->GetCalROC(det);
+
+    AliTRDCalROC *calRocRMS     = ((AliTRDCalROC *)GetCalRocRMS(det,kTRUE));
+   
+    for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
+      calROC22->SetValue(k,calRocRMS->GetValue(k));
     }
+
+  }
   
   return obj;
   
 }
+
+//_______________________________________________________________________________________
+AliTRDCalDet* AliTRDCalibPadStatus::CreateCalDet()
+{
+  //
+  // Create Det Noise correction factor
+  //
+
+  AliTRDCalDet* obj = new AliTRDCalDet("DetNoise", "DetNoise (correction factor)");
+
+  for(Int_t l = 0; l < 540; l++){
+    obj->SetValue(l,10.0);
+  }
+  
+  return obj;
+  
+}
+
 //_____________________________________________________________________
 void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
 {
@@ -700,7 +742,49 @@ void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir,
     f.Close();
 
     if ( backup ) backup->cd();
-}//_____________________________________________________________________________
+}
+
+//_____________________________________________________________________
+void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
+{
+    //
+    //  Put the AliTRDCalROC in the array fCalRocArrayMean
+    //
+
+
+  AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE);
+  
+  Int_t nChannels = rocMean->GetNchannels();
+  
+  for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
+    
+    rocMean->SetValue(iChannel,mean->GetValue(iChannel));
+    
+  }
+  
+}
+
+//_____________________________________________________________________
+void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
+{
+    //
+    //  Put the AliTRDCalROC in the array fCalRocArrayRMS
+    //
+
+
+  AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE);
+  
+  Int_t nChannels = rocRms->GetNchannels();
+  
+  for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
+    
+    rocRms->SetValue(iChannel,rms->GetValue(iChannel));
+    
+  }
+  
+}
+
+//_____________________________________________________________________________
 Int_t AliTRDCalibPadStatus::GetPlane(Int_t d) const
 {
   //
@@ -721,6 +805,7 @@ Int_t AliTRDCalibPadStatus::GetChamber(Int_t d) const
   return ((Int_t) (d % 30) / 6);
 
 }
+
 //_____________________________________________________________________________
 Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const
 {