CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FWPFLegoRecHit Class Reference

#include <FWPFLegoRecHit.h>

List of all members.

Public Member Functions

void addLine (float x1, float y1, float z1, float x2, float y2, float z2)
void addLine (const TEveVector &v1, const TEveVector &v2)
 FWPFLegoRecHit (const std::vector< TEveVector > &corners, TEveElement *comp, FWPFEcalRecHitLegoProxyBuilder *pb, const FWViewContext *vc, float e, float et)
float getEtEnergy (bool b) const
TEveBox * getTower ()
bool isTallest () const
void setIsTallest (bool b)
void setLine (int idx, float x1, float y1, float z1, float x2, float y2, float z2)
void setSquareColor (Color_t c)
void updateScale (const FWViewContext *vc)
virtual ~FWPFLegoRecHit ()

Private Member Functions

void buildLineSet (const std::vector< TEveVector > &corners, const FWViewContext *vc)
void buildTower (const std::vector< TEveVector > &corners, const FWViewContext *vc)
 FWPFLegoRecHit (const FWPFLegoRecHit &)
const FWPFLegoRecHitoperator= (const FWPFLegoRecHit &)
void setupEveBox (std::vector< TEveVector > &corners, float scale)

Private Attributes

FWPFEcalRecHitLegoProxyBuilderm_builder
float m_energy
float m_et
bool m_isTallest
TEveStraightLineSet * m_ls
TEveBox * m_tower

Detailed Description

Definition at line 34 of file FWPFLegoRecHit.h.


Constructor & Destructor Documentation

FWPFLegoRecHit::FWPFLegoRecHit ( const std::vector< TEveVector > &  corners,
TEveElement *  comp,
FWPFEcalRecHitLegoProxyBuilder pb,
const FWViewContext vc,
float  e,
float  et 
)

Definition at line 5 of file FWPFLegoRecHit.cc.

References buildLineSet(), buildTower(), m_ls, m_tower, and FWProxyBuilderBase::setupAddElement().

   : m_builder(pb), m_energy(e), m_et(et), m_isTallest(false)
{
   buildTower( corners, vc );
   buildLineSet( corners, vc );
   
   pb->setupAddElement( m_tower, comp );
   pb->setupAddElement( m_ls, comp );
}
virtual FWPFLegoRecHit::~FWPFLegoRecHit ( ) [inline, virtual]

Definition at line 40 of file FWPFLegoRecHit.h.

{}
FWPFLegoRecHit::FWPFLegoRecHit ( const FWPFLegoRecHit ) [private]

Member Function Documentation

void FWPFLegoRecHit::addLine ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2 
)

Definition at line 152 of file FWPFLegoRecHit.cc.

References m_ls.

Referenced by setIsTallest().

{
   m_ls->AddLine( x1, y1, z1, x2, y2, z2 );
}
void FWPFLegoRecHit::addLine ( const TEveVector &  v1,
const TEveVector &  v2 
)

Definition at line 159 of file FWPFLegoRecHit.cc.

References m_ls.

{
   m_ls->AddLine(v1.fX, v1.fY, v1.fZ, v2.fX, v2.fY, v2.fZ);
}
void FWPFLegoRecHit::buildLineSet ( const std::vector< TEveVector > &  corners,
const FWViewContext vc 
) [private]

Definition at line 52 of file FWPFLegoRecHit.cc.

References trackerHits::c, and m_ls.

Referenced by FWPFLegoRecHit().

{
   m_ls = new TEveStraightLineSet( "EcalRecHitLineSet" );

   // no need to set anything, all is re-set in updateScales()
   // reserve space for square outline
   TEveVector c;
   m_ls->AddLine( c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ );
   m_ls->AddLine( c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ );
   m_ls->AddLine( c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ );
   m_ls->AddLine( c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ );

   // last line is trick to add a marker in line set
   m_ls->SetMarkerStyle( 1 );
   m_ls->AddLine( c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ );
   m_ls->AddMarker( 0, 0. );
}
void FWPFLegoRecHit::buildTower ( const std::vector< TEveVector > &  corners,
const FWViewContext vc 
) [private]

Definition at line 36 of file FWPFLegoRecHit.cc.

References FWViewContext::getEnergyScale(), FWViewEnergyScale::getPlotEt(), FWViewEnergyScale::getScaleFactorLego(), m_energy, m_et, m_tower, and setupEveBox().

Referenced by FWPFLegoRecHit().

{
   m_tower = new TEveBox( "EcalRecHitTower" );
   std::vector<TEveVector> towerCorners = corners;
   FWViewEnergyScale *caloScale = vc->getEnergyScale();
   float val = caloScale->getPlotEt() ? m_et : m_energy;
   float scale = caloScale->getScaleFactorLego() * val;

   if( scale < 0 )
      scale *= -1;

   setupEveBox( towerCorners, scale );
}
float FWPFLegoRecHit::getEtEnergy ( bool  b) const [inline]

Definition at line 50 of file FWPFLegoRecHit.h.

References m_energy, and m_et.

{ return b ? m_et : m_energy; }
TEveBox* FWPFLegoRecHit::getTower ( ) [inline]

Definition at line 46 of file FWPFLegoRecHit.h.

References m_tower.

{ return m_tower; }
bool FWPFLegoRecHit::isTallest ( ) const [inline]

Definition at line 51 of file FWPFLegoRecHit.h.

References m_isTallest.

{ return m_isTallest; }
const FWPFLegoRecHit& FWPFLegoRecHit::operator= ( const FWPFLegoRecHit ) [private]
void FWPFLegoRecHit::setIsTallest ( bool  b)

