-void UpdateCDBIdealGeom(){
- // produce the ideal geometry with the current AliRoot and store it in the
- // CDB
+#include "ARVersion.h"
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBId.h"
+#include "AliCDBMetaData.h"
+#include "AliGeomManager.h"
+#include <TROOT.h>
+#include "AliRun.h"
+#include <TGeoManager.h>
+#include <TString.h>
+#endif
- AliCDBManager* man = AliCDBManager::Instance();
- man->SetDefaultStorage("local://$ALICE_ROOT");
- man->SetRun(0);
+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 version
+ // Get root and AliRoot versions
const char* rootv = gROOT->GetVersion();
+ TString av(ALIROOT_SVN_BRANCH);
+ Int_t revnum = ALIROOT_SVN_REVISION;
- // Get AliRoot version from file to set it in the metadata of the entry
- TFile *fv= TFile::Open("$ALICE_ROOT/CVS/Repository?filetype=raw","READ");
- Int_t size = fv->GetSize();
- char *buf = new Char_t[size];
- memset(buf, '\0', size);
- fv->Seek(0);
- char* alirootv;
- if ( fv->ReadBuffer(buf, size) ) {
- Printf("Error reading AliRoot version from file to buffer!");
- alirootv = "";
- }
- if(buf=="AliRoot"){
- alirootv="HEAD";
- }else{
- alirootv = buf;
- md->SetAliRootVersion(alirootv);
- md->SetComment(Form("Geometry produced with root version %s and AliRoot version %s",rootv,alirootv));
- }
+ 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();
+ gAlice->Init(cfgFile);
if(!gGeoManager){
Printf("Unable to produce a valid geometry to be put in the CDB!");
return;
}
+ 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,alirootv);
- man->Put(gGeoManager,id,md);
+ 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());
}
+
+