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