]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliSurveyToAlignObjs.cxx
including AliSurveyToAlignObjs class in .pkg and LinkDef files
[u/mrichter/AliRoot.git] / 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(),
251a7a21 37 fSurveyObj(NULL),
00627e37 38 fSurveyPoints(NULL),
39 fAlignObjArray(NULL),
40 fAlignObj(0){
41 //
42 // default constructor
251a7a21 43 fSurveyObj = new AliSurveyObj();
00627e37 44}
45
46//_________________________________________________________________________
47AliSurveyToAlignObjs::AliSurveyToAlignObjs(const AliSurveyToAlignObjs &s2aObj) :
48 TObject(s2aObj),
251a7a21 49 fSurveyObj(s2aObj.fSurveyObj),
50 fSurveyPoints(s2aObj.fSurveyPoints),
51 fAlignObjArray(s2aObj.fAlignObjArray),
52 fAlignObj(s2aObj.fAlignObj)
00627e37 53{
54 // copy constructor
55}
56
57//__________________________________________________________________________
58AliSurveyToAlignObjs & AliSurveyToAlignObjs::operator= (const AliSurveyToAlignObjs &s2aObj) {
59 //
60 // assignment operator
251a7a21 61 fSurveyObj = s2aObj.fSurveyObj;
62 fSurveyPoints = s2aObj.fSurveyPoints;
63 fAlignObjArray = s2aObj.fAlignObjArray;
64 fAlignObj = s2aObj.fAlignObj;
00627e37 65 return (*this);
66}
67
68//__________________________________________________________________________
69AliSurveyToAlignObjs::~AliSurveyToAlignObjs() {
70 //
71 // destructor
72 //
73 if(fSurveyObj) delete fSurveyObj;
74 if(fSurveyPoints) delete fSurveyPoints;
75 if(fAlignObjArray) delete fAlignObjArray;
76 if(fAlignObj) delete fAlignObj;
77}
78
79//__________________________________________________________________________
80Bool_t AliSurveyToAlignObjs::LoadSurveyFromLocalFile(const char* filename) {
81 // Load survey data from a formatted text file
82 // residing locally
83 //
84
85 //Load survey data from the local file
86 if(fSurveyObj->FillFromLocalFile(filename))
87 fSurveyPoints = fSurveyObj->GetData();
88 else
89 return kFALSE;
90
91 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
92
93 return kTRUE;
94}
95
96//__________________________________________________________________________
97Bool_t AliSurveyToAlignObjs::LoadSurveyFromAlienFile(const char* det, Int_t repNum, Int_t repVersion) {
98 // Load survey data from the formatted text file
99 // residing in the default location in alien
100 //
101
102 const char* alienUser=gSystem->Getenv("alien_API_USER");
103 if(fSurveyObj->Fill(det, repNum, repVersion, alienUser))
104 {
105 fSurveyPoints = fSurveyObj->GetData();
106 }else{
107 AliError("Error reading survey file from alien!");
108 return kFALSE;
109 }
110
111 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
112
113 return kTRUE;
114}
115
116//_________________________________________________________________________
117void AliSurveyToAlignObjs::StoreAlignObjToFile(const char* filename, const char* det){
118 // Stores the TClonesArray of alignment objects into the
119 // file specified as argument
120 //
121 TFile *f = TFile::Open(filename,"RECREATE");
122 if(!f){
123 AliError(Form("cannot open file %s\n",filename));
124 return;
125 }
126 AliInfo(Form("Saving alignment objects into the file %s",filename));
127 TString arrayname(det);
128 arrayname+="AlignObjs";
129
130 f->cd();
131 f->WriteObject(fAlignObjArray,arrayname,"kSingleKey");
132 f->Close();
133}
134
135//_________________________________________________________________________
136void AliSurveyToAlignObjs::StoreAlignObjToCDB(const char* cdbFolder, const char* det){
137 // Stores the TClonesArray of alignment objects into a
138 // CDB entry in the CDB folder specified by the argument
139 //
140
141 AliCDBManager* cdb = AliCDBManager::Instance();
142 cdb->SetDefaultStorage(cdbFolder);
143 cdb->SetRun(0);
144
145 AliCDBMetaData* md = new AliCDBMetaData();
146 md->SetComment(Form("Misalignment for subdetector %d from survey",det));
147 TString path(det);
148 path+="/Align/Data";
149 AliCDBId id(path.Data(),0,AliCDBRunRange::Infinity());
150 cdb->Put(fAlignObjArray,id,md);
151
152}
153
154