CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
80  void build(const reco::MET&, unsigned int, TEveElement&, const FWViewContext*);
81 
82  // ---------- member data --------------------------------
83  std::vector<Arrow*> m_arrows;
84 };
85 
86 //
87 // constructors and destructor
88 //
90 {
91 }
92 
94 {
95 }
96 
97 //
98 // member functions
99 //
100 void
102 {
103  // printf("scale prod \n");
104  FWViewEnergyScale* caloScale = vc->getEnergyScale();
105 
106  for (std::vector<Arrow*>::iterator i = m_arrows.begin(); i!= m_arrows.end(); ++ i)
107  {
108  if ( vc == (*i)->m_vc)
109  {
110  (*i)->setScale(caloScale);
111  }
112  }
113 }
114 
115 void
116 FWMET3DProxyBuilder::build(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* vc)
117 {
118  float r0;
119  float phi = met.phi();
120  float theta = met.theta();
121 
122  if (TMath::Abs(met.eta()) < context().caloTransEta())
123  r0 = context().caloR1()/sin(theta);
124  else
125  r0 = context().caloZ1()/fabs(cos(theta));
126 
127  Arrow* arrow = new Arrow( sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta),
128  r0*sin(theta)*cos(phi), r0*sin(theta)*sin(phi), r0*cos(theta));
129  arrow->m_et = met.et();
130  arrow->m_energy = met.energy();
131  arrow->m_vc = vc;
132  arrow->SetConeL(0.15);
133  arrow->SetConeR(0.06);
134  setupAddElement(arrow, &oItemHolder );
135 
136  m_arrows.push_back(arrow);
137  arrow->setScale(vc->getEnergyScale());
138  arrow->setScale(vc->getEnergyScale());
139 
140  context().voteMaxEtAndEnergy(met.et(), met.energy());
141 
142 }
143 
144 //
145 // const member functions
146 //
147 
148 //
149 // static member functions
150 //
151 
static float caloTransEta()
Definition: Context.cc:230
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
list parent
Definition: dbtoconf.py:74
virtual double et() const
transverse energy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:185
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
virtual double eta() const
momentum pseudorapidity
double double double z
static const int kAll3DBits
Definition: FWViewType.h:59
void setScale(FWViewEnergyScale *caloScale)
virtual double energy() const
energy
std::vector< Arrow * > m_arrows
Definition: MET.h:32
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:210
double f[11][100]
virtual double theta() const
momentum polar angle
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
static float caloZ1(bool offset=true)
Definition: Context.cc:220
Definition: DDAxes.h:10
const FWViewContext * m_vc
virtual double phi() const
momentum azimuthal angle
bool getPlotEt() const
Definition: DDAxes.h:10