Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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