X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=GRP%2FUpdateCDBIdealGeom.C;h=2a22b2d6ae7f48f57f2d89898cb37a86a51a56d2;hp=f58c659540ee7c146e7d2a01cfcaa240ca32530a;hb=0492edf588f5310c2e439befe66b1e7423b594a0;hpb=860aa38291eaa17019bf49e60c26444290ef5c11;ds=sidebyside diff --git a/GRP/UpdateCDBIdealGeom.C b/GRP/UpdateCDBIdealGeom.C index f58c659540e..2a22b2d6ae7 100644 --- a/GRP/UpdateCDBIdealGeom.C +++ b/GRP/UpdateCDBIdealGeom.C @@ -5,56 +5,85 @@ #include "AliCDBId.h" #include "AliCDBMetaData.h" #include "AliGeomManager.h" +#include "AliMC.h" #include #include "AliRun.h" #include #include +#include #endif void UpdateCDBIdealGeom(const char* cdbUri, const char* cfgFile){ - // Produce the ideal geometry and store it in the specified CDB - // The second argument allows to specify the config file to be used - // in particular for giving the choice to generate either a full or - // a partial geometry. - // - - AliCDBManager* cdb = AliCDBManager::Instance(); - // we set the default storage to the repository because some dets require - // already at the time of geometry creation to find calibration objects in the cdb - AliCDBStorage* storage = 0; - if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT"); - storage = cdb->GetStorage(cdbUri); - if(!storage) - { - Printf("unable to create valid storage from: %s", cdbUri); - return; - } - cdb->SetRun(0); - AliCDBId id("GRP/Geometry/Data",0,AliCDBRunRange::Infinity()); - AliCDBMetaData *md= new AliCDBMetaData(); - - // Get root and AliRoot versions - const char* rootv = gROOT->GetVersion(); - TString av(ALIROOT_SVN_BRANCH); - Int_t revnum = ALIROOT_SVN_REVISION; - - Printf("root version: %s. AliRoot %s, revision number %d",rootv,av.Data(),revnum); - - md->SetAliRootVersion(av.Data()); - md->SetComment(Form("Geometry produced with root version %s and AliRoot %s, revision number %d",rootv,av.Data(),revnum)); - - gAlice->Init(cfgFile); - - if(!gGeoManager){ - Printf("Unable to produce a valid geometry to be put in the CDB!"); - return; - } - - Printf("Storing in CDB geometry produced with root version %s and AliRoot version %s",rootv,av.Data()); - storage->Put(gGeoManager,id,md); - // This is to allow macros lauched after this one in the same session to find the - // newly produced geometry. - storage->QueryCDB(cdb->GetRun()); + // Produce the ideal geometry and store it in the specified CDB + // The second argument allows to specify the config file to be used + // in particular for giving the choice to generate either a full or + // a partial geometry. + // + + AliCDBManager* cdb = AliCDBManager::Instance(); + // we set the default storage to the repository because some dets require + // already at the time of geometry creation to find calibration objects in the cdb + AliCDBStorage* storage = 0; + if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + storage = cdb->GetStorage(cdbUri); + if(!storage) + { + Printf("unable to create valid storage from: %s", cdbUri); + return; + } + cdb->SetRun(0); + AliCDBId id("GRP/Geometry/Data",0,AliCDBRunRange::Infinity()); + AliCDBMetaData *md= new AliCDBMetaData(); + + // Get root and AliRoot versions + const char* rootv = gROOT->GetVersion(); + TString av(ALIROOT_BRANCH); + TString revnum(ALIROOT_REVISION); + + Printf("root version: %s. AliRoot %s, revision number %s",rootv,av.Data(),revnum); + + md->SetAliRootVersion(av.Data()); + md->SetComment(Form("Geometry produced with root version %s and AliRoot %s, revision number %s",rootv,av.Data(),revnum)); + md->AddDateToComment(); + + //gSystem->Exec("if [ -e geometry.root ]; then \necho deleting existing geometry.root \nrm -rf geometry.root \nfi"); + if(!gSystem->AccessPathName("geometry.root")){ + Printf("Deleting existing \"geometry.root\""); + gSystem->Exec("rm -rf geometry.root"); + } + + gROOT->LoadMacro(cfgFile); + gInterpreter->ProcessLine(gAlice->GetConfigFunction()); + + gAlice->GetMCApp()->Init(); + + if(!gGeoManager){ + Printf("Unable to produce a valid geometry to be put in the CDB!"); + return; + } + + /* + if (gSystem->Exec("if [ ! -e geometry.root ]; then \n return 1 \nfi")) { + Printf("Did not find freshly written geometry.root file"); + return; + } */ + if(gSystem->AccessPathName("geometry.root")){ + Printf("Did not find freshly written \"geometry.root\" file. Exiting ..."); + return; + } + + Printf("Reloading freshly written geometry.root file"); + if (TGeoManager::IsLocked()) TGeoManager::UnlockGeometry(); + AliGeomManager::LoadGeometry("geometry.root"); + + gGeoManager->DefaultColors(); // assign default colors according to Z of material + // (many colors turned into dark gray nuances some time ago, when the root palette was changed) + + Printf("Storing in CDB geometry produced with root version %s and AliRoot version %s",rootv,av.Data()); + storage->Put(gGeoManager,id,md); + // This is to allow macros lauched after this one in the same session to find the + // newly produced geometry. + storage->QueryCDB(cdb->GetRun()); }