]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
First fix for the exb calibration.
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 16 Oct 2011 16:46:56 +0000 (16:46 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 16 Oct 2011 16:46:56 +0000 (16:46 +0000)
TRD/AliTRDCalibraFit.cxx
TRD/AliTRDCalibraFit.h
TRD/AliTRDPreprocessorOffline.cxx
TRD/AliTRDPreprocessorOffline.h

index ba002ed07628a7645064dcf90225a18d304be2cd..873a76fec554fff4a9050d94c1aa0f1e83237c3d 100644 (file)
@@ -159,6 +159,8 @@ AliTRDCalibraFit::AliTRDCalibraFit()
   ,fCalROC(0x0)
   ,fCalDet2(0x0)
   ,fCalROC2(0x0)
+  ,fCalDetVdriftUsed(0x0)
+  ,fCalDetExBUsed(0x0)
   ,fCurrentCoefDetector(0x0)
   ,fCurrentCoefDetector2(0x0)
   ,fVectorFit(0)
@@ -219,6 +221,8 @@ AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c)
 ,fCalROC(0x0)
 ,fCalDet2(0x0)
 ,fCalROC2(0x0)
+,fCalDetVdriftUsed(0x0)
+,fCalDetExBUsed(0x0)
 ,fCurrentCoefDetector(0x0)
 ,fCurrentCoefDetector2(0x0)
 ,fVectorFit(0)
@@ -245,6 +249,9 @@ AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c)
   if(c.fCalROC) fCalROC   = new AliTRDCalROC(*c.fCalROC);
   if(c.fCalROC2) fCalROC  = new AliTRDCalROC(*c.fCalROC2);
 
+  if(c.fCalDetVdriftUsed) fCalDetVdriftUsed = new AliTRDCalDet(*c.fCalDetVdriftUsed);
+  if(c.fCalDetExBUsed)    fCalDetExBUsed = new AliTRDCalDet(*c.fCalDetExBUsed);
+
   fVectorFit.SetName(c.fVectorFit.GetName());
   for(Int_t k = 0; k < c.fVectorFit.GetEntriesFast(); k++){
     AliTRDFitInfo *fitInfo = new AliTRDFitInfo();
@@ -300,6 +307,8 @@ AliTRDCalibraFit::~AliTRDCalibraFit()
   if ( fCalDet2 ) delete fCalDet2;
   if ( fCalROC )  delete fCalROC;
   if ( fCalROC2 ) delete fCalROC2;
+  if ( fCalDetVdriftUsed)  delete fCalDetVdriftUsed;
+  if ( fCalDetExBUsed) delete fCalDetExBUsed;
   if( fCurrentCoefDetector ) delete [] fCurrentCoefDetector;
   if( fCurrentCoefDetector2 ) delete [] fCurrentCoefDetector2; 
   fVectorFit.Delete();
@@ -1245,6 +1254,7 @@ Bool_t AliTRDCalibraFit::AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *cali
 
     // CalculDatabaseVdriftandTan
     CalculVdriftLorentzCoef();
+    //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFit detector %d, vdrift %f and %f and exB %f and %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCurrentCoef[1],fCalDetExBUsed->GetValue(idet),fCurrentCoef2[1]);
 
     // Statistics   
     fNumberFitSuccess ++;
@@ -1277,12 +1287,22 @@ Bool_t AliTRDCalibraFit::AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *cali
   
 }
 //____________Functions fit Online CH2d________________________________________
-Double_t AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli)
+void AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall)
 {
   //
   // The linear method
   //
 
+  // Get the mean vdrift and exb used
+  Double_t meanvdriftused = 0.0;
+  Double_t meanexbused = 0.0;
+  Double_t counterdet = 0.0;
+  if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) {
+    vdriftoverall = -100.0;
+    exboverall = 100.0;
+    return;
+  }  
+
   // Add histos
 
   TH2S *linearfitterhisto = 0x0;
