CMS 3D CMS Logo

FWMETProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWMETProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 //
12 
13 // system include files
14 #include "TEveGeoNode.h"
15 #include "TEveGeoShape.h"
16 #include "TEveScalableStraightLineSet.h"
17 #include "TGeoTube.h"
18 #include "TMath.h"
19 
20 // user include files
28 
30 
32 //
33 // RPZ proxy builder with shared MET shape
34 //
36 
38 public:
40  ~FWMETProxyBuilder() override {}
41 
42  bool haveSingleProduct() const override { return false; } // use buildViewType instead of buildView
43 
44  bool havePerViewProduct(FWViewType::EType) const override { return true; } // used energy scaling
45 
46  void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override;
47 
48  void cleanLocal() override { m_lines.clear(); }
49 
51 
52 private:
53  FWMETProxyBuilder(const FWMETProxyBuilder&) = delete; // stop default
54  const FWMETProxyBuilder& operator=(const FWMETProxyBuilder&) = delete; // stop default
55 
57  void buildViewType(const reco::MET& iData,
58  unsigned int iIndex,
59  TEveElement& oItemHolder,
61  const FWViewContext*) override;
62 
63  std::vector<fireworks::scaleMarker> m_lines;
64 };
65 
67  typedef std::vector<fireworks::scaleMarker> Lines_t;
68  FWViewEnergyScale* caloScale = vc->getEnergyScale();
69 
70  // printf("MET %s %p -> %f\n", item()->name().c_str(), vc, caloScale->getScaleFactor3D() );
71  for (Lines_t::iterator i = m_lines.begin(); i != m_lines.end(); ++i) {
72  if (vc == (*i).m_vc) {
73  // printf("lineset %s %p val %f ...%f\n", item()->name().c_str(), (*i).m_ls , (*i).m_et, caloScale->getScaleFactor3D()*(*i).m_et);
74  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
75 
76  (*i).m_ls->SetScale(caloScale->getScaleFactor3D() * value);
77 
78  TEveProjectable* pable = static_cast<TEveProjectable*>((*i).m_ls);
79  for (TEveProjectable::ProjList_i j = pable->BeginProjecteds(); j != pable->EndProjecteds(); ++j) {
80  (*j)->UpdateProjection();
81  }
82  }
83  }
84 }
85 
87  unsigned int iIndex,
88  TEveElement& oItemHolder,
90  const FWViewContext* vc) {
91  using namespace TMath;
92  double phi = met.phi();
93  double theta = met.theta();
94  double size = 1.f;
95 
96  FWViewEnergyScale* caloScale = vc->getEnergyScale();
97 
98  TEveScalableStraightLineSet* marker = new TEveScalableStraightLineSet("MET marker");
99  marker->SetLineWidth(2);
100 
101  if (type == FWViewType::kRhoZ) {
102  // body
103  double r0;
104  if (TMath::Abs(met.eta()) < context().caloTransEta()) {
105  r0 = context().caloR1() / sin(theta);
106  } else {
107  r0 = context().caloZ1() / fabs(cos(theta));
108  }
109  marker->SetScaleCenter(0., Sign(r0 * sin(theta), phi), r0 * cos(theta));
110  double r1 = r0 + 1;
111  marker->AddLine(0., Sign(r0 * sin(theta), phi), r0 * cos(theta), 0., Sign(r1 * sin(theta), phi), r1 * cos(theta));
112 
113  // arrow pointer
114  double r2 = r1 - 0.1;
115  double dy = 0.05 * size;
116  marker->AddLine(0.,
117  Sign(r2 * sin(theta) + dy * cos(theta), phi),
118  r2 * cos(theta) - dy * sin(theta),
119  0.,
120  Sign(r1 * sin(theta), phi),
121  r1 * cos(theta));
122  dy = -dy;
123  marker->AddLine(0.,
124  Sign(r2 * sin(theta) + dy * cos(theta), phi),
125  r2 * cos(theta) - dy * sin(theta),
126  0.,
127  Sign(r1 * sin(theta), phi),
128  r1 * cos(theta));
129 
130  // segment
132  this, &oItemHolder, context().caloR1() - 1, context().caloZ1() - 1, theta - 0.04, theta + 0.04, phi);
133  } else {
134  // body
135  double r0 = context().caloR1();
136  double r1 = r0 + 1;
137  marker->SetScaleCenter(r0 * cos(phi), r0 * sin(phi), 0);
138  marker->AddLine(r0 * cos(phi), r0 * sin(phi), 0, r1 * cos(phi), r1 * sin(phi), 0);
139 
140  // arrow pointer, xy rotate offset point ..
141  double r2 = r1 - 0.1;
142  double dy = 0.05 * size;
143 
144  marker->AddLine(r2 * cos(phi) - dy * sin(phi), r2 * sin(phi) + dy * cos(phi), 0, r1 * cos(phi), r1 * sin(phi), 0);
145  dy = -dy;
146  marker->AddLine(r2 * cos(phi) - dy * sin(phi), r2 * sin(phi) + dy * cos(phi), 0, r1 * cos(phi), r1 * sin(phi), 0);
147 
148  // segment
149  double min_phi = phi - M_PI / 36 / 2;
150  double max_phi = phi + M_PI / 36 / 2;
151  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
152  TEveGeoShape* element =
153  fireworks::getShape("spread", new TGeoTubeSeg(r0 - 2, r0, 1, min_phi * 180 / M_PI, max_phi * 180 / M_PI), 0);
154  element->SetPickable(kTRUE);
155  setupAddElement(element, &oItemHolder);
156  }
157 
158  marker->SetScale(caloScale->getScaleFactor3D() * (caloScale->getPlotEt() ? met.et() : met.energy()));
159  setupAddElement(marker, &oItemHolder);
160 
161  // printf("add line %s %f %f .... eta %f theta %f\n", item()->name().c_str(), met.et(), met.energy(), met.eta(), met.theta());
162  m_lines.push_back(fireworks::scaleMarker(marker, met.et(), met.energy(), vc)); // register for scales
163 
164  context().voteMaxEtAndEnergy(met.et(), met.energy());
165 }
166 
FWMETProxyBuilder::haveSingleProduct
bool haveSingleProduct() const override
Definition: FWMETProxyBuilder.cc:42
mps_fire.i
i
Definition: mps_fire.py:428
FWSimpleProxyBuilderTemplate.h
FWMETProxyBuilder::m_lines
std::vector< fireworks::scaleMarker > m_lines
Definition: FWMETProxyBuilder.cc:63
FWViewType::EType
EType
Definition: FWViewType.h:31
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWViewType::kRhoZ
Definition: FWViewType.h:33
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
Sign
T Sign(T A, T B)
Definition: MathUtil.h:54
FWViewEnergyScale::getPlotEt
bool getPlotEt() const
Definition: FWViewEnergyScale.h:47
BuilderUtils.h
FWMETProxyBuilder::buildViewType
void buildViewType(const reco::MET &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
Definition: FWMETProxyBuilder.cc:86
fireworks::getShape
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:44
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FWMETProxyBuilder::operator=
const FWMETProxyBuilder & operator=(const FWMETProxyBuilder &)=delete
reco::MET
Definition: MET.h:41
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
FWViewType.h
Abs
T Abs(T a)
Definition: MathUtil.h:49
fireworks::Context::voteMaxEtAndEnergy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
fireworks::Context::caloTransEta
static float caloTransEta()
Definition: Context.cc:187
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
fireworks::addRhoZEnergyProjection
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:58
FWMETProxyBuilder::FWMETProxyBuilder
FWMETProxyBuilder()
Definition: FWMETProxyBuilder.cc:39
FWPFGeom::caloR1
float caloR1()
Definition: FWPFGeom.h:20
FWMETProxyBuilder::~FWMETProxyBuilder
~FWMETProxyBuilder() override
Definition: FWMETProxyBuilder.cc:40
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
FWPFGeom::caloZ1
float caloZ1()
Definition: FWPFGeom.h:21
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
value
Definition: value.py:1
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
FWMETProxyBuilder::scaleProduct
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
Definition: FWMETProxyBuilder.cc:66
PVValHelper::dy
Definition: PVValidationHelpers.h:50
scaleMarker.h
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
DDAxes::phi
FWViewEnergyScale::getScaleFactor3D
float getScaleFactor3D() const
Definition: FWViewEnergyScale.h:44
MET.h
FWMETProxyBuilder::cleanLocal
void cleanLocal() override
Definition: FWMETProxyBuilder.cc:48
fireworks::Context::caloZ1
static float caloZ1(bool offset=true)
Definition: Context.cc:183
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
relativeConstraints.value
value
Definition: relativeConstraints.py:53
FWViewEnergyScale
Definition: FWViewEnergyScale.h:34
fireworks::scaleMarker
Definition: scaleMarker.h:25
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
FWViewEnergyScale.h
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
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
FWMETProxyBuilder::havePerViewProduct
bool havePerViewProduct(FWViewType::EType) const override
Definition: FWMETProxyBuilder.cc:44
Context.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
FWMETProxyBuilder
Definition: FWMETProxyBuilder.cc:37