CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

FWRPZView Class Reference

#include <Fireworks/Core/interface/FWRPZView.h>

Inheritance diagram for FWRPZView:
FWEveView FWViewBase FWConfigurableParameterizable FWParameterizable FWConfigurable

List of all members.

Public Member Functions

virtual void addTo (FWConfiguration &) const
virtual void eventBegin ()
 FWRPZView (TEveWindowSlot *iParent, FWViewType::EType)
virtual TEveCaloViz * getEveCalo () const
void importElements (TEveElement *iProjectableChild, float layer, TEveElement *iProjectedParent=0)
virtual void populateController (ViewerParameterGUI &) const
void resetOrigin ()
virtual void setContext (const fireworks::Context &)
virtual void setFrom (const FWConfiguration &)
void shiftOrigin (TEveVector &center)
virtual void voteCaloMaxVal ()
virtual ~FWRPZView ()

Private Member Functions

void doCompression (bool)
void doFishEyeDistortion ()
void doPreScaleDistortion ()
void doShiftOriginToBeamSpot ()
 FWRPZView (const FWRPZView &)
const FWRPZViewoperator= (const FWRPZView &)
void projectionAxesLabelSize ()
void setEtaRng ()
void showProjectionAxes ()

Private Attributes

TEveProjectionAxes * m_axes
TEveCalo2D * m_calo
FWDoubleParameter m_caloDistortion
FWBoolParameter m_compressMuon
FWDoubleParameter m_fishEyeDistortion
FWDoubleParameter m_fishEyeR
FWDoubleParameter m_muonDistortion
FWDoubleParameter m_projectionAxesLabelSize
TEveProjectionManager * m_projMgr
FWBoolParameter m_shiftOrigin
FWBoolParameterm_showEndcaps
FWBoolParameterm_showHF
FWBoolParameter m_showProjectionAxes

Static Private Attributes

static const float s_distortF = 0.001
static const float s_distortFInv = 1000
static FWRPZViewGeometrys_geometryList = 0

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 41 of file FWRPZView.h.


Constructor & Destructor Documentation

FWRPZView::FWRPZView ( TEveWindowSlot *  iParent,
FWViewType::EType  id 
)

Definition at line 51 of file FWRPZView.cc.

