]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MakeMUONFullMisAlignment.C
- Adding a new group for macros
[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 "AliGeomManager.h"
29 #include "AliCDBManager.h"
30 #include "AliCDBStorage.h"
31 #include "AliCDBEntry.h"
32 #include "AliCDBId.h"
33
34 #include <TSystem.h>
35 #include <TError.h>
36 #include <TClonesArray.h>
37 #include <TString.h>
38 #include <TFile.h>
39 #include <Riostream.h>
40
41 #endif
42
43
44 void MakeMUONFullMisAlignment()
45 {
46   const char* macroname = "MakeMUONFullMisAlignment.C";
47   // Activate CDB storage and load geometry from CDB
48   AliCDBManager* cdb = AliCDBManager::Instance();
49   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
50   cdb->SetRun(0);
51   
52   AliCDBStorage* storage = 0;
53   
54   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
55     TString Storage = gSystem->Getenv("STORAGE");
56     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
57       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
58       return;
59     }
60     storage = cdb->GetStorage(Storage.Data());
61     if(!storage){
62       Error(macroname,"Unable to open storage %s\n",Storage.Data());
63       return;
64     }
65     AliCDBPath path("GRP","Geometry","Data");
66     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
67     if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
68     entry->SetOwner(0);
69     TGeoManager* geom = (TGeoManager*) entry->GetObject();
70     AliGeomManager::SetGeometry(geom);
71   }else{
72     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
73   }    
74
75   AliMUONGeometryTransformer transformer;
76   transformer.LoadGeometryData();
77   
78   AliMUONGeometryMisAligner misAligner(0.0, 0.03, 0.0, 0.03, 0.0, 0.03);
79   AliMUONGeometryTransformer* newTransform 
80     = misAligner.MisAlign(&transformer, true);
81   const TClonesArray* array = newTransform->GetMisAlignmentData();
82   
83   if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
84     // Save in file
85     const char* filename = "MUONfullMisalignment.root";
86     TFile f(filename,"RECREATE");
87     if (!f.IsOpen()) {
88       Error(macroname,"cannot open file for output\n");
89       return;
90     }
91     Info(macroname,"Saving alignment objects to the file %s", filename);
92     f.cd();
93     f.WriteObject(array,"MUONAlignObjs","kSingleKey");
94     f.Close();
95   }
96   else {
97     // Save in CDB storage
98     AliCDBMetaData* cdbData = new AliCDBMetaData();
99     cdbData->SetResponsible("Dimuon Offline project");
100     cdbData->SetComment("MUON alignment objects with full misalignment");
101     cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
102     AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity()); 
103     storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
104   }   
105   delete newTransform;
106 }