]>
Commit | Line | Data |
---|---|---|
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 zero misalignment data. | |
19 | // | |
20 | // Author: I. Hrivnacova, IPN Orsay | |
21 | ||
22 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
23 | ||
24 | #include "AliMUONGeometryTransformer.h" | |
25 | ||
26 | #include "AliGeomManager.h" | |
27 | #include "AliCDBManager.h" | |
28 | #include "AliCDBStorage.h" | |
29 | #include "AliCDBId.h" | |
30 | ||
31 | #include <TSystem.h> | |
32 | #include <TClonesArray.h> | |
33 | #include <TString.h> | |
34 | #include <TFile.h> | |
35 | #include <Riostream.h> | |
36 | ||
37 | #endif | |
38 | ||
39 | void MakeMUONZeroMisAlignment() | |
40 | { | |
41 | const char* macroname = "MakeMUONZeroMisAlignment.C"; | |
42 | // Activate CDB storage and load geometry from CDB | |
43 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
44 | if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT"); | |
45 | cdb->SetRun(0); | |
46 | ||
47 | AliCDBStorage* storage; | |
48 | ||
49 | if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ | |
50 | TString Storage = gSystem->Getenv("STORAGE"); | |
51 | if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { | |
52 | Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); | |
53 | return; | |
54 | } | |
55 | storage = cdb->GetStorage(Storage.Data()); | |
56 | if(!storage){ | |
57 | Error(macroname,"Unable to open storage %s\n",Storage.Data()); | |
58 | return; | |
59 | } | |
60 | AliCDBPath path("GRP","Geometry","Data"); | |
61 | AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); | |
62 | if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); | |
63 | entry->SetOwner(0); | |
64 | TGeoManager* geom = (TGeoManager*) entry->GetObject(); | |
65 | AliGeomManager::SetGeometry(geom); | |
66 | }else{ | |
67 | AliGeomManager::LoadGeometry(); //load geom from default CDB storage | |
68 | } | |
69 | ||
70 | AliMUONGeometryTransformer transformer; | |
71 | transformer.LoadGeometryData(); | |
72 | TClonesArray* array = transformer.CreateZeroAlignmentData();; | |
73 | ||
74 | if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) { | |
75 | // Create a file to store the alignment data | |
76 | const char* filename = "MUONZeroMisalignment.root"; | |
77 | TFile f(filename,"RECREATE"); | |
78 | if(!f){ | |
79 | Error(macroname,"cannot open file for output\n"); | |
80 | return; | |
81 | } | |
82 | Info(macroname,"Saving alignment objects to the file %s", filename); | |
83 | f.cd(); | |
84 | f.WriteObject(array,"MUONAlignObjs","kSingleKey"); | |
85 | f.Close(); | |
86 | } else { | |
87 | // save in CDB storage | |
88 | AliCDBMetaData* cdbData = new AliCDBMetaData(); | |
89 | cdbData->SetResponsible("Dimuon Offline project"); | |
90 | cdbData->SetComment("MUON alignment objects with zero misalignment"); | |
91 | cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION")); | |
92 | AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity()); | |
93 | storage->Put(array, id, cdbData); | |
94 | } | |
95 | } | |
96 |