@@ -1290,10 +1310,31 @@ Double_t AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLi
   for(Int_t idet = 0; idet < 540; idet++){
     
     TH2S * u = calivdli->GetLinearFitterHistoForce(idet);
+    Double_t detectorentries = u->Integral();
+    meanvdriftused += fCalDetVdriftUsed->GetValue(idet)*detectorentries;
+    meanexbused += fCalDetExBUsed->GetValue(idet)*detectorentries;
+    counterdet += detectorentries;
+
+    //printf("detectorentries %f\n",detectorentries);
+    
+    //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether detector %d, vdrift %f and exB %f\n",idet,fCalDetVdriftUsed->GetValue(idet),fCalDetExBUsed->GetValue(idet));
+
     if(idet == 0) linearfitterhisto = u;
     else linearfitterhisto->Add(u);
 
   }
+  if(counterdet > 0.0){
+    meanvdriftused = meanvdriftused/counterdet;
+    meanexbused = meanexbused/counterdet;    
+  }
+  else {
+    vdriftoverall = -100.0;
+    exboverall = 100.0;
+    return;
+  }
+  
+  
+  //printf("AliTRDCalibraFit::AnalyzeVdriftLinearFitsAllTogether MEAN vdrift %f and exB %f\n",meanvdriftused,meanexbused);
 
   // Fit
 
@@ -1332,7 +1373,9 @@ Double_t AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLi
   //printf("AnalyseLinearFittersAllTogether::Find %d entries\n",entries);
   //printf("Minstats %d\n",fMinEntries);
 
-      // Eval the linear fitter
+  
+
+  // Eval the linear fitter
   if(entries > fMinEntries){
     TVectorD  par  = TVectorD(2);
     //printf("Fit\n");
@@ -1340,23 +1383,35 @@ Double_t AliTRDCalibraFit::AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLi
       //printf("Take the param\n");
       linearfitter.GetParameters(par);
       //printf("Done\n");
-      par.Print();
+      //par.Print();
       //printf("Finish\n");
       // Put the fCurrentCoef
       fCurrentCoef[0]  = -par[1];
       // here the database must be the one of the reconstruction for the lorentz angle....
-      fCurrentCoef2[0] = (par[0]+fCurrentCoef[1]*fCurrentCoef2[1])/fCurrentCoef[0];
+      if(fCurrentCoef[0] > 0.0) fCurrentCoef2[0] = (par[0]+meanvdriftused*meanexbused)/fCurrentCoef[0];
+      else fCurrentCoef2[0] = 100.0;      
+
+    }
+    else {
+      
+      fCurrentCoef[0] = -100.0;
+      fCurrentCoef2[0] = 100.0;
       
-      return fCurrentCoef[0];
     }
-    else return -100.0;
     
     
   }
   else {
-    return -100.0;
+
+    fCurrentCoef[0] = -100.0;
+    fCurrentCoef2[0] = 100.0;
+    
   }
   
+  vdriftoverall = fCurrentCoef[0];
+  exboverall = fCurrentCoef2[0];
+  
+
   delete linearfitterhisto;
   delete fDebugStreamer;
   fDebugStreamer = 0x0;
