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