00001 #include <gui/EventDisplay.hh>
00002 #include <string>
00003
00004
00005 #include "root/CaloRun.hh"
00006 #include "root/CaloEvent.hh"
00007 #include "root/CaloHit.hh"
00008 #include "root/MTEvent.hh"
00009 #include "root/MTChannel.hh"
00010 #include "xml/XMLTool.hh"
00011 #include "Chamber.hh"
00012 #include "Detector.hh"
00013 #include "DiracChamber1.hh"
00014 #include "GassiplexChamber1.hh"
00015 #include "GassiplexChamber4.hh"
00016 #include "Hardroc1Chamber.hh"
00017 #include "MicroException.hh"
00018 #include "Log.hh"
00019 #include "Toolbox.hh"
00020
00021
00022 #include <TGResourcePool.h>
00023 #include <TView.h>
00024 #include <TGSlider.h>
00025
00026
00027 #include "TGFileDialog.h"
00028 #include <TGClient.h>
00029 #include <TRootCanvas.h>
00030 #include <TGMenu.h>
00031 #include <TGButton.h>
00032 #include <TGLabel.h>
00033 #include <TGNumberEntry.h>
00034
00035 #include <TROOT.h>
00036 #include <TRint.h>
00037 #include <TKey.h>
00038 #include <TCanvas.h>
00039 #include <TTree.h>
00040 #include <TFile.h>
00041 #include <TSystem.h>
00042 #include <TGeoManager.h>
00043 #include <TGeoMatrix.h>
00044 #include <RQ_OBJECT.h>
00045 #include <iostream>
00046 #include <sstream>
00047
00048 #include <string>
00049
00050 #include <TGClient.h>
00051 #include <TGListBox.h>
00052 #include <TList.h>
00053
00054 #include "TRootHelpDialog.h"
00055
00056
00057 #define CALOEVENT 1
00058 #define MTEVENT 2
00059
00060
00061 ClassImp(EventDisplay)
00062
00063 const char *dnd_types[] = {
00064 "ROOT files", "*.root",
00065 0, 0
00066 };
00067
00068 const char *filetypes[] = { "All files", "*",
00069 "ROOT files", "*.root",
00070 0, 0 };
00071
00072
00073 EventDisplay::EventDisplay(std::string &rootfileName, std::string &xmlfileName, const TGWindow *p, UInt_t w, UInt_t h)
00074 : TGMainFrame(p, w, h), eventNum(0), steername(xmlfileName) , c1(NULL), dtHist(NULL) , eventType(UNDEFINED)
00075 {
00076 file = new TFile(rootfileName.c_str(),"READONLY");
00077 fillTreeInfo(*file);
00078 this->Init();
00079 fLbRootFile->SetText(rootfileName.c_str());
00080 }
00081
00082 EventDisplay::EventDisplay(std::string &rootfileName, const TGWindow *p, UInt_t w, UInt_t h)
00083 : TGMainFrame(p, w, h), eventNum(0), c1(NULL), dtHist(NULL) , eventType(UNDEFINED)
00084 {
00085 file = new TFile(rootfileName.c_str(),"READONLY");
00086 fillTreeInfo(*file);
00087 this->Init();
00088 fLbRootFile->SetText(rootfileName.c_str());
00089 }
00090
00091
00092 EventDisplay::EventDisplay(const TGWindow *p, UInt_t w, UInt_t h)
00093 : TGMainFrame(p, w, h), eventNum(0) , file(NULL), steername("") , c1(NULL) , dtHist(NULL)
00094 {
00095
00096 this->Init();
00097 }
00098
00099 void EventDisplay::Init()
00100 {
00101 gSystem->Load("libGeom");
00102
00103 histCan = new TCanvas("dt", "dt", 600, 600);
00104 c1 = new TCanvas("Event Display", "Event Display", 600, 600);
00105 c1->SetFillColor(kBlack);
00106
00107 frame =new TGeoManager("Frame","mM event displayer");
00108 mat = new TGeoMaterial("SomeMaterial",1,1,1);
00109 med = new TGeoMedium("SomeMedium",1,mat);
00110 world = frame->MakeBox("World", med, 1, 1, 1);
00111
00112
00113 fMenuBar = new TGMenuBar(this, 35, 50, kHorizontalFrame);
00114 fMenuFile = new TGPopupMenu(gClient->GetRoot());
00115
00116 fMenuFile->AddEntry(" &Open Event file...", M_FILE_EVENT_OPEN, 0, gClient->GetPicture("bld_open.png"));
00117 fMenuFile->AddEntry(" &Open XML steer file...", M_FILE_XML_OPEN,0,gClient->GetPicture("bld_open.png"));
00118 fMenuFile->AddEntry(" &Exit ...", M_FILE_EXIT);
00119
00120 fMenuFile->Connect("Activated(Int_t)", "EventDisplay", this,
00121 "HandleMenu(int)");
00122
00123 fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0));
00124
00125 this->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX|kLHintsExpandY, 2, 2, 2, 5));
00126
00127
00128
00129 const TGFont *font = gClient->GetFont("-*-times-r-*-*-10-*-*-*-*-*-*-*");
00130 if (!font)
00131 font = gClient->GetResourcePool()->GetDefaultFont();
00132 GCValues_t gval;
00133 gval.fMask = kGCBackground | kGCFont | kGCForeground;
00134 gval.fFont = font->GetFontHandle();
00135 FontStruct_t labelfont = font->GetFontStruct();
00136 TGGC *fTextGC = gClient->GetGC(&gval, kTRUE);
00137 ULong_t bcolor, ycolor;
00138 gClient->GetColorByName("white", ycolor);
00139 gClient->GetColorByName("black", bcolor);
00140
00141 fLbRootFile = new TGLabel(this, "file name", fTextGC->GetGC(), labelfont, kChildFrame, bcolor);
00142 AddFrame(fLbRootFile, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 1, 5, 3, 4));
00143
00144
00145
00146
00147
00148 TGHorizontalFrame *controls = new TGHorizontalFrame(this);
00149 AddFrame(controls, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00150
00151 TGLabel *fLbEvent = new TGLabel(controls, "Event");
00152 LbEventNum = new TGNumberEntryField(controls);
00153
00154 prevButton = new TGTextButton(controls, "&<<", PREVID);
00155 nextButton = new TGTextButton(controls, "&>>", NEXTID);
00156 exitButton = new TGTextButton(this, "&Exit", 2);
00157
00158 controls->AddFrame(fLbEvent, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 2, 2, 2));
00159 controls->AddFrame(LbEventNum, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 2, 2, 2));
00160 controls->AddFrame(prevButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 2, 2, 2));
00161 controls->AddFrame(nextButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 2, 2, 2));
00162 prevButton->Connect("Clicked()", "EventDisplay", this, "PrevEvent()");
00163 nextButton->Connect("Clicked()", "EventDisplay", this, "NextEvent()");
00164 LbEventNum->Connect(" ReturnPressed()", "EventDisplay", this, "SetEventNum()");
00165
00166
00167
00168
00169 TGHorizontalFrame *zoomZone = new TGHorizontalFrame(this);
00170 AddFrame(zoomZone, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00171 zoomup = new TGTextButton(zoomZone, "&Zoom +", 2);
00172 zoomdown = new TGTextButton(zoomZone, "&Zoom -", 2);
00173 zoomZone->AddFrame(zoomup, new TGLayoutHints(kLHintsExpandX));
00174 zoomup->Connect("Clicked()", "EventDisplay", this, "Zoom()");
00175 zoomZone->AddFrame(zoomdown, new TGLayoutHints(kLHintsExpandX));
00176 zoomdown->Connect("Clicked()", "EventDisplay", this, "UnZoom()");
00177
00178
00179
00180 slider = new TGDoubleHSlider(this, 200, kDoubleScaleBoth, 10,
00181 kHorizontalFrame,
00182 GetDefaultFrameBackground(),
00183 kFALSE, kFALSE);
00184 slider->Connect("PositionChanged()", "EventDisplay",
00185 this, "DoSlider()");
00186
00187
00188
00189
00190
00191 slider->SetRange(0,1);
00192 slider->SetPosition(0,1);
00193
00194
00195 TGLabel *deltaTLabel = new TGLabel(this, "DeltaT");
00196 this->AddFrame(deltaTLabel, new TGLayoutHints(kLHintsExpandX));
00197 this->AddFrame(slider, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00198
00199 TGHorizontalFrame *deltaT = new TGHorizontalFrame(this);
00200 AddFrame(deltaT, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00201
00202 deltaTMin = new TGNumberEntryField(deltaT);
00203 deltaTMax = new TGNumberEntryField(deltaT);
00204
00205 TGLabel *deltaTMinLabel = new TGLabel(deltaT, "Min");
00206 TGLabel *deltaTMaxLabel = new TGLabel(deltaT, "Max");
00207 deltaT->AddFrame(deltaTMinLabel, new TGLayoutHints(kLHintsExpandX));
00208 deltaT->AddFrame(deltaTMin, new TGLayoutHints(kLHintsExpandX));
00209 deltaT->AddFrame(deltaTMaxLabel, new TGLayoutHints(kLHintsExpandX));
00210 deltaT->AddFrame(deltaTMax, new TGLayoutHints(kLHintsExpandX));
00211 deltaTMin->SetState(false);
00212 deltaTMax->SetState(false);
00213
00214
00215
00216 exitButton->SetCommand(".q" );
00217 fChkBut = new TGCheckButton(this, "Show chambers", 4);
00218
00219 fLbRootFile->SetTextColor(ycolor);
00220 fLbRootFile->Resize(350, 80);
00221 fLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY);
00222 AddFrame(fChkBut, fLayout);
00223 AddFrame(exitButton, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 5, 5, 3, 4));
00224
00225
00226
00227 MapSubwindows();
00228 Layout();
00229 SetWindowName("Micromegas LAPP Event Viewer");
00230 SetIconName("Micromegas LAPP Event Viewer");
00231 MapWindow();
00232 }
00233
00234 EventDisplay::~EventDisplay()
00235 {
00236 if ( file != NULL )
00237 {
00238 file->Close();
00239 delete file;
00240 }
00241 }
00242
00243
00244
00245
00246 void EventDisplay::DoSlider()
00247 {
00248 deltaTMin->SetNumber(slider->GetMinPosition());
00249 deltaTMax->SetNumber(slider->GetMaxPosition());
00250 this->Display();
00251
00252
00253 }
00254
00255 void EventDisplay::UnZoom()
00256 {
00257 c1->cd();
00258 gPad->GetView()->ZoomOut();
00259 c1->SetCanvasSize((UInt_t)(c1->GetWw()*.9),(UInt_t)(c1->GetWh()*.9));
00260
00261 }
00262
00263 void EventDisplay::Zoom()
00264 {
00265 c1->cd();
00266 gPad->GetView()->ZoomIn();
00267 c1->SetCanvasSize((UInt_t)(c1->GetWw()*1.1),(UInt_t)(c1->GetWh()*1.1));
00268
00269 }
00270
00271 void EventDisplay::SetEventNum()
00272 {
00273 if ( file == NULL ) { return ; }
00274 eventNum = LbEventNum->GetIntNumber();
00275 adjustSlider();
00276 this->Display();
00277 }
00278
00279
00280
00281 void EventDisplay::PrevEvent()
00282 {
00283 if ( file == NULL ) { return ; }
00284 if ( eventNum == 0 ) eventNum = 1;
00285 eventNum--;
00286
00287 LbEventNum->SetIntNumber(eventNum);
00288 adjustSlider();
00289 this->Display();
00290 }
00291
00292
00293 void EventDisplay::NextEvent()
00294 {
00295 if ( file == NULL ) { return ; }
00296 eventNum++;
00297 LbEventNum->SetIntNumber(eventNum);
00298 adjustSlider();
00299 this->Display();
00300 }
00301
00302
00303 void EventDisplay::adjustSlider()
00304 {
00305 Int_t min = 0;
00306 Int_t max = 0xffffffff;
00307 slider->SetRange(min, max);
00308 deltaTMin->SetNumber(min);
00309 deltaTMax->SetNumber(max);
00310 slider->SetPosition(min,max);
00311 return ;
00312 TTree *tree = NULL;
00313 TBranch *branch= NULL;
00314 Int_t nbEvent = 0;
00315
00316 TreeInfo_t* info = getTreeInfo(eventNum);
00317
00318 if ( info->type == CALOEVENT )
00319 {
00320 CaloEvent* caloEvt = new CaloEvent();
00321 tree = info->tree;
00322 branch= tree->GetBranch("CaloEvent");
00323 branch->SetAddress(&caloEvt);
00324 tree->GetEntry(this->eventNum-info->min);
00325
00326 Int_t NC=caloEvt->GetNHits();
00327 Int_t min = 0xffffffff;
00328 Int_t max = 0;
00329
00330 for(int i=0;i<NC ;i++)
00331 {
00332 CaloHit* caloChannel = (CaloHit*)caloEvt->GetHits()->UncheckedAt(i);
00333 UInt_t dt= caloChannel->GetDeltaT();
00334 if ( dt < min ) { min = dt; }
00335 if ( dt > max ) { max = dt; }
00336 }
00337
00338 cout << "min[" << min << "] max[" << max <<"]" << endl;
00339 slider->SetRange(min, max);
00340 deltaTMin->SetNumber(min);
00341 deltaTMax->SetNumber(max);
00342 slider->SetPosition(min,max);
00343 delete caloEvt;
00344 }
00345 else
00346 {
00347 MTEvent* caloEvt = new MTEvent();
00348 tree = info->tree;
00349 branch= tree->GetBranch("MTEvent");
00350 branch->SetAddress(&caloEvt);
00351 tree->GetEntry(this->eventNum-info->min);
00352
00353 Int_t NC=caloEvt->GetNchannel();
00354 Int_t min = 0xffffffff;
00355 Int_t max = 0;
00356
00357 for(int i=0;i<NC ;i++)
00358 {
00359 MTChannel* caloChannel = (MTChannel*)caloEvt->GetChannels()->UncheckedAt(i);
00360 UInt_t t2 = caloChannel->GetBcId_Dif();
00361 UInt_t t3 = caloChannel->GetBcId_Hit();
00362 UInt_t dt = t2 - t3;
00363
00364
00365 if ( dt < min ) { min = dt; }
00366 if ( dt > max ) { max = dt; }
00367 }
00368
00369 cout << "min[" << min << "] max[" << max <<"]" << endl;
00370 slider->SetRange(min, max);
00371 deltaTMin->SetNumber(min);
00372 deltaTMax->SetNumber(max);
00373 slider->SetPosition(min,max);
00374 delete caloEvt;
00375 }
00376 }
00377
00378
00379
00380
00381
00382 Bool_t EventDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
00383 {
00384
00385 switch (GET_MSG(msg)) {
00386 case kC_COMMAND:
00387 switch (GET_SUBMSG(msg)) {
00388 case kCM_CHECKBUTTON:
00389 this->Display();
00390 break;
00391 default:
00392 break;
00393 }
00394 default:
00395 break;
00396 }
00397 return kTRUE;
00398 }
00399
00400
00401
00402
00403
00404
00405
00406 void EventDisplay::Display()
00407 {
00408 if ( file == NULL ) { return ; }
00409 if ( file->IsZombie()) {
00410 exit(-1);
00411 }
00412
00413
00414
00415
00416 if ( fChkBut->IsDown())
00417 {
00418 Detector detector;
00419 SteerDesc steerDesc;
00420 XMLTool xml;
00421 xml.parse(steerDesc, steername);
00422
00423 if ( ! detector.build(steerDesc) == steerDesc.chambers.size() )
00424 {
00425 FILE_LOG(logERROR) << "Geometry Error. Please check your XML file." << endl;
00426 exit(-1);
00427 }
00428 ChamberMap_t chambers = detector.getChambers();
00429 for ( ChamberMap_t::const_iterator iter = chambers.begin(); iter!=chambers.end(); iter++)
00430 {
00431 Chamber *chamber = (*iter).second;
00432 TGeoVolume *pad = frame->MakeBox("1" ,med,chamber->getYLength(),chamber->getXLength(),96 );
00433 int color = 17;
00434 cout << "chamber->getX(): " << chamber->getX() << "chamber->getY(): " << chamber->getY() << "chamber->getZ(): " << chamber->getZ() << endl;
00435
00436
00437 world->AddNode(pad,1,new TGeoTranslation(chamber->getX(),chamber->getY(),chamber->getZ()));
00438 pad->SetLineColor(color);
00439 }
00440 }
00441
00442 TreeInfo_t* info = getTreeInfo(eventNum);
00443 if ( info != NULL )
00444 {
00445 if ( info->type == CALOEVENT )
00446 {
00447 this->DisplayCaloEvent();
00448 }
00449 else if ( info->type == MTEVENT )
00450 {
00451 this->DisplayMTEvent();
00452 }
00453 }
00454 }
00455
00456
00457 void EventDisplay::DisplayCaloEvent()
00458 {
00459 if ( dtHist != NULL ) { delete dtHist ;}
00460 dtHist = new TH1I("dt", "dt", slider->GetMaxPosition()-slider->GetMinPosition(), slider->GetMinPosition(), slider->GetMaxPosition() );
00461 CaloEvent *caloEvt = NULL;
00462
00463 int padNumber = 0;
00464 UInt_t curEvent = 0;
00465
00466 TTree *tree = NULL;
00467 TBranch *branch= NULL;
00468 Int_t nbEvent = 0;
00469
00470 caloEvt = new CaloEvent();
00471 TreeInfo_t* info = getTreeInfo(eventNum);
00472 if ( info != NULL )
00473 {
00474 tree = info->tree;
00475 branch= tree->GetBranch("CaloEvent");
00476 branch->SetAddress(&caloEvt);
00477 }
00478 else { return; }
00479 cout << "Get tree[" << tree << "]" << endl;
00480
00481
00482 tree->GetEntry(this->eventNum-info->min);
00483
00484 Int_t NC=caloEvt->GetNHits();
00485 frame->SetMaxVisNodes(NC+100);
00486
00487
00488 float x,y,z;
00489 for(int i=0;i<NC ;i++)
00490 {
00491 if ( padNumber < 169300)
00492 {
00493 CaloHit* caloChannel = NULL;
00494
00495 caloChannel = (CaloHit*)caloEvt->GetHits()->UncheckedAt(i);
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507 float xLength = 9600 ;
00508 float yLength = 9600 ;
00509 float zLength = 10;
00510
00511 string padID="";
00512 stringstream currentpad;
00513 padNumber++;
00514 currentpad<<padNumber;
00515 padID="pad_"+currentpad.str();
00516
00517 cout << "xLength: " << xLength << "yLength: " << yLength << "zLength: " << zLength << endl;
00518 TGeoVolume *pad = frame->MakeBox(padID.c_str(),med,yLength/2,xLength/2,zLength/2 );
00519 x=caloChannel->GetX();
00520 y=caloChannel->GetY();
00521 z=caloChannel->GetZ();
00522 cout << "x: " << x << "y: " << y << "z: " << z << endl;
00523
00524 int color;
00525 int sMax = 30;
00526 stringstream ch;
00527 ch<<i;
00528
00529 if ( caloChannel->GetThreshold() == 1 ) { color = 5; }
00530 else if ( caloChannel->GetThreshold() == 2 ) { color = 6; }
00531 else if ( caloChannel->GetThreshold() == 3 ) { color = 2; }
00532
00533 ostringstream ox,oy,oz;
00534 ox << x; oy << y; oz <<z ;
00535 string key = "x[" + ox.str() + "]y[" + oy.str() + "]z[" + oz.str() +"]" ;
00536
00537 {
00538 world->AddNode(pad,1,new TGeoTranslation(x,y,z));
00539
00540
00541 }
00542 pad->SetLineColor(color);
00543 pad->SetFillColor(color);
00544 pad->SetFillStyle(4100);
00545 }
00546 else
00547 {
00548 break;
00549 }
00550 }
00551 frame->SetTopVolume(world);
00552
00553 frame->CloseGeometry();
00554 histCan->cd();
00555 dtHist->Draw();
00556 c1->cd();
00557 world->Draw();
00558 c1->Update();
00559 histCan->Update();
00560 delete caloEvt;
00561
00562 }
00563
00564 void EventDisplay::DisplayMTEvent()
00565 {
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 if ( dtHist != NULL ) { delete dtHist; }
00577 dtHist = new TH1I("dt", "dt",
00578 slider->GetMaxPosition()-slider->GetMinPosition(),
00579 slider->GetMinPosition(),slider->GetMaxPosition() );
00580 MTEvent *mtEvt = NULL;
00581 int padNumber = 0;
00582 UInt_t curEvent = 0;
00583
00584 TTree *tree = NULL;
00585 TBranch *branch= NULL;
00586 Int_t nbEvent = 0;
00587
00588 mtEvt = new MTEvent();
00589 TreeInfo_t* info = getTreeInfo(eventNum);
00590 if ( info != NULL )
00591 {
00592 tree = info->tree;
00593 branch= tree->GetBranch("MTEvent");
00594 branch->SetAddress(&mtEvt);
00595 }
00596 else { return; }
00597
00598 tree->GetEntry(this->eventNum-info->min);
00599
00600 Int_t NC = mtEvt->GetNchannel();
00601 NC = 3000;
00602 frame->SetMaxVisNodes(NC+100);
00603
00604 UInt_t minSlider = slider->GetMinPosition();
00605 UInt_t maxSlider = slider->GetMaxPosition();
00606
00607 float x,y,z;
00608 for(int i=0;i<NC ;i++)
00609 {
00610
00611 {
00612 cout << "compute channel " << i << " / " << NC << "\t\t\t\t\t\t\t\t\t\t\t\r" << flush;
00613 MTChannel* mtChannel=NULL;
00614
00615 mtChannel = (MTChannel*)mtEvt->GetChannels()->UncheckedAt(i);
00616
00617 UInt_t t2 = mtChannel->GetBcId_Dif();
00618 UInt_t t3 = mtChannel->GetBcId_Hit();
00619 UInt_t dt = t2 - t3;
00620 if ( dt < minSlider || dt > maxSlider ) { continue; }
00621
00622 dtHist->Fill(dt);
00623 float xLength = 9600 ;
00624 float yLength = 9600 ;
00625 float zLength = 10;
00626
00627 string padID="";
00628 stringstream currentpad;
00629 padNumber++;
00630 currentpad<<padNumber;
00631 padID="pad_"+currentpad.str();
00632
00633 x=mtChannel->GetX() ;
00634 y=mtChannel->GetY() ;
00635 z=mtChannel->GetZ() ;
00636
00637 int color;
00638 int sMax = 30;
00639 stringstream ch;
00640 ch<<i;
00641
00642 if ( mtChannel->GetDigitalValue() == 1 ) { color = 5; }
00643 else if ( mtChannel->GetDigitalValue() == 2 ) { color = 6; }
00644 else if ( mtChannel->GetDigitalValue() == 3 ) { color = 2; }
00645
00646 ostringstream ox,oy,oz;
00647 ox << x; oy << y; oz <<z ;
00648 string key = "x[" + ox.str() + "]y[" + oy.str() + "]z[" + oz.str() +"]" ;
00649 TGeoVolume *pad = NULL;
00650 TGeoTranslation *tr = NULL;
00651 if ( nodes.find(key) == nodes.end() )
00652 {
00653 pad = frame->MakeBox(padID.c_str(),med,yLength/2,xLength/2,zLength/2 );
00654 nodes.insert(make_pair(key,pad));
00655 tr = new TGeoTranslation(x,y,z);
00656 trans.insert(make_pair(key,tr));
00657 world->AddNode(pad,1,tr);
00658 }
00659 else
00660 {
00661 pad = nodes[key];
00662 tr = trans[key];
00663 }
00664 pad->SetLineColor(color);
00665 pad->SetFillColor(color);
00666 pad->SetFillStyle(4100);
00667 }
00668 }
00669 frame->SetTopVolume(world);
00670
00671 if ( !frame->IsClosed() ) frame->CloseGeometry();
00672 histCan->cd();
00673 dtHist->Draw();
00674 c1->cd();
00675 world->Draw();
00676 histCan->Update();
00677 c1->Update();
00678
00679 delete mtEvt;
00680 }
00681
00682
00683 void EventDisplay::HandleMenu(int menu_id)
00684 {
00685
00686
00687 TRootHelpDialog *hd;
00688 static TString dir(".");
00689 TGFileInfo fi;
00690 fi.fFileTypes = dnd_types;
00691 fi.fIniDir = StrDup(dir);
00692
00693
00694 switch (menu_id) {
00695 gApplication->Terminate(0);
00696 case M_FILE_EXIT:
00697
00698 gApplication->Terminate(0);
00699 break;
00700 case M_FILE_EVENT_OPEN:
00701 fi.fFileTypes = filetypes;
00702 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
00703 if ( fi.fFilename != NULL )
00704 {
00705 string *full;
00706 full = new string(fi.fFilename);
00707 if ( file != NULL )
00708 {
00709 std::vector<TreeInfo_t*>::const_iterator iter;
00710 for( iter = treeInfos.begin(); iter != treeInfos.end(); iter++)
00711 {
00712 TreeInfo_t* info= *iter;
00713 {
00714 delete info;
00715 }
00716 }
00717 treeInfos.clear();
00718 delete dtHist;
00719 dtHist = NULL;
00720 file->Close();
00721 delete file;
00722 eventNum = 0;
00723 }
00724
00725
00726 file = new TFile(full->c_str(),"READONLY");
00727 fLbRootFile->SetText(full->c_str());
00728 fCaloTypeCheckBut = 0;
00729 fillTreeInfo(*file);
00730
00731 }
00732 break;
00733 case M_FILE_XML_OPEN:
00734 fi.fFileTypes = filetypes;
00735 new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
00736 if ( fi.fFilename != NULL ) steername = fi.fFilename;
00737 break;
00738 case M_HELP_ABOUT:
00739 hd = new TRootHelpDialog(this, "About Drag and Drop...", 550, 250);
00740
00741 hd->Popup();
00742 break;
00743 }
00744 }
00745
00746
00747 void EventDisplay::fillTreeInfo(const TFile &file)
00748 {
00749 treeInfos.clear();
00750
00751 TIter nextkey(file.GetListOfKeys());
00752 TKey *key;
00753 UInt_t nbEvent = 0;
00754 while (key = (TKey*)nextkey())
00755 {
00756 TreeInfo_t *foo = new TreeInfo_t();
00757
00758 TTree *tree = (TTree*)key->ReadObj();
00759 foo->min=nbEvent;
00760 foo->max=foo->min+tree->GetEntries()-1;
00761 nbEvent = foo->max+1;
00762 foo->tree = tree;
00763 if ( tree->FindBranch("CaloEvent")!= NULL)
00764 {
00765 foo->type = CALOEVENT;
00766 }
00767 else if ( tree->FindBranch("MTEvent")!= NULL)
00768 {
00769 foo->type = MTEVENT;
00770 }
00771
00772 treeInfos.push_back(foo);
00773 }
00774 }
00775
00776
00777 TreeInfo_t* EventDisplay::getTreeInfo(UInt_t eventNum)
00778 {
00779
00780
00781 std::vector<TreeInfo_t*>::const_iterator iter;
00782
00783 for( iter = treeInfos.begin(); iter != treeInfos.end(); iter++)
00784 {
00785 TreeInfo_t* info= *iter;
00786 if ( eventNum >= info->min && eventNum <= info->max )
00787 {
00788 return info;
00789 }
00790 }
00791 return NULL;
00792 }
00793