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