.so cleanup: more gSystem->Load()
[u/mrichter/AliRoot.git] / GRP / MakeSTRUCTFullMisAlignment.C
1 void MakeSTRUCTFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for all STRUCTures
3   // (presently this includes only FRAME)
4   // Full alignment objects for FRAME segments are built by
5   // averaging in each supermodule the values produced by the
6   // ANSYS finite-elements simulation
7   //
8   const char* macroname = "MakeSTRUCTFullMisAlignment.C";
9   TClonesArray *array = new TClonesArray("AliAlignObjParams",20);
10
11   const char* baseSymName ="FRAME/Sector"; //base of symbolic name corresponding to base of path "ALIC_1/B077_1/BSEGMO";
12   TString symname;
13
14   // the following hardcoded values have been obtained by taking the output of the ANSYS simulation
15   // (finite elements simulation of deformations for given loads) and recalculating the avarege
16   // displacement of the center of each space-frame sector
17   Double_t dx[18]={0.13375,0.25125,0.2325,0.17,0.1475,0.12625,0.06375,0.0475,0.1775,0.32375,0.35125,0.285,0.205,0.1775,0.1525,0.07625,0.0075,0.01375};
18   Double_t dy[18]={-0.0275,0.00125,-0.03625,-0.14375,-0.2,-0.13375,-0.02125,0.015,-0.0175,-0.03125,-0.0325,-0.105,-0.24375,-0.32,-0.25375,-0.1225,-0.04875,-0.04125};
19
20   for(Int_t sm=0; sm<18; sm++){
21     symname = baseSymName;
22     symname += sm;
23     cout<<symname.Data()<<endl;
24     ((*array)[sm]) = new AliAlignObjParams(symname.Data(),0,dx[sm],dy[sm],0.,0.,0.,0.,kTRUE);
25   }
26
27   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
28     // save on file
29     const char* filename = "STRUCTfullMisalignment.root";
30     TFile f(filename,"RECREATE");
31     if(!f){
32       Error(macroname,"cannot open file for output\n");
33       return;
34     }
35     Info(macroname,"Saving alignment objects in %s", filename);
36     f.cd();
37     f.WriteObject(array,"STRUCTAlignObjs","kSingleKey");
38     f.Close();
39   }else{
40     // save in CDB storage
41     TString Storage = gSystem->Getenv("STORAGE");
42     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
43       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
44       return;
45     }
46     Info(macroname,"Saving alignment objects in CDB storage %s",Storage.Data());
47     AliCDBManager* cdb = AliCDBManager::Instance();
48     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
49     if(!storage){
50       Error(macroname,"Unable to open storage %s\n",Storage.Data());
51       return;
52     }
53     AliCDBMetaData* md = new AliCDBMetaData();
54     md->SetResponsible("Grosso Raffaele");
55     md->SetComment("Full misalignment for FRAME, including dead weight and full weight deformations derived from ANSYS finiteelements simulation: dispmap corrected excel worksheet from Werner Riegler");
56     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
57     AliCDBId id("GRP/Align/Data",0,AliCDBRunRange::Infinity());
58     storage->Put(array,id,md);
59   }
60
61   array->Delete();
62
63 }
64