CMS 3D CMS Logo

FWMET3DProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Fireworks
4 // Class : FWMET3DProxyBuilder.cc
5 
6 /*
7 
8  Description: [one line class summary]
9 
10  Usage:
11  <usage>
12 
13 */
14 //
15 // Original Author:
16 // Created: Mon Jan 17 10:48:11 2011
17 //
18 //
19 
20 // system include files
21 
22 // user include files
23 
24 #include "TMath.h"
25 #include "TEveArrow.h"
26 #include "TEveScalableStraightLineSet.h"
27 
32 
33 // forward declarations
34 
36 public:
37  class Arrow : public TEveArrow
38  {
39  public:
40  float m_et;
41  float m_energy;
43 
44  Arrow(Float_t x, Float_t y, Float_t z,
45  Float_t xo, Float_t yo, Float_t zo=0) :
46  TEveArrow(x, y, z, xo, yo, zo),
47  m_et(0), m_energy(0), m_vc(0) {}
48 
49  void setScale(FWViewEnergyScale* caloScale)
50  {
51  static float maxW = 3;
52  float scale = caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? m_et : m_energy);
53  fVector.Normalize();
54  fVector *= scale;
55  fTubeR = TMath::Min(maxW/scale, 0.08f);
56  fConeR = TMath::Min(maxW*2.5f/scale, 0.25f);
57 
58  }
59  };
60 
62  virtual ~FWMET3DProxyBuilder();
63 
64  // ---------- const member functions ---------------------
65 
66  virtual bool havePerViewProduct(FWViewType::EType) const { return true; } // used energy scaling
67  virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
68  virtual void cleanLocal() { m_arrows.clear(); }
69 
70  // ---------- static member functions --------------------
71 
72  // ---------- member functions ---------------------------
73 
75 
76 private:
77  FWMET3DProxyBuilder(const FWMET3DProxyBuilder&); // stop default
78  const FWMET3DProxyBuilder& operator=(const FWMET3DProxyBuilder&); // stop default
79 
81  void build(const reco::MET&, unsigned int, TEveElement&, const FWViewContext*);
82 
83  // ---------- member data --------------------------------
84  std::vector<Arrow*> m_arrows;
85 };
86 
87 //
88 // constructors and destructor
89 //
91 {
92 }
93 
95 {
96 }
97 
98 //
99 // member functions
100 //
101 void
103 {
104  // printf("scale prod \n");
105  FWViewEnergyScale* caloScale = vc->getEnergyScale();
106 
107  for (std::vector<Arrow*>::iterator i = m_arrows.begin(); i!= m_arrows.end(); ++ i)
108  {
109  if ( vc == (*i)->m_vc)
110  {
111  (*i)->setScale(caloScale);
112  }
113  }
114 }
115 
116 void
117 FWMET3DProxyBuilder::build(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* vc)
118 {
119  float r0;
120  float phi = met.phi();
121  float theta = met.theta();
122 
123  if (TMath::Abs(met.eta()) < context().caloTransEta())
124  r0 = context().caloR1()/sin(theta);
125  else
126  r0 = context().caloZ1()/fabs(cos(theta));
127 
128  Arrow* arrow = new Arrow( sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta),
129  r0*sin(theta)*cos(phi), r0*sin(theta)*sin(phi), r0*cos(theta));
130  arrow->m_et = met.et();
131  arrow->m_energy = met.energy();
132  arrow->m_vc = vc;
133  arrow->SetConeL(0.15);
134  arrow->SetConeR(0.06);
135  setupAddElement(arrow, &oItemHolder );
136 
137  m_arrows.push_back(arrow);
138  arrow->setScale(vc->getEnergyScale());
139  arrow->setScale(vc->getEnergyScale());
140 
141  context().voteMaxEtAndEnergy(met.et(), met.energy());
142 
143 }
144 
145 //
146 // const member functions
147 //
148 
149 //
150 // static member functions
151 //
152 
static float caloTransEta()
Definition: Context.cc:228
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
virtual double eta() const final
momentum pseudorapidity
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:183
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FWViewEnergyScale * getEnergyScale() const
const FWMET3DProxyBuilder & operator=(const FWMET3DProxyBuilder &)
Geom::Theta< T > theta() const
T Min(T a, T b)
Definition: MathUtil.h:39
static const int kAll3DBits
Definition: FWViewType.h:59
virtual double phi() const final
momentum azimuthal angle
void setScale(FWViewEnergyScale *caloScale)
virtual double et() const final
transverse energy
virtual double theta() const final
momentum polar angle
std::vector< Arrow * > m_arrows
Definition: MET.h:42
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T Abs(T a)
Definition: MathUtil.h:49
virtual double energy() const final
energy
static float caloR1(bool offset=true)
Definition: Context.cc:208
double f[11][100]
Arrow(Float_t x, Float_t y, Float_t z, Float_t xo, Float_t yo, Float_t zo=0)
virtual bool havePerViewProduct(FWViewType::EType) const
met
===> hadronic RAZOR
static float caloZ1(bool offset=true)
Definition: Context.cc:218
const FWViewContext * m_vc
bool getPlotEt() const