]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/MakeACORDEResMisAlignment.C
Removing the lib files
[u/mrichter/AliRoot.git] / ACORDE / MakeACORDEResMisAlignment.C
1 void MakeACORDEResMisAlignment(){
2   // Create TClonesArray of Residual misalignment objects for ACORDE
3   //
4   const char* macroname = "MakeACORDEResMisAlignment.C";
5   // Activate CDB storage and load geometry from CDB
6   AliCDBManager* cdb = AliCDBManager::Instance();
7   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
8   cdb->SetRun(0);
9   
10   AliCDBStorage* storage;
11   
12   //load geom from local file till ACORDE is not switched on by default in standard config-files
13   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
14     TString Storage = gSystem->Getenv("STORAGE");
15     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
16       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
17       return;
18     }
19     storage = cdb->GetStorage(Storage.Data());
20     if(!storage){
21       Error(macroname,"Unable to open storage %s\n",Storage.Data());
22       return;
23     }
24     
25     AliCDBPath path("GRP","Geometry","Data");
26     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
27     if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
28     entry->SetOwner(0);
29     TGeoManager* geom = (TGeoManager*) entry->GetObject();
30     AliGeomManager::SetGeometry(geom);
31   }else{
32     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
33     
34
35   }
36   //  AliGeomManager::LoadGeometry("geometry.root");  
37
38   TClonesArray *array = new TClonesArray("AliAlignObjParams",64);
39   TClonesArray &alobj = *array;
40   
41   TRandom *rnd = new TRandom(4321);
42   Int_t j = 0;
43   Double_t dx, dy, dz, dpsi, dtheta, dphi;
44
45   // RS = local
46   // sigma translation
47   // sigma rotation 
48   Double_t sigmatr = 2;  // max shift in cm
49   Double_t sigmarot = 1;  // max rot in degrees
50   
51   TString symname;
52   TString basename = "ACORDE/Array";
53   Int_t iIndex=0;
54   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
55   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
56
57   for (Int_t imod=0; imod<60; imod++){
58     dx = rnd->Gaus(0.,sigmatr);
59     dy = rnd->Gaus(0.,sigmatr);
60     dz = rnd->Gaus(0.,sigmatr);
61     dpsi = rnd->Gaus(0.,sigmarot);
62     dtheta = rnd->Gaus(0.,sigmarot);
63     dphi = rnd->Gaus(0.,sigmarot);    
64     symname = basename;
65     symname += imod;    
66     new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);
67   }
68
69   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
70     // save on file
71     const char* filename = "ACORDEResMisalignment.root";
72     TFile f(filename,"RECREATE");
73     if(!f){
74       Error(macroname,"cannot open file for output\n");
75       return;
76     }
77     Info(macroname,"Saving residual misalignment objects to the file %s", filename);
78     f.cd();
79     f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");
80     f.Close();
81   }else{
82     // save in CDB storage
83     AliCDBMetaData* md = new AliCDBMetaData();
84     md->SetResponsible("E. Cuautle & M. Rodriguez ");
85     md->SetComment("Residual misalignment for ACORDE");
86     md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
87     AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());
88     storage->Put(array,id,md);
89   }
90
91   array->Delete();
92
93 }
94