Go to the documentation of this file.00001 #include "FWPFEcalRecHitRPProxyBuilder.h"
00002
00003
00004 void
00005 FWPFEcalRecHitRPProxyBuilder::scaleProduct( TEveElementList *parent, FWViewType::EType type, const FWViewContext *vc )
00006 {
00007 typedef std::vector<FWPFRhoPhiRecHit*> rpRecHits;
00008 unsigned int index = 0;
00009
00010 for( rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i )
00011 {
00012 m_towers[index]->updateScale( vc );
00013 index++;
00014 }
00015 }
00016
00017
00018 void
00019 FWPFEcalRecHitRPProxyBuilder::cleanLocal()
00020 {
00021 typedef std::vector<FWPFRhoPhiRecHit*> rpRecHits;
00022 for( rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i )
00023 (*i)->clean();
00024
00025 m_towers.clear();
00026 }
00027
00028
00029 TEveVector
00030 FWPFEcalRecHitRPProxyBuilder::calculateCentre( const float *vertices )
00031 {
00032 TEveVector centre;
00033
00034 for( unsigned int i = 0; i < 8; i++ )
00035 {
00036 int j = i * 3;
00037 centre.fX += vertices[j];
00038 centre.fY += vertices[j+1];
00039 centre.fZ += vertices[j+2];
00040 }
00041
00042 centre *= 1.0f / 8.0f;
00043
00044 return centre;
00045 }
00046
00047
00048 void
00049 FWPFEcalRecHitRPProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
00050 {
00051 m_towers.clear();
00052 for( unsigned int index = 0; index < static_cast<unsigned int>( iItem->size() ); ++index )
00053 {
00054 TEveCompound *itemHolder = createCompound();
00055 product->AddElement( itemHolder );
00056 const FWEventItem::ModelInfo &info = item()->modelInfo( index );
00057
00058 if( info.displayProperties().isVisible() )
00059 {
00060 bool added = false;
00061 float E, et;
00062 float ecalR = FWPFUtils::caloR1();
00063 Double_t lPhi, rPhi;
00064 const EcalRecHit &iData = modelData( index );
00065 const float *vertices = item()->getGeom()->getCorners( iData.detid() );
00066
00067 TEveVector centre = calculateCentre( vertices );
00068 TEveVector lVec = TEveVector( vertices[0], vertices[1], 0 );
00069 TEveVector rVec = TEveVector( vertices[9], vertices[10], 0 );
00070
00071 lPhi = lVec.Phi();
00072 rPhi = rVec.Phi();
00073 E = iData.energy();
00074 et = FWPFMaths::calculateEt( centre, E );
00075
00076 for( unsigned int i = 0; i < m_towers.size(); i++ )
00077 {
00078 Double_t phi = m_towers[i]->getlPhi();
00079 if( ( lPhi == phi ) || ( ( lPhi < phi + 0.0005 ) && ( lPhi > phi - 0.0005 ) ) )
00080 {
00081 m_towers[i]->addChild( this, itemHolder, vc, E, et );
00082 context().voteMaxEtAndEnergy( et, E );
00083 added = true;
00084 break;
00085 }
00086 }
00087
00088 if( !added )
00089 {
00090 rVec.fX = ecalR * cos( rPhi ); rVec.fY = ecalR * sin( rPhi );
00091 lVec.fX = ecalR * cos( lPhi ); lVec.fY = ecalR * sin( lPhi );
00092 std::vector<TEveVector> bCorners(2);
00093 bCorners[0] = lVec;
00094 bCorners[1] = rVec;
00095
00096 FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit( this, itemHolder, vc, E, et, lPhi, rPhi, bCorners );
00097 context().voteMaxEtAndEnergy(et, E);
00098 m_towers.push_back( rh );
00099 }
00100 }
00101 }
00102 }
00103
00104
00105 REGISTER_FWPROXYBUILDER( FWPFEcalRecHitRPProxyBuilder, EcalRecHit, "Ecal RecHit", FWViewType::kRhoPhiPFBit );