Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "TLatex.h"
00007 #include "TEveCalo.h"
00008 #include "TEvePointSet.h"
00009 #include "TEveScene.h"
00010 #include "TEveViewer.h"
00011 #include "TGLViewer.h"
00012 #include "TCanvas.h"
00013 #include "TEveCaloLegoOverlay.h"
00014
00015 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00016 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00017
00018 #include "Fireworks/Electrons/plugins/FWPhotonDetailView.h"
00019 #include "Fireworks/Calo/interface/FWECALDetailViewBuilder.h"
00020 #include "Fireworks/Core/interface/FWModelId.h"
00021 #include "Fireworks/Core/interface/FWEventItem.h"
00022 #include "Fireworks/Core/interface/FWGLEventHandler.h"
00023
00024
00025
00026
00027 FWPhotonDetailView::FWPhotonDetailView():
00028 m_builder(0)
00029 {
00030 }
00031
00032 FWPhotonDetailView::~FWPhotonDetailView()
00033 {
00034 m_eveViewer->GetGLViewer()->DeleteOverlayElements(TGLOverlayElement::kUser);
00035
00036 if (m_data) m_data->DecDenyDestroy();
00037 delete m_builder;
00038 }
00039
00040
00041
00042
00043 void FWPhotonDetailView::build (const FWModelId &id, const reco::Photon* iPhoton)
00044 {
00045 if(!iPhoton) return;
00046
00047
00048 m_builder = new FWECALDetailViewBuilder(id.item()->getEvent(), id.item()->getGeom(),
00049 iPhoton->caloPosition().eta(), iPhoton->caloPosition().phi(), 25);
00050 m_builder->showSuperClusters();
00051
00052 if ( iPhoton->superCluster().isAvailable() )
00053 m_builder->showSuperCluster(*(iPhoton->superCluster()), kYellow);
00054
00055 TEveCaloLego* lego = m_builder->build();
00056 m_data = lego->GetData();
00057 m_data->IncDenyDestroy();
00058 m_eveScene->AddElement(lego);
00059
00060
00061 if( iPhoton->superCluster().isAvailable() )
00062 addSceneInfo(iPhoton, m_eveScene);
00063
00064
00065 TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
00066 overlay->SetShowPlane(kFALSE);
00067 overlay->SetShowPerspective(kFALSE);
00068 overlay->SetCaloLego(lego);
00069 overlay->SetShowScales(1);
00070 viewerGL()->AddOverlayElement(overlay);
00071
00072
00073 viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00074 FWGLEventHandler* eh =
00075 new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
00076 viewerGL()->SetEventHandler(eh);
00077 viewerGL()->UpdateScene();
00078 viewerGL()->CurrentCamera().Reset();
00079
00080 viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
00081
00082 setTextInfo(id, iPhoton);
00083 }
00084
00085
00086
00087 void
00088 FWPhotonDetailView::setTextInfo(const FWModelId& id, const reco::Photon *photon)
00089 {
00090 m_infoCanvas->cd();
00091 float_t x = 0.02;
00092 float y = 0.97;
00093 TLatex* latex = new TLatex(x, y, "");
00094 const double textsize(0.05);
00095 latex->SetTextSize(2*textsize);
00096
00097 float h = latex->GetTextSize()*0.6;
00098 latex->DrawLatex(x, y, id.item()->modelName(id.index()).c_str() );
00099 y -= h;
00100
00101 latex->DrawLatex(x, y, Form(" E_{T} = %.1f GeV, #eta = %0.2f, #varphi = %0.2f",
00102 photon->et(), photon->eta(), photon->phi()) );
00103 y -= h;
00104 m_builder->makeLegend(x, y);
00105 }
00106
00107
00108
00109 void
00110 FWPhotonDetailView::addSceneInfo(const reco::Photon *i, TEveElementList* tList)
00111 {
00112 unsigned int subdetId(0);
00113 if ( !i->superCluster()->seed()->hitsAndFractions().empty() )
00114 subdetId = i->superCluster()->seed()->hitsAndFractions().front().first.subdetId();
00115
00116
00117 Double_t x(0), y(0), z(0);
00118 TEvePointSet *scposition = new TEvePointSet("sc position");
00119 scposition->SetPickable(kTRUE);
00120 scposition->SetTitle("Super cluster centroid");
00121 if (subdetId == EcalBarrel) {
00122 x = i->caloPosition().eta();
00123 y = i->caloPosition().phi();
00124 } else if (subdetId == EcalEndcap) {
00125 x = i->caloPosition().x();
00126 y = i->caloPosition().y();
00127 }
00128 scposition->SetNextPoint(x,y,z);
00129 scposition->SetMarkerSize(1);
00130 scposition->SetMarkerStyle(4);
00131 scposition->SetMarkerColor(kBlue);
00132 tList->AddElement(scposition);
00133
00134
00135 TEvePointSet *seedposition = new TEvePointSet("seed position");
00136 seedposition->SetTitle("Seed cluster centroid");
00137 seedposition->SetPickable(kTRUE);
00138 if (subdetId == EcalBarrel) {
00139 x = i->superCluster()->seed()->position().eta();
00140 y = i->superCluster()->seed()->position().phi();
00141 seedposition->SetMarkerSize(0.01);
00142 } else if (subdetId == EcalEndcap) {
00143 x = i->superCluster()->seed()->position().x();
00144 y = i->superCluster()->seed()->position().y();
00145 seedposition->SetMarkerSize(1);
00146 }
00147 seedposition->SetNextPoint(x, y, z);
00148 seedposition->SetMarkerStyle(2);
00149 seedposition->SetMarkerColor(kRed);
00150 tList->AddElement(seedposition);
00151 }
00152
00153 REGISTER_FWDETAILVIEW(FWPhotonDetailView,Photon);