File indexing completed on 2023-03-17 13:02:39
0001 #include <Geometry/CSCGeometry/src/CSCGangedWireGrouping.h>
0002
0003 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0004
0005 #include <iostream>
0006 #include <iomanip>
0007 #include <algorithm>
0008 #include <cstddef>
0009
0010 CSCGangedWireGrouping::CSCGangedWireGrouping(const Container& consecutiveGroups,
0011 const Container& wiresInConsecutiveGroups,
0012 int numberOfGroups)
0013 : theNumberOfGroups(numberOfGroups) {
0014 int countGroups = 0;
0015 int firstWire = 1;
0016 int countConsecutive = 0;
0017
0018 for (int igs : consecutiveGroups) {
0019 if (igs != 0) {
0020
0021
0022 countGroups += igs;
0023 for (int ic = 0; ic != igs; ++ic) {
0024 theFirstWireOfEachWireGroup.emplace_back(firstWire);
0025 int wiresInGroup = wiresInConsecutiveGroups[countConsecutive];
0026 theNumberOfWiresPerWireGroup.emplace_back(wiresInGroup);
0027 firstWire += wiresInGroup;
0028 }
0029 } else {
0030
0031 firstWire += wiresInConsecutiveGroups[countConsecutive];
0032 }
0033 ++countConsecutive;
0034 }
0035
0036 theNumberOfWires = firstWire - 1;
0037
0038 if (countGroups != numberOfGroups) {
0039 edm::LogError("CSC") << "CSCGangedWireGrouping: ERROR in parsing wire info from DDD..."
0040 << "\n";
0041 edm::LogError("CSC") << "groups expected = " << numberOfGroups << " groups seen = " << countGroups << "\n";
0042 edm::LogError("CSC") << "Please report this error to Tim.Cox@cern.ch"
0043 << "\n";
0044 }
0045
0046 LogTrace("CSCWireGeometry|CSC") << "CSCGangedWireGrouping constructor complete,"
0047 << " wire group list follows... ";
0048 LogTrace("CSCWireGeometry|CSC") << "Size of group buffers = " << theFirstWireOfEachWireGroup.size() << " and "
0049 << theNumberOfWiresPerWireGroup.size();
0050 LogTrace("CSCWireGeometry|CSC") << " wg# 1st wire #wires";
0051 for (size_t i = 0; i != theFirstWireOfEachWireGroup.size(); ++i) {
0052 LogTrace("CSCWireGeometry|CSC") << std::setw(4) << i + 1 << std::setw(12) << theFirstWireOfEachWireGroup[i]
0053 << std::setw(8) << theNumberOfWiresPerWireGroup[i];
0054 }
0055 LogTrace("CSCWireGeometry|CSC") << "Total no. of wires = " << theNumberOfWires;
0056 }
0057
0058 int CSCGangedWireGrouping::numberOfWiresPerGroup(int wireGroup) const {
0059 if (wireGroup > 0 && wireGroup <= theNumberOfGroups)
0060 return theNumberOfWiresPerWireGroup[wireGroup - 1];
0061 else
0062 return 0;
0063 }
0064
0065 int CSCGangedWireGrouping::wireGroup(int wire) const {
0066
0067
0068
0069
0070 int wireG = 0;
0071
0072
0073
0074
0075 CIterator it = upper_bound(theFirstWireOfEachWireGroup.begin(), theFirstWireOfEachWireGroup.end(), wire);
0076
0077
0078
0079 ptrdiff_t pd = it - theFirstWireOfEachWireGroup.begin();
0080
0081 if (pd > 0) {
0082 size_t id = --pd;
0083 int wiresInGroup = theNumberOfWiresPerWireGroup[id];
0084 int firstWire = theFirstWireOfEachWireGroup[id];
0085
0086
0087
0088 if (wire < (firstWire + wiresInGroup))
0089 wireG = ++id;
0090 }
0091 return wireG;
0092 }
0093
0094 float CSCGangedWireGrouping::middleWireOfGroup(int wireGroup) const {
0095
0096
0097
0098
0099
0100 float middleWire = 0.;
0101 if (wireGroup > 0 && wireGroup <= theNumberOfGroups) {
0102 middleWire = theFirstWireOfEachWireGroup[wireGroup - 1] + 0.5 * theNumberOfWiresPerWireGroup[wireGroup - 1] - 0.5;
0103 }
0104 return middleWire;
0105 }