@@ -2015,11 +2070,11 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec
       for (Int_t col = 0; col < colMax; col++) {
        value = coef[(Int_t)(col*rowMax+row)];
        if(value > 70.0) {
-         if((ofwhat == 0) && (meanAll > -1.5) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
+         if((ofwhat == 0) && (meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
          if(ofwhat == 1){
-           if((meanDetector[detector] > -1.5) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0;
-           else if((meanSupermodule[sector] > -1.5) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0;
-           else if((meanAll > -1.5) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
+           if((meanDetector[detector] > -3.0) && (countDetector[detector] > 20)) coef[(Int_t)(col*rowMax+row)] = meanDetector[detector]+100.0;
+           else if((meanSupermodule[sector] > -3.0) && (countSupermodule[sector] > 15)) coef[(Int_t)(col*rowMax+row)] = meanSupermodule[sector]+100.0;
+           else if((meanAll > -3.0) && (countAll > 15)) coef[(Int_t)(col*rowMax+row)] = meanAll+100.0;
          }  
        }
        // Debug
@@ -2224,7 +2279,8 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(const TObjArray *vec
       if(count > 0) mean = mean/count;
     */
     value = ((AliTRDFitInfo *) vectorFit->At(k))->GetCoef()[0];
-    object->SetValue(detector,-TMath::Abs(value));
+    if(value > 70.0) value = value-100.0;
+    object->SetValue(detector,value);
   }
 
   return object;
@@ -2844,45 +2900,10 @@ Bool_t AliTRDCalibraFit::InitFitLinearFitter()
     fCurrentCoefDetector2[k] = 0.0;    
   }
 
-  //printf("test0\n");
-  
-  AliTRDcalibDB     *cal    = AliTRDcalibDB::Instance();
-  if (!cal) {
-    AliInfo("Could not get calibDB");
-    return kFALSE;
-  }
-  
-  //Get the CalDet object
-  if(fAccCDB){
-    if(fCalDet) delete fCalDet;
-    if(fCalDet2) delete fCalDet2;
-    fCalDet  = new AliTRDCalDet(*(cal->GetVdriftDet()));
-    //printf("test1\n");
-    fCalDet2 = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
-    //printf("test2\n");
-    for(Int_t k = 0; k < 540; k++){
-      fCalDet2->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDet->GetValue(k)));
-    }
-    //printf("test3\n");
-  }
-  else{
-    Float_t devalue  = 1.5;
-    Float_t devalue2 = AliTRDCommonParam::Instance()->GetOmegaTau(1.5); 
-    if(fCalDet) delete fCalDet;
-    if(fCalDet2) delete fCalDet2;
-    //printf("test1\n");
-    fCalDet  = new AliTRDCalDet("ChamberVdrift","TRD drift velocities (detector value)");
-    fCalDet2 = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
-    //printf("test2\n");
-    for(Int_t k = 0; k < 540; k++){
-      fCalDet->SetValue(k,devalue);
-      fCalDet2->SetValue(k,devalue2);
-    }
-    //printf("test3\n");
-  }
+  if((!fCalDetVdriftUsed) || (!fCalDetExBUsed)) return kFALSE; 
+
   return kTRUE;
 }
-
 //____________Functions for initialising the AliTRDCalibraFit in the code_________
 void AliTRDCalibraFit::InitfCountDetAndfCount(Int_t i)
 {
@@ -3060,8 +3081,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticCH(Int_t idect)
   else if (fNbDet > 0){
     Int_t firstdetector = fCountDet;
     Int_t lastdetector  = fCountDet+fNbDet;
-    AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted"
-                ,idect,firstdetector,lastdetector));
+    //AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector));
     // loop over detectors
     for(Int_t det = firstdetector; det < lastdetector; det++){
 
@@ -3142,8 +3162,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticCH(Int_t idect)
   }
   else {
 
-    AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted"
-                ,idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))),fCountDet));
+//AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))),fCountDet));
     
     // Calcul the coef from the database choosen
     CalculChargeCoefMean(kFALSE);
@@ -3186,8 +3205,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticPH(Int_t idect,Double_t nentries)
 
     Int_t firstdetector = fCountDet;
     Int_t lastdetector  = fCountDet+fNbDet;
-    AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted"
-                ,idect,firstdetector,lastdetector));
+//AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector));
     // loop over detectors
     for(Int_t det = firstdetector; det < lastdetector; det++){
 
@@ -3283,8 +3301,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticPH(Int_t idect,Double_t nentries)
   }    
   else {
 
-    AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted"
-                ,idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))),fCountDet));
+//AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))),fCountDet));
 
     CalculVdriftCoefMean();
     CalculT0CoefMean();
@@ -3334,8 +3351,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticPRF(Int_t idect)
   
     Int_t firstdetector = fCountDet;
     Int_t lastdetector  = fCountDet+fNbDet;
-    AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted"
-                ,idect,firstdetector,lastdetector));
+//  AliInfo(Form("The element %d containing the detectors %d to %d has not enough statistic to be fitted",idect,firstdetector,lastdetector));
     
     // loop over detectors
     for(Int_t det = firstdetector; det < lastdetector; det++){
@@ -3418,8 +3434,7 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticPRF(Int_t idect)
   }
   else {
     
-    AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted"
-                ,idect-(fCount-(fCalibraMode->GetNfragZ(2)*fCalibraMode->GetNfragRphi(2))),fCountDet));
+//  AliInfo(Form("The element %d in this detector %d has not enough statistic to be fitted",idect-(fCount-(fCalibraMode->GetNfragZ(2)*fCalibraMode->GetNfragRphi(2))),fCountDet));
     
     CalculPRFCoefMean();
     