References fireworks::Context::caloR1(), FWGenericParameter< T >::changed_, doCompression(), doFishEyeDistortion(), doPreScaleDistortion(), doShiftOriginToBeamSpot(), FWEveView::eventScene(), FWEveView::geoScene(), FWViewType::kRhoPhi, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, m_axes, m_caloDistortion, m_compressMuon, m_fishEyeDistortion, m_fishEyeR, m_muonDistortion, m_projectionAxesLabelSize, m_projMgr, m_shiftOrigin, m_showEndcaps, m_showHF, m_showProjectionAxes, projectionAxesLabelSize(), s_distortF, setEtaRng(), showProjectionAxes(), FWGenericParameter< T >::value(), and FWEveView::viewerGL().

                                                                :
   FWEveView(iParent, id, 7),
   m_calo(0),
   m_shiftOrigin(this,"Shift origin to beam-spot", true),
   m_fishEyeDistortion(this,"Distortion",0., 0., 100.),
   m_fishEyeR(this,"FixedRadius",(double)fireworks::Context::caloR1(), 0.0, 150.0),

   m_caloDistortion(this,"Calo compression",1.0,0.01,10.),
   m_muonDistortion(this,"Muon compression",0.2,0.01,10.),
   m_showProjectionAxes(this,"Show projection axis", false),
   m_projectionAxesLabelSize(this,"Projection axis label size", 0.015, 0.001, 0.2),
   m_compressMuon(this,"Compress detectors",false),
   m_showHF(0),
   m_showEndcaps(0)
{

   TEveProjection::EPType_e projType = (id == FWViewType::kRhoZ) ? TEveProjection::kPT_RhoZ : TEveProjection::kPT_RPhi;

   m_projMgr = new TEveProjectionManager(projType);
   m_projMgr->IncDenyDestroy();
   m_projMgr->SetImportEmpty(kTRUE);

   m_projMgr->GetProjection()->SetDistortion(m_fishEyeDistortion.value()*s_distortF);
   m_projMgr->GetProjection()->SetFixR(m_fishEyeR.value());
         
#ifdef TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
   m_projMgr->GetProjection()->SetDisplaceOrigin( m_shiftOrigin.value());
#endif

   if ( id == FWViewType::kRhoPhi || id == FWViewType::kRhoPhiPF) {
      m_projMgr->GetProjection()->AddPreScaleEntry(0, fireworks::Context::caloR1(), 1.0);
      m_projMgr->GetProjection()->AddPreScaleEntry(0, 300, 0.2);
   } else {
      m_projMgr->GetProjection()->AddPreScaleEntry(0, fireworks::Context::caloR1(), 1.0);
      m_projMgr->GetProjection()->AddPreScaleEntry(1, 310, 1.0);
      m_projMgr->GetProjection()->AddPreScaleEntry(0, 370, 0.2);
      m_projMgr->GetProjection()->AddPreScaleEntry(1, 580, 0.2);
   }
 

   // camera  
   viewerGL()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
   if ( TGLOrthoCamera* camera = dynamic_cast<TGLOrthoCamera*>( &(viewerGL()->CurrentCamera()) ) ) {
      camera->SetZoomMax(1e6);
   }
   geoScene()->GetGLScene()->SetSelectable(kFALSE);

   m_axes = new TEveProjectionAxes(m_projMgr);
   m_axes->SetRnrState(m_showProjectionAxes.value());
   m_axes->SetLabelSize(m_projectionAxesLabelSize.value());
   m_showProjectionAxes.changed_.connect(boost::bind(&FWRPZView::showProjectionAxes,this));
   m_projectionAxesLabelSize.changed_.connect(boost::bind(&FWRPZView::projectionAxesLabelSize,this));
   eventScene()->AddElement(m_axes);

   if ( id != FWViewType::kRhoZ ) {
      m_showEndcaps = new FWBoolParameter(this,"Include EndCaps", true);
      m_showEndcaps->changed_.connect(  boost::bind(&FWRPZView::setEtaRng, this) );
      m_showHF = new FWBoolParameter(this,"Include HF", true);
      m_showHF->changed_.connect(  boost::bind(&FWRPZView::setEtaRng, this) );
   }

   m_shiftOrigin.changed_.connect(boost::bind(&FWRPZView::doShiftOriginToBeamSpot,this));

   m_fishEyeDistortion.changed_.connect(boost::bind(&FWRPZView::doFishEyeDistortion,this));
   m_fishEyeR.changed_.connect(boost::bind(&FWRPZView::doFishEyeDistortion,this));

   m_caloDistortion.changed_.connect(boost::bind(&FWRPZView::doPreScaleDistortion,this));
   m_muonDistortion.changed_.connect(boost::bind(&FWRPZView::doPreScaleDistortion,this));
   m_compressMuon.changed_.connect(boost::bind(&FWRPZView::doCompression,this,_1));
}
FWRPZView::~FWRPZView ( ) [virtual]

Definition at line 122 of file FWRPZView.cc.

References m_calo, and m_projMgr.

{
   m_calo->Destroy();
   m_projMgr->DecDenyDestroy();
}
FWRPZView::FWRPZView ( const FWRPZView ) [private]

Member Function Documentation

void FWRPZView::addTo ( FWConfiguration iTo) const [virtual]

Reimplemented from FWEveView.

Definition at line 295 of file FWRPZView.cc.

References FWEveView::addToOrthoCamera(), and FWEveView::viewerGL().

{
   FWEveView::addTo(iTo);
   TGLOrthoCamera* camera = dynamic_cast<TGLOrthoCamera*>( &(viewerGL()->CurrentCamera()) );
   if (camera) addToOrthoCamera(camera, iTo);
}
void FWRPZView::doCompression ( bool  flag) [private]

Definition at line 273 of file FWRPZView.cc.

References m_projMgr.

Referenced by FWRPZView().

