1895a097 |
1 | void MakeTRDFullMisAlignment(){ |
2 | // Create TClonesArray of full misalignment objects for TRD |
6fce62af |
3 | // Expects to read objects for FRAME |
1895a097 |
4 | // |
90dbf5fb |
5 | TClonesArray *array = new TClonesArray("AliAlignObjParams",1000); |
6fce62af |
6 | const char* macroname = "MakeTRDFullMisAlignment.C"; |
7 | |
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; |
a24be56b |
14 | TString Storage; |
6fce62af |
15 | |
a24be56b |
16 | if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ |
17 | Storage = gSystem->Getenv("STORAGE"); |
6fce62af |
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 | // load FRAME full misalignment objects (if needed, the macro |
38 | // for FRAME has to be ran in advance) and apply them to geometry |
6fce62af |
39 | AliCDBPath fpath("GRP","Align","Data"); |
a24be56b |
40 | AliCDBEntry *eFrame; |
41 | if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ |
42 | Info(macroname,"Loading FRAME alignment objects from CDB storage %s", |
43 | Storage.Data()); |
44 | eFrame = storage->Get(fpath.GetPath(),cdb->GetRun()); |
6fce62af |
45 | }else{ |
a24be56b |
46 | eFrame = cdb->Get(fpath.GetPath()); |
6fce62af |
47 | } |
a24be56b |
48 | if(!eFrame) Fatal(macroname,"Could not get the specified CDB entry!"); |
49 | TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject(); |
50 | arFrame->Sort(); |
51 | Int_t nvols = arFrame->GetEntriesFast(); |
52 | Bool_t flag = kTRUE; |
53 | for(Int_t j=0; j<nvols; j++) |
54 | { |
55 | AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j); |
56 | if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; |
57 | } |
58 | if(!flag) Fatal(macroname,"Error in the application of FRAME objects"); |
1895a097 |
59 | |
6fce62af |
60 | |
d3a9c52a |
61 | // sigmas for the supermodules |
62 | Double_t smdx=0.3; // 3 mm |
63 | Double_t smdy=0.3; // 3 mm |
64 | Double_t smdz=0.3; // 3 mm |
65 | Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad |
66 | Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad |
67 | Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad |
68 | |
69 | |
1895a097 |
70 | // sigmas for the chambers |
d3a9c52a |
71 | Double_t chdx=0.1; // 1 mm |
72 | Double_t chdy=0.1; // 1 mm |
73 | Double_t chdz=0.1; // 1 mm |
1895a097 |
74 | Double_t chrx=1.0/1000/TMath::Pi()*180; // 1 mrad |
75 | Double_t chry=1.0/1000/TMath::Pi()*180; // 1 mrad |
76 | Double_t chrz=0.7/1000/TMath::Pi()*180; // 0.7 mrad |
77 | |
05b6df61 |
78 | Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1}; |
1895a097 |
79 | Double_t dx,dy,dz,rx,ry,rz; |
80 | |
81 | Int_t j=0; |
82 | TRandom *ran = new TRandom(4357); |
83 | UShort_t volid; |
d3a9c52a |
84 | const char *symname; |
85 | |
d3a9c52a |
86 | // create the supermodules' alignment objects |
a24be56b |
87 | for (int iSect; iSect<18; iSect++) { |
88 | TString sm_symname(Form("TRD/sm%02d",iSect)); |
d3a9c52a |
89 | ran->Rannor(dx,rx); |
90 | ran->Rannor(dy,ry); |
91 | ran->Rannor(dz,rz); |
92 | dx*=smdx; |
93 | dy*=smdy; |
94 | dz*=smdz; |
95 | rx*=smrx; |
96 | ry*=smry; |
97 | rz*=smrz; |
05b6df61 |
98 | if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; |
6fce62af |
99 | new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE); |
d3a9c52a |
100 | } |
a24be56b |
101 | // apply supermodules' alignment objects |
102 | Int_t smCounter=0; |
103 | for(Int_t iSect=0; iSect<18; iSect++){ |
05b6df61 |
104 | if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; |
a24be56b |
105 | AliAlignObjParams* smobj = |
106 | (AliAlignObjParams*)array->UncheckedAt(smCounter++); |
d3a9c52a |
107 | if(!smobj->ApplyToGeometry()){ |
a24be56b |
108 | Fatal(macroname,Form("application of full misalignment object for sector %d failed!",iSect)); |
d3a9c52a |
109 | return; |
110 | } |
111 | } |
6fce62af |
112 | |
1895a097 |
113 | // create the chambers' alignment objects |
d3a9c52a |
114 | ran = new TRandom(4357); |
a24be56b |
115 | Int_t chId; |
ae079791 |
116 | for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) { |
a24be56b |
117 | chId=-1; |
118 | for (Int_t iSect = 0; iSect < 18; iSect++){ |
119 | for (Int_t iCh = 0; iCh < 5; iCh++) { |
d3a9c52a |
120 | ran->Rannor(dx,rx); |
121 | ran->Rannor(dy,ry); |
122 | ran->Rannor(dz,rz); |
1895a097 |
123 | dx*=chdx; |
124 | dy*=chdy; |
125 | dz*=chdz; |
126 | rx*=chrx; |
127 | ry*=chry; |
128 | rz*=chrz; |
a24be56b |
129 | chId++; |
259b0bd4 |
130 | if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue; |
a24be56b |
131 | volid = AliGeomManager::LayerToVolUID(iLayer,chId); |
05b6df61 |
132 | if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; |
ae079791 |
133 | symname = AliGeomManager::SymName(volid); |
6fce62af |
134 | new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE); |
1895a097 |
135 | } |
136 | } |
a24be56b |
137 | } |
1895a097 |
138 | |
a24be56b |
139 | if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ |
1895a097 |
140 | // save on file |
dfe9c69d |
141 | const char* filename = "TRDfullMisalignment.root"; |
142 | TFile f(filename,"RECREATE"); |
143 | if(!f){ |
144 | Error(macroname,"cannot open file for output\n"); |
145 | return; |
146 | } |
147 | Info(macroname,"Saving alignment objects to the file %s", filename); |
1895a097 |
148 | f.cd(); |
149 | f.WriteObject(array,"TRDAlignObjs","kSingleKey"); |
150 | f.Close(); |
151 | }else{ |
152 | // save in CDB storage |
dfe9c69d |
153 | Info(macroname,"Saving alignment objects in CDB storage %s", |
154 | Storage.Data()); |
1895a097 |
155 | AliCDBMetaData* md = new AliCDBMetaData(); |
156 | md->SetResponsible("Dariusz Miskowiec"); |
157 | md->SetComment("Full misalignment for TRD"); |
5bd470e1 |
158 | md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); |
dfe9c69d |
159 | AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity()); |
1895a097 |
160 | storage->Put(array,id,md); |
161 | } |
162 | |
163 | array->Delete(); |
1895a097 |
164 | } |
165 | |