@@ -3467,14 +3482,14 @@ Bool_t AliTRDCalibraFit::NotEnoughStatisticLinearFitter()
   for (Int_t k = 0; k < factor; k++) {
     fCurrentCoefDetector[k] = -TMath::Abs(fCurrentCoef[1]);
     // should be negative
-    fCurrentCoefDetector2[k] = +TMath::Abs(fCurrentCoef2[1]);
+    fCurrentCoefDetector2[k] = fCurrentCoef2[1]+100.0;
   }
    
   
-  //Put default opposite sign
+  //Put default opposite sign only for vdrift
   fCurrentCoef[0]  = -TMath::Abs(fCurrentCoef[1]);
   fCurrentCoefE    = 0.0;
-  fCurrentCoef2[0] = +TMath::Abs(fCurrentCoef2[1]);
+  fCurrentCoef2[0] = fCurrentCoef2[1]+100.0;
   fCurrentCoefE2 = 0.0; 
   
   FillFillLinearFitter();
@@ -3494,8 +3509,7 @@ Bool_t AliTRDCalibraFit::FillInfosFitCH(Int_t idect)
     if (fNbDet > 0){
       Int_t firstdetector = fCountDet;
       Int_t lastdetector  = fCountDet+fNbDet;
-      AliInfo(Form("The element %d containing the detectors %d to %d has been fitted"
-                  ,idect,firstdetector,lastdetector));
+      //    AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector));
       // loop over detectors
       for(Int_t det = firstdetector; det < lastdetector; det++){
        
@@ -3606,8 +3620,7 @@ Bool_t AliTRDCalibraFit::FillInfosFitPH(Int_t idect,Double_t nentries)
       
       Int_t firstdetector = fCountDet;
       Int_t lastdetector  = fCountDet+fNbDet;
-      AliInfo(Form("The element %d containing the detectors %d to %d has been fitted"
-                  ,idect,firstdetector,lastdetector));
+// AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector));
       
       // loop over detectors
       for(Int_t det = firstdetector; det < lastdetector; det++){
@@ -3736,8 +3749,7 @@ Bool_t AliTRDCalibraFit::FillInfosFitPRF(Int_t idect)
     
       Int_t firstdetector = fCountDet;
       Int_t lastdetector  = fCountDet+fNbDet;
-      AliInfo(Form("The element %d containing the detectors %d to %d has been fitted"
-                  ,idect,firstdetector,lastdetector));
+//    AliInfo(Form("The element %d containing the detectors %d to %d has been fitted",idect,firstdetector,lastdetector));
       
       // loop over detectors
       for(Int_t det = firstdetector; det < lastdetector; det++){
@@ -4209,8 +4221,8 @@ Bool_t AliTRDCalibraFit::CalculVdriftLorentzCoef()
   // For the detector fCountDet, mean drift velocity and tan lorentzangle
   //
 
-  fCurrentCoef[1]  = fCalDet->GetValue(fCountDet);
-  fCurrentCoef2[1] = fCalDet2->GetValue(fCountDet); 
+  fCurrentCoef[1]  = fCalDetVdriftUsed->GetValue(fCountDet);
+  fCurrentCoef2[1] = fCalDetExBUsed->GetValue(fCountDet); 
 
   return kTRUE;
 }
index 4c27c5f27148863447b720159afcace6e4afa2a2..e4ba42d0a972af4ff783dcf37a3d43e117c94aa4 100644 (file)
@@ -56,6 +56,9 @@ class AliTRDCalibraFit : public TObject {
 
   // Function for integration range of the charge 
   void     RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const;
+
+  // ExB calibration
+  void     SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;};
   
   // Functions fit for CH
   Bool_t   AnalyseCH(const TH2I *ch);
@@ -76,7 +79,7 @@ class AliTRDCalibraFit : public TObject {
   
   // Functions fit for vdrift/lorentzangle
   Bool_t   AnalyseLinearFitters(AliTRDCalibraVdriftLinearFit *calivdli);
-  Double_t AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli);
+  void     AnalyseLinearFittersAllTogether(AliTRDCalibraVdriftLinearFit *calivdli, Double_t &vdriftoverall, Double_t &exboverall);
   
   // Pad Calibration
   Bool_t   SetModeCalibration(TString name, Int_t i);
@@ -251,6 +254,9 @@ class AliTRDCalibraFit : public TObject {
        AliTRDCalROC *fCalROC;            // Current calib object
        AliTRDCalDet *fCalDet2;           // Current calib object
        AliTRDCalROC *fCalROC2;           // Current calib object
+
+       AliTRDCalDet *fCalDetVdriftUsed;  // ExB calibration
+       AliTRDCalDet *fCalDetExBUsed;     // ExB calibration
        
        // Current values detector
        
index 00b43745ff2999e0ba47d6b09868a7d758273bcb..b33b5ccfeca976ba2fbbee9bf678d854243398cf 100644 (file)
@@ -59,6 +59,7 @@
 #include "AliTRDCalibraVdriftLinearFit.h"
 #include "AliTRDPreprocessorOffline.h"
 #include "AliTRDCalChamberStatus.h"
+#include "AliTRDCommonParam.h"
 
 
 ClassImp(AliTRDPreprocessorOffline)
@@ -69,6 +70,7 @@ ClassImp(AliTRDPreprocessorOffline)
   fNameList("TRDCalib"),
   fCalDetGainUsed(0x0),
   fCalDetVdriftUsed(0x0),
+  fCalDetExBUsed(0x0),
   fCH2d(0x0),
   fPH2d(0x0),
   fPRF2d(0x0),
@@ -84,6 +86,7 @@ ClassImp(AliTRDPreprocessorOffline)
   fSubVersionVdriftUsed(0),
   fSwitchOnValidation(kTRUE),
   fVdriftValidated(kFALSE),
+  fExBValidated(kFALSE),
   fT0Validated(kFALSE),
   fMinStatsVdriftT0PH(800*20),
   fMinStatsVdriftLinear(800),
@@ -108,6 +111,7 @@ AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() {
 
   if(fCalDetGainUsed) delete fCalDetGainUsed;
   if(fCalDetVdriftUsed) delete fCalDetVdriftUsed;
+  if(fCalDetExBUsed) delete fCalDetExBUsed;
   if(fCH2d) delete fCH2d;
   if(fPH2d) delete fPH2d;
   if(fPRF2d) delete fPRF2d;
@@ -134,11 +138,12 @@ void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRun
   //
   fVdriftValidated = kTRUE;
   fT0Validated = kTRUE;
+  fExBValidated = kTRUE;
   fNotEnoughStatisticsForTheVdriftLinear = kFALSE;
   //
   // 2. extraction of the information
   //
-  if(ReadVdriftLinearFitGlobal(file)) AnalyzeVdriftLinearFit();
+  if(ReadVdriftLinearFitGlobal(file) && fCalDetVdriftUsed && fCalDetExBUsed) AnalyzeVdriftLinearFit();
   if(ReadVdriftT0Global(file)) AnalyzeVdriftT0();
   //
   // 3. Append QA plots
@@ -156,13 +161,17 @@ void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRun
     //AliError("TRD t0 OCDB parameters out of range!");
     fT0Validated = kFALSE;
   }
+  if(fSwitchOnValidation==kTRUE && ValidateExB()==kFALSE) { 
+    //AliError("TRD t0 OCDB parameters out of range!");
+    fExBValidated = kFALSE;
+  }
   //
   // 5. update of OCDB
   //
   //
   if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage);
   if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage);
-  UpdateOCDBExB(startRunNumber,endRunNumber,ocdbStorage);
+  if(fExBValidated) UpdateOCDBExB(startRunNumber,endRunNumber,ocdbStorage);
   
 }
 //_________________________________________________________________________________________________________________
@@ -311,7 +320,7 @@ Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){
    
   if(fVersionVdriftUsed == 0) fStatusPos = fStatusPos |kVdriftErrorOld;
   if(fVersionGainUsed == 0) fStatusPos = fStatusPos | kGainErrorOld;
-
   return kTRUE;
   
 }
