File indexing completed on 2024-04-06 12:11:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "TEveStraightLineSet.h"
0015 #include "TEvePointSet.h"
0016 #include "TEveLine.h"
0017
0018
0019 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0020 #include "Fireworks/Core/interface/FWEventItem.h"
0021 #include "Fireworks/Core/interface/FWMagField.h"
0022 #include "Fireworks/Tracks/interface/TrackUtils.h"
0023 #include "Fireworks/Tracks/interface/estimate_field.h"
0024 #include "Fireworks/Core/interface/FWGeometry.h"
0025 #include "Fireworks/Core/interface/fwLog.h"
0026
0027 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0028 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0029 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0030
0031 class FWTrajectorySeedProxyBuilder : public FWSimpleProxyBuilderTemplate<TrajectorySeed> {
0032 public:
0033 FWTrajectorySeedProxyBuilder();
0034 ~FWTrajectorySeedProxyBuilder() override;
0035
0036 REGISTER_PROXYBUILDER_METHODS();
0037
0038 FWTrajectorySeedProxyBuilder(const FWTrajectorySeedProxyBuilder&) = delete;
0039
0040 const FWTrajectorySeedProxyBuilder& operator=(const FWTrajectorySeedProxyBuilder&) = delete;
0041
0042 private:
0043 using FWSimpleProxyBuilderTemplate<TrajectorySeed>::build;
0044 void build(const TrajectorySeed& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0045 };
0046
0047 FWTrajectorySeedProxyBuilder::FWTrajectorySeedProxyBuilder() {}
0048
0049 FWTrajectorySeedProxyBuilder::~FWTrajectorySeedProxyBuilder() {}
0050
0051 void FWTrajectorySeedProxyBuilder::build(const TrajectorySeed& iData,
0052 unsigned int iIndex,
0053 TEveElement& itemHolder,
0054 const FWViewContext*) {
0055
0056
0057
0058
0059
0060 TEvePointSet* pointSet = new TEvePointSet;
0061 TEveLine* line = new TEveLine;
0062 TEveStraightLineSet* lineSet = new TEveStraightLineSet;
0063
0064 for (auto const& hit : iData.recHits()) {
0065 unsigned int id = hit.geographicalId();
0066 const FWGeometry* geom = item()->getGeom();
0067 const float* pars = geom->getParameters(id);
0068 const SiPixelRecHit* rh = dynamic_cast<const SiPixelRecHit*>(&hit);
0069
0070 if (rh) {
0071 const SiPixelCluster* itc = rh->cluster().get();
0072 if (!geom->contains(id)) {
0073 fwLog(fwlog::kWarning) << "failed get geometry of SiPixelCluster with detid: " << id << std::endl;
0074 continue;
0075 }
0076
0077 float localPoint[3] = {
0078 fireworks::pixelLocalX((*itc).minPixelRow(), pars), fireworks::pixelLocalY((*itc).minPixelCol(), pars), 0.0};
0079
0080 float globalPoint[3];
0081 geom->localToGlobal(id, localPoint, globalPoint);
0082
0083 pointSet->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
0084 line->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
0085
0086 }
0087
0088 else {
0089 const SiStripCluster* cluster = fireworks::extractClusterFromTrackingRecHit(&hit);
0090
0091 if (cluster) {
0092 short firststrip = cluster->firstStrip();
0093 float localTop[3] = {0.0, 0.0, 0.0};
0094 float localBottom[3] = {0.0, 0.0, 0.0};
0095
0096 fireworks::localSiStrip(firststrip, localTop, localBottom, pars, id);
0097
0098 float globalTop[3];
0099 float globalBottom[3];
0100 geom->localToGlobal(id, localTop, globalTop, localBottom, globalBottom);
0101
0102 lineSet->AddLine(globalTop[0], globalTop[1], globalTop[2], globalBottom[0], globalBottom[1], globalBottom[2]);
0103 }
0104 }
0105 }
0106
0107 setupAddElement(pointSet, &itemHolder);
0108 setupAddElement(line, &itemHolder);
0109 setupAddElement(lineSet, &itemHolder);
0110 }
0111
0112
0113
0114
0115 REGISTER_FWPROXYBUILDER(FWTrajectorySeedProxyBuilder,
0116 TrajectorySeed,
0117 "TrajectorySeeds",
0118 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);