]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MakeMUONResMisAlignment.C
Modifications to reflect latest changes in MUONTRGda
[u/mrichter/AliRoot.git] / MUON / MakeMUONResMisAlignment.C
CommitLineData
226783d4 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 **************************************************************************/
1895a097 15
226783d4 16// $Id$
1895a097 17
226783d4 18// Macro for generating the residual misalignment data.
19// The macro is triggered from AliRoot/macros/MakeAllDETsResMisAlignment.C
20//
21// Author: I. Hrivnacova, IPN Orsay
1895a097 22
0eae0737 23#if !defined(__CINT__) || defined(__MAKECINT__)
24
25#include "AliMUONGeometryTransformer.h"
26#include "AliMUONGeometryMisAligner.h"
27
ef4cb4f1 28#include "AliGeomManager.h"
0eae0737 29#include "AliCDBManager.h"
30#include "AliCDBStorage.h"
0dd10920 31#include "AliCDBEntry.h"
0eae0737 32#include "AliCDBId.h"
33
ef4cb4f1 34#include <TSystem.h>
0dd10920 35#include <TError.h>
0eae0737 36#include <TClonesArray.h>
37#include <TString.h>
38#include <TFile.h>
39#include <Riostream.h>
40
41#endif
42
226783d4 43void MakeMUONResMisAlignment()
44{
6fce62af 45 const char* macroname = "MakeMUONResMisAlignment.C";
46 // Activate CDB storage and load geometry from CDB
47 AliCDBManager* cdb = AliCDBManager::Instance();
48 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
49 cdb->SetRun(0);
50
0dd10920 51 AliCDBStorage* storage = 0;
6fce62af 52
a24be56b 53 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 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();
69 AliGeomManager::SetGeometry(geom);
70 }else{
71 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
72 }
ef4cb4f1 73
74 AliMUONGeometryTransformer transformer;
75 transformer.LoadGeometryData();
1895a097 76
77 AliMUONGeometryMisAligner misAligner(0.0, 0.004, 0.0, 0.003, 0.0, 0.0023);
78 AliMUONGeometryTransformer* newTransform
226783d4 79 = misAligner.MisAlign(&transformer, true);
0eae0737 80 const TClonesArray* array = newTransform->GetMisAlignmentData();
1895a097 81
0eae0737 82 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
6fce62af 83 // Save in file
dfe9c69d 84 const char* filename = "MUONresidualMisalignment.root";
85 TFile f(filename,"RECREATE");
0dd10920 86 if(!f.IsOpen()){
dfe9c69d 87 Error(macroname,"cannot open file for output\n");
88 return;
0eae0737 89 }
dfe9c69d 90 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 91 f.cd();
dfe9c69d 92 f.WriteObject(array,"MUONAlignObjs","kSingleKey");
1895a097 93 f.Close();
6fce62af 94 } else {
95 // Save in CDB storage
1895a097 96 AliCDBMetaData* cdbData = new AliCDBMetaData();
97 cdbData->SetResponsible("Dimuon Offline project");
98 cdbData->SetComment("MUON alignment objects with residual misalignment");
5bd470e1 99 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 100 AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
0eae0737 101 storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
1895a097 102 }
1895a097 103 delete newTransform;
0eae0737 104 }
1895a097 105