1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 $Log: AliT0Align.cxx,v $
19 Removing code violations
22 Preliminary test version (T.Malkiewicz)
25 #include "AliT0Align.h"
27 #include "Riostream.h"
32 #include "AliSurveyObj.h"
33 #include "AliAlignObjParams.h"
34 #include "AliCDBStorage.h"
35 #include <TClonesArray.h>
38 #include "AliCDBManager.h"
39 #include "AliSurveyPoint.h"
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.
50 AliT0Align::AliT0Align() :
66 // default constructor
69 //________________________________________________________________________
70 AliT0Align::AliT0Align(Int_t reportloc, Int_t side, Int_t reportglob) :
86 // constructor - defines data files
89 fRepGlob = reportglob;
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"));
99 // sprintf(fFileLoc,"%s/T0/Survey_%d_T0.txt",path,reportloc);
100 // sprintf(fFileGlob,"%s/T0/Survey_%d_V0.txt",path,reportglob);
102 // sprintf(fUser,gSystem->Getenv("alien_API_USER"));
104 //_________________________________________________________________________
105 AliT0Align::AliT0Align(const AliT0Align &align) :
121 // copy constructor - dummy
123 ((AliT0Align &) align).Copy(*this);
126 //__________________________________________________________________________
127 AliT0Align & AliT0Align::operator =(const AliT0Align & align)
130 // assignment operator - dummy
132 if (this != &align) ((AliT0Align &) align).Copy(*this);
137 //__________________________________________________________________________
138 AliT0Align::~AliT0Align()
143 if(fT0AAlignObj) delete fT0AAlignObj;
144 if(fT0CAlignObj) delete fT0CAlignObj;
145 if(fFileGlob) delete[] fFileGlob;
146 if(fUser) delete[] fUser;
148 //__________________________________________________________________________
149 Bool_t AliT0Align::LoadSurveyData()
152 // Create a new survey object and fill it.
154 AliSurveyObj * s1 = new AliSurveyObj();
155 const int numberPoints = 2;
156 TString pointNames[numberPoints]={"Flange_0","C67_6_Beamcircle"};
161 // Filling from DCDB (via GRID)
163 s1->SetGridUser(fUser);
166 s1->Fill("T0", fRepGlob, fUser);
170 s1->Fill("VZERO", fRepGlob, fUser);
174 cout<<"Enter the side properly: '0'- A side, '1'- C side'" <<endl;
180 // Filling from local file
183 s1->FillFromLocalFile(fFileGlob);
186 Float_t surveyedPoints [numberPoints][2];
187 AliSurveyPoint *currPoint;
190 for(Int_t i=0;i<numberPoints;i++)
193 currPoint = (AliSurveyPoint *) s1->GetData()->FindObject(pointNames[i]);
197 surveyedPoints[i][0]=currPoint->GetX();
198 surveyedPoints[i][1]=currPoint->GetY();
199 // surveyedPoints[i]=currPoint->GetZ();
201 Printf("INFO: Point %s coordinates read.\n", pointNames[i].Data() ) ;
207 Printf("ERROR: Essential point missing: %s\n", pointNames[i].Data() ) ;
214 fXPosA = surveyedPoints[0][0];
215 fYPosA = surveyedPoints[0][1];
219 fXPosC = surveyedPoints[1][0];
220 fYPosC = surveyedPoints[1][1];
227 //_________________________________________________________________
229 Double_t AliT0Align::ComputePosition()
231 // Float_t fZPos, shift;
232 // fZPos = surveyedPoints[3] - shift;
235 //_______________________________________________________________________
236 void AliT0Align::CreateAlignObj()
239 // TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
240 // TClonesArray &alobj = *array;
242 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
245 fT0AAlignObj = new AliAlignObjParams("ALIC_1/0STL_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
249 // dz=surveyedPoints[2];
251 fT0CAlignObj = new AliAlignObjParams("ALIC_1/0STR_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
255 //______________________________________________________________________
256 void AliT0Align::Run()
259 // runs the full chain
262 Bool_t flag = LoadSurveyData();
265 cout<<"Missing points"<<endl;
268 // ComputePosition();
272 //_________________________________________________________________________
274 void AliT0Align::StoreAlignObj()
277 // Storing T0 alignment objects
279 AliCDBManager* cdb = AliCDBManager::Instance();
280 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
282 TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
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);
296 // storing either in the OCDB or local file
298 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
300 const char* filename = "T0SurveyMisalignment.root";
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");
306 AliError("cannot open file for output\n");
309 AliInfo(Form("Saving alignment objects to the file %s", filename));
311 f->WriteObject(array,"T0AlignObjs","kSingleKey");
314 // save in CDB storage
315 AliCDBStorage* storage;
317 TString Storage = gSystem->Getenv("STORAGE");
318 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
320 "STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()));
323 storage = cdb->GetStorage(Storage.Data());
325 AliError(Form("Unable to open storage %s\n",Storage.Data()));
329 AliCDBMetaData* md = new AliCDBMetaData();
330 md->SetResponsible("Tomasz Malkiewicz");
331 md->SetComment("Position of T0-A and T0-C from survey");
332 AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
333 storage->Put(array,id,md);