]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/MakeTOFResMisAlignment.C
35672865de66db6d237c063b6d98cfea5dc042d6
[u/mrichter/AliRoot.git] / TOF / MakeTOFResMisAlignment.C
1 void MakeTOFResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TOF
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
5   TClonesArray &alobj = *array;
6    
7   const char* macroname = "MakeTOFResMisAlignment.C";
8
9   // Activate CDB storage and load geometry from CDB
10   AliCDBManager* cdb = AliCDBManager::Instance();
11   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
12   cdb->SetRun(0);
13   
14   AliCDBStorage* storage;
15   
16   if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
17     TString Storage = gSystem->Getenv("STORAGE");
18     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
19       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
20       return;
21     }
22     storage = cdb->GetStorage(Storage.Data());
23     if(!storage){
24       Error(macroname,"Unable to open storage %s\n",Storage.Data());
25       return;
26     }
27     AliCDBPath path("GRP","Geometry","Data");
28     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
29     if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
30     entry->SetOwner(0);
31     TGeoManager* geom = (TGeoManager*) entry->GetObject();
32     AliGeomManager::SetGeometry(geom);
33   }else{
34     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
35   }    
36
37   AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
38   Int_t i;
39   Int_t j=0;
40   Double_t dx=0.; 
41   Double_t dy=0.; 
42   Double_t dz=0.;
43   Double_t  dpsi, dtheta, dphi;
44   TRandom *rnd   = new TRandom(4357);
45   Double_t sigmatr = 0.1; // sigma (in cm) for shift w.r.t. local ideal RS
46
47   for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
48     dx = 0;
49     dy = rnd->Gaus(0.,sigmatr);
50     dz = rnd->Gaus(0.,sigmatr);
51     dpsi = 0.;
52     dtheta = 0.;
53     dphi = 0.;
54     new(alobj[j]) AliAlignObjParams(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
55     j++;
56   }
57
58   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
59     // save on file
60     const char* filename = "TOFresidualMisalignment.root";
61     TFile f(filename,"RECREATE");
62     if(!f){
63       Error(macroname,"cannot open file for output\n");
64       return;
65     }
66     Info(macroname,"Saving alignment objects to the file %s", filename);
67     f.cd();
68     f.WriteObject(array,"TOFAlignObjs","kSingleKey");
69     f.Close();
70   }else{
71     // save in CDB storage
72     AliCDBMetaData* md = new AliCDBMetaData();
73     md->SetResponsible("Silvia Arcelli");
74     md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
75     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
76     AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
77     storage->Put(array,id,md);
78   }
79
80   array->Delete();
81
82 }
83
84