CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Calo/plugins/FWCaloTowerDetailView.cc

Go to the documentation of this file.
00001 #include "TLatex.h"
00002 #include "TEveCalo.h"
00003 #include "TEveScene.h"
00004 #include "TGLViewer.h"
00005 #include "TCanvas.h"
00006 #include "TEveCaloLegoOverlay.h"
00007 
00008 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00009 
00010 #include "Fireworks/Calo/plugins/FWCaloTowerDetailView.h"
00011 #include "Fireworks/Calo/interface/FWECALDetailViewBuilder.h"
00012 #include "Fireworks/Core/interface/FWModelId.h"
00013 #include "Fireworks/Core/interface/FWEventItem.h"
00014 #include "Fireworks/Core/interface/FWGLEventHandler.h"
00015 
00016 //
00017 // constructors and destructor
00018 //
00019 FWCaloTowerDetailView::FWCaloTowerDetailView():
00020   m_data(0),
00021   m_builder(0)
00022 { 
00023 }
00024 
00025 FWCaloTowerDetailView::~FWCaloTowerDetailView()
00026 {
00027 }
00028 
00029 //
00030 // member functions
00031 //
00032 void FWCaloTowerDetailView::build(const FWModelId &id, const CaloTower* iTower)
00033 {
00034    if(!iTower) return;
00035 
00036    // build ECAL objects
00037    m_builder = new FWECALDetailViewBuilder(id.item()->getEvent(), id.item()->getGeom(),
00038                                            iTower->eta(), iTower->phi(), 25);
00039    m_builder->showSuperClusters();
00040    
00041    TEveCaloLego* lego = m_builder->build();
00042    m_data = lego->GetData();
00043    m_data->IncDenyDestroy();
00044    m_eveScene->AddElement(lego);
00045 
00046    // draw axis at the window corners
00047    TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
00048    overlay->SetShowPlane(kFALSE);
00049    overlay->SetShowPerspective(kFALSE);
00050    overlay->SetCaloLego(lego);
00051    overlay->SetShowScales(1); // temporary
00052    viewerGL()->AddOverlayElement(overlay);
00053 
00054    // set event handler and flip camera to top view at beginning
00055    viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00056    FWGLEventHandler* eh =
00057       new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
00058    viewerGL()->SetEventHandler(eh);
00059    viewerGL()->UpdateScene();
00060    viewerGL()->CurrentCamera().Reset();
00061 
00062    viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
00063 
00064    setTextInfo(id, iTower);
00065 
00066 }
00067 
00068 void
00069 FWCaloTowerDetailView::setTextInfo(const FWModelId& id, const CaloTower* tower)
00070 {
00071    m_infoCanvas->cd();
00072    float_t x = 0.02;
00073    float y = 0.97;
00074    TLatex* latex = new TLatex(x, y, "");
00075    const double textsize(0.05);
00076    latex->SetTextSize(textsize);
00077 
00078    float h = latex->GetTextSize()*0.6;
00079    latex->DrawLatex(x, y, "ECAL hit detail view centered on tower:" );
00080    y -= h;
00081    latex->DrawLatex(x, y, Form(" %s",id.item()->modelName(id.index()).c_str()) );
00082    y -= h;
00083    latex->DrawLatex(x, y, Form(" E_{T}(em) = %.1f GeV, E_{T}(had) = %.1f GeV",
00084                                tower->emEt(), tower->hadEt()) );
00085    y -= h;
00086    latex->DrawLatex(x, y, Form(" #eta = %0.2f, #varphi = %0.2f",
00087                                tower->eta(), tower->phi()) );
00088    y -= h;
00089    m_builder->makeLegend(x, y);
00090 }
00091 
00092 REGISTER_FWDETAILVIEW(FWCaloTowerDetailView, Tower);