Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:56

0001 #include "TLatex.h"
0002 #include "TEveCalo.h"
0003 #include "TEveScene.h"
0004 #include "TGLViewer.h"
0005 #include "TCanvas.h"
0006 #include "TEveCaloLegoOverlay.h"
0007 
0008 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0009 
0010 #include "Fireworks/Calo/plugins/FWCaloTowerDetailView.h"
0011 #include "Fireworks/Calo/interface/FWECALDetailViewBuilder.h"
0012 #include "Fireworks/Core/interface/FWModelId.h"
0013 #include "Fireworks/Core/interface/FWEventItem.h"
0014 #include "Fireworks/Core/interface/FWGLEventHandler.h"
0015 
0016 //
0017 // constructors and destructor
0018 //
0019 FWCaloTowerDetailView::FWCaloTowerDetailView() : m_data(nullptr), m_builder(nullptr) {}
0020 
0021 FWCaloTowerDetailView::~FWCaloTowerDetailView() {}
0022 
0023 //
0024 // member functions
0025 //
0026 void FWCaloTowerDetailView::build(const FWModelId& id, const CaloTower* iTower) {
0027   if (!iTower)
0028     return;
0029 
0030   // build ECAL objects
0031   m_builder =
0032       new FWECALDetailViewBuilder(id.item()->getEvent(), id.item()->getGeom(), iTower->eta(), iTower->phi(), 25);
0033   m_builder->showSuperClusters();
0034 
0035   TEveCaloLego* lego = m_builder->build();
0036   m_data = lego->GetData();
0037   m_data->IncDenyDestroy();
0038   m_eveScene->AddElement(lego);
0039 
0040   // draw axis at the window corners
0041   TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
0042   overlay->SetShowPlane(kFALSE);
0043   overlay->SetShowPerspective(kFALSE);
0044   overlay->SetCaloLego(lego);
0045   overlay->SetShowScales(true);  // temporary
0046   viewerGL()->AddOverlayElement(overlay);
0047 
0048   // set event handler and flip camera to top view at beginning
0049   viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
0050   FWGLEventHandler* eh = new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
0051   viewerGL()->SetEventHandler(eh);
0052   viewerGL()->UpdateScene();
0053   viewerGL()->CurrentCamera().Reset();
0054 
0055   viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
0056 
0057   setTextInfo(id, iTower);
0058 }
0059 
0060 void FWCaloTowerDetailView::setTextInfo(const FWModelId& id, const CaloTower* tower) {
0061   m_infoCanvas->cd();
0062   float_t x = 0.02;
0063   float y = 0.97;
0064   TLatex* latex = new TLatex(x, y, "");
0065   const double textsize(0.05);
0066   latex->SetTextSize(textsize);
0067 
0068   float h = latex->GetTextSize() * 0.6;
0069   latex->DrawLatex(x, y, "ECAL hit detail view centered on tower:");
0070   y -= h;
0071   latex->DrawLatex(x, y, Form(" %s", id.item()->modelName(id.index()).c_str()));
0072   y -= h;
0073   latex->DrawLatex(x, y, Form(" E_{T}(em) = %.1f GeV, E_{T}(had) = %.1f GeV", tower->emEt(), tower->hadEt()));
0074   y -= h;
0075   latex->DrawLatex(x, y, Form(" #eta = %0.2f, #varphi = %0.2f", tower->eta(), tower->phi()));
0076   y -= h;
0077   m_builder->makeLegend(x, y);
0078 }
0079 
0080 REGISTER_FWDETAILVIEW(FWCaloTowerDetailView, Tower);