]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
M AliTPCcalibBase.h - SetRun function
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jun 2010 11:28:37 +0000 (11:28 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jun 2010 11:28:37 +0000 (11:28 +0000)
M      AliTPCcalibDB.h                 - Adding array of composed correction - for differnt Bfield
M      AliTPCcalibTime.h               - Matchinch hostograms for TOF

M      AliTPCcalibAlign.cxx            - reducing the size of the THnSparse for clusters residual
M      AliTPCcalibDB.cxx               - Adding array of composed corrections
M      AliTPCcalibLaser.cxx            - calculating mean of variables - gaus fit problem if few entries
M      AliTPCcalibTime.cxx             - adding TOF matching histo
M      AliTPCComposedCorrection.cxx    - Print name and title before only title
M      AliTPCCorrection.cxx            - exporting curvature not 1/pt
M      AliTPCkalmanAlign.cxx           - fixes in the CE fitting
M      AliTPCTransform.cxx             - Using composed correction for different B field setting

  CalibMacros/MakeLookup.C             - use T1=1 and T2=1 as nominal values
 CalibMacros/MakeGlobalFit.C           - export of fit parameters into OCDB

Marian

14 files changed:
TPC/AliTPCComposedCorrection.cxx
TPC/AliTPCCorrection.cxx
TPC/AliTPCTransform.cxx
TPC/AliTPCcalibAlign.cxx
TPC/AliTPCcalibBase.h
TPC/AliTPCcalibCosmic.h
TPC/AliTPCcalibDB.cxx
TPC/AliTPCcalibDB.h
TPC/AliTPCcalibLaser.cxx
TPC/AliTPCcalibTime.cxx
TPC/AliTPCcalibTime.h
TPC/AliTPCkalmanAlign.cxx
TPC/CalibMacros/MakeGlobalFit.C
TPC/CalibMacros/MakeLookup.C

index c85d82d3c66283631cef1a12e1486469a30f1758..40bc07a6cdcf2010e1763f7f381e089cd46abc45 100644 (file)
@@ -166,10 +166,11 @@ void AliTPCComposedCorrection::Print(Option_t* option) const {
   AliTPCCorrection *c;
   while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
     if (opt.Contains("d")) {
-      printf("%d. ",in);
+      printf("\n");
+      printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName());
       c->Print(option);
     } else {
-      printf("%d. %s\n",in,c->GetTitle());
+      printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName());
     }
     ++in;
   }
