Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Muon
0004 // Class  :     FWGEMDigiProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author: mccauley
0010 //         Created:  Sun Jan  6 23:57:00 EST 2008
0011 // $Id: FWRPCDigiProxyBuilder.cc,v 1.14 2010/09/07 15:46:48 yana Exp $
0012 // $Id: FWGEMDigiProxyBuilder.cc,v 1.15 2013/10/10 22:06:00 YusangKim$
0013 //
0014 
0015 #include "TEveStraightLineSet.h"
0016 #include "TEveCompound.h"
0017 #include "TEveGeoNode.h"
0018 
0019 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0020 #include "Fireworks/Core/interface/FWEventItem.h"
0021 #include "Fireworks/Core/interface/FWGeometry.h"
0022 #include "Fireworks/Core/interface/fwLog.h"
0023 
0024 #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
0025 #include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h"
0026 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0027 #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h"
0028 
0029 class FWGEMDigiProxyBuilder : public FWProxyBuilderBase {
0030 public:
0031   FWGEMDigiProxyBuilder() {}
0032   ~FWGEMDigiProxyBuilder() override {}
0033 
0034   REGISTER_PROXYBUILDER_METHODS();
0035 
0036 private:
0037   using FWProxyBuilderBase::build;
0038   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0039 
0040 public:
0041   FWGEMDigiProxyBuilder(const FWGEMDigiProxyBuilder&) = delete;
0042   const FWGEMDigiProxyBuilder& operator=(const FWGEMDigiProxyBuilder&) = delete;
0043 };
0044 
0045 void FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0046   const GEMDigiCollection* digis = nullptr;
0047 
0048   iItem->get(digis);
0049 
0050   if (!digis) {
0051     fwLog(fwlog::kWarning) << "Failed to get GEMDigis" << std::endl;
0052     return;
0053   }
0054   const FWGeometry* geom = iItem->getGeom();
0055 
0056   for (GEMDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0057     unsigned int rawid = (*dri).first.rawId();
0058     const GEMDigiCollection::Range& range = (*dri).second;
0059 
0060     if (!geom->contains(rawid)) {
0061       fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
0062 
0063       TEveCompound* compound = createCompound();
0064       setupAddElement(compound, product);
0065 
0066       continue;
0067     }
0068 
0069     const float* parameters = geom->getParameters(rawid);
0070     float nStrips = parameters[0];
0071     float halfStripLength = parameters[1] * 0.5;
0072     float topPitch = parameters[3];
0073     float bottomPitch = parameters[4];
0074 
0075     for (GEMDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0076       TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
0077       stripDigiSet->SetLineWidth(3);
0078       setupAddElement(stripDigiSet, product);
0079 
0080       int strip = (*dit).strip();
0081       float topOfStrip = (strip - 0.5) * topPitch - 0.5 * nStrips * topPitch;
0082       float bottomOfStrip = (strip - 0.5) * bottomPitch - 0.5 * nStrips * bottomPitch;
0083 
0084       float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
0085 
0086       float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
0087 
0088       float globalPointTop[3];
0089       float globalPointBottom[3];
0090 
0091       geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
0092 
0093       stripDigiSet->AddLine(globalPointTop[0],
0094                             globalPointTop[1],
0095                             globalPointTop[2],
0096                             globalPointBottom[0],
0097                             globalPointBottom[1],
0098                             globalPointBottom[2]);
0099     }
0100   }
0101 }
0102 
0103 REGISTER_FWPROXYBUILDER(FWGEMDigiProxyBuilder,
0104                         GEMDigiCollection,
0105                         "GEMDigi",
0106                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);
0107 
0108 class FWGEMPadDigiProxyBuilder : public FWProxyBuilderBase {
0109 public:
0110   FWGEMPadDigiProxyBuilder() {}
0111   ~FWGEMPadDigiProxyBuilder() override {}
0112 
0113   REGISTER_PROXYBUILDER_METHODS();
0114 
0115 public:
0116   FWGEMPadDigiProxyBuilder(const FWGEMPadDigiProxyBuilder&) = delete;
0117   const FWGEMPadDigiProxyBuilder& operator=(const FWGEMPadDigiProxyBuilder&) = delete;
0118 
0119 private:
0120   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0121 };
0122 
0123 void FWGEMPadDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0124   const GEMPadDigiCollection* digis = nullptr;
0125 
0126   iItem->get(digis);
0127 
0128   if (!digis) {
0129     fwLog(fwlog::kWarning) << "Failed to get GEMPadDigis" << std::endl;
0130     return;
0131   }
0132   const FWGeometry* geom = iItem->getGeom();
0133 
0134   for (GEMPadDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0135     unsigned int rawid = (*dri).first.rawId();
0136     const GEMPadDigiCollection::Range& range = (*dri).second;
0137 
0138     if (!geom->contains(rawid)) {
0139       fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
0140 
0141       TEveCompound* compound = createCompound();
0142       setupAddElement(compound, product);
0143 
0144       continue;
0145     }
0146 
0147     const float* parameters = geom->getParameters(rawid);
0148     float nStrips = parameters[0];
0149     float halfStripLength = parameters[1] * 0.5;
0150     float nPads = parameters[5];
0151     float topPitch = parameters[3] * nStrips / nPads;
0152     float bottomPitch = parameters[4] * nStrips / nPads;
0153 
0154     for (GEMPadDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0155       TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
0156       stripDigiSet->SetLineWidth(3 * nStrips / nPads);
0157       setupAddElement(stripDigiSet, product);
0158 
0159       int pad = (*dit).pad();
0160       float topOfStrip = (pad - 0.5) * topPitch - 0.5 * topPitch * nPads;
0161       float bottomOfStrip = (pad - 0.5) * bottomPitch - 0.5 * bottomPitch * nPads;
0162 
0163       float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
0164 
0165       float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
0166 
0167       float globalPointTop[3];
0168       float globalPointBottom[3];
0169 
0170       geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
0171 
0172       stripDigiSet->AddLine(globalPointTop[0],
0173                             globalPointTop[1],
0174                             globalPointTop[2],
0175                             globalPointBottom[0],
0176                             globalPointBottom[1],
0177                             globalPointBottom[2]);
0178     }
0179   }
0180 }
0181 
0182 REGISTER_FWPROXYBUILDER(FWGEMPadDigiProxyBuilder,
0183                         GEMPadDigiCollection,
0184                         "GEMPadDigi",
0185                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);