CMS 3D CMS Logo

FWPhotonDetailView.cc
Go to the documentation of this file.
1 //
2 // Package: Electrons
3 // Class : FWPhotonDetailView
4 
5 #include "TLatex.h"
6 #include "TEveCalo.h"
7 #include "TEvePointSet.h"
8 #include "TEveScene.h"
9 #include "TEveViewer.h"
10 #include "TGLViewer.h"
11 #include "TCanvas.h"
12 #include "TEveCaloLegoOverlay.h"
13 
15 
21 
22 //
23 // constructors and destructor
24 //
25 FWPhotonDetailView::FWPhotonDetailView() : m_data(nullptr), m_builder(nullptr) {}
26 
28  m_eveViewer->GetGLViewer()->DeleteOverlayElements(TGLOverlayElement::kUser);
29 
30  if (m_data)
31  m_data->DecDenyDestroy();
32  delete m_builder;
33 }
34 
35 //
36 // member functions
37 //
38 void FWPhotonDetailView::build(const FWModelId& id, const reco::Photon* iPhoton) {
39  if (!iPhoton)
40  return;
41 
42  // build ECAL objects
44  id.item()->getEvent(), id.item()->getGeom(), iPhoton->caloPosition().eta(), iPhoton->caloPosition().phi(), 25);
46 
47  if (iPhoton->superCluster().isAvailable())
48  m_builder->showSuperCluster(*(iPhoton->superCluster()), kYellow + 1);
49 
50  TEveCaloLego* lego = m_builder->build();
51  m_data = lego->GetData();
52  m_data->IncDenyDestroy();
53  m_eveScene->AddElement(lego);
54 
55  // add Photon specific details
56  if (iPhoton->superCluster().isAvailable())
57  addSceneInfo(iPhoton, m_eveScene);
58 
59  // draw axis at the window corners
60  TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
61  overlay->SetShowPlane(kFALSE);
62  overlay->SetShowPerspective(kFALSE);
63  overlay->SetCaloLego(lego);
64  overlay->SetShowScales(true); // temporary
65  viewerGL()->AddOverlayElement(overlay);
66 
67  // set event handler and flip camera to top view at beginning
68  viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
69  FWGLEventHandler* eh = new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
70  viewerGL()->SetEventHandler(eh);
71  viewerGL()->UpdateScene();
72  viewerGL()->CurrentCamera().Reset();
73 
74  viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
75 
76  setTextInfo(id, iPhoton);
77 }
78 
79 //______________________________________________________________________________
80 
82  m_infoCanvas->cd();
83  float_t x = 0.02;
84  float y = 0.97;
85  TLatex* latex = new TLatex(x, y, "");
86  const double textsize(0.05);
87  latex->SetTextSize(2 * textsize);
88 
89  float h = latex->GetTextSize() * 0.6;
90  latex->DrawLatex(x, y, id.item()->modelName(id.index()).c_str());
91  y -= h;
92 
93  latex->DrawLatex(
94  x, y, Form(" E_{T} = %.1f GeV, #eta = %0.2f, #varphi = %0.2f", photon->et(), photon->eta(), photon->phi()));
95  y -= h;
97 }
98 
99 //______________________________________________________________________________
100 
101 void FWPhotonDetailView::addSceneInfo(const reco::Photon* i, TEveElementList* tList) {
102  // points for centroids
103  Double_t x(0), y(0), z(0);
104  TEvePointSet* scposition = new TEvePointSet("sc position");
105  scposition->SetPickable(kTRUE);
106  scposition->SetTitle("Super cluster centroid");
107 
108  x = i->caloPosition().eta();
109  y = i->caloPosition().phi();
110 
111  scposition->SetNextPoint(x, y, z);
112  scposition->SetMarkerSize(1);
113  scposition->SetMarkerStyle(4);
114  scposition->SetMarkerColor(kBlue);
115  tList->AddElement(scposition);
116 
117  // points for seed position
118  TEvePointSet* seedposition = new TEvePointSet("seed position");
119  seedposition->SetTitle("Seed cluster centroid");
120  seedposition->SetPickable(kTRUE);
121 
122  x = i->superCluster()->seed()->position().eta();
123  y = i->superCluster()->seed()->position().phi();
124  seedposition->SetMarkerSize(0.01);
125 
126  seedposition->SetNextPoint(x, y, z);
127  seedposition->SetMarkerStyle(2);
128  seedposition->SetMarkerColor(kRed);
129  tList->AddElement(seedposition);
130 }
131 
133 
134 /*
135 REGISTER_FWDETAILVIEW(FWPhotonDetailView,Photon,ecalRecHit);
136 REGISTER_FWDETAILVIEW(FWPhotonDetailView,Photon,reducedEcalRecHitsEB);
137 REGISTER_FWDETAILVIEW(FWPhotonDetailView,Photon,reducedEGamma);
138 */
FWPhotonDetailView::~FWPhotonDetailView
~FWPhotonDetailView() override
Definition: FWPhotonDetailView.cc:27
FWPhotonDetailView::FWPhotonDetailView
FWPhotonDetailView()
Definition: FWPhotonDetailView.cc:25
FWPhotonDetailView::setTextInfo
void setTextInfo(const FWModelId &id, const reco::Photon *) override
Definition: FWPhotonDetailView.cc:81
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
FWECALDetailViewBuilder::build
TEveCaloLego * build()
Definition: FWECALDetailViewBuilder.cc:99
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
FWDetailViewGL< reco::Photon >::m_eveScene
TEveScene * m_eveScene
Definition: FWDetailViewGL.h:29
reco::Photon::superCluster
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
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
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
FWModelId
Definition: FWModelId.h:28
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
FWDetailViewGL< reco::Photon >::viewerGL
TGLViewer * viewerGL() const
Definition: FWDetailViewGL.h:20
FWModelId.h
REGISTER_FWDETAILVIEW
#define REGISTER_FWDETAILVIEW(_classname_, _name_,...)
Definition: FWDetailViewFactory.h:32
DDAxes::x
FWPhotonDetailView::m_builder
FWECALDetailViewBuilder * m_builder
Definition: FWPhotonDetailView.h:41
Photon.h
HLTEgPhaseIITestSequence_cff.modelName
modelName
Definition: HLTEgPhaseIITestSequence_cff.py:16
FWDetailViewGL< reco::Photon >::m_infoCanvas
TCanvas * m_infoCanvas
Definition: FWDetailViewGL.h:25
DDAxes::z
FWPhotonDetailView::addSceneInfo
void addSceneInfo(const reco::Photon *, TEveElementList *)
Definition: FWPhotonDetailView.cc:101
h
reco::Photon::caloPosition
math::XYZPointF caloPosition() const
position in ECAL: this is th SC position if r9<0.93. If r8>0.93 is position of seed BasicCluster taki...
Definition: Photon.h:84
FWECALDetailViewBuilder::showSuperClusters
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
Definition: FWECALDetailViewBuilder.cc:156
FWPhotonDetailView::m_data
TEveCaloData * m_data
Definition: FWPhotonDetailView.h:40
FWDetailViewBase::item
const FWEventItem * item()
Definition: FWDetailViewBase.h:48
Photon
Definition: Photon.py:1
FWPhotonDetailView::build
void build(const FWModelId &id, const reco::Photon *) override
Definition: FWPhotonDetailView.cc:38
compare.overlay
def overlay(hists, ytitle, header, addon)
Definition: compare.py:123
FWECALDetailViewBuilder
Definition: FWECALDetailViewBuilder.h:22
FWEventItem.h
ecaldqm::binning::kUser
Definition: MESetBinningUtils.h:51
reco::Photon
Definition: Photon.h:21
FWPhotonDetailView
Definition: FWPhotonDetailView.h:24
FWDetailViewGL< reco::Photon >::m_eveViewer
TEveViewer * m_eveViewer
Definition: FWDetailViewGL.h:28
FWGLEventHandler
Definition: FWGLEventHandler.h:11
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWECALDetailViewBuilder::showSuperCluster
void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow)
Definition: FWECALDetailViewBuilder.cc:146
FWPhotonDetailView.h
FWECALDetailViewBuilder.h