]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/MakeTRDResMisAlignment.C
Moving the alignment-related static methods from AliAlignObj to the new geometry...
[u/mrichter/AliRoot.git] / TRD / MakeTRDResMisAlignment.C
1 void MakeTRDResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TRD
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjAngles",1000);
5   TClonesArray &alobj = *array;
6    
7   if(!gGeoManager) TGeoManager::Import("geometry.root");
8   // needed for the constructors with local coordinates not to fail
9
10   AliAlignObjAngles a;
11
12   // sigmas for the chambers
13   Double_t chdx=0.002; // 20 microns
14   Double_t chdy=0.003; // 30 microns
15   Double_t chdz=0.007; // 70 microns
16   Double_t chrx=0.3/1000/TMath::Pi()*180; // 0.3 mrad
17   Double_t chry=0.3/1000/TMath::Pi()*180; // 0.3 mrad
18   Double_t chrz=0.1/1000/TMath::Pi()*180; // 0.1 mrad
19
20   Double_t dx,dy,dz,rx,ry,rz;
21
22   Int_t j=0;
23   TRandom *ran = new TRandom(4357);
24   UShort_t volid;
25   const char *path;
26
27   // create the chambers' alignment objects
28   for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
29     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
30       ran.Rannor(dx,rx);
31       ran.Rannor(dy,ry);
32       ran.Rannor(dz,rz);
33       dx*=chdx;
34       dy*=chdy;
35       dz*=chdz;
36       rx*=chrx;
37       ry*=chry;
38       rz*=chrz;
39       volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
40       symname = AliGeomManager::SymName(volid);
41       new(alobj[j++]) AliAlignObjAngles(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
42     }
43   }
44
45   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
46     // save on file
47     TFile f("TRDresidualMisalignment.root","RECREATE");
48     if(!f) cerr<<"cannot open file for output\n";
49     f.cd();
50     f.WriteObject(array,"TRDAlignObjs","kSingleKey");
51     f.Close();
52   }else{
53     // save in CDB storage
54     const char* Storage = gSystem->Getenv("STORAGE");
55     AliCDBManager* cdb = AliCDBManager::Instance();
56     AliCDBStorage* storage = cdb->GetStorage(Storage);
57     AliCDBMetaData* md = new AliCDBMetaData();
58     md->SetResponsible("Dariusz Miskowiec");
59     md->SetComment("Residual misalignment for TRD");
60     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
61     AliCDBId id("TRD/Align/Data",0,9999999);
62     storage->Put(array,id,md);
63   }
64
65   array->Delete();
66
67 }
68
69