Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Tracks
0004 // Class  :     FWSiStripDigiProxyBuilder
0005 //
0006 //
0007 // Original Author:
0008 //         Created:  Thu Dec  6 18:01:21 PST 2007
0009 //
0010 
0011 #include "TEveStraightLineSet.h"
0012 
0013 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0014 #include "Fireworks/Core/interface/FWEventItem.h"
0015 #include "Fireworks/Core/interface/FWGeometry.h"
0016 #include "Fireworks/Core/interface/fwLog.h"
0017 #include "Fireworks/Tracks/interface/TrackUtils.h"
0018 
0019 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0020 #include "DataFormats/Common/interface/DetSetVector.h"
0021 #include "DataFormats/DetId/interface/DetId.h"
0022 
0023 class FWSiStripDigiProxyBuilder : public FWProxyBuilderBase {
0024 public:
0025   FWSiStripDigiProxyBuilder(void) {}
0026   ~FWSiStripDigiProxyBuilder(void) override {}
0027 
0028   REGISTER_PROXYBUILDER_METHODS();
0029 
0030 private:
0031   using FWProxyBuilderBase::build;
0032   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0033 
0034 public:
0035   FWSiStripDigiProxyBuilder(const FWSiStripDigiProxyBuilder&) = delete;
0036   const FWSiStripDigiProxyBuilder& operator=(const FWSiStripDigiProxyBuilder&) = delete;
0037 };
0038 
0039 void FWSiStripDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0040   const edm::DetSetVector<SiStripDigi>* digis = nullptr;
0041 
0042   iItem->get(digis);
0043 
0044   if (!digis) {
0045     return;
0046   }
0047   const FWGeometry* geom = iItem->getGeom();
0048 
0049   for (edm::DetSetVector<SiStripDigi>::const_iterator it = digis->begin(), end = digis->end(); it != end; ++it) {
0050     edm::DetSet<SiStripDigi> ds = *it;
0051     const uint32_t& id = ds.id;
0052 
0053     const float* pars = geom->getParameters(id);
0054 
0055     for (edm::DetSet<SiStripDigi>::const_iterator idigi = ds.data.begin(), idigiEnd = ds.data.end(); idigi != idigiEnd;
0056          ++idigi) {
0057       TEveStraightLineSet* lineSet = new TEveStraightLineSet;
0058       setupAddElement(lineSet, product);
0059 
0060       if (!geom->contains(id)) {
0061         fwLog(fwlog::kWarning) << "failed get geometry and topology of SiStripDigi with detid: " << id << std::endl;
0062         continue;
0063       }
0064       float localTop[3] = {0.0, 0.0, 0.0};
0065       float localBottom[3] = {0.0, 0.0, 0.0};
0066 
0067       fireworks::localSiStrip((*idigi).strip(), localTop, localBottom, pars, id);
0068 
0069       float globalTop[3];
0070       float globalBottom[3];
0071       geom->localToGlobal(id, localTop, globalTop, localBottom, globalBottom);
0072 
0073       lineSet->AddLine(globalTop[0], globalTop[1], globalTop[2], globalBottom[0], globalBottom[1], globalBottom[2]);
0074     }  // end of iteration over digis
0075   }    // end of iteration over the DetSetVector
0076 }
0077 
0078 REGISTER_FWPROXYBUILDER(FWSiStripDigiProxyBuilder,
0079                         edm::DetSetVector<SiStripDigi>,
0080                         "SiStripDigi",
0081                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);