CMS 3D CMS Logo

FWPFEcalRecHitLegoProxyBuilder.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
6  const FWViewContext *vc) {
7  FWViewEnergyScale *caloScale = vc->getEnergyScale();
8  bool b = caloScale->getPlotEt();
9  float maxVal = getMaxVal(b);
10  typedef std::vector<FWPFLegoRecHit *> rh;
11 
12  // printf("FWPFEcalRecHitLegoProxyBuilder::scaleProduct >> scale %f \n", caloScale->getValToHeight());
13  for (rh::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i) { // Tallest tower needs deciding still
14  if ((*i)->isTallest() == false && (*i)->getEtEnergy(b) == maxVal)
15  (*i)->setIsTallest(true);
16 
17  (*i)->updateScale(vc, getMaxValLog(caloScale->getPlotEt()));
18  }
19 }
20 
21 //______________________________________________________________________________
23  TEveElement *parent,
24  FWViewType::EType viewType,
25  const FWViewContext *vc) {
26  for (TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i) {
27  {
28  TEveStraightLineSet *line = dynamic_cast<TEveStraightLineSet *>(*i);
29  if (line) {
30  line->SetMarkerColor(item()->modelInfo(iId.index()).displayProperties().color());
31  }
32  }
33  }
34 }
35 
36 //______________________________________________________________________________
37 TEveVector FWPFEcalRecHitLegoProxyBuilder::calculateCentre(const std::vector<TEveVector> &corners) const {
38  TEveVector centre;
39 
40  for (size_t i = 0; i < corners.size(); ++i) {
41  centre.fX += corners[i].fX;
42  centre.fY += corners[i].fY; // Get total for x,y,z values
43  centre.fZ += corners[i].fZ;
44  }
45  centre *= 1.f / 8.f;
46 
47  return centre;
48 }
49 
50 //______________________________________________________________________________
52  TEveElementList *product,
53  const FWViewContext *vc) {
54  size_t itemSize = iItem->size(); //cache size
55 
56  for (size_t index = 0; index < itemSize; ++index) {
57  TEveCompound *itemHolder = createCompound();
58  product->AddElement(itemHolder);
59 
60  const EcalRecHit &iData = modelData(index);
61  const float *corners = item()->getGeom()->getCorners(iData.detid());
62  float energy, et;
63  std::vector<TEveVector> etaphiCorners(8);
64  TEveVector centre;
65 
66  if (corners == nullptr)
67  continue;
68 
69  int k = 3;
70  for (int i = 0; i < 4; ++i) {
71  int j = k * 3;
72  TEveVector cv = TEveVector(corners[j], corners[j + 1], corners[j + 2]);
73  etaphiCorners[i].fX = cv.Eta(); // Conversion of rechit X/Y values for plotting in Eta/Phi
74  etaphiCorners[i].fY = cv.Phi();
75  etaphiCorners[i].fZ = 0.0;
76 
77  etaphiCorners[i + 4].fX =
78  etaphiCorners[i].fX; // Top can simply be plotted exactly over the top of the bottom face
79  etaphiCorners[i + 4].fY = etaphiCorners[i].fY;
80  etaphiCorners[i + 4].fZ = 0.001;
81  // printf("%f %f %d \n", etaphiCorners[i].fX, etaphiCorners[i].fY, i);
82  --k;
83  }
84 
85  centre = calculateCentre(etaphiCorners);
86  energy = iData.energy();
87  et = FWPFMaths::calculateEt(centre, energy);
89 
90  if (energy > m_maxEnergy)
92  if (energy > m_maxEt)
93  m_maxEt = et;
94 
95  // Stop phi wrap
96  float dPhi1 = etaphiCorners[2].fY - etaphiCorners[1].fY;
97  float dPhi2 = etaphiCorners[3].fY - etaphiCorners[0].fY;
98  float dPhi3 = etaphiCorners[1].fY - etaphiCorners[2].fY;
99  float dPhi4 = etaphiCorners[0].fY - etaphiCorners[3].fY;
100 
101  if (dPhi1 > 1)
102  etaphiCorners[2].fY = etaphiCorners[2].fY - (2 * TMath::Pi());
103  if (dPhi2 > 1)
104  etaphiCorners[3].fY = etaphiCorners[3].fY - (2 * TMath::Pi());
105  if (dPhi3 > 1)
106  etaphiCorners[2].fY = etaphiCorners[2].fY + (2 * TMath::Pi());
107  if (dPhi4 > 1)
108  etaphiCorners[3].fY = etaphiCorners[3].fY + (2 * TMath::Pi());
109 
110  FWPFLegoRecHit *recHit = new FWPFLegoRecHit(etaphiCorners, itemHolder, this, vc, energy, et);
111  recHit->setSquareColor(item()->defaultDisplayProperties().color());
112  m_recHits.push_back(recHit);
113  }
114 
117 
119 }
120 
121 //______________________________________________________________________________
123  for (std::vector<FWPFLegoRecHit *>::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i)
124  delete (*i);
125 
126  m_recHits.clear();
127 }
128 
129 //______________________________________________________________________________
const double Pi
size_t size() const
Definition: FWEventItem.cc:457
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
int index() const
Definition: FWModelId.h:41
cv
Definition: cuy.py:363
const fireworks::Context & context() const
const EcalRecHit & modelData(int index)
bool getPlotEt() const
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
FWViewEnergyScale * getEnergyScale() const
TEveVector calculateCentre(const std::vector< TEveVector > &corners) const
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:439
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:169
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
double b
Definition: hdecay.h:118
const DetId & detid() const
Definition: EcalRecHit.h:72
float energy() const
Definition: EcalRecHit.h:68
const FWEventItem * item() const
std::vector< FWPFLegoRecHit * > m_recHits
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override