LCOV - code coverage report
Current view: top level - TRD/TRDbase - AliTRDalignment.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 28 3.6 %
Date: 2016-06-14 17:26:59 Functions: 1 34 2.9 %

          Line data    Source code
       1             : #ifndef ALITRDALIGNMENT_H
       2             : #define ALITRDALIGNMENT_H
       3             : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       4             :  * See cxx source for full Copyright notice                               */
       5             : 
       6             : /* $Id$ */
       7             : 
       8             : ////////////////////////////////////////////////////////////////////////////
       9             : //                                                                        //
      10             : // AliTRDalignment class is an instrument for reading, writing, and       //
      11             : // manipulating of the TRD alignment data.                                //
      12             : // D.Miskowiec, November 2006                                             //
      13             : //                                                                        //
      14             : ////////////////////////////////////////////////////////////////////////////
      15             : 
      16             : #include <TObject.h>
      17             : #include <TRandom.h>
      18             : #include <TObjString.h>
      19             : #include <AliGeomManager.h>
      20             : class TClonesArray;
      21             : class AliSurveyObj;
      22             : 
      23             : class AliTRDalignment : public TObject {
      24             :   
      25             :  public:
      26             : 
      27             :   AliTRDalignment();
      28             :   AliTRDalignment(const AliTRDalignment& source);
      29             :   AliTRDalignment& operator=(const AliTRDalignment& source);  
      30             :   AliTRDalignment& operator*=(double fac);  
      31             :   AliTRDalignment& operator+=(const AliTRDalignment& source);  
      32             :   AliTRDalignment& operator-=(const AliTRDalignment& source);  
      33             :   Bool_t operator==(const AliTRDalignment& source) const;  
      34           0 :   virtual ~AliTRDalignment() {};
      35             : 
      36             :   // setters 
      37             : 
      38             :   void SetSmZero();                                  // reset to zero supermodule data
      39             :   void SetChZero();                                  // reset to zero chamber data
      40           0 :   void SetSm(int sm, const double a[6])              {for (int i = 0; i < 6; i++) fSm[sm][i] = a[i];}
      41           0 :   void SetCh(int ch, const double a[6])              {for (int i = 0; i < 6; i++) fCh[ch][i] = a[i];}
      42             :   void SetSmRandom(double a[6]);                     // generate random gaussians with sigmas a
      43             :   void SetChRandom(double a[6]);                     // generate random gaussians with sigmas a
      44             :   void SetSmFull();                                  // set supermodule data to initial aka full 
      45             :   void SetChFull();                                  // set chamber data to initial aka full 
      46             :   void SetSmResidual();                              // set supermodule data to final aka residual
      47             :   void SetChResidual();                              // set chamber data to final aka residual
      48           0 :   void SetZero()                                     {SetSmZero(); SetChZero();}
      49           0 :   void SetIdeal()                                    {SetZero();}
      50           0 :   void SetFull()                                     {SetSmFull(); SetChFull();}
      51           0 :   void SetResidual()                                 {SetSmResidual(); SetChResidual();}
      52           0 :   void SetComment(char *s)                           {fComment.SetString(s);} 
      53             : 
      54             :   // simple getters (for other getters see below)
      55             : 
      56           0 :   void GetSm(int sm, double * const a) const         {for (int i = 0; i < 6; i++) a[i] = fSm[sm][i];}
      57           0 :   void GetCh(int ch, double * const a) const         {for (int i = 0; i < 6; i++) a[i] = fCh[ch][i];}
      58             :   
      59             :   // dumping on screen
      60             : 
      61             :   void PrintSm(int sm, FILE * const fp = stdout) const;   // print data of a supermodule
      62             :   void PrintCh(int ch, FILE * const fp = stdout) const;   // print data of a chamber
      63           0 :   void PrintSm(FILE * const fp = stdout) const       {for (int i = 0; i <  18; i++)  PrintSm(i,fp);}
      64           0 :   void PrintCh(FILE * const fp = stdout) const       {for (int i = 0; i < 540; i++)  PrintCh(i,fp);}
      65           0 :   void Print(FILE * const fp = stdout) const         {PrintSm(fp); PrintCh(fp);                    }
      66           0 :   void Print(Option_t *) const                       {Print();                                     } 
      67             : 
      68             :   // reading-in from file
      69             : 
      70             :   void ReadAscii(const char * const filename);           // read from ascii file
      71             :   void ReadCurrentGeo();                                 // read from currently loaded geometry
      72             :   void ReadRoot(const char * const filename);            // read from root file
      73             :   void ReadDB(const char * const filename);              // read from DB file
      74             :   void ReadDB(const char * const db, const char * const path, int run, int version=-1, int subversion=-1);
      75             :   Bool_t DecodeSurveyPointName(TString pna, Int_t &sm, Int_t &iz,Int_t &ir, Int_t &iphi);
      76             :   void ReadSurveyReport(const char * const filename);    // read from survey report
      77             :   void ReadSurveyReport(const AliSurveyObj * const so);  // read from survey object 
      78             :   void ReadAny(const char * const  filename);            // read from any kind of file
      79             : 
      80             :   // writing on file
      81             : 
      82             :   void WriteAscii(const char * const filename) const;                    // store data on ascii file
      83             :   void WriteRoot(const char * const filename);                           // store data on root file
      84             :   void WriteDB(const char * const fina, int r0, int r1, int v, int s);   // store data on a local DB-like file
      85             :   void WriteDB(char * const db, const char * const pa, int r0, int r1);  // store data on DB file
      86             :   void WriteGeo(char *filename);                                         // apply misalignment and store geometry 
      87             : 
      88             :   // geometry and symbolic names getters
      89             : 
      90             :   // phi-sector number of chamber ch, 0-17
      91           0 :   int GetSec(int ch) const           {return ch/30;}
      92             :   // stack number, 0-4
      93           0 :   int GetSta(int ch) const           {return ch%30/6;}
      94             :   // plane number, 0-5 
      95           0 :   int GetPla(int ch) const           {return ch%30%6;}
      96             :   // module number, 0-89
      97           0 :   int GetMod(int ch) const           {return 5*GetSec(ch)+GetSta(ch);} 
      98             :   // layer number, 9-14
      99           0 :   int GetLay(int ch) const           {return AliGeomManager::kTRD1+GetPla(ch);}
     100             :   // volume id
     101           0 :   UShort_t GetVoi(int ch) const      {return AliGeomManager::LayerToVolUID(GetLay(ch),GetMod(ch));}
     102             :   // symbolic name of a supermodule
     103           0 :   char *GetSmName(int sm) const      {return Form("TRD/sm%02d",sm);}
     104             :   // symbolic name of a chamber
     105           0 :   char *GetChName(int ch) const      {return Form("TRD/sm%02d/st%d/pl%d",GetSec(ch),GetSta(ch),GetPla(ch));}
     106             :   // index of a supermodule 
     107           0 :   int GetSmIndex(const char *name)   {for (int i=0; i<18; i++) if (strcmp(name,GetSmName(i))==0) return i; return -1;}
     108             :   // index of a chamber
     109           0 :   int GetChIndex(const char *name)   {for (int i=0; i<540; i++) if (strcmp(name,GetChName(i))==0) return i; return -1;}
     110             : 
     111             :   // data analysis
     112             : 
     113             :   double GetSmRMS(int xyz) const;                    // calculate rms fSm[*][xyz]
     114             :   double GetChRMS(int xyz) const;                    // calculate rms fCh[*][xyz]
     115             :   void   PrintSmRMS() const;                         // print rms of fSm
     116             :   void   PrintChRMS() const;                         // print rms of fCh
     117           0 :   void   PrintRMS() const                            {PrintSmRMS(); PrintChRMS();}
     118             : 
     119             :   double SurveyChi2(int i, const double * const a);  // compare survey with ideal, return chi2
     120           0 :   double SurveyChi2(const double * const a)          {return SurveyChi2(fIbuffer[0],a);}
     121             :   void   SurveyToAlignment(int i, const char * const flag);  // determine alignment of supermodule i based on survey
     122           0 :   void   SurveyToAlignment(const char * const flag)  {for (int i=0; i<18; i++) SurveyToAlignment(i,flag);}
     123             : 
     124             :  protected:
     125             : 
     126             :   void   ArToNumbers(TClonesArray * const ar);       // read ar and fill fSm and fCh
     127             :   void   NumbersToAr(TClonesArray * const ar);       // build ar using fSm and fCh data
     128             :   int    IsGeoLoaded();                              // check if geometry is loaded
     129             : 
     130             :  protected:
     131             : 
     132             :   double     fSm[18][6];                             // supermodule data
     133             :   double     fCh[540][6];                            // chamber data 
     134             :   TObjString fComment;                               // info concerning origin of the data etc.
     135             :   TRandom    fRan;                                   // random generator for fake alignment data
     136             : 
     137             :   // Temporary storage for ideal position of the survey points and the survey data.
     138             :   // The survey data are in master frame and in cm. Each supermodule has 8 survey marks. 
     139             :   // The indices are sm number, z-end, radius, phi. 
     140             :   // The ideal positions of survey points are in local frame of supermodule and in cm. 
     141             :   // The indices are z-end, radius, phi. 
     142             :   // The processed survey results are stored in fSm.
     143             :   double fSurveyX[18][2][2][2];                      // supermodule survey point X
     144             :   double fSurveyY[18][2][2][2];                      // supermodule survey point Y
     145             :   double fSurveyZ[18][2][2][2];                      // supermodule survey point Z
     146             :   double fSurveyEX[18][2][2][2];                     // supermodule survey point X error
     147             :   double fSurveyEY[18][2][2][2];                     // supermodule survey point Y error
     148             :   double fSurveyEZ[18][2][2][2];                     // supermodule survey point Z error
     149             :   double fSurveyX0[2][2][2];                         // ideal X position of the survey marks
     150             :   double fSurveyY0[2][2][2];                         // ideal Y position of the survey marks
     151             :   double fSurveyZ0[2][2][2];                         // ideal Z position of the survey marks
     152             :   int    fIbuffer[1000];                             // generic buffer for misc. operations
     153             :   double fDbuffer[1000];                             // generic buffer for misc. operations
     154             : 
     155          48 :   ClassDef(AliTRDalignment,1)    
     156             : 
     157             : };
     158             :     
     159             : #endif

Generated by: LCOV version 1.11