CMS 3D CMS Logo

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