Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Muon
0004 // Class  :     FWRPCDigiProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author: mccauley
0010 //         Created:  Sun Jan  6 23:57:00 EST 2008
0011 //
0012 
0013 #include "TEveStraightLineSet.h"
0014 #include "TEveCompound.h"
0015 #include "TEveGeoNode.h"
0016 
0017 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0018 #include "Fireworks/Core/interface/FWEventItem.h"
0019 #include "Fireworks/Core/interface/FWGeometry.h"
0020 #include "Fireworks/Core/interface/fwLog.h"
0021 
0022 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
0023 
0024 class FWRPCDigiProxyBuilder : public FWProxyBuilderBase {
0025 public:
0026   FWRPCDigiProxyBuilder() {}
0027   ~FWRPCDigiProxyBuilder() override {}
0028 
0029   REGISTER_PROXYBUILDER_METHODS();
0030 
0031 private:
0032   using FWProxyBuilderBase::build;
0033   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0034 
0035 public:
0036   FWRPCDigiProxyBuilder(const FWRPCDigiProxyBuilder&) = delete;
0037   const FWRPCDigiProxyBuilder& operator=(const FWRPCDigiProxyBuilder&) = delete;
0038 };
0039 
0040 void FWRPCDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0041   const RPCDigiCollection* digis = nullptr;
0042 
0043   iItem->get(digis);
0044 
0045   if (!digis) {
0046     fwLog(fwlog::kWarning) << "Failed to get RPCDigis" << std::endl;
0047     return;
0048   }
0049   const FWGeometry* geom = iItem->getGeom();
0050 
0051   for (RPCDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0052     unsigned int rawid = (*dri).first.rawId();
0053     const RPCDigiCollection::Range& range = (*dri).second;
0054 
0055     if (!geom->contains(rawid)) {
0056       fwLog(fwlog::kWarning) << "Failed to get geometry of RPC roll with detid: " << rawid << std::endl;
0057 
0058       TEveCompound* compound = createCompound();
0059       setupAddElement(compound, product);
0060 
0061       continue;
0062     }
0063 
0064     const float* parameters = geom->getParameters(rawid);
0065     float nStrips = parameters[0];
0066     float halfStripLength = parameters[1] * 0.5;
0067     float pitch = parameters[2];
0068     float offset = -0.5 * nStrips * pitch;
0069 
0070     for (RPCDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0071       TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
0072       stripDigiSet->SetLineWidth(3);
0073       setupAddElement(stripDigiSet, product);
0074 
0075       int strip = (*dit).strip();
0076       float centreOfStrip = (strip - 0.5) * pitch + offset;
0077 
0078       float localPointTop[3] = {centreOfStrip, halfStripLength, 0.0};
0079 
0080       float localPointBottom[3] = {centreOfStrip, -halfStripLength, 0.0};
0081 
0082       float globalPointTop[3];
0083       float globalPointBottom[3];
0084 
0085       geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
0086 
0087       stripDigiSet->AddLine(globalPointTop[0],
0088                             globalPointTop[1],
0089                             globalPointTop[2],
0090                             globalPointBottom[0],
0091                             globalPointBottom[1],
0092                             globalPointBottom[2]);
0093     }
0094   }
0095 }
0096 
0097 REGISTER_FWPROXYBUILDER(FWRPCDigiProxyBuilder,
0098                         RPCDigiCollection,
0099                         "RPCDigi",
0100                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);