CMS 3D CMS Logo

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

FWPFEcalRecHitLegoProxyBuilder Class Reference

#include <FWPFEcalRecHitLegoProxyBuilder.h>

Inheritance diagram for FWPFEcalRecHitLegoProxyBuilder:
FWProxyBuilderTemplate< EcalRecHit > FWProxyBuilderBase

List of all members.

Public Member Functions

virtual void build (const FWEventItem *iItem, TEveElementList *product, const FWViewContext *)
TEveVector calculateCentre (const std::vector< TEveVector > &corners) const
virtual void cleanLocal ()
 FWPFEcalRecHitLegoProxyBuilder ()
float getMaxVal (bool et) const
float getMaxValLog (bool et) const
virtual bool havePerViewProduct (FWViewType::EType) const
 REGISTER_PROXYBUILDER_METHODS ()
virtual void scaleProduct (TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
virtual ~FWPFEcalRecHitLegoProxyBuilder ()

Static Public Member Functions

static std::string typeOfBuilder ()
 Used by the plugin system to determine how the proxy uses the data from FWEventItem.

Protected Member Functions

virtual void localModelChanges (const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc)

Private Member Functions

 FWPFEcalRecHitLegoProxyBuilder (const FWPFEcalRecHitLegoProxyBuilder &)
const
FWPFEcalRecHitLegoProxyBuilder
operator= (const FWPFEcalRecHitLegoProxyBuilder &)

Private Attributes

float m_maxEnergy
float m_maxEnergyLog
float m_maxEt
float m_maxEtLog
std::vector< FWPFLegoRecHit * > m_recHits

Detailed Description

Definition at line 36 of file FWPFEcalRecHitLegoProxyBuilder.h.


Constructor & Destructor Documentation

FWPFEcalRecHitLegoProxyBuilder::FWPFEcalRecHitLegoProxyBuilder ( ) [inline]

Definition at line 40 of file FWPFEcalRecHitLegoProxyBuilder.h.

virtual FWPFEcalRecHitLegoProxyBuilder::~FWPFEcalRecHitLegoProxyBuilder ( ) [inline, virtual]

Definition at line 41 of file FWPFEcalRecHitLegoProxyBuilder.h.

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

Member Function Documentation

void FWPFEcalRecHitLegoProxyBuilder::build ( const FWEventItem iItem,
TEveElementList *  product,
const FWViewContext vc 
) [virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 59 of file FWPFEcalRecHitLegoProxyBuilder.cc.

References calculateCentre(), FWPFMaths::calculateEt(), FWProxyBuilderBase::context(), FWProxyBuilderBase::createCompound(), CaloRecHit::detid(), CaloRecHit::energy(), relval_parameters_module::energy, FWGeometry::getCorners(), FWEventItem::getGeom(), i, getHLTprescales::index, FWProxyBuilderBase::item(), j, gen::k, FWViewType::kLegoPFECAL, funct::log(), m_maxEnergy, m_maxEnergyLog, m_maxEt, m_maxEtLog, m_recHits, FWProxyBuilderTemplate< EcalRecHit >::modelData(), Pi, scaleProduct(), FWPFLegoRecHit::setSquareColor(), FWEventItem::size(), and fireworks::Context::voteMaxEtAndEnergy().

{
   size_t itemSize = iItem->size(); //cache size

   for( size_t index = 0; index < itemSize; ++index )
   {
      TEveCompound *itemHolder = createCompound();
      product->AddElement( itemHolder );

      const EcalRecHit &iData = modelData( index );
      const float *corners = item()->getGeom()->getCorners( iData.detid() );
      float energy, et;
      std::vector<TEveVector> etaphiCorners(8);
      TEveVector centre;

      if( corners == 0 )
         continue;

      int k = 3;
      for( int i = 0; i < 4; ++i )
      {
         int j = k * 3;
         TEveVector cv = TEveVector( corners[j], corners[j+1], corners[j+2] );
         etaphiCorners[i].fX = cv.Eta();                                     // Conversion of rechit X/Y values for plotting in Eta/Phi
         etaphiCorners[i].fY = cv.Phi();
         etaphiCorners[i].fZ = 0.0;

         etaphiCorners[i+4].fX = etaphiCorners[i].fX;                        // Top can simply be plotted exactly over the top of the bottom face
         etaphiCorners[i+4].fY = etaphiCorners[i].fY;
         etaphiCorners[i+4].fZ = 0.001;
         // printf("%f %f %d \n",  etaphiCorners[i].fX, etaphiCorners[i].fY, i);
         --k;
      }

      centre = calculateCentre( etaphiCorners );
      energy = iData.energy();
      et = FWPFMaths::calculateEt( centre, energy );
      context().voteMaxEtAndEnergy( et, energy );

      if( energy > m_maxEnergy )
         m_maxEnergy = energy;
      if( energy > m_maxEt )
         m_maxEt = et;

      // Stop phi wrap
      float dPhi1 = etaphiCorners[2].fY - etaphiCorners[1].fY;
      float dPhi2 = etaphiCorners[3].fY - etaphiCorners[0].fY;
      float dPhi3 = etaphiCorners[1].fY - etaphiCorners[2].fY;
      float dPhi4 = etaphiCorners[0].fY - etaphiCorners[3].fY;

      if( dPhi1 > 1 )
         etaphiCorners[2].fY = etaphiCorners[2].fY - ( 2 * TMath::Pi() );
      if( dPhi2 > 1 )
         etaphiCorners[3].fY = etaphiCorners[3].fY - ( 2 * TMath::Pi() );
      if( dPhi3 > 1 )
         etaphiCorners[2].fY = etaphiCorners[2].fY + ( 2 * TMath::Pi() );
      if( dPhi4 > 1 )
         etaphiCorners[3].fY = etaphiCorners[3].fY + ( 2 * TMath::Pi() );

      FWPFLegoRecHit *recHit = new FWPFLegoRecHit( etaphiCorners, itemHolder, this, vc, energy, et );
      recHit->setSquareColor( item()->defaultDisplayProperties().color() );
      m_recHits.push_back( recHit );
   }

      m_maxEnergyLog = log( m_maxEnergy );
      m_maxEtLog = log( m_maxEt );

      scaleProduct( product, FWViewType::kLegoPFECAL, vc );
}
TEveVector FWPFEcalRecHitLegoProxyBuilder::calculateCentre ( const std::vector< TEveVector > &  corners) const

Definition at line 42 of file FWPFEcalRecHitLegoProxyBuilder.cc.

References i.

Referenced by build().

{
   TEveVector centre;

   for( size_t i = 0; i < corners.size(); ++i )
   {
      centre.fX += corners[i].fX;
      centre.fY += corners[i].fY;            // Get total for x,y,z values
      centre.fZ += corners[i].fZ;
   }
   centre *= 1.f / 8.f;

   return centre;   
}
void FWPFEcalRecHitLegoProxyBuilder::cleanLocal ( ) [virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 131 of file FWPFEcalRecHitLegoProxyBuilder.cc.

References i, and m_recHits.

{
   for( std::vector<FWPFLegoRecHit*>::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
      delete (*i);

   m_recHits.clear();
}
float FWPFEcalRecHitLegoProxyBuilder::getMaxVal ( bool  et) const [inline]

Definition at line 55 of file FWPFEcalRecHitLegoProxyBuilder.h.

References m_maxEnergy, and m_maxEt.

Referenced by scaleProduct().

{ return et ? m_maxEt : m_maxEnergy; }
float FWPFEcalRecHitLegoProxyBuilder::getMaxValLog ( bool  et) const [inline]

Definition at line 54 of file FWPFEcalRecHitLegoProxyBuilder.h.

References m_maxEnergyLog, and m_maxEtLog.

Referenced by scaleProduct().

{ return et ? m_maxEtLog : m_maxEnergyLog; }
virtual bool FWPFEcalRecHitLegoProxyBuilder::havePerViewProduct ( FWViewType::EType  ) const [inline, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 49 of file FWPFEcalRecHitLegoProxyBuilder.h.

{ return true; }
void FWPFEcalRecHitLegoProxyBuilder::localModelChanges ( const FWModelId iId,
TEveElement *  iCompound,
FWViewType::EType  viewType,
const FWViewContext vc 
) [protected, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 24 of file FWPFEcalRecHitLegoProxyBuilder.cc.

References FWDisplayProperties::color(), i, FWModelId::index(), FWProxyBuilderBase::item(), geometryCSVtoXML::line, FWEventItem::modelInfo(), and AlCaHLTBitMon_ParallelJobs::p.

{
   for (TEveElement::List_i i = parent->BeginChildren(); i!= parent->EndChildren(); ++i)
   {
      {
         TEveStraightLineSet* line = dynamic_cast<TEveStraightLineSet*>(*i);
         if (line)
         {
            const FWDisplayProperties &p = item()->modelInfo( iId.index() ).displayProperties();
            line->SetMarkerColor( p.color() );
         }
      }
   }
}
const FWPFEcalRecHitLegoProxyBuilder& FWPFEcalRecHitLegoProxyBuilder::operator= ( const FWPFEcalRecHitLegoProxyBuilder ) [private]
FWPFEcalRecHitLegoProxyBuilder::REGISTER_PROXYBUILDER_METHODS ( )
void FWPFEcalRecHitLegoProxyBuilder::scaleProduct ( TEveElementList *  parent,
FWViewType::EType  type,
const FWViewContext vc 
) [virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 5 of file FWPFEcalRecHitLegoProxyBuilder.cc.

References b, FWViewContext::getEnergyScale(), getMaxVal(), getMaxValLog(), FWViewEnergyScale::getPlotEt(), i, and m_recHits.

Referenced by build().

{
   FWViewEnergyScale *caloScale = vc->getEnergyScale();
   bool b = caloScale->getPlotEt();
   float maxVal = getMaxVal( b );
   typedef std::vector<FWPFLegoRecHit*> rh;

   // printf("FWPFEcalRecHitLegoProxyBuilder::scaleProduct >> scale %f \n", caloScale->getValToHeight());
   for( rh::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
   {  // Tallest tower needs deciding still
      if( (*i)->isTallest() == false && (*i)->getEtEnergy( b ) == maxVal )
         (*i)->setIsTallest( true );

      (*i)->updateScale( vc, getMaxValLog(caloScale->getPlotEt()));
   }
}
static std::string FWPFEcalRecHitLegoProxyBuilder::typeOfBuilder ( ) [inline, static]

Used by the plugin system to determine how the proxy uses the data from FWEventItem.

Reimplemented from FWProxyBuilderBase.

Definition at line 43 of file FWPFEcalRecHitLegoProxyBuilder.h.

{ return "simple#"; }

Member Data Documentation

Definition at line 72 of file FWPFEcalRecHitLegoProxyBuilder.h.

Referenced by build(), and getMaxVal().

Definition at line 74 of file FWPFEcalRecHitLegoProxyBuilder.h.

Referenced by build(), and getMaxValLog().

Definition at line 73 of file FWPFEcalRecHitLegoProxyBuilder.h.

Referenced by build(), and getMaxVal().

Definition at line 75 of file FWPFEcalRecHitLegoProxyBuilder.h.

Referenced by build(), and getMaxValLog().

Definition at line 76 of file FWPFEcalRecHitLegoProxyBuilder.h.

Referenced by build(), cleanLocal(), and scaleProduct().