@@ -541,6 +550,7 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){
     ok = kTRUE;
   }
   else {
+    //printf("Not enough stats timeoffset\n");
     fStatusNeg = fStatusNeg | kTimeOffsetNotEnoughStatsNotFill;
   }
   calibra->ResetVectorFit();
@@ -558,6 +568,7 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){
 
   
   AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
+  calibra->SetCalDetVdriftExB(fCalDetVdriftUsed,fCalDetExBUsed);
   calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
   //printf("Fill PE Array\n");
   fAliTRDCalibraVdriftLinearFit->FillPEArray();
@@ -598,30 +609,41 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){
     fNotEnoughStatisticsForTheVdriftLinear = kTRUE;
     Int_t minNumberOfEntriesForAll = fMinStatsVdriftLinear*30;
     calibra->SetMinEntries(minNumberOfEntriesForAll); // Because we do it for all, we increase this
-    Double_t vdriftoverall =  calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit);
-    if(fCalDetVdriftUsed && (vdriftoverall > 0.0)) {
+    Double_t vdriftoverall = -100.0;
+    Double_t exboverall = 100.0;
+    calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit,vdriftoverall,exboverall);
+    //printf("Found mean vdrift %f and exb %f\n",vdriftoverall,exboverall);
+    if(fCalDetVdriftUsed && (vdriftoverall > 0.0) && (exboverall < 70.0)) {
       AliTRDCalDet *calDetVdrift = new AliTRDCalDet(*fCalDetVdriftUsed);
-      Double_t oldmean = fCalDetVdriftUsed->CalcMean(kFALSE);
+      AliTRDCalDet *calDetLorentz = new AliTRDCalDet(*fCalDetExBUsed);
+      Double_t oldmeanvdrift = fCalDetVdriftUsed->CalcMean(kFALSE);
+      Double_t oldmeanexb = fCalDetExBUsed->CalcMean(kFALSE);
       //printf("oldmean %f\n",oldmean);
-      if(oldmean > 0.0)  {
+      if((oldmeanvdrift > 0.0) && (oldmeanexb < 70.0))  {
        //printf("Correction factor %f\n",vdriftoverall);
-       calDetVdrift->Multiply(vdriftoverall/oldmean);
+       calDetVdrift->Multiply(vdriftoverall/oldmeanvdrift);
+       calDetLorentz->Multiply(exboverall/oldmeanexb);
        //printf("newmean %f\n",calDetVdrift->CalcMean(kFALSE));
        TH1F *coefDriftLinear  = calDetVdrift->MakeHisto1DAsFunctionOfDet();
+       TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
        // Put them in the array
        fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
+       fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
        fPlots->AddAt(coefDriftLinear,kVdriftLinear);
+       fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
        // 
        ok = kTRUE;
        fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsButFill;
       }
       else {
-       fStatusPos = fStatusPos | kVdriftErrorOld;
+       if(oldmeanvdrift) fStatusPos = fStatusPos | kVdriftErrorOld;
+       if(oldmeanexb) fStatusPos = fStatusPos | kExBErrorOld;
       }      
     }
     else {
-      if(vdriftoverall <= 0.0) fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsNotFill;
+      if((vdriftoverall <= 0.0) && (exboverall > 70.0)) fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsNotFill;
       if(!fCalDetVdriftUsed) fStatusPos = fStatusPos | kVdriftErrorOld;
+      if(!fCalDetExBUsed) fStatusPos = fStatusPos | kExBErrorOld;
     }
   }
   
