Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:54

0001 // -*- C++ -*-
0002 //
0003 // Package:     TrajectorySeeds
0004 // Class  :     FWTrajectorySeedProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Nov 25 14:42:13 EST 2008
0011 //
0012 
0013 // system include files
0014 #include "TEveStraightLineSet.h"
0015 #include "TEvePointSet.h"
0016 #include "TEveLine.h"
0017 
0018 // user include files
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;  // stop default
0039 
0040   const FWTrajectorySeedProxyBuilder& operator=(const FWTrajectorySeedProxyBuilder&) = delete;  // stop default
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   // LocalPoint pnt = iData.startingState().parameters().position();
0056   // std::cout << pnt << std::endl;
0057   // std::cout << dynamic_cast<const SiPixelRecHit *>(&(*iData.recHits().first)) << std::endl;
0058   // TEveVector startPos(pnt.x(), pnt.y(), pnt.z());
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     // std::cout << id << "id "<<   std::endl;
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 // static member functions
0114 //
0115 REGISTER_FWPROXYBUILDER(FWTrajectorySeedProxyBuilder,
0116                         TrajectorySeed,
0117                         "TrajectorySeeds",
0118                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);