CMS 3D CMS Logo

FWPFRhoPhiRecHit.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
5  float E, float et, double lPhi, double rPhi, std::vector<TEveVector> &bCorners )
6  : m_hasChild(false), m_energy(E), m_et(et), m_lPhi(lPhi), m_rPhi(rPhi), m_child(nullptr)
7 {
8  buildRecHit( pb, iH, vc, bCorners );
9 }
10 
11 //______________________________________________________________________________
13 
14 //______________________________________________________________________________
15 void
17 {
18  FWViewEnergyScale *caloScale = vc->getEnergyScale();
19  float value = caloScale->getPlotEt() ? m_et : m_energy;
20  Double_t scale = caloScale->getScaleFactor3D() * value;
21  unsigned int a = 0;
22 
23  if( scale < 0.f )
24  scale *= -1.f;
25 
26  // Scale centres
27  TEveVector sc1 = m_corners[1];
28  TEveVector sc2 = m_corners[0];
29 
30  // Used to store normalized vectors
31  TEveVector v1 = sc1; // Bottom right corner
32  TEveVector v2 = sc2; // Bottom left corner
33 
34  v1.Normalize();
35  v2.Normalize();
36 
37  v1 *= scale; // Now at new height
38  v2 *= scale;
39 
40 
41  // Get line parameters and scale coordinates
42  TEveChunkManager::iterator li( m_ls->GetLinePlex() );
43  while( li.next() )
44  {
45  TEveStraightLineSet::Line_t &l = *( TEveStraightLineSet::Line_t* ) li();
46  switch( a )
47  {
48  case 0:
49  // Left side of tower first
50  l.fV1[0] = sc2.fX;
51  l.fV1[1] = sc2.fY;
52  l.fV2[0] = sc2.fX + v2.fX;
53  l.fV2[1] = sc2.fY + v2.fY;
54  break;
55 
56  case 1:
57  // Top of tower
58  l.fV1[0] = sc2.fX + v2.fX;
59  l.fV1[1] = sc2.fY + v2.fY;
60  l.fV2[0] = sc1.fX + v1.fX;
61  l.fV2[1] = sc1.fY + v1.fY;
62  break;
63 
64  case 2:
65  // Right hand side of tower
66  l.fV1[0] = sc1.fX + v1.fX;
67  l.fV1[1] = sc1.fY + v1.fY;
68  l.fV2[0] = sc1.fX;
69  l.fV2[1] = sc1.fY;
70  break;
71 
72  case 3:
73  // Bottom of tower
74  l.fV1[0] = sc1.fX;
75  l.fV1[1] = sc1.fY;
76  l.fV2[0] = sc2.fX;
77  l.fV2[1] = sc2.fY;
78  break;
79  }
80  a++;
81  }
82  TEveProjected *proj = *(m_ls)->BeginProjecteds();
83  proj->UpdateProjection();
84 
85  m_corners[2] = sc2 + v2; // New top left of tower
86  m_corners[3] = sc1 + v1; // New top right of tower
87 
88  if( m_hasChild )
89  {
90  m_child->setCorners( 0, m_corners[2] );
91  m_child->setCorners( 1, m_corners[3] ); // Base of child is now top of parent
92  m_child->updateScale( vc );
93  }
94 }
95 
96 //______________________________________________________________________________
97 void
99 {
100  m_corners.clear();
101  if( m_hasChild )
102  m_child->clean();
103 
104  delete this;
105 }
106 
107 //______________________________________________________________________________
108 void
109 FWPFRhoPhiRecHit::addChild( FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, float E, float et )
110 {
111  if( m_hasChild ) // Already has a child stacked on top so move on to child
112  m_child->addChild( pb, itemHolder, vc, E, et );
113  else
114  {
115  std::vector<TEveVector> corners(2);
116  corners[0] = m_corners[2]; // Top left of current tower
117  corners[1] = m_corners[3]; // Top right of current tower
118  m_child = new FWPFRhoPhiRecHit( pb, itemHolder, vc, E, et, m_lPhi, m_rPhi, corners );
119  m_hasChild = true;
120  }
121 }
122 
123 //______________________________________________________________________________
124 void
125 FWPFRhoPhiRecHit::buildRecHit( FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, std::vector<TEveVector> &bCorners )
126 {
127  float scale = 0;
128  float value = 0;
129  TEveVector v1, v2, v3, v4;
130  TEveVector vec;
131 
132  FWViewEnergyScale *caloScale = vc->getEnergyScale();
133  value = caloScale->getPlotEt() ? m_et : m_energy;
134  scale = caloScale->getScaleFactor3D() * value;
135 
136  v1 = bCorners[0]; // Bottom left
137  v2 = bCorners[1]; // Bottom right
138 
139  v3 = v1;
140  vec = v3;
141  vec.Normalize();
142  v3 = v3 + ( vec * scale );
143 
144  v4 = v2;
145  vec = v4;
146  vec.Normalize();
147  v4 = v4 + ( vec * scale );
148 
149  m_ls = new TEveScalableStraightLineSet( "rhophiRecHit" );
150  m_ls->AddLine( v1.fX, v1.fY, 0, v3.fX, v3.fY, 0 ); // Bottom left - Top left
151  m_ls->AddLine( v3.fX, v3.fY, 0, v4.fX, v4.fY, 0 ); // Top left - Top right
152  m_ls->AddLine( v4.fX, v4.fY, 0, v2.fX, v2.fY, 0 ); // Top right - Bottom right
153  m_ls->AddLine( v2.fX, v2.fY, 0, v1.fX, v1.fY, 0 ); // Bottom right - Bottom left
154 
155  m_corners.push_back( v1 );
156  m_corners.push_back( v2 );
157  m_corners.push_back( v3 );
158  m_corners.push_back( v4 );
159 
160  pb->setupAddElement( m_ls, itemHolder );
161 }
float getScaleFactor3D() const
std::vector< TEveVector > m_corners
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
#define nullptr
FWViewEnergyScale * getEnergyScale() const
FWPFRhoPhiRecHit(FWProxyBuilderBase *pb, TEveElement *iH, const FWViewContext *vc, float E, float et, double lPhi, double rPhi, std::vector< TEveVector > &bCorners)
double f[11][100]
Definition: value.py:1
void addChild(FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, float E, float et)
void updateScale(TEveScalableStraightLineSet *ls, Double_t scale, unsigned int i)
void buildRecHit(FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, std::vector< TEveVector > &bCorners)
et
define resolution functions of each parameter
virtual ~FWPFRhoPhiRecHit()
double a
Definition: hdecay.h:121
void setCorners(int i, TEveVector vec)
TEveScalableStraightLineSet * m_ls
bool getPlotEt() const
FWPFRhoPhiRecHit * m_child