@@ -682,22 +704,26 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus()
   // get calibration objects
   AliTRDCalDet *calDetGain   = (AliTRDCalDet *) fCalibObjects->At(kGain);
   AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear);
+  AliTRDCalDet *calDetExB    = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
 
   // Check
-  if((!calDetGain) || (!calDetVDrift) || (!fCH2d)) return kFALSE;
+  if((!calDetGain) || (!calDetVDrift) || (!fCH2d) || (!calDetExB)) return kFALSE;
 
   // Gain
   Double_t gainmean = calDetGain->GetMean();
   Double_t vdriftmean = calDetVDrift->GetMean();
+  Double_t exbmean = calDetExB->GetMean();
 
   Double_t gainrms = calDetGain->GetRMSRobust();
   Double_t vdriftrms = calDetVDrift->GetRMSRobust();
+  Double_t exbrms = calDetExB->GetRMSRobust();
 
   //printf("Gain mean: %f, rms: %f\n",gainmean,gainrms);
   //printf("Vdrift mean: %f, rms: %f\n",vdriftmean,vdriftrms);
-  
+  //printf("ExB mean: %f, rms: %f\n",exbmean,exbrms);
+
   // Check
-  if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001)) return kFALSE;
+  if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001) || (TMath::Abs(exbrms) < 0.0000001)) return kFALSE;
 
   // mask chambers with empty gain entries
   //Int_t counter = 0;
