Add the first version of the TRD preprocessor
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Dec 2006 19:10:05 +0000 (19:10 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Dec 2006 19:10:05 +0000 (19:10 +0000)
TRD/AliTRDCalibra.cxx
TRD/AliTRDCalibra.h
TRD/AliTRDPreprocessor.cxx [new file with mode: 0644]
TRD/AliTRDPreprocessor.h [new file with mode: 0644]
TRD/TRDbaseLinkDef.h
TRD/libTRDbase.pkg

index d28d6ac..67731e4 100644 (file)
@@ -223,6 +223,7 @@ AliTRDCalibra::AliTRDCalibra()
   ,fT0Shift(0.0)
   ,fAccCDB(kFALSE)
   ,fNumberFit(0)
+  ,fNumberEnt(0)
   ,fStatisticMean(0.0)
   ,fDebug(0)
   ,fFitVoir(0)
@@ -299,7 +300,7 @@ AliTRDCalibra::AliTRDCalibra()
     fDet[k] = 0;
   }
 
-  for (Int_t i = 0; i < 2; i++) {
+  for (Int_t i = 0; i < 3; i++) {
     fPhd[i] = 0.0;
   }
 
@@ -338,6 +339,7 @@ AliTRDCalibra::AliTRDCalibra(const AliTRDCalibra &c)
   ,fT0Shift(0.0)
   ,fAccCDB(kFALSE)
   ,fNumberFit(0)
+  ,fNumberEnt(0)
   ,fStatisticMean(0.0)
   ,fDebug(0)
   ,fFitVoir(0)
@@ -560,6 +562,7 @@ Bool_t AliTRDCalibra::FitCHOnline(TH2I *ch)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // For memory
   if (fVectorCH) {
@@ -589,7 +592,10 @@ Bool_t AliTRDCalibra::FitCHOnline(TH2I *ch)
     for (Int_t k = 0; k < nybins; k++) {
       nentries += ch->GetBinContent(ch->GetBin(idect+1,k+1));
     }
-      
+    if (nentries > 0) {
+      fNumberEnt++;
+    }
+
     // Rebin and statistic stuff
     // Rebin
     if (fRebin > 1) {
@@ -691,6 +697,7 @@ Bool_t AliTRDCalibra::FitCHOnline()
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
  
   // Init fCountDet and fCount
   InitfCountDetAndfCount(0);
@@ -728,6 +735,9 @@ Bool_t AliTRDCalibra::FitCHOnline()
         nentries += projch->GetBinContent(k+1);
       }
     }
+    if (nentries > 0) {
+      fNumberEnt++;
+    }
   
     // Rebin and statistic stuff
     // Rebin
@@ -840,6 +850,7 @@ Bool_t AliTRDCalibra::FitCHOnline(TTree *tree)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
   
   // For memory
   if (fVectorCH) {
@@ -879,7 +890,10 @@ Bool_t AliTRDCalibra::FitCHOnline(TTree *tree)
       for (Int_t k = 0; k < projch->GetXaxis()->GetNbins(); k++) {
         nentries += projch->GetBinContent(k+1);
       }
-    }    
+    } 
+    if (nentries > 0) {
+      fNumberEnt++;   
+    }
 
     // Rebin and statistic stuff
     // Rebin
