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