Protection against 0x0 in TList.
[u/mrichter/AliRoot.git] / ITS / DrawITSAlignObj.C
CommitLineData
3b61c716 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TCanvas.h>
3#include <TClonesArray.h>
4#include <TFile.h>
5#include <TGeoManager.h>
6#include <TH1F.h>
7#include <TString.h>
8#include <Riostream.h>
9#include "AliAlignObj.h"
10#endif
3f4ae62a 11void DrawITSAlignObj(const char* filename="ITSfullMisalignment.root",
12 const char* filenameOut="ITSfullModuleMisalignment.root",
13 Bool_t local=kFALSE) {
3b61c716 14 //
15 // Draw distribution of alignment constants
16 // (original version: A.Jacholkowski; modified by: A.Dainese)
17 //
18
19/* $Id$ */
20
3f4ae62a 21 AliGeomManager::LoadGeometry("geometry.root");
3b61c716 22
23 TFile* f = TFile::Open(filename);
24 if(!f) {cerr<<"cannot open input file\n"; return;}
25
26 TCanvas *cSPDsector = new TCanvas("cSPDsector","SPD sectors alignobjs",0,0,800,600);
27 cSPDsector->Divide(3,2);
28 TH1F* hxSPDsector = new TH1F("hxSPDsector","x in SPD sectors",100,-0.1,0.1);
29 hxSPDsector->SetXTitle("[cm]");
30 TH1F* hySPDsector = new TH1F("hySPDsector","y in SPD sectors",100,-0.1,0.1);
31 hySPDsector->SetXTitle("[cm]");
32 TH1F* hzSPDsector = new TH1F("hzSPDsector","z in SPD sectors",100,-0.1,0.1);
33 hzSPDsector->SetXTitle("[cm]");
34 TH1F* hrxSPDsector = new TH1F("hrxSPDsector","rx in SPD sectors",100,-0.5,0.5);
35 hrxSPDsector->SetXTitle("[deg]");
36 TH1F* hrySPDsector = new TH1F("hrySPDsector","ry in SPD sectors",100,-0.5,0.5);
37 hrySPDsector->SetXTitle("[deg]");
38 TH1F* hrzSPDsector = new TH1F("hrzSPDsector","rz in SPD sectors",100,-0.5,0.5);
39 hrzSPDsector->SetXTitle("[deg]");
40
41 TCanvas *cSPDhalfstave = new TCanvas("cSPDhalfstave","SPD halfstaves alignobjs",0,0,800,600);
42 cSPDhalfstave->Divide(3,2);
43 TH1F* hxSPDhalfstave = new TH1F("hxSPDhalfstave","x in SPD halfstaves",100,-0.01,0.01);
44 hxSPDhalfstave->SetXTitle("[cm]");
45 TH1F* hySPDhalfstave = new TH1F("hySPDhalfstave","y in SPD halfstaves",100,-0.01,0.01);
46 hySPDhalfstave->SetXTitle("[cm]");
47 TH1F* hzSPDhalfstave = new TH1F("hzSPDhalfstave","z in SPD halfstaves",100,-0.01,0.01);
48 hzSPDhalfstave->SetXTitle("[cm]");
49 TH1F* hrxSPDhalfstave = new TH1F("hrxSPDhalfstave","rx in SPD halfstaves",100,-0.1,0.1);
50 hrxSPDhalfstave->SetXTitle("[deg]");
51 TH1F* hrySPDhalfstave = new TH1F("hrySPDhalfstave","ry in SPD halfstaves",100,-0.1,0.1);
52 hrySPDhalfstave->SetXTitle("[deg]");
53 TH1F* hrzSPDhalfstave = new TH1F("hrzSPDhalfstave","rz in SPD halfstaves",100,-0.5,0.5);
54 hrzSPDhalfstave->SetXTitle("[deg]");
55
56 TCanvas *cSPDladder = new TCanvas("cSPDladder","SPD ladders alignobjs",0,0,800,600);
57 cSPDladder->Divide(3,2);
58 TH1F* hxSPDladder = new TH1F("hxSPDladder","x in SPD ladders",100,-0.01,0.01);
59 hxSPDladder->SetXTitle("[cm]");
60 TH1F* hySPDladder = new TH1F("hySPDladder","y in SPD ladders",100,-0.01,0.01);
61 hySPDladder->SetXTitle("[cm]");
62 TH1F* hzSPDladder = new TH1F("hzSPDladder","z in SPD ladders",100,-0.01,0.01);
63 hzSPDladder->SetXTitle("[cm]");
64 TH1F* hrxSPDladder = new TH1F("hrxSPDladder","rx in SPD ladders",100,-0.01,0.01);
65 hrxSPDladder->SetXTitle("[deg]");
66 TH1F* hrySPDladder = new TH1F("hrySPDladder","ry in SPD ladders",100,-0.01,0.01);
67 hrySPDladder->SetXTitle("[deg]");
68 TH1F* hrzSPDladder = new TH1F("hrzSPDladder","rz in SPD ladders",100,-0.01,0.01);
69 hrzSPDladder->SetXTitle("[deg]");
70
71 TCanvas *cSDDladder = new TCanvas("cSDDladder","SDD ladders alignobjs",0,0,800,600);
72 cSDDladder->Divide(3,2);
73 TH1F* hxSDDladder = new TH1F("hxSDDladder","x in SDD ladders",100,-0.01,0.01);
74 hxSDDladder->SetXTitle("[cm]");
75 TH1F* hySDDladder = new TH1F("hySDDladder","y in SDD ladders",100,-0.01,0.01);
76 hySDDladder->SetXTitle("[cm]");
77 TH1F* hzSDDladder = new TH1F("hzSDDladder","z in SDD ladders",100,-0.01,0.01);
78 hzSDDladder->SetXTitle("[cm]");
79 TH1F* hrxSDDladder = new TH1F("hrxSDDladder","rx in SDD ladders",100,-0.01,0.01);
80 hrxSDDladder->SetXTitle("[deg]");
81 TH1F* hrySDDladder = new TH1F("hrySDDladder","ry in SDD ladders",100,-0.01,0.01);
82 hrySDDladder->SetXTitle("[deg]");
83 TH1F* hrzSDDladder = new TH1F("hrzSDDladder","rz in SDD ladders",100,-0.01,0.01);
84 hrzSDDladder->SetXTitle("[deg]");
85
86 TCanvas *cSDDsensor = new TCanvas("cSDDsensor","SDD sensors alignobjs",0,0,800,600);
87 cSDDsensor->Divide(3,2);
88 TH1F* hxSDDsensor = new TH1F("hxSDDsensor","x in SDD sensors",100,-0.01,0.01);
89 hxSDDsensor->SetXTitle("[cm]");
90 TH1F* hySDDsensor = new TH1F("hySDDsensor","y in SDD sensors",100,-0.01,0.01);
91 hySDDsensor->SetXTitle("[cm]");
92 TH1F* hzSDDsensor = new TH1F("hzSDDsensor","z in SDD sensors",100,-0.01,0.01);
93 hzSDDsensor->SetXTitle("[cm]");
94 TH1F* hrxSDDsensor = new TH1F("hrxSDDsensor","rx in SDD sensors",100,-0.01,0.01);
95 hrxSDDsensor->SetXTitle("[deg]");
96 TH1F* hrySDDsensor = new TH1F("hrySDDsensor","ry in SDD sensors",100,-0.01,0.01);
97 hrySDDsensor->SetXTitle("[deg]");
98 TH1F* hrzSDDsensor = new TH1F("hrzSDDsensor","rz in SDD sensors",100,-0.01,0.01);
99 hrzSDDsensor->SetXTitle("[deg]");
100
101
102 TCanvas *cSSDladder = new TCanvas("cSSDladder","SSD ladders alignobjs",0,0,800,600);
103 cSSDladder->Divide(3,2);
104 TH1F* hxSSDladder = new TH1F("hxSSDladder","x in SSD ladders",100,-0.01,0.01);
105 hxSSDladder->SetXTitle("[cm]");
106 TH1F* hySSDladder = new TH1F("hySSDladder","y in SSD ladders",100,-0.01,0.01);
107 hySSDladder->SetXTitle("[cm]");
108 TH1F* hzSSDladder = new TH1F("hzSSDladder","z in SSD ladders",100,-0.01,0.01);
109 hzSSDladder->SetXTitle("[cm]");
110 TH1F* hrxSSDladder = new TH1F("hrxSSDladder","rx in SSD ladders",100,-0.01,0.01);
111 hrxSSDladder->SetXTitle("[deg]");
112 TH1F* hrySSDladder = new TH1F("hrySSDladder","ry in SSD ladders",100,-0.01,0.01);
113 hrySSDladder->SetXTitle("[deg]");
114 TH1F* hrzSSDladder = new TH1F("hrzSSDladder","rz in SSD ladders",100,-0.01,0.01);
115 hrzSSDladder->SetXTitle("[deg]");
116
117 TCanvas *cSSDsensor = new TCanvas("cSSDsensor","SSD sensors alignobjs",0,0,800,600);
118 cSSDsensor->Divide(3,2);
119 TH1F* hxSSDsensor = new TH1F("hxSSDsensor","x in SSD sensors",100,-0.01,0.01);
120 hxSSDsensor->SetXTitle("[cm]");
121 TH1F* hySSDsensor = new TH1F("hySSDsensor","y in SSD sensors",100,-0.01,0.01);
122 hySSDsensor->SetXTitle("[cm]");
123 TH1F* hzSSDsensor = new TH1F("hzSSDsensor","z in SSD sensors",100,-0.01,0.01);
124 hzSSDsensor->SetXTitle("[cm]");
125 TH1F* hrxSSDsensor = new TH1F("hrxSSDsensor","rx in SSD sensors",100,-0.01,0.01);
126 hrxSSDsensor->SetXTitle("[deg]");
127 TH1F* hrySSDsensor = new TH1F("hrySSDsensor","ry in SSD sensors",100,-0.01,0.01);
128 hrySSDsensor->SetXTitle("[deg]");
129 TH1F* hrzSSDsensor = new TH1F("hrzSSDsensor","rz in SSD sensors",100,-0.01,0.01);
130 hrzSSDsensor->SetXTitle("[deg]");
131
132
133
134 TClonesArray* ar = (TClonesArray*)f->Get("ITSAlignObjs");
135 Int_t entries = ar->GetEntriesFast();
136 cout<<"number of alignment objects: "<<entries<<endl;
3f4ae62a 137 Bool_t overlaps;
138 AliGeomManager::ApplyAlignObjsToGeom(*ar,overlaps);
3b61c716 139
140 AliAlignObj* a;
141 Option_t *opt = NULL;
142 Double_t tr[3];
143 Double_t rot[3];
3f4ae62a 144 TGeoHMatrix delta;
145
146
147 TClonesArray *arrayOut = new TClonesArray("AliAlignObjParams",4000);
148 TClonesArray &alobjOut = *arrayOut;
149 Int_t j=0;
3b61c716 150
151 for(Int_t i=0; i<entries; i++){
152 a=(AliAlignObj*)ar->UncheckedAt(i);
153 if(local) {
154 a->GetLocalPars(tr,rot);
155 } else {
156 a->GetPars(tr,rot);
157 }
158 TString symName = a->GetSymName();
3f4ae62a 159 UShort_t volUID = a->GetVolUID();
160 printf("VolId %d %s\n",volUID,symName.Data());
161
162 AliGeomManager::GetDeltaForBranch(*a,delta);
163 //delta.Print();
164
165 // create AliAlignObjParam with total delta
166 if(i==0 || volUID!=0) {
167 new(alobjOut[j]) AliAlignObjParams(symName.Data(),volUID,delta,kTRUE);
168 j++;
169 }
170
171
172 // plots
173 //
3b61c716 174 if(!symName.Contains("SPD") && !symName.Contains("SDD") && !symName.Contains("SSD")) {
175 a->Print(opt);
176 }
177 if(symName.Contains("SPD") && symName.Contains("Sector") && !symName.Contains("HalfStave")) {
178 hxSPDsector->Fill(tr[0]);
179 hySPDsector->Fill(tr[1]);
180 hzSPDsector->Fill(tr[2]);
181 hrxSPDsector->Fill(rot[0]);
182 hrySPDsector->Fill(rot[1]);
3f4ae62a 183 hrzSPDsector->Fill(rot[2]);
3b61c716 184 }
185 if(symName.Contains("SPD") && symName.Contains("Sector") && symName.Contains("HalfStave") && !symName.Contains("Ladder")) {
186 hxSPDhalfstave->Fill(tr[0]);
187 hySPDhalfstave->Fill(tr[1]);
188 hzSPDhalfstave->Fill(tr[2]);
189 hrxSPDhalfstave->Fill(rot[0]);
190 hrySPDhalfstave->Fill(rot[1]);
191 hrzSPDhalfstave->Fill(rot[2]);
192 }
193 if(symName.Contains("SPD") && symName.Contains("Sector") && symName.Contains("HalfStave") && symName.Contains("Ladder")) {
194 hxSPDladder->Fill(tr[0]);
195 hySPDladder->Fill(tr[1]);
196 hzSPDladder->Fill(tr[2]);
197 hrxSPDladder->Fill(rot[0]);
198 hrySPDladder->Fill(rot[1]);
199 hrzSPDladder->Fill(rot[2]);
200 }
201 if(symName.Contains("SDD") && symName.Contains("Ladder") && !symName.Contains("Sensor")) {
202 hxSDDladder->Fill(tr[0]);
203 hySDDladder->Fill(tr[1]);
204 hzSDDladder->Fill(tr[2]);
205 hrxSDDladder->Fill(rot[0]);
206 hrySDDladder->Fill(rot[1]);
207 hrzSDDladder->Fill(rot[2]);
208 }
209 if(symName.Contains("SDD") && symName.Contains("Ladder") && symName.Contains("Sensor")) {
210 hxSDDsensor->Fill(tr[0]);
211 hySDDsensor->Fill(tr[1]);
212 hzSDDsensor->Fill(tr[2]);
213 hrxSDDsensor->Fill(rot[0]);
214 hrySDDsensor->Fill(rot[1]);
215 hrzSDDsensor->Fill(rot[2]);
216 }
217 if(symName.Contains("SSD") && symName.Contains("Ladder") && !symName.Contains("Sensor")) {
218 hxSSDladder->Fill(tr[0]);
219 hySSDladder->Fill(tr[1]);
220 hzSSDladder->Fill(tr[2]);
221 hrxSSDladder->Fill(rot[0]);
222 hrySSDladder->Fill(rot[1]);
223 hrzSSDladder->Fill(rot[2]);
224 }
225 if(symName.Contains("SSD") && symName.Contains("Ladder") && symName.Contains("Sensor")) {
226 hxSSDsensor->Fill(tr[0]);
227 hySSDsensor->Fill(tr[1]);
228 hzSSDsensor->Fill(tr[2]);
229 hrxSSDsensor->Fill(rot[0]);
230 hrySSDsensor->Fill(rot[1]);
231 hrzSSDsensor->Fill(rot[2]);
232 }
233
234
235 }
236
237
238 cSPDsector->cd(1);
239 hxSPDsector->Draw();
240 cSPDsector->cd(2);
241 hySPDsector->Draw();
242 cSPDsector->cd(3);
243 hzSPDsector->Draw();
244 cSPDsector->cd(4);
245 hrxSPDsector->Draw();
246 cSPDsector->cd(5);
247 hrySPDsector->Draw();
248 cSPDsector->cd(6);
249 hrzSPDsector->Draw();
250
251 cSPDhalfstave->cd(1);
252 hxSPDhalfstave->Draw();
253 cSPDhalfstave->cd(2);
254 hySPDhalfstave->Draw();
255 cSPDhalfstave->cd(3);
256 hzSPDhalfstave->Draw();
257 cSPDhalfstave->cd(4);
258 hrxSPDhalfstave->Draw();
259 cSPDhalfstave->cd(5);
260 hrySPDhalfstave->Draw();
261 cSPDhalfstave->cd(6);
262 hrzSPDhalfstave->Draw();
263
264 cSPDladder->cd(1);
265 hxSPDladder->Draw();
266 cSPDladder->cd(2);
267 hySPDladder->Draw();
268 cSPDladder->cd(3);
269 hzSPDladder->Draw();
270 cSPDladder->cd(4);
271 hrxSPDladder->Draw();
272 cSPDladder->cd(5);
273 hrySPDladder->Draw();
274 cSPDladder->cd(6);
275 hrzSPDladder->Draw();
276
277
278 cSDDladder->cd(1);
279 hxSDDladder->Draw();
280 cSDDladder->cd(2);
281 hySDDladder->Draw();
282 cSDDladder->cd(3);
283 hzSDDladder->Draw();
284 cSDDladder->cd(4);
285 hrxSDDladder->Draw();
286 cSDDladder->cd(5);
287 hrySDDladder->Draw();
288 cSDDladder->cd(6);
289 hrzSDDladder->Draw();
290
291 cSDDsensor->cd(1);
292 hxSDDsensor->Draw();
293 cSDDsensor->cd(2);
294 hySDDsensor->Draw();
295 cSDDsensor->cd(3);
296 hzSDDsensor->Draw();
297 cSDDsensor->cd(4);
298 hrxSDDsensor->Draw();
299 cSDDsensor->cd(5);
300 hrySDDsensor->Draw();
301 cSDDsensor->cd(6);
302 hrzSDDsensor->Draw();
303
304 cSSDladder->cd(1);
305 hxSSDladder->Draw();
306 cSSDladder->cd(2);
307 hySSDladder->Draw();
308 cSSDladder->cd(3);
309 hzSSDladder->Draw();
310 cSSDladder->cd(4);
311 hrxSSDladder->Draw();
312 cSSDladder->cd(5);
313 hrySSDladder->Draw();
314 cSSDladder->cd(6);
315 hrzSSDladder->Draw();
316
317 cSSDsensor->cd(1);
318 hxSSDsensor->Draw();
319 cSSDsensor->cd(2);
320 hySSDsensor->Draw();
321 cSSDsensor->cd(3);
322 hzSSDsensor->Draw();
323 cSSDsensor->cd(4);
324 hrxSSDsensor->Draw();
325 cSSDsensor->cd(5);
326 hrySSDsensor->Draw();
327 cSSDsensor->cd(6);
328 hrzSSDsensor->Draw();
329
3f4ae62a 330
331 TFile fout(filenameOut,"RECREATE");
332 fout.cd();
333 fout.WriteObject(arrayOut,"ITSAlignObjs","kSingleKey");
334 fout.Close();
335
3b61c716 336 return;
337}