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