Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "TMath.h"
00025 #include "TEveArrow.h"
00026 #include "TEveScalableStraightLineSet.h"
00027
00028 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00029 #include "Fireworks/Core/interface/Context.h"
00030 #include "Fireworks/Core/interface/FWViewEnergyScale.h"
00031 #include "DataFormats/METReco/interface/MET.h"
00032
00033
00034
00035 class FWMET3DProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::MET> {
00036 public:
00037 class Arrow : public TEveArrow
00038 {
00039 public:
00040 float m_et;
00041 float m_energy;
00042 const FWViewContext* m_vc;
00043
00044 Arrow(Float_t x, Float_t y, Float_t z,
00045 Float_t xo, Float_t yo, Float_t zo=0) :
00046 TEveArrow(x, y, z, xo, yo, zo),
00047 m_et(0), m_energy(0), m_vc(0) {}
00048
00049 void setScale(FWViewEnergyScale* caloScale)
00050 {
00051 static float maxW = 3;
00052 float scale = caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? m_et : m_energy);
00053 fVector.Normalize();
00054 fVector *= scale;
00055 fTubeR = TMath::Min(maxW/scale, 0.08f);
00056 fConeR = TMath::Min(maxW*2.5f/scale, 0.25f);
00057
00058 }
00059 };
00060
00061 FWMET3DProxyBuilder();
00062 virtual ~FWMET3DProxyBuilder();
00063
00064
00065
00066 virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
00067 virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
00068 virtual void cleanLocal() { m_arrows.clear(); }
00069
00070
00071
00072
00073
00074 REGISTER_PROXYBUILDER_METHODS();
00075
00076 private:
00077 FWMET3DProxyBuilder(const FWMET3DProxyBuilder&);
00078 const FWMET3DProxyBuilder& operator=(const FWMET3DProxyBuilder&);
00079
00080 void build(const reco::MET&, unsigned int, TEveElement&, const FWViewContext*);
00081
00082
00083 std::vector<Arrow*> m_arrows;
00084 };
00085
00086
00087
00088
00089 FWMET3DProxyBuilder::FWMET3DProxyBuilder()
00090 {
00091 }
00092
00093 FWMET3DProxyBuilder::~FWMET3DProxyBuilder()
00094 {
00095 }
00096
00097
00098
00099
00100 void
00101 FWMET3DProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
00102 {
00103
00104 FWViewEnergyScale* caloScale = vc->getEnergyScale();
00105
00106 for (std::vector<Arrow*>::iterator i = m_arrows.begin(); i!= m_arrows.end(); ++ i)
00107 {
00108 if ( vc == (*i)->m_vc)
00109 {
00110 (*i)->setScale(caloScale);
00111 }
00112 }
00113 }
00114
00115 void
00116 FWMET3DProxyBuilder::build(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* vc)
00117 {
00118 float r0;
00119 float phi = met.phi();
00120 float theta = met.theta();
00121
00122 if (TMath::Abs(met.eta()) < context().caloTransEta())
00123 r0 = context().caloR1()/sin(theta);
00124 else
00125 r0 = context().caloZ1()/fabs(cos(theta));
00126
00127 Arrow* arrow = new Arrow( sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta),
00128 r0*sin(theta)*cos(phi), r0*sin(theta)*sin(phi), r0*cos(theta));
00129 arrow->m_et = met.et();
00130 arrow->m_energy = met.energy();
00131 arrow->m_vc = vc;
00132 arrow->SetConeL(0.15);
00133 arrow->SetConeR(0.06);
00134 setupAddElement(arrow, &oItemHolder );
00135
00136 m_arrows.push_back(arrow);
00137 arrow->setScale(vc->getEnergyScale());
00138 arrow->setScale(vc->getEnergyScale());
00139
00140 context().voteMaxEtAndEnergy(met.et(), met.energy());
00141
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 REGISTER_FWPROXYBUILDER(FWMET3DProxyBuilder, reco::MET, "recoMET", FWViewType::kAll3DBits);