AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / MUON / MakeMUONFullMisAlignment.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 full misalignment data.
19// The macro is trigger from AliRoot/macros/MakeAllDETsFullMisAlignment.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"
31#include "AliCDBId.h"
32
ef4cb4f1 33#include <TSystem.h>
0eae0737 34#include <TClonesArray.h>
35#include <TString.h>
36#include <TFile.h>
37#include <Riostream.h>
38
39#endif
40
41
226783d4 42void MakeMUONFullMisAlignment()
43{
ef4cb4f1 44 // Load geometry, if not yet loaded,
dfe9c69d 45 if(!AliGeomManager::GetGeometry()){
46 if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
47 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
48 AliCDBManager::Instance()->SetRun(0);
49 AliGeomManager::LoadGeometry();
50 }
ef4cb4f1 51
52 AliMUONGeometryTransformer transformer;
53 transformer.LoadGeometryData();
1895a097 54
55 AliMUONGeometryMisAligner misAligner(0.0, 0.03, 0.0, 0.03, 0.0, 0.03);
56 AliMUONGeometryTransformer* newTransform
226783d4 57 = misAligner.MisAlign(&transformer, true);
0eae0737 58 const TClonesArray* array = newTransform->GetMisAlignmentData();
1895a097 59
dfe9c69d 60 const char* macroname = "MakeMUONFullMisAlignment.C";
0eae0737 61 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
dfe9c69d 62 const char* filename = "MUONfullMisalignment.root";
63 TFile f(filename,"RECREATE");
64 if(!f){
65 Error(macroname,"cannot open file for output\n");
66 return;
0eae0737 67 }
dfe9c69d 68 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 69 f.cd();
dfe9c69d 70 f.WriteObject(array,"MUONAlignObjs","kSingleKey");
1895a097 71 f.Close();
226783d4 72 }
73 else {
dfe9c69d 74 TString Storage = gSystem->Getenv("STORAGE");
75 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
76 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
77 return;
78 }
79 Info(macroname,"Saving alignment objects in CDB storage %s",
80 Storage.Data());
81 AliCDBManager* cdb = AliCDBManager::Instance();
82 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
83 if(!storage){
84 Error(macroname,"Unable to open storage %s\n",Storage.Data());
85 return;
86 }
1895a097 87 AliCDBMetaData* cdbData = new AliCDBMetaData();
88 cdbData->SetResponsible("Dimuon Offline project");
89 cdbData->SetComment("MUON alignment objects with full misalignment");
5bd470e1 90 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 91 AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
0eae0737 92 storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
1895a097 93 }
0eae0737 94 delete newTransform;
1895a097 95}