{
   m_projMgr->GetProjection()->SetUsePreScale(flag);
   m_projMgr->UpdateName();
   m_projMgr->ProjectChildren();
   gEve->Redraw3D();
}
void FWRPZView::doFishEyeDistortion ( ) [private]

Definition at line 243 of file FWRPZView.cc.

References m_fishEyeDistortion, m_fishEyeR, m_projMgr, L1TEmulatorMonitor_cff::p, s_distortF, s_distortFInv, and FWGenericParameter< T >::value().

Referenced by FWRPZView().

{
   TEveProjection* p = m_projMgr->GetProjection();
    if (p->GetDistortion() != m_fishEyeDistortion.value()*s_distortFInv)
   p->SetDistortion(m_fishEyeDistortion.value()*s_distortF);
   if (p->GetFixR() != m_fishEyeR.value())
      p->SetFixR(m_fishEyeR.value());

   m_projMgr->ProjectChildren();
   gEve->Redraw3D();
}
void FWRPZView::doPreScaleDistortion ( ) [private]

Definition at line 256 of file FWRPZView.cc.

References FWViewType::kRhoPhi, FWViewType::kRhoPhiPF, m_caloDistortion, m_muonDistortion, m_projMgr, FWViewBase::typeId(), and FWGenericParameter< T >::value().

Referenced by FWRPZView().

{
   if ( typeId() == FWViewType::kRhoPhi || typeId() == FWViewType::kRhoPhiPF ) {
      m_projMgr->GetProjection()->ChangePreScaleEntry(0,1,m_caloDistortion.value());
      m_projMgr->GetProjection()->ChangePreScaleEntry(0,2,m_muonDistortion.value());
   } else {
      m_projMgr->GetProjection()->ChangePreScaleEntry(0,1,m_caloDistortion.value());
      m_projMgr->GetProjection()->ChangePreScaleEntry(0,2,m_muonDistortion.value());
      m_projMgr->GetProjection()->ChangePreScaleEntry(1,1,m_caloDistortion.value());
      m_projMgr->GetProjection()->ChangePreScaleEntry(1,2,m_muonDistortion.value());
   }
   m_projMgr->UpdateName();
   m_projMgr->ProjectChildren();
   gEve->Redraw3D();
}
void FWRPZView::doShiftOriginToBeamSpot ( ) [private]

Definition at line 194 of file FWRPZView.cc.

References m_projMgr, m_shiftOrigin, L1TEmulatorMonitor_cff::p, and FWGenericParameter< T >::value().

Referenced by FWRPZView().

{ 
#ifdef TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE

   TEveProjection* p = m_projMgr->GetProjection();
   if (p->GetDisplaceOrigin() != m_shiftOrigin.value())
   {
      p->SetDisplaceOrigin( m_shiftOrigin.value());
      m_projMgr->ProjectChildren();
      gEve->Redraw3D();
   }
#endif
}
void FWRPZView::eventBegin ( ) [virtual]

Reimplemented from FWEveView.

Definition at line 167 of file FWRPZView.cc.

References b, FWEveView::context(), fwLog, fireworks::Context::getBeamSpot(), fwlog::kDebug, FWViewType::kRhoZ, m_projMgr, csvReporter::r, FWViewBase::typeId(), FWViewBase::typeName(), FWEveView::viewerGL(), FWBeamSpot::x0(), FWBeamSpot::y0(), and FWBeamSpot::z0().

{  
   if (context().getBeamSpot())
   {
      FWBeamSpot& b = *(context().getBeamSpot());
      fwLog(fwlog::kDebug) << Form("%s::eventBegin Set projection center (%f, %f, %f) \n", typeName().c_str(), b.x0(), b.y0(), b.z0());

      // projection center
      TEveVector center(b.x0(),  b.y0(), b.z0());
      m_projMgr->GetProjection()->SetCenter(center);

      // camera move
      TGLCamera& cam = viewerGL()->CurrentCamera();
      cam.SetExternalCenter(true);
      if (typeId() != FWViewType::kRhoZ)
      {
         double r = TMath::Sqrt( b.x0()*b.x0() +  b.y0()*b.y0());
         cam.SetCenterVec(b.z0(), TMath::Sign(r, b.y0()), 0);
      }
      else
      {
         cam.SetCenterVec(b.x0(), b.y0(), b.z0());
      }
   }
}
TEveCaloViz * FWRPZView::getEveCalo ( ) const [virtual]