@@ -713,14 +739,20 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus()
     // vdrift
     Double_t vdrift = calDetVDrift->GetValue(idet);
 
+    // exb
+    Double_t exb = calDetExB->GetValue(idet);
+
 
     if(entries<=0.5 ||
        TMath::Abs(gainmean-gain) > (15.0*gainrms) ||
-       TMath::Abs(vdriftmean-vdrift) > (15.0*vdriftrms)) {
+       TMath::Abs(vdriftmean-vdrift) > (15.0*vdriftrms) ||
+       TMath::Abs(exbmean-exb) > (50.0*exbrms)) {
      
       //printf(" chamber det %03d masked \n",idet);
       //printf(" gainmean %f and gain %f, gainrms %f \n",gainmean,gain,gainrms);
       //printf(" vdriftmean %f and vdrift %f, vdriftrms %f \n",vdriftmean,vdrift,vdriftrms);
+      //printf(" exbmean %f and exb %f, exbrms %f \n",exbmean,exb,exbrms);
+      
       CalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kMasked);
       //counter++;
     }
@@ -1056,6 +1088,26 @@ Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus()
 
    return ok;
 
+ }
+ //__________________________________________________________________________________________________________________________
+ Bool_t AliTRDPreprocessorOffline::ValidateExB(){
+   //
+   // Update OCDB entry
+   //
+
+   AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
+   if(calDet) {
+     Double_t mean = calDet->GetMean();
+     Double_t rms = calDet->GetRMSRobust();
+     //printf("Vdrift::mean %f, rms %f\n",mean,rms);
+     if(!((mean > -1.0) && (mean < 1.0) && (rms < 0.5))) {
+       fStatusNeg = fStatusNeg | kExBErrorRange;
+       return kFALSE;
+     }
+     else return kTRUE;
+   }
+   else return kFALSE; 
+   
  }
  //__________________________________________________________________________________________________________________________
  Bool_t AliTRDPreprocessorOffline::ValidateT0(){
@@ -1256,7 +1308,23 @@ void AliTRDPreprocessorOffline::PrintStatus() const
   AliInfo(Form("IsGainNotEnoughStatsNotFill? %d",(Int_t)IsGainNotEnoughStatsNotFill()));
   AliInfo(Form("IsVdriftNotEnoughStatsNotFill? %d",(Int_t)IsVdriftNotEnoughStatsNotFill()));
   AliInfo(Form("IsTimeOffsetNotEnoughStatsNotFill? %d",(Int_t)IsTimeOffsetNotEnoughStatsNotFill()));
+
+  AliInfo(Form("IsExBErrorRange? %d",(Int_t)IsExBErrorRange()));
+  AliInfo(Form("IsExBErrorOld? %d",(Int_t)IsExBErrorOld()));
   
 }
+//___________________________________________________________________________________
+void AliTRDPreprocessorOffline::SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed) 
+{
+
+  fCalDetVdriftUsed = calDetVdriftUsed;
+
+  fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
+  for(Int_t k = 0; k < 540; k++){
+    fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
+    //printf("Set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
+  }
+  
+};
 
 
index 6ce41bdc58f19e074e7d7d0441df992a770ec416..bd99d08b663541a72ced5921d81323ca8d19132b 100644 (file)
@@ -35,8 +35,19 @@ public:
       kChamberStatus = 7,
       kPRF = 8
       };   
