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"
31 #include "AliSurveyObj.h"
32 #include "AliAlignObjParams.h"
33 #include "AliCDBStorage.h"
34 #include <TClonesArray.h>
37 #include "AliCDBManager.h"
38 #include "AliSurveyPoint.h"
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.
49 AliT0Align::AliT0Align() :
65 // default constructor
68 //________________________________________________________________________
69 AliT0Align::AliT0Align(Int_t reportloc, Int_t side, Int_t reportglob) :
85 // constructor - defines data files
88 fRepGlob = reportglob;
91 fFileGlob = new Char_t[80];
92 fUser = new Char_t[10];
93 sprintf(path,gSystem->Getenv("ALICE_ROOT"));
95 // sprintf(fFileLoc,"%s/T0/Survey_%d_T0.txt",path,reportloc);
96 sprintf(fFileGlob,"%s/T0/Survey_%d_V0.txt",path,reportglob);
98 sprintf(fUser,gSystem->Getenv("alien_API_USER"));
100 //_________________________________________________________________________
101 AliT0Align::AliT0Align(const AliT0Align &align) :
117 // copy constructor - dummy
119 fDebug = align.fDebug;
121 //__________________________________________________________________________
122 AliT0Align & AliT0Align::operator =(const AliT0Align & align)
125 // assignment operator - dummy
131 //__________________________________________________________________________
132 AliT0Align::~AliT0Align()
137 if(fT0AAlignObj) delete fT0AAlignObj;
138 if(fT0CAlignObj) delete fT0CAlignObj;
139 if(fFileGlob) delete[] fT0CAlignObj;
140 if(fUser) delete[] fUser;
142 //__________________________________________________________________________
143 Bool_t AliT0Align::LoadSurveyData()
146 // Create a new survey object and fill it.
148 AliSurveyObj * s1 = new AliSurveyObj();
149 const int numberPoints = 2;
150 TString pointNames[numberPoints]={"FLANGE_CENTER","C67_6_Beamcircle"};
155 // Filling from DCDB (via GRID)
157 s1->SetGridUser(fUser);
160 s1->Fill("T0", fRepGlob, fUser);
164 s1->Fill("VZERO", fRepGlob, fUser);
168 cout<<"Enter the side properly: '0'- A side, '1'- C side'" <<endl;
174 // Filling from local file
177 s1->FillFromLocalFile(fFileGlob);
180 Float_t surveyedPoints [numberPoints][2];
181 AliSurveyPoint *currPoint;
184 for(Int_t i=0;i<numberPoints;i++)
187 currPoint = (AliSurveyPoint *) s1->GetData()->FindObject(pointNames[i]);
191 surveyedPoints[i][0]=currPoint->GetX();
192 surveyedPoints[i][1]=currPoint->GetY();
193 // surveyedPoints[i]=currPoint->GetZ();
195 Printf(Form("INFO: Point \"%s\" coordinates read.", pointNames[i].Data()));
201 Printf(Form("ERROR: Essential point missing: \"%s\"", pointNames[i].Data()));
208 fXPosA = surveyedPoints[0][0];
209 fYPosA = surveyedPoints[0][1];
213 fXPosC = surveyedPoints[1][0];
214 fYPosC = surveyedPoints[1][1];
221 //_________________________________________________________________
223 Double_t AliT0Align::ComputePosition()
225 // Float_t fZPos, shift;
226 // fZPos = surveyedPoints[3] - shift;
229 //_______________________________________________________________________
230 void AliT0Align::CreateAlignObj()
233 // TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
234 // TClonesArray &alobj = *array;
236 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
239 fT0AAlignObj = new AliAlignObjParams("ALIC_1/0STL_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
243 // dz=surveyedPoints[2];
245 fT0CAlignObj = new AliAlignObjParams("ALIC_1/0STR_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
249 //______________________________________________________________________
250 void AliT0Align::Run()
253 // runs the full chain
256 Bool_t flag = LoadSurveyData();
259 cout<<"Missing points"<<endl;
262 // ComputePosition();
266 //_________________________________________________________________________
268 void AliT0Align::StoreAlignObj()
271 // Storing T0 alignment objects
273 AliCDBManager* cdb = AliCDBManager::Instance();
274 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
276 TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
281 fT0AAlignObj->GetPars(shifts,rots);
282 new((*array)[0]) AliAlignObjParams(fT0AAlignObj->GetSymName(),0,shifts[0],
283 shifts[1],shifts[2],rots[0],rots[1],rots[2],kTRUE);
284 fT0CAlignObj->GetPars(shifts,rots);
285 new((*array)[1]) AliAlignObjParams(fT0CAlignObj->GetSymName(),0,shifts[0],
286 shifts[1],shifts[2],rots[0],rots[1],rots[2],kTRUE);
290 // storing either in the OCDB or local file
292 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
294 const char* filename = "T0SurveyMisalignment.root";
296 sprintf(fullname,"%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"),filename);
297 TFile *f = new TFile(fullname,"RECREATE");
299 AliError("cannot open file for output\n");
302 AliInfo(Form("Saving alignment objects to the file %s", filename));
304 f->WriteObject(array,"T0AlignObjs","kSingleKey");
307 // save in CDB storage
308 AliCDBStorage* storage;
310 TString Storage = gSystem->Getenv("STORAGE");
311 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
313 "STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()));
316 storage = cdb->GetStorage(Storage.Data());
318 AliError(Form("Unable to open storage %s\n",Storage.Data()));
322 AliCDBMetaData* md = new AliCDBMetaData();
323 md->SetResponsible("Tomasz Malkiewicz");
324 md->SetComment("Position of T0-A and T0-C from survey");
325 AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
326 storage->Put(array,id,md);