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 float
00049 FWPFEcalRecHitRPProxyBuilder::calculateEt( const TEveVector ¢re, float E )
00050 {
00051 TEveVector vec = centre;
00052 float et;
00053
00054 vec.Normalize();
00055 vec *= E;
00056 et = vec.Perp();
00057
00058 return et;
00059 }
00060
00061
00062 void
00063 FWPFEcalRecHitRPProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
00064 {
00065 m_towers.clear();
00066 for( unsigned int index = 0; index < static_cast<unsigned int>( iItem->size() ); ++index )
00067 {
00068 TEveCompound *itemHolder = createCompound();
00069 product->AddElement( itemHolder );
00070
00071 bool added = false;
00072 float E, et;
00073 float ecalR = m_pfUtils->getCaloR1();
00074 Double_t lPhi, rPhi;
00075 const EcalRecHit &iData = modelData( index );
00076 const float *vertices = item()->getGeom()->getCorners( iData.detid() );
00077
00078 TEveVector centre = calculateCentre( vertices );
00079 TEveVector lVec = TEveVector( vertices[0], vertices[1], 0 );
00080 TEveVector rVec = TEveVector( vertices[9], vertices[10], 0 );
00081
00082 lPhi = lVec.Phi();
00083 rPhi = rVec.Phi();
00084 E = iData.energy();
00085 et = calculateEt( centre, E );
00086
00087 for( unsigned int i = 0; i < m_towers.size(); i++ )
00088 {
00089 Double_t phi = m_towers[i]->getlPhi();
00090 if( ( lPhi == phi ) || ( ( lPhi < phi + 0.0005 ) && ( lPhi > phi - 0.0005 ) ) )
00091 {
00092 m_towers[i]->addChild( this, itemHolder, vc, E, et );
00093 context().voteMaxEtAndEnergy( et, E );
00094 added = true;
00095 break;
00096 }
00097 }
00098
00099 if( !added )
00100 {
00101 rVec.fX = ecalR * cos( rPhi ); rVec.fY = ecalR * sin( rPhi );
00102 lVec.fX = ecalR * cos( lPhi ); lVec.fY = ecalR * sin( lPhi );
00103 std::vector<TEveVector> bCorners(2);
00104 bCorners[0] = lVec;
00105 bCorners[1] = rVec;
00106
00107 FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit( this, itemHolder, vc, E, et, lPhi, rPhi, bCorners );
00108 context().voteMaxEtAndEnergy(et, E);
00109 m_towers.push_back( rh );
00110 }
00111 }
00112 }
00113
00114
00115 REGISTER_FWPROXYBUILDER( FWPFEcalRecHitRPProxyBuilder, EcalRecHit, "Ecal RecHit", FWViewType::kRhoPhiPFBit );