LCOV - code coverage report
Current view: top level - TRD/TRDbase - AliTRDtransform.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 72 164 43.9 %
Date: 2016-06-14 17:26:59 Functions: 9 16 56.2 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ////////////////////////////////////////////////////////////////////////////
      19             : //                                                                        //
      20             : //  Transforms clusters into space points with calibrated positions       //
      21             : //  defined in the local tracking system                                  //
      22             : //                                                                        //
      23             : ////////////////////////////////////////////////////////////////////////////
      24             : 
      25             : #include <TGeoMatrix.h>
      26             : 
      27             : #include "AliLog.h"
      28             : 
      29             : #include "AliTRDtransform.h"
      30             : #include "AliTRDcluster.h"
      31             : #include "AliTRDgeometry.h"
      32             : #include "AliTRDpadPlane.h"
      33             : #include "AliTRDCommonParam.h"
      34             : #include "AliTRDcalibDB.h"
      35             : #include "AliTRDCalDet.h"
      36             : #include "AliTRDCalROC.h"
      37             : 
      38          48 : ClassImp(AliTRDtransform)
      39             : 
      40             : //_____________________________________________________________________________
      41             : AliTRDtransform::AliTRDtransform()
      42           0 :   :TObject()
      43           0 :   ,fDetector(0)
      44           0 :   ,fParam(0x0)
      45           0 :   ,fCalibration(0x0)
      46           0 :   ,fCalVdriftROC(0x0)
      47           0 :   ,fCalT0ROC(0x0)
      48           0 :   ,fCalPRFROC(0x0)
      49           0 :   ,fkCalVdriftDet(0x0)
      50           0 :   ,fkCalT0Det(0x0)
      51           0 :   ,fkCalExBDet(0x0)
      52           0 :   ,fCalVdriftDetValue(0)
      53           0 :   ,fCalT0DetValue(0)
      54           0 :   ,fCalExBDetValue(0)
      55           0 :   ,fSamplingFrequency(0)
      56           0 :   ,fPadPlane(0x0)
      57           0 :   ,fZShiftIdeal(0)
      58           0 :   ,fMatrix(0x0)
      59           0 : {
      60             :   //
      61             :   // AliTRDtransform default constructor
      62             :   //
      63             : 
      64           0 :   fParam             = AliTRDCommonParam::Instance();
      65           0 :   if (!fParam) {
      66           0 :     AliError("Could not get common parameters\n");
      67             :   }
      68           0 :   fSamplingFrequency = fParam->GetSamplingFrequency();
      69             : 
      70           0 :   fCalibration       = AliTRDcalibDB::Instance();
      71           0 :   if (!fCalibration) {
      72           0 :     AliError("Cannot find calibration object");
      73             :   }
      74             : 
      75             :   // Get the calibration objects for the global calibration
      76           0 :   fkCalVdriftDet     = fCalibration->GetVdriftDet();
      77           0 :   fkCalT0Det         = fCalibration->GetT0Det();
      78           0 :   fkCalExBDet        = fCalibration->GetExBDet();
      79             : 
      80           0 : }
      81             : 
      82             : //_____________________________________________________________________________
      83             : AliTRDtransform::AliTRDtransform(Int_t det)
      84           2 :   :TObject()
      85           2 :   ,fDetector(0)
      86           2 :   ,fParam(0x0)
      87           2 :   ,fCalibration(0x0)
      88           2 :   ,fCalVdriftROC(0x0)
      89           2 :   ,fCalT0ROC(0x0)
      90           2 :   ,fCalPRFROC(0x0)
      91           2 :   ,fkCalVdriftDet(0x0)
      92           2 :   ,fkCalT0Det(0x0)
      93           2 :   ,fkCalExBDet(0x0)
      94           2 :   ,fCalVdriftDetValue(0)
      95           2 :   ,fCalT0DetValue(0)
      96           2 :   ,fCalExBDetValue(0)
      97           2 :   ,fSamplingFrequency(0)
      98           2 :   ,fPadPlane(0x0)
      99           2 :   ,fZShiftIdeal(0)
     100           2 :   ,fMatrix(0x0)
     101          10 : {
     102             :   //
     103             :   // AliTRDtransform constructor for a given detector
     104             :   //
     105             : 
     106           4 :   fParam             = AliTRDCommonParam::Instance();
     107           2 :   if (!fParam) {
     108           0 :     AliError("Could not get common parameters\n");
     109             :   }
     110           2 :   fSamplingFrequency = fParam->GetSamplingFrequency();
     111             : 
     112           4 :   fCalibration       = AliTRDcalibDB::Instance();
     113           2 :   if (!fCalibration) {
     114           0 :     AliError("Cannot find calibration object");
     115             :   }
     116             : 
     117             :   // Get the calibration objects for the global calibration
     118           4 :   fkCalVdriftDet     = fCalibration->GetVdriftDet();
     119           4 :   fkCalT0Det         = fCalibration->GetT0Det();
     120           4 :   fkCalExBDet        = fCalibration->GetExBDet();
     121             : 
     122           2 :   SetDetector(det);
     123             : 
     124           4 : }
     125             : 
     126             : //_____________________________________________________________________________
     127             : AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
     128           0 :   :TObject(t)
     129           0 :   ,fDetector(t.fDetector)
     130           0 :   ,fParam(0x0)
     131           0 :   ,fCalibration(0x0)
     132           0 :   ,fCalVdriftROC(0x0)
     133           0 :   ,fCalT0ROC(0x0)
     134           0 :   ,fCalPRFROC(0x0)
     135           0 :   ,fkCalVdriftDet(0x0)
     136           0 :   ,fkCalT0Det(0x0)
     137           0 :   ,fkCalExBDet(0x0)
     138           0 :   ,fCalVdriftDetValue(0)
     139           0 :   ,fCalT0DetValue(0)
     140           0 :   ,fCalExBDetValue(0)
     141           0 :   ,fSamplingFrequency(0)
     142           0 :   ,fPadPlane(0x0)
     143           0 :   ,fZShiftIdeal(0)
     144           0 :   ,fMatrix(0x0)
     145           0 : {
     146             :   //
     147             :   // AliTRDtransform copy constructor
     148             :   //
     149             : 
     150           0 :   fParam             = AliTRDCommonParam::Instance();
     151           0 :   if (!fParam) {
     152           0 :     AliError("Could not get common parameters\n");
     153             :   }
     154           0 :   fSamplingFrequency = fParam->GetSamplingFrequency();
     155             : 
     156           0 :   fCalibration = AliTRDcalibDB::Instance();
     157           0 :   if (!fCalibration) {
     158           0 :     AliError("Cannot find calibration object");
     159             :   }
     160           0 :   fkCalVdriftDet     = fCalibration->GetVdriftDet();
     161           0 :   fkCalT0Det         = fCalibration->GetT0Det();
     162           0 :   fkCalExBDet        = fCalibration->GetExBDet();
     163           0 : }
     164             : 
     165             : //_____________________________________________________________________________
     166             : AliTRDtransform::~AliTRDtransform()
     167           8 : {
     168             :   //
     169             :   // AliTRDtransform destructor
     170             :   //
     171             :   //  delete fCalibration;
     172           8 : }
     173             : 
     174             : //_____________________________________________________________________________
     175             : AliTRDtransform &AliTRDtransform::operator=(const AliTRDtransform &t)
     176             : {
     177             :   //
     178             :   // Assignment operator
     179             :   //
     180             : 
     181           0 :   if (this != &t) {
     182           0 :     ((AliTRDtransform &) t).Copy(*this);
     183           0 :   }
     184             : 
     185           0 :   return *this;
     186             : 
     187             : }
     188             : 
     189             : //_____________________________________________________________________________
     190             : void AliTRDtransform::Copy(TObject &t) const
     191             : {
     192             :   //
     193             :   // Copy function
     194             :   //
     195             : 
     196           0 :   ((AliTRDtransform &) t).fDetector          = fDetector;
     197           0 :   ((AliTRDtransform &) t).fParam             = AliTRDCommonParam::Instance();
     198           0 :   ((AliTRDtransform &) t).fCalibration       = AliTRDcalibDB::Instance();
     199           0 :   if (fCalibration) {
     200           0 :     ((AliTRDtransform &) t).fkCalVdriftDet   = fCalibration->GetVdriftDet();
     201           0 :     ((AliTRDtransform &) t).fkCalT0Det       = fCalibration->GetT0Det();
     202           0 :     ((AliTRDtransform &) t).fkCalExBDet      = fCalibration->GetExBDet();
     203           0 :   }
     204             :   else {
     205           0 :     ((AliTRDtransform &) t).fkCalVdriftDet   = 0;
     206           0 :     ((AliTRDtransform &) t).fkCalT0Det       = 0;
     207           0 :     ((AliTRDtransform &) t).fkCalExBDet      = 0;
     208             :   }
     209           0 :   ((AliTRDtransform &) t).fCalVdriftROC      = 0x0;
     210           0 :   ((AliTRDtransform &) t).fCalT0ROC          = 0x0;
     211           0 :   ((AliTRDtransform &) t).fCalPRFROC         = 0x0;
     212           0 :   ((AliTRDtransform &) t).fCalVdriftDetValue = 0; 
     213           0 :   ((AliTRDtransform &) t).fCalT0DetValue     = 0;
     214           0 :   ((AliTRDtransform &) t).fCalExBDetValue     = 0;
     215           0 :   ((AliTRDtransform &) t).fSamplingFrequency = 0;
     216           0 :   ((AliTRDtransform &) t).fPadPlane          = 0x0;
     217           0 :   ((AliTRDtransform &) t).fZShiftIdeal       = 0;
     218           0 :   ((AliTRDtransform &) t).fMatrix            = 0x0;
     219             : 
     220           0 : }
     221             : 
     222             : //_____________________________________________________________________________
     223             : AliTRDgeometry& AliTRDtransform::Geometry()
     224             : {
     225        3490 :   static AliTRDgeometry g;
     226        1742 :   if (!g.CreateClusterMatrixArray()) {
     227           0 :     AliErrorGeneral("AliTRDtransform::Geometry()", "Could not get transformation matrices\n");
     228           0 :   }
     229        1742 :   return g;
     230           0 : }
     231             : 
     232             : //_____________________________________________________________________________
     233             : void AliTRDtransform::SetDetector(Int_t det)
     234             : {
     235             :   //
     236             :   // Set to a new detector number and update the calibration objects
     237             :   // and values accordingly
     238             :   //
     239             : 
     240         756 :   fDetector          = det;
     241             : 
     242             :   // Get the calibration objects for the pad-by-pad calibration
     243         378 :   fCalVdriftROC      = fCalibration->GetVdriftROC(det);
     244         378 :   fCalT0ROC          = fCalibration->GetT0ROC(det);
     245         378 :   fCalPRFROC         = fCalibration->GetPRFROC(det);
     246             : 
     247             :   // Get the detector wise defined calibration values
     248         378 :   fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
     249         378 :   fCalT0DetValue     = fkCalT0Det->GetValue(det);
     250         378 :   fCalExBDetValue    = fkCalExBDet->GetValue(det);
     251             : 
     252             :   // Shift needed to define Z-position relative to middle of chamber
     253         378 :   Int_t layer        = Geometry().GetLayer(det);
     254         378 :   Int_t stack        = Geometry().GetStack(det);
     255         378 :   fPadPlane          = Geometry().GetPadPlane(layer,stack);
     256         378 :   fZShiftIdeal       = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
     257             : 
     258             :   // Get the current transformation matrix
     259         378 :   fMatrix            = Geometry().GetClusterMatrix(det);
     260             : 
     261         378 : }
     262             : 
     263             : //_____________________________________________________________________________
     264             : Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
     265             : {
     266             :   //
     267             :   // Transforms the local cluster coordinates into calibrated 
     268             :   // space point positions defined in the local tracking system.
     269             :   //
     270             :   // Here the calibration for T0, Vdrift and ExB is applied as well.
     271             :   //
     272             :   // Input: Cluster in the local chamber coordinates
     273             :   // Output: Tracking cluster
     274             : 
     275       38722 :   if (!fMatrix) return kFALSE;
     276             : 
     277             : 
     278             :   // Parameters to adjust the X position of clusters in the alignable volume
     279       18452 :   const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
     280             : 
     281             :  
     282             :   // Retrieve calibration values
     283       18452 :   Int_t col = c->GetPadCol(), row = c->GetPadRow();
     284             :   // drift velocity
     285       18452 :   Double_t vd  = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
     286             :   // t0
     287       18452 :   Double_t t0  = fCalT0DetValue     + fCalT0ROC->GetValue(col,row);
     288       18452 :   t0 /= fSamplingFrequency;
     289             :   // ExB correction
     290       18452 :   Double_t exb = fCalExBDetValue;//AliTRDCommonParam::Instance()->GetOmegaTau(vd);
     291             : 
     292       18452 :   Float_t x = c->GetXloc(t0, vd);
     293             : 
     294             :   // Pad dimensions
     295       18452 :   Double_t rs = fPadPlane->GetRowSize(row);
     296       18452 :   Double_t cs = fPadPlane->GetColSize(col);
     297             : 
     298             :   // cluster error with diffusion corrections
     299       18452 :   Double_t s2  = cs*fCalPRFROC->GetValue(col, row); 
     300       18452 :   s2 *= s2; 
     301       18452 :   Float_t dl, dt;
     302       18452 :   AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
     303             : 
     304       18452 :   Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
     305       73808 :   Double_t loc[] = {
     306       18452 :     kX0shift-x,                    // Invert the X-position,
     307       18452 :     c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
     308       18452 :     fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
     309             :   };
     310             : 
     311             :   // Go to tracking coordinates
     312       18452 :   Double_t trk[3];
     313       18452 :   fMatrix->LocalToMaster(loc, trk);
     314             : 
     315             :   // store tracking values
     316       18452 :   c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
     317       18452 :   c->SetSigmaY2(s2, dt, exb, x);
     318       18452 :   c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
     319             :   
     320             :   return kTRUE;
     321             : 
     322       37510 : }
     323             : 
     324             : //_____________________________________________________________________________
     325             : void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
     326             : {
     327             :   //
     328             :   // Recalibrates the position of a given cluster
     329             :   // If <setDet> is TRUE, the detector number is set for each cluster
     330             :   // automatically. Otherwise, AliTRDtransform::SetDetector() has to
     331             :   // be used.
     332             :   //
     333             : 
     334           0 :   if (setDet) SetDetector(c->GetDetector());
     335           0 :   Transform(c);
     336             : 
     337           0 : }

Generated by: LCOV version 1.11