Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //#include "TEveStraightLineSet.h"
0002 #include "TEveBoxSet.h"
0003 #include "TEveCompound.h"
0004 #include "TEveGeoNode.h"
0005 
0006 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0007 #include "Fireworks/Core/interface/FWEventItem.h"
0008 #include "Fireworks/Core/interface/FWGeometry.h"
0009 #include "Fireworks/Core/interface/fwLog.h"
0010 
0011 #include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h"
0012 #include "Geometry/GEMGeometry/interface/ME0Geometry.h"
0013 #include "Geometry/GEMGeometry/interface/ME0EtaPartition.h"
0014 
0015 class FWME0DigiProxyBuilder : public FWProxyBuilderBase {
0016 public:
0017   FWME0DigiProxyBuilder() {}
0018   ~FWME0DigiProxyBuilder() override {}
0019 
0020   REGISTER_PROXYBUILDER_METHODS();
0021 
0022   FWME0DigiProxyBuilder(const FWME0DigiProxyBuilder&) = delete;
0023   const FWME0DigiProxyBuilder& operator=(const FWME0DigiProxyBuilder&) = delete;
0024 
0025 private:
0026   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0027 };
0028 
0029 void FWME0DigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0030   const ME0DigiPreRecoCollection* digis = nullptr;
0031 
0032   iItem->get(digis);
0033 
0034   if (!digis) {
0035     fwLog(fwlog::kWarning) << "Failed to get ME0Digis" << std::endl;
0036     return;
0037   }
0038   const FWGeometry* geom = iItem->getGeom();
0039 
0040   for (ME0DigiPreRecoCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0041     unsigned int rawid = (*dri).first.rawId();
0042     const ME0DigiPreRecoCollection::Range& range = (*dri).second;
0043 
0044     if (!geom->contains(rawid)) {
0045       fwLog(fwlog::kWarning) << "Failed to get geometry of ME0 roll with detid: " << rawid << std::endl;
0046 
0047       TEveCompound* compound = createCompound();
0048       setupAddElement(compound, product);
0049 
0050       continue;
0051     }
0052 
0053     for (ME0DigiPreRecoCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0054       TEveBoxSet* stripDigiSet = new TEveBoxSet;
0055       setupAddElement(stripDigiSet, product);
0056 
0057       float localPoint[3] = {(*dit).x(), (*dit).y(), 0.0};
0058       float globalPoint[3];
0059 
0060       geom->localToGlobal(rawid, localPoint, globalPoint);
0061 
0062       stripDigiSet->AddBox(globalPoint[0], globalPoint[1], globalPoint[2], (*dit).ex(), (*dit).ey(), 0.1);
0063     }
0064   }
0065 }
0066 
0067 REGISTER_FWPROXYBUILDER(FWME0DigiProxyBuilder,
0068                         ME0DigiPreRecoCollection,
0069                         "ME0Digi",
0070                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);