]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDAlignFaker.cxx
All FMD corrections are now divided into the analysis + adding new corrections
[u/mrichter/AliRoot.git] / FMD / AliFMDAlignFaker.cxx
index 7942d65e9708946c321b554a8d8ba84a39041852..d15cc8b8a241ae410011905fd4612bfeab93a549 100644 (file)
@@ -56,6 +56,7 @@
 #include <TGeoNode.h>
 // #include <TGeoVolume.h>
 #include <TROOT.h>
+#include <TClass.h>
 
 //====================================================================
 ClassImp(AliFMDAlignFaker)
@@ -77,7 +78,7 @@ AliFMDAlignFaker::AliFMDAlignFaker(Int_t mask, const char* geo,
     fHalfRotMin(0,0,0),
     fHalfRotMax(0,0,0),
     fRunMin(0),
-    fRunMax(9999999), 
+    fRunMax(AliCDBRunRange::Infinity()), 
     fArray(0),
     fComment("")
 {
@@ -141,6 +142,42 @@ AliFMDAlignFaker::SetHalfRotation(Double_t x1, Double_t y1, Double_t z1,
 #define IS_NODE_SENSOR(name) \
   (name[0] == 'F' && name[2] == 'S' && name[3] == 'E')
 
+//__________________________________________________________________
+Bool_t
+AliFMDAlignFaker::GetGeometry(Bool_t toCdb, const TString& storage)
+{
+  if (!toCdb) { 
+     //load geom from default CDB storage
+    AliGeomManager::LoadGeometry(); 
+    return kTRUE;
+  }
+  if(!storage.BeginsWith("local://") && 
+     !storage.BeginsWith("alien://")) {
+    AliErrorClass(Form("STORAGE=\"%s\" invalid. Exiting\n", storage.Data()));
+    return kFALSE;
+  }
+
+  AliCDBManager* cdb   = AliCDBManager::Instance();
+  AliCDBStorage* store = cdb->GetStorage(storage.Data());
+  if(!store){
+    AliErrorClass(Form("Unable to open storage %s\n", storage.Data()));
+    return kFALSE;
+  }
+
+  AliCDBPath   path("GRP","Geometry","Data");
+  AliCDBEntry* entry = store->Get(path.GetPath(),cdb->GetRun());
+  if(!entry) {
+    AliErrorClass("Could not get the specified CDB entry!");
+    return kFALSE;
+  }
+  
+
+  entry->SetOwner(0);
+  TGeoManager* geom = static_cast<TGeoManager*>(entry->GetObject());
+  AliGeomManager::SetGeometry(geom);
+  return kTRUE;
+}
+  
 //__________________________________________________________________
 void
 AliFMDAlignFaker::Exec(Option_t*)
@@ -187,9 +224,11 @@ AliFMDAlignFaker::Exec(Option_t*)
       alignName     = Form("FMD/FMD%c_%c", currentDet, currentHalf);
     }
     if (IS_NODE_SENSOR(name)) {
-      Char_t ring  = name[1];
-      Int_t  copy  = node->GetNumber();
-      alignName    = Form("FMD/FMD%c_%c/FMD%c_%02d", 
+      Char_t ring      = name[1];
+      Int_t  lvl       = next.GetLevel();
+      TGeoNode* parent = next.GetNode(lvl-1);
+      Int_t     copy   = parent->GetNumber();
+      alignName        = Form("FMD/FMD%c_%c/FMD%c_%02d", 
                          currentDet, currentHalf, ring, copy);
     }
     if (alignName.IsNull()) continue;
@@ -327,7 +366,7 @@ AliFMDAlignFaker::WriteToFile()
     return;
   }
   file->cd();
-  fArray->Write("FMDAlignment");
+  fArray->Write("FMDAlignment",TObject::kSingleKey);
   file->Write();
   file->Close();
 }