]>
Commit | Line | Data |
---|---|---|
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 <AliGeomManager.h> |
afba1460 | 20 | class AliSurveyObj; |
8775e4e8 | 21 | |
22 | class 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 | |
5626950c | 35 | // setters |
8775e4e8 | 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 | |
5626950c | 53 | // simple getters (for other getters see below) |
54 | ||
55 | void GetSm(int sm, double * const a) {for (int i = 0; i < 6; i++) a[i] = fSm[sm][i];} | |
56 | void GetCh(int ch, double * const a) {for (int i = 0; i < 6; i++) a[i] = fCh[ch][i];} | |
57 | ||
8775e4e8 | 58 | // dumping on screen |
59 | ||
5626950c | 60 | void PrintSm(int sm, FILE * const fp = stdout) const; // print data of a supermodule |
61 | void PrintCh(int ch, FILE * const fp = stdout) const; // print data of a chamber | |
62 | void PrintSm(FILE * const fp = stdout) const {for (int i = 0; i < 18; i++) PrintSm(i,fp);} | |
63 | void PrintCh(FILE * const fp = stdout) const {for (int i = 0; i < 540; i++) PrintCh(i,fp);} | |
64 | void Print(FILE * const fp = stdout) const {PrintSm(fp); PrintCh(fp); } | |
d15124a9 | 65 | void Print(Option_t *) const {Print(); } |
8775e4e8 | 66 | |
67 | // reading-in from file | |
68 | ||
5626950c | 69 | void ReadAscii(const char * const filename); // read from ascii file |
70 | void ReadCurrentGeo(); // read from currently loaded geometry | |
71 | void ReadRoot(const char * const filename); // read from root file | |
72 | void ReadDB(const char * const filename); // read from DB file | |
73 | void ReadDB(const char * const db, const char * const path, int run, int version=-1, int subversion=-1); | |
afba1460 | 74 | Bool_t DecodeSurveyPointName(TString pna, Int_t &sm, Int_t &iz,Int_t &ir, Int_t &iphi); |
5626950c | 75 | void ReadSurveyReport(const char * const filename); // read from survey report |
76 | void ReadSurveyReport(const AliSurveyObj * const so); // read from survey object | |
77 | void ReadAny(const char * const filename); // read from any kind of file | |
8775e4e8 | 78 | |
79 | // writing on file | |
80 | ||
5626950c | 81 | void WriteAscii(const char * const filename) const; // store data on ascii file |
82 | void WriteRoot(const char * const filename); // store data on root file | |
83 | void WriteDB(const char * const filename, int run0, int run1); // store data on a local DB-like file | |
84 | void WriteDB(char * const db, const char * const pa, int r0, int r1); // store data on DB file | |
85 | void WriteGeo(char *filename); // apply misalignment and store geometry | |
8775e4e8 | 86 | |
87 | // geometry and symbolic names getters | |
88 | ||
89 | // phi-sector number of chamber ch, 0-17 | |
69219822 | 90 | int GetSec(int ch) const {return ch/30;} |
8775e4e8 | 91 | // stack number, 0-4 |
69219822 | 92 | int GetSta(int ch) const {return ch%30/6;} |
d15124a9 | 93 | // plane number, 0-5 |
69219822 | 94 | int GetPla(int ch) const {return ch%30%6;} |
8775e4e8 | 95 | // module number, 0-89 |
69219822 | 96 | int GetMod(int ch) const {return 5*GetSec(ch)+GetSta(ch);} |
8775e4e8 | 97 | // layer number, 9-14 |
69219822 | 98 | int GetLay(int ch) const {return AliGeomManager::kTRD1+GetPla(ch);} |
8775e4e8 | 99 | // volume id |
69219822 | 100 | UShort_t GetVoi(int ch) const {return AliGeomManager::LayerToVolUID(GetLay(ch),GetMod(ch));} |
d15124a9 | 101 | // symbolic name of a supermodule |
69219822 | 102 | char *GetSmName(int sm) const {return Form("TRD/sm%02d",sm);} |
d15124a9 | 103 | // symbolic name of a chamber |
69219822 | 104 | char *GetChName(int ch) const {return Form("TRD/sm%02d/st%d/pl%d",GetSec(ch),GetSta(ch),GetPla(ch));} |
105 | // index of a supermodule | |
106 | int GetSmIndex(const char *name) {for (int i=0; i<18; i++) if (strcmp(name,GetSmName(i))==0) return i; return -1;} | |
107 | // index of a chamber | |
108 | int GetChIndex(const char *name) {for (int i=0; i<540; i++) if (strcmp(name,GetChName(i))==0) return i; return -1;} | |
8775e4e8 | 109 | |
110 | // data analysis | |
111 | ||
d15124a9 | 112 | double GetSmRMS(int xyz) const; // calculate rms fSm[*][xyz] |
113 | double GetChRMS(int xyz) const; // calculate rms fCh[*][xyz] | |
114 | void PrintSmRMS() const; // print rms of fSm | |
115 | void PrintChRMS() const; // print rms of fCh | |
116 | void PrintRMS() const {PrintSmRMS(); PrintChRMS();} | |
117 | ||
5626950c | 118 | double SurveyChi2(int i, const double * const a); // compare survey with ideal, return chi2 |
119 | double SurveyChi2(const double * const a) {return SurveyChi2(fIbuffer[0],a);} | |
120 | void SurveyToAlignment(int i, const char * const flag); // determine alignment of supermodule i based on survey | |
121 | void SurveyToAlignment(const char * const flag) {for (int i=0; i<18; i++) SurveyToAlignment(i,flag);} | |
8775e4e8 | 122 | |
123 | protected: | |
124 | ||
5626950c | 125 | void ArToNumbers(TClonesArray * const ar); // read ar and fill fSm and fCh |
126 | void NumbersToAr(TClonesArray * const ar); // build ar using fSm and fCh data | |
69219822 | 127 | int IsGeoLoaded(); // check if geometry is loaded |
8775e4e8 | 128 | |
129 | protected: | |
130 | ||
d15124a9 | 131 | double fSm[18][6]; // supermodule data |
132 | double fCh[540][6]; // chamber data | |
133 | TObjString fComment; // info concerning origin of the data etc. | |
134 | TRandom fRan; // random generator for fake alignment data | |
135 | ||
136 | // Temporary storage for ideal position of the survey points and the survey data. | |
137 | // The survey data are in master frame and in cm. Each supermodule has 8 survey marks. | |
138 | // The indices are sm number, z-end, radius, phi. | |
139 | // The ideal positions of survey points are in local frame of supermodule and in cm. | |
140 | // The indices are z-end, radius, phi. | |
141 | // The processed survey results are stored in fSm. | |
142 | double fSurveyX[18][2][2][2]; // supermodule survey point X | |
143 | double fSurveyY[18][2][2][2]; // supermodule survey point Y | |
144 | double fSurveyZ[18][2][2][2]; // supermodule survey point Z | |
afba1460 | 145 | double fSurveyEX[18][2][2][2]; // supermodule survey point X error |
146 | double fSurveyEY[18][2][2][2]; // supermodule survey point Y error | |
147 | double fSurveyEZ[18][2][2][2]; // supermodule survey point Z error | |
d15124a9 | 148 | double fSurveyX0[2][2][2]; // ideal X position of the survey marks |
149 | double fSurveyY0[2][2][2]; // ideal Y position of the survey marks | |
150 | double fSurveyZ0[2][2][2]; // ideal Z position of the survey marks | |
151 | int fIbuffer[1000]; // generic buffer for misc. operations | |
152 | double fDbuffer[1000]; // generic buffer for misc. operations | |
8775e4e8 | 153 | |
154 | ClassDef(AliTRDalignment,1) | |
155 | ||
156 | }; | |
157 | ||
158 | #endif |