00324 {
00325
00326 MsgStream msg( msgSvc(), name() );
00327 msg << MSG::DEBUG << "m_pIMF = " << m_pIMF << endreq;
00328
00329 double referfield = m_pIMF->getReferField()/tesla;
00330 msg << MSG::DEBUG << "The reference field is " << referfield << " tesla" <<endreq;
00331 bool ifrealfield = m_pIMF->ifRealField();
00332 if(ifrealfield) msg << MSG::DEBUG << "Use the real field"<<endreq;
00333 else msg << MSG::DEBUG << "Use the fake field"<<endreq;
00334
00335 HepVector3D B(0.0,0.0,0.0);
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 const int n1=241;
00363 double x[n1],y[n1],y1[n1],y2[n1],y3[n1],y4[n1];
00364
00365 const int n2=121;
00366 double x1[n2],bz1[n2],bz2[n2],bz3[n2],bz4[n2],bz5[n2],bz6[n2];
00367 double br1[n2],br2[n2],br3[n2],br4[n2],br5[n2],br6[n2];
00368 double bp1[n2],bp2[n2],bp3[n2],bp4[n2],bp5[n2],bp6[n2];
00369 double bphi1[n2],bphi2[n2],bphi3[n2],bphi4[n2],bphi5[n2],bphi6[n2];
00370
00371 const int n3=161;
00372 double x2[n3],bx1[n3],bx2[n3],bx3[n3],bx4[n3],bx5[n3],bx6[n3];
00373 double by1[n3],by2[n3],by3[n3],by4[n3],by5[n3],by6[n3];
00374
00375 const int n4=521;
00376 double globle_x[n4],globle_bz[n4];
00377 int i=0;
00378 double px,py,pz;
00379 HepPoint3D pos(px,py,pz);
00380 for( px = -2600; px <= 2600; px += 10 ) {
00381 pos[0] = px; pos[1] = 0; pos[2] = 0;
00382 m_pIMF->fieldVector( pos, B );
00383 globle_x[i]=px/m;
00384 globle_bz[i]=B.z()/tesla;
00385 i++;
00386 }
00387 i=0;
00388 for ( pz = m_zMin; pz <= m_zMax; pz += 10 ) {
00389 pos[0] = 0; pos[1] = 0; pos[2] = pz;
00390 m_pIMF->fieldVector( pos, B );
00391 x[i]=pz/m;
00392 y[i]=B.z()/tesla;
00393
00394 pos[0] = 200; pos[1] = 0; pos[2] = pz;
00395 m_pIMF->fieldVector( pos, B );
00396 y1[i]=B.z()/tesla;
00397
00398 pos[0] = 400; pos[1] = 0; pos[2] = pz;
00399 m_pIMF->fieldVector( pos, B );
00400 y2[i]=B.z()/tesla;
00401
00402 pos[0] = 600; pos[1] = 0; pos[2] = pz;
00403 m_pIMF->fieldVector( pos, B );
00404 y3[i]=B.z()/tesla;
00405
00406 pos[0] = 800; pos[1] = 0; pos[2] = pz;
00407 m_pIMF->fieldVector( pos, B );
00408 y4[i]=B.z()/tesla;
00409 i++;
00410 }
00411 int j = 0;
00412 double tbx,tby,tbz,tbr,tbp,tbphi;
00413 for ( pz = 0; pz <= m_zMax; pz += 10 ) {
00414 pos[0] = 50; pos[1] = 0; pos[2] = pz;
00415 m_pIMF->fieldVector( pos, B );
00416 x1[j]=pz/m;
00417 tbx=B.x()/tesla;
00418 tby=B.y()/tesla;
00419 tbz=B.z()/tesla;
00420 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00421 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00422 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00423 bz1[j] = tbz;
00424 br1[j] = tbr*10000;
00425 bp1[j] = tbp;
00426 bphi1[j] = tbphi*10000;
00427
00428 pos[0] = 100; pos[1] = 0; pos[2] = pz;
00429 m_pIMF->fieldVector( pos, B );
00430 tbx=B.x()/tesla;
00431 tby=B.y()/tesla;
00432 tbz=B.z()/tesla;
00433 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00434 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00435 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00436 bz2[j] = tbz;
00437 br2[j] = tbr*10000;
00438 bp2[j] = tbp;
00439 bphi2[j] = tbphi*10000;
00440
00441 pos[0] = 200; pos[1] = 0; pos[2] = pz;
00442 m_pIMF->fieldVector( pos, B );
00443 tbx=B.x()/tesla;
00444 tby=B.y()/tesla;
00445 tbz=B.z()/tesla;
00446 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00447 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00448 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00449 bz3[j] = tbz;
00450 br3[j] = tbr*10000;
00451 bp3[j] = tbp;
00452 bphi3[j] = tbphi*10000;
00453
00454 pos[0] = 400; pos[1] = 0; pos[2] = pz;
00455 m_pIMF->fieldVector( pos, B );
00456 tbx=B.x()/tesla;
00457 tby=B.y()/tesla;
00458 tbz=B.z()/tesla;
00459 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00460 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00461 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00462 bz4[j] = tbz;
00463 br4[j] = tbr*10000;
00464 bp4[j] = tbp;
00465 bphi4[j] = tbphi*10000;
00466
00467 pos[0] = 600; pos[1] = 0; pos[2] = pz;
00468 m_pIMF->fieldVector( pos, B );
00469 tbx=B.x()/tesla;
00470 tby=B.y()/tesla;
00471 tbz=B.z()/tesla;
00472 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00473 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00474 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00475 bz5[j] = tbz;
00476 br5[j] = tbr*10000;
00477 bp5[j] = tbp;
00478 bphi5[j] = tbphi*10000;
00479
00480 pos[0] = 800; pos[1] = 0; pos[2] = pz;
00481 m_pIMF->fieldVector( pos, B );
00482 tbx=B.x()/tesla;
00483 tby=B.y()/tesla;
00484 tbz=B.z()/tesla;
00485 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00486 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00487 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
00488 bz6[j] = tbz;
00489 br6[j] = tbr*10000;
00490 bp6[j] = tbp;
00491 bphi6[j] = tbphi*10000;
00492 j++;
00493 }
00494 int l = 0;
00495 for(py = m_yMin; py<= m_yMax; py +=10){
00496 pos[0] = 0; pos[1] = py; pos[2] = 0;
00497 m_pIMF->fieldVector( pos, B );
00498 tbx=B.x()/tesla*10000;
00499 tby=B.y()/tesla*10000;
00500 tbz=B.z()/tesla*10000;
00501 x2[l] = py/m;
00502 bx1[l] = tbx;
00503 by1[l] = tby;
00504
00505 pos[0] = 100; pos[1] = py; pos[2] = 100;
00506 m_pIMF->fieldVector( pos, B );
00507 tbx=B.x()/tesla*10000;
00508 tby=B.y()/tesla*10000;
00509 tbz=B.z()/tesla*10000;
00510 bx2[l] = tbx;
00511 by2[l] = tby;
00512
00513 pos[0] = 400; pos[1] = py; pos[2] = 400;
00514 m_pIMF->fieldVector( pos, B );
00515 tbx=B.x()/tesla*10000;
00516 tby=B.y()/tesla*10000;
00517 tbz=B.z()/tesla*10000;
00518 bx3[l] = tbx;
00519 by3[l] = tby;
00520 l++;
00521 }
00522
00523 TGraph2D *dt = new TGraph2D();
00524 int k = 0;
00525 for ( pz = -3000; pz <= 3000; pz += 50 ) {
00526 for( py = -2700; py <= 2700; py += 50){
00527 pos[0] = 0; pos[1] = py; pos[2] = pz;
00528 m_pIMF->fieldVector( pos, B );
00529 tbx=B.x()/tesla;
00530 tby=B.y()/tesla;
00531 tbz=B.z()/tesla;
00532 dt->SetPoint(k,pz/m,py/m,tbz);
00533 k++;
00534 }
00535 }
00536 TGraph2D *dt1 = new TGraph2D();
00537 k = 0;
00538 for ( pz = -3000; pz <= 3000; pz += 50 ) {
00539 for( py = -3000; py <= 3000; py += 50){
00540 pos[0] = 0; pos[1] = py; pos[2] = pz;
00541 m_pIMF->fieldVector( pos, B );
00542 tbx=B.x()/tesla;
00543 tby=B.y()/tesla;
00544 tbz=B.z()/tesla;
00545 double btot = sqrt(tbx*tbx+tby*tby+tbz*tbz);
00546 dt1->SetPoint(k,pz/m,py/m,btot);
00547 k++;
00548 }
00549 }
00550 TGraph2D *dt2 = new TGraph2D();
00551 k = 0;
00552 for ( pz = m_zMin; pz <= m_zMax; pz += 50 ) {
00553 for( py = m_yMin; py <= m_yMax; py += 50){
00554 pos[0] = 0; pos[1] = py; pos[2] = pz;
00555 m_pIMF->fieldVector( pos, B );
00556 tbx=B.x()/tesla;
00557 tby=B.y()/tesla;
00558 tbz=B.z()/tesla;
00559
00560 dt2->SetPoint(k,pz/m,py/m,tbz);
00561 k++;
00562 }
00563 }
00564 gStyle->SetPalette(1);
00565 gStyle->SetOptTitle(1);
00566 gStyle->SetOptStat(0);
00567
00568 TFile* f1=new TFile("graph.root","RECREATE");
00569 TGraph *gr1 = new TGraph(n1,x,y);
00570 TGraph *gr2 = new TGraph(n1,x,y1);
00571 TGraph *gr3 = new TGraph(n1,x,y2);
00572 TGraph *gr4 = new TGraph(n1,x,y3);
00573 TGraph *gr5 = new TGraph(n1,x,y4);
00574
00575 TGraph *g1 = new TGraph(n2,x1,bz1);
00576 TGraph *g2 = new TGraph(n2,x1,bz2);
00577 TGraph *g3 = new TGraph(n2,x1,bz3);
00578 TGraph *g4 = new TGraph(n2,x1,bz4);
00579 TGraph *g5 = new TGraph(n2,x1,bz5);
00580 TGraph *g6 = new TGraph(n2,x1,bz6);
00581
00582 TGraph *g7 = new TGraph(n2,x1,br1);
00583 TGraph *g8 = new TGraph(n2,x1,br2);
00584 TGraph *g9 = new TGraph(n2,x1,br3);
00585 TGraph *g10 = new TGraph(n2,x1,br4);
00586 TGraph *g11 = new TGraph(n2,x1,br5);
00587 TGraph *g12 = new TGraph(n2,x1,br6);
00588
00589 TGraph *g13 = new TGraph(n2,x1,bp1);
00590 TGraph *g14 = new TGraph(n2,x1,bp2);
00591 TGraph *g15 = new TGraph(n2,x1,bp3);
00592 TGraph *g16 = new TGraph(n2,x1,bp4);
00593 TGraph *g17 = new TGraph(n2,x1,bp5);
00594 TGraph *g18 = new TGraph(n2,x1,bp6);
00595
00596 TGraph *g19 = new TGraph(n2,x1,bphi1);
00597 TGraph *g20 = new TGraph(n2,x1,bphi2);
00598 TGraph *g21 = new TGraph(n2,x1,bphi3);
00599 TGraph *g22 = new TGraph(n2,x1,bphi4);
00600 TGraph *g23 = new TGraph(n2,x1,bphi5);
00601 TGraph *g24 = new TGraph(n2,x1,bphi6);
00602
00603 TGraph *g25 = new TGraph(n3,x2,bx1);
00604 TGraph *g26 = new TGraph(n3,x2,bx2);
00605 TGraph *g27 = new TGraph(n3,x2,bx3);
00606
00607 TGraph *g28 = new TGraph(n3,x2,by1);
00608 TGraph *g29 = new TGraph(n3,x2,by2);
00609 TGraph *g30 = new TGraph(n3,x2,by3);
00610
00611 TGraph *g31 = new TGraph(n4,globle_x,globle_bz);
00612
00613 TCanvas *c1 = new TCanvas("c1","Two Graphs",200,10,600,400);
00614 TCanvas *c2 = new TCanvas("c2","Two Graphs",200,10,600,400);
00615 c1->Divide(2,2);
00616 c2->Divide(2,2);
00617 c1->cd(1);
00618 gr1->SetLineColor(2);
00619 gr1->SetLineWidth(2);
00620 gr1->Draw("ALP");
00621 gr1->SetTitle("bz vs z (y=0,x=0,200,400,600,800mm)");
00622 gr1->GetXaxis()->SetTitle("m");
00623 gr1->GetYaxis()->SetTitle("tesla");
00624 gr2->SetLineWidth(2);
00625 gr2->SetLineColor(3);
00626 gr2->Draw("LP");
00627 gr3->SetLineWidth(2);
00628 gr3->SetLineColor(4);
00629 gr3->Draw("LP");
00630 gr4->SetLineWidth(2);
00631 gr4->SetLineColor(5);
00632 gr4->Draw("LP");
00633 gr5->SetLineWidth(2);
00634 gr5->SetLineColor(6);
00635 gr5->Draw("LP");
00636
00637 c1->cd(2);
00638 g1->SetLineColor(2);
00639 g1->SetLineWidth(2);
00640 g1->Draw("ALP");
00641 g1->SetTitle("bz(red),bendp vs z (y=0,x=50,100,200,400,600,800mm)");
00642 g1->GetXaxis()->SetTitle("m");
00643 g1->GetYaxis()->SetTitle("tesla");
00644 g1->GetYaxis()->SetRangeUser(0.2,2);
00645 g2->SetLineWidth(2);
00646 g2->SetLineColor(2);
00647 g2->Draw("LP");
00648 g3->SetLineWidth(2);
00649 g3->SetLineColor(2);
00650 g3->Draw("LP");
00651 g4->SetLineWidth(2);
00652 g4->SetLineColor(2);
00653 g4->Draw("LP");
00654 g5->SetLineWidth(2);
00655 g5->SetLineColor(2);
00656 g5->Draw("LP");
00657 g6->SetLineColor(2);
00658 g6->SetLineWidth(2);
00659 g6->Draw("LP");
00660
00661 g13->SetLineWidth(2);
00662 g13->SetLineColor(4);
00663 g13->Draw("LP");
00664 g14->SetLineWidth(2);
00665 g14->SetLineColor(4);
00666 g14->Draw("LP");
00667 g15->SetLineWidth(2);
00668 g15->SetLineColor(4);
00669 g15->Draw("LP");
00670 g16->SetLineWidth(2);
00671 g16->SetLineColor(4);
00672 g16->Draw("LP");
00673 g17->SetLineWidth(2);
00674 g17->SetLineColor(4);
00675 g17->Draw("LP");
00676 g18->SetLineWidth(2);
00677 g18->SetLineColor(4);
00678 g18->Draw("LP");
00679
00680 c1->cd(3);
00681 g7->SetLineWidth(2);
00682 g7->SetLineColor(2);
00683 g7->Draw("ALP");
00684 g7->SetTitle("br vs z (y=0,x=50,100,200,400,600,800mm)");
00685 g7->GetXaxis()->SetTitle("m");
00686 g7->GetYaxis()->SetTitle("gauss");
00687 g7->GetYaxis()->SetRangeUser(-1100,1000);
00688 g8->SetLineWidth(2);
00689 g8->SetLineColor(3);
00690 g8->Draw("LP");
00691 g9->SetLineWidth(2);
00692 g9->SetLineColor(4);
00693 g9->Draw("LP");
00694 g10->SetLineWidth(2);
00695 g10->SetLineColor(5);
00696 g10->Draw("LP");
00697 g11->SetLineWidth(2);
00698 g11->SetLineColor(6);
00699 g11->Draw("LP");
00700 g12->SetLineWidth(2);
00701 g12->SetLineColor(7);
00702 g12->Draw("LP");
00703
00704 c1->cd(4);
00705 g19->SetLineWidth(2);
00706 g19->SetLineColor(2);
00707 g19->Draw("ALP");
00708 g19->SetTitle("bphi vs z (y=0,x=50,100,200,400,600,800mm)");
00709 g19->GetXaxis()->SetTitle("m");
00710 g19->GetYaxis()->SetTitle("gauss");
00711 g19->GetYaxis()->SetRangeUser(-1000,200);
00712 g20->SetLineWidth(2);
00713 g20->SetLineColor(3);
00714 g20->Draw("LP");
00715 g21->SetLineWidth(2);
00716 g21->SetLineColor(4);
00717 g21->Draw("LP");
00718 g22->SetLineWidth(2);
00719 g22->SetLineColor(5);
00720 g22->Draw("LP");
00721 g23->SetLineWidth(2);
00722 g23->SetLineColor(6);
00723 g23->Draw("LP");
00724 g24->SetLineWidth(2);
00725 g24->SetLineColor(7);
00726 g24->Draw("LP");
00727
00728 TCanvas *c3 = new TCanvas("c3","Two Graphs",200,10,600,400);
00729 c3->cd(1);
00730
00731
00732
00733 dt->Draw("z sinusoidal");
00734 dt->SetTitle("bz vs y,z (x=0)");
00735
00736 TCanvas *c4 = new TCanvas("c4","Two Graphs",200,10,600,400);
00737 c4->cd(1);
00738 dt1->Draw("z sinusoidal");
00739 dt1->SetTitle("btot vs y,z (x=0)");
00740
00741 TCanvas *c5 = new TCanvas("c5","Two Graphs",200,10,600,400);
00742 c5->cd(1);
00743 dt2->Draw("z sinusoidal");
00744 dt2->SetTitle("bz vs y,z (x=0)");
00745
00746 c2->cd(2);
00747 g25->SetLineWidth(2);
00748 g25->SetLineColor(2);
00749 g25->Draw("ALP");
00750 g25->SetTitle("bx(red),by vs y (x,z=0,100,400mm)");
00751 g25->GetXaxis()->SetTitle("m");
00752 g25->GetYaxis()->SetTitle("gauss");
00753 g25->GetYaxis()->SetRangeUser(-200,300);
00754 g26->SetLineWidth(2);
00755 g26->SetLineColor(2);
00756 g26->Draw("LP");
00757 g27->SetLineWidth(2);
00758 g27->SetLineColor(2);
00759 g27->Draw("LP");
00760
00761 g28->SetLineWidth(2);
00762 g28->SetLineColor(3);
00763 g28->Draw("LP");
00764 g29->SetLineWidth(2);
00765 g29->SetLineColor(3);
00766 g29->Draw("LP");
00767 g30->SetLineWidth(2);
00768 g30->SetLineColor(3);
00769 g30->Draw("LP");
00770
00771 c2->cd(3);
00772 g31->SetLineWidth(2);
00773 g31->SetLineColor(2);
00774 g31->Draw("ALP");
00775 g31->SetTitle("bz vs x (y,z=0)");
00776 g31->GetXaxis()->SetTitle("m");
00777 g31->GetYaxis()->SetTitle("tesla");
00778
00779 c1->Write();
00780 c2->Write();
00781 c3->Write();
00782 c4->Write();
00783 c5->Write();
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805 return StatusCode::SUCCESS;
00806 }