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