File indexing completed on 2024-04-06 12:11:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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/CSCWireDigiCollection.h"
0022
0023 #include <cmath>
0024
0025 class FWCSCWireDigiProxyBuilder : public FWProxyBuilderBase {
0026 public:
0027 FWCSCWireDigiProxyBuilder() {}
0028 ~FWCSCWireDigiProxyBuilder() override {}
0029
0030 REGISTER_PROXYBUILDER_METHODS();
0031
0032 FWCSCWireDigiProxyBuilder(const FWCSCWireDigiProxyBuilder&) = delete;
0033 const FWCSCWireDigiProxyBuilder& operator=(const FWCSCWireDigiProxyBuilder&) = delete;
0034
0035 private:
0036 using FWProxyBuilderBase::build;
0037 void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0038
0039
0040
0041 double getYOfFirstWire(const int station, const int ring, const double length);
0042 double getAverageWireSpacing(const int station, const int ring);
0043 };
0044
0045 double FWCSCWireDigiProxyBuilder::getYOfFirstWire(const int station, const int ring, const double length) {
0046 double yAlignmentFrame = 3.49;
0047 double alignmentPinToFirstWire;
0048
0049 if (station == 1) {
0050 if (ring == 1 || ring == 4) {
0051 alignmentPinToFirstWire = 1.065;
0052 yAlignmentFrame = 0.0;
0053 }
0054
0055 else
0056 alignmentPinToFirstWire = 2.85;
0057 }
0058
0059 else if (station == 4 && ring == 1)
0060 alignmentPinToFirstWire = 3.04;
0061
0062 else if (station == 3 && ring == 1)
0063 alignmentPinToFirstWire = 2.84;
0064
0065 else
0066 alignmentPinToFirstWire = 2.87;
0067
0068 return (yAlignmentFrame - length) + alignmentPinToFirstWire;
0069 }
0070
0071 double FWCSCWireDigiProxyBuilder::getAverageWireSpacing(const int station, const int ring) {
0072
0073
0074
0075 if (ring == 2) {
0076 if (station == 1)
0077 return 174.81 / 64;
0078 else
0079 return 323.38 / 64;
0080 }
0081
0082 if (station == 1 && (ring == 1 || ring == 4))
0083 return 150.5 / 48;
0084 if (station == 1 && ring == 3)
0085 return 164.47 / 32;
0086 if (station == 2 && ring == 1)
0087 return 189.97 / 112;
0088 if (station == 3 && ring == 1)
0089 return 170.01 / 96;
0090 if (station == 4 && ring == 1)
0091 return 149.73 / 96;
0092
0093 return 0.0;
0094 }
0095
0096 void FWCSCWireDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0097 const CSCWireDigiCollection* digis = nullptr;
0098
0099 iItem->get(digis);
0100
0101 if (!digis) {
0102 fwLog(fwlog::kWarning) << "Failed to get CSCWireDigis" << std::endl;
0103 return;
0104 }
0105 const FWGeometry* geom = iItem->getGeom();
0106
0107 for (CSCWireDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
0108 const CSCDetId& cscDetId = (*dri).first;
0109 unsigned int rawid = cscDetId.rawId();
0110 const CSCWireDigiCollection::Range& range = (*dri).second;
0111
0112 if (!geom->contains(rawid)) {
0113 fwLog(fwlog::kWarning) << "Failed to get geometry of CSC chamber with detid: " << rawid << std::endl;
0114
0115 TEveCompound* compound = createCompound();
0116 setupAddElement(compound, product);
0117
0118 continue;
0119 }
0120
0121 const float* shape = geom->getShapePars(rawid);
0122
0123 float length = shape[4];
0124 float topWidth = shape[2];
0125 float bottomWidth = shape[1];
0126
0127
0128
0129
0130 double wireSpacing = getAverageWireSpacing(cscDetId.station(), cscDetId.ring());
0131
0132
0133
0134 double yOfFirstWire = getYOfFirstWire(cscDetId.station(), cscDetId.ring(), length);
0135
0136 for (CSCWireDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
0137 TEveStraightLineSet* wireDigiSet = new TEveStraightLineSet();
0138 wireDigiSet->SetLineWidth(3);
0139 setupAddElement(wireDigiSet, product);
0140
0141 int wireGroup = (*dit).getWireGroup();
0142 float yOfWire = yOfFirstWire + ((wireGroup - 1) * wireSpacing);
0143 float wireLength = yOfWire * (topWidth - bottomWidth) / length;
0144 wireLength += bottomWidth * 2.0;
0145
0146 float localPointLeft[3] = {static_cast<float>(-wireLength * 0.5), yOfWire, static_cast<float>(0.0)};
0147
0148
0149
0150 float localPointRight[3] = {
0151 static_cast<float>(wireLength * 0.5), yOfWire, static_cast<float>(0.0)
0152
0153 };
0154
0155 float globalPointLeft[3];
0156 float globalPointRight[3];
0157
0158 geom->localToGlobal(rawid, localPointLeft, globalPointLeft, localPointRight, globalPointRight);
0159
0160 wireDigiSet->AddLine(globalPointLeft[0],
0161 globalPointLeft[1],
0162 globalPointLeft[2],
0163 globalPointRight[0],
0164 globalPointRight[1],
0165 globalPointRight[2]);
0166 }
0167 }
0168 }
0169
0170 REGISTER_FWPROXYBUILDER(FWCSCWireDigiProxyBuilder,
0171 CSCWireDigiCollection,
0172 "CSCWireDigi",
0173 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);