-  enum { kGainNotEnoughStatsButFill = 2, kVdriftNotEnoughStatsButFill = 4, kGainNotEnoughStatsNotFill = 8, kVdriftNotEnoughStatsNotFill = 16, kTimeOffsetNotEnoughStatsNotFill = 32};  
-  enum { kGainErrorOld = 2, kVdriftErrorOld = 4, kGainErrorRange = 8, kVdriftErrorRange = 16, kTimeOffsetErrorRange = 32, kChamberStatusErrorRange = 64};  
+  enum { kGainNotEnoughStatsButFill = 2,
+        kVdriftNotEnoughStatsButFill = 4,
+        kGainNotEnoughStatsNotFill = 8,
+        kVdriftNotEnoughStatsNotFill = 16,
+        kTimeOffsetNotEnoughStatsNotFill = 32,
+        kExBErrorRange = 64};  
+  enum { kGainErrorOld = 2,
+        kVdriftErrorOld = 4,
+        kExBErrorOld = 8,
+        kGainErrorRange = 16,
+        kVdriftErrorRange = 32,
+        kTimeOffsetErrorRange = 64,
+        kChamberStatusErrorRange = 128};  
 
 
   AliTRDPreprocessorOffline();
@@ -51,12 +62,16 @@ public:
   Bool_t      IsVdriftNotEnoughStatsNotFill() const 
     { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsNotFill);  };
   Bool_t      IsTimeOffsetNotEnoughStatsNotFill() const 
-    { return CheckStatus(fStatusNeg, kVdriftNotEnoughStatsNotFill);  };
+    { return CheckStatus(fStatusNeg, kTimeOffsetNotEnoughStatsNotFill);  };
+  Bool_t      IsExBErrorRange() const 
+    { return CheckStatus(fStatusNeg, kExBErrorRange);  };
   
   Bool_t      IsGainErrorOld() const 
     { return CheckStatus(fStatusPos, kGainErrorOld);  };
   Bool_t      IsVdriftErrorOld() const 
     { return CheckStatus(fStatusPos, kVdriftErrorOld);  };
+  Bool_t      IsExBErrorOld() const 
+    { return CheckStatus(fStatusPos, kExBErrorOld);  };
   Bool_t      IsGainErrorRange() const 
     { return CheckStatus(fStatusPos, kGainErrorRange);  };
   Bool_t      IsVdriftErrorRange() const 
@@ -75,7 +90,8 @@ public:
   void SetNameList(TString nameList) { fNameList = nameList;};
   TString GetNameList() const { return fNameList;}; 
   void SetCalDetGain(AliTRDCalDet *calDetGainUsed) {fCalDetGainUsed = calDetGainUsed;};
-  void SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed) {fCalDetVdriftUsed = calDetVdriftUsed;};
+  void SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed);
+  void SetCalDetVdriftExB(AliTRDCalDet *calDetVdriftUsed,AliTRDCalDet *calDetExBUsed) {fCalDetVdriftUsed = calDetVdriftUsed; fCalDetExBUsed = calDetExBUsed;};
   void SetSwitchOnValidation(Bool_t switchOnValidation) {fSwitchOnValidation = switchOnValidation;};
   AliTRDCalDet *GetCalDetGain() const { return fCalDetGainUsed;};
   AliTRDCalDet *GetCalDetVdrift() const { return fCalDetVdriftUsed;};
@@ -110,6 +126,7 @@ public:
 
   Bool_t ValidateGain();
   Bool_t ValidateVdrift();
+  Bool_t ValidateExB();
   Bool_t ValidateT0();
   Bool_t ValidatePRF() const;
   Bool_t ValidateChamberStatus();
@@ -137,6 +154,7 @@ public:
   TString fNameList;                         // Name of the list
   AliTRDCalDet *fCalDetGainUsed;             // CalDet used and to be corrected for
   AliTRDCalDet *fCalDetVdriftUsed;           // CalDet used and to be corrected for
+  AliTRDCalDet *fCalDetExBUsed;              // CalDet used and to be corrected for
   TH2I *fCH2d;                               // Gain
   TProfile2D *fPH2d;                         // Drift velocity first method
   TProfile2D *fPRF2d;                        // PRF
@@ -152,6 +170,7 @@ public:
   Int_t    fSubVersionVdriftUsed;         // SubVersionVdriftUsed
   Bool_t   fSwitchOnValidation;           // Validation
   Bool_t   fVdriftValidated;              // Vdrift validation
+  Bool_t   fExBValidated;                 // ExB validation
   Bool_t   fT0Validated;                  // T0 validation
   Int_t    fMinStatsVdriftT0PH;           // MinStats VdriftT0
   Int_t    fMinStatsVdriftLinear;         // MinStats Vdrift Linear