]>
Commit | Line | Data |
---|---|---|
7d5a9359 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #include "AliFieldReader.h" | |
19 | #include "AliMagFMaps.h" | |
20 | ||
21 | ||
22 | ||
23 | #include <TCanvas.h> | |
24 | #include <TGraph.h> | |
25 | #include <TMultiGraph.h> | |
26 | #include <TNtuple.h> | |
27 | #include <TObjString.h> | |
28 | #include <TString.h> | |
29 | #include <TStyle.h> | |
bfbd5665 | 30 | #include <TFile.h> |
7d5a9359 | 31 | ClassImp(AliFieldReader) |
32 | ||
33 | ||
34 | //_______________________________________________________________________ | |
35 | AliFieldReader::AliFieldReader() | |
36 | { | |
37 | SetCatalogueName(); | |
38 | SetZStart(); | |
39 | SetPolarity(); | |
40 | ||
41 | fDd = 0.08; | |
42 | fDz = 0.064; | |
43 | } | |
44 | ||
45 | //_______________________________________________________________________ | |
46 | AliFieldReader::~AliFieldReader() | |
47 | { | |
48 | // | |
49 | // Destructor | |
50 | // | |
51 | } | |
52 | ||
53 | //_______________________________________________________________________ | |
54 | void AliFieldReader::Init() | |
55 | { | |
56 | // Calculated map | |
57 | fField = new AliMagFMaps("Maps","Maps", 2, 1., 10., 2); | |
58 | // Catalogue | |
59 | fCatalogue = fopen(fCatalogueName, "r"); | |
60 | ||
61 | // HTML | |
62 | fHtmlMain = fopen("bmap.html", "w"); | |
63 | MakeHtmlHeaderMain(fHtmlMain); | |
64 | ||
65 | } | |
66 | ||
67 | ||
68 | void AliFieldReader::ReadMap() | |
69 | { | |
70 | // html | |
71 | ||
72 | ||
73 | Float_t zA[450], bxzA[200], byzA[200], bzzA[200], bxzcA[200], byzcA[200], bzzcA[200]; | |
74 | Float_t yA[450], bxyA[200], byyA[200], bzyA[200], bxycA[200], byycA[200], bzycA[200]; | |
75 | Float_t xA[450], bxxA[200], byxA[200], bzxA[200], bxxcA[200], byxcA[200], bzxcA[200]; | |
76 | ||
77 | Char_t sLine[255]; | |
78 | Char_t fLine[255]; | |
79 | ||
80 | Float_t xpos, ypos, zpos; | |
81 | Int_t iboxpos; | |
82 | ||
83 | Float_t h[3], x[3], b[3]; | |
84 | Float_t temp; | |
85 | Float_t xnt[17]; | |
86 | Int_t ires; | |
87 | ||
88 | Int_t iret, ipos; | |
89 | Int_t ic115 = 0; | |
90 | Float_t dx = 0.; | |
91 | Float_t dy = 0.; | |
92 | ||
93 | Init(); | |
94 | // Read register | |
95 | ReadRegisterMap(); | |
96 | // n-tuple | |
97 | fMap = new TNtuple("Field Map", "Map", | |
98 | "x:y:z:ix:iy:iz:bx:by:bz:bxc:byc:bzc:ifile:ireg:irot:temp:cal", 4000); | |
99 | ||
100 | // | |
101 | // Loop over files | |
102 | // | |
103 | Int_t ifiles = 0; | |
104 | // File catalogue | |
105 | while ((fgets(fLine, 255, fCatalogue)) != NULL && ifiles <= 2000) { | |
106 | ||
107 | if (strncmp(fLine,"#HEADER", 7) == 0) { | |
108 | iret = sscanf(&fLine[7],"%f", &fZStart); | |
109 | continue; | |
110 | } | |
111 | ifiles++; | |
112 | ||
113 | // if (ifiles != 87) continue; | |
114 | char fileName[32]; | |
115 | iret = sscanf(fLine, "%s", fileName); | |
116 | printf("Reading File %s\n", fileName); | |
117 | ||
118 | // Get run name | |
119 | TString* tsFile = new TString(fileName); | |
120 | TObjArray * tokens = tsFile->Tokenize("."); | |
121 | const char* runName = (((TObjString*) tokens->At(0))->GetString()).Data(); | |
122 | FILE* file = fopen(fileName, "r"); | |
123 | ||
124 | ||
125 | Float_t bdl = 0.; | |
126 | Float_t bdlc = 0.; | |
127 | Int_t iz = 0; | |
128 | Int_t izz = 0; | |
129 | Int_t iy = 0; | |
130 | Int_t ix = 0; | |
131 | Int_t iheader = 0; | |
132 | Float_t stepsz = 0.; | |
133 | // Graphs go here | |
134 | TMultiGraph* bxzmg = new TMultiGraph("bxzmg", "B_{x}"); | |
135 | TMultiGraph* byzmg = new TMultiGraph("byzmg", "B_{y}"); | |
136 | TMultiGraph* bzzmg = new TMultiGraph("bzzmg", "B_{z}"); | |
137 | while ((fgets(sLine, 255, file)) != NULL) { | |
138 | // read z-position | |
139 | ||
140 | if (strncmp(sLine," Current", 8) == 0) { | |
141 | Float_t current; | |
142 | iret = sscanf(&sLine[9],"%f", ¤t); | |
143 | printf("Current %f \n", current); | |
144 | ||
145 | fPolarity = current / 6000.; | |
146 | } | |
147 | if (strncmp(sLine," z", 2) == 0) { | |
148 | Float_t zmin, zmax; | |
149 | Int_t nsteps; | |
150 | iret = sscanf(&sLine[3],"%f %f %d", &zmin, &zmax, &nsteps); | |
151 | printf("zmin zmax %13.3f %13.3f %13.3f\n", | |
152 | zmin, zmax, TMath::Abs(zmax - zmin)/Float_t(nsteps)); | |
153 | zmax = TMath::Max(zmin, zmax); | |
154 | stepsz = TMath::Abs(zmax - zmin)/Float_t(nsteps); | |
155 | } | |
156 | ||
157 | if (strncmp(sLine," X position", 11) == 0) | |
158 | { | |
159 | TString string; | |
160 | TString* tsLine = new TString(sLine); | |
161 | TObjArray * tokens = tsLine->Tokenize("="); | |
162 | string = ((TObjString*) tokens->At(1))->GetString(); | |
163 | iret = sscanf(string.Data(), "%f", &xpos); | |
164 | string = ((TObjString*) tokens->At(2))->GetString(); | |
165 | iret = sscanf(string.Data(), "%f", &ypos); | |
166 | string = ((TObjString*) tokens->At(3))->GetString(); | |
167 | iret = sscanf(string.Data(), "%d", &iboxpos); | |
168 | ||
169 | ||
170 | printf("This file is for x = %13.3f y = %13.3f Box Position %1d\n", xpos, ypos, iboxpos); | |
171 | iheader++; | |
172 | ||
173 | } | |
174 | ||
175 | if (strncmp(sLine," R Z-pos",8) == 0) | |
176 | { | |
177 | iret = sscanf(&sLine[8],"%e", &zpos); | |
178 | ipos = 0; | |
179 | ic115 = 0; | |
180 | izz++; | |
181 | } | |
182 | ||
183 | ||
184 | if (strncmp(sLine,"C",1) == 0) { | |
185 | ipos++; | |
186 | Int_t ireg; | |
187 | iret = sscanf(&sLine[2],"%d %f %f %f %f %d", &ireg, &h[0], &h[1], &h[2], &temp, &ires); | |
188 | // | |
189 | // fix for address 115 | |
190 | // | |
191 | if (ireg == 115) ic115++; | |
192 | if (ic115 == 2 && ireg == 115) ireg = 119; | |
193 | ||
194 | if (iheader == 1) { | |
195 | ||
196 | Float_t bx = 0., by = 0., bz = 0.; | |
197 | Int_t jx = fRegMap[ireg][0]; | |
198 | Int_t jy = fRegMap[ireg][1]; | |
199 | Int_t jz = fRegMap[ireg][2]; | |
200 | ||
201 | switch (iboxpos) { | |
202 | case 0: | |
203 | bx = h[1]; | |
204 | by = h[2]; | |
205 | dx = -0.36 + jx * fDd; | |
206 | dy = jy * fDd; | |
207 | break; | |
208 | case 1: | |
209 | bx = -h[2]; | |
210 | by = h[1]; | |
211 | dx = 0.36 + jy * fDd; | |
212 | dy = -(-0.36 + jx * fDd); | |
213 | break; | |
214 | case 2: | |
215 | bx = -h[1]; | |
216 | by = -h[2]; | |
217 | dx = 0.36 - jx * fDd; | |
218 | dy = -jy * fDd; | |
219 | break; | |
220 | case 3: | |
221 | bx = h[2]; | |
222 | by = -h[1]; | |
223 | dx = -0.36 - jy * fDd; | |
224 | dy = -(0.36 - jx * fDd); | |
225 | break; | |
226 | } // switch | |
227 | ||
228 | bz = h[0]; | |
229 | if (jz == 0) { | |
230 | bz = -bz; | |
231 | if (iboxpos == 1 || iboxpos == 3) { | |
232 | by = -by; | |
233 | } else { | |
234 | bx = -bx; | |
235 | } | |
236 | } | |
237 | ||
238 | ||
239 | Float_t dz = (jz == 0)? fDz/2. : - fDz/2.; | |
240 | dz *= 100.; | |
241 | ||
242 | ||
243 | Float_t xc = xpos + dx; | |
244 | Float_t yc = ypos + dy; | |
245 | ||
246 | ||
247 | x[0] = - xc * 100.; | |
248 | x[1] = + yc * 100.; | |
249 | x[2] = - (-zpos * 100. + fZStart + dz); | |
250 | ||
251 | fField->Field(x, b); | |
252 | b[0] *= fPolarity; | |
253 | b[1] *= fPolarity; | |
254 | b[2] *= fPolarity; | |
255 | ||
256 | xnt[ 0] = xc; | |
257 | xnt[ 1] = yc; | |
258 | xnt[ 2] = -x[2] / 100.; | |
259 | xnt[ 3] = Float_t (jx); | |
260 | xnt[ 4] = Float_t (jy); | |
261 | xnt[ 5] = Float_t (jz); | |
262 | xnt[ 6] = bx; | |
263 | xnt[ 7] = by; | |
264 | xnt[ 8] = bz; | |
265 | xnt[ 9] = b[0]/10.; | |
266 | xnt[10] = b[1]/10.; | |
267 | xnt[11] = b[2]/10.; | |
268 | xnt[12] = Float_t (ifiles); | |
269 | xnt[13] = Float_t (ireg); | |
270 | xnt[14] = Float_t(iboxpos); | |
271 | xnt[15] = temp; | |
272 | xnt[16] = Float_t(ires); | |
273 | ||
274 | fMap->Fill(xnt); | |
275 | ||
276 | ||
277 | // | |
278 | // Calculated field | |
279 | ||
280 | if (jy != -1 && jz == 1 && jy == 0 && izz == 40){ | |
281 | x[1] = x[1] + 10.; | |
282 | fField->Field(x, b); | |
283 | yA [jx] = yc; | |
284 | bxyA[jx] = bx; | |
285 | byyA[jx] = by; | |
286 | bzyA[jx] = bz; | |
287 | bxycA[jx] = b[0] / 10.; | |
288 | byycA[jx] = b[1] / 10.; | |
289 | bzycA[jx] = b[2] / 10.; | |
290 | iy++; | |
291 | } // if | |
292 | ||
293 | if (jy != -1 && jz == 1 && jy == 0 && izz == 1){ | |
294 | x[1] = x[1] + 10.; | |
295 | fField->Field(x, b); | |
296 | xA [jx] = xc; | |
297 | bxxA[jx] = bx; | |
298 | byxA[jx] = by; | |
299 | bzxA[jx] = bz; | |
300 | bxxcA[jx] = b[0] / 10.; | |
301 | byxcA[jx] = b[1] / 10.; | |
302 | bzxcA[jx] = b[2] / 10.; | |
303 | ix++; | |
304 | } // if | |
305 | ||
306 | ||
307 | if (ireg == 181) { | |
308 | fField->Field(x, b); | |
309 | // printf("Field %f %f %f %f %f %f \n", x[0], x[1], x[2], b[0], b[1] , b[2]); | |
310 | ||
311 | bdl += stepsz * bx; | |
312 | bdlc += stepsz * b[0]; | |
313 | ||
314 | zA [iz] = x[2]; | |
315 | bxzA[iz] = bx; | |
316 | byzA[iz] = by; | |
317 | bzzA[iz] = bz; | |
318 | bxzcA[iz] = b[0] / 10.; | |
319 | byzcA[iz] = b[1] / 10.; | |
320 | bzzcA[iz] = b[2] / 10.; | |
321 | iz++; | |
322 | } | |
323 | } // if 1st header | |
324 | } // if C | |
325 | } // next line | |
326 | gStyle->SetOptStat(0); | |
327 | char title[128]; | |
328 | sprintf(title, "File#: %5d, X = %13.2f m , Y = %13.2f m, Box Orientation: %2d", ifiles, xpos, ypos, iboxpos); | |
329 | TCanvas* c2 = new TCanvas("c2", title, 1200, 800); | |
330 | c2->Divide(2,2); | |
331 | c2->cd(1); | |
332 | TGraph* bxg = new TGraph(iz, zA, bxzA); | |
333 | TGraph* bxcg = new TGraph(iz, zA, bxzcA); | |
334 | bxcg->SetLineColor(2); | |
335 | bxzmg->Add(bxg); | |
336 | bxzmg->Add(bxcg); | |
337 | bxzmg->Draw("lA"); | |
338 | bxzmg->GetHistogram()->SetXTitle("z[m]"); | |
339 | bxzmg->GetHistogram()->SetYTitle("B_{x} [T]"); | |
340 | bxzmg->Draw("lA"); | |
341 | ||
342 | c2->cd(2); | |
343 | TGraph* byg = new TGraph(iz, zA, byzA); | |
344 | TGraph* bycg = new TGraph(iz, zA, byzcA); | |
345 | bycg->SetLineColor(2); | |
346 | byzmg->Add(byg); | |
347 | byzmg->Add(bycg); | |
348 | byzmg->Draw("lA"); | |
349 | byzmg->GetHistogram()->SetXTitle("z[m]"); | |
350 | byzmg->GetHistogram()->SetYTitle("B_{y} [T]"); | |
351 | byzmg->Draw("lA"); | |
352 | ||
353 | c2->cd(3); | |
354 | TGraph* bzg = new TGraph(iz, zA, bzzA); | |
355 | TGraph* bzcg = new TGraph(iz, zA, bzzcA); | |
356 | bzcg->SetLineColor(2); | |
357 | bzzmg->Add(bzg); | |
358 | bzzmg->Add(bzcg); | |
359 | bzzmg->Draw("lA"); | |
360 | bzzmg->GetHistogram()->SetXTitle("z[m]"); | |
361 | bzzmg->GetHistogram()->SetYTitle("B_{z} [T]"); | |
362 | bzzmg->Draw("lA"); | |
363 | ||
364 | c2->Update(); | |
365 | char pictFile[64]; | |
366 | sprintf(pictFile, "%s.gif", runName); | |
367 | c2->SaveAs(pictFile); | |
368 | // | |
369 | // Html generation | |
370 | // | |
371 | char htmlFile[64]; | |
372 | sprintf(htmlFile, "%s.html", runName); | |
373 | FILE* chtml = fopen(htmlFile, "w"); | |
374 | MakeHtmlHeaderPict(chtml); | |
375 | MakeHtmlPict(chtml, pictFile); | |
376 | MakeHtmlTableEntry(fHtmlMain, fileName, htmlFile, xpos, ypos, iboxpos, bdl, ifiles); | |
377 | ||
378 | // | |
379 | // | |
380 | printf("Bdl [Tm] %f %f \n", 2. * bdl, 2 * bdlc / 10.); | |
381 | } // files | |
382 | MakeHtmlTrailor(fHtmlMain); | |
383 | TFile* out = new TFile("fmap.root", "recreate"); | |
384 | fMap->Write(); | |
385 | out->Close(); | |
386 | } | |
387 | ||
388 | void AliFieldReader::ReadMapSolenoid(){ | |
389 | Float_t phiA[450], bzPhiA[200], brPhiA[200], btPhiA[200], bbPhiA[200]; | |
390 | Float_t bzcPhiA[200], brcPhiA[200], btcPhiA[200], bbcPhiA[200]; | |
391 | Char_t sLine[255]; | |
392 | Char_t fLine[255]; | |
393 | ||
394 | Float_t zpos, phipos, skewing, temp; | |
395 | Int_t ical; | |
396 | Float_t zmin, zmax; | |
397 | Float_t h[3], x[3], b[3]; | |
398 | Int_t iret; | |
399 | Int_t ipos = 0; | |
400 | ||
401 | Init(); | |
402 | ReadRegisterMapSolenoid(); | |
403 | fMap = new TNtuple("Field Map", "Map", | |
404 | "r:phi:z:br:bt:bz:brc:btc:bzc:ifile:ireg:temp:cal:arm", 4000); | |
405 | ||
406 | // | |
407 | // Loop over files | |
408 | // | |
409 | Int_t ifiles = 0; | |
410 | // File catalogue | |
411 | while ((fgets(fLine, 255, fCatalogue)) != NULL && ifiles <= 2000) { | |
412 | ||
413 | if (strncmp(fLine,"#HEADER", 7) == 0) { | |
414 | iret = sscanf(&fLine[7],"%f", &fZStart); | |
415 | continue; | |
416 | } | |
417 | ifiles++; | |
418 | ||
419 | char fileName[32]; | |
420 | iret = sscanf(fLine, "%s", fileName); | |
421 | printf("Reading File %s\n", fileName); | |
422 | ||
423 | // Get run name | |
424 | TString* tsFile = new TString(fileName); | |
425 | TObjArray * tokens = tsFile->Tokenize("."); | |
426 | Int_t n = tokens->GetEntries(); | |
427 | char* runName = new char[256]; | |
428 | sprintf(runName, "%s", (((TObjString*) tokens->At(0))->GetString()).Data()); | |
429 | if (n > 2) { | |
430 | for (Int_t i = 1; i < n-1; i++) | |
431 | { | |
432 | sprintf(runName, "%s.%s", | |
433 | runName, (((TObjString*) tokens->At(i))->GetString()).Data()); | |
434 | } | |
435 | } | |
436 | FILE* file = fopen(fileName, "r"); | |
437 | ||
438 | ||
439 | Float_t bdl = 0.; | |
440 | Float_t bdlc = 0.; | |
441 | Int_t iA = 0; | |
442 | Int_t izz = 0; | |
443 | Int_t iphi = 0; | |
444 | // Graphs go here | |
445 | TMultiGraph* bxzmg = new TMultiGraph("bxzmg", "B_{z}"); | |
446 | TMultiGraph* byzmg = new TMultiGraph("byzmg", "B_{r}"); | |
447 | TMultiGraph* bzzmg = new TMultiGraph("bzzmg", "B_{t}"); | |
448 | TMultiGraph* bbmg = new TMultiGraph("bbmg", "|B|"); | |
449 | ||
450 | while ((fgets(sLine, 255, file)) != NULL) { | |
451 | if (strncmp(sLine," z", 2) == 0) { | |
452 | Int_t nsteps; | |
453 | iret = sscanf(&sLine[3],"%f %f %d", &zmin, &zmax, &nsteps); | |
454 | printf("zmin zmax %13.3f %13.3f %13.3f\n", | |
455 | zmin, zmax, TMath::Abs(zmax - zmin)/Float_t(nsteps)); | |
456 | } | |
457 | if (strncmp(sLine," R\tPOSITION NUMBER", 18) == 0) | |
458 | { | |
459 | // | |
460 | // Current z-position | |
461 | TString string; | |
462 | TString* tsLine = new TString(sLine); | |
463 | TObjArray * tokens = tsLine->Tokenize("="); | |
464 | string = ((TObjString*) tokens->At(1))->GetString(); | |
465 | iret = sscanf(string.Data(), "%f", &zpos); | |
466 | printf("POSITION NUMBER Z: %f\n", zpos); | |
467 | izz ++; | |
468 | delete tsLine; | |
469 | } | |
470 | ||
471 | ||
472 | if (strncmp(sLine," SKEWING ON Z:", 14) == 0) | |
473 | { | |
474 | // | |
475 | // Skew in z | |
476 | iret = sscanf(&sLine[14],"%f", &skewing); | |
477 | printf("SKEWING ON Z: %f\n", skewing); | |
478 | } | |
479 | ||
480 | ||
481 | if (strncmp(sLine,"Phi", 3) == 0) | |
482 | { | |
483 | Float_t phiStart, phiStop; | |
484 | ||
485 | iret = sscanf(&sLine[3],"%f %f", &phiStart, &phiStop); | |
486 | ||
487 | printf("phiStart phiStop %f %f\n", phiStart, phiStop); | |
488 | ||
489 | } | |
490 | ||
491 | ||
492 | if (strncmp(sLine," R\tPhi-Angle",12) == 0) | |
493 | { | |
494 | iret = sscanf(&sLine[12],"%e", &phipos); | |
495 | ipos = 0; | |
496 | iphi++; | |
497 | } | |
498 | ||
499 | ||
500 | if (strncmp(sLine,"C",1) == 0) { | |
501 | ||
502 | Int_t ireg; | |
503 | iret = sscanf(&sLine[2],"%d %f %f %f %f %d", &ireg, &h[0], &h[1], &h[2], &temp, &ical); | |
504 | ipos++; | |
505 | ||
506 | Int_t ir = fRegMap[ireg][0]; | |
507 | Int_t ia = fRegMap[ireg][1]; | |
508 | Float_t rpos = 0.; | |
509 | ||
510 | ||
511 | if (ia == 0) { | |
512 | rpos = 0.2295 + ir * 0.16; | |
513 | } else { | |
514 | if (ireg == 81) rpos = 0.2295; | |
515 | if (ireg == 59) rpos = 1.0295; | |
516 | if (ireg == 142) rpos = 2.1495; | |
517 | if (ireg == 180) rpos = 3.1095; | |
518 | if (ireg == 69) rpos = 4.2295; | |
519 | ||
520 | // if (ireg == 55) rpos = 0.2295; | |
521 | //if (ireg == 195) rpos = 1.0295; | |
522 | //if (ireg == 129) rpos = 2.1495; | |
523 | //if (ireg == 167) rpos = 3.1095; | |
524 | //if (ireg == 142) rpos = 4.2295; | |
525 | } | |
526 | ||
527 | Float_t phi = phipos; | |
528 | if (ia == 1) { | |
529 | phi += 180.; | |
530 | if (phi > 360.) phi -= 360.; | |
531 | } | |
532 | ||
533 | phi = - phi * TMath::Pi() / 180.; | |
534 | Float_t xpos = rpos * TMath::Cos(phi); | |
535 | Float_t ypos = rpos * TMath::Sin(phi); | |
536 | x[0] = - xpos * 100.; | |
537 | x[1] = ypos * 100.; | |
538 | x[2] = -400. + zpos * 100.; | |
539 | ||
540 | fField->Field(x, b); | |
541 | Float_t phi0 = TMath::Pi() - phi; | |
542 | ||
543 | Float_t brc = b[0] * TMath::Cos(phi0) + b[1] * TMath::Sin(phi0); | |
544 | Float_t btc = - b[0] * TMath::Sin(phi0) + b[1] * TMath::Cos(phi0); | |
545 | Float_t bzc = b[2]; | |
546 | ||
547 | brc /= 10.; | |
548 | btc /= 10.; | |
549 | bzc /= 10.; | |
550 | ||
551 | fMap->Fill(rpos, -phi, -(615.5 - fZStart) / 100. + zpos, h[2], -h[1], h[0], brc, btc, bzc, ifiles, ireg, temp, Float_t(ical), Int_t(ia)); | |
552 | ||
553 | if (ireg == 174) { | |
554 | printf("Field (Bx, By, Bz) at position %d: %13.3f %13.3f %13.3f %13.3f %13.3f %13.3f %5d\n", | |
555 | ipos, zpos, rpos, phipos, h[0], h[1], h[2], ia); | |
556 | if (izz == 1) { | |
557 | phiA[iA] = phi; | |
558 | bzPhiA[iA] = -h[0]; | |
559 | brPhiA[iA] = h[2]; | |
560 | btPhiA[iA] = -h[1]; | |
561 | bbPhiA[iA] = TMath::Sqrt(h[0] * h[0] + h[1] * h[1] + h[2] * h[2]); | |
562 | bzcPhiA[iA] = bzc; | |
563 | brcPhiA[iA] = brc; | |
564 | btcPhiA[iA] = btc; | |
565 | bbcPhiA[iA] = TMath::Sqrt(brc * brc + bzc * bzc + btc * btc); | |
566 | iA++; | |
567 | } | |
568 | } | |
569 | } // if R | |
570 | } // next line | |
571 | ||
572 | gStyle->SetOptStat(0); | |
573 | char title[128]; | |
574 | sprintf(title, "Z = %13.2f m , Phi = %13.2f m", zpos, phipos); | |
575 | ||
576 | ||
577 | TCanvas* c2 = new TCanvas("c2", title, 1200, 800); | |
578 | ||
579 | c2->Divide(2,2); | |
580 | c2->cd(1); | |
581 | TGraph* bzg = new TGraph(iA, phiA, bzPhiA); | |
582 | TGraph* bzcg = new TGraph(iA, phiA, bzcPhiA); | |
583 | bzcg->SetLineColor(2); | |
584 | bxzmg->Add(bzg); | |
585 | bxzmg->Add(bzcg); | |
586 | bxzmg->Draw("lA"); | |
587 | bxzmg->GetHistogram()->SetXTitle("#phi[rad]"); | |
588 | bxzmg->GetHistogram()->SetYTitle("B_{z} [T]"); | |
589 | bxzmg->Draw("lA"); | |
590 | ||
591 | c2->cd(2); | |
592 | TGraph* brg = new TGraph(iA, phiA, brPhiA); | |
593 | TGraph* brcg = new TGraph(iA, phiA, brcPhiA); | |
594 | brcg->SetLineColor(2); | |
595 | byzmg->Add(brcg); | |
596 | byzmg->Add(brg); | |
597 | ||
598 | byzmg->SetMaximum(0.03); | |
599 | byzmg->SetMinimum(-0.03); | |
600 | byzmg->Draw("lA"); | |
601 | byzmg->GetHistogram()->SetXTitle("#phi[rad]"); | |
602 | byzmg->GetHistogram()->SetYTitle("B_{r} [T]"); | |
603 | byzmg->Draw("lA"); | |
604 | ||
605 | c2->cd(3); | |
606 | TGraph* btg = new TGraph(iA, phiA, btPhiA); | |
607 | TGraph* btcg = new TGraph(iA, phiA, btcPhiA); | |
608 | btcg->SetLineColor(2); | |
609 | bzzmg->Add(btcg); | |
610 | bzzmg->Add(btg); | |
611 | bzzmg->Draw("lA"); | |
612 | bzzmg->SetMaximum(0.03); | |
613 | bzzmg->SetMinimum(-0.03); | |
614 | bzzmg->GetHistogram()->SetXTitle("#phi[rad]"); | |
615 | bzzmg->GetHistogram()->SetYTitle("B_{t} [T]"); | |
616 | bzzmg->Draw("lA"); | |
617 | ||
618 | ||
619 | c2->cd(4); | |
620 | TGraph* bg = new TGraph(iA, phiA, bbPhiA); | |
621 | TGraph* bcg = new TGraph(iA, phiA, bbcPhiA); | |
622 | bcg->SetLineColor(2); | |
623 | bbmg->Add(bg); | |
624 | bbmg->Add(bcg); | |
625 | bbmg->Draw("lA"); | |
626 | bbmg->GetHistogram()->SetXTitle("#phi[rad]"); | |
627 | bbmg->GetHistogram()->SetYTitle("|B| [T]"); | |
628 | bbmg->Draw("lA"); | |
629 | ||
630 | ||
631 | ||
632 | ||
633 | char pictFile[64]; | |
634 | sprintf(pictFile, "%s.gif", runName); | |
635 | c2->SaveAs(pictFile); | |
636 | ||
637 | // | |
638 | // Html generation | |
639 | // | |
640 | char htmlFile[64]; | |
641 | sprintf(htmlFile, "%s.html", runName); | |
642 | FILE* chtml = fopen(htmlFile, "w"); | |
643 | MakeHtmlHeaderPict(chtml); | |
644 | MakeHtmlPict(chtml, pictFile); | |
645 | MakeHtmlTableEntry(fHtmlMain, fileName, htmlFile, zmin, zmax, ifiles, 0., 0); | |
646 | ||
647 | // | |
648 | // | |
649 | printf("Bdl [Tm] %f %f \n", 2. * bdl, 2 * bdlc / 10.); | |
650 | } // files | |
651 | MakeHtmlTrailor(fHtmlMain); | |
652 | TFile* out = new TFile("fmap.root", "recreate"); | |
653 | fMap->Write(); | |
654 | out->Close(); | |
655 | } | |
656 | ||
657 | ||
658 | ||
659 | void AliFieldReader::MakeHtmlHeaderMain(FILE* file) | |
660 | { | |
661 | fprintf(file,"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | |
662 | fprintf(file, "<html>\n"); | |
663 | fprintf(file, "<head>\n"); | |
664 | fprintf(file, "<meta http-equiv=\"content-type\"\n"); | |
665 | fprintf(file, "content=\"text/html; charset=ISO-8859-1\"\n"); | |
666 | fprintf(file, "<title>main.html</title>\n"); | |
667 | fprintf(file, "<\\head>\n"); | |
668 | fprintf(file, "<body>\n"); | |
669 | fprintf(file, "<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\"\n"); | |
670 | fprintf(file, "style=\"text-align: left; width: 80;\">\n"); | |
671 | fprintf(file, "<tbody>\n"); | |
672 | fprintf(file, "<td style=\"vertical-align: top;\">File# <br></td>\n"); | |
673 | fprintf(file, "<td style=\"vertical-align: top;\">File Name <br></td>\n"); | |
674 | fprintf(file, "<td style=\"vertical-align: top;\">X-Position <br></td>\n"); | |
675 | fprintf(file, "<td style=\"vertical-align: top;\">Y-Position <br></td>\n"); | |
676 | fprintf(file, "<td style=\"vertical-align: top;\">Box Orientation <br></td>\n"); | |
677 | fprintf(file, "<td style=\"vertical-align: top;\">B.dl <br></td>\n"); | |
678 | fprintf(file, "<td style=\"vertical-align: top;\">Link to plots <br></td>\n"); | |
679 | ||
680 | } | |
681 | ||
682 | void AliFieldReader::MakeHtmlHeaderPict(FILE* file) | |
683 | { | |
684 | fprintf(file,"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); | |
685 | fprintf(file, "<html>\n"); | |
686 | fprintf(file, "<head>\n"); | |
687 | fprintf(file, "<meta http-equiv=\"content-type\"\n"); | |
688 | fprintf(file, "content=\"text/html; charset=ISO-8859-1\"\n"); | |
689 | fprintf(file, "<title>main.html</title>\n"); | |
690 | fprintf(file, "</head>\n"); | |
691 | fprintf(file, "<body>\n"); | |
692 | } | |
693 | ||
694 | void AliFieldReader:: MakeHtmlPict(FILE* chtml, char* pictFile) | |
695 | { | |
696 | fprintf(chtml, "<img src=\"./%s\" alt=\"%s\" style=\"width: 1196px; height: 772px;\">\n", | |
697 | pictFile, pictFile); | |
698 | ||
699 | fprintf(chtml, "<br> <br> <br>\n"); | |
700 | fprintf(chtml, "<a href=\"./bmap.html\">Back to main page</a><br>\n"); | |
701 | ||
702 | fprintf(chtml, "</body>\n"); | |
703 | fprintf(chtml, "</header>\n"); | |
704 | fclose(chtml); | |
705 | } | |
706 | ||
707 | void AliFieldReader::MakeHtmlTableEntry(FILE* htmlmain, char* fileName, char* htmlFile, Float_t x, Float_t y, Int_t i, Float_t bdl, Int_t ifile) | |
708 | { | |
709 | fprintf(htmlmain, "<tr>\n"); | |
710 | // | |
711 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%5d</td>\n", ifile); | |
712 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%s</td>\n", fileName); | |
713 | ||
714 | // | |
715 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%13.2f</td>\n",x); | |
716 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%13.2f</td>\n",y); | |
717 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%3d </td>\n",i); | |
718 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">%13.3f</td>\n",bdl); | |
719 | // | |
720 | fprintf(htmlmain, "<td style=\"vertical-align: top;\">\n"); | |
721 | fprintf(htmlmain, "<span style=\"text-decoration: underline;\"><a href=\"./%s\">gif</a></span></td>\n", htmlFile); | |
722 | fprintf(htmlmain, "</tr>\n"); | |
723 | } | |
724 | ||
725 | ||
726 | void AliFieldReader::MakeHtmlTrailor(FILE* htmlmain) | |
727 | { | |
728 | fprintf(htmlmain, "</tbody>\n"); | |
729 | fprintf(htmlmain, "</table>\n"); | |
730 | fprintf(htmlmain, "</body>\n"); | |
731 | fprintf(htmlmain, "</header>\n"); | |
732 | fclose(htmlmain); | |
733 | } | |
734 | ||
735 | void AliFieldReader::ReadRegisterMap() | |
736 | { | |
737 | FILE* regmap = fopen("register.map", "r"); | |
738 | Int_t ireg; | |
739 | for (ireg = 0; ireg < 200; ireg++) { | |
740 | fRegMap[ireg][0] = -1; | |
741 | fRegMap[ireg][1] = -1; | |
742 | fRegMap[ireg][2] = -1; | |
743 | } | |
744 | for (Int_t iz = 0; iz < 2; iz++) { | |
745 | for (Int_t iy = 2; iy >= 0; iy--) { | |
746 | for (Int_t ix = 0; ix < 10; ix++) { | |
747 | fscanf(regmap, "%d\n", &ireg); | |
748 | printf("Address %5d %5d %5d %5d \n", iz, iy, ix, ireg); | |
749 | fRegMap[ireg][1] = iy; | |
750 | fRegMap[ireg][2] = iz; | |
751 | if (iz == 1) { | |
752 | fRegMap[ireg][0] = ix; | |
753 | } else { | |
754 | fRegMap[ireg][0] = 9 - ix; | |
755 | } | |
756 | } // ix | |
757 | } // iy | |
758 | } // iz | |
759 | fclose(regmap); | |
760 | printf("-> ReadRegisterMap()\n\n"); | |
761 | } | |
762 | ||
763 | ||
764 | void AliFieldReader::ReadRegisterMapSolenoid() | |
765 | { | |
766 | FILE* regmap = fopen("register.map", "r"); | |
767 | Int_t ireg; | |
768 | ||
769 | // Initialize | |
770 | for (ireg = 0; ireg < 200; ireg++) { | |
771 | fRegMap[ireg][0] = -1; | |
772 | fRegMap[ireg][1] = -1; | |
773 | fRegMap[ireg][2] = -1; | |
774 | } | |
775 | ||
776 | // Main arm | |
777 | for (Int_t ir = 0; ir < 33; ir++) { | |
778 | fscanf(regmap, "%d\n", &ireg); | |
779 | fRegMap[ireg][0] = ir; | |
780 | fRegMap[ireg][1] = 0; | |
781 | } | |
782 | // Opposite arm | |
783 | for (Int_t ir = 0; ir < 5; ir++) { | |
784 | fscanf(regmap, "%d\n", &ireg); | |
785 | fRegMap[ireg][0] = ir; | |
786 | fRegMap[ireg][1] = 1; | |
787 | } | |
788 | ||
789 | fclose(regmap); | |
790 | ||
791 | } |