Reimplemented from FWEveView.

Definition at line 133 of file FWRPZView.cc.

References m_calo.

{
   return static_cast<TEveCaloViz*>(m_calo);
}
void FWRPZView::importElements ( TEveElement *  iProjectableChild,
float  layer,
TEveElement *  iProjectedParent = 0 
)

Definition at line 282 of file FWRPZView.cc.

References m_projMgr.

Referenced by addElements(), and FWEveViewManager::finishViewCreate().

{
   float oldLayer = m_projMgr->GetCurrentDepth();
   m_projMgr->SetCurrentDepth(iLayer);
   //make sure current depth is reset even if an exception is thrown
   boost::shared_ptr<TEveProjectionManager> sentry(m_projMgr,
                                                   boost::bind(&TEveProjectionManager::SetCurrentDepth,
                                                               _1,oldLayer));
   m_projMgr->ImportElements(iChildren,iProjectedParent);
}
const FWRPZView& FWRPZView::operator= ( const FWRPZView ) [private]
void FWRPZView::populateController ( ViewerParameterGUI gui) const [virtual]

Reimplemented from FWEveView.

Definition at line 379 of file FWRPZView.cc.

References ViewerParameterGUI::addParam(), f, ViewerParameterGUI::getTabContainer(), FWViewType::kRhoPhi, FWViewType::kRhoPhiPF, m_caloDistortion, m_compressMuon, m_fishEyeDistortion, m_fishEyeR, m_muonDistortion, m_projectionAxesLabelSize, m_shiftOrigin, m_showEndcaps, m_showHF, m_showProjectionAxes, ViewerParameterGUI::requestTab(), and FWViewBase::typeId().

{
   FWEveView::populateController(gui);   

#ifdef TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
   gui.requestTab("Projection").addParam(&m_shiftOrigin);
#endif

   gui.requestTab("Projection").
   addParam(&m_showProjectionAxes).
   addParam(&m_projectionAxesLabelSize).
   separator();

   TGCompositeFrame* f = gui.getTabContainer();

   f->AddFrame(new TGLabel(f, "FishEye:"));
   gui.addParam(&m_fishEyeDistortion).
      addParam(&m_fishEyeR).
      separator();

   f->AddFrame(new TGLabel(f, "PreScales:"));

   gui.requestTab("Projection").
      addParam(&m_compressMuon).
      addParam(&m_muonDistortion).
      addParam(&m_caloDistortion);


   if (typeId() == FWViewType::kRhoPhi || typeId() == FWViewType::kRhoPhiPF) 
   {
      gui.requestTab("Calo").
         addParam(m_showHF).
         addParam(m_showEndcaps);
   }
}
void FWRPZView::projectionAxesLabelSize ( ) [private]

Definition at line 372 of file FWRPZView.cc.

References m_axes, m_projectionAxesLabelSize, FWGenericParameter< T >::value(), and FWEveView::viewerGL().

Referenced by FWRPZView().

{   
   m_axes->SetLabelSize(m_projectionAxesLabelSize.value());
   viewerGL()->RequestDraw();
}
void FWRPZView::resetOrigin ( )

Definition at line 227 of file FWRPZView.cc.

References b, FWEveView::context(), fireworks::Context::getBeamSpot(), m_projMgr, FWBeamSpot::x0(), FWBeamSpot::y0(), and FWBeamSpot::z0().

Referenced by FWViewContextMenuHandlerGL::select().

{ 
   // set center back to beam spot

#ifdef TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
   FWBeamSpot& b = *(context().getBeamSpot());
   TEveVector center(b.x0(),  b.y0(), b.z0());
   m_projMgr->GetProjection()->SetCenter(center);

   m_projMgr->ProjectChildren();
   gEve->Redraw3D();
#endif
}
void FWRPZView::setContext ( const fireworks::Context ctx) [virtual]

