CMS 3D CMS Logo

CSCGangedWireGrouping.cc
Go to the documentation of this file.
2 
4 
5 #include <iostream>
6 #include <iomanip>
7 #include <algorithm>
8 #include <cstddef>
9 
11  const Container& wiresInConsecutiveGroups,
12  int numberOfGroups)
13  : theNumberOfGroups(numberOfGroups) {
14  int countGroups = 0; // counter for no. of wire groups
15  int firstWire = 1; // (virtual) wire number which is 1st in a group
16  int countConsecutive = 0; // counter for the sections in DDD
17 
18  for (int igs : consecutiveGroups) {
19  if (igs != 0) {
20  // igs is number of consecutive groups each containing
21  // an identical number of wires
22  countGroups += igs;
23  for (int ic = 0; ic != igs; ++ic) {
24  theFirstWireOfEachWireGroup.emplace_back(firstWire);
25  int wiresInGroup = wiresInConsecutiveGroups[countConsecutive];
26  theNumberOfWiresPerWireGroup.emplace_back(wiresInGroup);
27  firstWire += wiresInGroup; // ready for next group
28  }
29  } else {
30  // zero means a gap - just add in the no. of virtual wires in gap
31  firstWire += wiresInConsecutiveGroups[countConsecutive];
32  }
33  ++countConsecutive; // ready for next set of consecutive groups
34  }
35 
36  theNumberOfWires = firstWire - 1; // at end of loop we're on 1st for next
37 
38  if (countGroups != numberOfGroups) {
39  edm::LogError("CSC") << "CSCGangedWireGrouping: ERROR in parsing wire info from DDD..."
40  << "\n";
41  edm::LogError("CSC") << "groups expected = " << numberOfGroups << " groups seen = " << countGroups << "\n";
42  edm::LogError("CSC") << "Please report this error to Tim.Cox@cern.ch"
43  << "\n";
44  }
45 
46  LogTrace("CSCWireGeometry|CSC") << "CSCGangedWireGrouping constructor complete,"
47  << " wire group list follows... ";
48  LogTrace("CSCWireGeometry|CSC") << "Size of group buffers = " << theFirstWireOfEachWireGroup.size() << " and "
50  LogTrace("CSCWireGeometry|CSC") << " wg# 1st wire #wires";
51  for (size_t i = 0; i != theFirstWireOfEachWireGroup.size(); ++i) {
52  LogTrace("CSCWireGeometry|CSC") << std::setw(4) << i + 1 << std::setw(12) << theFirstWireOfEachWireGroup[i]
53  << std::setw(8) << theNumberOfWiresPerWireGroup[i];
54  }
55  LogTrace("CSCWireGeometry|CSC") << "Total no. of wires = " << theNumberOfWires;
56 }
57 
61  else
62  return 0;
63 }
64 
66  // Return wire group number (start at 1) containing (virtual) 'wire'
67  // Return 0 if 'wire' is not in a wire group; this includes
68  // wires out outside the chamber, and lying in 'dead' regions
69 
70  int wireG = 0;
71 
72  // upper_bound works on a sorted range and points to first element
73  // _succeeding_ supplied value.
74 
76 
77  // We are now pointing to the wire group _after_ the required one
78  // (unless we are at begin() or end() when we just return wireG=0)
79  ptrdiff_t pd = it - theFirstWireOfEachWireGroup.begin();
80 
81  if (pd > 0) {
82  size_t id = --pd; //@@ Need to step back one. IS THIS SANE CODE?
83  int wiresInGroup = theNumberOfWiresPerWireGroup[id];
84  int firstWire = theFirstWireOfEachWireGroup[id];
85 
86  // Require wire not past end of group (may be in a dead region, or
87  // bigger than total wires in chamber)
88  if (wire < (firstWire + wiresInGroup))
89  wireG = ++id;
90  }
91  return wireG;
92 }
93 
95  // Return exact wire number for group with odd number of wires
96  // Return half-integer wire number for group with even number of wires
97  // i.e. first + 0.5 * float(#) - 0.5
98  // Return 0 if out of range
99 
100  float middleWire = 0.;
101  if (wireGroup > 0 && wireGroup <= theNumberOfGroups) {
103  }
104  return middleWire;
105 }
CSCGangedWireGrouping(const Container &consecutiveGroups, const Container &wiresInConsecutiveGroups, int numberOfGroups)
Log< level::Error, false > LogError
#define LogTrace(id)
std::vector< int > Container
float middleWireOfGroup(int wireGroup) const override
Container::const_iterator CIterator
int numberOfWiresPerGroup(int wireGroup) const override
int wireGroup(int wire) const override