AliRoot Core  edcc906 (edcc906)
MakeMUONZeroMisAlignment.C
Go to the documentation of this file.
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 // $Id$
17 
23 
24 #if !defined(__CINT__) || defined(__MAKECINT__)
25 
27 
28 #include "AliGeomManager.h"
29 #include "AliCDBManager.h"
30 #include "AliCDBStorage.h"
31 #include "AliCDBEntry.h"
32 #include "AliCDBId.h"
33 
34 #include <TSystem.h>
35 #include <TError.h>
36 #include <TClonesArray.h>
37 #include <TString.h>
38 #include <TFile.h>
39 #include <Riostream.h>
40 
41 #endif
42 
44 {
45  const char* macroname = "MakeMUONZeroMisAlignment.C";
46  // Activate CDB storage and load geometry from CDB
48  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
49  cdb->SetRun(0);
50 
51  AliCDBStorage* storage = 0;
52 
53  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
54  TString Storage = gSystem->Getenv("STORAGE");
55  if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
56  Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
57  return;
58  }
59  storage = cdb->GetStorage(Storage.Data());
60  if(!storage){
61  Error(macroname,"Unable to open storage %s\n",Storage.Data());
62  return;
63  }
64  AliCDBPath path("GRP","Geometry","Data");
65  AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
66  if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
67  entry->SetOwner(0);
68  TGeoManager* geom = (TGeoManager*) entry->GetObject();
70  }else{
71  AliGeomManager::LoadGeometry(); //load geom from default CDB storage
72  }
73 
74  AliMUONGeometryTransformer transformer;
75  transformer.LoadGeometryData();
76  TClonesArray* array = transformer.CreateZeroAlignmentData();;
77 
78  if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
79  // Create a file to store the alignment data
80  const char* filename = "MUONZeroMisalignment.root";
81  TFile f(filename,"RECREATE");
82  if(!f.IsOpen()){
83  Error(macroname,"cannot open file for output\n");
84  return;
85  }
86  Info(macroname,"Saving alignment objects to the file %s", filename);
87  f.cd();
88  f.WriteObject(array,"MUONAlignObjs","kSingleKey");
89  f.Close();
90  } else {
91  // save in CDB storage
92  AliCDBMetaData* cdbData = new AliCDBMetaData();
93  cdbData->SetResponsible("Dimuon Offline project");
94  cdbData->SetComment("MUON alignment objects with zero misalignment");
95  cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
96  AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
97  storage->Put(array, id, cdbData);
98  }
99 }
100 
AliCDBEntry * Get(const AliCDBId &query)
const TString & GetPath() const
Definition: AliCDBPath.h:38
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
Int_t GetRun() const
Bool_t LoadGeometryData(const TString &fileName)
Top container class for geometry transformations.
const char * path
void SetComment(const char *comment)
void SetResponsible(const char *yourName)
void MakeMUONZeroMisAlignment()
TObjArray * array
Definition: AnalyzeLaser.C:12
TObject * GetObject()
Definition: AliCDBEntry.h:56
AliCDBStorage * GetStorage(const char *dbString)
void SetAliRootVersion(const char *version)
static void SetGeometry(TGeoManager *const geom)
TClonesArray * CreateZeroAlignmentData() const
void SetRun(Int_t run)
Definition: AliCDBEntry.h:18
TF1 * f
Definition: interpolTest.C:21
void SetDefaultStorage(const char *dbString)
void SetOwner(Bool_t owner)
Definition: AliCDBEntry.h:64
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
TEveGeoShape * geom
Definition: tpc_tracks.C:10
Bool_t IsDefaultStorageSet() const
Definition: AliCDBManager.h:60
static void LoadGeometry(const char *geomFileName=NULL)
static Int_t Infinity()