]> git.uio.no Git - u/mrichter/AliRoot.git/blob - GRP/UpdateCDBIdealGeom.C
add libPWGmuon.so
[u/mrichter/AliRoot.git] / GRP / UpdateCDBIdealGeom.C
1 #include "ARVersion.h"
2 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include "AliCDBManager.h"
4 #include "AliCDBStorage.h"
5 #include "AliCDBId.h"
6 #include "AliCDBMetaData.h"
7 #include "AliGeomManager.h"
8 #include "AliMC.h"
9 #include <TROOT.h>
10 #include "AliRun.h"
11 #include <TGeoManager.h>
12 #include <TString.h>
13 #include <TInterpreter.h>
14 #endif
15
16 void UpdateCDBIdealGeom(const char* cdbUri, const char* cfgFile){
17         // Produce the ideal geometry and store it in the specified CDB
18         // The second argument allows to specify the config file to be used
19         // in particular for giving the choice to generate either a full or
20         // a partial geometry.
21         //
22
23         AliCDBManager* cdb = AliCDBManager::Instance();
24         // we set the default storage to the repository because some dets require
25         // already at the time of geometry creation to find calibration objects in the cdb
26         AliCDBStorage* storage = 0;
27         if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
28         storage = cdb->GetStorage(cdbUri);
29         if(!storage) 
30         {
31                 Printf("unable to create valid storage from: %s", cdbUri);
32                 return;
33         }
34         cdb->SetRun(0);
35         AliCDBId id("GRP/Geometry/Data",0,AliCDBRunRange::Infinity());
36         AliCDBMetaData *md= new AliCDBMetaData();
37
38         // Get root and AliRoot versions
39         const char* rootv = gROOT->GetVersion();
40         TString av(ALIROOT_SVN_BRANCH);
41         Int_t revnum = ALIROOT_SVN_REVISION;
42
43         Printf("root version: %s.  AliRoot %s, revision number %d",rootv,av.Data(),revnum);
44
45         md->SetAliRootVersion(av.Data());
46         md->SetComment(Form("Geometry produced with root version %s and AliRoot %s, revision number %d",rootv,av.Data(),revnum));
47         md->AddDateToComment();
48
49         //gSystem->Exec("if [ -e geometry.root ]; then \necho deleting existing geometry.root \nrm -rf geometry.root \nfi");
50         if(!gSystem->AccessPathName("geometry.root")){
51                 Printf("Deleting existing \"geometry.root\"");
52                 gSystem->Exec("rm -rf geometry.root");
53         }
54
55         gROOT->LoadMacro(cfgFile);
56         gInterpreter->ProcessLine(gAlice->GetConfigFunction());
57
58         gAlice->GetMCApp()->Init();
59
60         if(!gGeoManager){
61                 Printf("Unable to produce a valid geometry to be put in the CDB!");
62                 return;
63         }
64
65         /*
66         if (gSystem->Exec("if [ ! -e geometry.root ]; then \n return 1  \nfi")) {
67                 Printf("Did not find freshly written geometry.root file");
68                 return;
69         } */
70         if(gSystem->AccessPathName("geometry.root")){
71                 Printf("Did not find freshly written \"geometry.root\" file. Exiting ...");
72                 return;
73         }
74
75         Printf("Reloading freshly written geometry.root file");
76         if (TGeoManager::IsLocked()) TGeoManager::UnlockGeometry();
77         AliGeomManager::LoadGeometry("geometry.root");
78
79         gGeoManager->DefaultColors(); // assign default colors according to Z of material
80         // (many colors turned into dark gray nuances some time ago, when the root palette was changed)
81
82         Printf("Storing in CDB geometry produced with root version %s and AliRoot version %s",rootv,av.Data());
83         storage->Put(gGeoManager,id,md);
84         // This is to allow macros lauched after this one in the same session to find the
85         // newly produced geometry.
86         storage->QueryCDB(cdb->GetRun());
87
88 }
89
90