23#include <TPaveLabel.h>
31#include <TVirtualGeoPainter.h>
32#include <TControlBar.h>
35#include <TGeoManager.h>
36#include <TGeoMaterial.h>
37#include <TGeoMedium.h>
38#include <TGeoVolume.h>
39#include <TGeoMatrix.h>
43#include <TViewerX3D.h>
45#include "BesVisLib/BesPolygon2D.h"
46#include "BesVisLib/BesCircle2D.h"
47#include "BesVisLib/BesVisDisplay.h"
48#include "BesVisLib/BesEvent.h"
49#include "BesVisLib/BesTView.h"
97 fCanvas =
new TCanvas(
"Canvas",
" ",0,0,1024,768);
108 fCanvas->SetFillColor(10);
111 fPad3D =
new TPad(
"Pad3D",
"Pad3D", 0.75, 0.75, 0.9, 0.9);
118 fPadHeader =
new TPad(
"PadHeader",
"PadHeader", 0.0, 0.68, 1.0, 1.0);
122 TString fp = gEnv->GetValue(
"Root.TTFontPath",
"");
123 TString bc = fp +
"/BlackChancery.ttf";
124 TString ar = fp +
"/arial.ttf";
126 string besvisPath = getenv(
"BESVISLIBROOT");
127 TString filePath(besvisPath);
128 filePath +=
"/icons/";
130 fHeaderHImage = TImage::Open(filePath +
"HeaderH.gif");
131 fHeaderHImage->SetEditable(kTRUE);
133 fHeaderVImage = TImage::Open(filePath +
"HeaderV.gif");
134 fHeaderVImage->SetEditable(kTRUE);
136 fHeaderImage = TImage::Open(filePath +
"Header.gif");
137 fHeaderImage->DrawText(620, 15,
"BesVis", 30,
138 gROOT->GetColor(2)->AsHexString(),
139 bc, TImage::kShadeBelow);
140 fHeaderImage->SetConstRatio(
false);
141 fHeaderImage->Draw(
"same");
143 fBesHeader =
new BesHeader(0,0,1,1,
"br");
144 fBesHeader->SetTextSize(0.1);
145 fBesHeader->SetFillColor(28);
146 fBesHeader->SetFillStyle(0);
156 fDistanceOfRows=0.01;
162 Connect(fBesHeader,
"TransferMdcOn(Bool_t)",
"BesVisDisplay",
this,
"SetMdcOn(Bool_t)");
163 Connect(fBesHeader,
"TransferTofOn(Bool_t)",
"BesVisDisplay",
this,
"SetTofOn(Bool_t)");
164 Connect(fBesHeader,
"TransferEmcOn(Bool_t)",
"BesVisDisplay",
this,
"SetEmcOn(Bool_t)");
169 fPadXY =
new TPad(
"PadXY",
"PadXY", 0.0, 0.0, 0.5, 0.68);
173 fPadZR =
new TPad(
"PadZR",
"PadZR", 0.5, 0.0, 1.0, 0.68);
195 if (view) view->
Reset();
200 if (view) view->
Reset();
205 if (view) view->
Reset();
279 fHeaderImage->Zoom(161, 649, 635, 174);
283 fHeaderImage->Zoom(600, 324, 164, 473);
294 fBesHeader->AddText(
"No Event Info");
298 Double_t coordx=fCoordx;
299 Double_t coordy=fCoordy;
321 sprintf(title1,
"Run %ld ", runno);
322 TText* ttitle1 = fBesHeader->AddText(coordx,coordy,title1);
323 ttitle1->SetTextSize(fTextSizeTitle);
324 ttitle1->SetTextColor(1);
325 ttitle1->SetTextAlign(12);
337 sprintf(title2,
"Event %ld ", eventno);
338 TText* ttitle2 = fBesHeader->AddText(coordx,coordy,title2);
339 ttitle2->SetTextSize(fTextSizeTitle);
340 ttitle2->SetTextColor(1);
341 ttitle2->SetTextAlign(12);
352 char titleEvTime[30];
359 double esTimeConst = 230;
362 else sprintf(titleEvTime,
"Estime:0 ns");
364 else sprintf(titleEvTime,
"Estime: -");
366 TText* ttitleEvTime = fBesHeader->AddText(coordx,coordy,titleEvTime);
367 ttitleEvTime->SetTextSize(fTextSizeTime);
368 ttitleEvTime->SetTextFont(52);
369 ttitleEvTime->SetTextColor(1);
370 ttitleEvTime->SetTextAlign(12);
381 char titleEvTimeStat[30];
388 else sprintf(titleEvTimeStat,
" stat: -");
390 TText* ttitleEvTimeStat = fBesHeader->AddText(coordx,coordy,titleEvTimeStat);
391 ttitleEvTimeStat->SetTextSize(fTextSizeTime);
392 ttitleEvTimeStat->SetTextFont(52);
393 ttitleEvTimeStat->SetTextColor(1);
394 ttitleEvTimeStat->SetTextAlign(12);
405 char titleEvTimeQ[30];
412 else sprintf(titleEvTimeQ,
" quality: -");
414 TText* ttitleEvTimeQ = fBesHeader->AddText(coordx,coordy,titleEvTimeQ);
415 ttitleEvTimeQ->SetTextSize(fTextSizeTime);
416 ttitleEvTimeQ->SetTextFont(52);
417 ttitleEvTimeQ->SetTextColor(1);
418 ttitleEvTimeQ->SetTextAlign(12);
430 sprintf(date,
"date: %4d-%02d-%02d ", year,month,day);
431 TText* tdate = fBesHeader->AddText(coordx,coordy,date);
432 tdate->SetTextSize(fTextSizeTime);
433 tdate->SetTextFont(52);
434 tdate->SetTextColor(1);
435 tdate->SetTextAlign(12);
448 TText* ttime=fBesHeader->AddText(coordx,coordy,
time);
449 ttime->SetTextSize(fTextSizeTime);
450 ttime->SetTextFont(52);
451 ttime->SetTextColor(1);
452 ttime->SetTextAlign(12);
456 vector<TString> statusCon;
461 statusCon.push_back(TString(
data));
468 statusCon.push_back(TString(
data));
477 for (Int_t i = 0; i < (Int_t)statusCon.size(); i++) {
478 TText* ttitle=fBesHeader->AddText(coordx,coordy,statusCon[i].Data());
481 ttitle->SetTextSize(fTextSizeData);
482 ttitle->SetTextFont(62);
483 ttitle->SetTextColor(1);
484 ttitle->SetTextAlign(12);
486 vector<TString> infoCon;
488 vector<Int_t>::iterator pTrigVector;
594 Float_t textSize = fTextSizeData;
609 pTrigVector = trigChannelVector.begin();
610 for (Int_t i = 0; i < (Int_t)infoCon.size(); i++) {
611 coordx = fCoordx + (i%npr)*(1.0/npr);
612 coordy = fCoordy - (i/npr)*rowH;
614 if (*pTrigVector == i){
615 TString temp = infoCon[i] +
" ON";
616 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
617 tdata->SetTextSize(textSize);
618 tdata->SetTextFont(62);
619 tdata->SetTextColor(2);
620 tdata->SetTextAlign(12);
624 TString temp = infoCon[i] +
" OFF";
625 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
626 tdata->SetTextSize(textSize);
627 tdata->SetTextFont(62);
628 tdata->SetTextColor(1);
629 tdata->SetTextAlign(12);
635 fBesHeader->Draw(
"same");
637 fPadHeader->SetEditable(kFALSE);
638 fPadHeader->Modified();
639 fPadHeader->Update();
683 Double_t xlowH = -0.11, xupH = -0.1, ylowH = -0.11, yupH = -0.1;
684 Int_t width = fCanvas->GetWw();
685 Int_t height = fCanvas->GetWh();
686 Double_t hVSw = Double_t(height)/width;
687 Double_t x2D = 1.0-hVSw;
689 Double_t y2D = 0.5/hVSw;
690 Double_t x3D = (1.0/3)/hVSw;
692 switch ( fDisplayMode ) {
694 fPadHeader->SetPad(0.0, y2D, 1.0, 1.0);
695 fPadXY ->SetPad(0.0, 0.0, 0.5, y2D);
696 fPadZR ->SetPad(0.5, 0.0, 1.0, y2D);
697 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
700 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
701 fPadXY ->SetPad(x2D, 0.0, 1.0, 1.0);
702 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
703 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
706 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
707 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
708 fPadZR ->SetPad(x2D, 0.0, 1.0, 1.0);
709 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
712 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
713 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
714 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
715 fPad3D ->SetPad(x2D, 0.0, 1.0, 1.0);
719 fPadHeader->SetPad(0.0, 2*x3D, 1.0, 1.0);
720 fPadXY ->SetPad(0.0, x3D, 1.0/3, 2*x3D);
721 fPadZR ->SetPad(0.0, 0.0, 1.0/3, x3D);
722 fPad3D ->SetPad(1.0/3, 0.0, 1.0, 2*x3D);
729 if (!fVisHeader) fPadHeader->SetPad(xlowH * 10, ylowH * 10, xupH * 10, yupH * 10);
734 switch ( fDisplayMode ) {
762 if (fDisplayMode == 0) {
763 if ((TPad*)gPad == fPadXY) fPadZR->cd();
767 if (fDisplayMode == 4) {
768 if ((TPad*)gPad == fPadXY) fPadZR->cd();
769 else if ((TPad*)gPad == fPadZR) fPad3D->cd();
783 if (trig) fEM1->SetFillColor(kGreen);
784 else fEM1->SetFillColor(kRed);
785 if (trig) fPH1->SetFillColor(kGreen);
786 else fPH1->SetFillColor(kRed);
787 if (trig) fEM2->SetFillColor(kGreen);
788 else fEM2->SetFillColor(kRed);
789 if (trig) fMU1->SetFillColor(kGreen);
790 else fMU1->SetFillColor(kRed);
791 if (trig) fMU2->SetFillColor(kGreen);
792 else fMU2->SetFillColor(kRed);
793 if (trig) fEMU->SetFillColor(kGreen);
794 else fEMU->SetFillColor(kRed);
795 if (trig) fJT1->SetFillColor(kGreen);
796 else fJT1->SetFillColor(kRed);
797 if (trig) fJT3->SetFillColor(kGreen);
798 else fJT3->SetFillColor(kRed);
799 if (trig) fJT4->SetFillColor(kGreen);
800 else fJT4->SetFillColor(kRed);
801 if (trig) fALL->SetFillColor(kGreen);
802 else fALL->SetFillColor(kRed);
803 fTrigPad->Modified();
814 if (gPad == fTrigPad) {
815 gPad->SetCursor(kCross);
819 const Int_t big = 9999;
821 Float_t xmin = gPad->GetX1();
822 Float_t xmax = gPad->GetX2();
823 Float_t dx = 0.05*(xmax - xmin);
824 Float_t
x = gPad->AbsPixeltoX(px);
825 if (x < xmin+dx || x > xmax-dx)
return dist;
885 cout <<
"Create 2D View " << endl;
904 cout <<
"enter BesVisDisplay::Draw3D()" << endl;
933 fDrawAllViews = kTRUE;
935 fPad->SetFillColor(15);
967 Float_t xmin = gPad->GetX1();
968 Float_t xmax = gPad->GetX2();
969 Float_t ymin = gPad->GetY1();
970 Float_t ymax = gPad->GetY2();
971 Float_t dx = xmax-xmin;
972 Float_t dy = ymax-ymin;
973 if (strlen(option) == 0) {
974 TPaveText *
title =
new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
975 title->SetBit(kCanDelete);
976 title->SetFillColor(42);
981 sprintf(ptitle,
"Monte Carlo event");
982 title->AddText(ptitle);
986 TPaveLabel *label =
new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
987 label->SetBit(kCanDelete);
988 label->SetFillColor(42);
1009 view->
SetRange(-0.5*fBesR, -0.5*fBesR, -0.5*fBesZ, 0.5*fBesR, 0.5*fBesR, 0.5*fBesZ);
1015 fBesGeometry->
Draw(
"3D");
1030 view->
SetView(phi, theta, 270, iret);
1047 gPad->GetView()->SetRange(x0 - 0.5*zoomSize, y0 - 0.5*zoomSize, z0 - 0.5*zoomSize,
1048 x0 + 0.5*zoomSize, y0 + 0.5*zoomSize, z0 + 0.5*zoomSize);
1056 TPad *pad = (TPad*)gPad->GetPadSave();
1058 TView *view = pad->GetView();
1068 TPad *pad = (TPad*)gPad->GetPadSave();
1070 TView *view = pad->GetView();
1079 TCanvas *rayCanvas =
new TCanvas(
"rayCanvas",
"Raytracer Canvas", 10, 10, 800, 800);
1086 gPad->SetFillColor(1);
1093 TView *view = gPad->GetView();
1096 view->ZoomView(gPad, 1.5);
1097 view->SetView(phi, theta, psi, iret);
1104 gGeoManager->GetGeomPainter()->SetRaytracing(kTRUE);
1106 rayCanvas->Modified();
1107 rayCanvas->Update();
1111 stringstream sPicCount;
1112 sPicCount << fRayPicCount <<
".gif";
1113 string str = sPicCount.str();
1115 gPad->SaveAs(str.c_str());
1121 TCanvas *x3dCanvas =
new TCanvas(
"x3dCanvas",
"X3dtracer Canvas", 10, 10, 800, 800);
1124 gPad->SetFillColor(1);
1138 gPad->GetViewer3D();
1155 stringstream sPicCount;
1157 sPicCount << fRayPicCount <<
".gif";
1158 string str = sPicCount.str();
1160 gPad->SaveAs(str.c_str());
1186 if (gPad->GetView()) {
1187 gPad->GetView()->ExecuteRotateView(event, px, py);
1239 if (fDrawAllViews) {
1255 fPTcutEGMUNU = ptcut;
1257 if (fDrawAllViews) {
1276 fDrawAllViews = kFALSE;
1281 TView *view = gPad->GetView();
1282 if (view) view->SetView(fPhi, fTheta, 0, iret);
1311 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};
1312 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};
1314 for (
int i = 0; i < 135; i++) {
1316 if (layer[i] > 35) fMdcROOTGeo->
GetPhysicalReplica(layer[i]+7, replica[i])->SetVisibility(1);
1317 std::cout << layer[i] <<
" " << replica[i] << std::endl;
1324 int part[7] = {1,1,1,2,2,1,1,};
1325 int scin[7] = {31,32,57,31,32,59,21};
1327 std::cout <<
"set tof fired cell" << std::endl;
1328 for (
int i = 0; i < 7; i++) {
1330 std::cout << part[i] <<
" " << scin[i] << std::endl;
1337 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};
1338 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};
1340 for (
int i = 0; i < 26; i++) {
1342 std::cout <<
"1" <<
" " << phi[i] <<
" " << theta[i] << std::endl;
1349 vector<int> cellCon;
1351 int part[11] = {1,1,1,1,1,1,1,1,1,1,1};
1352 int seg[11] = {6,6,2,2,2,2,2,2,2,2,2};
1353 int gap[11] = {0, 1, 0, 1, 2, 2, 3, 4, 5, 6, 7};
1354 int strip[11]= {2,20,20,29,21,22,27,25,25,30,22};
1356 for (
int i = 0; i < 11; i++) {
1357 fMucROOTGeo->
GetPhysicalStrip(part[i], seg[i], gap[i], strip[i])->SetVisibility(1);
1358 std::cout <<
" " << part[i] <<
" " << seg[i] <<
" " << gap[i] <<
" " << strip[i] << std::endl;
1365 const Int_t npoints = 2;
1366 gSize3D.numPoints += npoints;
1367 gSize3D.numSegs += (npoints-1);
1368 gSize3D.numPolys += 0;
ClassImp(BesVisDisplay) BesVisDisplay
R__EXTERN BesEvent * gEvent
R__EXTERN BesGeometry * gBesGeometry
BesEventHeader GetHeader()
virtual void SetDefaultVis()
EmcROOTGeo * GetEmcROOTGeo()
virtual void InitFromGDML(const TString fPath, bool mrpc=false, bool cgem=false)
MdcROOTGeo * GetMdcROOTGeo()
virtual void Draw(Option_t *option="3D")
virtual void InitFromROOT(TGeoVolume *volBes)
MucROOTGeo * GetMucROOTGeo()
TofROOTGeo * GetTofROOTGeo()
virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor=1.25)
virtual void SetRange(const Double_t *min, const Double_t *max)
static void AdjustPad(TVirtualPad *pad=0)
virtual void SetParallel()
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
virtual void SizeFruit() const
virtual void DrawViewRaytracer(Float_t theta, Float_t phi, Float_t psi)
void Draw3D(Option_t *option="")
virtual void SetMdcOn(Bool_t MdcOn)
virtual void PaintParticles(Option_t *option="")
virtual void SetTofOn(Bool_t TofOn)
virtual void SetPTcut(Float_t ptcut=0.4)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
void Draw2DZR(Option_t *option="")
void SetDisplayMode(Int_t mode)
virtual void SizeParticles() const
virtual void DrawViewGL()
virtual void DrawView(Float_t theta, Float_t phi)
void DrawImageSequence(Int_t thetaStart, Int_t thetaStep)
virtual void SetPTcutEGMUNU(Float_t ptcut=5)
virtual void InitGeometryFromGDML(const TString fPath, bool mrpc=false, bool cgem=false)
virtual void Clear(Option_t *option="")
virtual void DrawHeader()
virtual void Draw(Option_t *option="")
virtual void InitGeometryFromROOT(TGeoVolume *bes)
virtual void Paint(Option_t *option="")
virtual void ShowNextEvent(Int_t delta=1)
virtual void DrawViewX3D()
virtual void DrawTitle(Option_t *option="")
virtual void SetVisHeader(Bool_t val)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual void SwitchDisplayMode(Int_t mode)
virtual void SetCanvas(TCanvas *c=0)
virtual void SetView(Float_t theta, Float_t phi)
virtual void DrawAllViews()
void DrawViewRange(Double_t x0, Double_t y0, Double_t z0, Double_t zoomSize)
virtual void SetEmcOn(Bool_t EmcOn)
virtual void GetEvent(Long64_t event)
void Draw2D(Option_t *option="")
virtual void DisplayTrigger(Int_t trig)
virtual void PaintFruit(TObject *obj, Float_t eta, Float_t phi, Float_t pt, Int_t type, Option_t *option="")
void Draw2DXY(Option_t *option="")
TGeoPhysicalNode * GetPhysicalCrystal(int part, int phi, int theta)
Get crystal physical node;.
TGeoPhysicalNode * GetPhysicalReplica(int layer, int replica)
Get replica physical node;.
TGeoPhysicalNode * GetPhysicalStrip(int part, int seg, int gap, int strip)
Get strip physical node;.
TGeoPhysicalNode * GetPhysicalScin(int part, int scin)
Get scintillator physical node;.
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)