Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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