00001 #include <iostream>
00002 #include <fstream>
00003 #include <stdlib.h>
00004
00005 #include "RecoParticleFlow/PFBlockAlgo/interface/PFGeometry.h"
00006 #include "RecoParticleFlow/PFRootEvent/interface/DialogFrame.h"
00007 #include "RecoParticleFlow/PFRootEvent/interface/DisplayCommon.h"
00008
00009 #include <TROOT.h>
00010 #include <TTree.h>
00011 #include "TLine.h"
00012 #include "TList.h"
00013 #include "TCanvas.h"
00014 #include "TButton.h"
00015 #include "TGraph.h"
00016 #include "TMarker.h"
00017 #include "TText.h"
00018 #include <TApplication.h>
00019
00020
00021
00022
00023 DialogFrame::DialogFrame(PFRootEventManager *evman,DisplayManager *dm,const TGWindow *p,UInt_t w,UInt_t h)
00024 :TGMainFrame(p, w, h),evMan_(evman),display_(dm),attrView_(0),
00025 thisClusPattern_(0),trackPattern_(0),simplePartPattern_(0)
00026 {
00027
00028 mainFrame_= new TGCompositeFrame(this,200,300,kVerticalFrame);
00029 createCmdFrame();
00030 AddFrame(mainFrame_, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
00031
00032
00033 SetWindowName("PFRootEvent Dialog");
00034
00035 MapSubwindows();
00036
00037 Resize(mainFrame_->GetDefaultSize());
00038
00039 MapWindow();
00040
00041 }
00042
00043 void DialogFrame::closeCanvasAttr()
00044 {
00045 if (gROOT->GetListOfCanvases()->FindObject("graphic Attributes"))
00046 attrView_->Close();
00047 attrView_=0;
00048 thisClusPattern_=0;
00049 trackPattern_=0;
00050 simplePartPattern_=0;
00051 }
00052
00053 void DialogFrame::createCanvasAttr()
00054 {
00055
00056
00057
00058 closeCanvasAttr();
00059 attrView_=0;
00060 attrView_ = new TCanvas("graphic Attributes","graphic Attributes",180,300);
00061 char *action1="win->DialogFrame::modifyAttr()";
00062 char *action2="win->DialogFrame::closeCanvasAttr()";
00063 TButton *accept_ = new TButton("modify",action1,0.1,0.2,0.5,0.3);
00064 TButton *cancel_ = new TButton("cancel",action2,0.54,0.2,0.9,0.3);
00065 double x[3];
00066 double y[3];
00067 x[0]=0.1;x[1]=0.3;x[2]=0.5;
00068 y[0]=0.6;y[1]=0.6;y[2]=0.6;
00069 thisClusPattern_= new TMarker(0.3,0.8,display_->clusPattern_->GetMarkerStyle());
00070 thisClusPattern_->SetMarkerColor(display_->clusPattern_->GetMarkerColor());
00071 thisClusPattern_->SetMarkerSize(display_->clusPattern_->GetMarkerSize());
00072 thisClusPattern_->Draw();
00073 TText * tt=new TText(0.6,0.78,"clusters");
00074 tt->SetTextSize(.08);
00075 tt->Draw();
00076 trackPattern_= new TGraph(3,x,y);
00077 trackPattern_->SetLineColor(display_->trackPatternL_->GetLineColor());
00078 trackPattern_->SetMarkerColor(display_->trackPatternM_->GetMarkerColor());
00079 trackPattern_->SetMarkerStyle(display_->trackPatternM_->GetMarkerStyle());
00080 trackPattern_->SetMarkerSize(display_->trackPatternM_->GetMarkerSize());
00081 trackPattern_->Draw("pl");
00082 TText *tt2= new TText(0.6,0.58,"recTracks");
00083 tt2->SetTextSize(.08);
00084 tt2->Draw();
00085
00086 accept_->Draw();
00087 cancel_->Draw();
00088 attrView_->Update();
00089 }
00090
00091 void DialogFrame::createCmdFrame()
00092 {
00093 TGCompositeFrame *h1Frame1 = new TGCompositeFrame(mainFrame_, 100, 100, kHorizontalFrame | kRaisedFrame);
00094 mainFrame_->AddFrame(h1Frame1,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00095 TGLayoutHints *lo;
00096 lo = new TGLayoutHints(kLHintsLeft|kLHintsExpandX |kLHintsExpandY ,5,2,5,2);
00097
00098
00099 TGGroupFrame *gr1= new TGGroupFrame(h1Frame1,"Draw Selection",kVerticalFrame);
00100 gr1->SetLayoutManager(new TGMatrixLayout(gr1,7,3,5));
00101
00102 selectObject_[0] = new TGCheckButton(gr1,"Hits");
00103 selectObject_[0]->SetState(display_->drawHits_ ? kButtonDown :kButtonUp);
00104 selectObject_[0]->Connect("Clicked()","DialogFrame",this,"doModifyOptions(=0)");
00105 selectObject_[1] = new TGCheckButton(gr1,"Clusters");
00106 selectObject_[1]->SetState(display_->drawClus_ ? kButtonDown :kButtonUp);
00107 selectObject_[1]->Connect("Clicked()","DialogFrame",this,"doModifyOptions(=1)");
00108 selectObject_[2] = new TGCheckButton(gr1,"Tracks");
00109 selectObject_[2]->SetState(display_->drawTracks_ ? kButtonDown :kButtonUp);
00110 selectObject_[2]->Connect("Clicked()","DialogFrame",this,"doModifyOptions(=2)");
00111 selectObject_[3] = new TGCheckButton(gr1,"SimParticles");
00112 selectObject_[3]->SetState(display_->drawParticles_ ? kButtonDown :kButtonUp);
00113 selectObject_[3]->Connect("Clicked()","DialogFrame",this,"doModifyOptions(=3)");
00114 selectObject_[4] = new TGCheckButton(gr1,"GenParticles");
00115 selectObject_[4]->SetState(display_->drawGenParticles_ ? kButtonDown :kButtonUp);
00116 selectObject_[4]->Connect("Clicked()","DialogFrame",this,"doModifyOptions(=4)");
00117 selectObject_[5] = new TGCheckButton(gr1,"PFBlock visible");
00118 selectObject_[5]->SetState(display_->drawPFBlocks_ ? kButtonDown :kButtonUp);
00119 selectObject_[5]->Connect("Clicked()","DialogFrame",this,"isPFBlockVisible()");
00120
00121
00122 TGNumberFormat::ELimit lim = TGNumberFormat::kNELLimitMinMax;
00123 for (int i=0;i<5;++i){
00124 thresholdS_[i] = new TGDoubleHSlider(gr1,100,kDoubleScaleNo,ENER+i);
00125 thresholdS_[i]->Associate(this);
00126 thresholdS_[i]->SetRange(0,10);
00127
00128 threshEntry_[i] = new TGNumberEntryField(gr1,EN+i,0);
00129 threshEntry_[i]->Associate(this);
00130 threshEntry_[i]->SetLimits(lim,0,10);
00131 threshEntry_[i]->SetFormat((TGNumberFormat::EStyle)2);
00132 }
00133 thresholdS_[0]->SetPosition((float) display_->hitEnMin_,(float) display_->hitEnMin_);
00134 thresholdS_[1]->SetPosition((float) display_->clusEnMin_,(float)display_->clusEnMin_);
00135 thresholdS_[2]->SetPosition((float) display_->trackPtMin_,(float)display_->trackPtMin_);
00136 thresholdS_[3]->SetPosition((float) display_->particlePtMin_,(float)display_->particlePtMin_);
00137 thresholdS_[4]->SetPosition((float) display_->genParticlePtMin_,(float)display_->genParticlePtMin_);
00138
00139
00140 int charw= threshEntry_[0]->GetCharWidth("O");
00141 int size=charw*4;
00142 for (int i=0;i<5;++i) {
00143 threshEntry_[i]->SetNumber(thresholdS_[i]->GetMinPosition());
00144 threshEntry_[i]->Resize(size,threshEntry_[i]->GetDefaultHeight());
00145 }
00146
00147
00148 TGLayoutHints *lo1=new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
00149 TGLabel *label=new TGLabel(gr1," ");
00150 gr1->AddFrame(label,lo1);
00151 label=new TGLabel(gr1," En/Pt Threshold");
00152 gr1->AddFrame(label,lo1);
00153 label=new TGLabel(gr1," (Gev) ");
00154 gr1->AddFrame(label,lo1);
00155
00156 for (int i=0;i<5;++i) {
00157 gr1->AddFrame(selectObject_[i],lo1);
00158 gr1->AddFrame(thresholdS_[i],lo1);
00159 gr1->AddFrame(threshEntry_[i],lo1);
00160 }
00161 gr1->AddFrame(selectObject_[5],lo1);
00162 h1Frame1->AddFrame(gr1,lo1);
00163
00164
00165 TGVerticalFrame *optionFrame = new TGVerticalFrame(h1Frame1,10,10,kSunkenFrame);
00166
00167
00168 TGLabel *lab1,*lab2;
00169 TGHorizontalFrame *h2 = new TGHorizontalFrame(optionFrame,10,10);
00170 TGGroupFrame *printGroup = new TGGroupFrame(h2, " Print", kVerticalFrame);
00171 lab1 = new TGLabel(printGroup," ");
00172 lab2 = new TGLabel(printGroup," ");
00173
00174 printGroup->SetLayoutManager(new TGMatrixLayout(printGroup, 7,3,3));
00175 printButton_[0] = new TGCheckButton(printGroup,"RecHits ");
00176 printButton_[0]->SetState(evMan_->printRecHits_ ? kButtonDown :kButtonUp);
00177 printButton_[0]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=0)");
00178 printButton_[1] = new TGCheckButton(printGroup,"Clusters");
00179 printButton_[1]->SetState(evMan_->printClusters_ ? kButtonDown :kButtonUp);
00180 printButton_[1]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=1)");
00181 printButton_[2] = new TGCheckButton(printGroup,"PFBlocks");
00182 printButton_[2]->SetState(evMan_->printPFBlocks_ ? kButtonDown :kButtonUp);
00183 printButton_[2]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=2)");
00184 printButton_[3] = new TGCheckButton(printGroup,"PFCandidates ");
00185 printButton_[3]->SetState(evMan_->printPFCandidates_ ? kButtonDown :kButtonUp);
00186 printButton_[3]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=3)");
00187 printButton_[4] = new TGCheckButton(printGroup,"PFJets ");
00188 printButton_[4]->SetState(evMan_->printPFJets_ ? kButtonDown :kButtonUp);
00189 printButton_[4]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=4)");
00190 printButton_[5] = new TGCheckButton(printGroup,"SimParticles ");
00191 printButton_[5]->SetState(evMan_->printSimParticles_ ? kButtonDown :kButtonUp);
00192 printButton_[5]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=5)");
00193 printButton_[6] = new TGCheckButton(printGroup,"GenParticles");
00194 TGLabel *maxl = new TGLabel(printGroup,"max lines:");
00195 maxLineEntry_= new TGNumberEntryField(printGroup,MAXL,30);
00196 maxLineEntry_->Associate(this);
00197 maxLineEntry_->SetFormat((TGNumberFormat::EStyle)0);
00198 maxLineEntry_->Resize(charw*3,maxLineEntry_->GetDefaultHeight());
00199 printButton_[6]->SetState(evMan_->printGenParticles_ ? kButtonDown :kButtonUp);
00200 printButton_[6]->Connect("Clicked()","DialogFrame",this,"selectPrintOption(=6)");
00201
00202
00203 for(UInt_t i = 0 ;i<6 ; ++i){
00204 printGroup->AddFrame(printButton_[i],lo1);
00205 printGroup->AddFrame(lab1,lo1);
00206 printGroup->AddFrame(lab2,lo1);
00207 }
00208 printGroup->AddFrame(printButton_[6],lo1);
00209 printGroup->AddFrame(maxl,lo1);
00210 printGroup->AddFrame(maxLineEntry_,lo1);
00211
00212
00213 TGTextButton *sendPrintButton = new TGTextButton(h2,"Print");
00214 sendPrintButton->Connect("Clicked()","DialogFrame",this,"doPrint()");
00215
00216 h2->AddFrame(printGroup,lo1);
00217 h2->AddFrame(sendPrintButton,new TGLayoutHints(kLHintsLeft|kLHintsCenterY,2,2,2,2));
00218
00219 TGGroupFrame *viewGroup = new TGGroupFrame(optionFrame,"View",kHorizontalFrame);
00220 lab1 = new TGLabel(viewGroup," ");
00221 lab2 = new TGLabel(viewGroup," ");
00222 viewGroup->SetLayoutManager(new TGMatrixLayout(viewGroup, 3,3,3));
00223
00224 TGTextButton *lookFor = new TGTextButton(viewGroup,"Look for");
00225 lookFor->Connect("Clicked()","DialogFrame",this,"doLookForGenParticle()");
00226 TGLabel *genPartNb = new TGLabel(viewGroup,"Gen Particle Nb:");
00227 particleTypeEntry_ = new TGNumberEntryField(viewGroup,PARTTYPE,1);
00228 particleTypeEntry_->Associate(this);
00229 particleTypeEntry_->SetFormat((TGNumberFormat::EStyle)0);
00230 particleTypeEntry_->Resize(charw*3,particleTypeEntry_->GetDefaultHeight());
00231
00232 TGTextButton *unZoomButton = new TGTextButton(viewGroup,"Unzoom");
00233 unZoomButton->Connect("Clicked()","DialogFrame",this,"unZoom()");
00234
00235 TGTextButton *newAttrBis = new TGTextButton(viewGroup,"Modify Graphic Attr");
00236 newAttrBis->Connect("Clicked()","DialogFrame",this,"createCanvasAttr()");
00237
00238 viewGroup->AddFrame(lookFor,lo1);
00239 viewGroup->AddFrame(genPartNb,lo1),
00240 viewGroup->AddFrame(particleTypeEntry_,lo1);
00241 viewGroup->AddFrame(unZoomButton,lo1);
00242 viewGroup->AddFrame(lab1,lo1);
00243 viewGroup->AddFrame(lab2,lo1);
00244 viewGroup->AddFrame(newAttrBis,lo1);
00245
00246
00247 optionFrame->AddFrame(h2,lo);
00248 optionFrame->AddFrame(viewGroup,lo1);
00249 h1Frame1->AddFrame(optionFrame,lo);
00250
00251
00252
00253
00254 TGHorizontalFrame *h1 = new TGHorizontalFrame(mainFrame_,20,30);
00255 mainFrame_->AddFrame(h1,new TGLayoutHints(kLHintsCenterX,2,2,2,2));
00256
00257 nextButton = new TGTextButton(h1,"Draw Next");
00258 nextButton->Connect("Clicked()","DialogFrame",this,"doNextEvent()");
00259 h1->AddFrame(nextButton,new TGLayoutHints(kLHintsBottom|kLHintsCenterX,2,2,2,2));
00260
00261 previousButton = new TGTextButton(h1,"Draw Previous");
00262 previousButton->Connect("Clicked()","DialogFrame",this,"doPreviousEvent()");
00263 h1->AddFrame(previousButton,new TGLayoutHints(kLHintsBottom|kLHintsCenterX,2,2,2,2));
00264
00265
00266 reProcessButton = new TGTextButton(h1,"Re-Process");
00267 reProcessButton->Connect("Clicked()","DialogFrame",this,"doReProcessEvent()");
00268 h1->AddFrame(reProcessButton,new TGLayoutHints(kLHintsBottom|kLHintsCenterX,2,2,2,2));
00269
00270
00271
00272
00273
00274
00275
00276 exitButton = new TGTextButton(h1,"&Exit","gApplication->Terminate(0)");
00277 h1->AddFrame(exitButton,new TGLayoutHints(kLHintsBottom|kLHintsCenterX,2,2,2,2));
00278 }
00279
00280
00281 void DialogFrame::CloseWindow()
00282 {
00284 gApplication->Terminate(0);
00285 }
00286
00287 void DialogFrame::doLookForGenParticle()
00288 {
00289 int num = particleTypeEntry_->GetIntNumber();
00290 display_->lookForGenParticle((unsigned)num);
00291 }
00292
00293
00294 void DialogFrame::doModifyOptions(unsigned objNb)
00295 {
00296 switch (objNb) {
00297 case 0:
00298 display_->drawHits_ = (selectObject_[0]->IsDown()) ?true :false;
00299 break;
00300 case 1:
00301 display_->drawClus_ = (selectObject_[1]->IsDown()) ?true :false;
00302 break;
00303 case 2:
00304 display_->drawTracks_ = (selectObject_[2]->IsDown()) ?true :false;
00305 break;
00306 case 3:
00307 display_->drawParticles_ = (selectObject_[3]->IsDown()) ?true :false;
00308 break;
00309 case 4:
00310 display_->drawGenParticles_ = (selectObject_[4]->IsDown()) ?true :false;
00311 break;
00312 }
00313 display_->displayAll();
00314 }
00315
00316 DialogFrame::~DialogFrame()
00317 {
00318 mainFrame_->Cleanup();
00319 }
00320
00321 void DialogFrame::doModifyPtThreshold(unsigned objNb,double pt)
00322 {
00323 switch(objNb) {
00324 case 0:
00325 display_->hitEnMin_= pt;break;
00326 case 1:
00327 display_->clusEnMin_= pt;break;
00328 case 2:
00329 display_->trackPtMin_= pt;break;
00330 case 3:
00331 display_->particlePtMin_= pt;break;
00332 case 4:
00333 display_->genParticlePtMin_= pt;break;
00334
00335 default:break;
00336 }
00337 display_->displayAll();
00338 }
00339
00340 void DialogFrame::doNextEvent()
00341 {
00342 display_->displayNext();
00343 doLookForGenParticle();
00344
00345
00346 }
00347
00348 void DialogFrame::doPreviousEvent()
00349 {
00350 display_->displayPrevious();
00351 doLookForGenParticle();
00352
00353
00354 }
00355
00356 void DialogFrame::doPrint()
00357 {
00358 evMan_->print(std::cout,maxLineEntry_->GetIntNumber());
00359 }
00360
00361 void DialogFrame::doPrintGenParticles()
00362 {
00363 evMan_->printGenParticles(std::cout,maxLineEntry_->GetIntNumber());
00364 }
00365
00366 void DialogFrame::doReProcessEvent()
00367 {
00368 int eventNumber = evMan_->eventNumber();
00369 display_->display(eventNumber);
00370 }
00371
00372 void DialogFrame::isPFBlockVisible()
00373 {
00374 display_->enableDrawPFBlock((selectObject_[5]->IsDown()) ?true :false);
00375 }
00376
00377 void DialogFrame::selectPrintOption(int opt)
00378 {
00379 switch (opt) {
00380 case 0:
00381 evMan_->printRecHits_ = (printButton_[0]->IsDown()) ?true :false;
00382 break;
00383 case 1:
00384 evMan_->printClusters_ = (printButton_[1]->IsDown()) ?true :false;
00385 break;
00386 case 2:
00387 evMan_->printPFBlocks_ = (printButton_[2]->IsDown()) ?true :false;
00388 break;
00389 case 3:
00390 evMan_->printPFCandidates_ = (printButton_[3]->IsDown()) ?true :false;
00391 break;
00392 case 4:
00393 evMan_->printPFJets_ = (printButton_[4]->IsDown()) ?true :false;
00394 break;
00395 case 5:
00396 evMan_->printSimParticles_ = (printButton_[5]->IsDown()) ?true :false;
00397 break;
00398 case 6:
00399 evMan_->printGenParticles_ = (printButton_[6]->IsDown()) ?true :false;
00400 break;
00401 default: break;
00402
00403 }
00404 }
00405
00406 void DialogFrame::updateDisplay()
00407 {
00408 display_->updateDisplay();
00409 }
00410
00411
00412 void DialogFrame::unZoom()
00413 {
00414 display_->unZoom();
00415 }
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 void DialogFrame::modifyAttr()
00428 {
00429 display_->clusPattern_->SetMarkerStyle(thisClusPattern_->GetMarkerStyle());
00430 display_->clusPattern_->SetMarkerSize(thisClusPattern_->GetMarkerSize());
00431 display_->clusPattern_->SetMarkerColor(thisClusPattern_->GetMarkerColor());
00432 display_->trackPatternL_->SetLineColor(trackPattern_->GetLineColor());
00433 display_->trackPatternM_->SetMarkerStyle(trackPattern_->GetMarkerStyle());
00434 display_->trackPatternM_->SetMarkerSize(trackPattern_->GetMarkerSize());
00435
00436 closeCanvasAttr();
00437 display_->drawWithNewGraphicAttributes();
00438 }
00439
00440 Bool_t DialogFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
00441 {
00442 switch (GET_MSG(msg)) {
00443 case kC_TEXTENTRY:
00444 switch (GET_SUBMSG(msg)) {
00445 case kTE_ENTER:
00446 switch (parm1) {
00447 case EN :case EN+1: case EN+2: case EN+3: case EN+4:
00448 {
00449
00450 float val=threshEntry_[parm1-EN]->GetNumber();
00451 thresholdS_[parm1-EN]->SetPosition(val,val);
00452 doModifyPtThreshold(parm1-EN,val);
00453 break;
00454 }
00455 case MAXL:
00456 evMan_->printGenParticles_ = true;
00457 printButton_[6]->SetState(kButtonDown);
00458 doPrintGenParticles();
00459 break;
00460 case PARTTYPE:
00461 doLookForGenParticle();
00462 break;
00463 default:break;
00464 }
00465 break;
00466 default:break;
00467 }
00468 break;
00469 case kC_HSLIDER:
00470 switch (GET_SUBMSG(msg)) {
00471 case kSL_POS:
00472 switch (parm1) {
00473 case ENER: case ENER+1: case ENER+2: case ENER+3: case ENER+4:
00474 {
00475 unsigned index=parm1-ENER;
00476 float val = thresholdS_[index]->GetMinPosition();
00477 threshEntry_[index]->SetNumber(val);
00478 fClient->NeedRedraw(threshEntry_[index]);
00479 break;
00480 }
00481 default:break;
00482 }
00483 break;
00484 case kSL_RELEASE:
00485 switch (parm1) {
00486 case ENER: case ENER+1: case ENER+2: case ENER+3:case ENER+4:
00487 {
00488 float val = thresholdS_[parm1-ENER]->GetMinPosition();
00489 doModifyPtThreshold(parm1-ENER,(double)val);
00490 break;
00491 }
00492 default:break;
00493 }
00494 break;
00495 default:break;
00496 }
00497 break;
00498 default:break;
00499 }
00500 return true;
00501 }