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