File indexing completed on 2024-04-06 12:11:49
0001
0002
0003
0004
0005
0006
0007
0008 #include "TEvePointSet.h"
0009 #include "TEveStraightLineSet.h"
0010
0011 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0012 #include "Fireworks/Core/interface/FWEventItem.h"
0013 #include "Fireworks/Core/interface/FWGeometry.h"
0014 #include "Fireworks/Core/interface/fwLog.h"
0015
0016 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0017 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
0018
0019 using namespace DTEnums;
0020
0021 class FWDTRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<DTRecHit1DPair> {
0022 public:
0023 FWDTRecHitProxyBuilder(void) {}
0024 ~FWDTRecHitProxyBuilder(void) override {}
0025
0026 bool haveSingleProduct() const override { return false; }
0027
0028 REGISTER_PROXYBUILDER_METHODS();
0029
0030
0031 FWDTRecHitProxyBuilder(const FWDTRecHitProxyBuilder&) = delete;
0032
0033 const FWDTRecHitProxyBuilder& operator=(const FWDTRecHitProxyBuilder&) = delete;
0034
0035 private:
0036 using FWSimpleProxyBuilderTemplate<DTRecHit1DPair>::buildViewType;
0037 void buildViewType(const DTRecHit1DPair& iData,
0038 unsigned int iIndex,
0039 TEveElement& oItemHolder,
0040 FWViewType::EType type,
0041 const FWViewContext*) override;
0042 };
0043
0044 void FWDTRecHitProxyBuilder::buildViewType(const DTRecHit1DPair& iData,
0045 unsigned int iIndex,
0046 TEveElement& oItemHolder,
0047 FWViewType::EType type,
0048 const FWViewContext*) {
0049 const DTLayerId& layerId = iData.wireId().layerId();
0050 int superLayer = layerId.superlayerId().superLayer();
0051
0052 const FWGeometry* geom = item()->getGeom();
0053
0054 if (!geom->contains(layerId)) {
0055 fwLog(fwlog::kError) << "failed get geometry of DT layer with detid: " << layerId << std::endl;
0056 return;
0057 }
0058
0059 TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
0060 setupAddElement(recHitSet, &oItemHolder);
0061
0062 TEvePointSet* pointSet = new TEvePointSet;
0063 setupAddElement(pointSet, &oItemHolder);
0064
0065 const DTRecHit1D* leftRecHit = iData.componentRecHit(Left);
0066 const DTRecHit1D* rightRecHit = iData.componentRecHit(Right);
0067 float lLocalPos[3] = {leftRecHit->localPosition().x(), 0.0, 0.0};
0068 float rLocalPos[3] = {rightRecHit->localPosition().x(), 0.0, 0.0};
0069
0070 if (((type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF) && superLayer != 2) ||
0071 (type == FWViewType::kRhoZ && superLayer == 2) || type == FWViewType::k3D || type == FWViewType::kISpy) {
0072 float leftGlobalPoint[3];
0073 float rightGlobalPoint[3];
0074
0075 geom->localToGlobal(layerId, lLocalPos, leftGlobalPoint, rLocalPos, rightGlobalPoint);
0076
0077 pointSet->SetNextPoint(leftGlobalPoint[0], leftGlobalPoint[1], leftGlobalPoint[2]);
0078 pointSet->SetNextPoint(rightGlobalPoint[0], rightGlobalPoint[1], rightGlobalPoint[2]);
0079
0080 recHitSet->AddLine(leftGlobalPoint[0],
0081 leftGlobalPoint[1],
0082 leftGlobalPoint[2],
0083 rightGlobalPoint[0],
0084 rightGlobalPoint[1],
0085 rightGlobalPoint[2]);
0086 }
0087 }
0088
0089 REGISTER_FWPROXYBUILDER(FWDTRecHitProxyBuilder,
0090 DTRecHit1DPair,
0091 "DT RecHits",
0092 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);