00001 #include "Fireworks/ParticleFlow/interface/FWPFClusterRPZUtils.h"
00002
00003
00004 float
00005 FWPFClusterRPZUtils::calculateEt( const reco::PFCluster &cluster, float e )
00006 {
00007 float et = 0.f;
00008 TEveVector vec;
00009
00010 vec.fX = cluster.x();
00011 vec.fY = cluster.y();
00012 vec.fZ = cluster.z();
00013
00014 vec.Normalize();
00015 vec *= e;
00016 et = vec.Perp();
00017
00018 return et;
00019 }
00020
00021
00022 TEveScalableStraightLineSet *
00023 FWPFClusterRPZUtils::buildRhoPhiClusterLineSet( const reco::PFCluster &cluster, const FWViewContext *vc, float r )
00024 {
00025 float energy, et;
00026
00027 energy = cluster.energy();
00028 et = calculateEt( cluster, energy );
00029
00030 return buildRhoPhiClusterLineSet( cluster, vc, energy, et, r );
00031 }
00032
00033
00034 TEveScalableStraightLineSet *
00035 FWPFClusterRPZUtils::buildRhoPhiClusterLineSet( const reco::PFCluster &cluster, const FWViewContext *vc,
00036 float e, float et, float r )
00037 {
00038 TEveScalableStraightLineSet *ls = new TEveScalableStraightLineSet( "rhophiCluster" );
00039 TEveVector vec;
00040 float size = 1.f;
00041 double phi;
00042
00043 vec = TEveVector( cluster.x(), cluster.y(), cluster.z() );
00044 phi = vec.Phi();
00045
00046 FWViewEnergyScale *energyScale = vc->getEnergyScale();
00047 ls->SetLineWidth( 4 );
00048
00049 ls->SetScaleCenter( r * cos( phi ), r * sin( phi ), 0 );
00050 ls->AddLine( r * cos( phi ), r * sin( phi ), 0, ( r + size ) * cos( phi ), ( r + size ) * sin( phi ), 0 );
00051 ls->SetScale( energyScale->getScaleFactor3D() * ( energyScale->getPlotEt() ? et : e ) );
00052
00053 return ls;
00054 }
00055
00056
00057 TEveScalableStraightLineSet *
00058 FWPFClusterRPZUtils::buildRhoZClusterLineSet( const reco::PFCluster &cluster, const FWViewContext *vc,
00059 float caloTransAngle, float r, float z )
00060 {
00061 float energy, et;
00062
00063 energy = cluster.energy();
00064 et = calculateEt( cluster, energy );
00065
00066 return buildRhoZClusterLineSet( cluster, vc, caloTransAngle, energy, et, r, z );
00067 }
00068
00069
00070 TEveScalableStraightLineSet *
00071 FWPFClusterRPZUtils::buildRhoZClusterLineSet( const reco::PFCluster &cluster, const FWViewContext *vc,
00072 float caloTransAngle, float e, float et, float r, float z )
00073 {
00074 float size = 1.f;
00075 float offr = 4;
00076 float ecalZ = z + offr / tan( caloTransAngle );
00077 double theta, phi;
00078 double rad(0);
00079 TEveVector vec;
00080 TEveScalableStraightLineSet *ls = new TEveScalableStraightLineSet( "rhoZCluster" );
00081
00082 vec = TEveVector( cluster.x(), cluster.y(), cluster.z() );
00083 phi = vec.Phi();
00084 theta = vec.Theta();
00085
00086 FWViewEnergyScale *caloScale = vc->getEnergyScale();
00087 ls->SetLineWidth( 4 );
00088
00089 if ( theta < caloTransAngle || TMath::Pi() - theta < caloTransAngle )
00090 rad = ecalZ / fabs( cos( theta ) );
00091 else
00092 rad = r / sin( theta );
00093
00094 ls->SetScaleCenter( 0., ( phi > 0 ? rad * fabs( sin( theta ) ) : -rad * fabs( sin( theta ) ) ), rad * cos( theta ) );
00095 ls->AddLine( 0., ( phi > 0 ? rad * fabs( sin( theta ) ) : -rad * fabs( sin( theta ) ) ), rad * cos( theta ),
00096 0., ( phi > 0 ? ( rad + size ) * fabs( sin ( theta ) ) : -( rad + size ) * fabs( sin( theta) ) ),
00097 ( rad + size ) * cos( theta ) );
00098 ls->SetScale( caloScale->getScaleFactor3D() * ( caloScale->getPlotEt() ? et : e ) );
00099
00100 return ls;
00101 }
00102