00001
00002
00004
00005
00006
00007
00008
00010
00011 #include <iostream>
00012 #include <sstream>
00013 #include <TROOT.h>
00014 #include <TEnv.h>
00015 #include <TButton.h>
00016 #include <TCanvas.h>
00017 #include <TPad.h>
00018 #include <TColor.h>
00019 #include <TAttImage.h>
00020 #include <TView.h>
00021 #include <TArc.h>
00022 #include <TText.h>
00023 #include <TPaveLabel.h>
00024 #include <TPaveText.h>
00025 #include <TList.h>
00026 #include <TDiamond.h>
00027 #include <TNode.h>
00028 #include <TTUBE.h>
00029 #include <TMath.h>
00030 #include <X3DBuffer.h>
00031 #include <TVirtualGeoPainter.h>
00032 #include <TControlBar.h>
00033 #include <TImage.h>
00034 #include <TASImage.h>
00035 #include <TGeoManager.h>
00036 #include <TGeoMaterial.h>
00037 #include <TGeoMedium.h>
00038 #include <TGeoVolume.h>
00039 #include <TGeoMatrix.h>
00040 #include <TGeoBBox.h>
00041 #include <TGeoTube.h>
00042 #include <TGeoArb8.h>
00043 #include <TViewerX3D.h>
00044
00045 #include "BesVisLib/BesPolygon2D.h"
00046 #include "BesVisLib/BesCircle2D.h"
00047 #include "BesVisLib/BesVisDisplay.h"
00048 #include "BesVisLib/BesEvent.h"
00049 #include "BesVisLib/BesTView.h"
00050
00051 BesVisDisplay *gDisplay = 0;
00052
00053 using namespace std;
00054
00055 #ifndef __CINT__
00056 ClassImp(BesVisDisplay)
00057 #endif
00058
00059
00060 BesVisDisplay::BesVisDisplay() : TQObject()
00061 {
00062
00063 }
00064
00065
00066 BesVisDisplay::BesVisDisplay(const char *title) : TQObject(),
00067 fBesGeometry(0),
00068 fMdcROOTGeo(0),
00069 fTofROOTGeo(0),
00070 fEmcROOTGeo(0),
00071 fMucROOTGeo(0),
00072 fMdcCon(0),
00073 fTofCon(0),
00074 fEmcCon(0),
00075 fMucCon(0),
00076 fAllVis(0),
00077 fQuarterVis(0),
00078 fHalfVis(0),
00079 fNoEndVis(0)
00080 {
00081
00082 }
00083
00084
00085 BesVisDisplay::~BesVisDisplay()
00086 {
00087
00088 }
00089
00090
00091 void BesVisDisplay::SetCanvas(TCanvas *c)
00092 {
00093 if (c != 0) {
00094 fCanvas = c;
00095 }
00096 else {
00097 fCanvas = new TCanvas("Canvas", " ",0,0,1024,768);
00098 }
00099 }
00100
00101 void BesVisDisplay::Init()
00102 {
00103 fDisplayMode = 0;
00104 fCanvas->cd();
00105
00106 fCanvas->SetFillColor(10);
00107
00108
00109 fPad3D = new TPad("Pad3D", "Pad3D", 0.75, 0.75, 0.9, 0.9);
00110 fPad3D->SetFillColor(TColor::GetColor(204,204,204));
00111 fPad3D->SetFillColor(16);
00112 fPad3D->Draw();
00113
00114
00115 fPadHeader = new TPad("PadHeader", "PadHeader", 0.0, 0.68, 1.0, 1.0);
00116 fPadHeader->Draw();
00117 fPadHeader->cd();
00118
00119 TString fp = gEnv->GetValue("Root.TTFontPath", "");
00120 TString bc = fp + "/BlackChancery.ttf";
00121 TString ar = fp + "/arial.ttf";
00122
00123 string besvisPath = getenv("BESVISLIBROOT");
00124 TString filePath(besvisPath);
00125 filePath += "/icons/";
00126
00127 fHeaderHImage = TImage::Open(filePath + "HeaderH.gif");
00128 fHeaderHImage->SetEditable(kTRUE);
00129
00130 fHeaderVImage = TImage::Open(filePath + "HeaderV.gif");
00131 fHeaderVImage->SetEditable(kTRUE);
00132
00133 fHeaderImage = TImage::Open(filePath + "Header.gif");
00134 fHeaderImage->DrawText(620, 15, "BesVis", 30,
00135 gROOT->GetColor(2)->AsHexString(),
00136 bc, TImage::kShadeBelow);
00137 fHeaderImage->SetConstRatio(false);
00138 fHeaderImage->Draw("same");
00139
00140 fBesHeader = new BesHeader(0,0,1,1, "br");
00141 fBesHeader->SetTextSize(0.1);
00142 fBesHeader->SetFillColor(28);
00143 fBesHeader->SetFillStyle(0);
00144 fBesHeader->SetBorderSize(4);
00145
00146 fLatticeWidth=0.185;
00147 fTextSizeTitle=0.08;
00148 fTextSizeTime=0.07;
00149 fTextSizeData=0.05;
00150 fTextSizeFlt=0.02;
00151 fCoordx=0.01;
00152 fCoordy=0.8;
00153 fDistanceOfRows=0.01;
00154
00155 fMdcOn = true;
00156 fTofOn = true;
00157 fEmcOn = true;
00158
00159 Connect(fBesHeader,"TransferMdcOn(Bool_t)","BesVisDisplay",this,"SetMdcOn(Bool_t)");
00160 Connect(fBesHeader,"TransferTofOn(Bool_t)","BesVisDisplay",this,"SetTofOn(Bool_t)");
00161 Connect(fBesHeader,"TransferEmcOn(Bool_t)","BesVisDisplay",this,"SetEmcOn(Bool_t)");
00162
00163 DrawHeader();
00164
00165
00166 fPadXY = new TPad("PadXY", "PadXY", 0.0, 0.0, 0.5, 0.68);
00167 fPadXY->Draw();
00168
00169
00170 fPadZR = new TPad("PadZR", "PadZR", 0.5, 0.0, 1.0, 0.68);
00171 fPadZR->Draw();
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 }
00184
00185
00186 void BesVisDisplay::Reset()
00187 {
00188 if (fPadXY) {
00189 fPadXY->cd();
00190 ((BesView*)fPadXY->GetView())->Reset();
00191 }
00192 if (fPadZR) {
00193 fPadZR->cd();
00194 ((BesView*)fPadZR->GetView())->Reset();
00195 }
00196 if (fPad3D) {
00197 fPad3D->cd();
00198 ((BesView*)fPad3D->GetView())->Reset();
00199 }
00200
00201 SwitchDisplayMode(fDisplayMode);
00202 }
00203
00204
00205
00206 void BesVisDisplay::InitGeometryFromGDML(const TString fPath)
00207 {
00208 if ( gBesGeometry ) delete gBesGeometry;
00209 fBesGeometry = new BesGeometry();
00210 gBesGeometry = fBesGeometry;
00211 fBesGeometry->InitFromGDML(fPath);
00212 fBesGeometry->SetDefaultVis();
00213
00214
00215 fMdcROOTGeo = fBesGeometry->GetMdcROOTGeo();
00216 fTofROOTGeo = fBesGeometry->GetTofROOTGeo();
00217 fEmcROOTGeo = fBesGeometry->GetEmcROOTGeo();
00218 fMucROOTGeo = fBesGeometry->GetMucROOTGeo();
00219 }
00220
00221
00222
00223 void BesVisDisplay::InitGeometryFromROOT(TGeoVolume *volBes)
00224 {
00225 if ( gBesGeometry ) delete gBesGeometry;
00226 fBesGeometry = new BesGeometry();
00227 gBesGeometry = fBesGeometry;
00228 fBesGeometry->InitFromROOT(volBes);
00229
00230
00231 fMdcROOTGeo = fBesGeometry->GetMdcROOTGeo();
00232 fTofROOTGeo = fBesGeometry->GetTofROOTGeo();
00233 fEmcROOTGeo = fBesGeometry->GetEmcROOTGeo();
00234 fMucROOTGeo = fBesGeometry->GetMucROOTGeo();
00235 }
00236
00237 void BesVisDisplay::DrawHeader()
00238 {
00239 fPadHeader->cd();
00240
00241
00242
00243
00244
00245
00246
00247 if (fDisplayMode == 0 || fDisplayMode == 4) {
00248 fHeaderImage->Zoom(161, 649, 635, 174);
00249
00250 }
00251 else {
00252 fHeaderImage->Zoom(600, 324, 164, 473);
00253
00254 }
00255
00256
00257
00258
00259 fBesHeader->Clear();
00260
00261
00262 if (!gEvent) {
00263 fBesHeader->AddText("No Event Info");
00264 }
00265 else {
00266
00267 Double_t coordx=fCoordx;
00268 Double_t coordy=fCoordy;
00269
00270
00271 Long64_t runno = gEvent->GetRun();
00272 Long64_t eventno = gEvent->GetEvent();
00273 Int_t year = gEvent->GetYear();
00274 Int_t month = gEvent->GetMonth();
00275 Int_t day = gEvent->GetDay();
00276 Int_t hour = gEvent->GetHour();
00277 Int_t min = gEvent->GetMin();
00278 Int_t sec = gEvent->GetSec();
00279
00280
00281 if (IsVHeader()) {
00282 coordx = 0.1;
00283 coordy = 0.90;
00284 }
00285 else {
00286 coordx = 0.02;
00287 coordy = 0.9;
00288 }
00289 char title1[20];
00290 sprintf(title1, "Run %ld ", runno);
00291 TText* ttitle1 = fBesHeader->AddText(coordx,coordy,title1);
00292 ttitle1->SetTextSize(fTextSizeTitle);
00293 ttitle1->SetTextColor(1);
00294 ttitle1->SetTextAlign(12);
00295
00296 if (IsVHeader()) {
00297 coordx = 0.1;
00298 coordy = 0.86;
00299 }
00300 else {
00301 coordx = 0.02;
00302 coordy = 0.82;
00303 }
00304 char title2[20];
00305 sprintf(title2, "Event %ld ", eventno);
00306 TText* ttitle2 = fBesHeader->AddText(coordx,coordy,title2);
00307 ttitle2->SetTextSize(fTextSizeTitle);
00308 ttitle2->SetTextColor(1);
00309 ttitle2->SetTextAlign(12);
00310
00311
00312 if (IsVHeader()) {
00313 coordx = 0.1;
00314 coordy = 0.83;
00315 }
00316 else {
00317 coordx = 0.02;
00318 coordy = 0.72;
00319 }
00320
00321 char titleEvTime[30];
00322 if(fabs(gEvent->GetHeader().GetEvTime())>0.0001){
00323 double esTimeConst = 230;
00324 sprintf(titleEvTime, "Estime:%5.1fns", gEvent->GetHeader().GetEvTime()-esTimeConst);
00325 }else{
00326 sprintf(titleEvTime, "Estime:0 ns");
00327 }
00328 TText* ttitleEvTime = fBesHeader->AddText(coordx,coordy,titleEvTime);
00329 ttitleEvTime->SetTextSize(fTextSizeTime);
00330 ttitleEvTime->SetTextFont(52);
00331 ttitleEvTime->SetTextColor(1);
00332 ttitleEvTime->SetTextAlign(12);
00333
00334
00335 if (IsVHeader()) {
00336 coordx = 0.1;
00337 coordy = 0.81;
00338 }
00339 else {
00340 coordx = 0.2;
00341 coordy = 0.72;
00342 }
00343
00344 char titleEvTimeStat[30];
00345 sprintf(titleEvTimeStat, " stat:%3d", gEvent->GetHeader().GetEvTimeStatus());
00346 TText* ttitleEvTimeStat = fBesHeader->AddText(coordx,coordy,titleEvTimeStat);
00347 ttitleEvTimeStat->SetTextSize(fTextSizeTime);
00348 ttitleEvTimeStat->SetTextFont(52);
00349 ttitleEvTimeStat->SetTextColor(1);
00350 ttitleEvTimeStat->SetTextAlign(12);
00351
00352
00353 if (IsVHeader()) {
00354 coordx = 0.1;
00355 coordy = 0.79;
00356 }
00357 else {
00358 coordx = 0.4;
00359 coordy = 0.72;
00360 }
00361
00362 char titleEvTimeQ[30];
00363 sprintf(titleEvTimeQ, " quality:%3.1f", gEvent->GetHeader().GetEvTimeQuality());
00364 TText* ttitleEvTimeQ = fBesHeader->AddText(coordx,coordy,titleEvTimeQ);
00365 ttitleEvTimeQ->SetTextSize(fTextSizeTime);
00366 ttitleEvTimeQ->SetTextFont(52);
00367 ttitleEvTimeQ->SetTextColor(1);
00368 ttitleEvTimeQ->SetTextAlign(12);
00369
00370
00371 if (IsVHeader()) {
00372 coordx = 0.1;
00373 coordy = 0.76;
00374 }
00375 else {
00376 coordx = 0.02;
00377 coordy = 0.60;
00378 }
00379
00380 char date[70];
00381 sprintf(date,"date: %4d-%02d-%02d ", year,month,day);
00382 TText* tdate = fBesHeader->AddText(coordx,coordy,date);
00383 tdate->SetTextSize(fTextSizeTime);
00384 tdate->SetTextFont(52);
00385 tdate->SetTextColor(1);
00386 tdate->SetTextAlign(12);
00387
00388
00389 if (IsVHeader()) {
00390 coordx = 0.1;
00391 coordy = 0.74;
00392 }
00393 else {
00394 coordx = 0.25;
00395 coordy = 0.60;
00396 }
00397 char time[70];
00398 sprintf(time,"time: %02d:%02d:%02d", hour,min,sec);
00399 TText* ttime=fBesHeader->AddText(coordx,coordy,time);
00400 ttime->SetTextSize(fTextSizeTime);
00401 ttime->SetTextFont(52);
00402 ttime->SetTextColor(1);
00403 ttime->SetTextAlign(12);
00404
00405
00406 TString info;
00407 vector<TString> statusCon;
00408
00409 char data[25];
00410 if (gEvent->GetMC()) sprintf(data, "MC=Yes");
00411 else sprintf(data, "MC=No");
00412 statusCon.push_back(TString(data));
00413
00414 vector<Int_t> trigChannelVector = gEvent->GetHeader().GetTrigChannelVector();
00415 vector<Int_t> trigConditionVector = gEvent->GetHeader().GetTrigConditionVector();
00416 Int_t timeType = gEvent->GetHeader().GetTimeType();
00417
00418 sprintf(data, "Time Type: %d", timeType);
00419 statusCon.push_back(TString(data));
00420 if (IsVHeader()) {
00421 coordx = 0.10;
00422 coordy = 0.71;
00423 }
00424 else {
00425 coordx = 0.02;
00426 coordy = 0.50;
00427 }
00428 for (Int_t i = 0; i < (Int_t)statusCon.size(); i++) {
00429 TText* ttitle=fBesHeader->AddText(coordx,coordy,statusCon[i].Data());
00430 if (IsVHeader()) coordy -= 0.02 ;
00431 else coordx += 0.2;
00432 ttitle->SetTextSize(fTextSizeData);
00433 ttitle->SetTextFont(62);
00434 ttitle->SetTextColor(1);
00435 ttitle->SetTextAlign(12);
00436 }
00437 vector<TString> infoCon;
00438
00439 vector<Int_t>::iterator pTrigVector;
00440 for (pTrigVector = trigConditionVector.begin();
00441 pTrigVector != trigConditionVector.end();
00442 pTrigVector++){
00443
00444 }
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00527
00542 Int_t npr;
00543 Float_t rowH;
00544 Float_t textSize = fTextSizeData;
00545 if (IsVHeader()) {
00546 fCoordx = 0.10;
00547 fCoordy = 0.70;
00548 npr = 1;
00549 rowH = 0.04;
00550 textSize *= 1.2;
00551 }
00552 else {
00553 fCoordx = 0.02;
00554 fCoordy = 0.50;
00555 npr = 4;
00556 rowH = 0.1;
00557 }
00558
00559 pTrigVector = trigChannelVector.begin();
00560 for (Int_t i = 0; i < (Int_t)infoCon.size(); i++) {
00561 coordx = fCoordx + (i%npr)*(1.0/npr);
00562 coordy = fCoordy - (i/npr)*rowH;
00563
00564 if (*pTrigVector == i){
00565 TString temp = infoCon[i] + " ON";
00566 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
00567 tdata->SetTextSize(textSize);
00568 tdata->SetTextFont(62);
00569 tdata->SetTextColor(2);
00570 tdata->SetTextAlign(12);
00571 pTrigVector++;
00572 }
00573 else {
00574 TString temp = infoCon[i] + " OFF";
00575 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
00576 tdata->SetTextSize(textSize);
00577 tdata->SetTextFont(62);
00578 tdata->SetTextColor(1);
00579 tdata->SetTextAlign(12);
00580 }
00581 }
00582
00583 }
00584
00585 fBesHeader->Draw("same");
00586
00587 fPadHeader->SetEditable(kFALSE);
00588 fPadHeader->Modified();
00589 fPadHeader->Update();
00590 fCanvas->cd();
00591 }
00592
00593
00594
00595 void BesVisDisplay::SetMdcOn(Bool_t MdcOn)
00596 {
00597 fMdcOn = MdcOn;
00598
00599 DrawHeader();
00600 }
00601
00602
00603
00604 void BesVisDisplay::SetTofOn(Bool_t TofOn)
00605 {
00606 fTofOn = TofOn;
00607
00608 DrawHeader();
00609 }
00610
00611
00612
00613 void BesVisDisplay::SetEmcOn(Bool_t EmcOn)
00614 {
00615 fEmcOn = EmcOn;
00616
00617 DrawHeader();
00618 }
00619
00620
00621
00622 void BesVisDisplay::SwitchDisplayMode(Int_t mode)
00623 {
00624 SetDisplayMode(mode);
00625 ResizePad();
00626 fCanvas->Update();
00627 }
00628
00629
00630 void BesVisDisplay::ResizePad()
00631 {
00632 fCanvas->cd();
00633 Double_t xlowH = -0.11, xupH = -0.1, ylowH = -0.11, yupH = -0.1;
00634 Int_t width = fCanvas->GetWw();
00635 Int_t height = fCanvas->GetWh();
00636 Double_t hVSw = Double_t(height)/width;
00637 Double_t x2D = 1.0-hVSw;
00638
00639 Double_t y2D = 0.5/hVSw;
00640 Double_t x3D = (1.0/3)/hVSw;
00641
00642 switch ( fDisplayMode ) {
00643 case 0 :
00644 fPadHeader->SetPad(0.0, y2D, 1.0, 1.0);
00645 fPadXY ->SetPad(0.0, 0.0, 0.5, y2D);
00646 fPadZR ->SetPad(0.5, 0.0, 1.0, y2D);
00647 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
00648 break;
00649 case 1 :
00650 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
00651 fPadXY ->SetPad(x2D, 0.0, 1.0, 1.0);
00652 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
00653 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
00654 break;
00655 case 2 :
00656 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
00657 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
00658 fPadZR ->SetPad(x2D, 0.0, 1.0, 1.0);
00659 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
00660 break;
00661 case 3 :
00662 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
00663 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
00664 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
00665 fPad3D ->SetPad(x2D, 0.0, 1.0, 1.0);
00666 break;
00667 case 4 :
00668
00669 fPadHeader->SetPad(0.0, 2*x3D, 1.0, 1.0);
00670 fPadXY ->SetPad(0.0, x3D, 1.0/3, 2*x3D);
00671 fPadZR ->SetPad(0.0, 0.0, 1.0/3, x3D);
00672 fPad3D ->SetPad(1.0/3, 0.0, 1.0, 2*x3D);
00673 break;
00674 default :
00675 return;
00676 }
00677
00678
00679 DrawHeader();
00680
00681 switch ( fDisplayMode ) {
00682 case 0 :
00683 fPadXY->cd();
00684 fPadXY->Update();
00685 fPadZR->Update();
00686 break;
00687 case 1 :
00688 fPadXY->cd();
00689 fPadXY->Update();
00690 break;
00691 case 2 :
00692 fPadZR->cd();
00693 fPadZR->Update();
00694 break;
00695 case 3 :
00696 fPad3D->cd();
00697 fPad3D->Update();
00698 break;
00699 case 4 :
00700 fPad3D->cd();
00701 fPad3D->Update();
00702 break;
00703 default :
00704 return;
00705 }
00706 }
00707
00708 void BesVisDisplay::SwitchPad()
00709 {
00710 if (fDisplayMode == 0) {
00711 if ((TPad*)gPad == fPadXY) fPadZR->cd();
00712 else fPadXY->cd();
00713 }
00714
00715 if (fDisplayMode == 4) {
00716 if ((TPad*)gPad == fPadXY) fPadZR->cd();
00717 else if ((TPad*)gPad == fPadZR) fPad3D->cd();
00718 else fPadXY->cd();
00719 }
00720
00721 fCanvas->Update();
00722 }
00723
00724
00725
00726 void BesVisDisplay::DisplayTrigger(Int_t trig)
00727 {
00728
00729 trig = 1;
00730
00731 if (trig) fEM1->SetFillColor(kGreen);
00732 else fEM1->SetFillColor(kRed);
00733 if (trig) fPH1->SetFillColor(kGreen);
00734 else fPH1->SetFillColor(kRed);
00735 if (trig) fEM2->SetFillColor(kGreen);
00736 else fEM2->SetFillColor(kRed);
00737 if (trig) fMU1->SetFillColor(kGreen);
00738 else fMU1->SetFillColor(kRed);
00739 if (trig) fMU2->SetFillColor(kGreen);
00740 else fMU2->SetFillColor(kRed);
00741 if (trig) fEMU->SetFillColor(kGreen);
00742 else fEMU->SetFillColor(kRed);
00743 if (trig) fJT1->SetFillColor(kGreen);
00744 else fJT1->SetFillColor(kRed);
00745 if (trig) fJT3->SetFillColor(kGreen);
00746 else fJT3->SetFillColor(kRed);
00747 if (trig) fJT4->SetFillColor(kGreen);
00748 else fJT4->SetFillColor(kRed);
00749 if (trig) fALL->SetFillColor(kGreen);
00750 else fALL->SetFillColor(kRed);
00751 fTrigPad->Modified();
00752 }
00753
00754
00755 Int_t BesVisDisplay::DistancetoPrimitive(Int_t px, Int_t py)
00756 {
00757
00758
00759 if (fBesHeader) return fBesHeader->DistancetoPrimitive(px, py)-10;
00760 else return 9999;
00761
00762 if (gPad == fTrigPad) {
00763 gPad->SetCursor(kCross);
00764 return 0;
00765 }
00766
00767 const Int_t big = 9999;
00768 Int_t dist = big;
00769 Float_t xmin = gPad->GetX1();
00770 Float_t xmax = gPad->GetX2();
00771 Float_t dx = 0.05*(xmax - xmin);
00772 Float_t x = gPad->AbsPixeltoX(px);
00773 if (x < xmin+dx || x > xmax-dx) return dist;
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 return 0;
00802 }
00803
00804
00805 void BesVisDisplay::Draw(Option_t *)
00806 {
00807
00808
00809
00810
00811
00812 Draw2D();
00813 Draw3D();
00814 SwitchDisplayMode(0);
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828 }
00829
00830
00831 void BesVisDisplay::Draw2D(Option_t *)
00832 {
00833 cout << "Create 2D View " << endl;
00834 fPadXY->cd();
00835 fPadXY->Clear();
00836 Draw2DXY();
00837 fPadXY->Update();
00838
00839 fPadZR->cd();
00840 fPadZR->Clear();
00841 Draw2DZR();
00842 fPadZR->Update();
00843
00844
00845
00846
00847 }
00848
00849
00850 void BesVisDisplay::Draw3D(Option_t *)
00851 {
00852 cout << "enter BesVisDisplay::Draw3D()" << endl;
00853
00854 fPad3D->cd();
00855 fPad3D->Clear();
00856
00857 f3DView = new BesView();
00858 f3DView->View3D();
00859 }
00860
00861
00862 void BesVisDisplay::Draw2DXY(Option_t *)
00863 {
00864 fxyView = new BesView();
00865 fxyView->ViewXY();
00866 }
00867
00868
00869
00870 void BesVisDisplay::Draw2DZR(Option_t *)
00871 {
00872 fzrView = new BesView();
00873 fzrView->ViewZR();
00874 }
00875
00876
00877 void BesVisDisplay::DrawAllViews()
00878 {
00879
00880
00881 fDrawAllViews = kTRUE;
00882 fPad->cd();
00883 fPad->SetFillColor(15);
00884 fPad->Clear();
00885 fPad->Divide(2,2);
00886
00887
00888 fPad->cd(1);
00889 DrawView(30, 30);
00890 DrawTitle();
00891
00892
00893 fPad->cd(2);
00894 DrawView(0, 180);
00895 DrawTitle("Front");
00896
00897
00898 fPad->cd(3);
00899 DrawView(90, 90);
00900 DrawTitle("Top");
00901
00902
00903 fPad->cd(4);
00904 DrawView(90, 0);
00905 DrawTitle("Side");
00906
00907 fPad->cd(2);
00908 }
00909
00910
00911 void BesVisDisplay::DrawTitle(Option_t *option)
00912 {
00913
00914
00915 Float_t xmin = gPad->GetX1();
00916 Float_t xmax = gPad->GetX2();
00917 Float_t ymin = gPad->GetY1();
00918 Float_t ymax = gPad->GetY2();
00919 Float_t dx = xmax-xmin;
00920 Float_t dy = ymax-ymin;
00921 if (strlen(option) == 0) {
00922 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
00923 title->SetBit(kCanDelete);
00924 title->SetFillColor(42);
00925 title->Draw();
00926 char ptitle[100];
00927
00928
00929 sprintf(ptitle,"Monte Carlo event");
00930 title->AddText(ptitle);
00931
00932
00933 } else {
00934 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
00935 label->SetBit(kCanDelete);
00936 label->SetFillColor(42);
00937 label->Draw();
00938 }
00939 }
00940
00941
00942 void BesVisDisplay::DrawView(Float_t theta, Float_t phi)
00943 {
00944
00945
00946
00947
00948 gPad->Clear();
00949
00950
00951
00952
00953
00954
00955 Int_t iret;
00956 BesTView *view = new BesTView(1);
00957 view->SetRange(-0.5*fBesR, -0.5*fBesR, -0.5*fBesZ, 0.5*fBesR, 0.5*fBesR, 0.5*fBesZ);
00958 view->ZoomView(gPad, 1.2);
00959
00960
00961
00962 fBesGeometry->Draw("3D");
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 view->SetView(phi, theta, 270, iret);
00978
00979 view->SetParallel();
00980
00981
00982
00983
00984
00985
00986 }
00987
00988
00989 void BesVisDisplay::DrawViewRange(Double_t x0, Double_t y0, Double_t z0,
00990 Double_t zoomSize)
00991 {
00992
00993
00994 gPad->GetView()->SetRange(x0 - 0.5*zoomSize, y0 - 0.5*zoomSize, z0 - 0.5*zoomSize,
00995 x0 + 0.5*zoomSize, y0 + 0.5*zoomSize, z0 + 0.5*zoomSize);
00996 }
00997
00998
00999 void BesVisDisplay::DrawViewGL()
01000 {
01001
01002
01003 TPad *pad = (TPad*)gPad->GetPadSave();
01004 pad->cd();
01005 TView *view = pad->GetView();
01006 if (!view) return;
01007 pad->x3d("OPENGL");
01008 }
01009
01010
01011 void BesVisDisplay::DrawViewX3D()
01012 {
01013
01014
01015 TPad *pad = (TPad*)gPad->GetPadSave();
01016 pad->cd();
01017 TView *view = pad->GetView();
01018 if (!view) return;
01019 pad->x3d();
01020 }
01021
01022
01023 void BesVisDisplay::DrawViewRaytracer(Float_t theta, Float_t phi, Float_t psi)
01024 {
01025
01026 TCanvas *rayCanvas = new TCanvas("rayCanvas", "Raytracer Canvas", 10, 10, 800, 800);
01027 rayCanvas->cd();
01028
01029
01030
01031
01032
01033 gPad->SetFillColor(1);
01034
01035
01036
01037
01038
01039
01040 TView *view = gPad->GetView();
01041
01042 int iret;
01043 view->ZoomView(gPad, 1.5);
01044 view->SetView(phi, theta, psi, iret);
01045
01046
01047
01048
01049
01050
01051 gGeoManager->GetGeomPainter()->SetRaytracing(kTRUE);
01052
01053 rayCanvas->Modified();
01054 rayCanvas->Update();
01055
01056
01057
01058 stringstream sPicCount;
01059 sPicCount << fRayPicCount << ".gif";
01060 string str = sPicCount.str();
01061
01062 gPad->SaveAs(str.c_str());
01063 fRayPicCount++;
01064 }
01065
01066 void BesVisDisplay::DrawViewX3D(char option)
01067 {
01068 TCanvas *x3dCanvas = new TCanvas("x3dCanvas", "X3dtracer Canvas", 10, 10, 800, 800);
01069 x3dCanvas->cd();
01070
01071 gPad->SetFillColor(1);
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085 gPad->GetViewer3D();
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102 stringstream sPicCount;
01103 fRayPicCount = 0;
01104 sPicCount << fRayPicCount << ".gif";
01105 string str = sPicCount.str();
01106
01107 gPad->SaveAs(str.c_str());
01108 fRayPicCount++;
01109 }
01110
01111 void BesVisDisplay::DrawImageSequence(Int_t thetaStart, Int_t thetaStep)
01112 {
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125 }
01126
01127
01128 void BesVisDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
01129 {
01130
01131
01132
01133 if (gPad->GetView()) {
01134 gPad->GetView()->ExecuteRotateView(event, px, py);
01135 }
01136 }
01137
01138
01139 void BesVisDisplay::GetEvent(Long64_t event)
01140 {
01141
01142
01143
01144
01145
01146
01147
01148 SetMdcFiredCell();
01149 SetTofFiredCell();
01150 SetEmcFiredCell();
01151 SetMucFiredCell();
01152 }
01153
01154
01155 void BesVisDisplay::Paint(Option_t *)
01156 {
01157
01158
01159 }
01160
01161
01162 void BesVisDisplay::PaintFruit(TObject *obj, Float_t eta, Float_t phi, Float_t pt, Int_t type, Option_t *option)
01163 {
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173 }
01174
01175
01176 void BesVisDisplay::PaintParticles(Option_t *option)
01177 {
01178
01179 }
01180
01181
01182 void BesVisDisplay::SetPTcut(Float_t ptcut)
01183 {
01184 fPTcut = ptcut;
01185
01186 if (fDrawAllViews) {
01187 fPad->cd(1);
01188 gPad->Modified();
01189 fPad->cd(2);
01190 gPad->Modified();
01191 fPad->cd(3);
01192 gPad->Modified();
01193 fPad->cd(4);
01194 gPad->Modified();
01195 fPad->cd();
01196 }
01197 }
01198
01199
01200 void BesVisDisplay::SetPTcutEGMUNU(Float_t ptcut)
01201 {
01202 fPTcutEGMUNU = ptcut;
01203
01204 if (fDrawAllViews) {
01205 fPad->cd(1);
01206 gPad->Modified();
01207 fPad->cd(2);
01208 gPad->Modified();
01209 fPad->cd(3);
01210 gPad->Modified();
01211 fPad->cd(4);
01212 gPad->Modified();
01213 fPad->cd();
01214 }
01215 }
01216
01217
01218 void BesVisDisplay::SetView(Float_t theta, Float_t phi)
01219 {
01220
01221
01222 fPad->cd();
01223 fDrawAllViews = kFALSE;
01224 fPhi = phi;
01225 fTheta = theta;
01226 Int_t iret;
01227
01228 TView *view = gPad->GetView();
01229 if (view) view->SetView(fPhi, fTheta, 0, iret);
01230 else Draw();
01231
01232 gPad->Modified();
01233 }
01234
01235
01236 void BesVisDisplay::ShowNextEvent(Int_t delta)
01237 {
01238
01239
01240
01241
01242
01243
01244 if (delta) {
01245
01246
01247
01248
01249
01250 }
01251 fPad->cd();
01252 Draw();
01253 }
01254
01255
01256 void BesVisDisplay::SetMdcFiredCell()
01257 {
01258 int layer[135] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10,11,12,13,14,15,16,17,18,19,19,20,21,22,22,23,24,25,26,27,28,29,29,30,31,32,33,34,35,36,37,38,39,40,41,41,42,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42};
01259 int replica[135] = {12 ,13 ,14 ,17 ,19 ,23 ,25 ,25 ,25 ,26 ,29 ,30 ,33 ,34 ,38 ,38 ,44 ,44 ,48 ,48 ,49 ,51 ,52 ,51 ,52 ,52 ,62 ,63 ,63 ,63 ,68 ,68 ,69 ,68 ,69 ,79 ,80 ,79 ,80 ,91 ,91 ,91 ,92 ,103,103,104,103,4 ,7 ,9 ,4 ,9 ,4 ,9 ,9 ,8 ,8 ,55 ,56 ,63 ,64 ,71 ,71 ,82 ,82 ,89 ,90 ,99 ,100,99 ,100,120,120,120,120,130,131,130,131,151,151,151,151,166,166,167,166,167,187,188,188,7 ,9 ,9 ,12 ,13 ,15 ,16 ,17 ,17 ,17 ,20 ,20 ,22 ,23 ,25 ,26 ,29 ,30 ,32 ,33 ,34 ,35 ,34 ,35 ,42 ,42 ,42 ,42 ,45 ,46 ,46 ,46 ,46 ,53 ,54 ,53 ,54 ,61 ,62 ,61 ,62 ,69 ,70 ,70};
01260
01261 for (int i = 0; i < 135; i++) {
01262 fMdcROOTGeo->GetPhysicalReplica(layer[i], replica[i])->SetVisibility(1);
01263 if (layer[i] > 35) fMdcROOTGeo->GetPhysicalReplica(layer[i]+7, replica[i])->SetVisibility(1);
01264 std::cout << layer[i] << " " << replica[i] << std::endl;
01265 }
01266 }
01267
01268
01269 void BesVisDisplay::SetTofFiredCell()
01270 {
01271 int part[7] = {1,1,1,2,2,1,1,};
01272 int scin[7] = {31,32,57,31,32,59,21};
01273
01274 std::cout << "set tof fired cell" << std::endl;
01275 for (int i = 0; i < 7; i++) {
01276 fTofROOTGeo->GetPhysicalScin(part[i], 0, scin[i])->SetVisibility(1);
01277 std::cout << part[i] << " " << scin[i] << std::endl;
01278 }
01279 }
01280
01281
01282 void BesVisDisplay::SetEmcFiredCell()
01283 {
01284 int theta[26] = {3,3,2,9,9,8,5,7,6,10,10,7,8,9,9,9,37,2,7,7,4,4,5,5,15,15};
01285 int phi[26] = {45,46,46,80,81,80,83,81,81,81,80,80,81,82,83,84,17,84,77,78,79,80,80,79,31,32};
01286
01287 for (int i = 0; i < 26; i++) {
01288 fEmcROOTGeo->GetPhysicalCrystal(1, phi[i], theta[i])->SetVisibility(1);
01289 std::cout << "1" << " " << phi[i] << " " << theta[i] << std::endl;
01290 }
01291 }
01292
01293
01294 void BesVisDisplay::SetMucFiredCell()
01295 {
01296 vector<int> cellCon;
01297
01298 int part[11] = {1,1,1,1,1,1,1,1,1,1,1};
01299 int seg[11] = {6,6,2,2,2,2,2,2,2,2,2};
01300 int gap[11] = {0, 1, 0, 1, 2, 2, 3, 4, 5, 6, 7};
01301 int strip[11]= {2,20,20,29,21,22,27,25,25,30,22};
01302
01303 for (int i = 0; i < 11; i++) {
01304 fMucROOTGeo->GetPhysicalStrip(part[i], seg[i], gap[i], strip[i])->SetVisibility(1);
01305 std::cout << " " << part[i] << " " << seg[i] << " " << gap[i] << " " << strip[i] << std::endl;
01306 }
01307 }
01308
01309
01310 void BesVisDisplay::SizeFruit() const
01311 {
01312 const Int_t npoints = 2;
01313 gSize3D.numPoints += npoints;
01314 gSize3D.numSegs += (npoints-1);
01315 gSize3D.numPolys += 0;
01316 }
01317
01318
01319 void BesVisDisplay::SizeParticles() const
01320 {
01321
01322
01323 }
01324
01325
01326
01327 void BesVisDisplay::Clear(Option_t *)
01328 {
01329
01330
01331 }
01332