CMS 3D CMS Logo

FWCaloTowerDetailView.cc
Go to the documentation of this file.
1 #include "TLatex.h"
2 #include "TEveCalo.h"
3 #include "TEveScene.h"
4 #include "TGLViewer.h"
5 #include "TCanvas.h"
6 #include "TEveCaloLegoOverlay.h"
7 
9 
15 
16 //
17 // constructors and destructor
18 //
19 FWCaloTowerDetailView::FWCaloTowerDetailView() : m_data(nullptr), m_builder(nullptr) {}
20 
22 
23 //
24 // member functions
25 //
26 void FWCaloTowerDetailView::build(const FWModelId& id, const CaloTower* iTower) {
27  if (!iTower)
28  return;
29 
30  // build ECAL objects
31  m_builder =
32  new FWECALDetailViewBuilder(id.item()->getEvent(), id.item()->getGeom(), iTower->eta(), iTower->phi(), 25);
34 
35  TEveCaloLego* lego = m_builder->build();
36  m_data = lego->GetData();
37  m_data->IncDenyDestroy();
38  m_eveScene->AddElement(lego);
39 
40  // draw axis at the window corners
41  TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
42  overlay->SetShowPlane(kFALSE);
43  overlay->SetShowPerspective(kFALSE);
44  overlay->SetCaloLego(lego);
45  overlay->SetShowScales(true); // temporary
46  viewerGL()->AddOverlayElement(overlay);
47 
48  // set event handler and flip camera to top view at beginning
49  viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
50  FWGLEventHandler* eh = new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
51  viewerGL()->SetEventHandler(eh);
52  viewerGL()->UpdateScene();
53  viewerGL()->CurrentCamera().Reset();
54 
55  viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
56 
57  setTextInfo(id, iTower);
58 }
59 
61  m_infoCanvas->cd();
62  float_t x = 0.02;
63  float y = 0.97;
64  TLatex* latex = new TLatex(x, y, "");
65  const double textsize(0.05);
66  latex->SetTextSize(textsize);
67 
68  float h = latex->GetTextSize() * 0.6;
69  latex->DrawLatex(x, y, "ECAL hit detail view centered on tower:");
70  y -= h;
71  latex->DrawLatex(x, y, Form(" %s", id.item()->modelName(id.index()).c_str()));
72  y -= h;
73  latex->DrawLatex(x, y, Form(" E_{T}(em) = %.1f GeV, E_{T}(had) = %.1f GeV", tower->emEt(), tower->hadEt()));
74  y -= h;
75  latex->DrawLatex(x, y, Form(" #eta = %0.2f, #varphi = %0.2f", tower->eta(), tower->phi()));
76  y -= h;
78 }
79 
FWECALDetailViewBuilder * m_builder
double makeLegend(double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow)
void setTextInfo(const FWModelId &, const CaloTower *) override
const FWEventItem * item()
#define REGISTER_FWDETAILVIEW(_classname_, _name_,...)
def overlay(hists, ytitle, header, addon)
Definition: compare.py:122
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
TGLViewer * viewerGL() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double phi() const final
momentum azimuthal angle
void build(const FWModelId &id, const CaloTower *) override
double eta() const final
momentum pseudorapidity