1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #include "Riostream.h"
19 #include "TClonesArray.h"
21 #include "AliSurveyToAlignObjs.h"
22 #include "AliSurveyPoint.h"
23 #include "AliAlignObjParams.h"
27 #include "AliCDBManager.h"
28 #include "AliCDBEntry.h"
29 #include "AliCDBStorage.h"
30 #include "AliCDBMetaData.h"
32 ClassImp(AliSurveyToAlignObjs)
34 //________________________________________________________________________
35 AliSurveyToAlignObjs::AliSurveyToAlignObjs() :
37 fSurveyObj(new AliSurveyObj()),
39 fAlignObjArray(new TClonesArray("AliAlignObjParams",10)),
43 // default constructor
47 //_________________________________________________________________________
48 AliSurveyToAlignObjs::AliSurveyToAlignObjs(const AliSurveyToAlignObjs &s2aObj) :
50 fSurveyObj(s2aObj.fSurveyObj),
53 fAlignObj(s2aObj.fAlignObj)
56 fSurveyPoints = (TObjArray*)(s2aObj.fSurveyObj->Clone());
57 fAlignObjArray = (TClonesArray*) (s2aObj.fAlignObjArray->Clone());
60 //__________________________________________________________________________
61 AliSurveyToAlignObjs & AliSurveyToAlignObjs::operator= (const AliSurveyToAlignObjs &s2aObj) {
63 // assignment operator
66 //if(s2aObj.fSurveyObj){
68 this->fSurveyObj = s2aObj.fSurveyObj;
70 //if(s2aObj.fSurveyPoints){
71 //fSurveyPoints->Delete();
72 //delete fSurveyPoints;
73 fSurveyPoints = (TObjArray*)(s2aObj.fSurveyObj->Clone());
75 //if(s2aObj.fAlignObjArray){
76 //fAlignObjArray->Delete();
77 //delete fAlignObjArray;
78 fAlignObjArray = (TClonesArray*) (s2aObj.fAlignObjArray->Clone());
80 //if(s2aObj.fAlignObj){
82 this->fAlignObj = s2aObj.fAlignObj;
88 //__________________________________________________________________________
89 AliSurveyToAlignObjs::~AliSurveyToAlignObjs()
96 delete fAlignObjArray;
100 //__________________________________________________________________________
101 Bool_t AliSurveyToAlignObjs::LoadSurveyFromLocalFile(const char* filename) {
102 // Load survey data from a formatted text file
106 //Load survey data from the local file
107 if(fSurveyObj->FillFromLocalFile(filename))
108 fSurveyPoints = fSurveyObj->GetData();
112 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
117 //__________________________________________________________________________
118 Bool_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
123 const char* alienUser=gSystem->Getenv("alien_API_USER");
124 if(fSurveyObj->Fill(det, repNum, repVersion, alienUser))
126 fSurveyPoints = fSurveyObj->GetData();
128 AliError("Error reading survey file from alien!");
132 AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
137 //_________________________________________________________________________
138 Bool_t AliSurveyToAlignObjs::StoreAlignObjToFile(const char* filename, const char* det){
139 // Stores the TClonesArray of alignment objects into the
140 // file specified as argument
142 TFile *f = TFile::Open(filename,"RECREATE");
144 AliError(Form("cannot open file %s\n",filename));
147 AliInfo(Form("Saving alignment objects into the file %s",filename));
148 TString arrayname(det);
149 arrayname+="AlignObjs";
152 f->WriteObject(fAlignObjArray,arrayname,"kSingleKey");
158 //_________________________________________________________________________
159 Bool_t AliSurveyToAlignObjs::StoreAlignObjToCDB(const char* cdbFolder, const char* det){
160 // Stores the TClonesArray of alignment objects into a
161 // CDB entry in the CDB folder specified by the argument
164 AliCDBManager* cdb = AliCDBManager::Instance();
165 cdb->SetDefaultStorage(cdbFolder);
168 AliCDBMetaData* md = new AliCDBMetaData();
169 md->SetComment(Form("Misalignment for subdetector %s from survey",det));
172 AliCDBId id(path.Data(),0,AliCDBRunRange::Infinity());
173 cdb->Put(fAlignObjArray,id,md);