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