00001
00002 #include "bfemDisplay/EDControl.h"
00003 #include "bfemDisplay/DisplayCanvas.h"
00004
00005
00006
00007 #define kDrawTitle 1
00008 #define kSetRange 2
00009 #define kShowAxes 4
00010
00011
00012 extern EDControl *m_evtCtrl;
00013
00014
00015
00017
00018 ClassImp(DisplayCanvas)
00019
00020 DisplayCanvas::DisplayCanvas() {
00021
00022
00024
00028
00029 m_TowerHeight = 38.81;
00030 m_TowerWidth = 16.5;
00031
00032 frame_x = m_TowerWidth;
00033 frame_y = m_TowerWidth;
00034 frame_z = m_TowerHeight;
00035
00036 m_eventTextList = 0;
00037
00038
00039
00040
00041 fTree = 0;
00042 rTree = 0;
00043
00044 m_event = 0;
00045 m_recon = 0;
00046
00047
00048
00049 m_ped = m_evtCtrl->getCALPeds();
00050
00051 m_acdped = m_evtCtrl->getACDPeds();
00052
00053
00054
00055
00056
00057 m_canvas = m_evtCtrl->getCanvas();
00058
00059
00060
00061
00062 TBRIK* top = new TBRIK( "top", "top", "void", 0.001, 0.001, 0.001 );
00063
00064 TNode* m_topNode = new TNode( "topNode", "topNode", "top" );
00065
00066
00067
00068
00069
00070 TBRIK *frame = new TBRIK( "frame", "frame", "void", frame_x, frame_y, frame_z );
00071 frame->SetLineColor( 10 );
00072
00073 m_frameNode = new TNode( "frameNode", "frameNode", "frame" );
00074
00075
00076 TBRIK *tower = new TBRIK( "tower", "tower", "void", m_TowerWidth, m_TowerWidth, m_TowerHeight );
00077 tower->SetLineColor( 10 );
00078
00079 m_towerNode = new TNode( "towerNode", "towerNode", "tower" );
00080 m_towerNode->cd();
00081
00082
00083 m_Tkr = new TkrDisplay( m_towerNode );
00084
00085
00086 m_CAL = new CalDisplay( m_towerNode, m_ped );
00087
00088
00089 m_Acd = new AcdDisplay( m_towerNode, m_acdped );
00090
00091
00092
00093
00094 m_currentevent = 0;
00095
00096 m_scanForward = kTRUE;
00097
00098
00099 }
00100
00101
00102
00103
00105
00116 void DisplayCanvas::Draw( Bool_t dataType ) {
00117
00118
00119
00120
00121 fTree = m_evtCtrl->getRawTree();
00122 rTree = m_evtCtrl->getReconTree();
00123
00124 m_event = m_evtCtrl->getEvent();
00125 m_recon = m_evtCtrl->getRecon();
00126
00127 if ( m_event ) m_event->Clean();
00128
00129
00130 if ( fTree ) {
00131
00132 if ( ( m_currentevent < 0 ) || ( m_currentevent > m_evtCtrl->getEntries() ) ) return;
00133
00134 fTree->SetBranchStatus("*",0);
00135 fTree->SetBranchStatus("m_Acd*",1);
00136 fTree->SetBranchStatus("m_Xgt*",1);
00137 fTree->SetBranchStatus("m_Tkr*",1);
00138 fTree->SetBranchStatus("m_Cal*",1);
00139 fTree->SetBranchStatus("m_eventId", 1);
00140 fTree->SetBranchStatus("m_run", 1);
00141 fTree->GetEvent(m_currentevent);
00142
00143 }
00144
00145 if ( rTree ) {
00146 TBranch* TKR = rTree->GetBranch("m_tkr");
00147 TKR->GetEvent( m_currentevent );
00148 TBranch* CALrec = rTree->GetBranch("m_cal");
00149 CALrec->GetEvent( m_currentevent );
00150 }
00151
00152 m_canvas->Clear();
00153 setDrawingPads();
00154
00155
00156 if ( fTree ) {
00157 m_Tkr->DrawEvents( m_event, m_recon );
00158 m_CAL->DrawEvents( m_event, m_recon, dataType );
00159 m_Acd->DrawEvents( m_event );
00160 }
00161
00162
00163
00164
00165 addEnergyScale();
00166
00167
00169
00170
00171
00173
00174
00175
00176 if ( m_eventTextList ) m_eventTextList->Delete();
00177 m_eventTextList = new TObjArray();
00178
00179
00180
00181
00182 m_3DPad->cd();
00183
00184 m_Tkr->setVisibility( kHideNone );
00185 m_CAL->setVisibility( kHideNone );
00186
00187 m_towerNode->DrawClone();
00188
00189
00190
00191
00192 AnnotatePad( m_3DPad, "3D", kSetRange );
00193
00194
00195 DrawEventInfo( m_3DPad );
00196
00197
00198
00199
00200 m_zxpad->cd();
00201
00202 m_Tkr->setVisibility( kHideY );
00203 m_CAL->setVisibility( kHideY );
00204
00205 m_towerNode->DrawClone();
00206
00207 AnnotatePad( m_zxpad, "Z-X", kDrawTitle | kSetRange );
00208
00209
00210
00211 m_zypad->cd();
00212
00213 m_Tkr->setVisibility( kHideX );
00214 m_CAL->setVisibility( kHideX );
00215
00216 m_towerNode->DrawClone();
00217
00218 AnnotatePad( m_zypad, "Z-Y", kDrawTitle | kSetRange );
00219
00220
00221
00222 m_xyTopPad->cd();
00223
00224 m_Tkr->setVisibility( kHideAll );
00225 m_CAL->setVisibility( kHideAll );
00226
00227 m_towerNode->DrawClone();
00228
00229 AnnotatePad( m_xyTopPad, "X-Y", kDrawTitle | kSetRange );
00230
00231
00232
00233 m_yxTopPad->cd();
00234
00235 m_Tkr->setVisibility( kHideAll );
00236 m_CAL->setVisibility( kHideAll );
00237
00238 m_towerNode->Draw();
00239
00240 AnnotatePad( m_yxTopPad, "Y-X", kDrawTitle | kSetRange );
00241
00242
00243
00244
00245 printf("\nFinished displaying event %i\n",m_currentevent);
00246
00247
00248 if ( m_scanForward ) m_currentevent++;
00249
00250 else m_currentevent--;
00251
00252
00253
00254
00255 m_3DPad->cd();
00256
00257
00258
00259 m_canvas->Update();
00260
00261
00262 }
00263
00264
00265
00266
00267 void DisplayCanvas::setDrawingPads() {
00268
00269
00271
00272 m_infoPad = new TPad("mainpad","GLAST Display",0.0,0.95,1.0,1.0);
00273 m_infoPad->Draw();
00274
00275
00277
00278 m_3DPad = new TPad("3DPad","GLAST Display",0.0,0.0,0.33,0.95);
00279 m_3DPad->Draw();
00280 m_3DPad->SetTheta(10.0);
00281 m_3DPad->SetPhi(30.0);
00282
00283
00285
00286 m_zxpad = new TPad("zxpad","GLAST Display",0.33,0.0,0.66,0.64);
00287 m_zxpad->Draw();
00288 m_zxpad->SetTheta(0.);
00289 m_zxpad->SetPhi(0.);
00290
00291
00293
00294 m_zypad = new TPad("zypad","GLAST Display",0.66,0.0,1.0,0.64);
00295 m_zypad->Draw();
00296 m_zypad->SetPhi(-90.);
00297 m_zypad->SetTheta(0.);
00298
00299
00301
00302 m_xyTopPad = new TPad("xyTopPad","GLAST Display",0.33,0.64,0.66,0.95);
00303 m_xyTopPad->Draw();
00304 m_xyTopPad->SetTheta(90.);
00305 m_xyTopPad->SetPhi(0.);
00306
00307
00309
00310 m_yxTopPad = new TPad("yxTopPad","GLAST Display",0.66,0.64,1.0,0.95);
00311 m_yxTopPad->Draw();
00312 m_yxTopPad->SetTheta(90.);
00313 m_yxTopPad->SetPhi(-90.);
00314
00315 }
00316
00317
00318 void DisplayCanvas::AnnotatePad( TPad *pad, Char_t *title, UShort_t opt ) {
00319
00320
00321
00322 pad->cd();
00323
00324 TView *view;
00325 TPaveText *text;
00326
00327
00328 if ( opt & kDrawTitle ) {
00329
00330 Bool_t isTopView = !strcmp( title, "X-Y" ) || !strcmp( title, "Y-X" );
00331
00332 if ( isTopView ) text = new TPaveText( 0.80, 0.90, 0.95, 0.98, "NDC" );
00333 else text = new TPaveText( 0.80, 0.95, 0.95, 0.99, "NDC" );
00334
00335 text->SetFillColor( 42 );
00336
00337 text->AddText( title );
00338 text->SetAllWith( title, "Size", 0.07 );
00339
00340 text->Draw();
00341
00342 m_eventTextList->Add( text );
00343
00344 }
00345
00346 view = pad->GetView();
00347
00348 if ( opt & kSetRange ) {
00349
00350 if ( !strcmp( title, "3D" ) ) view->SetRange( -23.0, -23.0, -35.0, 23.0, 23.0, 55.0 );
00351 else view->SetRange( -23.0, -23.0, -20.0, 23.0, 23.0, 50.0 );
00352
00353 }
00354
00355 if ( opt & kShowAxes ) {
00356
00357 view->ShowAxis();
00358
00359 }
00360
00361 }
00362
00363
00364
00365
00366 void DisplayCanvas::DrawEventInfo( TPad *pad ) {
00367
00368 pad->cd();
00369
00370 Char_t evt_num[ 50 ];
00371
00372
00373
00374 if (m_CAL->m_Gammas) {
00375
00376 TPaveText *gammas = new TPaveText( 0., 0.12, 0.9, 0.15, "NDC" );
00377
00378 gammas->SetTextColor(2);
00379 gammas->SetBorderSize( 0 );
00380 gammas->SetTextSize(0.05);
00381
00382 sprintf( evt_num, "Gamma convertion!!!");
00383
00384 gammas->AddText( evt_num );
00385
00386 gammas->Draw();
00387
00388 m_eventTextList->Add( gammas );
00389
00390 }
00391
00392
00393
00394 Float_t eTot=0, eCorr=0, eLeak=0;
00395
00396 if ( rTree ) {
00397
00398 eTot = m_CAL->m_eTot;
00399 eCorr = m_CAL->m_eCorr;
00400 eLeak = m_CAL->m_eLeak;
00401
00402
00403
00404 TPaveText *ecal = new TPaveText( 0., 0., 0.9, 0.1, "NDC" );
00405
00406 ecal->SetFillColor( 0 );
00407 ecal->SetBorderSize( 0 );
00408 ecal->SetTextSize(0.05);
00409 ecal->SetTextAlign(12);
00410
00411 sprintf( evt_num, "CAL: Etot(GeV): %4.2f\n", eTot);
00412
00413 ecal->AddText( evt_num );
00414
00415 ecal->Draw();
00416
00417 sprintf( evt_num, " Ecorr(GeV): %4.2f\n", eCorr);
00418
00419 ecal->AddText( evt_num );
00420
00421 ecal->Draw();
00422
00423 sprintf( evt_num, " Eleak(GeV): %4.2f\n", eLeak);
00424
00425 ecal->AddText( evt_num );
00426
00427 ecal->Draw();
00428
00429 m_eventTextList->Add( ecal );
00430
00431 }
00432
00433
00434
00435 TPaveText *text = new TPaveText( 0.0, 0.95, 0.85, 0.98, "NDC" );
00436
00437 text->SetFillColor( 0 );
00438 text->SetBorderSize( 0 );
00439 text->SetTextSize(0.05);
00440 text->SetTextAlign(12);
00441
00442 Int_t runID;
00443 Int_t rawEventID;
00444
00445
00446 if ( m_event ) {
00447
00448 runID = m_event->getRunId();
00449 rawEventID = m_event->getEventId();
00450
00451 }
00452
00453 else { runID = 0; rawEventID = 0; }
00454
00455 sprintf( evt_num, " Event Id: %d -- Run. %d ", rawEventID, runID );
00456
00457 text->AddText( evt_num );
00458
00459 text->Draw();
00460
00461 m_eventTextList->Add( text );
00462
00463 }
00464
00465
00466 void DisplayCanvas::setThresholds( Float_t thresh[ 3 ][ 4 ] ) {
00467
00468 m_cal_lev[ 0 ] = thresh[ 0 ][ 0 ];
00469 m_cal_lev[ 1 ] = thresh[ 0 ][ 1 ];
00470 m_cal_lev[ 2 ] = thresh[ 0 ][ 2 ];
00471 m_cal_lev[ 3 ] = thresh[ 0 ][ 3 ];
00472
00473 m_CAL->setThresholds( m_cal_lev );
00474
00475 m_acd_lev[ 0 ] = thresh[ 1 ][ 0 ];
00476 m_acd_lev[ 1 ] = thresh[ 1 ][ 1 ];
00477 m_acd_lev[ 2 ] = thresh[ 1 ][ 2 ];
00478 m_acd_lev[ 3 ] = thresh[ 1 ][ 3 ];
00479
00480 m_xgt_lev[ 0 ] = thresh[ 2 ][ 0 ];
00481 m_xgt_lev[ 1 ] = thresh[ 2 ][ 1 ];
00482 m_xgt_lev[ 2 ] = thresh[ 2 ][ 2 ];
00483 m_xgt_lev[ 3 ] = thresh[ 2 ][ 3 ];
00484
00485 m_Acd->setThresholds( m_acd_lev, m_xgt_lev );
00486
00487 }
00488
00489
00491
00492 void DisplayCanvas::addEnergyScale(){
00493
00494
00495
00496 Int_t colors[ 4 ] = { 3, 4, 2 ,5 };
00497
00498 Float_t xOffset;
00499
00500 Float_t x[ 5 ];
00501 Float_t y[ 5 ];
00502
00503 y[ 0 ] = y[ 1 ] = y[ 4 ] = 0.3;
00504 y[ 2 ] = y[ 3 ] = 0.7;
00505
00506 m_infoPad->cd();
00507
00508 TPaveText *CALtext = new TPaveText( 0.6, 0.5, 0.69, 0.9, "NDC" );
00509 CALtext->SetTextSize(0.35);
00510 CALtext->SetFillColor( 0 );
00511 CALtext->SetBorderSize( 0 );
00512 CALtext->AddText( "XGT (MIP): " );
00513 CALtext->Draw();
00514
00515 TPaveText *CALtext1 = new TPaveText( 0.6, 0.1, 0.69, 0.5, "NDC" );
00516 CALtext1->SetTextSize(0.35);
00517 CALtext1->SetFillColor( 0 );
00518 CALtext1->SetBorderSize( 0 );
00519 CALtext1->SetTextAlign(32);
00520 CALtext1->AddText( "ACD (MIP) " );
00521 CALtext1->Draw();
00522
00523 Char_t text[ 10 ];
00524 Float_t mip;
00525
00526 for ( Int_t color=0; color<4; ++color ) {
00527
00528 xOffset = 0.7 + 0.065*color;
00529
00530 x[ 0 ] = x[ 3 ] = x[ 4 ] = xOffset;
00531 x[ 1 ] = x[ 2 ] = xOffset + 0.02;
00532
00533 TPolyLine *box = new TPolyLine( 5, x, y );
00534
00535 box->SetLineColor( colors[ color ] );
00536
00537 box->Draw();
00538
00539 TPaveText *CALtext3 = new TPaveText( xOffset+0.025, 0.5, xOffset+0.06, 0.9, "NDC" );
00540 CALtext3->SetTextSize(0.35);
00541 CALtext3->SetFillColor( 0 );
00542 CALtext3->SetBorderSize( 0 );
00543 sprintf( text, "%5.1f ", m_xgt_lev[ color ] );
00544 CALtext3->AddText( text );
00545 CALtext3->Draw();
00546 TPaveText *CALtext4 = new TPaveText( xOffset+0.025, 0.1, xOffset+0.06, 0.5, "NDC" );
00547 CALtext4->SetTextSize(0.35);
00548 CALtext4->SetFillColor( 0 );
00549 CALtext4->SetBorderSize( 0 );
00550 mip = m_acd_lev[ color ];
00551 sprintf( text, "%5.1f ", mip );
00552 CALtext4->AddText( text );
00553 CALtext4->Draw();
00554 }
00555
00556
00557
00558
00559 TPaveText *CALtext5 = new TPaveText( 0.0, 0.3, 0.1, 0.8, "NDC" );
00560 CALtext5->SetTextSize(0.35);
00561 CALtext5->SetFillColor( 0 );
00562 CALtext5->SetBorderSize( 0 );
00563 CALtext5->AddText( "CAL (MIP) " );
00564 CALtext5->Draw();
00565
00566
00567 for ( Int_t color=0; color<4; ++color ) {
00568
00569 xOffset = 0.1 + 0.065*color;
00570
00571 x[ 0 ] = x[ 3 ] = x[ 4 ] = xOffset;
00572 x[ 1 ] = x[ 2 ] = xOffset + 0.02;
00573
00574 TPolyLine *box = new TPolyLine( 5, x, y );
00575
00576 box->SetLineColor( colors[ color ] );
00577
00578 box->Draw();
00579
00580 TPaveText *CALtext4 = new TPaveText( xOffset+0.025, 0.3, xOffset+0.06, 0.8, "NDC" );
00581 CALtext4->SetTextSize(0.35);
00582 CALtext4->SetFillColor( 0 );
00583 CALtext4->SetBorderSize( 0 );
00584 mip = m_cal_lev[ color ];
00585 sprintf( text, "%5.1f ", mip );
00586 CALtext4->AddText( text );
00587 CALtext4->Draw();
00588
00589 }
00590
00591 }
00592
00594
00595 void DisplayCanvas::drawAxes(){
00596
00597
00598
00599 TBRIK* x_axis = new TBRIK("x_axis","x_axis","void",frame_x/2.0,m_axis_width,m_axis_width);
00600
00601 x_axis->SetLineColor(5);
00602
00603 TBRIK* y_axis = new TBRIK("y_axis","y_axis","void",m_axis_width,frame_y/2.0,m_axis_width);
00604
00605 y_axis->SetLineColor(6);
00606
00607 TBRIK* z_axis = new TBRIK("z_axis","z_axis","void",m_axis_width,m_axis_width,frame_z/2.0);
00608
00609 z_axis->SetLineColor(6);
00610
00611 }
00612
00613
00614
00616
00617 Char_t* DisplayCanvas::getText(TString color, Float_t energy){
00618
00619 Char_t lev[40];
00620
00621
00622
00623 m_TextLine = new TString(color);
00624
00625 m_TextLine->Append(" > ");
00626
00627 sprintf(lev,"%6.4f",energy);
00628
00629 m_TextLine->Append(lev);
00630
00631 m_TextLine->Append(" GeV");
00632
00633 return (Char_t*)m_TextLine->Data();
00634
00635
00636
00637 }
00638
00639
00640
00642
00643 Char_t* DisplayCanvas::getTextInt(TString str, Int_t number){
00644
00645 Char_t lev[40];
00646
00647
00648
00649 m_TextLine = new TString(str);
00650
00651 sprintf(lev,"%i",number);
00652
00653 m_TextLine->Append(lev);
00654
00655 return (Char_t*)m_TextLine->Data();
00656
00657
00658
00659 }
00660
00661
00662
00663
00664
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720