1895a097 |
1 | void MakeTRDResMisAlignment(){ |
2 | // Create TClonesArray of residual misalignment objects for TRD |
3 | // |
6fce62af |
4 | const char* macroname = "MakeTRDResMisAlignment.C"; |
90dbf5fb |
5 | TClonesArray *array = new TClonesArray("AliAlignObjParams",1000); |
1895a097 |
6 | TClonesArray &alobj = *array; |
7 | |
6fce62af |
8 | // Activate CDB storage and load geometry from CDB |
9 | AliCDBManager* cdb = AliCDBManager::Instance(); |
10 | if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT"); |
11 | cdb->SetRun(0); |
12 | |
13 | AliCDBStorage* storage; |
14 | |
15 | if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){ |
16 | TString Storage = gSystem->Getenv("STORAGE"); |
17 | if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { |
18 | Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); |
19 | return; |
20 | } |
21 | storage = cdb->GetStorage(Storage.Data()); |
22 | if(!storage){ |
23 | Error(macroname,"Unable to open storage %s\n",Storage.Data()); |
24 | return; |
25 | } |
26 | AliCDBPath path("GRP","Geometry","Data"); |
27 | AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); |
28 | if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); |
29 | entry->SetOwner(0); |
30 | TGeoManager* geom = (TGeoManager*) entry->GetObject(); |
31 | AliGeomManager::SetGeometry(geom); |
32 | }else{ |
33 | AliGeomManager::LoadGeometry(); //load geom from default CDB storage |
34 | } |
1895a097 |
35 | |
1895a097 |
36 | // sigmas for the chambers |
d3a9c52a |
37 | Double_t chdx=0.002; // 20 microns |
38 | Double_t chdy=0.003; // 30 microns |
39 | Double_t chdz=0.007; // 70 microns |
1895a097 |
40 | Double_t chrx=0.3/1000/TMath::Pi()*180; // 0.3 mrad |
41 | Double_t chry=0.3/1000/TMath::Pi()*180; // 0.3 mrad |
42 | Double_t chrz=0.1/1000/TMath::Pi()*180; // 0.1 mrad |
43 | |
6fce62af |
44 | Double_t dx=0.,dy=0.,dz=0.,rx=0.,ry=0.,rz=0.; |
1895a097 |
45 | |
46 | Int_t j=0; |
47 | TRandom *ran = new TRandom(4357); |
48 | UShort_t volid; |
6fce62af |
49 | const char* symname; |
1895a097 |
50 | |
6fce62af |
51 | // create the supermodules' alignment objects |
52 | for (int i; i<18; i++) { |
53 | TString sm_symname(Form("TRD/sm%02d",i)); |
54 | new((*array)[j++]) |
55 | AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kTRUE); |
56 | } |
57 | |
1895a097 |
58 | // create the chambers' alignment objects |
ae079791 |
59 | for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) { |
60 | for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) { |
6fce62af |
61 | ran->Rannor(dx,rx); |
62 | ran->Rannor(dy,ry); |
63 | ran->Rannor(dz,rz); |
1895a097 |
64 | dx*=chdx; |
65 | dy*=chdy; |
66 | dz*=chdz; |
67 | rx*=chrx; |
68 | ry*=chry; |
69 | rz*=chrz; |
ae079791 |
70 | volid = AliGeomManager::LayerToVolUID(iLayer,iModule); |
71 | symname = AliGeomManager::SymName(volid); |
90dbf5fb |
72 | new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE); |
1895a097 |
73 | } |
74 | } |
75 | |
5bd470e1 |
76 | if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){ |
1895a097 |
77 | // save on file |
dfe9c69d |
78 | const char* filename = "TRDresidualMisalignment.root"; |
79 | TFile f(filename,"RECREATE"); |
80 | if(!f){ |
81 | Error(macroname,"cannot open file for output\n"); |
82 | return; |
83 | } |
84 | Info(macroname,"Saving alignment objects to the file %s", filename); |
1895a097 |
85 | f.cd(); |
86 | f.WriteObject(array,"TRDAlignObjs","kSingleKey"); |
87 | f.Close(); |
88 | }else{ |
89 | // save in CDB storage |
1895a097 |
90 | AliCDBMetaData* md = new AliCDBMetaData(); |
91 | md->SetResponsible("Dariusz Miskowiec"); |
92 | md->SetComment("Residual misalignment for TRD"); |
5bd470e1 |
93 | md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); |
dfe9c69d |
94 | AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity()); |
1895a097 |
95 | storage->Put(array,id,md); |
96 | } |
97 | |
98 | array->Delete(); |
99 | |
100 | } |
101 | |
102 | |