CMS 3D CMS Logo

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 void
49 FWPFEcalRecHitRPProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
50 {
51  m_towers.clear(); // Bug fix required for when multiple RhoPhiPF views are active
52  for( unsigned int index = 0; index < static_cast<unsigned int>( iItem->size() ); ++index )
53  {
54  TEveCompound *itemHolder = createCompound();
55  product->AddElement( itemHolder );
57 
58  if( info.displayProperties().isVisible() )
59  {
60  bool added = false;
61  float E, et;
62  float ecalR = FWPFGeom::caloR1();
63  Double_t lPhi, rPhi;
64  const EcalRecHit &iData = modelData( index );
65  const float *vertices = item()->getGeom()->getCorners( iData.detid() );
66 
67  TEveVector centre = calculateCentre( vertices );
68  TEveVector lVec = TEveVector( vertices[0], vertices[1], 0 ); // Bottom left corner of tower
69  TEveVector rVec = TEveVector( vertices[9], vertices[10], 0 ); // Bottom right corner of tower
70 
71  lPhi = lVec.Phi();
72  rPhi = rVec.Phi();
73  E = iData.energy();
74  et = FWPFMaths::calculateEt( centre, E );
75 
76  for( unsigned int i = 0; i < m_towers.size(); i++ )
77  { // Small range to catch rounding inaccuracies etc.
78  Double_t phi = m_towers[i]->getlPhi();
79  if( ( lPhi == phi ) || ( ( lPhi < phi + 0.0005 ) && ( lPhi > phi - 0.0005 ) ) )
80  {
81  m_towers[i]->addChild( this, itemHolder, vc, E, et );
82  context().voteMaxEtAndEnergy( et, E );
83  added = true;
84  break;
85  }
86  }
87 
88  if( !added )
89  {
90  rVec.fX = ecalR * cos( rPhi ); rVec.fY = ecalR * sin( rPhi );
91  lVec.fX = ecalR * cos( lPhi ); lVec.fY = ecalR * sin( lPhi );
92  std::vector<TEveVector> bCorners(2);
93  bCorners[0] = lVec;
94  bCorners[1] = rVec;
95 
96  FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit( this, itemHolder, vc, E, et, lPhi, rPhi, bCorners );
97  context().voteMaxEtAndEnergy(et, E);
98  m_towers.push_back( rh );
99  }
100  }
101  }
102 }
103 
104 //______________________________________________________________________________
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
static const TGPicture * info(bool iBackgroundIsBlack)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:183
std::vector< FWPFRhoPhiRecHit * > m_towers
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const DetId & detid() const
Definition: EcalRecHit.h:72
const FWEventItem * item() const
const EcalRecHit & modelData(int index)
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
float caloR1()
Definition: FWPFGeom.h:21
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float energy() const
Definition: EcalRecHit.h:68
TEveVector calculateCentre(const float *corners)
float calculateEt(const TEveVector &centre, float e)
Definition: FWPFMaths.cc:115
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:430
size_t size() const
Definition: FWEventItem.cc:550
et
define resolution functions of each parameter
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683