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