M AliTPCcalibBase.h - make magnetic field persistent
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Apr 2010 08:33:48 +0000 (08:33 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Apr 2010 08:33:48 +0000 (08:33 +0000)
M      AliTPCcalibDB.h          - adding composed correction
M      AliTPCCorrection.h       - fit the distorted track
M      AliTPCRecoParam.h        - flag to use composed correction
M      AliTPCcalibDB.cxx        - adding composed correction
M      AliTPCCorrection.cxx     - fit distorted track
M      AliTPCRecoParam.cxx      - usage of comsed correction flag
M      AliTPCTransform.cxx      - usage of composed correction

Marian

TPC/AliTPCCorrection.cxx
TPC/AliTPCCorrection.h
TPC/AliTPCRecoParam.cxx
TPC/AliTPCRecoParam.h
TPC/AliTPCTransform.cxx
TPC/AliTPCcalibBase.h
TPC/AliTPCcalibDB.cxx
TPC/AliTPCcalibDB.h

index a68bdd3..948c103 100644 (file)
 #include <TH2F.h>
 #include <TMath.h>
 #include <TROOT.h>
+#include <TTreeStream.h>
+
+#include  "AliExternalTrackParam.h"
+#include  "AliTrackPointArray.h"
+#include  "TDatabasePDG.h"
+#include  "AliTrackerBase.h"
+#include  "AliTPCROC.h"
+
 
 #include "AliTPCCorrection.h"
 
+ClassImp(AliTPCCorrection)
+
 // FIXME: the following values should come from the database
 const Double_t AliTPCCorrection::fgkTPC_Z0   =249.7;     // nominal gating grid position 
 const Double_t AliTPCCorrection::fgkIFCRadius= 83.06;    // Mean Radius of the Inner Field Cage ( 82.43 min,  83.70 max) (cm)
@@ -455,4 +465,130 @@ void AliTPCCorrection::Search( const Int_t n, const Double_t xArray[], const Dou
   
 }
 
-ClassImp(AliTPCCorrection)
+
+AliExternalTrackParam * AliTPCCorrection::FitDistortedTrack(const AliExternalTrackParam * trackIn, Double_t refX, Int_t dir,TTreeSRedirector *pcstream){
+  //
+  // Fit the track parameters - without and with distortion
+  // 1. Space points in the TPC are simulated along the trajectory  
+  // 2. Space points distorted
+  // 3. Fits  the non distorted and distroted track to the reference plane at refX
+  // 4. For visualization and debugging  purposes the space points and tracks can be stored  in the tree - using the TTreeSRedirector functionality 
+  //
+  // trackIn   - input track parameters
+  // refX     - reference X to fit the track
+  // dir      - direction - out=1 or in=-1
+  // pcstream -  debug streamer to check the results
+  //
+  AliTPCROC * roc = AliTPCROC::Instance();
+  const Int_t    npoints0=roc->GetNRows(0)+roc->GetNRows(36);
+  const Double_t kRTPC0  =roc->GetPadRowRadii(0,0);
+  const Double_t kRTPC1  =roc->GetPadRowRadii(36,roc->GetNRows(36)-1);
+    
+  const Double_t kMaxSnp = 0.85;  
+  const Double_t kSigmaY=0.1;
+  const Double_t kSigmaZ=0.1;
+  const Double_t kMass = TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
+
+  AliExternalTrackParam  track(*trackIn); // 
+  // generate points
+  AliTrackPointArray pointArray0(npoints0);
+  AliTrackPointArray pointArray1(npoints0);
+  Double_t xyz[3];
+  AliTrackerBase::PropagateTrackTo(&track,kRTPC0,kMass,3,kTRUE,kMaxSnp);
+  //
+  // simulate the track
+  Int_t npoints=0;
+  Float_t covPoint[6]={0,0,0, kSigmaY*kSigmaY,0,kSigmaZ*kSigmaZ};  //covariance at the local frame
+  for (Double_t radius=kRTPC0; radius<kRTPC1; radius++){
+    AliTrackerBase::PropagateTrackTo(&track,radius,kMass,3,kTRUE,kMaxSnp);
+    track.GetXYZ(xyz);
+    AliTrackPoint pIn0;                               // space point          
+    AliTrackPoint pIn1;
+    Int_t roc= (xyz[2]>0)? 0:18;
+    pointArray0.GetPoint(pIn0,npoints);
+    pointArray1.GetPoint(pIn1,npoints);
+    Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
+    Float_t distPoint[3]={xyz[0],xyz[1],xyz[2]};
+    DistortPoint(distPoint, roc);
+    pIn0.SetXYZ(xyz[0], xyz[1],xyz[2]);
+    pIn1.SetXYZ(distPoint[0], distPoint[1],distPoint[2]);
+    //
+    track.Rotate(alpha);
+    AliTrackPoint prot0 = pIn0.Rotate(alpha);   // rotate to the local frame - non distoted  point
+    AliTrackPoint prot1 = pIn1.Rotate(alpha);   // rotate to the local frame -     distorted point
+    prot0.SetXYZ(prot0.GetX(),prot0.GetY(), prot0.GetZ(),covPoint);
+    prot1.SetXYZ(prot1.GetX(),prot1.GetY(), prot1.GetZ(),covPoint);
+    pIn0=prot0.Rotate(-alpha);                       // rotate back to global frame
+    pIn1=prot1.Rotate(-alpha);                       // rotate back to global frame
+    pointArray0.AddPoint(npoints, &pIn0);      
+    pointArray1.AddPoint(npoints, &pIn1);
+    npoints++;
+    if (npoints>=npoints0) break;
+  }
+  //
+  // refit track
+  //
+  AliExternalTrackParam *track0=0;
+  AliExternalTrackParam *track1=0;
+  AliTrackPoint   point1,point2,point3;
+  if (dir==1) {  //make seed inner
+    pointArray0.GetPoint(point1,1);
+    pointArray0.GetPoint(point2,10);
+    pointArray0.GetPoint(point3,20);
+  }
+  if (dir==-1){ //make seed outer
+    pointArray0.GetPoint(point1,npoints-20);
+    pointArray0.GetPoint(point2,npoints-10);
+    pointArray0.GetPoint(point3,npoints-1);
+  }  
+  track0 = AliTrackerBase::MakeSeed(point1, point2, point3);
+  track1 = AliTrackerBase::MakeSeed(point1, point2, point3);
+
+
+  for (Int_t jpoint=0; jpoint<npoints; jpoint++){
+    Int_t ipoint= (dir>0) ? ipoint: npoints-1-jpoint;
+    //
+    AliTrackPoint pIn0;
+    AliTrackPoint pIn1;
+    pointArray0.GetPoint(pIn0,ipoint);
+    pointArray1.GetPoint(pIn1,ipoint);
+    AliTrackPoint prot0 = pIn0.Rotate(track0->GetAlpha());   // rotate to the local frame - non distoted  point
+    AliTrackPoint prot1 = pIn1.Rotate(track1->GetAlpha());   // rotate to the local frame -     distorted point
+    //
+    AliTrackerBase::PropagateTrackTo(track0,prot0.GetX(),kMass,1,kFALSE,kMaxSnp);
+    AliTrackerBase::PropagateTrackTo(track1,prot1.GetX(),kMass,1,kFALSE,kMaxSnp);
+    track.GetXYZ(xyz);
+    //
+    Double_t pointPos[2]={0,0};
+    Double_t pointCov[3]={0,0,0};
+    pointPos[0]=prot0.GetY();//local y
+    pointPos[1]=prot0.GetZ();//local z
+    pointCov[0]=prot0.GetCov()[3];//simay^2
+    pointCov[1]=prot0.GetCov()[4];//sigmayz
+    pointCov[2]=prot0.GetCov()[5];//sigmaz^2
+    track0->Update(pointPos,pointCov);
+    //
+    pointPos[0]=prot1.GetY();//local y
+    pointPos[1]=prot1.GetZ();//local z
+    pointCov[0]=prot1.GetCov()[3];//simay^2
+    pointCov[1]=prot1.GetCov()[4];//sigmayz
+    pointCov[2]=prot1.GetCov()[5];//sigmaz^2
+    track1->Update(pointPos,pointCov);
+  }
+
+  AliTrackerBase::PropagateTrackTo(track0,refX,kMass,2.,kTRUE,kMaxSnp);
+  track1->Rotate(track0->GetAlpha());
+  AliTrackerBase::PropagateTrackTo(track1,refX,kMass,2.,kFALSE,kMaxSnp);
+
+  if (pcstream) (*pcstream)<<"fitDistort"<<
+    "point0.="<<&pointArray0<<   //  points
+    "point1.="<<&pointArray1<<   //  distorted points
+    "trackIn.="<<&track<<       //  original track
+    "track0.="<<track0<<         //  fitted track
+    "track1.="<<track1<<         //  fitted distorted track
+    "\n";
+  delete track0;
+  return track1;
+}
+
+
index aa39c23..cc79df9 100644 (file)
@@ -34,6 +34,8 @@
 #include <TNamed.h>
 class TH2F;
 class TCollection;
+class TTreeSRedirector;
+class AliExternalTrackParam;
 
 class AliTPCCorrection : public TNamed {
 public:
@@ -67,6 +69,7 @@ public:
 
   // normally called directly in the correction classes which inherit from this class
   virtual void SetOmegaTauT1T2(Float_t omegaTau,Float_t t1,Float_t t2);
+  AliExternalTrackParam * FitDistortedTrack(const AliExternalTrackParam * trackIn, Double_t refX, Int_t dir,TTreeSRedirector *pcstream);
 
 protected:
   TH2F* CreateTH2F(const char *name,const char *title,
index b06b876..16cc47f 100644 (file)
@@ -86,6 +86,7 @@ AliTPCRecoParam::AliTPCRecoParam():
   fBKinkFinder(kTRUE),
   fLastSeedRowSec(120),
   fUseFieldCorrection(2),      // use field correction
+  fUseComposedCorrection(kFALSE),      // use field correction
   fUseRPHICorrection(0),      // use rphi correction
   fUseRadialCorrection(0),    // use radial correction
   fUseQuadrantAlignment(0),   // use quadrant alignment
index 6e727af..93d2588 100644 (file)
@@ -70,6 +70,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
   // Correction setup
   //
   void  SetUseFieldCorrection(Int_t flag){fUseFieldCorrection=flag;}
+  void  SetUseComposedCorrection(Bool_t flag){fUseComposedCorrection=flag;}
   void  SetUseRPHICorrection(Int_t flag){fUseRPHICorrection=flag;}
   void  SetUseRadialCorrection(Int_t flag){fUseRadialCorrection=flag;}
   void  SetUseQuadrantAlignment(Int_t flag){fUseQuadrantAlignment=flag;}
@@ -81,6 +82,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
   void  SetUseTOFCorrection(Bool_t flag) {fUseTOFCorrection = flag;}
   //
   Int_t GetUseFieldCorrection() const {return fUseFieldCorrection;}
+  Int_t GetUseComposedCorrection() const {return fUseComposedCorrection;}
   Int_t GetUseRPHICorrection() const {return fUseRPHICorrection;}
   Int_t GetUseRadialCorrection() const {return fUseRadialCorrection;}
   Int_t GetUseQuadrantAlignment() const {return fUseQuadrantAlignment;}
@@ -143,6 +145,7 @@ class AliTPCRecoParam : public AliDetectorRecoParam
   // Correction switches
   //
   Int_t fUseFieldCorrection;     // use field correction
+  Bool_t fUseComposedCorrection; // flag to use composed correction
   Int_t fUseRPHICorrection;      // use rphi correction
   Int_t fUseRadialCorrection;    // use radial correction
   Int_t fUseQuadrantAlignment;   // use quadrant alignment
@@ -168,7 +171,7 @@ public:
                                       // to be switched off for pass 0 reconstruction
                                       // Use static function, other option will be to use 
                                       // additional specific storage ?
-  ClassDef(AliTPCRecoParam, 9)
+  ClassDef(AliTPCRecoParam, 10)
 };
 
 
index 6781ba9..6759286 100755 (executable)
@@ -59,6 +59,7 @@
 #include "TMath.h"
 #include "AliLog.h"
 #include "AliTPCExB.h"
+#include "AliTPCCorrection.h"
 #include "TGeoMatrix.h"
 #include "AliTPCRecoParam.h"
 #include "AliTPCCalibVdrift.h"
@@ -146,6 +147,7 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   AliTPCCalPad * distortionMapY = calib->GetDistortionMap(0); 
   AliTPCCalPad * distortionMapZ = calib->GetDistortionMap(1); 
   AliTPCParam  * param    = calib->GetParameters(); 
+  AliTPCCorrection * correction = calib->GetTPCComposedCorrection();
   if (!time0TPC){
     AliFatal("Time unisochronity missing");
   }
@@ -168,9 +170,9 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   // Alignment
   //TODO:  calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
   RotatedGlobal2Global(sector,x);
+  
   //
-  //
-  // ExB correction
+  // old ExB correction 
   //
   if(fCurrentRecoParam&&fCurrentRecoParam->GetUseExBCorrection()) {
 
@@ -184,6 +186,18 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   }
 
   //
+  // new composed  correction  - will replace soon ExB correction
+  //
+  if(fCurrentRecoParam&&fCurrentRecoParam->GetUseComposedCorrection()&&correction) {
+    Float_t distPoint[3]={xx[0],xx[1],xx[2]};
+    correction->CorrectPoint(distPoint, sector);
+    xx[0]=distPoint[0];
+    xx[1]=distPoint[1];
+    xx[2]=distPoint[2];
+  } 
+
+
+  //
   // Time of flight correction
   // 
   if (fCurrentRecoParam&&fCurrentRecoParam->GetUseTOFCorrection()){
index fd826b5..ceb1d6a 100644 (file)
@@ -56,7 +56,7 @@ protected:
   Int_t  fEvent;                        //! current Event number
   Int_t  fTime;                         //!  current Time
   ULong64_t  fTrigger;                  //! current trigger mask
-  Float_t fMagF;                        //! current magnetic field 
+  Float_t fMagF;                        // current magnetic field 
   Int_t   fTriggerMaskReject;           //trigger mask - non accept trigger
   Int_t   fTriggerMaskAccept;           //trigger mask - accept
   Bool_t  fHasLaser;                    //flag the laser is overlayed with given event
@@ -68,7 +68,7 @@ protected:
 private:
   Int_t  fDebugLevel;                   //  debug level
 
-  ClassDef(AliTPCcalibBase,1)
+  ClassDef(AliTPCcalibBase,2)
 };
 
 #endif
index 808311c..59fe2e5 100644 (file)
@@ -124,7 +124,7 @@ class AliTPCCalDet;
 #include "AliTPCCalibVdrift.h"
 #include "AliTPCCalibRaw.h"
 #include "AliTPCParam.h"
-
+#include "AliTPCCorrection.h"
 #include "AliTPCPreprocessorOnline.h"
 
 
@@ -179,6 +179,7 @@ AliTPCcalibDB::AliTPCcalibDB():
   fDedxGainFactor(0),
   fPadTime0(0),
   fDistortionMap(0),
+  fComposedCorrection(0),
   fPadNoise(0),
   fPedestals(0),
   fCalibRaw(0),
@@ -219,6 +220,7 @@ AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
   fDedxGainFactor(0),
   fPadTime0(0),
   fDistortionMap(0),
+  fComposedCorrection(0),
   fPadNoise(0),
   fPedestals(0),
   fCalibRaw(0),
index 3ae3a0c..611f090 100644 (file)
@@ -37,6 +37,7 @@ class TMap;
 class AliMagF;
 class AliTPCcalibDButil;
 class AliCTPTimeParams;
+class AliTPCCorrection;
 //class AliCDBStorage;
 
 class AliTPCcalibDB : public TObject
@@ -64,6 +65,8 @@ class AliTPCcalibDB : public TObject
   AliTPCCalPad* GetDedxGainFactor() const {return fDedxGainFactor;}
   AliTPCCalPad* GetPadTime0() const {return fPadTime0;}
   AliTPCCalPad* GetDistortionMap(Int_t i) const {return (fDistortionMap) ? (AliTPCCalPad*)fDistortionMap->At(i):0;}
+  AliTPCCorrection * GetTPCComposedCorrection() const { return fComposedCorrection;}
+  void          SetTPCComposedCorrection(AliTPCCorrection *compCorr) { fComposedCorrection=compCorr;}
   AliTPCCalPad* GetPadNoise() const {return fPadNoise;}
   AliTPCCalPad* GetPedestals() const{return fPedestals;}
   //ALTRO config data
@@ -175,6 +178,7 @@ protected:
   AliTPCCalPad* fDedxGainFactor;   // Gain calibration entry - for dEdx
   AliTPCCalPad* fPadTime0;        // Time0 calibration entry
   TObjArray   *fDistortionMap;    // distortion map
+  AliTPCCorrection *fComposedCorrection;  // general space point corrections
   AliTPCCalPad* fPadNoise;        // Noise calibration entry
   AliTPCCalPad* fPedestals;       // Pedestal calibration entry
   AliTPCCalibRaw *fCalibRaw;      // raw data calibration entry