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  public:
39  float m_et;
40  float m_energy;
42 
43  Arrow(Float_t x, Float_t y, Float_t z, Float_t xo, Float_t yo, Float_t zo = 0)
44  : TEveArrow(x, y, z, xo, yo, zo), m_et(0), m_energy(0), m_vc(nullptr) {}
45 
46  void setScale(FWViewEnergyScale* caloScale) {
47  static float maxW = 3;
48  float scale = caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? m_et : m_energy);
49  fVector.Normalize();
50  fVector *= scale;
51  fTubeR = TMath::Min(maxW / scale, 0.08f);
52  fConeR = TMath::Min(maxW * 2.5f / scale, 0.25f);
53  }
54  };
55 
57  ~FWMET3DProxyBuilder() override;
58 
59  // ---------- const member functions ---------------------
60 
61  bool havePerViewProduct(FWViewType::EType) const override { return true; } // used energy scaling
62  void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override;
63  void cleanLocal() override { m_arrows.clear(); }
64 
65  // ---------- static member functions --------------------
66 
67  // ---------- member functions ---------------------------
68 
70 
71  FWMET3DProxyBuilder(const FWMET3DProxyBuilder&) = delete; // stop default
72  const FWMET3DProxyBuilder& operator=(const FWMET3DProxyBuilder&) = delete; // stop default
73 
74 private:
76  void build(const reco::MET&, unsigned int, TEveElement&, const FWViewContext*) override;
77 
78  // ---------- member data --------------------------------
79  std::vector<Arrow*> m_arrows;
80 };
81 
82 //
83 // constructors and destructor
84 //
86 
88 
89 //
90 // member functions
91 //
93  // printf("scale prod \n");
94  FWViewEnergyScale* caloScale = vc->getEnergyScale();
95 
96  for (std::vector<Arrow*>::iterator i = m_arrows.begin(); i != m_arrows.end(); ++i) {
97  if (vc == (*i)->m_vc) {
98  (*i)->setScale(caloScale);
99  }
100  }
101 }
102 
104  unsigned int iIndex,
105  TEveElement& oItemHolder,
106  const FWViewContext* vc) {
107  float r0;
108  float phi = met.phi();
109  float theta = met.theta();
110 
111  if (TMath::Abs(met.eta()) < context().caloTransEta())
112  r0 = context().caloR1() / sin(theta);
113  else
114  r0 = context().caloZ1() / fabs(cos(theta));
115 
116  Arrow* arrow = new Arrow(sin(theta) * cos(phi),
117  sin(theta) * sin(phi),
118  cos(theta),
119  r0 * sin(theta) * cos(phi),
120  r0 * sin(theta) * sin(phi),
121  r0 * cos(theta));
122  arrow->m_et = met.et();
123  arrow->m_energy = met.energy();
124  arrow->m_vc = vc;
125  arrow->SetConeL(0.15);
126  arrow->SetConeR(0.06);
127  setupAddElement(arrow, &oItemHolder);
128 
129  m_arrows.push_back(arrow);
130  arrow->setScale(vc->getEnergyScale());
131  arrow->setScale(vc->getEnergyScale());
132 
133  context().voteMaxEtAndEnergy(met.et(), met.energy());
134 }
135 
136 //
137 // const member functions
138 //
139 
140 //
141 // static member functions
142 //
143 
static float caloTransEta()
Definition: Context.cc:194
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int kAll3DBits
Definition: FWViewType.h:68
const fireworks::Context & context() const
bool getPlotEt() const
void setScale(FWViewEnergyScale *caloScale)
FWViewEnergyScale * getEnergyScale() const
std::vector< Arrow * > m_arrows
Definition: MET.h:41
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:169
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:187
double f[11][100]
const FWMET3DProxyBuilder & operator=(const FWMET3DProxyBuilder &)=delete
Arrow(Float_t x, Float_t y, Float_t z, Float_t xo, Float_t yo, Float_t zo=0)
void cleanLocal() override
float getScaleFactor3D() const
static float caloZ1(bool offset=true)
Definition: Context.cc:190
bool havePerViewProduct(FWViewType::EType) const override
const FWViewContext * m_vc
Geom::Theta< T > theta() const