Go to the documentation of this file.00001 #include "FWPFEcalRecHitLegoProxyBuilder.h"
00002
00003
00004 void
00005 FWPFEcalRecHitLegoProxyBuilder::scaleProduct( TEveElementList *parent, FWViewType::EType type, const FWViewContext *vc )
00006 {
00007 FWViewEnergyScale *caloScale = vc->getEnergyScale();
00008 bool b = caloScale->getPlotEt();
00009 float maxVal = getMaxVal( b );
00010 typedef std::vector<FWPFLegoRecHit*> rh;
00011
00012
00013 for( rh::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
00014 {
00015 if( (*i)->isTallest() == false && (*i)->getEtEnergy( b ) == maxVal )
00016 (*i)->setIsTallest( true );
00017
00018 (*i)->updateScale( vc, getMaxValLog(caloScale->getPlotEt()));
00019 }
00020 }
00021
00022
00023 void
00024 FWPFEcalRecHitLegoProxyBuilder::localModelChanges( const FWModelId &iId, TEveElement *parent,
00025 FWViewType::EType viewType, const FWViewContext *vc )
00026 {
00027 for (TEveElement::List_i i = parent->BeginChildren(); i!= parent->EndChildren(); ++i)
00028 {
00029 {
00030 TEveStraightLineSet* line = dynamic_cast<TEveStraightLineSet*>(*i);
00031 if (line)
00032 {
00033 const FWDisplayProperties &p = item()->modelInfo( iId.index() ).displayProperties();
00034 line->SetMarkerColor( p.color() );
00035 }
00036 }
00037 }
00038 }
00039
00040
00041 TEveVector
00042 FWPFEcalRecHitLegoProxyBuilder::calculateCentre( const std::vector<TEveVector> &corners ) const
00043 {
00044 TEveVector centre;
00045
00046 for( size_t i = 0; i < corners.size(); ++i )
00047 {
00048 centre.fX += corners[i].fX;
00049 centre.fY += corners[i].fY;
00050 centre.fZ += corners[i].fZ;
00051 }
00052 centre *= 1.f / 8.f;
00053
00054 return centre;
00055 }
00056
00057
00058 void
00059 FWPFEcalRecHitLegoProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
00060 {
00061 size_t itemSize = iItem->size();
00062
00063 for( size_t index = 0; index < itemSize; ++index )
00064 {
00065 TEveCompound *itemHolder = createCompound();
00066 product->AddElement( itemHolder );
00067
00068 const EcalRecHit &iData = modelData( index );
00069 const float *corners = item()->getGeom()->getCorners( iData.detid() );
00070 float energy, et;
00071 std::vector<TEveVector> etaphiCorners(8);
00072 TEveVector centre;
00073
00074 if( corners == 0 )
00075 continue;
00076
00077 int k = 3;
00078 for( int i = 0; i < 4; ++i )
00079 {
00080 int j = k * 3;
00081 TEveVector cv = TEveVector( corners[j], corners[j+1], corners[j+2] );
00082 etaphiCorners[i].fX = cv.Eta();
00083 etaphiCorners[i].fY = cv.Phi();
00084 etaphiCorners[i].fZ = 0.0;
00085
00086 etaphiCorners[i+4].fX = etaphiCorners[i].fX;
00087 etaphiCorners[i+4].fY = etaphiCorners[i].fY;
00088 etaphiCorners[i+4].fZ = 0.001;
00089
00090 --k;
00091 }
00092
00093 centre = calculateCentre( etaphiCorners );
00094 energy = iData.energy();
00095 et = FWPFMaths::calculateEt( centre, energy );
00096 context().voteMaxEtAndEnergy( et, energy );
00097
00098 if( energy > m_maxEnergy )
00099 m_maxEnergy = energy;
00100 if( energy > m_maxEt )
00101 m_maxEt = et;
00102
00103
00104 float dPhi1 = etaphiCorners[2].fY - etaphiCorners[1].fY;
00105 float dPhi2 = etaphiCorners[3].fY - etaphiCorners[0].fY;
00106 float dPhi3 = etaphiCorners[1].fY - etaphiCorners[2].fY;
00107 float dPhi4 = etaphiCorners[0].fY - etaphiCorners[3].fY;
00108
00109 if( dPhi1 > 1 )
00110 etaphiCorners[2].fY = etaphiCorners[2].fY - ( 2 * TMath::Pi() );
00111 if( dPhi2 > 1 )
00112 etaphiCorners[3].fY = etaphiCorners[3].fY - ( 2 * TMath::Pi() );
00113 if( dPhi3 > 1 )
00114 etaphiCorners[2].fY = etaphiCorners[2].fY + ( 2 * TMath::Pi() );
00115 if( dPhi4 > 1 )
00116 etaphiCorners[3].fY = etaphiCorners[3].fY + ( 2 * TMath::Pi() );
00117
00118 FWPFLegoRecHit *recHit = new FWPFLegoRecHit( etaphiCorners, itemHolder, this, vc, energy, et );
00119 recHit->setSquareColor( item()->defaultDisplayProperties().color() );
00120 m_recHits.push_back( recHit );
00121 }
00122
00123 m_maxEnergyLog = log( m_maxEnergy );
00124 m_maxEtLog = log( m_maxEt );
00125
00126 scaleProduct( product, FWViewType::kLegoPFECAL, vc );
00127 }
00128
00129
00130 void
00131 FWPFEcalRecHitLegoProxyBuilder::cleanLocal()
00132 {
00133 for( std::vector<FWPFLegoRecHit*>::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
00134 delete (*i);
00135
00136 m_recHits.clear();
00137 }
00138
00139
00140 REGISTER_FWPROXYBUILDER( FWPFEcalRecHitLegoProxyBuilder, EcalRecHit, "Ecal RecHit", FWViewType::kLegoPFECALBit );