CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 
22 
23 //
24 // constructors and destructor
25 //
27 m_data(0),
28 m_builder(0)
29 {
30 }
31 
33 {
34  m_eveViewer->GetGLViewer()->DeleteOverlayElements(TGLOverlayElement::kUser);
35 
36  if (m_data) m_data->DecDenyDestroy();
37  delete m_builder;
38 }
39 
40 //
41 // member functions
42 //
43 void FWPhotonDetailView::build (const FWModelId &id, const reco::Photon* iPhoton)
44 {
45  if(!iPhoton) return;
46 
47  // build ECAL objects
48  m_builder = new FWECALDetailViewBuilder(id.item()->getEvent(), id.item()->getGeom(),
49  iPhoton->caloPosition().eta(), iPhoton->caloPosition().phi(), 25);
51 
52  if ( iPhoton->superCluster().isAvailable() )
53  m_builder->showSuperCluster(*(iPhoton->superCluster()), kYellow);
54 
55  TEveCaloLego* lego = m_builder->build();
56  m_data = lego->GetData();
57  m_data->IncDenyDestroy();
58  m_eveScene->AddElement(lego);
59 
60  // add Photon specific details
61  if( iPhoton->superCluster().isAvailable() )
62  addSceneInfo(iPhoton, m_eveScene);
63 
64  // draw axis at the window corners
65  TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
66  overlay->SetShowPlane(kFALSE);
67  overlay->SetShowPerspective(kFALSE);
68  overlay->SetCaloLego(lego);
69  overlay->SetShowScales(1); // temporary
70  viewerGL()->AddOverlayElement(overlay);
71 
72  // set event handler and flip camera to top view at beginning
73  viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
74  FWGLEventHandler* eh =
75  new FWGLEventHandler((TGWindow*)viewerGL()->GetGLWidget(), (TObject*)viewerGL(), lego);
76  viewerGL()->SetEventHandler(eh);
77  viewerGL()->UpdateScene();
78  viewerGL()->CurrentCamera().Reset();
79 
80  viewerGL()->RequestDraw(TGLRnrCtx::kLODHigh);
81 
82  setTextInfo(id, iPhoton);
83 }
84 
85 //______________________________________________________________________________
86 
87 void
89 {
90  m_infoCanvas->cd();
91  float_t x = 0.02;
92  float y = 0.97;
93  TLatex* latex = new TLatex(x, y, "");
94  const double textsize(0.05);
95  latex->SetTextSize(2*textsize);
96 
97  float h = latex->GetTextSize()*0.6;
98  latex->DrawLatex(x, y, id.item()->modelName(id.index()).c_str() );
99  y -= h;
100 
101  latex->DrawLatex(x, y, Form(" E_{T} = %.1f GeV, #eta = %0.2f, #varphi = %0.2f",
102  photon->et(), photon->eta(), photon->phi()) );
103  y -= h;
104  m_builder->makeLegend(x, y);
105 }
106 
107 //______________________________________________________________________________
108 
109 void
110 FWPhotonDetailView::addSceneInfo(const reco::Photon *i, TEveElementList* tList)
111 {
112  unsigned int subdetId(0);
113  if ( !i->superCluster()->seed()->hitsAndFractions().empty() )
114  subdetId = i->superCluster()->seed()->hitsAndFractions().front().first.subdetId();
115 
116  // points for centroids
117  Double_t x(0), y(0), z(0);
118  TEvePointSet *scposition = new TEvePointSet("sc position");
119  scposition->SetPickable(kTRUE);
120  scposition->SetTitle("Super cluster centroid");
121  if (subdetId == EcalBarrel) {
122  x = i->caloPosition().eta();
123  y = i->caloPosition().phi();
124  } else if (subdetId == EcalEndcap) {
125  x = i->caloPosition().x();
126  y = i->caloPosition().y();
127  }
128  scposition->SetNextPoint(x,y,z);
129  scposition->SetMarkerSize(1);
130  scposition->SetMarkerStyle(4);
131  scposition->SetMarkerColor(kBlue);
132  tList->AddElement(scposition);
133 
134  // points for seed position
135  TEvePointSet *seedposition = new TEvePointSet("seed position");
136  seedposition->SetTitle("Seed cluster centroid");
137  seedposition->SetPickable(kTRUE);
138  if (subdetId == EcalBarrel) {
139  x = i->superCluster()->seed()->position().eta();
140  y = i->superCluster()->seed()->position().phi();
141  seedposition->SetMarkerSize(0.01);
142  } else if (subdetId == EcalEndcap) {
143  x = i->superCluster()->seed()->position().x();
144  y = i->superCluster()->seed()->position().y();
145  seedposition->SetMarkerSize(1);
146  }
147  seedposition->SetNextPoint(x, y, z);
148  seedposition->SetMarkerStyle(2);
149  seedposition->SetMarkerColor(kRed);
150  tList->AddElement(seedposition);
151 }
152 
void showSuperCluster(const reco::SuperCluster &cluster, Color_t color=kYellow)
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
TGLViewer * viewerGL() const
double makeLegend(double x0=0.02, double y0=0.95, Color_t clustered1=kGreen+1, Color_t clustered2=kTeal, Color_t supercluster=kYellow)
const FWEventItem * item()
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:58
bool isAvailable() const
Definition: Ref.h:276
float float float z
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
FWECALDetailViewBuilder * m_builder
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:80
virtual void build(const FWModelId &id, const reco::Photon *)
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
TEveCaloData * m_data
void showSuperClusters(Color_t color1=kGreen+2, Color_t color2=kTeal)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void addSceneInfo(const reco::Photon *, TEveElementList *)
virtual void setTextInfo(const FWModelId &id, const reco::Photon *)
#define REGISTER_FWDETAILVIEW(_classname_, _name_)
Definition: DDAxes.h:10