--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+#include "Riostream.h"
+#include "TFile.h"
+#include "TSystem.h"
+#include "TClonesArray.h"
+
+#include "AliSurveyToAlignObjs.h"
+#include "AliSurveyPoint.h"
+#include "AliAlignObjParams.h"
+
+#include "AliLog.h"
+
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliCDBStorage.h"
+#include "AliCDBMetaData.h"
+
+ClassImp(AliSurveyToAlignObjs)
+
+//________________________________________________________________________
+AliSurveyToAlignObjs::AliSurveyToAlignObjs() :
+ TObject(),
+ fSurveyObj(0),
+ fSurveyPoints(NULL),
+ fAlignObjArray(NULL),
+ fAlignObj(0){
+ //
+ // default constructor
+ //
+}
+
+//_________________________________________________________________________
+AliSurveyToAlignObjs::AliSurveyToAlignObjs(const AliSurveyToAlignObjs &s2aObj) :
+ TObject(s2aObj),
+ fSurveyObj(0),
+ fSurveyPoints(NULL),
+ fAlignObjArray(NULL),
+ fAlignObj(0)
+{
+ // copy constructor
+}
+
+//__________________________________________________________________________
+AliSurveyToAlignObjs & AliSurveyToAlignObjs::operator= (const AliSurveyToAlignObjs &s2aObj) {
+ //
+ // assignment operator
+ return (*this);
+}
+
+//__________________________________________________________________________
+AliSurveyToAlignObjs::~AliSurveyToAlignObjs() {
+ //
+ // destructor
+ //
+ if(fSurveyObj) delete fSurveyObj;
+ if(fSurveyPoints) delete fSurveyPoints;
+ if(fAlignObjArray) delete fAlignObjArray;
+ if(fAlignObj) delete fAlignObj;
+}
+
+//__________________________________________________________________________
+Bool_t AliSurveyToAlignObjs::LoadSurveyFromLocalFile(const char* filename) {
+ // Load survey data from a formatted text file
+ // residing locally
+ //
+
+ //Load survey data from the local file
+ if(fSurveyObj->FillFromLocalFile(filename))
+ fSurveyPoints = fSurveyObj->GetData();
+ else
+ return kFALSE;
+
+ AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
+
+ return kTRUE;
+}
+
+//__________________________________________________________________________
+Bool_t AliSurveyToAlignObjs::LoadSurveyFromAlienFile(const char* det, Int_t repNum, Int_t repVersion) {
+ // Load survey data from the formatted text file
+ // residing in the default location in alien
+ //
+
+ const char* alienUser=gSystem->Getenv("alien_API_USER");
+ if(fSurveyObj->Fill(det, repNum, repVersion, alienUser))
+ {
+ fSurveyPoints = fSurveyObj->GetData();
+ }else{
+ AliError("Error reading survey file from alien!");
+ return kFALSE;
+ }
+
+ AliInfo(Form("%d survey points read",fSurveyPoints->GetEntries()));
+
+ return kTRUE;
+}
+
+//_________________________________________________________________________
+void AliSurveyToAlignObjs::StoreAlignObjToFile(const char* filename, const char* det){
+ // Stores the TClonesArray of alignment objects into the
+ // file specified as argument
+ //
+ TFile *f = TFile::Open(filename,"RECREATE");
+ if(!f){
+ AliError(Form("cannot open file %s\n",filename));
+ return;
+ }
+ AliInfo(Form("Saving alignment objects into the file %s",filename));
+ TString arrayname(det);
+ arrayname+="AlignObjs";
+
+ f->cd();
+ f->WriteObject(fAlignObjArray,arrayname,"kSingleKey");
+ f->Close();
+}
+
+//_________________________________________________________________________
+void AliSurveyToAlignObjs::StoreAlignObjToCDB(const char* cdbFolder, const char* det){
+ // Stores the TClonesArray of alignment objects into a
+ // CDB entry in the CDB folder specified by the argument
+ //
+
+ AliCDBManager* cdb = AliCDBManager::Instance();
+ cdb->SetDefaultStorage(cdbFolder);
+ cdb->SetRun(0);
+
+ AliCDBMetaData* md = new AliCDBMetaData();
+ md->SetComment(Form("Misalignment for subdetector %d from survey",det));
+ TString path(det);
+ path+="/Align/Data";
+ AliCDBId id(path.Data(),0,AliCDBRunRange::Infinity());
+ cdb->Put(fAlignObjArray,id,md);
+
+}
+
+
--- /dev/null
+#ifndef ALISURVEYTOALIGNOBJS_H
+#define ALISURVEYTOALIGNOBJS_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/////////////////////////////////////////////////////////////////////////
+// Base class for creating the alignment objects from survey //
+// for a given subdetector //
+// //
+/////////////////////////////////////////////////////////////////////////
+#include <TSystem.h>
+#include <TObjArray.h>
+#include <TClonesArray.h>
+
+#include "AliAlignObjParams.h"
+#include "AliSurveyObj.h"
+
+
+class AliSurveyToAlignObjs : public TObject {
+
+ public:
+ AliSurveyToAlignObjs();
+ AliSurveyToAlignObjs(const char* det, Int_t repNum, Int_t repVer);
+ AliSurveyToAlignObjs(const AliSurveyToAlignObjs &align); // copy constructor
+ AliSurveyToAlignObjs &operator = (const AliSurveyToAlignObjs &align); //assignment operator
+
+ Bool_t LoadSurveyFromLocalFile(const char* filename);
+ Bool_t LoadSurveyFromAlienFile(const char* det, Int_t repNum, Int_t repVersion);
+
+ virtual void CreateAlignObjs() = 0;
+ virtual void Run() = 0;
+ void StoreAlignObjToFile(const char* filename, const char* det);
+ void StoreAlignObjToCDB(const char* cdbFolder, const char* det);
+ virtual ~AliSurveyToAlignObjs();
+ //
+ protected:
+ AliSurveyObj *fSurveyObj; // survey object
+ TObjArray *fSurveyPoints; // array of survey points
+ TClonesArray *fAlignObjArray; // TClonesArray of alignment objects
+ AliAlignObjParams *fAlignObj; // alignment object
+
+ ClassDef(AliSurveyToAlignObjs,0);
+};
+#endif