]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEER/AliSurveyToAlignObjs.cxx
Putting some order in the list and number of detectors
[u/mrichter/AliRoot.git] / STEER / STEER / AliSurveyToAlignObjs.cxx
CommitLineData
00627e37 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#include "Riostream.h"
17#include "TFile.h"
18#include "TSystem.h"
19#include "TClonesArray.h"
20
21#include "AliSurveyToAlignObjs.h"
22#include "AliSurveyPoint.h"
23#include "AliAlignObjParams.h"
24
25#include "AliLog.h"
26
27#include "AliCDBManager.h"
28#include "AliCDBEntry.h"
29#include "AliCDBStorage.h"
30#include "AliCDBMetaData.h"
31
32ClassImp(AliSurveyToAlignObjs)
33
34//________________________________________________________________________
35AliSurveyToAlignObjs::AliSurveyToAlignObjs() :
36 TObject(),
9f242ac7 37 fSurveyObj(new AliSurveyObj()),
00627e37 38 fSurveyPoints(NULL),
9f242ac7 39 fAlignObjArray(new TClonesArray("AliAlignObjParams",10)),
40 fAlignObj(0)
41{
00627e37 42 //
43 // default constructor
9f242ac7 44 //
00627e37 45}
46
47//_________________________________________________________________________
48AliSurveyToAlignObjs::AliSurveyToAlignObjs(const AliSurveyToAlignObjs &s2aObj) :
49 TObject(s2aObj),
251a7a21 50 fSurveyObj(s2aObj.fSurveyObj),
d65e8f5c 51 fSurveyPoints(NULL),
52 fAlignObjArray(NULL),
251a7a21 53 fAlignObj(s2aObj.fAlignObj)
00627e37 54{
55 // copy constructor
d65e8f5c 56 fSurveyPoints = (TObjArray*)(s2aObj.fSurveyObj->Clone());
57 fAlignObjArray = (TClonesArray*) (s2aObj.fAlignObjArray->Clone());
00627e37 58}
59
60//__________________________________________________________________________
61AliSurveyToAlignObjs & AliSurveyToAlignObjs::operator= (const AliSurveyToAlignObjs &s2aObj) {
62 //
63 // assignment operator
9f242ac7 64 //
d65e8f5c 65 if(this != &s2aObj) {
66 //if(s2aObj.fSurveyObj){
67 //delete fSurveyObj;
68 this->fSurveyObj = s2aObj.fSurveyObj;
69 //}
70 //if(s2aObj.fSurveyPoints){
71 //fSurveyPoints->Delete();
72 //delete fSurveyPoints;
73 fSurveyPoints = (TObjArray*)(s2aObj.fSurveyObj->Clone());
74 //}
75 //if(s2aObj.fAlignObjArray){
76 //fAlignObjArray->Delete();
77 //delete fAlignObjArray;
78 fAlignObjArray = (TClonesArray*) (s2aObj.fAlignObjArray->Clone());
79 //}
80 //if(s2aObj.fAlignObj){
81 //delete fAlignObj;
82 this->fAlignObj = s2aObj.fAlignObj;
83 //}
84 }
85 return *this;
00627e37 86}
87
88//__________________________________________________________________________
9f242ac7 89AliSurveyToAlignObjs::~AliSurveyToAlignObjs()
90{
00627e37 91 //
92 // destructor
93 //
9f242ac7 94 delete fSurveyObj;
95 delete fSurveyPoints;
96 delete fAlignObjArray;
97 delete fAlignObj;
00627e37 98}
99
100//__________________________________________________________________________
101Bool_t AliSurveyToAlignObjs::LoadSurveyFromLocalFile(const char* filename) {
102 // Load survey data from a formatted text file
103 // residing locally
104 //
105
106 //Load survey data from the local file
107 if(fSurveyObj->FillFromLocalFile(filename))
108 fSurveyPoints = fSurveyObj->GetData();
109 else
110 return kFALSE;
111
112 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
113
114 return kTRUE;
115}
116
117//__________________________________________________________________________
118Bool_t AliSurveyToAlignObjs::LoadSurveyFromAlienFile(const char* det, Int_t repNum, Int_t repVersion) {
119 // Load survey data from the formatted text file
120 // residing in the default location in alien
121 //
122
123 const char* alienUser=gSystem->Getenv("alien_API_USER");
124 if(fSurveyObj->Fill(det, repNum, repVersion, alienUser))
125 {
126 fSurveyPoints = fSurveyObj->GetData();
127 }else{
128 AliError("Error reading survey file from alien!");
129 return kFALSE;
130 }
131
132 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
133
134 return kTRUE;
135}
136
137//_________________________________________________________________________
e2909f78 138Bool_t AliSurveyToAlignObjs::StoreAlignObjToFile(const char* filename, const char* det){
00627e37 139 // Stores the TClonesArray of alignment objects into the
140 // file specified as argument
141 //
142 TFile *f = TFile::Open(filename,"RECREATE");
143 if(!f){
144 AliError(Form("cannot open file %s\n",filename));
e2909f78 145 return kFALSE;
00627e37 146 }
147 AliInfo(Form("Saving alignment objects into the file %s",filename));
148 TString arrayname(det);
149 arrayname+="AlignObjs";
150
151 f->cd();
152 f->WriteObject(fAlignObjArray,arrayname,"kSingleKey");
153 f->Close();
e2909f78 154
155 return kTRUE;
00627e37 156}
157
158//_________________________________________________________________________
e2909f78 159Bool_t AliSurveyToAlignObjs::StoreAlignObjToCDB(const char* cdbFolder, const char* det){
00627e37 160 // Stores the TClonesArray of alignment objects into a
161 // CDB entry in the CDB folder specified by the argument
162 //
163
164 AliCDBManager* cdb = AliCDBManager::Instance();
165 cdb->SetDefaultStorage(cdbFolder);
166 cdb->SetRun(0);
167
168 AliCDBMetaData* md = new AliCDBMetaData();
65b25288 169 md->SetComment(Form("Misalignment for subdetector %s from survey",det));
00627e37 170 TString path(det);
171 path+="/Align/Data";
172 AliCDBId id(path.Data(),0,AliCDBRunRange::Infinity());
173 cdb->Put(fAlignObjArray,id,md);
174
e2909f78 175 return kTRUE;
00627e37 176}
177
178