CMS 3D CMS Logo

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

FWHFTowerProxyBuilderBase Class Reference

#include <FWHFTowerProxyBuilder.h>

Inheritance diagram for FWHFTowerProxyBuilderBase:
FWCaloDataProxyBuilderBase FWProxyBuilderBase

List of all members.

Public Member Functions

 FWHFTowerProxyBuilderBase ()
 REGISTER_PROXYBUILDER_METHODS ()
virtual ~FWHFTowerProxyBuilderBase ()

Protected Member Functions

virtual bool assertCaloDataSlice ()
virtual void fillCaloData ()
virtual void itemBeingDestroyed (const FWEventItem *)
virtual void setCaloData (const fireworks::Context &)

Private Member Functions

virtual void build (const FWEventItem *iItem, TEveElementList *product, const FWViewContext *)
int fillTowerForDetId (unsigned int rawid, float)
 FWHFTowerProxyBuilderBase (const FWHFTowerProxyBuilderBase &)
const FWHFTowerProxyBuilderBaseoperator= (const FWHFTowerProxyBuilderBase &)

Private Attributes

const HFRecHitCollectionm_hits
TEveCaloDataVec * m_vecData

Detailed Description

Definition at line 34 of file FWHFTowerProxyBuilder.h.


Constructor & Destructor Documentation

FWHFTowerProxyBuilderBase::FWHFTowerProxyBuilderBase ( )

Definition at line 29 of file FWHFTowerProxyBuilder.cc.

                                                    :
   m_hits(0),
   // m_depth(depth),
   m_vecData(0)
{}
FWHFTowerProxyBuilderBase::~FWHFTowerProxyBuilderBase ( ) [virtual]

Definition at line 35 of file FWHFTowerProxyBuilder.cc.

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

Member Function Documentation

bool FWHFTowerProxyBuilderBase::assertCaloDataSlice ( ) [protected, virtual]

Implements FWCaloDataProxyBuilderBase.

Definition at line 48 of file FWHFTowerProxyBuilder.cc.

References FWFromTEveCaloDataSelector::addSliceSelector(), newFWLiteAna::base, FWProxyBuilderBase::item(), FWCaloDataProxyBuilderBase::m_caloData, FWCaloDataProxyBuilderBase::m_sliceIndex, m_vecData, AlCaRecoCosmics_cfg::name, and runTheMatrix::sel.

{
   if (m_sliceIndex == -1)
   {
      m_sliceIndex = m_vecData->AddSlice();
      // printf("add slice %d \n",m_sliceIndex  );
      m_caloData->RefSliceInfo(m_sliceIndex).Setup(item()->name().c_str() , 0.,
                                                   item()->defaultDisplayProperties().color(),
                                                   item()->defaultDisplayProperties().transparency());
    
      // add new selector
      FWFromTEveCaloDataSelector* sel = 0;
      if (m_caloData->GetUserData())
      {
         FWFromEveSelectorBase* base = reinterpret_cast<FWFromEveSelectorBase*>(m_caloData->GetUserData());
         assert(0!=base);
         sel = dynamic_cast<FWFromTEveCaloDataSelector*> (base);
         assert(0!=sel);
      }
      else
      {
         sel = new FWFromTEveCaloDataSelector(m_caloData);
         //make sure it is accessible via the base class
         m_caloData->SetUserData(static_cast<FWFromEveSelectorBase*>(sel));
      }
    
      sel->addSliceSelector(m_sliceIndex, new FWHFTowerSliceSelector(item(), m_vecData));
    
      return true;
   }
   return false;
}
void FWHFTowerProxyBuilderBase::build ( const FWEventItem iItem,
TEveElementList *  product,
const FWViewContext ctx 
) [private, virtual]

Reimplemented from FWCaloDataProxyBuilderBase.

Definition at line 82 of file FWHFTowerProxyBuilder.cc.

References FWProxyBuilderBase::build(), FWEventItem::get(), and m_hits.

{
   m_hits=0;
   if (iItem)
   {
      iItem->get(m_hits);
      FWCaloDataProxyBuilderBase::build(iItem, el, ctx);
   }
}
void FWHFTowerProxyBuilderBase::fillCaloData ( ) [protected, virtual]

Implements FWCaloDataProxyBuilderBase.

Definition at line 112 of file FWHFTowerProxyBuilder.cc.

References edm::SortedCollection< T, SORT >::begin(), FWEventItem::ModelInfo::displayProperties(), edm::SortedCollection< T, SORT >::end(), fillTowerForDetId(), i, getHLTprescales::index, info, FWEventItem::ModelInfo::isSelected(), FWDisplayProperties::isVisible(), FWProxyBuilderBase::item(), m_hits, FWCaloDataProxyBuilderBase::m_sliceIndex, m_vecData, FWEventItem::modelInfo(), findQualityFiles::size, and edm::SortedCollection< T, SORT >::size().

{
   //reset values for this slice
   std::vector<float>& sliceVals = m_vecData->GetSliceVals(m_sliceIndex);
   for (std::vector<float>::iterator i = sliceVals.begin(); i!= sliceVals.end(); ++i)
   {
      *i = 0;
   }

   if (m_hits)
   {
      TEveCaloData::vCellId_t& selected = m_vecData->GetCellsSelected();

      if(item()->defaultDisplayProperties().isVisible()) {
         assert(item()->size() >= m_hits->size());

         unsigned int index=0;
         TEveCaloData::vCellId_t cellId;
         for(HFRecHitCollection::const_iterator it = m_hits->begin(); it != m_hits->end(); ++it,++index) 
         {
            const FWEventItem::ModelInfo& info = item()->modelInfo(index);
            if(info.displayProperties().isVisible())
            {
               unsigned int rawid = (*it).detid().rawId();
               int tower = fillTowerForDetId(rawid, (*it).energy());
                
               if(info.isSelected())
               {
                  selected.push_back(TEveCaloData::CellId_t(tower, m_sliceIndex));
               } 
            }
         }
      }
   }
}
int FWHFTowerProxyBuilderBase::fillTowerForDetId ( unsigned int  rawid,
float  val 
) [private]

