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 
65 int CSCGangedWireGrouping::wireGroup(int wire) const {
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 
94 float CSCGangedWireGrouping::middleWireOfGroup(int wireGroup) const {
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 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
CSCGangedWireGrouping::theNumberOfWiresPerWireGroup
Container theNumberOfWiresPerWireGroup
Definition: CSCGangedWireGrouping.h:74
CSCGangedWireGrouping::middleWireOfGroup
float middleWireOfGroup(int wireGroup) const override
Definition: CSCGangedWireGrouping.cc:94
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
edm::LogError
Definition: MessageLogger.h:183
CSCGangedWireGrouping::CSCGangedWireGrouping
CSCGangedWireGrouping(const Container &consecutiveGroups, const Container &wiresInConsecutiveGroups, int numberOfGroups)
Definition: CSCGangedWireGrouping.cc:10
CSCGangedWireGrouping::theNumberOfGroups
int theNumberOfGroups
Definition: CSCGangedWireGrouping.h:72
CSCGangedWireGrouping::CIterator
Container::const_iterator CIterator
Definition: CSCGangedWireGrouping.h:21
CSCGangedWireGrouping::Container
std::vector< int > Container
Definition: CSCGangedWireGrouping.h:20
CSCGangedWireGrouping.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
CSCGangedWireGrouping::wireGroup
int wireGroup(int wire) const override
Definition: CSCGangedWireGrouping.cc:65
CSCGangedWireGrouping::numberOfWiresPerGroup
int numberOfWiresPerGroup(int wireGroup) const override
Definition: CSCGangedWireGrouping.cc:58
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
CSCGangedWireGrouping::theFirstWireOfEachWireGroup
Container theFirstWireOfEachWireGroup
Definition: CSCGangedWireGrouping.h:73
CSCGangedWireGrouping::theNumberOfWires
int theNumberOfWires
Definition: CSCGangedWireGrouping.h:71