00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "TEveGeoNode.h"
00016 #include "TEveScalableStraightLineSet.h"
00017 #include "TGeoTube.h"
00018 #include "TMath.h"
00019
00020
00021 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00022 #include "Fireworks/Core/interface/FWViewType.h"
00023 #include "Fireworks/Core/interface/BuilderUtils.h"
00024 #include "Fireworks/Core/interface/Context.h"
00025 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00026 #include "Fireworks/Core/interface/FWEventItem.h"
00027 #include "Fireworks/Calo/interface/scaleMarker.h"
00028
00029 #include "DataFormats/METReco/interface/MET.h"
00030
00032
00033
00034
00036
00037 class FWMETProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::MET>
00038 {
00039 public:
00040 FWMETProxyBuilder() {}
00041 virtual ~FWMETProxyBuilder() {}
00042
00043 virtual bool haveSingleProduct() const { return false; }
00044
00045 virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
00046
00047 virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
00048
00049 virtual void cleanLocal() { m_lines.clear(); }
00050
00051 REGISTER_PROXYBUILDER_METHODS();
00052
00053 private:
00054
00055 FWMETProxyBuilder( const FWMETProxyBuilder& );
00056 const FWMETProxyBuilder& operator=( const FWMETProxyBuilder& );
00057
00058 virtual void buildViewType(const reco::MET& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*);
00059
00060 std::vector<fireworks::scaleMarker> m_lines;
00061 };
00062
00063 void
00064 FWMETProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
00065 {
00066 typedef std::vector<fireworks::scaleMarker> Lines_t;
00067 FWViewEnergyScale* caloScale = vc->getEnergyScale();
00068
00069
00070 for (Lines_t::iterator i = m_lines.begin(); i!= m_lines.end(); ++ i)
00071 {
00072 if ( vc == (*i).m_vc )
00073 {
00074
00075 float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
00076
00077 (*i).m_ls->SetScale(caloScale->getScaleFactor3D()*value);
00078
00079 TEveProjectable *pable = static_cast<TEveProjectable*>((*i).m_ls);
00080 for (TEveProjectable::ProjList_i j = pable->BeginProjecteds(); j != pable->EndProjecteds(); ++j)
00081 {
00082 (*j)->UpdateProjection();
00083 }
00084 }
00085 }
00086 }
00087
00088 void
00089 FWMETProxyBuilder::buildViewType(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* vc)
00090 {
00091 using namespace TMath;
00092 double phi = met.phi();
00093 double theta = met.theta();
00094 double size = 1.f;
00095
00096 FWViewEnergyScale* caloScale = vc->getEnergyScale();
00097
00098 TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet( "MET marker" );
00099 marker->SetLineWidth( 2 );
00100
00101
00102
00103 if ( type == FWViewType::kRhoZ )
00104 {
00105
00106 double r0;
00107 if (TMath::Abs(met.eta()) < context().caloTransEta())
00108 {
00109 r0 = context().caloR1()/sin(theta);
00110 }
00111 else
00112 {
00113 r0 = context().caloZ1()/fabs(cos(theta));
00114 }
00115 marker->SetScaleCenter( 0., Sign(r0*sin(theta), phi), r0*cos(theta) );
00116 double r1 = r0 + 1;
00117 marker->AddLine( 0., Sign(r0*sin(theta), phi), r0*cos(theta),
00118 0., Sign(r1*sin(theta), phi), r1*cos(theta) );
00119
00120
00121 double r2 = r1 - 0.1;
00122 double dy = 0.05*size;
00123 marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta),
00124 0., Sign(r1*sin(theta), phi), r1*cos(theta) );
00125 dy = -dy;
00126 marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta),
00127 0., Sign(r1*sin(theta), phi), r1*cos(theta) );
00128
00129
00130 fireworks::addRhoZEnergyProjection( this, &oItemHolder, context().caloR1() -1, context().caloZ1() -1,
00131 theta - 0.04, theta + 0.04,
00132 phi );
00133 }
00134 else
00135 {
00136
00137 double r0 = context().caloR1();
00138 double r1 = r0 + 1;
00139 marker->SetScaleCenter( r0*cos(phi), r0*sin(phi), 0 );
00140 marker->AddLine( r0*cos(phi), r0*sin(phi), 0,
00141 r1*cos(phi), r1*sin(phi), 0);
00142
00143
00144 double r2 = r1 - 0.1;
00145 double dy = 0.05*size;
00146
00147 marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0,
00148 r1*cos(phi), r1*sin(phi), 0);
00149 dy = -dy;
00150 marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0,
00151 r1*cos(phi), r1*sin(phi), 0);
00152
00153
00154 double min_phi = phi-M_PI/36/2;
00155 double max_phi = phi+M_PI/36/2;
00156 TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
00157 TEveGeoShape *element = fireworks::getShape( "spread", new TGeoTubeSeg( r0 - 2, r0, 1, min_phi*180/M_PI, max_phi*180/M_PI ), 0 );
00158 element->SetPickable( kTRUE );
00159 setupAddElement( element, &oItemHolder );
00160 }
00161
00162 marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? met.et() : met.energy()));
00163 setupAddElement( marker, &oItemHolder );
00164
00165
00166 m_lines.push_back(fireworks::scaleMarker(marker, met.et(), met.energy(), vc));
00167
00168 context().voteMaxEtAndEnergy(met.et(), met.energy());
00169 }
00170
00171 REGISTER_FWPROXYBUILDER( FWMETProxyBuilder, reco::MET, "recoMET", FWViewType::kAllRPZBits );