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);
106 fCanvas->SetFillColor(10);
109 fPad3D =
new TPad(
"Pad3D",
"Pad3D", 0.75, 0.75, 0.9, 0.9);
110 fPad3D->SetFillColor(TColor::GetColor(204,204,204));
111 fPad3D->SetFillColor(16);
115 fPadHeader =
new TPad(
"PadHeader",
"PadHeader", 0.0, 0.68, 1.0, 1.0);
119 TString fp = gEnv->GetValue(
"Root.TTFontPath",
"");
120 TString bc = fp +
"/BlackChancery.ttf";
121 TString ar = fp +
"/arial.ttf";
123 string besvisPath = getenv(
"BESVISLIBROOT");
124 TString filePath(besvisPath);
125 filePath +=
"/icons/";
127 fHeaderHImage = TImage::Open(filePath +
"HeaderH.gif");
128 fHeaderHImage->SetEditable(kTRUE);
130 fHeaderVImage = TImage::Open(filePath +
"HeaderV.gif");
131 fHeaderVImage->SetEditable(kTRUE);
133 fHeaderImage = TImage::Open(filePath +
"Header.gif");
134 fHeaderImage->DrawText(620, 15,
"BesVis", 30,
135 gROOT->GetColor(2)->AsHexString(),
136 bc, TImage::kShadeBelow);
137 fHeaderImage->SetConstRatio(
false);
138 fHeaderImage->Draw(
"same");
140 fBesHeader =
new BesHeader(0,0,1,1,
"br");
141 fBesHeader->SetTextSize(0.1);
142 fBesHeader->SetFillColor(28);
143 fBesHeader->SetFillStyle(0);
153 fDistanceOfRows=0.01;
159 Connect(fBesHeader,
"TransferMdcOn(Bool_t)",
"BesVisDisplay",
this,
"SetMdcOn(Bool_t)");
160 Connect(fBesHeader,
"TransferTofOn(Bool_t)",
"BesVisDisplay",
this,
"SetTofOn(Bool_t)");
161 Connect(fBesHeader,
"TransferEmcOn(Bool_t)",
"BesVisDisplay",
this,
"SetEmcOn(Bool_t)");
166 fPadXY =
new TPad(
"PadXY",
"PadXY", 0.0, 0.0, 0.5, 0.68);
170 fPadZR =
new TPad(
"PadZR",
"PadZR", 0.5, 0.0, 1.0, 0.68);
247 if (fDisplayMode == 0 || fDisplayMode == 4) {
248 fHeaderImage->Zoom(161, 649, 635, 174);
252 fHeaderImage->Zoom(600, 324, 164, 473);
263 fBesHeader->AddText(
"No Event Info");
267 Double_t coordx=fCoordx;
268 Double_t coordy=fCoordy;
290 sprintf(title1,
"Run %ld ", runno);
291 TText* ttitle1 = fBesHeader->AddText(coordx,coordy,title1);
292 ttitle1->SetTextSize(fTextSizeTitle);
293 ttitle1->SetTextColor(1);
294 ttitle1->SetTextAlign(12);
305 sprintf(title2,
"Event %ld ", eventno);
306 TText* ttitle2 = fBesHeader->AddText(coordx,coordy,title2);
307 ttitle2->SetTextSize(fTextSizeTitle);
308 ttitle2->SetTextColor(1);
309 ttitle2->SetTextAlign(12);
321 char titleEvTime[30];
323 double esTimeConst = 230;
326 sprintf(titleEvTime,
"Estime:0 ns");
328 TText* ttitleEvTime = fBesHeader->AddText(coordx,coordy,titleEvTime);
329 ttitleEvTime->SetTextSize(fTextSizeTime);
330 ttitleEvTime->SetTextFont(52);
331 ttitleEvTime->SetTextColor(1);
332 ttitleEvTime->SetTextAlign(12);
344 char titleEvTimeStat[30];
346 TText* ttitleEvTimeStat = fBesHeader->AddText(coordx,coordy,titleEvTimeStat);
347 ttitleEvTimeStat->SetTextSize(fTextSizeTime);
348 ttitleEvTimeStat->SetTextFont(52);
349 ttitleEvTimeStat->SetTextColor(1);
350 ttitleEvTimeStat->SetTextAlign(12);
362 char titleEvTimeQ[30];
364 TText* ttitleEvTimeQ = fBesHeader->AddText(coordx,coordy,titleEvTimeQ);
365 ttitleEvTimeQ->SetTextSize(fTextSizeTime);
366 ttitleEvTimeQ->SetTextFont(52);
367 ttitleEvTimeQ->SetTextColor(1);
368 ttitleEvTimeQ->SetTextAlign(12);
381 sprintf(date,
"date: %4d-%02d-%02d ", year,month,day);
382 TText* tdate = fBesHeader->AddText(coordx,coordy,date);
383 tdate->SetTextSize(fTextSizeTime);
384 tdate->SetTextFont(52);
385 tdate->SetTextColor(1);
386 tdate->SetTextAlign(12);
398 sprintf(
time,
"time: %02d:%02d:%02d", hour,
min,sec);
399 TText* ttime=fBesHeader->AddText(coordx,coordy,
time);
400 ttime->SetTextSize(fTextSizeTime);
401 ttime->SetTextFont(52);
402 ttime->SetTextColor(1);
403 ttime->SetTextAlign(12);
407 vector<TString> statusCon;
411 else sprintf(
data,
"MC=No");
412 statusCon.push_back(TString(
data));
418 sprintf(
data,
"Time Type: %d", timeType);
419 statusCon.push_back(TString(
data));
428 for (Int_t i = 0; i < (Int_t)statusCon.size(); i++) {
429 TText* ttitle=fBesHeader->AddText(coordx,coordy,statusCon[i].Data());
432 ttitle->SetTextSize(fTextSizeData);
433 ttitle->SetTextFont(62);
434 ttitle->SetTextColor(1);
435 ttitle->SetTextAlign(12);
437 vector<TString> infoCon;
439 vector<Int_t>::iterator pTrigVector;
440 for (pTrigVector = trigConditionVector.begin();
441 pTrigVector != trigConditionVector.end();
544 Float_t textSize = fTextSizeData;
559 pTrigVector = trigChannelVector.begin();
560 for (Int_t i = 0; i < (Int_t)infoCon.size(); i++) {
561 coordx = fCoordx + (i%npr)*(1.0/npr);
562 coordy = fCoordy - (i/npr)*rowH;
564 if (*pTrigVector == i){
565 TString temp = infoCon[i] +
" ON";
566 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
567 tdata->SetTextSize(textSize);
568 tdata->SetTextFont(62);
569 tdata->SetTextColor(2);
570 tdata->SetTextAlign(12);
574 TString temp = infoCon[i] +
" OFF";
575 TText* tdata=fBesHeader->AddText(coordx,coordy,temp.Data());
576 tdata->SetTextSize(textSize);
577 tdata->SetTextFont(62);
578 tdata->SetTextColor(1);
579 tdata->SetTextAlign(12);
585 fBesHeader->Draw(
"same");
587 fPadHeader->SetEditable(kFALSE);
588 fPadHeader->Modified();
589 fPadHeader->Update();
633 Double_t xlowH = -0.11, xupH = -0.1, ylowH = -0.11, yupH = -0.1;
634 Int_t width = fCanvas->GetWw();
635 Int_t height = fCanvas->GetWh();
636 Double_t hVSw = Double_t(height)/width;
637 Double_t x2D = 1.0-hVSw;
639 Double_t y2D = 0.5/hVSw;
640 Double_t x3D = (1.0/3)/hVSw;
642 switch ( fDisplayMode ) {
644 fPadHeader->SetPad(0.0, y2D, 1.0, 1.0);
645 fPadXY ->SetPad(0.0, 0.0, 0.5, y2D);
646 fPadZR ->SetPad(0.5, 0.0, 1.0, y2D);
647 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
650 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
651 fPadXY ->SetPad(x2D, 0.0, 1.0, 1.0);
652 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
653 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
656 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
657 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
658 fPadZR ->SetPad(x2D, 0.0, 1.0, 1.0);
659 fPad3D ->SetPad(xlowH, ylowH, xupH, yupH);
662 fPadHeader->SetPad(0.0, 0.0, x2D, 1.0);
663 fPadXY ->SetPad(xlowH, ylowH, xupH, yupH);
664 fPadZR ->SetPad(xlowH, ylowH, xupH, yupH);
665 fPad3D ->SetPad(x2D, 0.0, 1.0, 1.0);
669 fPadHeader->SetPad(0.0, 2*x3D, 1.0, 1.0);
670 fPadXY ->SetPad(0.0, x3D, 1.0/3, 2*x3D);
671 fPadZR ->SetPad(0.0, 0.0, 1.0/3, x3D);
672 fPad3D ->SetPad(1.0/3, 0.0, 1.0, 2*x3D);
681 switch ( fDisplayMode ) {
710 if (fDisplayMode == 0) {
711 if ((TPad*)gPad == fPadXY) fPadZR->cd();
715 if (fDisplayMode == 4) {
716 if ((TPad*)gPad == fPadXY) fPadZR->cd();
717 else if ((TPad*)gPad == fPadZR) fPad3D->cd();
731 if (trig) fEM1->SetFillColor(kGreen);
732 else fEM1->SetFillColor(kRed);
733 if (trig) fPH1->SetFillColor(kGreen);
734 else fPH1->SetFillColor(kRed);
735 if (trig) fEM2->SetFillColor(kGreen);
736 else fEM2->SetFillColor(kRed);
737 if (trig) fMU1->SetFillColor(kGreen);
738 else fMU1->SetFillColor(kRed);
739 if (trig) fMU2->SetFillColor(kGreen);
740 else fMU2->SetFillColor(kRed);
741 if (trig) fEMU->SetFillColor(kGreen);
742 else fEMU->SetFillColor(kRed);
743 if (trig) fJT1->SetFillColor(kGreen);
744 else fJT1->SetFillColor(kRed);
745 if (trig) fJT3->SetFillColor(kGreen);
746 else fJT3->SetFillColor(kRed);
747 if (trig) fJT4->SetFillColor(kGreen);
748 else fJT4->SetFillColor(kRed);
749 if (trig) fALL->SetFillColor(kGreen);
750 else fALL->SetFillColor(kRed);
751 fTrigPad->Modified();
762 if (gPad == fTrigPad) {
763 gPad->SetCursor(kCross);
767 const Int_t big = 9999;
769 Float_t xmin = gPad->GetX1();
770 Float_t xmax = gPad->GetX2();
771 Float_t dx = 0.05*(xmax - xmin);
772 Float_t
x = gPad->AbsPixeltoX(px);
773 if (x < xmin+dx || x > xmax-dx)
return dist;
833 cout <<
"Create 2D View " << endl;
852 cout <<
"enter BesVisDisplay::Draw3D()" << endl;
881 fDrawAllViews = kTRUE;
883 fPad->SetFillColor(15);
915 Float_t xmin = gPad->GetX1();
916 Float_t xmax = gPad->GetX2();
917 Float_t ymin = gPad->GetY1();
918 Float_t ymax = gPad->GetY2();
919 Float_t dx = xmax-xmin;
920 Float_t dy = ymax-ymin;
921 if (strlen(option) == 0) {
922 TPaveText *title =
new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
923 title->SetBit(kCanDelete);
924 title->SetFillColor(42);
929 sprintf(ptitle,
"Monte Carlo event");
930 title->AddText(ptitle);
934 TPaveLabel *label =
new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
935 label->SetBit(kCanDelete);
936 label->SetFillColor(42);
957 view->
SetRange(-0.5*fBesR, -0.5*fBesR, -0.5*fBesZ, 0.5*fBesR, 0.5*fBesR, 0.5*fBesZ);
962 fBesGeometry->
Draw(
"3D");
977 view->
SetView(phi, theta, 270, iret);
994 gPad->GetView()->SetRange(x0 - 0.5*zoomSize, y0 - 0.5*zoomSize, z0 - 0.5*zoomSize,
995 x0 + 0.5*zoomSize, y0 + 0.5*zoomSize, z0 + 0.5*zoomSize);
1003 TPad *pad = (TPad*)gPad->GetPadSave();
1005 TView *view = pad->GetView();
1015 TPad *pad = (TPad*)gPad->GetPadSave();
1017 TView *view = pad->GetView();
1026 TCanvas *rayCanvas =
new TCanvas(
"rayCanvas",
"Raytracer Canvas", 10, 10, 800, 800);
1033 gPad->SetFillColor(1);
1040 TView *view = gPad->GetView();
1043 view->ZoomView(gPad, 1.5);
1044 view->SetView(phi, theta, psi, iret);
1051 gGeoManager->GetGeomPainter()->SetRaytracing(kTRUE);
1053 rayCanvas->Modified();
1054 rayCanvas->Update();
1058 stringstream sPicCount;
1059 sPicCount << fRayPicCount <<
".gif";
1060 string str = sPicCount.str();
1062 gPad->SaveAs(str.c_str());
1068 TCanvas *x3dCanvas =
new TCanvas(
"x3dCanvas",
"X3dtracer Canvas", 10, 10, 800, 800);
1071 gPad->SetFillColor(1);
1085 gPad->GetViewer3D();
1102 stringstream sPicCount;
1104 sPicCount << fRayPicCount <<
".gif";
1105 string str = sPicCount.str();
1107 gPad->SaveAs(str.c_str());
1133 if (gPad->GetView()) {
1134 gPad->GetView()->ExecuteRotateView(event, px, py);
1186 if (fDrawAllViews) {
1202 fPTcutEGMUNU = ptcut;
1204 if (fDrawAllViews) {
1223 fDrawAllViews = kFALSE;
1228 TView *view = gPad->GetView();
1229 if (view) view->SetView(fPhi, fTheta, 0, iret);
1258 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};
1259 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};
1261 for (
int i = 0; i < 135; i++) {
1263 if (layer[i] > 35) fMdcROOTGeo->
GetPhysicalReplica(layer[i]+7, replica[i])->SetVisibility(1);
1264 std::cout << layer[i] <<
" " << replica[i] << std::endl;
1271 int part[7] = {1,1,1,2,2,1,1,};
1272 int scin[7] = {31,32,57,31,32,59,21};
1274 std::cout <<
"set tof fired cell" << std::endl;
1275 for (
int i = 0; i < 7; i++) {
1277 std::cout << part[i] <<
" " << scin[i] << std::endl;
1284 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};
1285 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};
1287 for (
int i = 0; i < 26; i++) {
1289 std::cout <<
"1" <<
" " << phi[i] <<
" " << theta[i] << std::endl;
1296 vector<int> cellCon;
1298 int part[11] = {1,1,1,1,1,1,1,1,1,1,1};
1299 int seg[11] = {6,6,2,2,2,2,2,2,2,2,2};
1300 int gap[11] = {0, 1, 0, 1, 2, 2, 3, 4, 5, 6, 7};
1301 int strip[11]= {2,20,20,29,21,22,27,25,25,30,22};
1303 for (
int i = 0; i < 11; i++) {
1304 fMucROOTGeo->
GetPhysicalStrip(part[i], seg[i], gap[i], strip[i])->SetVisibility(1);
1305 std::cout <<
" " << part[i] <<
" " << seg[i] <<
" " << gap[i] <<
" " << strip[i] << std::endl;
1312 const Int_t npoints = 2;
1313 gSize3D.numPoints += npoints;
1314 gSize3D.numSegs += (npoints-1);
1315 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)
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)
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 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 InitGeometryFromGDML(const TString fPath)
virtual void DrawTitle(Option_t *option="")
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;.