]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - macros/MakeAllDETsZeroMisAlignment.C
New TPC monitoring package from Stefan Kniege. The monitoring package can be started...
[u/mrichter/AliRoot.git] / macros / MakeAllDETsZeroMisAlignment.C
index 8d426053dd6d0fa4c2f112ecce9c6786ddbf5be9..37daf1dd174b138129c4d64813ad99a35ed48326 100644 (file)
@@ -1,28 +1,53 @@
-void MakeAllDETsZeroMisAlignment(Char_t* CDBstorage = "local://$HOME/Zero"){
+const char* GetARversion();
+
+void MakeAllDETsZeroMisAlignment(Char_t* CDBstorage = "local://$ALICE_ROOT"){
   // Make zero misalignment objects for all detectors
   // Pass different "CDBstorage" argument if needed (e.g. to fill
   // conditions' data base on alien) or set it to null string to have
   // the objects saved locally on file 
   //
+  const char* macroname="MakeAllDETsZeroMisAlignment.C";
+
   TString strStorage(CDBstorage);
   if(strStorage.IsNull()){
     gSystem->Setenv("TOCDB","kFALSE");
   }else{  
     gSystem->Setenv("TOCDB","kTRUE");
     gSystem->Setenv("STORAGE",strStorage.Data());
-    gSystem->Setenv("ARVERSION","v4-05-08");
+    gSystem->Setenv("ARVERSION",GetARversion());
   }
 
-  if(!AliGeomManager::GetGeometry()){
-    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-      AliCDBManager::Instance()->SetRun(0);
-    AliGeomManager::LoadGeometry();
+  // Load geometry from CDB updating it if we are producing the
+  // alignment objects for the CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+  cdb->SetRun(0);
+  
+  if(strStorage.IsNull()){ //if we produce the objects into a file
+    AliGeomManager::LoadGeometry(); //load geom from default CDB storage
+  }else{ // if we produce the objects in a CDB storage
+    // update geometry in it
+    Info(macroname,"Updating geometry in CDB storage %s",strStorage.Data());
+    gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C");
+    UpdateCDBIdealGeom(strStorage.Data(),"$ALICE_ROOT/macros/Config.C");    
+    // load the same geometry from given CDB storage
+    AliCDBPath path("GRP","Geometry","Data");
+    AliCDBStorage* storage = cdb->GetStorage(strStorage.Data());
+    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+    if(!entry) Fatal(macroname,"Couldn't load geometry data from CDB!");
+    entry->SetOwner(0);
+    TGeoManager* geom = (TGeoManager*) entry->GetObject();
+    if (!geom) Fatal(macroname,"Couldn't find TGeoManager in the specified CDB entry!");
+    AliGeomManager::SetGeometry(geom);
   }
+  
+  // run macro for non-sensitive modules
+  // (presently generates only FRAME alignment objects)
+  gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTZeroMisAlignment.C");
 
-
-  TString dets="EMCAL,FMD,HMPID,ITS,MUON,PMD,PHOS,T0,TRD,TPC,TOF,VZERO,ZDC";
-  TObjArray *detArray = dets.Tokenize(',');
+  // run macros for sensitive modules
+  TString sModules="EMCAL,FMD,HMPID,ITS,MUON,PMD,PHOS,T0,TRD,TPC,TOF,VZERO,ZDC";
+  TObjArray *detArray = sModules.Tokenize(',');
   TIter iter(detArray);
   TObjString *ostr;
   TString exec_det_macro;
@@ -40,3 +65,24 @@ void MakeAllDETsZeroMisAlignment(Char_t* CDBstorage = "local://$HOME/Zero"){
 
   return;
 }
+
+const char* GetARversion(){
+  // Get AliRoot version from $ALICE_ROOT/CVS/Repository file
+  // It's the best we can do without a GetVersion() method
+  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);
+  const 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;
+  }
+  return alirootv;
+}