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