Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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