File indexing completed on 2024-04-06 12:11:51
0001 #include "FWPFEcalRecHitRPProxyBuilder.h"
0002
0003
0004 void FWPFEcalRecHitRPProxyBuilder::scaleProduct(TEveElementList *parent,
0005 FWViewType::EType type,
0006 const FWViewContext *vc) {
0007 typedef std::vector<FWPFRhoPhiRecHit *> rpRecHits;
0008 unsigned int index = 0;
0009
0010 for (rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i) {
0011 m_towers[index]->updateScale(vc);
0012 index++;
0013 }
0014 }
0015
0016
0017 void FWPFEcalRecHitRPProxyBuilder::cleanLocal() {
0018 typedef std::vector<FWPFRhoPhiRecHit *> rpRecHits;
0019 for (rpRecHits::iterator i = m_towers.begin(); i != m_towers.end(); ++i)
0020 (*i)->clean();
0021
0022 m_towers.clear();
0023 }
0024
0025
0026 TEveVector FWPFEcalRecHitRPProxyBuilder::calculateCentre(const float *vertices) {
0027 TEveVector centre;
0028
0029 for (unsigned int i = 0; i < 8; i++) {
0030 int j = i * 3;
0031 centre.fX += vertices[j];
0032 centre.fY += vertices[j + 1];
0033 centre.fZ += vertices[j + 2];
0034 }
0035
0036 centre *= 1.0f / 8.0f;
0037
0038 return centre;
0039 }
0040
0041
0042 void FWPFEcalRecHitRPProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) {
0043 m_towers.clear();
0044 for (unsigned int index = 0; index < static_cast<unsigned int>(iItem->size()); ++index) {
0045 TEveCompound *itemHolder = createCompound();
0046 product->AddElement(itemHolder);
0047 const FWEventItem::ModelInfo &info = item()->modelInfo(index);
0048
0049 if (info.displayProperties().isVisible()) {
0050 bool added = false;
0051 float E, et;
0052 float ecalR = FWPFGeom::caloR1();
0053 Double_t lPhi, rPhi;
0054 const EcalRecHit &iData = modelData(index);
0055 const float *vertices = item()->getGeom()->getCorners(iData.detid());
0056
0057 TEveVector centre = calculateCentre(vertices);
0058 TEveVector lVec = TEveVector(vertices[0], vertices[1], 0);
0059 TEveVector rVec = TEveVector(vertices[9], vertices[10], 0);
0060
0061 lPhi = lVec.Phi();
0062 rPhi = rVec.Phi();
0063 E = iData.energy();
0064 et = FWPFMaths::calculateEt(centre, E);
0065
0066 for (unsigned int i = 0; i < m_towers.size(); i++) {
0067 Double_t phi = m_towers[i]->getlPhi();
0068 if ((lPhi == phi) || ((lPhi < phi + 0.0005) && (lPhi > phi - 0.0005))) {
0069 m_towers[i]->addChild(this, itemHolder, vc, E, et);
0070 context().voteMaxEtAndEnergy(et, E);
0071 added = true;
0072 break;
0073 }
0074 }
0075
0076 if (!added) {
0077 rVec.fX = ecalR * cos(rPhi);
0078 rVec.fY = ecalR * sin(rPhi);
0079 lVec.fX = ecalR * cos(lPhi);
0080 lVec.fY = ecalR * sin(lPhi);
0081 std::vector<TEveVector> bCorners(2);
0082 bCorners[0] = lVec;
0083 bCorners[1] = rVec;
0084
0085 FWPFRhoPhiRecHit *rh = new FWPFRhoPhiRecHit(this, itemHolder, vc, E, et, lPhi, rPhi, bCorners);
0086 context().voteMaxEtAndEnergy(et, E);
0087 m_towers.push_back(rh);
0088 }
0089 }
0090 }
0091 }
0092
0093
0094 REGISTER_FWPROXYBUILDER(FWPFEcalRecHitRPProxyBuilder, EcalRecHit, "PF Ecal RecHit", FWViewType::kRhoPhiPFBit);