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 **************************************************************************/
18 // Macro for generating the zero misalignment data.
20 // Author: I. Hrivnacova, IPN Orsay
22 #if !defined(__CINT__) || defined(__MAKECINT__)
24 #include "AliMUONGeometryTransformer.h"
26 #include "AliGeomManager.h"
27 #include "AliCDBManager.h"
28 #include "AliCDBStorage.h"
29 #include "AliCDBEntry.h"
34 #include <TClonesArray.h>
37 #include <Riostream.h>
41 void MakeMUONZeroMisAlignment()
43 const char* macroname = "MakeMUONZeroMisAlignment.C";
44 // Activate CDB storage and load geometry from CDB
45 AliCDBManager* cdb = AliCDBManager::Instance();
46 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
49 AliCDBStorage* storage = 0;
51 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
52 TString Storage = gSystem->Getenv("STORAGE");
53 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
54 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
57 storage = cdb->GetStorage(Storage.Data());
59 Error(macroname,"Unable to open storage %s\n",Storage.Data());
62 AliCDBPath path("GRP","Geometry","Data");
63 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
64 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
66 TGeoManager* geom = (TGeoManager*) entry->GetObject();
67 AliGeomManager::SetGeometry(geom);
69 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
72 AliMUONGeometryTransformer transformer;
73 transformer.LoadGeometryData();
74 TClonesArray* array = transformer.CreateZeroAlignmentData();;
76 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
77 // Create a file to store the alignment data
78 const char* filename = "MUONZeroMisalignment.root";
79 TFile f(filename,"RECREATE");
81 Error(macroname,"cannot open file for output\n");
84 Info(macroname,"Saving alignment objects to the file %s", filename);
86 f.WriteObject(array,"MUONAlignObjs","kSingleKey");
89 // save in CDB storage
90 AliCDBMetaData* cdbData = new AliCDBMetaData();
91 cdbData->SetResponsible("Dimuon Offline project");
92 cdbData->SetComment("MUON alignment objects with zero misalignment");
93 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
94 AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
95 storage->Put(array, id, cdbData);