- New and more flexible code for processing of Survey+Photogrammetry data of the
[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
e54bf126 18/// \ingroup macros
19/// \file MakeMUONFullMisAlignment.C
20/// \brief Macro for generating the full misalignment data.
21///
22/// The macro is triggered from AliRoot/macros/MakeAllDETsFullMisAlignment.C
23///
24/// \author: I. Hrivnacova, IPN Orsay
1895a097 25
0eae0737 26#if !defined(__CINT__) || defined(__MAKECINT__)
27
28#include "AliMUONGeometryTransformer.h"
29#include "AliMUONGeometryMisAligner.h"
30
ef4cb4f1 31#include "AliGeomManager.h"
0eae0737 32#include "AliCDBManager.h"
33#include "AliCDBStorage.h"
0dd10920 34#include "AliCDBEntry.h"
0eae0737 35#include "AliCDBId.h"
36
ef4cb4f1 37#include <TSystem.h>
0dd10920 38#include <TError.h>
0eae0737 39#include <TClonesArray.h>
40#include <TString.h>
41#include <TFile.h>
42#include <Riostream.h>
43
44#endif
45
46
226783d4 47void MakeMUONFullMisAlignment()
48{
6fce62af 49 const char* macroname = "MakeMUONFullMisAlignment.C";
50 // Activate CDB storage and load geometry from CDB
51 AliCDBManager* cdb = AliCDBManager::Instance();
52 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
53 cdb->SetRun(0);
54
0dd10920 55 AliCDBStorage* storage = 0;
6fce62af 56
a24be56b 57 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
6fce62af 58 TString Storage = gSystem->Getenv("STORAGE");
59 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
60 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
61 return;
62 }
63 storage = cdb->GetStorage(Storage.Data());
64 if(!storage){
65 Error(macroname,"Unable to open storage %s\n",Storage.Data());
66 return;
67 }
68 AliCDBPath path("GRP","Geometry","Data");
69 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
70 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
71 entry->SetOwner(0);
72 TGeoManager* geom = (TGeoManager*) entry->GetObject();
73 AliGeomManager::SetGeometry(geom);
74 }else{
75 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
76 }
ef4cb4f1 77
78 AliMUONGeometryTransformer transformer;
79 transformer.LoadGeometryData();
1895a097 80
81 AliMUONGeometryMisAligner misAligner(0.0, 0.03, 0.0, 0.03, 0.0, 0.03);
82 AliMUONGeometryTransformer* newTransform
226783d4 83 = misAligner.MisAlign(&transformer, true);
0eae0737 84 const TClonesArray* array = newTransform->GetMisAlignmentData();
1895a097 85
0eae0737 86 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
6fce62af 87 // Save in file
dfe9c69d 88 const char* filename = "MUONfullMisalignment.root";
89 TFile f(filename,"RECREATE");
0dd10920 90 if (!f.IsOpen()) {
dfe9c69d 91 Error(macroname,"cannot open file for output\n");
92 return;
0eae0737 93 }
dfe9c69d 94 Info(macroname,"Saving alignment objects to the file %s", filename);
1895a097 95 f.cd();
dfe9c69d 96 f.WriteObject(array,"MUONAlignObjs","kSingleKey");
1895a097 97 f.Close();
226783d4 98 }
99 else {
6fce62af 100 // Save in CDB storage
1895a097 101 AliCDBMetaData* cdbData = new AliCDBMetaData();
102 cdbData->SetResponsible("Dimuon Offline project");
103 cdbData->SetComment("MUON alignment objects with full misalignment");
5bd470e1 104 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 105 AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
0eae0737 106 storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
1895a097 107 }
0eae0737 108 delete newTransform;
1895a097 109}