CMS 3D CMS Logo

FWPFEcalRecHitRPProxyBuilder.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
6  const FWViewContext *vc) {
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  m_towers[index]->updateScale(vc);
12  index++;
13  }
14 }
15 
16 //______________________________________________________________________________
18  typedef std::vector<FWPFRhoPhiRecHit *> rpRecHits;
19  for (rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i)
20  (*i)->clean();
21 
22  m_towers.clear();
23 }
24 
25 //______________________________________________________________________________
27  TEveVector centre;
28 
29  for (unsigned int i = 0; i < 8; i++) {
30  int j = i * 3;
31  centre.fX += vertices[j];
32  centre.fY += vertices[j + 1]; // Total x,y,z values
33  centre.fZ += vertices[j + 2];
34  }
35 
36  centre *= 1.0f / 8.0f; // Actually calculate the centre point
37 
38  return centre;
39 }
40 
41 //______________________________________________________________________________
42 void FWPFEcalRecHitRPProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) {
43  m_towers.clear(); // Bug fix required for when multiple RhoPhiPF views are active
44  for (unsigned int index = 0; index < static_cast<unsigned int>(iItem->size()); ++index) {
45  TEveCompound *itemHolder = createCompound();
46  product->AddElement(itemHolder);
48 
49  if (info.displayProperties().isVisible()) {
50  bool added = false;
51  float E, et;
52  float ecalR = FWPFGeom::caloR1();
53  Double_t lPhi, rPhi;
54  const EcalRecHit &iData = modelData(index);
55  const float *vertices = item()->getGeom()->getCorners(iData.detid());
56 
57  TEveVector centre = calculateCentre(vertices);
58  TEveVector lVec = TEveVector(vertices[0], vertices[1], 0); // Bottom left corner of tower
59  TEveVector rVec = TEveVector(vertices[9], vertices[10], 0); // Bottom right corner of tower
60 
61  lPhi = lVec.Phi();
62  rPhi = rVec.Phi();
63  E = iData.energy();
64  et = FWPFMaths::calculateEt(centre, E);
65 
66  for (unsigned int i = 0; i < m_towers.size(); i++) { // Small range to catch rounding inaccuracies etc.
67  Double_t phi = m_towers[i]->getlPhi();
68  if ((lPhi == phi) || ((lPhi < phi + 0.0005) && (lPhi > phi - 0.0005))) {
69  m_towers[i]->addChild(this, itemHolder, vc, E, et);
71  added = true;
72  break;
73  }
74  }
75 
76  if (!added) {
77  rVec.fX = ecalR * cos(rPhi);
78  rVec.fY = ecalR * sin(rPhi);
79  lVec.fX = ecalR * cos(lPhi);
80  lVec.fY = ecalR * sin(lPhi);
81  std::vector<TEveVector> bCorners(2);
82  bCorners[0] = lVec;
83  bCorners[1] = rVec;
84 
85  FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit(this, itemHolder, vc, E, et, lPhi, rPhi, bCorners);
87  m_towers.push_back(rh);
88  }
89  }
90  }
91 }
92 
93 //______________________________________________________________________________
size_t size() const
Definition: FWEventItem.cc:457
static const TGPicture * info(bool iBackgroundIsBlack)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const fireworks::Context & context() const
const EcalRecHit & modelData(int index)
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
float caloR1()
Definition: FWPFGeom.h:20
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:439
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TEveVector calculateCentre(const float *corners)
float calculateEt(const TEveVector &centre, float e)
Definition: FWPFMaths.cc:115
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const DetId & detid() const
Definition: EcalRecHit.h:72
std::vector< FWPFRhoPhiRecHit * > m_towers
float energy() const
Definition: EcalRecHit.h:68
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
const FWEventItem * item() const