Definition at line 149 of file FWHFTowerProxyBuilder.cc.

References ExpressReco_HICollisions_FallBack::e, eta(), prof2calltree::front, fwLog, relativeConstraints::geom, FWEventItem::getGeom(), i, FWProxyBuilderBase::item(), j, fwlog::kInfo, FWCaloDataProxyBuilderBase::m_sliceIndex, m_vecData, siStripFEDMonitor_P5_cff::Max, siStripFEDMonitor_P5_cff::Min, phi, Pi, and TwoPi.

Referenced by fillCaloData().

{
   using namespace TMath;
   const static float upPhiLimit = Pi() -10*DegToRad() -1e-5;

   TEveCaloData::vCellId_t cellIds;
   const FWGeometry *geom = item()->getGeom();
   if( ! geom->contains( rawid ))
   {
      fwLog( fwlog::kInfo ) << "FWHFTowerProxyBuilderBase cannot get geometry for DetId: "<< rawid << ". Ignored.\n";
      return -1;
   }
     
   const float* corners = geom->getCorners( rawid );
   
   std::vector<TEveVector> front( 4 );
   float eta[4], phi[4];
   bool plusSignPhi  = false;
   bool minusSignPhi = false;
   int j = 0;
   for( int i = 0; i < 4; ++i )
   {     
     front[i] = TEveVector( corners[j], corners[j + 1], corners[j + 2] );
     j += 3;
 
     eta[i] = front[i].Eta();
     phi[i] = front[i].Phi();

     // make sure sign around Pi is same as sign of fY
     phi[i] = Sign( phi[i], front[i].fY );

     ( phi[i] >= 0 ) ? plusSignPhi = true :  minusSignPhi = true;
   }

   // check for cell around phi and move up edge to negative side
   if( plusSignPhi && minusSignPhi ) 
   {
      for( int i = 0; i < 4; ++i )
      {
         if( phi[i] >= upPhiLimit ) 
         {
            //  printf("over phi max limit %f \n", phi[i]);
            phi[i] -= TwoPi();
         }
      }
   }
  
   float etaM = -10;
   float etam =  10;
   float phiM = -4;
   float phim =  4;
   for( int i = 0; i < 4; ++i )
   { 
      etam = Min( etam, eta[i] );
      etaM = Max( etaM, eta[i] );
      phim = Min( phim, phi[i] );
      phiM = Max( phiM, phi[i] );
   }

   /*
     if (phiM - phim > 1) 
     printf("!!! [%.2f %.2f] input(%.3f, %.3f, %.3f, %.3f) \n", phim, phiM, phiRef[0] , phiRef[1] , phiRef[2],  phiRef[3]);
   */

   // check if tower is there
   Float_t ceta = (etam+etaM)*0.5;
   Float_t cphi = (phim+phiM)*0.5;
   int tower = -1;
   int idx = 0;
   for ( TEveCaloData::vCellGeom_i i = m_vecData->GetCellGeom().begin(); i!= m_vecData->GetCellGeom().end(); ++i, ++idx)
   {
      const TEveCaloData::CellGeom_t &cg = *i;
      if ((ceta > cg.fEtaMin && ceta < cg.fEtaMax) && (cphi > cg.fPhiMin && cphi < cg.fPhiMax))
      {
         tower = idx;
         break;
      }
   }

   // add it if not there 
   if (tower == -1 )
   {
      tower = m_vecData->AddTower(etam, etaM, phim, phiM);
   }


   m_vecData->FillSlice(m_sliceIndex, tower, val);
   return tower; 
}
void FWHFTowerProxyBuilderBase::itemBeingDestroyed ( const FWEventItem iItem) [protected, virtual]

Reimplemented from FWCaloDataProxyBuilderBase.

Definition at line 94 of file FWHFTowerProxyBuilder.cc.

References i, m_hits, FWCaloDataProxyBuilderBase::m_sliceIndex, and m_vecData.

{
  
   if(0!=m_hits) {

      //reset values for this slice
      std::vector<float>& sliceVals = m_vecData->GetSliceVals(m_sliceIndex);
      for (std::vector<float>::iterator i = sliceVals.begin(); i!= sliceVals.end(); ++i)
      {
         *i = 0;
      }


   }
   FWCaloDataProxyBuilderBase::itemBeingDestroyed(iItem);
}
const FWHFTowerProxyBuilderBase& FWHFTowerProxyBuilderBase::operator= ( const FWHFTowerProxyBuilderBase ) [private]
FWHFTowerProxyBuilderBase::REGISTER_PROXYBUILDER_METHODS ( )
void FWHFTowerProxyBuilderBase::setCaloData ( const fireworks::Context ctx) [protected, virtual]

Member Data Documentation

Definition at line 66 of file FWHFTowerProxyBuilder.h.

Referenced by build(), fillCaloData(), and itemBeingDestroyed().

TEveCaloDataVec* FWHFTowerProxyBuilderBase::m_vecData [private]