Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:02

0001 // -*- C++ -*-
0002 //
0003 // Package:     Muons
0004 // Class  :     FWCSCRecHitProxyBuilder
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/CSCRecHit/interface/CSCRecHit2DCollection.h"
0017 
0018 class FWCSCRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<CSCRecHit2D> {
0019 public:
0020   FWCSCRecHitProxyBuilder(void) {}
0021   ~FWCSCRecHitProxyBuilder(void) override {}
0022 
0023   REGISTER_PROXYBUILDER_METHODS();
0024 
0025   FWCSCRecHitProxyBuilder(const FWCSCRecHitProxyBuilder&) = delete;
0026   const FWCSCRecHitProxyBuilder& operator=(const FWCSCRecHitProxyBuilder&) = delete;
0027 
0028 private:
0029   using FWSimpleProxyBuilderTemplate<CSCRecHit2D>::build;
0030   void build(const CSCRecHit2D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0031 };
0032 
0033 void FWCSCRecHitProxyBuilder::build(const CSCRecHit2D& iData,
0034                                     unsigned int iIndex,
0035                                     TEveElement& oItemHolder,
0036                                     const FWViewContext*) {
0037   const FWGeometry* geom = item()->getGeom();
0038   unsigned int rawid = iData.cscDetId().rawId();
0039 
0040   if (!geom->contains(rawid)) {
0041     fwLog(fwlog::kError) << "failed to get geometry of CSC layer with detid: " << rawid << std::endl;
0042     return;
0043   }
0044   FWGeometry::IdToInfoItr det = geom->find(rawid);
0045 
0046   TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
0047   setupAddElement(recHitSet, &oItemHolder);
0048 
0049   TEvePointSet* pointSet = new TEvePointSet;
0050   setupAddElement(pointSet, &oItemHolder);
0051 
0052   float localPositionX = iData.localPosition().x();
0053   float localPositionY = iData.localPosition().y();
0054 
0055   float localPositionXX = sqrt(iData.localPositionError().xx());
0056   float localPositionYY = sqrt(iData.localPositionError().yy());
0057 
0058   float localU1Point[3] = {localPositionX - localPositionXX, localPositionY, 0.0};
0059 
0060   float localU2Point[3] = {localPositionX + localPositionXX, localPositionY, 0.0};
0061 
0062   float localV1Point[3] = {localPositionX, localPositionY - localPositionYY, 0.0};
0063 
0064   float localV2Point[3] = {localPositionX, localPositionY + localPositionYY, 0.0};
0065 
0066   float globalU1Point[3];
0067   float globalU2Point[3];
0068   float globalV1Point[3];
0069   float globalV2Point[3];
0070 
0071   geom->localToGlobal(*det, localU1Point, globalU1Point);
0072   geom->localToGlobal(*det, localU2Point, globalU2Point);
0073   geom->localToGlobal(*det, localV1Point, globalV1Point);
0074   geom->localToGlobal(*det, localV2Point, globalV2Point);
0075 
0076   pointSet->SetNextPoint(globalU1Point[0], globalU1Point[1], globalU1Point[2]);
0077   pointSet->SetNextPoint(globalU2Point[0], globalU2Point[1], globalU2Point[2]);
0078   pointSet->SetNextPoint(globalV1Point[0], globalV1Point[1], globalV1Point[2]);
0079   pointSet->SetNextPoint(globalV2Point[0], globalV2Point[1], globalV2Point[2]);
0080 
0081   recHitSet->AddLine(
0082       globalU1Point[0], globalU1Point[1], globalU1Point[2], globalU2Point[0], globalU2Point[1], globalU2Point[2]);
0083 
0084   recHitSet->AddLine(
0085       globalV1Point[0], globalV1Point[1], globalV1Point[2], globalV2Point[0], globalV2Point[1], globalV2Point[2]);
0086 }
0087 
0088 REGISTER_FWPROXYBUILDER(FWCSCRecHitProxyBuilder,
0089                         CSCRecHit2D,
0090                         "CSC RecHits",
0091                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);