File indexing completed on 2024-04-06 12:11:45
0001
0002
0003
0004
0005 #include "TLatex.h"
0006 #include "TEveCalo.h"
0007 #include "TEvePointSet.h"
0008 #include "TEveScene.h"
0009 #include "TEveViewer.h"
0010 #include "TGLViewer.h"
0011 #include "TCanvas.h"
0012 #include "TEveCaloLegoOverlay.h"
0013
0014 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0015
0016 #include "Fireworks/Electrons/plugins/FWPhotonDetailView.h"
0017 #include "Fireworks/Calo/interface/FWECALDetailViewBuilder.h"
0018 #include "Fireworks/Core/interface/FWModelId.h"
0019 #include "Fireworks/Core/interface/FWEventItem.h"
0020 #include "Fireworks/Core/interface/FWGLEventHandler.h"
0021
0022
0023
0024
0025 FWPhotonDetailView::FWPhotonDetailView() : m_data(nullptr), m_builder(nullptr) {}
0026
0027 FWPhotonDetailView::~FWPhotonDetailView() {
0028 m_eveViewer->GetGLViewer()->DeleteOverlayElements(TGLOverlayElement::kUser);
0029
0030 if (m_data)
0031 m_data->DecDenyDestroy();
0032 delete m_builder;
0033 }
0034
0035
0036
0037
0038 void FWPhotonDetailView::build(const FWModelId& id, const reco::Photon* iPhoton) {
0039 if (!iPhoton)
0040 return;
0041
0042
0043 m_builder = new FWECALDetailViewBuilder(
0044 id.item()->getEvent(), id.item()->getGeom(), iPhoton->caloPosition().eta(), iPhoton->caloPosition().phi(), 25);
0045 m_builder->showSuperClusters();
0046
0047 if (iPhoton->superCluster().isAvailable())
0048 m_builder->showSuperCluster(*(iPhoton->superCluster()), kYellow + 1);
0049
0050 TEveCaloLego* lego = m_builder->build();
0051 m_data = lego->GetData();
0052 m_data->IncDenyDestroy();
0053 m_eveScene->AddElement(lego);
0054
0055
0056 if (iPhoton->superCluster().isAvailable())
0057 addSceneInfo(iPhoton, m_eveScene);
0058
0059
0060 TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
0061 overlay->SetShowPlane(kFALSE);
0062 overlay->SetShowPerspective(kFALSE);
0063 overlay->SetCaloLego(lego);
0064 overlay->SetShowScales(true);
0065 viewerGL()->AddOverlayElement(overlay);
0066
0067
0068 viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
0069 FWGLEventHandler* eh = new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
0070 viewerGL()->SetEventHandler(eh);
0071 viewerGL()->UpdateScene();
0072 viewerGL()->CurrentCamera().Reset();
0073
0074 viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
0075
0076 setTextInfo(id, iPhoton);
0077 }
0078
0079
0080
0081 void FWPhotonDetailView::setTextInfo(const FWModelId& id, const reco::Photon* photon) {
0082 m_infoCanvas->cd();
0083 float_t x = 0.02;
0084 float y = 0.97;
0085 TLatex* latex = new TLatex(x, y, "");
0086 const double textsize(0.05);
0087 latex->SetTextSize(2 * textsize);
0088
0089 float h = latex->GetTextSize() * 0.6;
0090 latex->DrawLatex(x, y, id.item()->modelName(id.index()).c_str());
0091 y -= h;
0092
0093 latex->DrawLatex(
0094 x, y, Form(" E_{T} = %.1f GeV, #eta = %0.2f, #varphi = %0.2f", photon->et(), photon->eta(), photon->phi()));
0095 y -= h;
0096 m_builder->makeLegend(x, y);
0097 }
0098
0099
0100
0101 void FWPhotonDetailView::addSceneInfo(const reco::Photon* i, TEveElementList* tList) {
0102
0103 Double_t x(0), y(0), z(0);
0104 TEvePointSet* scposition = new TEvePointSet("sc position");
0105 scposition->SetPickable(kTRUE);
0106 scposition->SetTitle("Super cluster centroid");
0107
0108 x = i->caloPosition().eta();
0109 y = i->caloPosition().phi();
0110
0111 scposition->SetNextPoint(x, y, z);
0112 scposition->SetMarkerSize(1);
0113 scposition->SetMarkerStyle(4);
0114 scposition->SetMarkerColor(kBlue);
0115 tList->AddElement(scposition);
0116
0117
0118 TEvePointSet* seedposition = new TEvePointSet("seed position");
0119 seedposition->SetTitle("Seed cluster centroid");
0120 seedposition->SetPickable(kTRUE);
0121
0122 x = i->superCluster()->seed()->position().eta();
0123 y = i->superCluster()->seed()->position().phi();
0124 seedposition->SetMarkerSize(0.01);
0125
0126 seedposition->SetNextPoint(x, y, z);
0127 seedposition->SetMarkerStyle(2);
0128 seedposition->SetMarkerColor(kRed);
0129 tList->AddElement(seedposition);
0130 }
0131
0132 REGISTER_FWDETAILVIEW(FWPhotonDetailView, Photon);
0133
0134
0135
0136
0137
0138