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