]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MakeMUONFullMisAlignment.C
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / MakeMUONFullMisAlignment.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 full misalignment data.
19 // The macro is trigger from AliRoot/macros/MakeAllDETsFullMisAlignment.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 "AliCDBManager.h"
29 #include "AliCDBStorage.h"
30 #include "AliCDBId.h"
31
32 #include <TGeoManager.h>
33 #include <TClonesArray.h>
34 #include <TString.h>
35 #include <TFile.h>
36 #include <Riostream.h>
37
38 #endif
39
40
41 void MakeMUONFullMisAlignment()
42 {
43   // Check first if geometry is loaded,
44   // if not loaded try to load it from galice.root file
45   if ( ! gGeoManager && ! TGeoManager::Import("geometry.root") )  {
46     cerr << "Loading geometry failed." << endl;
47     return;
48   }  
49
50   AliMUONGeometryTransformer transformer(true);
51   transformer.ReadGeometryData("volpath.dat", gGeoManager);
52   
53   AliMUONGeometryMisAligner misAligner(0.0, 0.03, 0.0, 0.03, 0.0, 0.03);
54   AliMUONGeometryTransformer* newTransform 
55     = misAligner.MisAlign(&transformer, true);
56   const TClonesArray* array = newTransform->GetMisAlignmentData();
57   
58   if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
59     cout << "Generating full misalignment data in a file" << endl;
60
61     // Create a File to store the alignment data
62     TFile f("MUONfullMisalignment.root","RECREATE");
63     if ( !f.IsOpen() ) {
64       cerr << "cannot open file for output" << endl;
65     }
66     
67     f.cd();
68     f.WriteObject(array,"MUONAlignObjs ","kSingleKey");
69     f.Close();
70   }
71   else {
72     cout << "Generating full misalignment data in CDB" << endl;
73
74     // save in CDB storage
75     const char* Storage = gSystem->Getenv("STORAGE");
76     
77     AliCDBManager* cdbManager = AliCDBManager::Instance();
78     AliCDBStorage* storage = cdbManager->GetStorage(Storage);
79     AliCDBMetaData* cdbData = new AliCDBMetaData();
80     cdbData->SetResponsible("Dimuon Offline project");
81     cdbData->SetComment("MUON alignment objects with full misalignment");
82     cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
83     AliCDBId id("MUON/Align/Data", 0, 9999999); 
84     storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
85   }   
86   delete newTransform;
87 }