@@ -990,6 +1004,7 @@ Bool_t AliTRDCalibra::FitPHOnline(TProfile2D *ph)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // For memory
   if (fVectorPH) {
@@ -1013,7 +1028,10 @@ Bool_t AliTRDCalibra::FitPHOnline(TProfile2D *ph)
     for (Int_t k = 0; k < nybins; k++) {
       nentries += ph->GetBinEntries(ph->GetBin(idect+1,k+1));
     }
-  
+    if (nentries > 0) {
+      fNumberEnt++;
+    }  
+
     // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
     UpdatefCountDetAndfCount(idect,1);
 
@@ -1127,6 +1145,7 @@ Bool_t AliTRDCalibra::FitPHOnline()
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // Init fCountDet and fCount
   InitfCountDetAndfCount(1);
@@ -1142,6 +1161,8 @@ Bool_t AliTRDCalibra::FitPHOnline()
     TString name("PH");
     name += idect;
     if (place != -1) {
+      //Entries
+      fNumberEnt++;
       // Variable
       AliTRDPInfo *fPHInfo = new AliTRDPInfo();
       // Retrieve
@@ -1264,6 +1285,7 @@ Bool_t AliTRDCalibra::FitPHOnline(TTree *tree)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // For memory
   if (fVectorPH) {
@@ -1288,6 +1310,8 @@ Bool_t AliTRDCalibra::FitPHOnline(TTree *tree)
     TH1F *projph = 0x0;
     // Is in
     if (place != -1) {
+      //Entries
+      fNumberEnt++;
       // Variable
       tree->GetEntry(place);
       projph = CorrectTheError(projphtree);
@@ -1412,6 +1436,7 @@ Bool_t AliTRDCalibra::FitPRFOnline(TProfile2D *prf)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // For memory
   if (fVectorPRF) {
@@ -1435,6 +1460,7 @@ Bool_t AliTRDCalibra::FitPRFOnline(TProfile2D *prf)
     for (Int_t k = 0; k < nybins; k++) {
       nentries += prf->GetBinEntries(prf->GetBin(idect+1,k+1));
     }
+    if(nentries > 0) fNumberEnt++;
     
     // Determination of fNnZ, fNnRphi, fNfragZ and fNfragRphi
     UpdatefCountDetAndfCount(idect,2);
@@ -1538,6 +1564,7 @@ Bool_t AliTRDCalibra::FitPRFOnline(TTree *tree)
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // For memory
   if (fVectorPRF) {
@@ -1562,6 +1589,8 @@ Bool_t AliTRDCalibra::FitPRFOnline(TTree *tree)
     // Is in   
     TH1F *projprf = 0x0;
     if (place != -1) {
+      //Entries
+      fNumberEnt++;
       // Variable
       tree->GetEntry(place);
       projprf = CorrectTheError(projprftree);
@@ -1671,6 +1700,7 @@ Bool_t AliTRDCalibra::FitPRFOnline()
   }
   fStatisticMean = 0.0;
   fNumberFit     = 0;
+  fNumberEnt     = 0;
 
   // Init fCountDet and fCount
   InitfCountDetAndfCount(2);
@@ -1686,6 +1716,8 @@ Bool_t AliTRDCalibra::FitPRFOnline()
     TString name("PRF");
     name += idect;
     if (place != -1) {
+      //Entries
+      fNumberEnt++;
       // Variable
       AliTRDPInfo *fPRFInfo = new AliTRDPInfo();
       // Retrieve
@@ -2721,20 +2753,9 @@ TObject *AliTRDCalibra::CreatePadObjectTree(TTree *tree, Int_t i
     Int_t colMax = calROC->GetNcols();
     for (Int_t row = 0; row < rowMax; ++row) {
       for (Int_t col = 0; col < colMax; ++col) {
-       if (i == 0) {
-          calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean);
-       }
-       if (i == 1) {
-          calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean);
-       }
-       if (i == 3) {
-         if (values[(Int_t) (col*rowMax+row)]/mean < 0.0) {
-           calROC->SetValue(col,row,0.0);
-         }
-         if (values[(Int_t) (col*rowMax+row)]/mean >= 0.0) {
-           calROC->SetValue(col,row,values[(Int_t) (col*rowMax+row)]/mean);
-         }
-       }
+       
+       calROC->SetValue(col,row,TMath::Abs(values[(Int_t) (col*rowMax+row)])/mean);
+       
       } // Col
     } // Row
   }
@@ -4420,8 +4441,8 @@ void AliTRDCalibra::CreateFitHistoT0(Int_t nbins, Double_t low, Double_t high)
   // Histograms for Debug
   fDeltaT0[0] = new TH1F("deltaT00","",nbins,low ,high);
   fDeltaT0[1] = new TH1F("deltaT01","",nbins,low ,high);
-  fErrorT0[0] = new TH1I("errorT00","",300  ,-0.1,0.1);
-  fErrorT0[1] = new TH1I("errorT01","",300  ,-0.1,0.1);
+  fErrorT0[0] = new TH1I("errorT00","",100,-0.2,0.2);
+  fErrorT0[1] = new TH1I("errorT01","",100,-0.2,0.2);
 
   fCoefT0[0]->SetXTitle("Det/pad groups");
   fCoefT0[0]->SetYTitle("t0 [timebin]");
@@ -4573,7 +4594,7 @@ void AliTRDCalibra::CreateFitHistoPRF(Int_t nbins, Double_t low, Double_t high)
  
   // Histograms for Debug 
   fDeltaPRF   = new TH1F("deltaPRF","",nbins,low ,high);
-  fErrorPRF   = new TH1I("errorPRF","",300  ,-0.5,0.5);
+  fErrorPRF   = new TH1I("errorPRF","",300,-0.5,0.5);
 
   fDeltaPRF->SetMarkerColor(6);
   fDeltaPRF->SetMarkerStyle(26);
@@ -5210,12 +5231,12 @@ Bool_t AliTRDCalibra::NotEnoughStatistic(Int_t idect, Int_t i)
         (fDebug == 4)) {
 
       if (fFitPHOn) {
-       fCoefVdrift[0]->SetBinContent(idect-fDect1[1]+1,fVdriftCoef[2]);
-       fCoefT0[0]->SetBinContent(idect-fDect1[1]+1,fT0Coef[2]);
+       fCoefVdrift[0]->SetBinContent(idect-fDect1[1]+1,-fVdriftCoef[2]);
+       fCoefT0[0]->SetBinContent(idect-fDect1[1]+1,-fT0Coef[2]);
       }
 
-      fCoefVdrift[1]->SetBinContent(idect-fDect1[1]+1,fVdriftCoef[2]);
-      fCoefT0[1]->SetBinContent(idect-fDect1[1]+1,fT0Coef[2]);
+      fCoefVdrift[1]->SetBinContent(idect-fDect1[1]+1,-fVdriftCoef[2]);
+      fCoefT0[1]->SetBinContent(idect-fDect1[1]+1,-fT0Coef[2]);
 
     }
     
@@ -7423,7 +7444,7 @@ void AliTRDCalibra::FitPente(TH1* projPH, Int_t idect)
     fVdriftCoef[1] = (kDrWidth) / (fPhd[2]-fPhd[1]);
     if (fPhd[0] >= 0.0) {
       fT0Coef[1] = (fPhd[0] - fT0Shift) / widbins;
-      if (fT0Coef[1] <= -1.0) {
+      if (fT0Coef[1] < 0.0) {
         fT0Coef[1] = - TMath::Abs(fT0Coef[2]);
       }
     }
@@ -7438,12 +7459,14 @@ void AliTRDCalibra::FitPente(TH1* projPH, Int_t idect)
 
   if ((fDebug == 1) || 
       (fDebug == 4)) {
-    fCoefVdrift[1]->SetBinContent(idect+1,TMath::Abs(fVdriftCoef[1]));
+    fCoefVdrift[1]->SetBinContent(idect+1,fVdriftCoef[1]);
     fCoefT0[1]->SetBinContent(idect+1,fT0Coef[1]);
     if (fVdriftCoef[1] > 0.0) {
       if (fVdriftCoef[2] != 0.0) {
         fDeltaVdrift[1]->SetBinContent(idect+1,(fVdriftCoef[1] - fVdriftCoef[2]) / fVdriftCoef[2]);
       }
+    }
+    if(fT0Coef[1] >= 0.0){
       fDeltaT0[1]->SetBinContent(idect+1,(fT0Coef[1] - fT0Coef[2]));
     }
   }
@@ -7543,8 +7566,8 @@ void AliTRDCalibra::FitPH(TH1* projPH, Int_t idect)
 
     if ((fDebug == 1) || 
         (fDebug == 4)) {
-      fCoefVdrift[0]->SetBinContent(idect+1,TMath::Abs(fVdriftCoef[0]));
-      fCoefT0[0]->SetBinContent(idect+1,TMath::Abs(fT0Coef[0]));
+      fCoefVdrift[0]->SetBinContent(idect+1,fVdriftCoef[0]);
+      fCoefT0[0]->SetBinContent(idect+1,fT0Coef[0]);
     if (fVdriftCoef[0] > 0.0){
        if (fVdriftCoef[2] != 0.0) {
           fDeltaVdrift[0]->SetBinContent(idect+1,(fVdriftCoef[0]-fVdriftCoef[2])/fVdriftCoef[2]);
@@ -7596,6 +7619,7 @@ void AliTRDCalibra::FitPRF(TH1 *projPRF, Int_t idect)
   }
 
   fPRFCoef[0] = projPRF->GetFunction("gaus")->GetParameter(2);
+  if(fPRFCoef[0] <= 0.0) fPRFCoef[0] = -fPRFCoef[1];
 
   if ((fDebug == 1) || 
       (fDebug == 4)) {
index b2579aa..a2d8760 100644 (file)
@@ -27,6 +27,7 @@ class TH2F;
 class TF1;
 
 class AliLog;
+
 class AliTRDcluster;
 class AliTRDtrack;
 class AliTRDmcmTracklet;
@@ -99,55 +100,55 @@ class AliTRDCalibra : public TObject {
 
   // Choice to fill or not the 2D
           void     SetMITracking(Bool_t mitracking = kTRUE)                  { fMITracking      = mitracking;  }
-          void     SetMcmTracking(Bool_t mcmtracking = kTRUE)                { fMcmTracking     = mcmtracking;  }
-          void     SetMcmCorrectAngle()                                      { fMcmCorrectAngle = kTRUE; }
-          void     SetPH2dOn()                                               { fPH2dOn          = kTRUE; }
-          void     SetCH2dOn()                                               { fCH2dOn          = kTRUE; }
-          void     SetPRF2dOn()                                              { fPRF2dOn         = kTRUE; }
-          void     SetHisto2d()                                              { fHisto2d         = kTRUE; }
-          void     SetVector2d()                                             { fVector2d        = kTRUE; }
+          void     SetMcmTracking(Bool_t mcmtracking = kTRUE)                { fMcmTracking     = mcmtracking; }
+          void     SetMcmCorrectAngle()                                      { fMcmCorrectAngle = kTRUE;       }
+          void     SetPH2dOn()                                               { fPH2dOn          = kTRUE;       }
+          void     SetCH2dOn()                                               { fCH2dOn          = kTRUE;       }
+          void     SetPRF2dOn()                                              { fPRF2dOn         = kTRUE;       }
+          void     SetHisto2d()                                              { fHisto2d         = kTRUE;       }
+          void     SetVector2d()                                             { fVector2d        = kTRUE;       }
   
-          Bool_t   GetMITracking() const                                     { return fMITracking;       }
-          Bool_t   GetMcmTracking() const                                    { return fMcmTracking;      }
-          Bool_t   GetMcmCorrectAngle() const                                { return fMcmCorrectAngle;  }
-          Bool_t   GetPH2dOn() const                                         { return fPH2dOn;           }
-          Bool_t   GetCH2dOn() const                                         { return fCH2dOn;           }
-          Bool_t   GetPRF2dOn() const                                        { return fPRF2dOn;          }
-          Bool_t   GetHisto2d() const                                        { return fHisto2d;          }
-          Bool_t   GetVector2d() const                                       { return fVector2d;         }
-  TH2I            *GetCH2d() const                                           { return fCH2d;             }
-  TProfile2D      *GetPH2d() const                                           { return fPH2d;             }
-  TProfile2D      *GetPRF2d() const                                          { return fPRF2d;            }
+          Bool_t   GetMITracking() const                                     { return fMITracking;             }
+          Bool_t   GetMcmTracking() const                                    { return fMcmTracking;            }
+          Bool_t   GetMcmCorrectAngle() const                                { return fMcmCorrectAngle;        }
+          Bool_t   GetPH2dOn() const                                         { return fPH2dOn;                 }
+          Bool_t   GetCH2dOn() const                                         { return fCH2dOn;                 }
+          Bool_t   GetPRF2dOn() const                                        { return fPRF2dOn;                }
+          Bool_t   GetHisto2d() const                                        { return fHisto2d;                }
+          Bool_t   GetVector2d() const                                       { return fVector2d;               }
+  TH2I            *GetCH2d() const                                           { return fCH2d;                   }
+  TProfile2D      *GetPH2d() const                                           { return fPH2d;                   }
+  TProfile2D      *GetPRF2d() const                                          { return fPRF2d;                  }
   
   // How to fill the 2D
-          void     SetRelativeScaleAuto()                                    { fRelativeScaleAuto    = kTRUE;                      }
+          void     SetRelativeScaleAuto()                                    { fRelativeScaleAuto    = kTRUE;                }
           void     SetRelativeScale(Float_t relativeScale);                      
-          void     SetThresholdDigit(Int_t digitthreshold)                   { fThresholdDigit       = digitthreshold;             }
-          void     SetThresholdClusterPRF1(Float_t thresholdClusterPRF1)     { fThresholdClusterPRF1 = thresholdClusterPRF1;       }
-          void     SetThresholdClusterPRF2(Float_t thresholdClusterPRF2)     { fThresholdClusterPRF2 = thresholdClusterPRF2;       }
-          void     SetCenterOfflineCluster()                                 { fCenterOfflineCluster = kTRUE;                      }
-          void     SetTraMaxPad()                                            { fTraMaxPad            = kTRUE;                      }
+          void     SetThresholdDigit(Int_t digitthreshold)                   { fThresholdDigit       = digitthreshold;       }
+          void     SetThresholdClusterPRF1(Float_t thresholdClusterPRF1)     { fThresholdClusterPRF1 = thresholdClusterPRF1; }
+          void     SetThresholdClusterPRF2(Float_t thresholdClusterPRF2)     { fThresholdClusterPRF2 = thresholdClusterPRF2; }
+          void     SetCenterOfflineCluster()                                 { fCenterOfflineCluster = kTRUE;                }
+          void     SetTraMaxPad()                                            { fTraMaxPad            = kTRUE;                }
           void     SetNz(Int_t i, Short_t nz);
           void     SetNrphi(Int_t i, Short_t nrphi);
-          void     SetProcent(Float_t procent)                               { fProcent              = procent;                    }
-          void     SetDifference(Short_t difference)                         { fDifference           = difference;                 }
-          void     SetNumberClusters(Short_t numberClusters)                 { fNumberClusters       = numberClusters;             }
-          void     SetNumberBinCharge(Short_t numberBinCharge)               { fNumberBinCharge      = numberBinCharge;            }
-          void     SetNumberBinPRF(Short_t numberBinPRF)                     { fNumberBinPRF         = numberBinPRF;               }
+          void     SetProcent(Float_t procent)                               { fProcent              = procent;              }
+          void     SetDifference(Short_t difference)                         { fDifference           = difference;           }
+          void     SetNumberClusters(Short_t numberClusters)                 { fNumberClusters       = numberClusters;       }
+          void     SetNumberBinCharge(Short_t numberBinCharge)               { fNumberBinCharge      = numberBinCharge;      }
+          void     SetNumberBinPRF(Short_t numberBinPRF)                     { fNumberBinPRF         = numberBinPRF;         }
   
-          Float_t  GetRelativeScale() const                                  { return fRelativeScale;        }
-          Bool_t   GetRelativeScaleAuto() const                              { return fRelativeScaleAuto;    }
-          Int_t    GetThresholdDigit() const                                 { return fThresholdDigit;       }
-          Float_t  GetThresholdClusterPRF1() const                           { return fThresholdClusterPRF1; }
-          Float_t  GetThresholdClusterPRF2() const                           { return fThresholdClusterPRF2; }
-          Bool_t   GetTraMaxPad()const                                       { return fTraMaxPad;            }
-          Short_t  GetNz(Int_t i) const                                      { return fNz[i];                }
-          Short_t  GetNrphi(Int_t i) const                                   { return fNrphi[i];             }
-          Float_t  GetProcent() const                                        { return fProcent;              }
-          Short_t  GetDifference() const                                     { return fDifference;           }
-          Short_t  GetNumberClusters() const                                 { return fNumberClusters;       }
-          Short_t  GetNumberBinCharge() const                                { return fNumberBinCharge;      }
-          Short_t  GetNumberBinPRF() const                                   { return fNumberBinPRF;         }
+          Float_t  GetRelativeScale() const                                  { return fRelativeScale;          }
+          Bool_t   GetRelativeScaleAuto() const                              { return fRelativeScaleAuto;      }
+          Int_t    GetThresholdDigit() const                                 { return fThresholdDigit;         }
+          Float_t  GetThresholdClusterPRF1() const                           { return fThresholdClusterPRF1;   }
+          Float_t  GetThresholdClusterPRF2() const                           { return fThresholdClusterPRF2;   }
+          Bool_t   GetTraMaxPad()const                                       { return fTraMaxPad;              }
+          Short_t  GetNz(Int_t i) const                                      { return fNz[i];                  }
+          Short_t  GetNrphi(Int_t i) const                                   { return fNrphi[i];               }
+          Float_t  GetProcent() const                                        { return fProcent;                }
+          Short_t  GetDifference() const                                     { return fDifference;             }
+          Short_t  GetNumberClusters() const                                 { return fNumberClusters;         }
+          Short_t  GetNumberBinCharge() const                                { return fNumberBinCharge;        }
+          Short_t  GetNumberBinPRF() const                                   { return fNumberBinPRF;           }
   
   // Write
           void     SetWriteCoef(Int_t i)                                     { fWriteCoef[i]  = kTRUE;         }
@@ -161,59 +162,60 @@ class AliTRDCalibra : public TObject {
           TString  GetWriteName() const                                      { return fWriteName;              }
   
   // Fit
-          void     SetFitPHOn()                                              { fFitPHOn        = kTRUE;}
+          void     SetFitPHOn()                                              { fFitPHOn        = kTRUE;        }
           void     SetPeriodeFitPH(Int_t periodeFitPH);   
           void     SetBeginFitCharge(Float_t beginFitCharge);     
           void     SetT0Shift(Float_t t0Shift); 
           void     SetRangeFitPRF(Float_t rangeFitPRF);       
-          void     SetMeanChargeOn()                                         { fMeanChargeOn   = kTRUE;      }
-          void     SetAccCDB()                                               { fAccCDB         = kTRUE;      }
-          void     SetFitChargeBisOn()                                       { fFitChargeBisOn = kTRUE;      }
-          void     SetMinEntries(Int_t minEntries)                           { fMinEntries     = minEntries; }
+          void     SetMeanChargeOn()                                         { fMeanChargeOn   = kTRUE;        }
+          void     SetAccCDB()                                               { fAccCDB         = kTRUE;        }
+          void     SetFitChargeBisOn()                                       { fFitChargeBisOn = kTRUE;        }
+          void     SetMinEntries(Int_t minEntries)                           { fMinEntries     = minEntries;   }
   
-          Bool_t   GetFitPHOn() const                                        { return fFitPHOn;        }
-          Int_t    GetPeriodeFitPH() const                                   { return fFitPHPeriode;   }
-          Float_t  GetBeginFitCharge() const                                 { return fBeginFitCharge; }
-          Float_t  GetT0Shift() const                                        { return fT0Shift;        }
-          Float_t  GetRangeFitPRF() const                                    { return fRangeFitPRF;    }
-          Bool_t   GetMeanChargeOn() const                                   { return fMeanChargeOn;   }
-          Bool_t   GetAccCDB() const                                         { return fAccCDB;         }
-          Bool_t   GetFitChargeBisOn() const                                 { return fFitChargeBisOn; }
-          Int_t    GetMinEntries() const                                     { return fMinEntries;     }
-          Int_t    GetNumberFit() const                                      { return fNumberFit;      }
-          Double_t GetStatisticMean() const                                  { return fStatisticMean;  }
+          Bool_t   GetFitPHOn() const                                        { return fFitPHOn;                }
+          Int_t    GetPeriodeFitPH() const                                   { return fFitPHPeriode;           }
+          Float_t  GetBeginFitCharge() const                                 { return fBeginFitCharge;         }
+          Float_t  GetT0Shift() const                                        { return fT0Shift;                }
+          Float_t  GetRangeFitPRF() const                                    { return fRangeFitPRF;            }
+          Bool_t   GetMeanChargeOn() const                                   { return fMeanChargeOn;           }
+          Bool_t   GetAccCDB() const                                         { return fAccCDB;                 }
+          Bool_t   GetFitChargeBisOn() const                                 { return fFitChargeBisOn;         }
+          Int_t    GetMinEntries() const                                     { return fMinEntries;             }
+          Int_t    GetNumberFit() const                                      { return fNumberFit;              }
+         Int_t    GetNumberEnt() const                                      { return fNumberEnt;              }
+          Double_t GetStatisticMean() const                                  { return fStatisticMean;          }
   
   // Debug
-          void     SetDebug(Short_t debug)                                   { fDebug   = debug;   }
+          void     SetDebug(Short_t debug)                                   { fDebug   = debug;               }
           void     SetDet(Int_t iPlane, Int_t iChamb, Int_t iSect)           { fDet[0]  = iPlane; 
                                                                                fDet[1]  = iChamb; 
-                                                                               fDet[2]  = iSect;   }
-          void     SetFitVoir(Int_t fitVoir)                                 { fFitVoir = fitVoir; }
+                                                                               fDet[2]  = iSect;               }
+          void     SetFitVoir(Int_t fitVoir)                                 { fFitVoir = fitVoir;             }
   
-          Short_t  GetDebug() const                                          { return fDebug;      }
-          Int_t    GetDet(Int_t i) const                                     { return fDet[i];     }
-          Int_t    GetFitVoir() const                                        { return fFitVoir;    }
+          Short_t  GetDebug() const                                          { return fDebug;                  }
+          Int_t    GetDet(Int_t i) const                                     { return fDet[i];                 }
+          Int_t    GetFitVoir() const                                        { return fFitVoir;                }
 
   //
   // Internal variables to be sure!
   //
   
   // Pad calibration
-          Short_t  GetNnz(Int_t i) const                                     { return fNnZ[i];       }
-          Short_t  GetNnrphi(Int_t i) const                                  { return fNnRphi[i];    }
-          Short_t  GetNfragz(Int_t i) const                                  { return fNfragZ[i];    }
-          Short_t  GetNfragrphi(Int_t i) const                               { return fNfragRphi[i]; }
-          Short_t  GetDetChamb0(Int_t i) const                               { return fDetChamb0[i]; }
-          Short_t  GetDetChamb2(Int_t i) const                               { return fDetChamb2[i]; }
+          Short_t  GetNnz(Int_t i) const                                     { return fNnZ[i];                 }
+          Short_t  GetNnrphi(Int_t i) const                                  { return fNnRphi[i];              }
+          Short_t  GetNfragz(Int_t i) const                                  { return fNfragZ[i];              }
+          Short_t  GetNfragrphi(Int_t i) const                               { return fNfragRphi[i];           }
+          Short_t  GetDetChamb0(Int_t i) const                               { return fDetChamb0[i];           }
+          Short_t  GetDetChamb2(Int_t i) const                               { return fDetChamb2[i];           }
     
           void     SetRebin(Short_t rebin);
-          Short_t  GetRebin() const                                          { return fRebin;        }
+          Short_t  GetRebin() const                                          { return fRebin;                  }
 
   // Getter for the coefficient trees 
-          TTree   *GetPRF() const                                            { return fPRF;          }
-          TTree   *GetGain() const                                           { return fGain;         }
-          TTree   *GetT0() const                                             { return fT0;           }
-          TTree   *GetVdrift() const                                         { return fVdrift;       }
+          TTree   *GetPRF() const                                            { return fPRF;                    }
+          TTree   *GetGain() const                                           { return fGain;                   }
+          TTree   *GetT0() const                                             { return fT0;                     }
+          TTree   *GetVdrift() const                                         { return fVdrift;                 }
 
  private:
   
@@ -271,6 +273,7 @@ class AliTRDCalibra : public TObject {
           Float_t  fT0Shift;                // T0 Shift with the actual method
           Bool_t   fAccCDB;                 // If there is a calibration database to be compared with....
           Int_t    fNumberFit;              // To know how many pad groups have been fitted
+         Int_t    fNumberEnt;              // To know how many pad groups have entries in the histo
           Double_t fStatisticMean;          // To know the mean statistic of the histos
 
   // Debug Mode
diff --git a/TRD/AliTRDPreprocessor.cxx b/TRD/AliTRDPreprocessor.cxx
new file mode 100644 (file)
index 0000000..45c8bfd
--- /dev/null
@@ -0,0 +1,251 @@
+////////////////////////////////////////////////////////
+//
+// This class is a first implementation for the TRD.
+// It takes data from HLT and computes the parameters
+// and stores both reference data and online calibration parameters in the CDB 
+//
+/////////////////////////////////////////////////////////
+
+#include "AliTRDPreprocessor.h"
+
+#include <TTimeStamp.h>
+#include <TFile.h>
+#include <TProfile2D.h>
+#include <TH2I.h>
+#include <TStopwatch.h>
+#include <TObjString.h>
+#include <TString.h>
+#include <TList.h>
+#include <TCollection.h>
+
+#include "AliCDBMetaData.h"
+#include "AliDCSValue.h"
+#include "AliLog.h"
+
+#include "AliTRDCalibra.h"
+#include "Cal/AliTRDCalDet.h"
+
+
+ClassImp(AliTRDPreprocessor)
+
+//______________________________________________________________________________________________
+AliTRDPreprocessor::AliTRDPreprocessor(const Char_t *detector, AliShuttleInterface *shuttle)
+                   :AliPreprocessor(detector, shuttle)
+{
+  //
+  // Constructor
+  //
+
+}
+
+//______________________________________________________________________________________________
+AliTRDPreprocessor::~AliTRDPreprocessor()
+{
+  //
+  // Destructor
+  //
+
+}
+
+//______________________________________________________________________________________________
+void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
+{
+  //
+  // Initialization routine for the TRD preprocessor
+  //
+
+  AliPreprocessor::Initialize(run,startTime,endTime);
+
+}
+
+//______________________________________________________________________________________________
+UInt_t AliTRDPreprocessor::Process(TMap* /*dcsAliasMap*/)
+{
+  //
+  // Process the calibraion data for the HLT part
+  //
+
+  // How long does it take for the HLT part?
+  TStopwatch timer;
+  timer.Start();
+
+  // Metadata for the reference data
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(1);
+  metaData.SetResponsible("Raphaelle Bailhache");
+  metaData.SetComment("This preprocessor fills reference data.");
+
+
+  // Take the file from the HLT file exchange server
+  TList *filesources = GetFileSources(kHLT,"GAINDRIFTPRF");
+  if (!filesources) {
+    AliError(Form("No sources found for GAINDRIFTPRF for run %d !",fRun));
+    return 0;
+  }
+  if (filesources->GetSize() != 1) {
+    AliError(Form("More than one source found for GAINDRIFTPRF for run %d!",fRun));
+    return 0;
+  }
+
+  // Call a AliTRDCalibra instance for fit
+  AliTRDCalibra *calibra = AliTRDCalibra::Instance();
+
+  // Init some things
+  AliTRDCalDet *objgaindet          = 0x0; // Object for det average gain factor
+  AliTRDCalDet *objdriftvelocitydet = 0x0; // Object for det average drift velocity
+  AliTRDCalDet *objtime0det         = 0x0; // Object for det average time0 
+  TObject      *objgainpad          = 0x0; // Object for pad (relative to the det) gain factor
+  TObject      *objdriftvelocitypad = 0x0; // Object for pad (relative to the det) drift velocity
+  TObject      *objtime0pad         = 0x0; // Object for pad (relative to the det) time0
+  TObject      *objPRFpad           = 0x0; // Object for pad prf width
+  TH2I         *histogain           = 0x0; // Histogram taken from HLT for gain factor
+  TProfile2D   *histodriftvelocity  = 0x0; // Profile taken from HLT for drift velocity and time0
+  TProfile2D   *histoprf            = 0x0; // Profile taken from HLT for prf
+
+  Int_t    numberfit[3]        = { 0,   0,   0   }; // Number of histos fitted for gain, drift velocity and prf
+  Int_t    numberEnt[3]        = { 0,   0,   0   }; // Number of histos with entries
+  Double_t statisticmean[3]    = { 0.0, 0.0, 0.0 }; // Mean values of the number of entries in these histos
+  Int_t    numbertotalgroup[3] = { 0,   0,   0   }; // Total number of groups
+
+
+  // Loop over the files taken from the HLT/
+  TIter iter(filesources);
+  TObjString *source;
+  while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
+    
+    TString filename = GetFile(kHLT,"GAINDRIFTPRF",source->GetName());
+    if (!filename.Data()) {
+      AliError(Form("Error retrieving file from source %d failed!", source->GetName()));
+      delete filesources;
+      return 0;
+    }
+
+    // Take the histos
+    TFile *file = TFile::Open(filename);
+    histogain = (TH2I *) file->Get("CH2d");
+    histogain->SetDirectory(0);
+    if (!histogain) {
+      AliError("Error retrieving 2D histos for gain failed!");
+    }
+    histodriftvelocity = (TProfile2D *) file->Get("PH2d");
+    histodriftvelocity->SetDirectory(0);
+    if (!histodriftvelocity) {
+      AliError("Error retrieving 2D Profile for average pulse height failed!");
+    }
+    histoprf = (TProfile2D *) file->Get("PRF2d");
+    histoprf->SetDirectory(0);
+    if (!histoprf) {
+      AliError("Error retrieving 2D Profile for Pad Response Function failed!");
+    }
+    file->Close();
+
+    // Set the mode of calibration from the TObject, store the reference data and try to fit them
+    if (histogain) {
+      calibra->SetModeCalibrationFromTObject((TObject *) histogain,0);
+      Store("Data","Gain",(TObject *) histogain,&metaData,0,0);
+      AliInfo("Take the CH reference data. Now we will try to fit\n");
+      calibra->SetMinEntries(100); // If there is less than 100 entries in the histo: no fit
+      calibra->FitCHOnline(histogain);
+      numbertotalgroup[0] = 6*4*18*((Int_t) calibra->GetDetChamb0(0))
+                          + 6*  18*((Int_t) calibra->GetDetChamb2(0));
+      numberfit[0]        = calibra->GetNumberFit();
+      statisticmean[0]    = calibra->GetStatisticMean(); 
+      numberEnt[0]        = calibra->GetNumberEnt();
+      objgaindet          = calibra->CreateDetObjectTree(calibra->GetGain(),0);
+      objgainpad          = calibra->CreatePadObjectTree(calibra->GetGain(),0,objgaindet);
+    }
+    
+    if (histodriftvelocity) {
+      calibra->SetModeCalibrationFromTObject((TObject *) histodriftvelocity,1);
+      Store("Data","VdriftT0",(TObject *) histodriftvelocity,&metaData,0,0);
+      AliInfo("Take the PH reference data. Now we will try to fit\n");
+      calibra->SetMinEntries(100*20); // If there is less than 2000
+      calibra->FitPHOnline(histodriftvelocity);
+      numbertotalgroup[1] = 6*4*18*((Int_t) calibra->GetDetChamb0(1))
+                          + 6*  18*((Int_t) calibra->GetDetChamb2(1));
+      numberfit[1]        = calibra->GetNumberFit();
+      statisticmean[1]    = calibra->GetStatisticMean(); 
+      numberEnt[1]        = calibra->GetNumberEnt();
+      objdriftvelocitydet = calibra->CreateDetObjectTree(calibra->GetVdrift(),1);
+      objdriftvelocitypad = calibra->CreatePadObjectTree(calibra->GetVdrift(),1,objdriftvelocitydet);
+      objtime0det         = calibra->CreateDetObjectTree(calibra->GetT0(),3);
+      objtime0pad         = calibra->CreatePadObjectTree(calibra->GetT0(),3,objtime0det);
+    }
+    
+    if (histoprf) {
+      calibra->SetModeCalibrationFromTObject((TObject *) histoprf,2);
+      Store("Data","PRF",(TObject *) histoprf,&metaData,0,0);
+      AliInfo("Take the PRF reference data. Now we will try to fit\n");
+      calibra->SetMinEntries(100*20); // If there is less than 2000
+      calibra->SetRangeFitPRF(0.5);
+      calibra->FitPRFOnline(histoprf);
+      numbertotalgroup[2] = 6*4*18*((Int_t) calibra->GetDetChamb0(2))
+                          + 6*  18*((Int_t) calibra->GetDetChamb2(2));
+      numberfit[2]        = calibra->GetNumberFit();
+      statisticmean[2]    = calibra->GetStatisticMean(); 
+      numberEnt[2]        = calibra->GetNumberEnt();
+      objPRFpad           = calibra->CreatePadObjectTree(calibra->GetPRF());
+    }
+
+  }
+  
+  // Bilan of the fit statistic
+  AliInfo(Form("The mean number of entries required for a fit is: %d"
+              ,(Int_t) calibra->GetMinEntries()));
+  AliInfo(Form("FOR THE CH: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
+              ,statisticmean[0],numberfit[0],numbertotalgroup[0],numberEnt[0]));
+  AliInfo(Form("FOR THE PH: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
+              ,statisticmean[1],numberfit[1],numbertotalgroup[1],numberEnt[1]));
+  AliInfo(Form("FOR THE PRF: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
+              ,statisticmean[2],numberfit[2],numbertotalgroup[2],numberEnt[2]));
+  
+
+  //
+  // Store the coefficients in the grid OCDB if enough statistics
+  //
+  
+  // Store the infos for the detector
+  AliCDBMetaData *md1= new AliCDBMetaData(); 
+  md1->SetObjectClassName("AliTRDCalDet");
+  md1->SetResponsible("Raphaelle Bailhache");
+  md1->SetBeamPeriod(1);
+  md1->SetAliRootVersion("01-10-06"); // root version
+  md1->SetComment("The dummy values in this calibration file are for testing only");
+  if ((numbertotalgroup[0] >                  0) && 
+      (numberfit[0]        >= 0.95*numberEnt[0])) {
+    Store("Calib","ChamberGainFactor",(TObject *) objgaindet         ,md1,0,kTRUE);
+  }
+  if ((numbertotalgroup[1] >                  0) && 
+      (numberfit[1]        >= 0.95*numberEnt[1])) {
+    Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,md1,0,kTRUE);
+    Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,md1,0,kTRUE);
+  }
+  
+  // Store the infos for the pads
+  AliCDBMetaData *md2= new AliCDBMetaData(); 
+  md2->SetObjectClassName("AliTRDCalPad");
+  md2->SetResponsible("Raphaelle Bailhache");
+  md2->SetBeamPeriod(1);
+  md2->SetAliRootVersion("01-10-06"); //root version
+  md2->SetComment("The dummy values in this calibration file are for testing only");
+  if ((numbertotalgroup[0] >                  0) && 
+      (numberfit[0]        >= 0.95*numberEnt[0])) {
+    Store("Calib","LocalGainFactor"  ,(TObject *) objgainpad         ,md2,0,kTRUE);
+  }
+  if ((numbertotalgroup[1] >                  0) && 
+      (numberfit[1]        >= 0.95*numberEnt[1])) {
+    Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,md2,0,kTRUE);
+    Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,md2,0,kTRUE);
+  }
+  if ((numbertotalgroup[2] >                  0) && 
+      (numberfit[2]        >= 0.95*numberEnt[2])) {
+    Store("Calib","PRFWidth"         ,(TObject *) objPRFpad          ,md2,0,kTRUE);
+  }
+  
+  // End
+  delete filesources;
+  timer.Stop();
+  timer.Print();
+  return 1;  
+
+}
diff --git a/TRD/AliTRDPreprocessor.h b/TRD/AliTRDPreprocessor.h
new file mode 100644 (file)
index 0000000..5082f68
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef ALI_TRD_PREPROCESSOR_H
+#define ALI_TRD_PREPROCESSOR_H
+
+#include "AliPreprocessor.h"
+
+/////////////////////////////////////////////////////
+//
+// TRD preprocessor
+//
+//////////////////////////////////////////////////
+
+class AliTRDPreprocessor : public AliPreprocessor
+{
+
+  public:
+
+    AliTRDPreprocessor(const Char_t *detector, AliShuttleInterface *shuttle);
+    virtual ~AliTRDPreprocessor();
+
+  protected:
+
+    virtual void   Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
+    virtual UInt_t Process(TMap* /*dcsAliasMap*/);
+
+  private:
+    
+    ClassDef(AliTRDPreprocessor,0);
+
+};
+
+#endif
index c35ce28..d0759af 100644 (file)
@@ -44,6 +44,7 @@
 #pragma link C++ class  AliTRDCalSingleChamberStatus+;
 
 #pragma link C++ class  AliTRDCalibra+;
+#pragma link C++ class  AliTRDPreprocessor+;
 
 #pragma link C++ class  AliTRDTriggerL1+;
 #pragma link C++ class  AliTRDtrigger+;
index a8f5ac2..013f63c 100644 (file)
@@ -26,6 +26,7 @@ SRCS= AliTRDarrayI.cxx \
       Cal/AliTRDCalPadStatus.cxx \
       Cal/AliTRDCalSingleChamberStatus.cxx \
       AliTRDCalibra.cxx \
+      AliTRDPreprocessor.cxx \
       AliTRDTriggerL1.cxx \
       AliTRDmcmTracklet.cxx \
       AliTRDmcm.cxx \