CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Fireworks/Candidates/src/FWLegoCandidate.cc

Go to the documentation of this file.
00001 #include "Fireworks/Candidates/interface/FWLegoCandidate.h"
00002 
00003 #include "Fireworks/Core/interface/Context.h"
00004 #include "Fireworks/Core/interface/FWViewContext.h"
00005 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00006 
00007 //______________________________________________________________________________
00008 FWLegoCandidate::FWLegoCandidate( const FWViewContext *vc, const fireworks::Context &context, float energy, float et, float pt,
00009                                       float eta, float phi )
00010 : m_energy(energy), m_et(et), m_pt(pt), m_eta(eta), m_phi(phi)
00011 {
00012    float base = 0.001;  // Floor offset 1%
00013 
00014    // First vertical line
00015    FWViewEnergyScale *caloScale = vc->getEnergyScale();
00016    float val = caloScale->getPlotEt() ? m_pt : m_energy;    // Use pt instead of et
00017 
00018    AddLine( m_eta, m_phi, base,
00019             m_eta, m_phi, base + val * caloScale->getScaleFactorLego() );
00020 
00021    AddMarker( 0, 1.f );
00022    SetMarkerStyle( 3 );
00023    SetMarkerSize( 0.01 );
00024    SetDepthTest( false );
00025 
00026    // Circle pt
00027    const unsigned int nLineSegments = 20;
00028    const double radius = log( 1 + m_pt ) / log(10) / 30.f;
00029    //const double radius = m_pt / 100.f;
00030    const double twoPi = 2 * TMath::Pi();
00031 
00032    for( unsigned int iPhi = 0; iPhi < nLineSegments; ++iPhi )
00033    {
00034       AddLine( m_eta + radius * cos( twoPi / nLineSegments * iPhi ),
00035                m_phi + radius * sin( twoPi / nLineSegments * iPhi ),
00036                base,
00037                m_eta + radius * cos( twoPi / nLineSegments * ( iPhi + 1 ) ),
00038                m_phi + radius * sin( twoPi / nLineSegments * ( iPhi + 1 ) ),
00039                base );
00040    }
00041 }
00042 
00043 //______________________________________________________________________________
00044 void
00045 FWLegoCandidate::updateScale( const FWViewContext *vc, const fireworks::Context &context )
00046 {
00047    FWViewEnergyScale *caloScale = vc->getEnergyScale();
00048    float val = caloScale->getPlotEt() ? m_pt : m_energy; // Use pt instead of et
00049    float scaleFac = caloScale->getScaleFactorLego();
00050 
00051    // Resize first line
00052    TEveChunkManager::iterator li( GetLinePlex() );
00053    li.next();
00054    TEveStraightLineSet::Line_t &l = * ( TEveStraightLineSet::Line_t* ) li();
00055    l.fV2[2] = l.fV1[2] + val * scaleFac;
00056 
00057    // Move end point (marker)
00058    TEveChunkManager::iterator mi( GetMarkerPlex() );
00059    mi.next();
00060    TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
00061    m.fV[2] = l.fV2[2];   // Set to new top of line
00062 }