CMS 3D CMS Logo

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