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 private:
72  FWMET3DProxyBuilder(const FWMET3DProxyBuilder&) = delete; // stop default
73  const FWMET3DProxyBuilder& operator=(const FWMET3DProxyBuilder&) = delete; // stop default
74 
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 
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
FWMET3DProxyBuilder::Arrow::m_vc
const FWViewContext * m_vc
Definition: FWMET3DProxyBuilder.cc:41
FWSimpleProxyBuilderTemplate.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
FWViewType::EType
EType
Definition: FWViewType.h:31
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FWMET3DProxyBuilder::havePerViewProduct
bool havePerViewProduct(FWViewType::EType) const override
Definition: FWMET3DProxyBuilder.cc:61
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWMET3DProxyBuilder
Definition: FWMET3DProxyBuilder.cc:35
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWMET3DProxyBuilder::Arrow::setScale
void setScale(FWViewEnergyScale *caloScale)
Definition: FWMET3DProxyBuilder.cc:46
FWMET3DProxyBuilder::cleanLocal
void cleanLocal() override
Definition: FWMET3DProxyBuilder.cc:63
FWViewEnergyScale::getPlotEt
bool getPlotEt() const
Definition: FWViewEnergyScale.h:47
DDAxes::x
FWMET3DProxyBuilder::FWMET3DProxyBuilder
FWMET3DProxyBuilder()
Definition: FWMET3DProxyBuilder.cc:85
FWMET3DProxyBuilder::operator=
const FWMET3DProxyBuilder & operator=(const FWMET3DProxyBuilder &)=delete
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::MET
Definition: MET.h:41
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs
T Abs(T a)
Definition: MathUtil.h:49
FWMET3DProxyBuilder::~FWMET3DProxyBuilder
~FWMET3DProxyBuilder() override
Definition: FWMET3DProxyBuilder.cc:87
fireworks::Context::voteMaxEtAndEnergy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
FWMET3DProxyBuilder::Arrow::m_et
float m_et
Definition: FWMET3DProxyBuilder.cc:39
DDAxes::z
fireworks::Context::caloTransEta
static float caloTransEta()
Definition: Context.cc:187
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
FWMET3DProxyBuilder::m_arrows
std::vector< Arrow * > m_arrows
Definition: FWMET3DProxyBuilder.cc:79
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
FWMET3DProxyBuilder::Arrow
Definition: FWMET3DProxyBuilder.cc:37
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
FWMET3DProxyBuilder::scaleProduct
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
Definition: FWMET3DProxyBuilder.cc:92
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWViewContext
Definition: FWViewContext.h:32
DDAxes::phi
FWViewEnergyScale::getScaleFactor3D
float getScaleFactor3D() const
Definition: FWViewEnergyScale.h:44
MET.h
fireworks::Context::caloZ1
static float caloZ1(bool offset=true)
Definition: Context.cc:183
FWMET3DProxyBuilder::Arrow::Arrow
Arrow(Float_t x, Float_t y, Float_t z, Float_t xo, Float_t yo, Float_t zo=0)
Definition: FWMET3DProxyBuilder.cc:43
FWViewEnergyScale
Definition: FWViewEnergyScale.h:34
FWMET3DProxyBuilder::Arrow::m_energy
float m_energy
Definition: FWMET3DProxyBuilder.cc:40
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
FWViewEnergyScale.h
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
Min
T Min(T a, T b)
Definition: MathUtil.h:39
FWViewContext::getEnergyScale
FWViewEnergyScale * getEnergyScale() const
Definition: FWViewContext.cc:25
class-composition.parent
parent
Definition: class-composition.py:88
fireworks::Context::caloR1
static float caloR1(bool offset=true)
Definition: Context.cc:180
Context.h