Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  *  FWPSimHitProxyBuilder.cc
0003  *  FWorks
0004  *
0005  *  Created by Ianna Osborne on 9/9/10.
0006  *
0007  */
0008 
0009 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0010 #include "Fireworks/Core/interface/FWEventItem.h"
0011 #include "Fireworks/Core/interface/FWGeometry.h"
0012 #include "Fireworks/Core/interface/fwLog.h"
0013 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0014 #include <DataFormats/MuonDetId/interface/DTWireId.h>
0015 
0016 #include "TEvePointSet.h"
0017 
0018 class FWPSimHitProxyBuilder : public FWSimpleProxyBuilderTemplate<PSimHit> {
0019 public:
0020   FWPSimHitProxyBuilder(void) {}
0021   ~FWPSimHitProxyBuilder(void) override {}
0022 
0023   bool haveSingleProduct() const override { return false; }
0024 
0025   REGISTER_PROXYBUILDER_METHODS();
0026 
0027   // Disable default copy constructor
0028   FWPSimHitProxyBuilder(const FWPSimHitProxyBuilder&) = delete;
0029   // Disable default assignment operator
0030   const FWPSimHitProxyBuilder& operator=(const FWPSimHitProxyBuilder&) = delete;
0031 
0032 private:
0033   using FWSimpleProxyBuilderTemplate<PSimHit>::buildViewType;
0034   void buildViewType(const PSimHit& iData,
0035                      unsigned int iIndex,
0036                      TEveElement& oItemHolder,
0037                      FWViewType::EType type,
0038                      const FWViewContext*) override;
0039 };
0040 
0041 void FWPSimHitProxyBuilder::buildViewType(
0042     const PSimHit& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type, const FWViewContext*) {
0043   TEvePointSet* pointSet = new TEvePointSet;
0044   setupAddElement(pointSet, &oItemHolder);
0045   const FWGeometry* geom = item()->getGeom();
0046   unsigned int rawid = iData.detUnitId();
0047   if (!geom->contains(rawid)) {
0048     fwLog(fwlog::kError) << "failed to get geometry of detid: " << rawid << std::endl;
0049     return;
0050   }
0051 
0052   float local[3] = {iData.localPosition().x(), iData.localPosition().y(), iData.localPosition().z()};
0053   float global[3];
0054 
0055   // Specialized for DT simhits
0056   DetId id(rawid);
0057   if (id.det() == DetId::Muon && id.subdetId() == 1) {
0058     DTWireId wId(rawid);
0059     rawid = wId.layerId().rawId();  // DT simhits are in the RF of the DTLayer, but their ID is the id of the wire!
0060     if (abs(iData.particleType()) != 13) {
0061       pointSet->SetMarkerStyle(26);  // Draw non-muon simhits (e.g. delta rays) with a different marker
0062     }
0063     if (type == FWViewType::kRhoZ) {  //
0064       // In RhoZ view, draw hits at the middle of the layer in the global Z coordinate,
0065       // otherwise they won't align with 1D rechits, for which only one coordinate is known.
0066       if (wId.superLayer() == 2) {
0067         local[1] = 0;
0068       } else {
0069         local[0] = 0;
0070       }
0071     }
0072   }
0073 
0074   geom->localToGlobal(rawid, local, global);
0075   pointSet->SetNextPoint(global[0], global[1], global[2]);
0076 }
0077 
0078 REGISTER_FWPROXYBUILDER(FWPSimHitProxyBuilder, PSimHit, "PSimHits", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);