index f75482689cd4b4ef4f589d0a2f0f0191c86c7ec4..80acc9aadf8ebc47791ded65742ac5d3551dc640 100644 (file)
@@ -602,8 +602,8 @@ AliExternalTrackParam * AliTPCCorrection::FitDistortedTrack(AliExternalTrackPara
     Double_t deltaYX=deltaX*TMath::Tan(TMath::ASin(track1->GetSnp()));  // deltaY due  delta X
     Double_t deltaZX=deltaX*track1->GetTgl();                           // deltaZ due  delta X
 
-    pointPos[0]=prot1.GetY()+deltaYX;//local y is sign correct?
-    pointPos[1]=prot1.GetZ()+deltaZX;//local z is sign correct?
+    pointPos[0]=prot1.GetY()-deltaYX;//local y is sign correct? should be minus
+    pointPos[1]=prot1.GetZ()-deltaZX;//local z is sign correct? should be minus
     pointCov[0]=prot1.GetCov()[3];//simay^2
     pointCov[1]=prot1.GetCov()[4];//sigmayz
     pointCov[2]=prot1.GetCov()[5];//sigmaz^2
@@ -751,7 +751,7 @@ void AliTPCCorrection::MakeTrackDistortionTree(TTree *tinput, Int_t dtype, Int_t
     track.GetXYZ(xyz);
     Int_t id=0;
     Double_t dRrec=0; // dummy value - needed for points - e.g for laser
-    
+    if (ptype==4 &&bz<0) mean*=-1;  // interpret as curvature
     (*pcstream)<<"fit"<<
       "bz="<<bz<<         // magnetic filed used
       "dtype="<<dtype<<   // detector match type
@@ -791,6 +791,7 @@ void AliTPCCorrection::MakeTrackDistortionTree(TTree *tinput, Int_t dtype, Int_t
        }else{
          corrections[icorr]=0;
        }
+       if (ptype==4 &&bz<0) corrections[icorr]*=-1;  // interpret as curvature
       }      
       Double_t dRdummy=0;
       (*pcstream)<<"fit"<<
index 1c5f129ae3bcad2ea46a61c9ee8d16af52e32dbf..daadb94bd2a59d041133d2270997b469b3974884 100755 (executable)
@@ -64,6 +64,9 @@
 #include "AliTPCRecoParam.h"
 #include "AliTPCCalibVdrift.h"
 #include "AliTPCTransform.h"
+#include "AliMagF.h"
+#include "TGeoGlobalMagField.h"
+#include "AliTracker.h"
 #include <AliCTPTimeParams.h>
 
 ClassImp(AliTPCTransform)
@@ -148,7 +151,8 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   AliTPCCalPad * distortionMapZ = calib->GetDistortionMap(1); 
   AliTPCCalPad * distortionMapR = calib->GetDistortionMap(2); 
   AliTPCParam  * param    = calib->GetParameters(); 
-  AliTPCCorrection * correction = calib->GetTPCComposedCorrection();
+  AliTPCCorrection * correction = calib->GetTPCComposedCorrection();   // first user defined correction  // if does not exist  try to get it from calibDB array
+  if (!correction) correction = calib->GetTPCComposedCorrection(AliTracker::GetBz());
   if (!time0TPC){
     AliFatal("Time unisochronity missing");
   }
@@ -231,16 +235,32 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   // Apply non linear distortion correction  
   //
   if (distortionMapY ){
+    // wt - to get it form the OCDB
+    // ignore T1 and T2
+    AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+    Double_t bzField = magF->SolenoidField()/10.; //field in T
+    Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
+    Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
+    if (sector%36<18) ezField*=-1;
+    Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
+    Double_t c0=1./(1.+wt*wt);
+    Double_t c1=wt/c0;
+    
     //can be switch on for each dimension separatelly
     if (fCurrentRecoParam->GetUseFieldCorrection()&0x2)
-      if (distortionMapY) 
-       xx[1]-=distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+      if (distortionMapY){
+       xx[1]-= c0*distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+       xx[0]-= c1*distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+      }
     if (fCurrentRecoParam->GetUseFieldCorrection()&0x4) 
       if (distortionMapZ)
        xx[2]-=distortionMapZ->GetCalROC(sector)->GetValue(row,pad);
     if (fCurrentRecoParam->GetUseFieldCorrection()&0x8) 
-      if (distortionMapR)
-       xx[0]-=distortionMapR->GetCalROC(sector)->GetValue(row,pad);
+      if (distortionMapR){
+       xx[0]-= c0*distortionMapR->GetCalROC(sector)->GetValue(row,pad);
+       xx[1]-=-c1*distortionMapR->GetCalROC(sector)->GetValue(row,pad)*wt;
+      }
+    
   }
   //
 
index d6e89b00561c0ec50ed78b381804b7d6fb8df768..264837e79bd0e9a0ec7e041a25a5f79c37320d84 100644 (file)
@@ -1659,16 +1659,16 @@ void AliTPCcalibAlign::MakeResidualHistos(){
   binsTrack[0]=60;       xminTrack[0]=-0.6;        xmaxTrack[0]=0.6; 
   //
   axisName[1]="sector";   axisTitle[1]="Sector Number"; 
-  binsTrack[1]=360;       xminTrack[1]=0;        xmaxTrack[1]=18; 
+  binsTrack[1]=180;       xminTrack[1]=0;        xmaxTrack[1]=18; 
   //
   axisName[2]="localX";   axisTitle[2]="x (cm)"; 
   binsTrack[2]=53;       xminTrack[2]=85.;        xmaxTrack[2]=245.; 
   //
   axisName[3]="kY";      axisTitle[3]="dy/dx"; 
-  binsTrack[3]=8;       xminTrack[3]=-0.16;        xmaxTrack[3]=0.16; 
+  binsTrack[3]=1;       xminTrack[3]=-0.16;        xmaxTrack[3]=0.16; 
   //
   axisName[4]="kZ";      axisTitle[4]="dz/dx"; 
-  binsTrack[4]=10;       xminTrack[4]=-1.5;        xmaxTrack[4]=1.5
+  binsTrack[4]=22;       xminTrack[4]=-1.1;        xmaxTrack[4]=1.1
   //
   fClusterDelta[0] = new THnSparseF("#Delta_{Y} (cm)","#Delta_{Y} (cm)", 5, binsTrack,xminTrack, xmaxTrack);
   fClusterDelta[1] = new THnSparseF("#Delta_{Z} (cm)","#Delta_{Z} (cm)", 5, binsTrack,xminTrack, xmaxTrack);
@@ -1901,34 +1901,34 @@ void  AliTPCcalibAlign::MakeTree(const char *fname, Int_t minPoints){
       Double_t sy=0, sz=0, sphi=0,stheta=0;
       Double_t ny=0, nz=0, nphi=0,ntheta=0;
       Double_t chi2v12=0, chi2v9=0, chi2v6=0;
-      Int_t npoints=0;
-      TLinearFitter * fitter = 0;      
+      //      Int_t npoints=0;
+      // TLinearFitter * fitter = 0;      
       if (fPoints[GetIndex(s1,s2)]>minPoints){
        //
        //
        //
-       fitter = GetFitter12(s1,s2);
-       npoints = fitter->GetNpoints();
-       chi2v12 = TMath::Sqrt(fitter->GetChisquare()/npoints);
+//     fitter = GetFitter12(s1,s2);
+//     npoints = fitter->GetNpoints();
+//     chi2v12 = TMath::Sqrt(fitter->GetChisquare()/npoints);
        
-       //
-       fitter = GetFitter9(s1,s2);
-       npoints = fitter->GetNpoints();
-       chi2v9 = TMath::Sqrt(fitter->GetChisquare()/npoints);
-       //
-       fitter = GetFitter6(s1,s2);
-       npoints = fitter->GetNpoints();
-       chi2v6 = TMath::Sqrt(fitter->GetChisquare()/npoints);
-       fitter->GetParameters(param6Diff);
-       //
-       GetTransformation6(s1,s2,m6);
-       GetTransformation9(s1,s2,m9);
-       GetTransformation12(s1,s2,m12);
-       //
-       fitter = GetFitter6(s1,s2);
-       //fitter->FixParameter(3,0);
-       //fitter->Eval();
-       GetTransformation6(s1,s2,m6FX);
+//     //
+//     fitter = GetFitter9(s1,s2);
+//     npoints = fitter->GetNpoints();
+//     chi2v9 = TMath::Sqrt(fitter->GetChisquare()/npoints);
+//     //
+//     fitter = GetFitter6(s1,s2);
+//     npoints = fitter->GetNpoints();
+//     chi2v6 = TMath::Sqrt(fitter->GetChisquare()/npoints);
+//     fitter->GetParameters(param6Diff);
+//     //
+//     GetTransformation6(s1,s2,m6);
+//     GetTransformation9(s1,s2,m9);
+//     GetTransformation12(s1,s2,m12);
+//     //
+//     fitter = GetFitter6(s1,s2);
+//     //fitter->FixParameter(3,0);
+//     //fitter->Eval();
+//     GetTransformation6(s1,s2,m6FX);
        //
        TH1 * his=0;
        his = GetHisto(kY,s1,s2);
@@ -1942,28 +1942,13 @@ void  AliTPCcalibAlign::MakeTree(const char *fname, Int_t minPoints){
        //
 
       }
+      AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+      if (!magF) AliError("Magneticd field - not initialized");
+      Double_t bz = magF->SolenoidField()/10.; //field in T
 
-      // x2    =  a00*x1 + a01*y1 + a02*z1 + a03
-      // y2    =  a10*x1 + a11*y1 + a12*z1 + a13
-      // z2    =  a20*x1 + a21*y1 + a22*z1 + a23
-      // dydx2 = (a10    + a11*dydx1 + a12*dzdx1)/(a00    + a01*dydx1 + a02*dzdx1)
-      // dzdx2 = (a20    + a21*dydx1 + a22*dzdx1)/(a00    + a01*dydx1 + a02*dzdx1)
-      //
-      //                     a00  a01 a02  a03     p[0]   p[1]  p[2]  p[9]
-      //                     a10  a11 a12  a13 ==> p[3]   p[4]  p[5]  p[10]
-      //                     a20  a21 a22  a23     p[6]   p[7]  p[8]  p[11] 
-      
-      //
-      // 
-      // dy:-(fXIO*m6.fElements[4]+m6.fElements[7])
-      // 
-      // dphi:-(m6.fElements[4])
-      //
-      // dz:fXIO*m6.fElements[8]+m6.fElements[11]
-      //
-      // dtheta:m6.fElements[8]
-      //
       cstream<<"Align"<<
+       "run="<<fRun<<  // run
+       "bz="<<bz<<
        "s1="<<s1<<     // reference sector
        "s2="<<s2<<     // sector to align
        "m6FX.="<<&m6FX<<   // tranformation matrix
index 88f557e716e942af3c22c00f632f3d21a3988e67..6344777118f1e3b82cf59f875454b87bace9cca7 100644 (file)
@@ -50,6 +50,7 @@ public:
   static TGraphErrors *        FitSlices(THnSparse *h, Int_t axisDim1, Int_t axisDim2, Int_t minEntries, Int_t nmaxBin, Float_t fracLow=0.1, Float_t fracUp=0.9, Bool_t useMedian=kFALSE, TTreeSRedirector *cstream=0, Int_t ival=1);
   static void            BinLogX(THnSparse *h, Int_t axisDim);
   static void            BinLogX(TH1 *h);
+  void SetRun(Int_t run){ fRun=run;}
 protected: 
   TTreeSRedirector *fDebugStreamer;     //! debug streamer
   Int_t  fStreamLevel;                  //  debug stream level
index eb27674bbfa684a7a9e484a5e2aeb08b50742489..ffee9e5e13eccc559f3582fa31b3ab67acd38da6 100644 (file)
@@ -54,7 +54,7 @@ public:
   void     Process(AliESDtrack *const track, Int_t runNo=-1) {AliTPCcalibBase::Process(track,runNo);};
   void     Process(AliTPCseed *const track)  {return AliTPCcalibBase::Process(track);}
 
-protected:  
+public:  
   //
   // Performance histograms
   //
index 4de9c718f07883bac5acaf63a6846e878c0644e2..c1d95fcba7953ae138df734f7515a3ad4317454f 100644 (file)
@@ -180,6 +180,7 @@ AliTPCcalibDB::AliTPCcalibDB():
   fPadTime0(0),
   fDistortionMap(0),
   fComposedCorrection(0),
+  fComposedCorrectionArray(0),
   fPadNoise(0),
   fPedestals(0),
   fCalibRaw(0),
@@ -222,6 +223,7 @@ AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
   fPadTime0(0),
   fDistortionMap(0),
   fComposedCorrection(0),
+  fComposedCorrectionArray(0),
   fPadNoise(0),
   fPedestals(0),
   fCalibRaw(0),
@@ -459,7 +461,14 @@ void AliTPCcalibDB::Update(){
   if (entry){
     //entry->SetOwner(kTRUE);
     fComposedCorrection=dynamic_cast<AliTPCCorrection*>(entry->GetObject());
-    fComposedCorrection->Init();
+    if (fComposedCorrection) fComposedCorrection->Init();
+    fComposedCorrectionArray=dynamic_cast<TObjArray*>(entry->GetObject());
+    if (fComposedCorrectionArray){
+      for (Int_t i=0; i<fComposedCorrectionArray->GetEntries(); i++){
+       AliTPCCorrection* composedCorrection= dynamic_cast<AliTPCCorrection*>(fComposedCorrectionArray->At(i));
+       if (composedCorrection) composedCorrection->Init();
+      }
+    }
   }else{
     AliError("TPC - Missing calibration entry-  TPC/Calib/Correction")
   }  
@@ -1925,3 +1934,15 @@ AliTPCCalPad* AliTPCcalibDB::MakeDeadMap(Double_t notInMap, const char* nameMapp
 }
 
 
+
+AliTPCCorrection * AliTPCcalibDB::GetTPCComposedCorrection(Float_t field) const{
+  //
+  // GetComposed correction for given field setting
+  //
+  if (!fComposedCorrectionArray) return 0;
+  if (field>0.1) return (AliTPCCorrection *)fComposedCorrectionArray->At(1);
+  if (field<-0.1) return (AliTPCCorrection *)fComposedCorrectionArray->At(2);
+  return (AliTPCCorrection *)fComposedCorrectionArray->At(0);
+  
+}
+
index 8db23f00da7b0ca25f0a8346aed4d548caf03331..af776f1bc34772d45c426f6e091da051005621a5 100644 (file)
@@ -67,6 +67,8 @@ class AliTPCcalibDB : public TObject
   AliTPCCalPad* GetDistortionMap(Int_t i) const;
   AliTPCCorrection * GetTPCComposedCorrection() const { return fComposedCorrection;}
   void          SetTPCComposedCorrection(AliTPCCorrection *compCorr) { fComposedCorrection=compCorr;}
+  AliTPCCorrection * GetTPCComposedCorrection(Float_t field) const;
+
   AliTPCCalPad* GetPadNoise() const {return fPadNoise;}
   AliTPCCalPad* GetPedestals() const{return fPedestals;}
   //ALTRO config data
@@ -179,6 +181,7 @@ protected:
   AliTPCCalPad* fPadTime0;        // Time0 calibration entry
   TObjArray   *fDistortionMap;    // distortion map
   AliTPCCorrection *fComposedCorrection;  // general space point corrections
+  TObjArray *      fComposedCorrectionArray; //space point corrections for different field setting
   AliTPCCalPad* fPadNoise;        // Noise calibration entry
   AliTPCCalPad* fPedestals;       // Pedestal calibration entry
   AliTPCCalibRaw *fCalibRaw;      // raw data calibration entry
index 4a91299d4ae0136c2b7e5c07483e6e7828f966a8..df85417b60e4c5e606cb1f3716ff73836ac4b5a4 100644 (file)
@@ -2341,11 +2341,15 @@ void AliTPCcalibLaser::DumpMeanInfo(Int_t run){
       hisP3->Fit(&fg,"","",hisP3->GetMean()-4*hisP3->GetRMS(),hisP3->GetMean()+4*hisP3->GetRMS());
     Double_t gp31 = fg.GetParameter(1);
     Double_t gp32 = fg.GetParameter(2);
+    Double_t meanp3 = hisP3->GetMean();
+    Double_t rmsp3  = hisP3->GetRMS();
     //
     if (hisP4->GetRMS()>hisP4->GetBinWidth(1))
       hisP4->Fit(&fg,"","",hisP4->GetMean()-4*hisP4->GetRMS(),hisP4->GetMean()+4*hisP4->GetRMS());
     Double_t gp41 = fg.GetParameter(1);
     Double_t gp42 = fg.GetParameter(2);
+    Double_t meanp4 = hisP4->GetMean();
+    Double_t rmsp4  = hisP4->GetRMS();
     //
     Float_t meanS=hisS->GetMean();
     //
@@ -2928,8 +2932,12 @@ void AliTPCcalibLaser::DumpMeanInfo(Int_t run){
       //
       "gp31="<<gp31<<            //gaus mean - tgl
       "gp32="<<gp32<<            //gaus rms  -tgl
+      "meanp3="<<meanp3<<            //mean - tgl
+      "rmsp3="<<rmsp3<<            //rms  -tgl
       "gp41="<<gp41<<            //gaus mean - P4
       "gp42="<<gp42<<            //gaus rms  - P4
+      "meanp4="<<meanp4<<            //mean - P4
+      "rmsp4="<<rmsp4<<            //rms  - P4
       // Parameters from abs res analysis
       "SecIn="<<secInner<<              // inner sector
       "SecOut="<<secOuter<<             // outer sector
index c4284b70292691c3153a719d70950acd691eb0de..153e02f399f322af9cc571d91282ad9a69da21ae 100644 (file)
@@ -141,6 +141,7 @@ AliTPCcalibTime::AliTPCcalibTime()
   for (Int_t i=0;i<5;i++) {
     fResHistoTPCITS[i]=0;
     fResHistoTPCTRD[i]=0;
+    fResHistoTPCTOF[i]=0;
     fResHistoTPCvertex[i]=0;
   }
 
@@ -186,6 +187,7 @@ AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t
   for (Int_t i=0;i<5;i++) {
     fResHistoTPCITS[i]=0;
     fResHistoTPCTRD[i]=0;
+    fResHistoTPCTOF[i]=0;
     fResHistoTPCvertex[i]=0;
   }
 
@@ -295,9 +297,11 @@ AliTPCcalibTime::~AliTPCcalibTime(){
   for (Int_t i=0;i<5;i++) {
     delete fResHistoTPCITS[i];
     delete fResHistoTPCTRD[i];
+    delete fResHistoTPCTOF[i];
     delete fResHistoTPCvertex[i];
     fResHistoTPCITS[i]=0;
     fResHistoTPCTRD[i]=0;
+    fResHistoTPCTOF[i]=0;
     fResHistoTPCvertex[i]=0;
   }
 
@@ -860,6 +864,7 @@ Long64_t AliTPCcalibTime::Merge(TCollection *const li) {
        fResHistoTPCITS[imeas]->Add(cal->fResHistoTPCITS[imeas]);
        fResHistoTPCvertex[imeas]->Add(cal->fResHistoTPCvertex[imeas]);
        fResHistoTPCTRD[imeas]->Add(cal->fResHistoTPCTRD[imeas]);
+       fResHistoTPCTOF[imeas]->Add(cal->fResHistoTPCTOF[imeas]);
       }
     }
     TObjArray* addArray=cal->GetHistoDrift();
@@ -1421,7 +1426,11 @@ void  AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, AliESDfriendTra
   align->AddTrackParams(&pTRD,&pTPC);
   align->SetTimeStamp(fTime);
   align->SetRunNumber(fRun );
-  FillResHistoTPCTRD(&pTPC,&pTRD);
+  Float_t dca[2],cov[3];
+  track->GetImpactParameters(dca,cov);
+  if (TMath::Abs(dca[0])<kMaxDy){
+    FillResHistoTPCTRD(&pTPC,&pTRD);  //only primaries
+  }
   //
   Int_t nupdates=align->GetNUpdates();
   align->SetOutRejSigma(kOutCut+kOutCut*kN/Double_t(nupdates));
@@ -1580,6 +1589,11 @@ void  AliTPCcalibTime::ProcessAlignTOF(AliESDtrack *const track, AliESDfriendTra
     fAlignTOFTPC->AddAt(align,htime);
   }
   align->AddTrackParams(&pTOF,&pTPC);
+  Float_t dca[2],cov[3];
+  track->GetImpactParameters(dca,cov);
+  if (TMath::Abs(dca[0])<kMaxDy){
+    FillResHistoTPCTOF(&pTPC,&pTOF);
+  }
   align->SetTimeStamp(fTime);
   align->SetRunNumber(fRun );
   //
@@ -1654,30 +1668,37 @@ void  AliTPCcalibTime::BookDistortionMaps(){
   fResHistoTPCvertex[0]    = new THnSparseS("TPCVertex#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
   xminTrack[0] =-1.5; xmaxTrack[0]=1.5;  // 
   fResHistoTPCTRD[0] = new THnSparseS("TPCTRD#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
+  xminTrack[0] =-5; xmaxTrack[0]=5;  // 
+  fResHistoTPCTOF[0] = new THnSparseS("TPCTOF#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
   //
   // delta z
   xminTrack[0] =-3.; xmaxTrack[0]=3.;  // 
   fResHistoTPCITS[1] = new THnSparseS("TPCITS#Delta_{Z} (cm)","#Delta_{Z} (cm)",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCvertex[1]    = new THnSparseS("TPCVertex#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCTRD[1] = new THnSparseS("TPCTRD#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
+  xminTrack[0] =-5.; xmaxTrack[0]=5.;  // 
+  fResHistoTPCTOF[1] = new THnSparseS("TPCTOF#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
   //
   // delta snp-P2
   xminTrack[0] =-0.015; xmaxTrack[0]=0.015;  // 
   fResHistoTPCITS[2] = new THnSparseS("TPCITS#Delta_{#phi}","#Delta_{#phi}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCvertex[2] = new THnSparseS("TPCITSv#Delta_{#phi}","#Delta_{#phi}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCTRD[2] = new THnSparseS("TPCTRD#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
+  fResHistoTPCTOF[2] = new THnSparseS("TPCTOF#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
   //
   // delta theta-P3
   xminTrack[0] =-0.025; xmaxTrack[0]=0.025;  // 
   fResHistoTPCITS[3] = new THnSparseS("TPCITS#Delta_{#theta}","#Delta_{#theta}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCvertex[3] = new THnSparseS("TPCITSv#Delta_{#theta}","#Delta_{#theta}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCTRD[3] = new THnSparseS("TPCTRD#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
+  fResHistoTPCTOF[3] = new THnSparseS("TPCTOF#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
   //
   // delta theta-P4
   xminTrack[0] =-0.2; xmaxTrack[0]=0.2;  // 
   fResHistoTPCITS[4] = new THnSparseS("TPCITS#Delta_{1/pt}","#Delta_{1/pt}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCvertex[4] = new THnSparseS("TPCITSv#Delta_{1/pt}","#Delta_{1/pt}",    4, binsTrack,xminTrack, xmaxTrack);
   fResHistoTPCTRD[4] = new THnSparseS("TPCTRD#Delta_{1/pt}","#Delta_{1/pt}",    4, binsTrack,xminTrack, xmaxTrack);
+  fResHistoTPCTOF[4] = new THnSparseS("TPCTOF#Delta_{1/pt}","#Delta_{1/pt}",    4, binsTrack,xminTrack, xmaxTrack);
   //
   for (Int_t ivar=0;ivar<4;ivar++){
     for (Int_t ivar2=0;ivar2<4;ivar2++){      
@@ -1770,3 +1791,27 @@ void        AliTPCcalibTime::FillResHistoTPCTRD(const AliExternalTrackParam * pT
   }
 
 }
+
+void        AliTPCcalibTime::FillResHistoTPCTOF(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTOFIn ){
+  //
+  // fill resuidual histogram TPCout-TOFin
+  // track propagated to the TOF position
+  Double_t histoX[4];
+  Double_t xyz[3];
+
+  AliExternalTrackParam ltpc(*pTPCOut);
+  ltpc.Rotate(pTOFIn->GetAlpha());
+  AliTracker::PropagateTrackToBxByBz(&ltpc,pTOFIn->GetX(),0.1,0.1,kFALSE);
+  //
+  ltpc.GetXYZ(xyz);
+  Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
+  histoX[1]= ltpc.GetTgl();
+  histoX[2]= phi;
+  histoX[3]= ltpc.GetSnp();
+  //
+  for (Int_t ihisto=0; ihisto<2; ihisto++){
+    histoX[0]=ltpc.GetParameter()[ihisto]-pTOFIn->GetParameter()[ihisto];
+    fResHistoTPCTOF[ihisto]->Fill(histoX);
+  }
+
+}
index 7b353d22138e6fcbaf438d4a69c1f8a40fd75d58..d67fc57d00e716f3d3fe01aa48292b5e243a9162 100644 (file)
@@ -64,11 +64,13 @@ public:
   THnSparse*  GetResHistoTPCITS(Int_t index) const { return (index<5) ? fResHistoTPCITS[index]:0;}        //TPC-ITS    matching map
   THnSparse*  GetResHistoTPCvertex(Int_t index)      const { return (index<5) ? fResHistoTPCvertex[index]   :0;}        //TPC vertex matching map
   THnSparse*  GetResHistoTPCTRD(Int_t index)   const { return (index<5) ? fResHistoTPCTRD[index]:0;}        //TPC-TRD    matching map
+  THnSparse*  GetResHistoTPCTOF(Int_t index)   const { return (index<5) ? fResHistoTPCTOF[index]:0;}        //TPC-TOF    matching map
 
   void        BookDistortionMaps();      // book histograms
   void        FillResHistoTPCITS(const AliExternalTrackParam * pTPCIn, const AliExternalTrackParam * pITSOut );       // fill residual histo
   void        FillResHistoTPC(const AliESDtrack * pTrack);
   void        FillResHistoTPCTRD(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTRDIn );
+  void        FillResHistoTPCTOF(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTOFIn );
 
 private:
   void ResetCurrent();                  // reset current values
@@ -97,6 +99,7 @@ private:
   THnSparse*  fResHistoTPCITS[5];        //TPC-ITS    matching map
   THnSparse*  fResHistoTPCvertex[5];           //TPC-ITS    vertex matching map
   THnSparse*  fResHistoTPCTRD[5];        //TPC-TRD    matching map
+  THnSparse*  fResHistoTPCTOF[5];        //TPC-TRD    matching map
   // laser histo
   THnSparse * fHistVdriftLaserA[3];    //Histograms for V drift from laser
   THnSparse * fHistVdriftLaserC[3];    //Histograms for V drift from laser
@@ -120,7 +123,7 @@ private:
   Int_t    fBinsVdrift[4];             //Bins for vdrift
   Double_t fXminVdrift[4];             //Xmax for vdrift
   Double_t fXmaxVdrift[4];             //Xmin for vdrift
-  ClassDef(AliTPCcalibTime, 3); 
+  ClassDef(AliTPCcalibTime, 4); 
 };
 
 #endif
index 6e21e82b6773390a4c579179d76726454d1b1a1c..ba12df8e2d66727f36edd0f62773a8cacf28e5dd 100644 (file)
@@ -74,6 +74,7 @@
 #include "TStatToolkit.h"
 #include "AliTPCPreprocessorOnline.h"
 #include "TPostScript.h"
+#include "AliGRPObject.h"
 
 AliTPCkalmanAlign::AliTPCkalmanAlign():
   TNamed(),
@@ -200,8 +201,16 @@ void AliTPCkalmanAlign::MakeGlobalAlign(){
   //
   // Combine all pairs of fitters and make global alignemnt
   //
+  
   AliTPCkalmanAlign &kalmanAlign=*this;
   TTreeSRedirector *pcstream = new TTreeSRedirector("AliTPCkalmanAlign.root");
+  Int_t run = AliCDBManager::Instance()->GetRun();
+  AliGRPObject * grp = AliTPCcalibDB::Instance()->GetGRP(run);
+  Float_t bz = AliTracker::GetBz();
+  UInt_t timeS = grp->GetTimeStart();
+  UInt_t timeE = grp->GetTimeEnd();
+  UInt_t  time = (timeS+timeE)/2;
+  
   //
   // get ce info
   //
@@ -281,7 +290,7 @@ void AliTPCkalmanAlign::MakeGlobalAlign(){
   statUpDown/=36;
   statLeftRight/=36;
   MakeNewAlignment(kTRUE);
-  //FitCE();
+  FitCE();
   for (Int_t is0=0;is0<72;is0++)
     for (Int_t is1=0;is1<72;is1++){
       Bool_t isPair=kFALSE;
@@ -318,46 +327,57 @@ void AliTPCkalmanAlign::MakeGlobalAlign(){
        rms[3]=his->GetRMS();
        stat[3]=his->GetEntries();
       }
-      Int_t run = AliCDBManager::Instance()->GetRun();
-      Float_t bz = AliTracker::GetBz();
-      TVectorD fceG[6],fceL[6];
-      for (Int_t ipar=0; ipar<6;ipar++){
-       fceG[ipar]=*((TVectorD*)fFitCEGlobal->At(ipar));
-       fceL[ipar]=*((TVectorD*)fFitCELocal->At(ipar));
-      }
+      TVectorD fceG[8],fceL[6];
+      if (fFitCEGlobal)
+       for (Int_t ipar=0; ipar<8;ipar++){
+         fceG[ipar].ResizeTo(36);
+         if (ipar<6) fceL[ipar].ResizeTo(36);
+         if (fFitCEGlobal->At(ipar)){
+           fceG[ipar]=*((TVectorD*)fFitCEGlobal->At(ipar));
+           if (ipar<6){
+             fceL[ipar]=*((TVectorD*)fFitCELocal->At(ipar));
+           }
+         }           
+       }
+      
       (*pcstream)<<"kalmanAlignDebug"<<
-       "run="<<run<<
+       "run="<<run<<            // runs
+       "time="<<time<<          // time
+       "timeE="<<timeE<<        // sart of tun time
+       "timeS="<<timeS<<        // end od run time
        "bz="<<bz<<
        "is0="<<is0<<
        "is1="<<is1<<
-       "delta.="<<&delta<<
-       "rms.="<<&rms<<
+       "delta.="<<&delta<<      // alignment deltas
+       "rms.="<<&rms<<          // rms
        "stat.="<<&stat<<
        "vec0.="<<&vec[0]<<
        "vec1.="<<&vec[1]<<
        "vec2.="<<&vec[2]<<
        "vec3.="<<&vec[3]<<
-       "pceIn0.="<<&paramCE[is0%36]<<
+       "pceIn0.="<<&paramCE[is0%36]<<        // default CE parameters
        "pceOut0.="<<&paramCE[is0%36+36]<<
        "pceIn1.="<<&paramCE[is1%36]<<
        "pceOut1.="<<&paramCE[is1%36+36]<<
-       "fceG0.="<<&fceG[0]<<  // global fit of CE
-       "fceG1.="<<&fceG[1]<<  // global fit of CE
-       "fceG2.="<<&fceG[2]<<  // global fit of CE
-       "fceG3.="<<&fceG[3]<<  // global fit of CE
-       "fceG4.="<<&fceG[4]<<  // global fit of CE
-       "fceL5.="<<&fceG[5]<<  // global fit of CE
-       "fceL0.="<<&fceL[0]<<  // global fit of CE
-       "fceL1.="<<&fceL[1]<<  // global fit of CE
-       "fceL2.="<<&fceL[2]<<  // global fit of CE
-       "fceL3.="<<&fceL[3]<<  // global fit of CE
-       "fceL4.="<<&fceL[4]<<  // global fit of CE
-       "fceL5.="<<&fceL[5]<<  // global fit of CE
+       //                     // current CE parameters form last calibration - not used in Reco
+       "fceG0.="<<&fceG[0]<<  // global fit of CE  - offset
+       "fceG1.="<<&fceG[1]<<  // global fit of CE  - Gy gradient 
+       "fceG2.="<<&fceG[2]<<  // global fit of CE  - Gx gradient
+       "fceG3.="<<&fceG[3]<<  // global fit of CE  - IROC-OROC offset
+       "fceG4.="<<&fceG[4]<<  // global fit of CE  - commont slope LX
+       "fceG5.="<<&fceG[5]<<  // global fit of CE  - delta slope LX
+       "fceG6.="<<&fceG[6]<<  // global fit of CE  - common slope LY
+       "fceG7.="<<&fceG[7]<<  // global fit of CE  - delta slope LY
+       //
+       "fceL0.="<<&fceL[0]<<  // local fit of CE  - offset to mean
+       "fceL1.="<<&fceL[1]<<  // local fit of CE  - IROC-OROC offset
+       "fceL2.="<<&fceL[2]<<  // local fit of CE  - common slope LX
+       "fceL3.="<<&fceL[3]<<  // local fit of CE  - delta slope  LX
+       "fceL4.="<<&fceL[4]<<  // local fit of CE  - common slope LY
+       "fceL5.="<<&fceL[5]<<  // local fit of CE  - delta slope  LY
        "\n";
     }
   
-  Int_t run = AliCDBManager::Instance()->GetRun();
-  Float_t bz = AliTracker::GetBz();
   (*pcstream)<<"runSummary"<<
     "run="<<run<<                      // run number 
     "bz="<<bz<<                        // bz field
@@ -683,6 +703,11 @@ void AliTPCkalmanAlign::DrawAlignmentTrends(){
   // Draw trends of alingment variables
   //
   /*
+    //1.  Create a list of  align data
+    //
+    //2. Filter list
+    AliXRDPROOFtoolkit::FilterList("align.list","AliTPCkalmanAlign.root kalmanAlignDebug",0);
+
   */
   AliXRDPROOFtoolkit toolkit;
   TChain * chain = toolkit.MakeChainRandom("align.list.Good","kalmanAlignDebug",0,2000);
@@ -783,14 +808,14 @@ void AliTPCkalmanAlign::FitCE(){
   AliTPCkalmanAlign::MakeAliasCE(chain);
   TString  fstringG="";              // global part
   //
-  fstringG+="Gy++";                  // par 1 - global y
-  fstringG+="Gx++";                  // par 2 - global x
+  fstringG+="Gy++";                  // 1 - global y
+  fstringG+="Gx++";                  // 2 - global x
   // 
-  fstringG+="isin++";                // delta IROC-OROC offset
-  fstringG+="Lx++";                  // common slope 
-  fstringG+="Lx*isin++";             // delta slope 
-  fstringG+="Ly++";                  // common slope 
-  fstringG+="Ly*isin++";             // delta slope 
+  fstringG+="isin++";                // 3 -delta IROC-OROC offset
+  fstringG+="Lx++";                  // 4 -common slope 
+  fstringG+="Lx*isin++";             // 5 -delta slope 
+  fstringG+="Ly++";                  // 6 -common slope 
+  fstringG+="Ly*isin++";             // 7 -delta slope 
   TVectorD vecG[2];
   TString * strFitG=0;
   TString * strFitLX=0;
@@ -830,8 +855,8 @@ void AliTPCkalmanAlign::FitCE(){
   fstringL+="isin++";                // 1. delta IROC-OROC offset
   fstringL+="Lx++";                  // 2. common slope 
   fstringL+="Lx*isin++";             // 3. delta slope 
-  fstringL+="Ly++";                  // 2. common slope 
-  fstringL+="Ly*isin++";             // 3. delta slope 
+  fstringL+="Ly++";                  // 4. common slope 
+  fstringL+="Ly*isin++";             // 5. delta slope 
   TVectorD vecL[36];
   TVectorD dummy(6);
   AliTPCCalPad *padFitLCE = new AliTPCCalPad("LocalCE","LocalCE");
@@ -853,26 +878,24 @@ void AliTPCkalmanAlign::FitCE(){
   //
   // write data to array
   //
-  fFitCEGlobal = new TObjArray(6); 
   fFitCELocal  = new TObjArray(6); 
-  for (Int_t ipar=0; ipar<6;ipar++){
-    fFitCEGlobal->AddAt(new TVectorD(36),ipar);
-    fFitCELocal->AddAt(new TVectorD(36),ipar);
+  fFitCEGlobal = new TObjArray(8); 
+  for (Int_t ipar=0; ipar<8;ipar++){
     //
+    fFitCEGlobal->AddAt(new TVectorD(36),ipar);
     TVectorD &fvecG = *((TVectorD*)fFitCEGlobal->At(ipar));
-    TVectorD &fvecL = *((TVectorD*)fFitCELocal->At(ipar));
-    //
     for (Int_t isec=0; isec<36;isec++){      
-      fvecL[isec]=vecL[isec][ipar];
-      if (ipar>0){
-       if (isec<18)  fvecG[isec]=vecG[0][ipar+2];
-       if (isec>=18) fvecG[isec]=vecG[1][ipar+2];
+      if (isec<18)  fvecG[isec]=vecG[0][ipar];
+      if (isec>=18) fvecG[isec]=vecG[1][ipar];    
+    }
+    if (ipar<6){
+      fFitCELocal->AddAt(new TVectorD(36),ipar);
+      TVectorD &fvecL = *((TVectorD*)fFitCELocal->At(ipar));
+      for (Int_t isec=0; isec<36;isec++){      
+       fvecL[isec]=vecL[isec][ipar];
       }
     }
   }
-  //
-  // 
-  //
 }
 
 void AliTPCkalmanAlign::MakeAliasCE(TTree * chain){
index 3f3eded5a9789f463783de3531434da49d79d261..36f1fd5726757f069320b665c81319e509957309 100644 (file)
 #include "AliTPCCalibGlobalMisalignment.h"
 #include "AliTPCExBEffective.h"
 #include "TEntryList.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBId.h"
+#include "AliCDBManager.h" 
+#include "AliCDBStorage.h"
+#include "AliTPCcalibDB.h"
 #endif
 
 const char* chDetName[5]={"ITS","TRD", "Vertex", "TOF","Laser"};
 const char* chParName[5]={"rphi","z", "snp", "tan","1/pt"};
 const char* chSideName[2]={"A side","C side"};
-Bool_t enableDet[5]={1,1,1,1,1};      // detector  for fit  ITS=0, TRD=1, Vertex=2, Laser=4
+Bool_t enableDet[5]={1,1,1,0,1};      // detector  for fit  ITS=0, TRD=1, Vertex=2, Laser=4
 Bool_t enableParam[5]={1,0,1,0,1};    //
 Bool_t enableSign=kFALSE;  
 Bool_t useEff0=kFALSE;
@@ -73,6 +78,7 @@ void MakeChain();
 void MakeAliases();
 void MakeCuts();
 void MakeFit(TCut cutCustom);
+void MakeOCDBEntry(Int_t refRun);
 TCanvas* DrawFitITS(const char *name);
 TCanvas* DrawFitVertex(const char *name);
 TCanvas*  DrawFitLaser(const char *cname);
@@ -103,7 +109,7 @@ void MakeGlobalFit(){
   //
   //
   gROOT->Macro("~/rootlogon.C");
-  gROOT->Macro("NimStyle.C");
+  //gROOT->Macro("NimStyle.C");
   gSystem->AddIncludePath("-I$ALICE_ROOT/STAT");
   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC");
   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
@@ -111,25 +117,41 @@ void MakeGlobalFit(){
   gSystem->Load("libTPCcalib");
 
   MakeChain();  
-  PrintMatch();
-  TPostScript *ps = new TPostScript("matching.ps", 112); 
   gStyle->SetOptTitle(1);
   gStyle->SetOptStat(0);
-
-  useEff0=kFALSE; useEffD=kFALSE; useEffR=kFALSE;
+  TPostScript *ps = new TPostScript("exbFit.eps", 112); 
+  ps->NewPage();
+  TCanvas *c=0;
+  useEff0=kFALSE; useEffD=kFALSE; useEffR=kFALSE; 
+  ps->NewPage();
   MakeFit("1");  
+  //
   ps->NewPage();
-  DrawFitdY("dY-Physical")->Draw();
+  c=DrawFitdY("dY-Physical"); 
+  c->Update();
   ps->NewPage();
-  DrawFitdSnp("dSnp-Physical")->Draw();
+  c->Update();
+
   ps->NewPage();
-  DrawFitITS("ITS Physical")->Draw();
+  c=DrawFitdSnp("dSnp-Physical");
+  c->Update();
+  
   ps->NewPage();
-  DrawFitVertex("Vertex Physical")->Draw();
+  c=DrawFitITS("ITS Physical");
+  c->Update();
+  
   ps->NewPage();
-  DrawFitLaser("Laser Physical")->Draw();
+  c=DrawFitVertex("Vertex Physical");
+  c->Update();
+  
+  ps->NewPage();
+  c=DrawFitLaser("Laser Physical");
+  c->Update();
+  
   ps->NewPage();
-  MakeComposedCorrection("Correction physical")->Draw();
+  c=MakeComposedCorrection("Correction physical");
+  c->Update();  
+
   //
   //
   //
@@ -138,101 +160,102 @@ void MakeGlobalFit(){
   ps->NewPage();
   MakeFit("1");
   ps->NewPage();
-  DrawFitdY("dY-Physical+Effective ")->Draw();
+  c=DrawFitdY("dY-Physical+Effective ");
+  c->Update();  
+  
   ps->NewPage();
-  DrawFitdSnp("dSnp-Physical+Effective ")->Draw();
+  c=DrawFitdSnp("dSnp-Physical+Effective ");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitITS("ITS Physical+Effective")->Draw();
+  c=DrawFitITS("ITS Physical+Effective");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitVertex("Vertex Physical+Effective")->Draw();
+  c=DrawFitVertex("Vertex Physical+Effective");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitLaser("Laser Physical +Effective ")->Draw();
+  c=DrawFitLaser("Laser Physical +Effective ");
+  c->Update();  
+
   ps->NewPage();
-  MakeComposedCorrection("Correction physical+Effective")->Draw();
+  c=MakeComposedCorrection("Correction physical+Effective");
+  c->Update();  
   //
-  useEff0=kTRUE; useEffD=kTRUE; useEffR=kTRUE; enableSign=kTRUE;
+  useEff0=kTRUE; useEffD=kTRUE; useEffR=kTRUE; enableSign=kTRUE; 
   ps->NewPage();
   MakeFit("1");
+  //
   ps->NewPage();
-  DrawFitdY("dY-Physical+Effective Sign")->Draw();
+  c=DrawFitdY("dY-Physical+Effective Sign");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitdSnp("dSnp-Physical+Effective Sign")->Draw();
+  c=DrawFitdSnp("dSnp-Physical+Effective Sign");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitITS("ITS Physical+Effective Sign")->Draw();
+  c=DrawFitITS("ITS Physical+Effective Sign");
+  c->Update();  
+
   ps->NewPage();
-  DrawFitVertex("Vertex Physical+Effective Sign")->Draw();
+  c=DrawFitVertex("Vertex Physical+Effective Sign");
+  c->Update();  
+  
   ps->NewPage();
-  DrawFitLaser("Laser Physical +Effective Sign")->Draw();
+  c=DrawFitLaser("Laser Physical +Effective Sign");
+  c->Update();  
   ps->NewPage();
-  MakeComposedCorrection("Correction physical+Effective Sign")->Draw();
-  //
+  c=MakeComposedCorrection("Correction physical+Effective Sign");
+  c->Update();  
+  
   ps->Close();
   delete ps;
 
+  //
 }
 
 void MakeChain(){
   //
   //
   TH1::AddDirectory(0);
-  TFile * f =0;
-  TTree * tree=0;
-  TTree * treeF=0;
+  TFile * f0 =0;      // file 0 field
+  TFile * fp =0;      // file plus
+  TFile * fm =0;      // file minus
+  TTree * tree0=0;
+  TTree * treeP=0;
+  TTree * treeM=0;
   //
   chain    = new TChain("fit","fit");
   chainRef = new TChain("fit","fit");
+  //
+  //
+  //
   for (Int_t idet=0; idet<5; idet++){
     for (Int_t ipar=0; ipar<5; ipar++){
-      char fname[1000];      
-      f= TFile::Open(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
-      if (f){
-       tree = (TTree*)f->Get("fit");
-       f= TFile::Open(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
-       if (f && ipar!=4 &&ipar!=3 &&ipar!=1){
-         treeF = (TTree*)f->Get("fit");
-         if (tree && treeF) 
-           if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
-             printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
-             chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
-             chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
-           }
-       }else{
-         f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-         if (f){
-           treeF = (TTree*)f->Get("fit");
-           if (tree && treeF) 
-             if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
-               printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
-               chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
-               chainRef->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-           }       
-         }
+      f0= TFile::Open(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
+      fp= TFile::Open(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
+      fm= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
+      tree0 = (f0) ? (TTree*)f0->Get("fit"):0;
+      treeP = (fp) ? (TTree*)fp->Get("fit"):0;
+      treeM = (fm) ? (TTree*)fm->Get("fit"):0;
+      //
+      if ( ipar==0 || ipar==2){
+       if (tree0 && treeP){
+         chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
+         chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar)); 
        }
-      }
-      f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-      if (f){
-       tree = (TTree*)f->Get("fit");
-       f= TFile::Open(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
-       if (f){
-         treeF = (TTree*)f->Get("fit");
-         if (tree && treeF) 
-           if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
-             printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
-             chain->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-             chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
-           }
+       if (tree0 && treeM){
+         chain->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
+         chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar)); 
        }
-       else{
-         f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-         if (f && ipar!=4&&ipar!=3 &&ipar!=1){
-           treeF = (TTree*)f->Get("fit");
-           if (tree && treeF) 
-             if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
-               printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
-               chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
-               chainRef->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
-             }     
-         }
+      }
+      if ( ipar==1 || ipar==3 || ipar==4){
+       if (treeP && treeM){
+         chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
+         chainRef->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));  
        }
       }
     }
@@ -292,8 +315,6 @@ void MakeFit(TCut cutCustom){
   fstring+="(tY1-R.tY1)++";                   // twist Y
   fstring+="(sign(bz)*(tX1-R.tX1))++";       // twist X
   fstring+="(sign(bz)*(tY1-R.tY1))++";       // twist Y
-  fstring+="(exbT1-exb11-(R.exbT1-R.exb11))++";                // T1 adjustment
-  fstring+="(exbT2-exb11-(R.exbT2-R.exb11))++";                // T2 adjustment
 
   {if (enableDet[0]){
     fstring+="(isITS*shiftX)++";             // shift X - ITS
@@ -312,6 +333,8 @@ void MakeFit(TCut cutCustom){
   }
   TString fstringCustom="";
   if (useEff0){
+    fstring+="(exbT1-exb11-(R.exbT1-R.exb11))++";                // T1 adjustment
+    fstring+="(exbT2-exb11-(R.exbT2-R.exb11))++";                // T2 adjustment
     fstringCustom+="(eff0_0_0-R.eff0_0_0)++";                  // effective correction constant part 
     fstringCustom+="(eff1_0_0-R.eff1_0_0)++";                  // 
   }
@@ -383,14 +406,14 @@ void PrintMatch(){
   for (Int_t ipar=0; ipar<5; ipar++){      
     for (Int_t idet=0; idet<5; idet++){
       Double_t mean0,rms0,mean1,rms1;
-      Int_t entries = chain->Draw("delta-mdelta",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"");
+      Int_t entries = chain->Draw("delta-mdelta>>rhis",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"goff");
       if (entries==0) continue;
       TH1 * his = (TH1*)(chain->GetHistogram()->Clone());
       mean1=his->GetMean();
       rms1 =his->GetRMS();
       delete his;
       //
-      entries = chain->Draw("mdelta",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"");
+      entries = chain->Draw("mdelta>>rhis",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"goff");
       if (entries==0) continue;
       his = (TH1*)(chain->GetHistogram()->Clone());
       //
@@ -850,14 +873,19 @@ TCanvas * DrawFitdSnp(const char *name){
   return canvas;
 }
 
+
+
+
+
+
 TCanvas * MakeComposedCorrection(const char *name){
   
   TString  fit = chain->GetAlias("delta");
   TObjArray * array = fit.Tokenize("++");
   Int_t nfun=array->GetEntries();
   Double_t wt = 0.3 ; 
-  Double_t T1 = 0.9;
-  Double_t T2 = 1.5;
+  Double_t T1 = 1.0;
+  Double_t T2 = 1.0;
   //
   // sign independent correction
   //
@@ -875,8 +903,12 @@ TCanvas * MakeComposedCorrection(const char *name){
   TMatrixD polC(100,4);
   TMatrixD valA(100,1);
   TMatrixD valC(100,1);
+  TMatrixD valAS(100,1);
+  TMatrixD valCS(100,1);
   Int_t counterA=0;
   Int_t counterC=0;
+  Int_t counterAS=0;
+  Int_t counterCS=0;
 
   {
     for (Int_t i=1; i<nfun;i++){
@@ -937,8 +969,8 @@ TCanvas * MakeComposedCorrection(const char *name){
   //
   //
   {
-    counterA=0;
-    counterC=0;
+    counterAS=0;
+    counterCS=0;
     for (Int_t i=1; i<nfun;i++){
       TObjString fitName=array->At(i)->GetName();
       TObjString fitVal= &(fitName.String()[1+fitName.String().Last('(')]);
@@ -966,20 +998,20 @@ TCanvas * MakeComposedCorrection(const char *name){
        Int_t pp  =0;
        //printf("%s\t%d\t%d\t%d\t%d\t%f\n",fitName.GetName(),side,px,pd,pp, value);
        if (side==0){
-         polA(counterA,0)=0;
-         polA(counterA,1)=px;
-         polA(counterA,2)=pd;
-         polA(counterA,3)=pp;
-         valA(counterA,0)=value*0.1;
-         counterA++;
+         polA(counterAS,0)=0;
+         polA(counterAS,1)=px;
+         polA(counterAS,2)=pd;
+         polA(counterAS,3)=pp;
+         valAS(counterAS,0)=value*0.1;
+         counterAS++;
        }
        if (side==1){
-         polC(counterC,0)=0;
-         polC(counterC,1)=px;
-         polC(counterC,2)=pd;
-         polC(counterC,3)=pp;
-         valC(counterC,0)=value*0.1;
-         counterC++;
+         polC(counterCS,0)=0;
+         polC(counterCS,1)=px;
+         polC(counterCS,2)=pd;
+         polC(counterCS,3)=pp;
+         valCS(counterCS,0)=value*0.1;
+         counterCS++;
        }
       }
     }
@@ -989,29 +1021,168 @@ TCanvas * MakeComposedCorrection(const char *name){
   valA.ResizeTo(counterA,1);
   valC.ResizeTo(counterC,1);
   effS->SetPolynoms(&polA,&polC);
-  effS->SetCoeficients(&valA,&valC);
+  effS->SetCoeficients(&valAS,&valCS);
   effS->SetOmegaTauT1T2(wt,T1,T2);
   shiftITSS->SetOmegaTauT1T2(wt,T1,T2);
   twistS->SetOmegaTauT1T2(wt,T1,T2);
+  //
+  // Make combined correction
+  //
 
+  TObjArray * corr0 = new TObjArray;
+  TObjArray * corrP = new TObjArray;
+  TObjArray * corrM = new TObjArray;
+  AliTPCExBEffective            *eff0      = new  AliTPCExBEffective;
+  AliTPCCalibGlobalMisalignment *shiftITSP = new  AliTPCCalibGlobalMisalignment;
+  AliTPCExBTwist                *twistP    = new  AliTPCExBTwist;
+  AliTPCExBEffective            *effP      = new  AliTPCExBEffective;
+  AliTPCCalibGlobalMisalignment *shiftITSM = new  AliTPCCalibGlobalMisalignment;
+  AliTPCExBTwist                *twistM    = new  AliTPCExBTwist;
+  AliTPCExBEffective            *effM      = new  AliTPCExBEffective;
+  //
+  shiftITSP->SetXShift(shiftITS->GetXShift()+shiftITSS->GetXShift());    // shift due to the B field
+  shiftITSP->SetYShift(shiftITS->GetXShift()+shiftITSS->GetYShift());                  
+  shiftITSM->SetXShift(shiftITS->GetXShift()-shiftITSS->GetXShift());
+  shiftITSM->SetYShift(shiftITS->GetXShift()-shiftITSS->GetYShift());
+  //
+  twistP->SetXTwist(twist->GetXTwist()+twistS->GetXTwist());     // twist between field  - both used
+  twistP->SetYTwist(twist->GetYTwist()+twistS->GetYTwist());     //
+  twistM->SetXTwist(twist->GetXTwist()-twistS->GetXTwist());
+  twistM->SetYTwist(twist->GetYTwist()-twistS->GetYTwist());
+  //
+  effP->SetPolynoms(&polA,&polC);                                // effective correction
+  effP->SetCoeficients(&valA,&valC);
+  effM->SetPolynoms(&polA,&polC);
+  effM->SetCoeficients(&valA,&valC);
+  //
+  eff0->SetPolynoms((TMatrixD*)&polA,(TMatrixD*)&polC);
+  eff0->SetCoeficients((TMatrixD*)&valA,(TMatrixD*)&valC);
+  //
+  //
+  //
+  
+  //
+  corrP->AddLast(shiftITSP);
+  corrP->AddLast(twistP);
+  corrP->AddLast(effP);
+  corrM->AddLast(shiftITSM);
+  corrM->AddLast(twistM);
+  corrM->AddLast(effM);
+  corr0->AddLast(eff0);
+  //
 
-
+  AliTPCComposedCorrection *comp0= new AliTPCComposedCorrection ;
+  AliTPCComposedCorrection *compP= new AliTPCComposedCorrection ;
+  AliTPCComposedCorrection *compM= new AliTPCComposedCorrection ;
+  comp0->SetCorrections((TObjArray*)(corr0));
+  compP->SetCorrections((TObjArray*)(corrP));
+  compM->SetCorrections((TObjArray*)(corrM));
+  //
+  comp0->SetOmegaTauT1T2(0*wt,T1,T2);
+  compP->SetOmegaTauT1T2(wt,T1,T2);
+  compM->SetOmegaTauT1T2(-wt,T1,T2);
+
+  TFile f("correctionsExB.root","update");
+  f.mkdir(name);
+  f.cd(name);  
+  printf("\nDump correction B=+0.5T:\n");
+  compP->Print("da");
+  printf("\nDump correction B=-0.5T:\n");
+  compM->Print("da");
+  //
+  comp0->Write("ExB-Field0");  
+  compP->Write("ExB-Bplus");
+  compM->Write("ExB-Bminus");
+  //
   //
   TCanvas *c = new TCanvas(name,name,800,800);
-  c->Divide(3,2);
+  c->Divide(4,2);
   c->cd(1);
   shiftITS->CreateHistoDRPhiinXY()->Draw("surf2");
   c->cd(2);
   twist->CreateHistoDRPhiinXY()->Draw("surf2");
   c->cd(3);
   eff->CreateHistoDRPhiinZR()->Draw("surf2");
-  c->cd(4);
-  shiftITSS->CreateHistoDRPhiinXY()->Draw("surf2");
   c->cd(5);
-  twistS->CreateHistoDRPhiinXY()->Draw("surf2");
+  shiftITSS->CreateHistoDRPhiinXY()->Draw("surf2");
   c->cd(6);
+  twistS->CreateHistoDRPhiinXY()->Draw("surf2");
+  c->cd(7);
   effS->CreateHistoDRPhiinZR()->Draw("surf2");
-  TObjArray * corr = new TObjArray;
+  //
+  c->cd(4);
+  compP->CreateHistoDRPhiinZR()->Draw("surf2");
+  c->cd(8);
+  compM->CreateHistoDRPhiinZR()->Draw("surf2");
+
 
   return c;
 }
+
+
+void MakeOCDBEntry(Int_t refRun){
+  //
+  // make a Correction OCDB entry
+  // take the fit values writen in config file
+  //
+  //
+  // 1. Read previous value used in calibration
+  //    OCDB has to be initialized before
+  
+  gROOT->Macro(Form("ConfigCalibTrain.C(%d)",refRun));  // configuring calib db
+  gROOT->LoadMacro("AddTaskTPCCalib.C");
+  gROOT->ProcessLine(Form("ConfigOCDB(%d);",refRun));
+  AliTPCCorrection *corr  = AliTPCcalibDB::Instance()->GetTPCComposedCorrection();
+  //
+  TFile f("correctionsExB.root");
+  AliTPCComposedCorrection * corrP0=(AliTPCComposedCorrection *)f.Get("/Correction physical/ExB-Field0");
+  AliTPCComposedCorrection * corrPP=(AliTPCComposedCorrection *)f.Get("/Correction physical/ExB-Bplus");
+  AliTPCComposedCorrection * corrPM=(AliTPCComposedCorrection *)f.Get("/Correction physical/ExB-Bminus");
+  //
+  AliTPCComposedCorrection * corrPE0=(AliTPCComposedCorrection *)f.Get("/Correction physical+Effective/ExB-Field0");
+  AliTPCComposedCorrection * corrPEP=(AliTPCComposedCorrection *)f.Get("/Correction physical+Effective/ExB-Bplus");
+  AliTPCComposedCorrection * corrPEM=(AliTPCComposedCorrection *)f.Get("/Correction physical+Effective/ExB-Bminus");
+  //
+  corrP0->SetName("Field0 correction");
+  corrPP->SetName("FieldP correction");
+  corrPM->SetName("FieldM correction");
+  corrPE0->SetName("Field0 correction");
+  corrPEP->SetName("FieldP correction");
+  corrPEM->SetName("FieldM correction");
+
+  TObjArray corrPhysical;
+  TObjArray corrPhysicalEffective;
+  //
+  // add the base correction
+  corrP0->GetCorrections()->Add(corr);
+  corrPP->GetCorrections()->Add(corr);
+  corrPM->GetCorrections()->Add(corr);
+  corrPE0->GetCorrections()->Add(corr);
+  corrPEP->GetCorrections()->Add(corr);
+  corrPEM->GetCorrections()->Add(corr);
+  //
+  corrPhysical.AddLast(corrP0);  corrPhysical.AddLast(corrPP);  corrPhysical.AddLast(corrPM); 
+  corrPhysicalEffective.AddLast(corrPE0);  corrPhysicalEffective.AddLast(corrPEP);  corrPhysicalEffective.AddLast(corrPEM); 
+  //
+  // make OCDB entries
+  TString userName=gSystem->GetFromPipe("echo $USER");
+  TString date=gSystem->GetFromPipe("date");
+  TString ocdbStorage="local:////";
+  ocdbStorage+=gSystem->GetFromPipe("pwd")+"/OCDB";
+  //
+  AliCDBMetaData *metaData= new AliCDBMetaData();
+  metaData->SetObjectClassName("TObjArray");
+  metaData->SetResponsible("Marian Ivanov");
+  metaData->SetBeamPeriod(1);
+  metaData->SetAliRootVersion("05-25-01"); //root version
+  metaData->SetComment(Form("Correction calibration. User: %s\n Data%s",userName.Data(),date.Data()));
+  AliCDBId* id1=NULL;
+  id1=new AliCDBId("TPC/Calib/Correction", 0, AliCDBRunRange::Infinity());
+  AliCDBStorage* gStorage = 0;
+
+  gStorage=AliCDBManager::Instance()->GetStorage((ocdbStorage+"Physical").Data());
+  gStorage->Put(&corrPhysical, (*id1), metaData);  
+  gStorage = AliCDBManager::Instance()->GetStorage((ocdbStorage+"PhysicalEffective").Data());
+  gStorage->Put(&corrPhysicalEffective, (*id1), metaData);  
+}
+
index a6acc80ff5b0b51a07dc9522ca41bf54458dfdcc..32b5c420fd7375b3ed1e8055e0f22eab6f31d328 100644 (file)
@@ -469,7 +469,7 @@ void MakeFitTree(){
   AliTPCComposedCorrection *cc= MakeComposedCorrection();
   TObjArray * corr = (TObjArray*)(cc->GetCorrections());
   //  corr->AddLast(cc);
-  const Int_t kskip=3;
+  const Int_t kskip=23;
   //
   TFile f("mean.root");
   TTree * tree= 0;
@@ -847,8 +847,8 @@ AliTPCComposedCorrection * MakeComposedCorrection(){
   Double_t vdrift = 2.6; // [cm/us]   // to be updated: per second (ideally)
   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
-  Double_t T1 = 0.9;
-  Double_t T2 = 1.5;
+  Double_t T1 = 1.0;
+  Double_t T2 = 1.0;
   //
   //