]>
Commit | Line | Data |
---|---|---|
a4c640e1 | 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 | ||
9dcc11e4 | 16 | /* |
17 | $Log: AliT0Align.cxx,v $ | |
18 | Revision 2008/01/30 | |
19 | Removing code violations | |
a4c640e1 | 20 | |
9dcc11e4 | 21 | Version 1.1 2006/10 |
22 | Preliminary test version (T.Malkiewicz) | |
23 | */ | |
a4c640e1 | 24 | |
25 | #include "AliT0Align.h" | |
a4c640e1 | 26 | #include "TROOT.h" |
27 | #include "Riostream.h" | |
28 | #include "TFile.h" | |
29 | #include "TMath.h" | |
30 | #include "TSystem.h" | |
f7350425 | 31 | #include "TString.h" |
a4c640e1 | 32 | #include "AliSurveyObj.h" |
33 | #include "AliAlignObjParams.h" | |
34 | #include "AliCDBStorage.h" | |
35 | #include <TClonesArray.h> | |
36 | #include <TFile.h> | |
37 | #include "AliLog.h" | |
38 | #include "AliCDBManager.h" | |
9dcc11e4 | 39 | #include "AliSurveyPoint.h" |
40 | ||
41 | // Class creating the T0 aligmnent objects | |
42 | // from the surveys done by surveyers at Point2. | |
43 | // Survey results are fetched from | |
44 | // Survey Depot, based on survey results | |
45 | // position of T0 alignment objects is computed. | |
46 | ||
a4c640e1 | 47 | |
48 | ClassImp(AliT0Align) | |
49 | ||
50 | AliT0Align::AliT0Align() : | |
51 | TObject(), | |
9dcc11e4 | 52 | fFileGlob(0x0), |
a4c640e1 | 53 | fT0AAlignObj(0x0), |
54 | fT0CAlignObj(0x0), | |
9dcc11e4 | 55 | fDebug(0), |
81c2ef80 | 56 | fXPosC(0.), |
57 | fYPosC(0.), | |
58 | fXPosA(0.), | |
59 | fYPosA(0.), | |
60 | fRepLoc(0), | |
61 | fRepGlob(0), | |
62 | fSide(0x0), | |
63 | fUser(0x0) | |
64 | { | |
a4c640e1 | 65 | // |
66 | // default constructor | |
67 | // | |
68 | } | |
69 | //________________________________________________________________________ | |
81c2ef80 | 70 | AliT0Align::AliT0Align(Int_t reportloc, Int_t side, Int_t reportglob) : |
a4c640e1 | 71 | TObject(), |
9dcc11e4 | 72 | fFileGlob(0x0), |
a4c640e1 | 73 | fT0AAlignObj(0x0), |
74 | fT0CAlignObj(0x0), | |
9dcc11e4 | 75 | fDebug(0), |
81c2ef80 | 76 | fXPosC(0.), |
77 | fYPosC(0.), | |
78 | fXPosA(0.), | |
79 | fYPosA(0.), | |
80 | fRepLoc(0), | |
81 | fRepGlob(0), | |
82 | fSide(0x0), | |
83 | fUser(0x0) | |
a4c640e1 | 84 | { |
85 | // | |
86 | // constructor - defines data files | |
87 | // | |
88 | fRepLoc = reportloc; | |
81c2ef80 | 89 | fRepGlob = reportglob; |
90 | fSide = side; | |
769a17f9 | 91 | // Char_t path[50]; |
92 | TString path = Form("%s",gSystem->Getenv("ALICE_ROOT")) ; | |
93 | // fFileGlob = new Char_t[80]; | |
94 | // fUser = new Char_t[10]; | |
95 | fFileGlob = Form("%s/T0/Survey_%d_V0.txt",path.Data(),reportglob); | |
96 | fUser = Form("%s/T0/Survey_%d_V0.txt",path.Data(),reportglob); | |
97 | // sprintf(path,gSystem->Getenv("ALICE_ROOT")); | |
a4c640e1 | 98 | // |
99 | // sprintf(fFileLoc,"%s/T0/Survey_%d_T0.txt",path,reportloc); | |
769a17f9 | 100 | // sprintf(fFileGlob,"%s/T0/Survey_%d_V0.txt",path,reportglob); |
a4c640e1 | 101 | // |
769a17f9 | 102 | // sprintf(fUser,gSystem->Getenv("alien_API_USER")); |
a4c640e1 | 103 | } |
104 | //_________________________________________________________________________ | |
105 | AliT0Align::AliT0Align(const AliT0Align &align) : | |
106 | TObject(), | |
9dcc11e4 | 107 | fFileGlob(0x0), |
a4c640e1 | 108 | fT0AAlignObj(0x0), |
109 | fT0CAlignObj(0x0), | |
9dcc11e4 | 110 | fDebug(0), |
81c2ef80 | 111 | fXPosC(0.), |
112 | fYPosC(0.), | |
113 | fXPosA(0.), | |
114 | fYPosA(0.), | |
115 | fRepLoc(0), | |
116 | fRepGlob(0), | |
117 | fSide(0x0), | |
118 | fUser(0x0) | |
a4c640e1 | 119 | { |
120 | // | |
121 | // copy constructor - dummy | |
122 | // | |
57b90263 | 123 | ((AliT0Align &) align).Copy(*this); |
124 | ||
a4c640e1 | 125 | } |
126 | //__________________________________________________________________________ | |
127 | AliT0Align & AliT0Align::operator =(const AliT0Align & align) | |
128 | { | |
129 | // | |
130 | // assignment operator - dummy | |
131 | // | |
57b90263 | 132 | if (this != &align) ((AliT0Align &) align).Copy(*this); |
133 | ||
134 | return (*this); | |
a4c640e1 | 135 | } |
136 | ||
137 | //__________________________________________________________________________ | |
d6ac4d13 | 138 | AliT0Align::~AliT0Align() |
139 | { | |
a4c640e1 | 140 | // |
141 | // destructor | |
142 | // | |
143 | if(fT0AAlignObj) delete fT0AAlignObj; | |
144 | if(fT0CAlignObj) delete fT0CAlignObj; | |
203ca5a7 | 145 | if(fFileGlob) delete[] fFileGlob; |
d6ac4d13 | 146 | if(fUser) delete[] fUser; |
a4c640e1 | 147 | } |
148 | //__________________________________________________________________________ | |
149 | Bool_t AliT0Align::LoadSurveyData() | |
150 | { | |
151 | // | |
152 | // Create a new survey object and fill it. | |
153 | ||
154 | AliSurveyObj * s1 = new AliSurveyObj(); | |
81c2ef80 | 155 | const int numberPoints = 2; |
1e8a79ac | 156 | TString pointNames[numberPoints]={"Flange_0","C67_6_Beamcircle"}; |
a4c640e1 | 157 | |
158 | if(fRepLoc == 0) | |
81c2ef80 | 159 | { |
160 | // | |
161 | // Filling from DCDB (via GRID) | |
162 | // | |
163 | s1->SetGridUser(fUser); | |
164 | if(fSide == 0) | |
165 | { | |
166 | s1->Fill("T0", fRepGlob, fUser); | |
167 | } | |
168 | else if(fSide == 1) | |
169 | { | |
170 | s1->Fill("VZERO", fRepGlob, fUser); | |
171 | } | |
172 | else | |
173 | { | |
174 | cout<<"Enter the side properly: '0'- A side, '1'- C side'" <<endl; | |
175 | return 0; | |
176 | } | |
a4c640e1 | 177 | } |
a4c640e1 | 178 | else |
179 | // | |
180 | // Filling from local file | |
181 | // | |
182 | { | |
183 | s1->FillFromLocalFile(fFileGlob); | |
184 | } | |
185 | // | |
81c2ef80 | 186 | Float_t surveyedPoints [numberPoints][2]; |
a4c640e1 | 187 | AliSurveyPoint *currPoint; |
188 | ||
189 | // | |
190 | for(Int_t i=0;i<numberPoints;i++) | |
191 | { | |
192 | currPoint=0; | |
193 | currPoint = (AliSurveyPoint *) s1->GetData()->FindObject(pointNames[i]); | |
194 | // | |
195 | if(currPoint) | |
196 | { | |
197 | surveyedPoints[i][0]=currPoint->GetX(); | |
198 | surveyedPoints[i][1]=currPoint->GetY(); | |
199 | // surveyedPoints[i]=currPoint->GetZ(); | |
200 | if(fDebug) | |
093a8821 | 201 | Printf("INFO: Point %s coordinates read.\n", pointNames[i].Data() ) ; |
a4c640e1 | 202 | } |
203 | else | |
204 | { | |
205 | if(fDebug) | |
206 | { | |
093a8821 | 207 | Printf("ERROR: Essential point missing: %s\n", pointNames[i].Data() ) ; |
a4c640e1 | 208 | return 1; |
209 | } | |
210 | } | |
211 | } | |
81c2ef80 | 212 | if(fSide == 0) |
213 | { | |
214 | fXPosA = surveyedPoints[0][0]; | |
215 | fYPosA = surveyedPoints[0][1]; | |
216 | } | |
217 | else if(fSide == 1) | |
218 | { | |
219 | fXPosC = surveyedPoints[1][0]; | |
220 | fYPosC = surveyedPoints[1][1]; | |
221 | } | |
a4c640e1 | 222 | // |
223 | delete s1; | |
224 | // | |
225 | return 0; | |
226 | } | |
227 | //_________________________________________________________________ | |
228 | ||
229 | Double_t AliT0Align::ComputePosition() | |
230 | { | |
231 | // Float_t fZPos, shift; | |
232 | // fZPos = surveyedPoints[3] - shift; | |
a80ab6cd | 233 | return 0; |
a4c640e1 | 234 | } |
235 | //_______________________________________________________________________ | |
81c2ef80 | 236 | void AliT0Align::CreateAlignObj() |
237 | { | |
a4c640e1 | 238 | // |
a9ab7568 | 239 | // TClonesArray *array = new TClonesArray("AliAlignObjParams",2); |
a4c640e1 | 240 | // TClonesArray &alobj = *array; |
241 | ||
a4c640e1 | 242 | Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.; |
81c2ef80 | 243 | dx=fXPosA; |
244 | dy=fYPosA; | |
a4c640e1 | 245 | fT0AAlignObj = new AliAlignObjParams("ALIC_1/0STL_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE); |
246 | ||
81c2ef80 | 247 | dx=fXPosC; |
248 | dy=fYPosC; | |
a4c640e1 | 249 | // dz=surveyedPoints[2]; |
250 | dz=0.; | |
251 | fT0CAlignObj = new AliAlignObjParams("ALIC_1/0STR_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE); | |
81c2ef80 | 252 | |
a4c640e1 | 253 | } |
254 | ||
255 | //______________________________________________________________________ | |
81c2ef80 | 256 | void AliT0Align::Run() |
257 | { | |
a4c640e1 | 258 | // |
259 | // runs the full chain | |
260 | // | |
cd2b94bd | 261 | // SetDebug(0); |
a4c640e1 | 262 | Bool_t flag = LoadSurveyData(); |
263 | if(flag) | |
264 | { | |
265 | cout<<"Missing points"<<endl; | |
266 | return; | |
267 | } | |
268 | // ComputePosition(); | |
269 | CreateAlignObj(); | |
270 | StoreAlignObj(); | |
271 | } | |
272 | //_________________________________________________________________________ | |
273 | ||
274 | void AliT0Align::StoreAlignObj() | |
275 | { | |
9dcc11e4 | 276 | // |
277 | // Storing T0 alignment objects | |
278 | // | |
a4c640e1 | 279 | AliCDBManager* cdb = AliCDBManager::Instance(); |
162637e4 | 280 | if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
a4c640e1 | 281 | // |
282 | TClonesArray *array = new TClonesArray("AliAlignObjParams",2); | |
283 | // | |
284 | Double_t shifts[3]; | |
285 | Double_t rots[3]; | |
286 | // | |
287 | fT0AAlignObj->GetPars(shifts,rots); | |
288 | new((*array)[0]) AliAlignObjParams(fT0AAlignObj->GetSymName(),0,shifts[0], | |
289 | shifts[1],shifts[2],rots[0],rots[1],rots[2],kTRUE); | |
290 | fT0CAlignObj->GetPars(shifts,rots); | |
291 | new((*array)[1]) AliAlignObjParams(fT0CAlignObj->GetSymName(),0,shifts[0], | |
292 | shifts[1],shifts[2],rots[0],rots[1],rots[2],kTRUE); | |
293 | ||
294 | ||
295 | // | |
296 | // storing either in the OCDB or local file | |
297 | // | |
298 | if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ | |
299 | // save on file | |
300 | const char* filename = "T0SurveyMisalignment.root"; | |
f7350425 | 301 | // Char_t fullname[80]; |
302 | // sprintf(fullname,"%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"),filename); | |
303 | TString fullname = Form("%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"), filename); | |
304 | TFile *f = new TFile(fullname.Data(),"RECREATE"); | |
a4c640e1 | 305 | if(!f){ |
306 | AliError("cannot open file for output\n"); | |
307 | return; | |
308 | } | |
309 | AliInfo(Form("Saving alignment objects to the file %s", filename)); | |
310 | f->cd(); | |
311 | f->WriteObject(array,"T0AlignObjs","kSingleKey"); | |
312 | f->Close(); | |
313 | }else{ | |
314 | // save in CDB storage | |
315 | AliCDBStorage* storage; | |
316 | // | |
317 | TString Storage = gSystem->Getenv("STORAGE"); | |
318 | if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { | |
319 | AliError(Form( | |
320 | "STORAGE variable set to %s is not valid. Exiting\n",Storage.Data())); | |
321 | return; | |
322 | } | |
323 | storage = cdb->GetStorage(Storage.Data()); | |
324 | if(!storage){ | |
325 | AliError(Form("Unable to open storage %s\n",Storage.Data())); | |
326 | return; | |
327 | } | |
328 | // | |
329 | AliCDBMetaData* md = new AliCDBMetaData(); | |
330 | md->SetResponsible("Tomasz Malkiewicz"); | |
81c2ef80 | 331 | md->SetComment("Position of T0-A and T0-C from survey"); |
a4c640e1 | 332 | AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity()); |
333 | storage->Put(array,id,md); | |
334 | } | |
335 | } | |
336 |