]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDAlignFaker.cxx
Allow to pass trigger mask value as parameter to AddTaskQAsym
[u/mrichter/AliRoot.git] / FMD / AliFMDAlignFaker.cxx
index 3f63b9b7036d97cc9994a5d5e9255abb4765246d..fa4f98cc4ab2b5f0c6a048c73096f2961fea4ad3 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 /* $Id$ */
-/** @file    AliFMDAlignFaker.cxx
-    @author  Christian Holm Christensen <cholm@nbi.dk>
-    @date    Sun Mar 26 17:57:55 2006
-    @brief   Implementation of AliFMDAlignFaker 
-*/
+/** 
+ * @file    AliFMDAlignFaker.cxx
+ * @author  Christian Holm Christensen <cholm@nbi.dk>
+ * @date    Sun Mar 26 17:57:55 2006
+ * @brief   Implementation of AliFMDAlignFaker 
+ */
 //____________________________________________________________________
 //
 //  Class 
 // storage `local://cdb' which is a directory in the current
 // directory. 
 //                                                       
-#include "AliLog.h"               // ALILOG_H
+#include "AliFMDDebug.h"               // ALIFMDDEBUG_H ALILOG_H
 #include "AliFMDAlignFaker.h"      // ALIFMDALIGNFAKER_H
 #include <AliCDBManager.h>         // ALICDBMANAGER_H
 #include <AliCDBStorage.h>         // ALICDBSTORAGE_H
 #include <AliCDBEntry.h>           // ALICDBMANAGER_H
 // #include <AliAlignObj.h>
-#include <AliAlignObjAngles.h>
+#include <AliAlignObjParams.h>
 // #include <Riostream.h>
-// #include <TSystem.h>
+#include <TSystem.h>
 // #include <TMath.h>
 #include <TRandom.h>
 #include <TClonesArray.h>
@@ -55,7 +56,8 @@
 #include <TGeoManager.h>
 #include <TGeoNode.h>
 // #include <TGeoVolume.h>
-// #include <TROOT.h>
+#include <TROOT.h>
+#include <TClass.h>
 
 //====================================================================
 ClassImp(AliFMDAlignFaker)
@@ -77,7 +79,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 +143,52 @@ 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)
+{
+  // 
+  // Get the geometry
+  // 
+  // Parameters:
+  //    toCdb   Whether to store in CDB
+  //    storage Storage element to use 
+  // 
+  // Return:
+  //    true on success 
+  //
+  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*)
@@ -161,7 +209,7 @@ AliFMDAlignFaker::Exec(Option_t*)
     return;
   }
   // Make container of transforms 
-  if (!fArray) fArray = new TClonesArray("AliAlignObjAngles");
+  if (!fArray) fArray = new TClonesArray("AliAlignObjParams");
   fArray->Clear();
   
   // Make an iterator
@@ -187,9 +235,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;
@@ -198,7 +248,7 @@ AliFMDAlignFaker::Exec(Option_t*)
                      alignName.Data(), path.Data()));
       alignName = path;
     }
-    AliDebug(1, Form("Making alignment for %s -> %s (%d)", 
+    AliFMDDebug(1, ("Making alignment for %s -> %s (%d)", 
                     alignName.Data(), path.Data(), id));
     if (IS_NODE_HALF(name))   MakeAlignHalf(alignName, id);
     if (IS_NODE_SENSOR(name)) MakeAlignSensor(alignName, id);
@@ -249,12 +299,12 @@ AliFMDAlignFaker::MakeAlign(const TString& path, Int_t id,
   //   rotX      Rotation about X-axis 
   //   rotY      Rotation about Y-axis
   //   rotZ      Rotation about Z-axis 
-  AliDebug(3, Form("Make alignment for %s (volume %d): (%f,%f,%f) (%f,%f,%f)", 
+  AliFMDDebug(3, ("Make alignment for %s (volume %d): (%f,%f,%f) (%f,%f,%f)", 
                   path.Data(), id, transX, transY, transZ, rotX, rotY, rotZ));
   Int_t nAlign = fArray->GetEntries();
   id = 0;
-  AliAlignObjAngles* obj = 
-    new ((*fArray)[nAlign]) AliAlignObjAngles(path.Data(),
+  AliAlignObjParams* obj = 
+    new ((*fArray)[nAlign]) AliAlignObjParams(path.Data(),
                                              id,0,0,0,0,0,0,kTRUE);
   if (!obj) {
     AliError(Form("Failed to create alignment object for %s", path.Data()));
@@ -272,7 +322,7 @@ Bool_t
 AliFMDAlignFaker::MakeAlignHalf(const TString& path, Int_t id)
 {
   // Make alignment of a half ring/cone 
-  AliDebug(15, Form("Make alignment for half-ring/cone %s", path.Data()));
+  AliFMDDebug(15, ("Make alignment for half-ring/cone %s", path.Data()));
   Double_t transX = gRandom->Uniform(fHalfTransMin.X(), fHalfTransMax.X());
   Double_t transY = gRandom->Uniform(fHalfTransMin.Y(), fHalfTransMax.Y());
   Double_t transZ = gRandom->Uniform(fHalfTransMin.Z(), fHalfTransMax.Z());
@@ -288,7 +338,7 @@ Bool_t
 AliFMDAlignFaker::MakeAlignSensor(const TString& path, Int_t id)
 {
   // Make alignment of a sensor 
-  AliDebug(15, Form("Make alignment for sensor %s", path.Data()));
+  AliFMDDebug(15, ("Make alignment for sensor %s", path.Data()));
   Double_t transX = gRandom->Uniform(fSensorTransMin.X(), fSensorTransMax.X());
   Double_t transY = gRandom->Uniform(fSensorTransMin.Y(), fSensorTransMax.Y());
   Double_t transZ = gRandom->Uniform(fSensorTransMin.Z(), fSensorTransMax.Z());
@@ -327,7 +377,7 @@ AliFMDAlignFaker::WriteToFile()
     return;
   }
   file->cd();
-  fArray->Write("FMDAlignment");
+  fArray->Write("FMDAlignment",TObject::kSingleKey);
   file->Write();
   file->Close();
 }