File indexing completed on 2024-04-06 12:11:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "TEvePointSet.h"
0013 #include "TEveStraightLineSet.h"
0014 #include "TEveCompound.h"
0015 #include "TEveBox.h"
0016 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0017 #include "Fireworks/Core/interface/FWEventItem.h"
0018 #include "Fireworks/Core/interface/FWGeometry.h"
0019 #include "Fireworks/Core/interface/fwLog.h"
0020 #include "Fireworks/Tracks/interface/TrackUtils.h"
0021
0022 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0023
0024 class FWSiPixelClusterProxyBuilder : public FWProxyBuilderBase {
0025 public:
0026 FWSiPixelClusterProxyBuilder(void) {}
0027 ~FWSiPixelClusterProxyBuilder(void) override {}
0028
0029 REGISTER_PROXYBUILDER_METHODS();
0030
0031
0032 FWSiPixelClusterProxyBuilder(const FWSiPixelClusterProxyBuilder&) = delete;
0033
0034 const FWSiPixelClusterProxyBuilder& operator=(const FWSiPixelClusterProxyBuilder&) = delete;
0035
0036 private:
0037 using FWProxyBuilderBase::build;
0038 void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0039 };
0040
0041 void FWSiPixelClusterProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0042 const SiPixelClusterCollectionNew* pixels = nullptr;
0043
0044 iItem->get(pixels);
0045
0046 if (!pixels) {
0047 fwLog(fwlog::kWarning) << "failed get SiPixelDigis" << std::endl;
0048 return;
0049 }
0050
0051 for (SiPixelClusterCollectionNew::const_iterator set = pixels->begin(), setEnd = pixels->end(); set != setEnd;
0052 ++set) {
0053 unsigned int id = set->detId();
0054
0055 const FWGeometry* geom = iItem->getGeom();
0056 const float* pars = geom->getParameters(id);
0057
0058 const edmNew::DetSet<SiPixelCluster>& clusters = *set;
0059
0060 for (edmNew::DetSet<SiPixelCluster>::const_iterator itc = clusters.begin(), edc = clusters.end(); itc != edc;
0061 ++itc) {
0062 TEveElement* itemHolder = createCompound();
0063 product->AddElement(itemHolder);
0064
0065 TEvePointSet* pointSet = new TEvePointSet;
0066
0067 if (!geom->contains(id)) {
0068 fwLog(fwlog::kWarning) << "failed get geometry of SiPixelCluster with detid: " << id << std::endl;
0069 continue;
0070 }
0071
0072 float localPoint[3] = {
0073 fireworks::pixelLocalX((*itc).minPixelRow(), pars), fireworks::pixelLocalY((*itc).minPixelCol(), pars), 0.0};
0074
0075 float globalPoint[3];
0076 geom->localToGlobal(id, localPoint, globalPoint);
0077
0078 pointSet->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
0079
0080 setupAddElement(pointSet, itemHolder);
0081
0082 TEveStraightLineSet* ls = new TEveStraightLineSet();
0083 for (int j = 0; j < (*itc).size(); j++) {
0084
0085 float adc = 0.025;
0086 float offsetx[4] = {-0.4, -0.4, +0.4, +0.4};
0087 float offsety[4] = {-0.4, +0.4, +0.4, -0.4};
0088
0089
0090 std::vector<TEveVector> boxCorners;
0091 for (int of = 0; of < 8; of++) {
0092 float lp[3] = {fireworks::pixelLocalX((*itc).pixel(j).x + offsetx[of % 4], pars),
0093 fireworks::pixelLocalY((*itc).pixel(j).y + offsety[of % 4], pars),
0094 (of < 4) ? (0.0f) : (adc)};
0095
0096 TEveVector p;
0097 geom->localToGlobal(id, lp, p.Arr());
0098
0099 boxCorners.push_back(p);
0100 }
0101
0102
0103 ls->AddLine(boxCorners[0], boxCorners[1]);
0104 ls->AddLine(boxCorners[1], boxCorners[2]);
0105 ls->AddLine(boxCorners[2], boxCorners[3]);
0106 ls->AddLine(boxCorners[3], boxCorners[0]);
0107
0108 ls->AddLine(boxCorners[4], boxCorners[5]);
0109 ls->AddLine(boxCorners[5], boxCorners[6]);
0110 ls->AddLine(boxCorners[6], boxCorners[7]);
0111 ls->AddLine(boxCorners[7], boxCorners[4]);
0112
0113 ls->AddLine(boxCorners[0], boxCorners[4]);
0114 ls->AddLine(boxCorners[1], boxCorners[5]);
0115 ls->AddLine(boxCorners[2], boxCorners[6]);
0116 ls->AddLine(boxCorners[3], boxCorners[7]);
0117 }
0118
0119 setupAddElement(ls, itemHolder);
0120 }
0121 }
0122 }
0123
0124 REGISTER_FWPROXYBUILDER(FWSiPixelClusterProxyBuilder,
0125 SiPixelClusterCollectionNew,
0126 "SiPixelCluster",
0127 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);