Reimplemented from FWEveView.

Definition at line 139 of file FWRPZView.cc.

References FWPFUtils::caloR1(), FWPFUtils::caloZ1(), FWEveView::context(), runTheMatrix::data, FWEveView::eventScene(), FWEveView::geoScene(), fireworks::Context::getCaloData(), FWRPZViewGeometry::getGeoElements(), FWViewType::kRhoPhiPF, m_calo, m_projMgr, s_geometryList, and FWViewBase::typeId().

{
   FWEveView::setContext(ctx);

   if (!s_geometryList)
   {
      s_geometryList = new  FWRPZViewGeometry(ctx);
      s_geometryList->IncDenyDestroy();
   }
   m_projMgr->ImportElements(s_geometryList->getGeoElements(typeId()), geoScene());

   TEveCaloData* data = context().getCaloData();

   TEveCalo3D* calo3d = new TEveCalo3D(data);

   m_calo = static_cast<TEveCalo2D*> (m_projMgr->ImportElements(calo3d, eventScene()));

   if (typeId() == FWViewType::kRhoPhiPF)
      m_calo->SetBarrelRadius(177);
   else
      m_calo->SetBarrelRadius(context().caloR1(false));

   m_calo->SetEndCapPos(context().caloZ1(false));
   m_calo->SetAutoRange(false);
   m_calo->SetScaleAbs(true);
}
void FWRPZView::setEtaRng ( ) [private]

Definition at line 319 of file FWRPZView.cc.

References fireworks::Context::caloMaxEta(), fireworks::Context::caloTransEta(), FWEveView::context(), FWViewType::kRhoZ, m_calo, m_showEndcaps, m_showHF, FWEveView::setupEnergyScale(), FWViewBase::typeId(), and FWGenericParameter< T >::value().

Referenced by FWRPZView().

{
   if (typeId() != FWViewType::kRhoZ)
   {
      // rng controllers only in RhoPhi
      double eta_range = context().caloMaxEta();
      if (!m_showHF->value() ) eta_range = 3.0;
      if (!m_showEndcaps->value() ) eta_range = context().caloTransEta();
      m_calo->SetEta(-eta_range,eta_range);
   }

   FWEveView::setupEnergyScale();
}
void FWRPZView::setFrom ( const FWConfiguration iFrom) [virtual]

Reimplemented from FWEveView.

Definition at line 303 of file FWRPZView.cc.

References m_showProjectionAxes, FWGenericParameter< T >::set(), FWEveView::setFromOrthoCamera(), FWConfiguration::value(), relativeConstraints::value, FWConfiguration::valueForKey(), FWConfiguration::version(), and FWEveView::viewerGL().

{
   FWEveView::setFrom(iFrom);
   
   TGLOrthoCamera* camera = dynamic_cast<TGLOrthoCamera*>( &(viewerGL()->CurrentCamera()) );
   if (camera) setFromOrthoCamera(camera, iFrom);

   if (iFrom.version() < 7)
   { 
      const FWConfiguration* value = iFrom.valueForKey("Show projection axes");
      if (value)
         m_showProjectionAxes.set(value->value() == "1");
   }
}
void FWRPZView::shiftOrigin ( TEveVector &  center)

Definition at line 209 of file FWRPZView.cc.

References m_projMgr, and FWEveView::viewerGL().

Referenced by FWViewContextMenuHandlerGL::select().

{ 
#ifdef TEVEPROJECTIONS_DISPLACE_ORIGIN_MODE
   // re-project with new center
   m_projMgr->GetProjection()->SetCenter(center);
   m_projMgr->ProjectChildren();

   // draw projected center
   float* pc =  m_projMgr->GetProjection()->GetProjectedCenter();
   viewerGL()->CurrentCamera().SetExternalCenter(true);
   viewerGL()->CurrentCamera().SetCenterVec(pc[0], pc[1], pc[2]);
   viewerGL()->SetDrawCameraCenter(true);

   gEve->Redraw3D();
#endif
}
void FWRPZView::showProjectionAxes ( ) [private]

