File indexing completed on 2024-04-06 12:11:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "TEveGeoNode.h"
0014 #include "TEveGeoShape.h"
0015 #include "TEveStraightLineSet.h"
0016
0017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0018 #include "Fireworks/Core/interface/FWEventItem.h"
0019 #include "Fireworks/Core/interface/FWGeometry.h"
0020 #include "Fireworks/Core/interface/fwLog.h"
0021
0022 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0023
0024 class FWGEMRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<GEMRecHit> {
0025 public:
0026 FWGEMRecHitProxyBuilder() {}
0027 ~FWGEMRecHitProxyBuilder() override {}
0028
0029 bool haveSingleProduct() const override { return false; }
0030
0031 REGISTER_PROXYBUILDER_METHODS();
0032
0033 FWGEMRecHitProxyBuilder(const FWGEMRecHitProxyBuilder&) = delete;
0034 const FWGEMRecHitProxyBuilder& operator=(const FWGEMRecHitProxyBuilder&) = delete;
0035
0036 private:
0037 using FWSimpleProxyBuilderTemplate<GEMRecHit>::buildViewType;
0038 void buildViewType(const GEMRecHit& iData,
0039 unsigned int iIndex,
0040 TEveElement& oItemHolder,
0041 FWViewType::EType type,
0042 const FWViewContext*) override;
0043 };
0044
0045 void FWGEMRecHitProxyBuilder::buildViewType(const GEMRecHit& iData,
0046 unsigned int iIndex,
0047 TEveElement& oItemHolder,
0048 FWViewType::EType type,
0049 const FWViewContext*) {
0050 GEMDetId gemId = iData.gemId();
0051 unsigned int rawid = gemId.rawId();
0052
0053 const FWGeometry* geom = item()->getGeom();
0054
0055 if (!geom->contains(rawid)) {
0056 fwLog(fwlog::kError) << "failed to get geometry of GEM roll with detid: " << rawid << std::endl;
0057 return;
0058 }
0059
0060 TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
0061 recHitSet->SetLineWidth(3);
0062
0063 if (type == FWViewType::k3D || type == FWViewType::kISpy) {
0064 TEveGeoShape* shape = geom->getEveShape(rawid);
0065 shape->SetMainTransparency(75);
0066 shape->SetMainColor(item()->defaultDisplayProperties().color());
0067 recHitSet->AddElement(shape);
0068 }
0069
0070 float localX = iData.localPosition().x();
0071 float localY = iData.localPosition().y();
0072 float localZ = iData.localPosition().z();
0073
0074 float localXerr = sqrt(iData.localPositionError().xx());
0075 float localYerr = sqrt(iData.localPositionError().yy());
0076
0077 float localU1[3] = {localX - localXerr, localY, localZ};
0078
0079 float localU2[3] = {localX + localXerr, localY, localZ};
0080
0081 float localV1[3] = {localX, localY - localYerr, localZ};
0082
0083 float localV2[3] = {localX, localY + localYerr, localZ};
0084
0085 float globalU1[3];
0086 float globalU2[3];
0087 float globalV1[3];
0088 float globalV2[3];
0089
0090 FWGeometry::IdToInfoItr det = geom->find(rawid);
0091
0092 geom->localToGlobal(*det, localU1, globalU1);
0093 geom->localToGlobal(*det, localU2, globalU2);
0094 geom->localToGlobal(*det, localV1, globalV1);
0095 geom->localToGlobal(*det, localV2, globalV2);
0096
0097 recHitSet->AddLine(globalU1[0], globalU1[1], globalU1[2], globalU2[0], globalU2[1], globalU2[2]);
0098
0099 recHitSet->AddLine(globalV1[0], globalV1[1], globalV1[2], globalV2[0], globalV2[1], globalV2[2]);
0100
0101 setupAddElement(recHitSet, &oItemHolder);
0102 }
0103
0104 REGISTER_FWPROXYBUILDER(FWGEMRecHitProxyBuilder,
0105 GEMRecHit,
0106 "GEM RecHits",
0107 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);