Definition at line 138 of file FWPFLegoRecHit.cc.

References addLine(), b, and m_isTallest.

{
   m_isTallest = b;
   
   if( m_isTallest )
   {
      TEveVector vec;
      addLine( vec, vec );
      addLine( vec, vec );
   }
}
void FWPFLegoRecHit::setLine ( int  idx,
float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2 
)

Definition at line 121 of file FWPFLegoRecHit.cc.

References prof2calltree::l, and m_ls.

Referenced by updateScale().

{
   // AMT: this func should go in TEveStraightLineSet class

   TEveStraightLineSet::Line_t* l = ((TEveStraightLineSet::Line_t*)(m_ls->GetLinePlex().Atom(idx)));

   l->fV1[0] = x1;
   l->fV1[1] = y1;
   l->fV1[2] = z1; 

   l->fV2[0] = x2;
   l->fV2[1] = y2;
   l->fV2[2] = z2;
}
void FWPFLegoRecHit::setSquareColor ( Color_t  c) [inline]

Definition at line 44 of file FWPFLegoRecHit.h.

References m_ls.

Referenced by FWPFEcalRecHitLegoProxyBuilder::build().

{ m_ls->SetMarkerColor(c); m_ls->SetLineColor(kBlack); }
void FWPFLegoRecHit::setupEveBox ( std::vector< TEveVector > &  corners,
float  scale 
) [private]

Definition at line 18 of file FWPFLegoRecHit.cc.

References i, j, and m_tower.

Referenced by buildTower().

{
   for( size_t i = 0; i < 4; ++i )
   {
      int j = i + 4;
      corners[i+4].fZ = corners[i].fZ + scale;
      m_tower->SetVertex( i, corners[i] );
      m_tower->SetVertex( j, corners[j] );
   }

   m_tower->SetPickable( true );
   m_tower->SetDrawFrame(false);
   m_tower->SetLineWidth( 1.0 );
   m_tower->SetLineColor( kBlack );
}
void FWPFLegoRecHit::updateScale ( const FWViewContext vc)

Definition at line 72 of file FWPFLegoRecHit.cc.

References trackerHits::c, AlCaHLTBitMon_QueryRunRegistry::data, FWViewContext::getEnergyScale(), FWPFEcalRecHitLegoProxyBuilder::getMaxValLog(), FWViewEnergyScale::getPlotEt(), FWViewEnergyScale::getScaleFactorLego(), i, funct::log(), m, m_builder, m_energy, m_et, m_isTallest, m_ls, m_tower, asciidump::s, setLine(), and z.

{
   FWViewEnergyScale *caloScale = vc->getEnergyScale();
   float val = caloScale->getPlotEt() ? m_et : m_energy;
   float scale = caloScale->getScaleFactorLego() * val;

   // printf("scale %f %f\n",  caloScale->getValToHeight(), val);

   if( scale < 0 )
      scale *= -1;

   // Reposition top points of tower
   const float *data;
   TEveVector c;
   for( unsigned int i = 0; i < 4; ++i )
   {
      data = m_tower->GetVertex( i );
      c.fX += data[0];
      c.fY += data[1];
      m_tower->SetVertex( i, data[0], data[1], 0 );
      m_tower->SetVertex( i+4,  data[0], data[1], scale);
   }
   c *= 0.25;
   // Scale lineset 
   float s = log( 1 + val ) / m_builder->getMaxValLog(caloScale->getPlotEt());
   float d = 0.5 * ( m_tower->GetVertex(1)[0]  -m_tower->GetVertex(0)[0]);
   d *= s;
   float z =  scale * 1.001;
   setLine(0, c.fX - d, c.fY -d, z, c.fX + d, c.fY -d, z);
   setLine(1, c.fX + d, c.fY -d, z, c.fX + d, c.fY +d, z);
   setLine(2, c.fX + d, c.fY +d, z, c.fX - d, c.fY +d, z);
   setLine(3, c.fX - d, c.fY +d, z, c.fX - d, c.fY -d, z);

   if( m_isTallest )
   {
      // This is the tallest tower and hence two additional lines needs scaling
      setLine( 4, c.fX - d, c.fY - d, z, c.fX + d, c.fY + d, z );
      setLine( 5, c.fX - d, c.fY + d, z, c.fX + d, c.fY - d, z );
   }

   TEveStraightLineSet::Marker_t* m = ((TEveStraightLineSet::Marker_t*)(m_ls->GetMarkerPlex().Atom(0)));
   m->fV[0] = c.fX; m->fV[1] = c.fY; m->fV[2] = z;

   // stamp changed elements
   m_tower->StampTransBBox();
   m_ls->StampTransBBox();
}

Member Data Documentation

Definition at line 64 of file FWPFLegoRecHit.h.

Referenced by updateScale().

float FWPFLegoRecHit::m_energy [private]

Definition at line 67 of file FWPFLegoRecHit.h.

Referenced by buildTower(), getEtEnergy(), and updateScale().

float FWPFLegoRecHit::m_et [private]

Definition at line 68 of file FWPFLegoRecHit.h.

Referenced by buildTower(), getEtEnergy(), and updateScale().

Definition at line 69 of file FWPFLegoRecHit.h.

Referenced by isTallest(), setIsTallest(), and updateScale().

TEveStraightLineSet* FWPFLegoRecHit::m_ls [private]
TEveBox* FWPFLegoRecHit::m_tower [private]

Definition at line 65 of file FWPFLegoRecHit.h.

Referenced by buildTower(), FWPFLegoRecHit(), getTower(), setupEveBox(), and updateScale().