Split the 0MQ dependent part of MINITOR
[u/mrichter/AliRoot.git] / ACORDE / MakeACORDEFullMisAlignment.C
CommitLineData
a65a7e70 1void MakeACORDEFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for ACORDE
3 //
4 const char* macroname = "MakeACORDEFullMisAlignment.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 // AliGeomManager::LoadGeometry("geometry.root");
36
37 TClonesArray *array = new TClonesArray("AliAlignObjParams",60);
38 TClonesArray &alobj = *array;
39
40 TRandom *rnd = new TRandom(4321);
41 Int_t j = 0;
42 Double_t dx, dy, dz, dpsi, dtheta, dphi;
43
44 // RS = local
45 // sigma translation = 1 mm
46 // sigma rotation = 0.5 degrees
47 Double_t sigmatr = 2;
48 Double_t sigmarot = 1;
49
50 TString symname;
51 TString basename = "ACORDE/Array";
52 Int_t iIndex=0;
53 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
54 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
55
56 for (Int_t imod=0; imod<60; imod++){
57 dx = rnd->Gaus(0.,sigmatr);
58 dy = rnd->Gaus(0.,sigmatr);
59 dz = rnd->Gaus(0.,sigmatr);
60 dpsi = rnd->Gaus(0.,sigmarot);
61 dtheta = rnd->Gaus(0.,sigmarot);
62 dphi = rnd->Gaus(0.,sigmarot);
63 symname = basename;
64 symname += imod;
65 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);
66 }
67
68 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
69 // save on file
70 const char* filename = "ACORDEfullMisalignment.root";
71 TFile f(filename,"RECREATE");
72 if(!f){
73 Error(macroname,"cannot open file for output\n");
74 return;
75 }
76 Info(macroname,"Saving alignment objects to the file %s", filename);
77 f.cd();
78 f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");
79 f.Close();
80 }else{
81 // save in CDB storage
82 AliCDBMetaData* md = new AliCDBMetaData();
83 md->SetResponsible("E. Cuautle & M. Rodriguez");
84 md->SetComment("Full misalignment for ACORDE");
85 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
86 AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());
87 storage->Put(array,id,md);
88 }
89
90 array->Delete();
91
92}
93