// $Id$
-// Macro for generating the zero misalignment data.
-//
-// Author: I. Hrivnacova, IPN Orsay
+/// \ingroup macros
+/// \file MakeMUONZeroMisAlignment.C
+/// \brief Macro for generating the zero misalignment data.
+///
+/// \author: I. Hrivnacova, IPN Orsay
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "AliMUONGeometryTransformer.h"
+
+#include "AliGeomManager.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+#include "AliCDBId.h"
+
+#include <TSystem.h>
+#include <TError.h>
+#include <TClonesArray.h>
+#include <TString.h>
+#include <TFile.h>
+#include <Riostream.h>
+
+#endif
void MakeMUONZeroMisAlignment()
{
- // Check first if geometry is loaded,
- // if not loaded try to load it from galice.root file
- if ( ! gGeoManager && ! TGeoManager::Import("geometry.root") ) {
- cerr << "Loading geometry failed." << endl;
- return;
- }
-
- AliMUONGeometryTransformer transformer(true);
- transformer.ReadGeometryData("volpath.dat", gGeoManager);
- TClonesArray* array = transformer.CreateZeroAlignmentData();;
+ const char* macroname = "MakeMUONZeroMisAlignment.C";
+ // Activate CDB storage and load geometry from CDB
+ AliCDBManager* cdb = AliCDBManager::Instance();
+ if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+ cdb->SetRun(0);
+
+ AliCDBStorage* storage = 0;
+
+ if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+ TString Storage = gSystem->Getenv("STORAGE");
+ if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
+ Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
+ return;
+ }
+ storage = cdb->GetStorage(Storage.Data());
+ if(!storage){
+ Error(macroname,"Unable to open storage %s\n",Storage.Data());
+ return;
+ }
+ AliCDBPath path("GRP","Geometry","Data");
+ AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+ if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+ entry->SetOwner(0);
+ TGeoManager* geom = (TGeoManager*) entry->GetObject();
+ AliGeomManager::SetGeometry(geom);
+ }else{
+ AliGeomManager::LoadGeometry(); //load geom from default CDB storage
+ }
- if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
- // save in file
- cout << "Generating zero misalignment data in a file ..." << endl;
+ AliMUONGeometryTransformer transformer;
+ transformer.LoadGeometryData();
+ TClonesArray* array = transformer.CreateZeroAlignmentData();;
+ if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
// Create a file to store the alignment data
- TFile f("MUONzeroMisalignment.root", "RECREATE");
- if(!f) {
- cerr<<"cannot open file for output\n";
+ const char* filename = "MUONZeroMisalignment.root";
+ TFile f(filename,"RECREATE");
+ if(!f.IsOpen()){
+ Error(macroname,"cannot open file for output\n");
+ return;
}
+ Info(macroname,"Saving alignment objects to the file %s", filename);
f.cd();
- f.WriteObject(array,"MUONAlignObjs ","kSingleKey");
+ f.WriteObject(array,"MUONAlignObjs","kSingleKey");
f.Close();
- }
- else {
- cout << "Generating zero misalignment data in CDB ..." << endl;
-
+ } else {
// save in CDB storage
- const char* Storage = gSystem->Getenv("STORAGE");
- AliCDBManager* cdbManager = AliCDBManager::Instance();
- AliCDBStorage* storage = cdbManager->GetStorage(Storage);
AliCDBMetaData* cdbData = new AliCDBMetaData();
cdbData->SetResponsible("Dimuon Offline project");
cdbData->SetComment("MUON alignment objects with zero misalignment");
cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
- AliCDBId id("MUON/Align/Data", 0, 9999999);
+ AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
storage->Put(array, id, cdbData);
}
}