Macro that generates the Full MisAlignment in ACORDE Geometry
authormrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 May 2008 23:11:09 +0000 (23:11 +0000)
committermrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 May 2008 23:11:09 +0000 (23:11 +0000)
ACORDE/MakeACORDEFullMisAlignment.C [new file with mode: 0644]

diff --git a/ACORDE/MakeACORDEFullMisAlignment.C b/ACORDE/MakeACORDEFullMisAlignment.C
new file mode 100644 (file)
index 0000000..54d9fb5
--- /dev/null
@@ -0,0 +1,93 @@
+void MakeACORDEFullMisAlignment(){\r
+  // Create TClonesArray of full misalignment objects for ACORDE\r
+  //\r
+  const char* macroname = "MakeACORDEFullMisAlignment.C";\r
+  // Activate CDB storage and load geometry from CDB\r
+  AliCDBManager* cdb = AliCDBManager::Instance();\r
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");\r
+  cdb->SetRun(0);\r
+  \r
+  AliCDBStorage* storage;\r
+  \r
+  //load geom from local file till ACORDE is not switched on by default in standard config-files\r
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){\r
+    TString Storage = gSystem->Getenv("STORAGE");\r
+    if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {\r
+      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());\r
+      return;\r
+    }\r
+    storage = cdb->GetStorage(Storage.Data());\r
+    if(!storage){\r
+      Error(macroname,"Unable to open storage %s\n",Storage.Data());\r
+      return;\r
+    }\r
+    \r
+    AliCDBPath path("GRP","Geometry","Data");\r
+    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());\r
+    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");\r
+    entry->SetOwner(0);\r
+    TGeoManager* geom = (TGeoManager*) entry->GetObject();\r
+    AliGeomManager::SetGeometry(geom);\r
+  }else{\r
+    AliGeomManager::LoadGeometry(); //load geom from default CDB storage\r
+    \r
+  }\r
+  //  AliGeomManager::LoadGeometry("geometry.root");  \r
+\r
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",64);\r
+  TClonesArray &alobj = *array;\r
+  \r
+  TRandom *rnd = new TRandom(4321);\r
+  Int_t j = 0;\r
+  Double_t dx, dy, dz, dpsi, dtheta, dphi;\r
+\r
+  // RS = local\r
+  // sigma translation = 1 mm\r
+  // sigma rotation = 0.5 degrees\r
+  Double_t sigmatr = 2;\r
+  Double_t sigmarot = 1;\r
+  \r
+  TString symname;\r
+  TString basename = "ACORDE/Array";\r
+  Int_t iIndex=0;\r
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;\r
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);\r
+\r
+  for (Int_t imod=1; imod<61; imod++){\r
+    dx = rnd->Gaus(0.,sigmatr);\r
+    dy = rnd->Gaus(0.,sigmatr);\r
+    dz = rnd->Gaus(0.,sigmatr);\r
+    dpsi = rnd->Gaus(0.,sigmarot);\r
+    dtheta = rnd->Gaus(0.,sigmarot);\r
+    dphi = rnd->Gaus(0.,sigmarot);    \r
+    symname = basename;\r
+    symname += imod;    \r
+    new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);\r
+  }\r
+\r
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){\r
+    // save on file\r
+    const char* filename = "ACORDEfullMisalignment.root";\r
+    TFile f(filename,"RECREATE");\r
+    if(!f){\r
+      Error(macroname,"cannot open file for output\n");\r
+      return;\r
+    }\r
+    Info(macroname,"Saving alignment objects to the file %s", filename);\r
+    f.cd();\r
+    f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");\r
+    f.Close();\r
+  }else{\r
+    // save in CDB storage\r
+    AliCDBMetaData* md = new AliCDBMetaData();\r
+    md->SetResponsible("E. Cuautle & M. Rodriguez");\r
+    md->SetComment("Full misalignment for ACORDE");\r
+    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));\r
+    AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());\r
+    storage->Put(array,id,md);\r
+  }\r
+\r
+  array->Delete();\r
+\r
+}\r
+\r