Definition at line 365 of file FWRPZView.cc.

References m_axes, m_showProjectionAxes, FWGenericParameter< T >::value(), and FWEveView::viewerGL().

Referenced by FWRPZView().

{   
   m_axes->SetRnrState(m_showProjectionAxes.value());
   gEve->Redraw3D();
   viewerGL()->RequestDraw();
}
void FWRPZView::voteCaloMaxVal ( ) [virtual]

Reimplemented from FWEveView.

Definition at line 334 of file FWRPZView.cc.

References a, FWEveView::context(), gen::k, m_calo, and fireworks::Context::voteMaxEtAndEnergy().

{
   if (! m_calo->GetData()->Empty())
   {
      m_calo->AssertCellIdCache();
      Float_t sumEt, sumE;
      TEveCaloData::CellData_t cellData;
      typedef std::vector<TEveCaloData::vCellId_t*>           vBinCells_t;
      typedef std::vector<TEveCaloData::vCellId_t*>::iterator vBinCells_i;

      vBinCells_t   cellLists = m_calo->fCellLists;
      for (vBinCells_i it = cellLists.begin(); it != cellLists.end(); it++)
      {
         TEveCaloData::vCellId_t* binCells = *it;
         if (binCells) {
            sumEt =  0; sumE = 0;
            TEveCaloData::vCellId_i a = binCells->end();
      
            for (TEveCaloData::vCellId_i k = binCells->begin(); k != a; ++k)
            { 
               m_calo->GetData()->GetCellData((*k), cellData);
               sumEt += cellData.Value(true);
               sumE  += cellData.Value(false);
            } 
            // printf("vote sum %f %f \n", sumEt , sumE);
            context().voteMaxEtAndEnergy(sumEt, sumE);
         }
      }
   }
}

Member Data Documentation

TEveProjectionAxes* FWRPZView::m_axes [private]

Definition at line 86 of file FWRPZView.h.

Referenced by FWRPZView(), projectionAxesLabelSize(), and showProjectionAxes().

TEveCalo2D* FWRPZView::m_calo [private]

Definition at line 87 of file FWRPZView.h.

Referenced by getEveCalo(), setContext(), setEtaRng(), voteCaloMaxVal(), and ~FWRPZView().

Definition at line 95 of file FWRPZView.h.

Referenced by doPreScaleDistortion(), FWRPZView(), and populateController().

Definition at line 99 of file FWRPZView.h.

Referenced by FWRPZView(), and populateController().

Definition at line 92 of file FWRPZView.h.

Referenced by doFishEyeDistortion(), FWRPZView(), and populateController().

Definition at line 93 of file FWRPZView.h.

Referenced by doFishEyeDistortion(), FWRPZView(), and populateController().

Definition at line 96 of file FWRPZView.h.

Referenced by doPreScaleDistortion(), FWRPZView(), and populateController().

Definition at line 98 of file FWRPZView.h.

Referenced by FWRPZView(), populateController(), and projectionAxesLabelSize().

TEveProjectionManager* FWRPZView::m_projMgr [private]

Definition at line 91 of file FWRPZView.h.

Referenced by doShiftOriginToBeamSpot(), FWRPZView(), and populateController().

Definition at line 102 of file FWRPZView.h.

Referenced by FWRPZView(), populateController(), and setEtaRng().

Definition at line 101 of file FWRPZView.h.

Referenced by FWRPZView(), populateController(), and setEtaRng().

Definition at line 97 of file FWRPZView.h.

Referenced by FWRPZView(), populateController(), setFrom(), and showProjectionAxes().

const float FWRPZView::s_distortF = 0.001 [static, private]

Definition at line 82 of file FWRPZView.h.

Referenced by doFishEyeDistortion(), and FWRPZView().

const float FWRPZView::s_distortFInv = 1000 [static, private]

Definition at line 83 of file FWRPZView.h.

Referenced by doFishEyeDistortion().

Definition at line 81 of file FWRPZView.h.

Referenced by setContext().