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