CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 "TEveScalableStraightLineSet.h"
16 #include "TGeoTube.h"
17 #include "TMath.h"
18 
19 // user include files
27 
29 
31 //
32 // RPZ proxy builder with shared MET shape
33 //
35 
37 {
38 public:
40  virtual ~FWMETProxyBuilder() {}
41 
42  virtual bool haveSingleProduct() const { return false; } // use buildViewType instead of buildView
43 
44  virtual bool havePerViewProduct(FWViewType::EType) const { return true; } // used energy scaling
45 
46  virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
47 
48  virtual void cleanLocal() { m_lines.clear(); }
49 
51 
52 private:
53 
54  FWMETProxyBuilder( const FWMETProxyBuilder& ); // stop default
55  const FWMETProxyBuilder& operator=( const FWMETProxyBuilder& ); // stop default
56 
58  virtual void buildViewType(const reco::MET& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*);
59 
60  std::vector<fireworks::scaleMarker> m_lines;
61 };
62 
63 void
65 {
66  typedef std::vector<fireworks::scaleMarker> Lines_t;
67  FWViewEnergyScale* caloScale = vc->getEnergyScale();
68 
69  // printf("MET %s %p -> %f\n", item()->name().c_str(), vc, caloScale->getScaleFactor3D() );
70  for (Lines_t::iterator i = m_lines.begin(); i!= m_lines.end(); ++ i)
71  {
72  if ( vc == (*i).m_vc )
73  {
74  // printf("lineset %s %p val %f ...%f\n", item()->name().c_str(), (*i).m_ls , (*i).m_et, caloScale->getScaleFactor3D()*(*i).m_et);
75  float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
76 
77  (*i).m_ls->SetScale(caloScale->getScaleFactor3D()*value);
78 
79  TEveProjectable *pable = static_cast<TEveProjectable*>((*i).m_ls);
80  for (TEveProjectable::ProjList_i j = pable->BeginProjecteds(); j != pable->EndProjecteds(); ++j)
81  {
82  (*j)->UpdateProjection();
83  }
84  }
85  }
86 }
87 
88 void
89 FWMETProxyBuilder::buildViewType(const reco::MET& met, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* vc)
90 {
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 
102 
103  if ( type == FWViewType::kRhoZ )
104  {
105  // body
106  double r0;
107  if (TMath::Abs(met.eta()) < context().caloTransEta())
108  {
109  r0 = context().caloR1()/sin(theta);
110  }
111  else
112  {
113  r0 = context().caloZ1()/fabs(cos(theta));
114  }
115  marker->SetScaleCenter( 0., Sign(r0*sin(theta), phi), r0*cos(theta) );
116  double r1 = r0 + 1;
117  marker->AddLine( 0., Sign(r0*sin(theta), phi), r0*cos(theta),
118  0., Sign(r1*sin(theta), phi), r1*cos(theta) );
119 
120  // arrow pointer
121  double r2 = r1 - 0.1;
122  double dy = 0.05*size;
123  marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta),
124  0., Sign(r1*sin(theta), phi), r1*cos(theta) );
125  dy = -dy;
126  marker->AddLine( 0., Sign(r2*sin(theta) + dy*cos(theta), phi), r2*cos(theta) -dy*sin(theta),
127  0., Sign(r1*sin(theta), phi), r1*cos(theta) );
128 
129  // segment
130  fireworks::addRhoZEnergyProjection( this, &oItemHolder, context().caloR1() -1, context().caloZ1() -1,
131  theta - 0.04, theta + 0.04,
132  phi );
133  }
134  else
135  {
136  // body
137  double r0 = context().caloR1();
138  double r1 = r0 + 1;
139  marker->SetScaleCenter( r0*cos(phi), r0*sin(phi), 0 );
140  marker->AddLine( r0*cos(phi), r0*sin(phi), 0,
141  r1*cos(phi), r1*sin(phi), 0);
142 
143  // arrow pointer, xy rotate offset point ..
144  double r2 = r1 - 0.1;
145  double dy = 0.05*size;
146 
147  marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0,
148  r1*cos(phi), r1*sin(phi), 0);
149  dy = -dy;
150  marker->AddLine( r2*cos(phi) -dy*sin(phi), r2*sin(phi) + dy*cos(phi), 0,
151  r1*cos(phi), r1*sin(phi), 0);
152 
153  // segment
154  double min_phi = phi-M_PI/36/2;
155  double max_phi = phi+M_PI/36/2;
156  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
157  TEveGeoShape *element = fireworks::getShape( "spread", new TGeoTubeSeg( r0 - 2, r0, 1, min_phi*180/M_PI, max_phi*180/M_PI ), 0 );
158  element->SetPickable( kTRUE );
159  setupAddElement( element, &oItemHolder );
160  }
161 
162  marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? met.et() : met.energy()));
163  setupAddElement( marker, &oItemHolder );
164 
165  // printf("add line %s %f %f .... eta %f theta %f\n", item()->name().c_str(), met.et(), met.energy(), met.eta(), met.theta());
166  m_lines.push_back(fireworks::scaleMarker(marker, met.et(), met.energy(), vc)); // register for scales
167 
168  context().voteMaxEtAndEnergy(met.et(), met.energy());
169 }
170 
static float caloTransEta()
Definition: Context.cc:230
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
float getScaleFactor3D() const
std::vector< fireworks::scaleMarker > m_lines
int i
Definition: DBlmapReader.cc:9
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
list parent
Definition: dbtoconf.py:74
static const int kAllRPZBits
Definition: FWViewType.h:58
virtual double et() const
transverse energy
T Sign(T A, T B)
Definition: MathUtil.h:54
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
Geom::Theta< T > theta() const
virtual bool havePerViewProduct(FWViewType::EType) const
virtual double eta() const
momentum pseudorapidity
float caloR1()
Definition: FWPFGeom.h:21
virtual double energy() const
energy
Definition: MET.h:42
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T Abs(T a)
Definition: MathUtil.h:49
static float caloR1(bool offset=true)
Definition: Context.cc:210
int j
Definition: DBlmapReader.cc:9
#define M_PI
virtual double theta() const
momentum polar angle
void addRhoZEnergyProjection(FWProxyBuilderBase *, TEveElement *, double r_ecal, double z_ecal, double theta_min, double theta_max, double phi)
Definition: BuilderUtils.cc:60
float caloZ1()
Definition: FWPFGeom.h:22
const FWMETProxyBuilder & operator=(const FWMETProxyBuilder &)
virtual void cleanLocal()
virtual void buildViewType(const reco::MET &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *)
static float caloZ1(bool offset=true)
Definition: Context.cc:220
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
virtual ~FWMETProxyBuilder()
virtual bool haveSingleProduct() const
TEveGeoShape * getShape(const char *name, TGeoBBox *shape, Color_t color)
Definition: BuilderUtils.cc:42
virtual double phi() const
momentum azimuthal angle
tuple size
Write out results.
bool getPlotEt() const