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 **************************************************************************/
18 Revision 1.1 2007/10/01 14:12:45 pchrist
19 Class creating the aligmnent object fro the surveyor measurements.
24 // Creates the SSD align object
27 #include "Riostream.h"
30 #include "TClonesArray.h"
31 #include "TGeoManager.h"
32 #include "TGeoMatrix.h"
33 #include "TGeoPhysicalNode.h"
35 #include "AliITSSurveyToAlignSSD.h"
36 #include "AliSurveyObj.h"
37 #include "AliSurveyPoint.h"
38 #include "AliAlignObjParams.h"
42 #include "AliCDBManager.h"
43 #include "AliCDBEntry.h"
44 #include "AliCDBStorage.h"
46 ClassImp(AliITSSurveyToAlignSSD)
48 //________________________________________________________________________
49 AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD() :
55 fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)),
59 // default constructor
63 //________________________________________________________________________
64 AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD(Int_t run, Int_t reportloc, Int_t reportglob) :
70 fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)),
74 // constructor - defines data files
76 fFileLoc = new Char_t[80];
77 fFileGlob = new Char_t[80];
79 sprintf(path,gSystem->Getenv("ALICE_ROOT"));
81 sprintf(fFileLoc,"%s/ITS/Survey_SSD_%d.txt",path,reportloc);
82 sprintf(fFileGlob,"%s/ITS/Survey_SSD_%d.txt",path,reportglob);
86 //_________________________________________________________________________
87 AliITSSurveyToAlignSSD::AliITSSurveyToAlignSSD(const AliITSSurveyToAlignSSD &align) :
92 fSSDAlignObj(new TClonesArray("AliAlignObjParams",100)),
96 // copy constructor - dummy
98 fDebug = align.fDebug;
101 //__________________________________________________________________________
102 AliITSSurveyToAlignSSD & AliITSSurveyToAlignSSD::operator =(const AliITSSurveyToAlignSSD & align) {
104 // assignment operator - dummy
106 fDebug = align.fDebug;
110 //__________________________________________________________________________
111 AliITSSurveyToAlignSSD::~AliITSSurveyToAlignSSD() {
115 if(fSurveyPoints) delete fSurveyPoints;
116 if(fSSDAlignObj) delete fSSDAlignObj;
117 if(fSSDAlignObjParam) delete fSSDAlignObjParam;
120 //______________________________________________________________________
121 void AliITSSurveyToAlignSSD::Run() {
123 // runs the full chain
126 Bool_t flag = LoadSurveyData();
128 cout<<"Missing points"<<endl;
136 //__________________________________________________________________________
137 Bool_t AliITSSurveyToAlignSSD::LoadSurveyData() {
139 // for a time being it loads from the local file the surveyed point
140 // and has the ideal points hardwired. I am waiting until Ricardo
144 //Load survey data from the local file
145 AliSurveyObj * s1 = new AliSurveyObj();
146 if(s1->FillFromLocalFile(fFileGlob))
147 fSurveyPoints = s1->GetData();
151 cout<<"Number of SSD survey points: "<<fSurveyPoints->GetEntries()<<endl;
156 //_______________________________________________________________________
157 void AliITSSurveyToAlignSSD::CreateAlignObj(){
159 // This method creates AliAlignObj and fills it with Euler angles
160 // and shifts. The units are degrees and cm.
162 TClonesArray &alobj = *fSSDAlignObj;
164 //load ideal geometry from the OCDB
165 AliCDBManager *cdb = AliCDBManager::Instance();
166 cdb->SetDefaultStorage("local://$ALICE_ROOT");
168 AliCDBEntry* entry = cdb->Get("GRP/Geometry/Data");
169 AliGeomManager::SetGeometry(gGeoManager);
171 AliSurveyPoint* pt = 0;
173 TGeoPNEntry* pne = 0;
178 Int_t ilayer, imodule;
180 for(Int_t imod = 0; imod < fSurveyPoints->GetEntries(); imod++) {
181 pt = (AliSurveyPoint*) fSurveyPoints->At(imod);
183 sx = pt->GetX()*100.;
184 sy = pt->GetY()*100.;
185 sz = pt->GetZ()*100.;
187 ilayer = (imod < 748) ? AliGeomManager::kSSD1 : AliGeomManager::kSSD2;
188 imodule = (imod < 748) ? imod : imod - 748;
190 uid = AliGeomManager::LayerToVolUID(ilayer,imodule);
191 symname = AliGeomManager::SymName(uid);
192 pne = gGeoManager->GetAlignableEntryByUID(uid);
193 hm = pne->GetGlobalOrig();
194 tr = hm->GetTranslation();
196 //Printf("symname %s", symname);
197 //Printf("x,y,z from survey: %f %f %f", sx, sy, sz);
198 //Printf("x,y,z from ideal : %f %f %f", tr[0], tr[1], tr[2]);
200 new(alobj[imod]) AliAlignObjParams(symname, uid, sx-tr[0], sy-tr[1], sz-tr[2], 0., 0., 0., kTRUE);
206 //_________________________________________________________________________
207 void AliITSSurveyToAlignSSD::StoreAlignObj(){
208 // Stores the TClonesArray of AliAlignObj in
209 // $ALICE_ROOT/ITS/Align/Data/SSDfromSurvey.root
210 // In a later version these objects will be merged
211 // with the SDD ones and will be put in the OCDB
212 const char* filename = "$ALICE_ROOT/ITS/Align/Data/SSDfromSurvey.root";
213 TFile *f = TFile::Open(filename,"RECREATE");
215 Error(filename,"cannot open file for output\n");
218 cout<<"Saving alignment objects to the file "<<filename<<endl;
220 f->WriteObject(fSSDAlignObj,"SSDAlignObjs","kSingleKey");