CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWJetProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calo
4 // Class : FWJetProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 // $Id: FWJetProxyBuilder.cc,v 1.28 2010/11/11 20:25:27 amraktad Exp $
12 //
13 
14 #include "TEveJetCone.h"
15 #include "TEveScalableStraightLineSet.h"
16 
17 // user include files
25 
27 
29 {
30 public:
32  virtual ~FWJetProxyBuilder();
33 
34  virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
35  virtual bool haveSingleProduct() const { return false; } // different view types
36  virtual void cleanLocal();
37 
39 
40 protected:
41  virtual void buildViewType(const reco::Jet& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext*);
42 
43 
44  virtual void localModelChanges(const FWModelId& iId, TEveElement* iCompound,
45  FWViewType::EType viewType, const FWViewContext* vc);
46 
47  virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
48 
49 private:
50  FWJetProxyBuilder( const FWJetProxyBuilder& ); // stop default
51  const FWJetProxyBuilder& operator=( const FWJetProxyBuilder& ); // stop default
52 
53  TEveElementList* requestCommon();
54  TEveElementList* m_common;
55 
56  std::vector<fireworks::scaleMarker> m_lines;
57 };
58 
59 //______________________________________________________________________________
61  m_common(0)
62 {
63  m_common = new TEveElementList( "common electron scene" );
64  m_common->IncDenyDestroy();
65 }
66 
68 {
69  m_common->DecDenyDestroy();
70 }
71 
72 TEveElementList*
74 {
75  if( m_common->HasChildren() == false )
76  {
77  for (int i = 0; i < static_cast<int>(item()->size()); ++i)
78  {
79  TEveJetCone* cone = fireworks::makeEveJetCone(modelData(i), context());
80 
81  m_common->AddElement(cone);
82  cone->SetFillColor(item()->defaultDisplayProperties().color());
83  cone->SetLineColor(item()->defaultDisplayProperties().color());
84 
85  }
86  }
87  return m_common;
88 }
89 
90 void
91 FWJetProxyBuilder::buildViewType(const reco::Jet& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* vc)
92 {
93  // add cone from shared pool
94  TEveElementList* cones = requestCommon();
95  TEveElement::List_i coneIt = cones->BeginChildren();
96  std::advance(coneIt, iIndex);
97 
99  setupAddElement( *coneIt, &oItemHolder );
100  (*coneIt)->SetMainTransparency(TMath::Min(100, 80 + dp.transparency() / 5));
101 
102  // scale markers in projected views
103  if (FWViewType::isProjected(type))
104  {
105  TEveScalableStraightLineSet* marker =new TEveScalableStraightLineSet("jet lineset");
106  float size = 1.f; // values are saved in scale
107  double theta = iData.theta();
108  double phi = iData.phi();
109 
110  if ( type == FWViewType::kRhoZ )
111  {
112  static const float_t offr = 4;
113  float r_ecal = context().caloR1() + offr;
114  float z_ecal = context().caloZ1() + offr/tan(context().caloTransAngle());
115 
116  double r(0);
117  if ( theta < context().caloTransAngle() || M_PI-theta < context().caloTransAngle())
118  {
119  z_ecal = context().caloZ2() + offr/tan(context().caloTransAngle());
120  r = z_ecal/fabs(cos(theta));
121  }
122  else
123  {
124  r = r_ecal/sin(theta);
125  }
126 
127  marker->SetScaleCenter( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta) );
128  marker->AddLine( 0., (phi>0 ? r*fabs(sin(theta)) : -r*fabs(sin(theta))), r*cos(theta),
129  0., (phi>0 ? (r+size)*fabs(sin(theta)) : -(r+size)*fabs(sin(theta))), (r+size)*cos(theta) );
130  }
131  else
132  {
133  float ecalR = context().caloR1() + 4;
134  marker->SetScaleCenter(ecalR*cos(phi), ecalR*sin(phi), 0);
135  marker->AddLine(ecalR*cos(phi), ecalR*sin(phi), 0, (ecalR+size)*cos(phi), (ecalR+size)*sin(phi), 0);
136  }
137 
138  marker->SetLineWidth(4);
139 
140  marker->SetLineColor(dp.color());
141 
142  FWViewEnergyScale* caloScale = vc->getEnergyScale();
143  marker->SetScale(caloScale->getScaleFactor3D()*(caloScale->getPlotEt() ? iData.et() : iData.energy()));
144  setupAddElement( marker, &oItemHolder );
145  m_lines.push_back(fireworks::scaleMarker(marker, iData.et(), iData.energy(), vc));
146 
147  context().voteMaxEtAndEnergy(iData.et(), iData.energy());
148  }
149 }
150 
151 void
152 FWJetProxyBuilder::localModelChanges(const FWModelId& iId, TEveElement* iCompound,
153  FWViewType::EType viewType, const FWViewContext* vc)
154 {
155  increaseComponentTransparency(iId.index(), iCompound, "TEveJetCone", 80);
156 }
157 
158 void
160 {
161  m_lines.clear();
162  m_common->DestroyElements();
163 }
164 
165 void
167 {
168  typedef std::vector<fireworks::scaleMarker> Lines_t;
169  for (Lines_t::iterator i = m_lines.begin(); i!= m_lines.end(); ++ i)
170  {
171  if (vc == (*i).m_vc)
172  {
173  float value = vc->getEnergyScale()->getPlotEt() ? (*i).m_et : (*i).m_energy;
174  (*i).m_ls->SetScale(vc->getEnergyScale()->getScaleFactor3D() *value);
175  TEveProjected* proj = *(*i).m_ls->BeginProjecteds();
176  proj->UpdateProjection();
177  }
178  }
179 }
180 
const FWJetProxyBuilder & operator=(const FWJetProxyBuilder &)
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:451
#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
std::vector< fireworks::scaleMarker > m_lines
Base class for all types of Jets.
Definition: Jet.h:21
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
static float caloZ2(bool offset=true)
Definition: Context.cc:225
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
Color_t color() const
static bool isProjected(int)
Definition: FWViewType.cc:128
virtual void cleanLocal()
virtual double energy() const
energy
Char_t transparency() const
int index() const
Definition: FWModelId.h:50
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static float caloR1(bool offset=true)
Definition: Context.cc:210
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
virtual ~FWJetProxyBuilder()
virtual bool havePerViewProduct(FWViewType::EType) const
virtual double theta() const
momentum polar angle
TEveElementList * m_common
virtual bool haveSingleProduct() const
#define M_PI
Definition: BFit3D.cc:3
size_t size() const
Definition: FWEventItem.cc:548
virtual void buildViewType(const reco::Jet &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *)
virtual void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc)
static float caloZ1(bool offset=true)
Definition: Context.cc:220
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
TEveElementList * requestCommon()
virtual double phi() const
momentum azimuthal angle
tuple size
Write out results.
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
TEveJetCone * makeEveJetCone(const reco::Jet &iData, const fireworks::Context &context)
bool getPlotEt() const
Definition: DDAxes.h:10