]>
Commit | Line | Data |
---|---|---|
0af6f9be | 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 | /* | |
17 | $Log$ | |
18 | Revision 1.1 2007/10/01 14:12:45 pchrist | |
19 | Class creating the aligmnent object fro the surveyor measurements. | |
20 | ||
21 | */ | |
22 | ||
23 | // | |
24 | // Creates the SSD align object | |
25 | // | |
26 | // | |
27 | #include "Riostream.h" | |
28 | #include "TFile.h" | |
29 | #include "TSystem.h" | |
30 | #include "TClonesArray.h" | |
31 | #include "TGeoManager.h" | |
32 | #include "TGeoMatrix.h" | |
33 | #include "TGeoPhysicalNode.h" | |
34 | ||
35 | #include "AliITSSurveyToAlignSSD.h" | |
36 | #include "AliSurveyObj.h" | |
37 | #include "AliSurveyPoint.h" | |
38 | #include "AliAlignObjParams.h" | |
39 | ||
40 | #include "AliLog.h" | |
41 | ||
42 | #include "AliCDBManager.h" | |
43 | #include "AliCDBEntry.h" | |
44 | #include "AliCDBStorage.h" | |
45 | ||
46 | ClassImp(AliITSSurveyToAlignSSD) | |
47 | ||
48 | //________________________________________________________________________ | |
49 | AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD() : | |
50 | TObject(), | |
51 | fRun(0), | |
eda96f1f | 52 | fFileLocal(0x0), |
53 | fFileGrid(0x0), | |
0af6f9be | 54 | fSurveyPoints(0), |
55 | fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)), | |
56 | fSSDAlignObjParam(0), | |
57 | fDebug(0) { | |
58 | // | |
59 | // default constructor | |
60 | // | |
61 | } | |
62 | ||
63 | //________________________________________________________________________ | |
eda96f1f | 64 | AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD(Int_t reportId, Int_t runNumber) : |
0af6f9be | 65 | TObject(), |
66 | fRun(0), | |
eda96f1f | 67 | fFileLocal(0x0), |
68 | fFileGrid(0x0), | |
0af6f9be | 69 | fSurveyPoints(0), |
70 | fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)), | |
71 | fSSDAlignObjParam(0), | |
72 | fDebug(0) { | |
73 | // | |
74 | // constructor - defines data files | |
75 | // | |
eda96f1f | 76 | fRun = runNumber; |
77 | fFileLocal = new Char_t[80]; | |
78 | fFileGrid = new Char_t[80]; | |
0af6f9be | 79 | Char_t path[50]; |
0af6f9be | 80 | |
eda96f1f | 81 | sprintf(path,gSystem->Getenv("ALICE_ROOT")); |
82 | sprintf(fFileLocal,"%s/ITS/Survey_SSD_%d.txt",path,reportId); | |
0af6f9be | 83 | } |
eda96f1f | 84 | |
0af6f9be | 85 | //_________________________________________________________________________ |
86 | AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD(const AliITSSurveyToAlignSSD &align) : | |
87 | TObject(), | |
3a4cb7b6 | 88 | fRun(0), |
eda96f1f | 89 | fFileLocal(0x0), |
90 | fFileGrid(0x0), | |
0af6f9be | 91 | fSurveyPoints(0), |
92 | fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)), | |
93 | fSSDAlignObjParam(0), | |
94 | fDebug(0) { | |
95 | // | |
96 | // copy constructor - dummy | |
97 | ||
98 | fDebug = align.fDebug; | |
99 | } | |
100 | ||
101 | //__________________________________________________________________________ | |
102 | AliITSSurveyToAlignSSD & AliITSSurveyToAlignSSD::operator =(const AliITSSurveyToAlignSSD & align) { | |
103 | // | |
104 | // assignment operator - dummy | |
105 | // | |
106 | fDebug = align.fDebug; | |
107 | return (*this); | |
108 | } | |
109 | ||
110 | //__________________________________________________________________________ | |
111 | AliITSSurveyToAlignSSD::~AliITSSurveyToAlignSSD() { | |
112 | // | |
113 | // destructor | |
114 | // | |
115 | if(fSurveyPoints) delete fSurveyPoints; | |
116 | if(fSSDAlignObj) delete fSSDAlignObj; | |
117 | if(fSSDAlignObjParam) delete fSSDAlignObjParam; | |
118 | } | |
119 | ||
120 | //______________________________________________________________________ | |
121 | void AliITSSurveyToAlignSSD::Run() { | |
122 | // | |
123 | // runs the full chain | |
124 | // | |
125 | SetDebug(0); | |
126 | Bool_t flag = LoadSurveyData(); | |
127 | if(!flag) { | |
128 | cout<<"Missing points"<<endl; | |
129 | return; | |
130 | } | |
131 | CreateAlignObj(); | |
132 | StoreAlignObj(); | |
0af6f9be | 133 | } |
134 | ||
135 | //__________________________________________________________________________ | |
136 | Bool_t AliITSSurveyToAlignSSD::LoadSurveyData() { | |
137 | // | |
138 | // for a time being it loads from the local file the surveyed point | |
139 | // and has the ideal points hardwired. I am waiting until Ricardo | |
140 | // completes his job | |
141 | // | |
142 | ||
143 | //Load survey data from the local file | |
144 | AliSurveyObj * s1 = new AliSurveyObj(); | |
eda96f1f | 145 | if(s1->FillFromLocalFile(fFileLocal)) |
0af6f9be | 146 | fSurveyPoints = s1->GetData(); |
147 | else | |
148 | return kFALSE; | |
149 | ||
150 | cout<<"Number of SSD survey points: "<<fSurveyPoints->GetEntries()<<endl; | |
151 | ||
152 | return kTRUE; | |
153 | } | |
154 | ||
155 | //_______________________________________________________________________ | |
156 | void AliITSSurveyToAlignSSD::CreateAlignObj(){ | |
157 | // | |
158 | // This method creates AliAlignObj and fills it with Euler angles | |
159 | // and shifts. The units are degrees and cm. | |
160 | // | |
161 | TClonesArray &alobj = *fSSDAlignObj; | |
162 | ||
163 | //load ideal geometry from the OCDB | |
164 | AliCDBManager *cdb = AliCDBManager::Instance(); | |
165 | cdb->SetDefaultStorage("local://$ALICE_ROOT"); | |
166 | cdb->SetRun(fRun); | |
167 | AliCDBEntry* entry = cdb->Get("GRP/Geometry/Data"); | |
168 | AliGeomManager::SetGeometry(gGeoManager); | |
169 | ||
170 | AliSurveyPoint* pt = 0; | |
171 | TGeoHMatrix* hm = 0; | |
172 | TGeoPNEntry* pne = 0; | |
173 | Double_t* tr; | |
174 | Int_t uid; | |
175 | const char* symname; | |
176 | Double_t sx, sy, sz; | |
177 | Int_t ilayer, imodule; | |
178 | ||
179 | for(Int_t imod = 0; imod < fSurveyPoints->GetEntries(); imod++) { | |
180 | pt = (AliSurveyPoint*) fSurveyPoints->At(imod); | |
181 | if(!pt) continue; | |
432925f4 | 182 | sx = pt->GetX(); |
183 | sy = pt->GetY(); | |
184 | sz = pt->GetZ(); | |
0af6f9be | 185 | |
186 | ilayer = (imod < 748) ? AliGeomManager::kSSD1 : AliGeomManager::kSSD2; | |
187 | imodule = (imod < 748) ? imod : imod - 748; | |
188 | ||
189 | uid = AliGeomManager::LayerToVolUID(ilayer,imodule); | |
190 | symname = AliGeomManager::SymName(uid); | |
191 | pne = gGeoManager->GetAlignableEntryByUID(uid); | |
192 | hm = pne->GetGlobalOrig(); | |
193 | tr = hm->GetTranslation(); | |
194 | ||
195 | //Printf("symname %s", symname); | |
196 | //Printf("x,y,z from survey: %f %f %f", sx, sy, sz); | |
197 | //Printf("x,y,z from ideal : %f %f %f", tr[0], tr[1], tr[2]); | |
198 | ||
199 | new(alobj[imod]) AliAlignObjParams(symname, uid, sx-tr[0], sy-tr[1], sz-tr[2], 0., 0., 0., kTRUE); | |
200 | }//module loop | |
201 | ||
202 | delete entry; | |
203 | } | |
204 | ||
205 | //_________________________________________________________________________ | |
206 | void AliITSSurveyToAlignSSD::StoreAlignObj(){ | |
207 | // Stores the TClonesArray of AliAlignObj in | |
208 | // $ALICE_ROOT/ITS/Align/Data/SSDfromSurvey.root | |
209 | // In a later version these objects will be merged | |
210 | // with the SDD ones and will be put in the OCDB | |
211 | const char* filename = "$ALICE_ROOT/ITS/Align/Data/SSDfromSurvey.root"; | |
212 | TFile *f = TFile::Open(filename,"RECREATE"); | |
213 | if(!f){ | |
214 | Error(filename,"cannot open file for output\n"); | |
215 | return; | |
216 | } | |
217 | cout<<"Saving alignment objects to the file "<<filename<<endl; | |
218 | f->cd(); | |
eda96f1f | 219 | f->WriteObject(fSSDAlignObj,"ITSAlignObjs","kSingleKey"); |
0af6f9be | 220 | f->Close(); |
0af6f9be | 221 | } |