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  :     FWCSCStripDigiProxyBuilder
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 
0016 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0017 #include "Fireworks/Core/interface/FWEventItem.h"
0018 #include "Fireworks/Core/interface/FWGeometry.h"
0019 #include "Fireworks/Core/interface/fwLog.h"
0020 
0021 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0022 
0023 class FWCSCStripDigiProxyBuilder : public FWProxyBuilderBase {
0024 public:
0025   FWCSCStripDigiProxyBuilder() {}
0026   ~FWCSCStripDigiProxyBuilder() 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   FWCSCStripDigiProxyBuilder(const FWCSCStripDigiProxyBuilder&) = delete;
0036   const FWCSCStripDigiProxyBuilder& operator=(const FWCSCStripDigiProxyBuilder&) = delete;
0037 };
0038 
0039 void FWCSCStripDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0040   const CSCStripDigiCollection* digis = nullptr;
0041 
0042   iItem->get(digis);
0043 
0044   if (!digis) {
0045     fwLog(fwlog::kWarning) << "failed to get CSCStripDigis" << std::endl;
0046     return;
0047   }
0048   const FWGeometry* geom = iItem->getGeom();
0049 
0050   int thresholdOffset = 9;
0051 
0052   for (CSCStripDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0053     unsigned int rawid = (*dri).first.rawId();
0054     const CSCStripDigiCollection::Range& range = (*dri).second;
0055 
0056     if (!geom->contains(rawid)) {
0057       fwLog(fwlog::kWarning) << "failed to get geometry of CSC with detid: " << rawid << std::endl;
0058 
0059       TEveCompound* compound = createCompound();
0060       setupAddElement(compound, product);
0061 
0062       continue;
0063     }
0064 
0065     const float* shape = geom->getShapePars(rawid);
0066     float length = shape[4];
0067 
0068     const float* parameters = geom->getParameters(rawid);
0069 
0070     float yAxisOrientation = parameters[0];
0071     float centreToIntersection = parameters[1];
0072     float yCentre = parameters[2];
0073     float phiOfOneEdge = parameters[3];
0074     float stripOffset = parameters[4];
0075     float angularWidth = parameters[5];
0076 
0077     for (CSCStripDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0078       std::vector<int> adcCounts = (*dit).getADCCounts();
0079 
0080       int signalThreshold = (adcCounts[0] + adcCounts[1]) / 2 + thresholdOffset;
0081 
0082       TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet();
0083       setupAddElement(stripDigiSet, product);
0084 
0085       if (std::find_if(adcCounts.begin(), adcCounts.end(), [&](auto c) { return c > signalThreshold; }) !=
0086           adcCounts.end()) {
0087         stripDigiSet->SetLineWidth(3);
0088         int stripId = (*dit).getStrip();
0089 
0090         float yOrigin = centreToIntersection - yCentre;
0091         float stripAngle = phiOfOneEdge + yAxisOrientation * (stripId - (0.5 - stripOffset)) * angularWidth;
0092         float tanStripAngle = tan(stripAngle);
0093         //float xOfStrip = yAxisOrientation*yOrigin*tanStripAngle; this is x of strip at origin
0094 
0095         float localPointTop[3] = {yAxisOrientation * (yOrigin + length) * tanStripAngle, length, 0.0};
0096 
0097         float localPointBottom[3] = {yAxisOrientation * (yOrigin - length) * tanStripAngle, -length, 0.0};
0098 
0099         float globalPointTop[3];
0100         float globalPointBottom[3];
0101 
0102         geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
0103 
0104         stripDigiSet->AddLine(globalPointBottom[0],
0105                               globalPointBottom[1],
0106                               globalPointBottom[2],
0107                               globalPointTop[0],
0108                               globalPointTop[1],
0109                               globalPointTop[2]);
0110       }
0111     }
0112   }
0113 }
0114 
0115 REGISTER_FWPROXYBUILDER(FWCSCStripDigiProxyBuilder,
0116                         CSCStripDigiCollection,
0117                         "CSCStripDigi",
0118                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);