CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWPFEcalRecHitRPProxyBuilder.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
4 void
6 {
7  typedef std::vector<FWPFRhoPhiRecHit*> rpRecHits;
8  unsigned int index = 0;
9 
10  for( rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i )
11  {
12  m_towers[index]->updateScale( vc );
13  index++;
14  }
15 }
16 
17 //______________________________________________________________________________
18 void
20 {
21  typedef std::vector<FWPFRhoPhiRecHit*> rpRecHits;
22  for( rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i )
23  (*i)->clean();
24 
25  m_towers.clear();
26 }
27 
28 //______________________________________________________________________________
29 TEveVector
31 {
32  TEveVector centre;
33 
34  for( unsigned int i = 0; i < 8; i++ )
35  {
36  int j = i * 3;
37  centre.fX += vertices[j];
38  centre.fY += vertices[j+1]; // Total x,y,z values
39  centre.fZ += vertices[j+2];
40  }
41 
42  centre *= 1.0f / 8.0f; // Actually calculate the centre point
43 
44  return centre;
45 }
46 
47 //______________________________________________________________________________
48 float
49 FWPFEcalRecHitRPProxyBuilder::calculateEt( const TEveVector &centre, float E )
50 {
51  TEveVector vec = centre;
52  float et;
53 
54  vec.Normalize();
55  vec *= E;
56  et = vec.Perp();
57 
58  return et;
59 }
60 
61 //______________________________________________________________________________
62 void
63 FWPFEcalRecHitRPProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
64 {
65  m_towers.clear(); // Bug fix required for when multiple RhoPhiPF views are active
66  for( unsigned int index = 0; index < static_cast<unsigned int>( iItem->size() ); ++index )
67  {
68  TEveCompound *itemHolder = createCompound();
69  product->AddElement( itemHolder );
70 
71  bool added = false;
72  float E, et;
73  float ecalR = m_pfUtils->getCaloR1();
74  Double_t lPhi, rPhi;
75  const EcalRecHit &iData = modelData( index );
76  const float *vertices = item()->getGeom()->getCorners( iData.detid() );
77 
78  TEveVector centre = calculateCentre( vertices );
79  TEveVector lVec = TEveVector( vertices[0], vertices[1], 0 ); // Bottom left corner of tower
80  TEveVector rVec = TEveVector( vertices[9], vertices[10], 0 ); // Bottom right corner of tower
81 
82  lPhi = lVec.Phi();
83  rPhi = rVec.Phi();
84  E = iData.energy();
85  et = calculateEt( centre, E );
86 
87  for( unsigned int i = 0; i < m_towers.size(); i++ )
88  { // Small range to catch rounding inaccuracies etc.
89  Double_t phi = m_towers[i]->getlPhi();
90  if( ( lPhi == phi ) || ( ( lPhi < phi + 0.0005 ) && ( lPhi > phi - 0.0005 ) ) )
91  {
92  m_towers[i]->addChild( this, itemHolder, vc, E, et );
93  context().voteMaxEtAndEnergy( et, E );
94  added = true;
95  break;
96  }
97  }
98 
99  if( !added )
100  {
101  rVec.fX = ecalR * cos( rPhi ); rVec.fY = ecalR * sin( rPhi );
102  lVec.fX = ecalR * cos( lPhi ); lVec.fY = ecalR * sin( lPhi );
103  std::vector<TEveVector> bCorners(2);
104  bCorners[0] = lVec;
105  bCorners[1] = rVec;
106 
107  FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit( this, itemHolder, vc, E, et, lPhi, rPhi, bCorners );
108  context().voteMaxEtAndEnergy(et, E);
109  m_towers.push_back( rh );
110  }
111  }
112 }
113 
114 //______________________________________________________________________________
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
list parent
Definition: dbtoconf.py:74
const DetId & detid() const
Definition: CaloRecHit.h:21
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:185
std::vector< FWPFRhoPhiRecHit * > m_towers
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float getCaloR1()
Definition: FWPFUtils.h:46
const FWEventItem * item() const
const EcalRecHit & modelData(int index)
float energy() const
Definition: CaloRecHit.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
TEveVector calculateCentre(const float *corners)
float calculateEt(const TEveVector &centre, float E)
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:278
size_t size() const
Definition: FWEventItem.cc:549
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:688
Definition: DDAxes.h:10