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::build
TEveCaloLego * build()
Definition: FWECALDetailViewBuilder.cc:99
DDAxes::y
FWDetailViewGL< CaloTower >::m_eveScene
TEveScene * m_eveScene
Definition: FWDetailViewGL.h:29
FWECALDetailViewBuilder::makeLegend
double makeLegend(double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow)
Definition: FWECALDetailViewBuilder.cc:410
FWGLEventHandler.h
CaloTower.h
FWModelId
Definition: FWModelId.h:28
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
FWDetailViewGL< CaloTower >::viewerGL
TGLViewer * viewerGL() const
Definition: FWDetailViewGL.h:20
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:3
FWModelId.h
FWCaloTowerDetailView::FWCaloTowerDetailView
FWCaloTowerDetailView()
Definition: FWCaloTowerDetailView.cc:19
REGISTER_FWDETAILVIEW
#define REGISTER_FWDETAILVIEW(_classname_, _name_,...)
Definition: FWDetailViewFactory.h:32
FWCaloTowerDetailView::~FWCaloTowerDetailView
~FWCaloTowerDetailView() override
Definition: FWCaloTowerDetailView.cc:21
DDAxes::x
FWCaloTowerDetailView::m_data
TEveCaloData * m_data
Definition: FWCaloTowerDetailView.h:27
FWCaloTowerDetailView::m_builder
FWECALDetailViewBuilder * m_builder
Definition: FWCaloTowerDetailView.h:28
FWDetailViewGL< CaloTower >::m_infoCanvas
TCanvas * m_infoCanvas
Definition: FWDetailViewGL.h:25
FWCaloTowerDetailView
Definition: FWCaloTowerDetailView.h:17
FWCaloTowerDetailView::setTextInfo
void setTextInfo(const FWModelId &, const CaloTower *) override
Definition: FWCaloTowerDetailView.cc:60
h
FWECALDetailViewBuilder::showSuperClusters
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
Definition: FWECALDetailViewBuilder.cc:156
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
FWDetailViewBase::item
const FWEventItem * item()
Definition: FWDetailViewBase.h:48
CaloTower
Definition: CaloTower.h:26
compare.overlay
def overlay(hists, ytitle, header, addon)
Definition: compare.py:123
FWECALDetailViewBuilder
Definition: FWECALDetailViewBuilder.h:22
FWCaloTowerDetailView::build
void build(const FWModelId &id, const CaloTower *) override
Definition: FWCaloTowerDetailView.cc:26
FWEventItem.h
ecalBarrelClusterFastTimer_cfi.modelName
modelName
Definition: ecalBarrelClusterFastTimer_cfi.py:11
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
FWGLEventHandler
Definition: FWGLEventHandler.h:11
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWCaloTowerDetailView.h
FWECALDetailViewBuilder.h