CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCRecHit2D.cc
Go to the documentation of this file.
2 #include <iostream>
3 
5  theLocalPosition(0.,0.),
6  theLocalError(0.,0.,0.),
7  theStrips( ChannelContainer() ),
8  theADCs( ADCContainer() ),
9  theWireGroups( ChannelContainer() ),
10  theTpeak( -999. ),
11  thePositionWithinStrip(-999.),
12  theErrorWithinStrip(-999.),
13  theQuality( 0 ), theBadStrip( 0 ), theBadWireGroup( 0 ),
14  theScaledWireTime( 0 )
15 {
16 
18 theStripsLowBits.clear();
19 for(int i=0; i<(int)theStrips.size(); i++){
20  theStripsLowBits.push_back(theStrips[i] & 0x000000FF);
21  }
23 theStripsHighBits.clear();
24 for(int i=0; i<(int)theStrips.size(); i++){
25  theStripsHighBits.push_back(theStrips[i] & 0x0000FF00);
26  }
27 
29 theWgroupsHighBits.clear();
30 for(int i=0; i<(int)theWireGroups.size(); i++)
31  theWgroupsHighBits.push_back((theWireGroups[i] >> 16) & 0x0000FFFF);
32 theWgroupsLowBits.clear();
33 for(int i=0; i<(int)theWireGroups.size(); i++)
34  theWgroupsLowBits.push_back(theWireGroups[i] & 0x0000FFFF);
35 
36 }
37 
39  const LocalPoint& pos,
40  const LocalError& err,
41  const ChannelContainer& channels,
42  const ADCContainer& adcs,
43  const ChannelContainer& wgroups,
44  float tpeak,
45  float posInStrip,
46  float errInStrip,
47  int quality, short int badStrip, short int badWireGroup,
48  int scaledWireTime ):
49  RecHit2DLocalPos( id ),
50  theLocalPosition( pos ),
51  theLocalError( err ),
52  theStrips( channels ),
53  theADCs( adcs ),
54  theWireGroups( wgroups ),
55  theTpeak( tpeak ),
56  thePositionWithinStrip( posInStrip ),
57  theErrorWithinStrip( errInStrip ),
58  theQuality( quality ), theBadStrip( badStrip ), theBadWireGroup( badWireGroup ),
59  theScaledWireTime ( scaledWireTime )
60 {
61 
63 theStripsLowBits.clear();
64 for(int i=0; i<(int)theStrips.size(); i++){
65  theStripsLowBits.push_back(theStrips[i] & 0x000000FF);
66  }
68 theStripsHighBits.clear();
69 for(int i=0; i<(int)theStrips.size(); i++){
70  theStripsHighBits.push_back(theStrips[i] & 0x0000FF00);
71  }
72 
74 theWgroupsHighBits.clear();
75 for(int i=0; i<(int)theWireGroups.size(); i++)
76  theWgroupsHighBits.push_back((theWireGroups[i] >> 16) & 0x0000FFFF);
77 theWgroupsLowBits.clear();
78 for(int i=0; i<(int)theWireGroups.size(); i++)
79  theWgroupsLowBits.push_back(theWireGroups[i] & 0x0000FFFF);
80 
81 }
82 
84 
86 
87  // This is to satisfy the base class virtual function
88 
89  // @@ Cast the enum (!) But what if the TRH::SIT changes?!
91  return sharesInput(other, cscWhat);
92 }
93 
95 
96  // Check to see if the TrackingRecHit is actually a CSCRecHit2D.
97  if (other->geographicalId().subdetId() != MuonSubdetId::CSC) return false;
98 
99  // Now I can static cast, because the previous guarantees that this is a CSCRecHit2D
100  const CSCRecHit2D *otherRecHit = static_cast<const CSCRecHit2D *>(other);
101 
102  return sharesInput(otherRecHit, what);
103 }
104 
106 
107  // Check to see if the geographical ID of the two are the same
108  if (geographicalId() != otherRecHit->geographicalId()) return false;
109 
110  // Trivial cases
111  const ChannelContainer otherStrips = otherRecHit->channels();
112  const ChannelContainer otherWireGroups = otherRecHit->wgroups();
113  if (theStrips.size() == 0 && otherStrips.size() == 0 && theWireGroups.size() == 0 && otherWireGroups.size() == 0) return true;
114  if ((what == allWires || what == someWires) && theWireGroups.size() == 0 && otherWireGroups.size() == 0) return true;
115  if ((what == allStrips || what == someStrips) && theStrips.size() == 0 && otherStrips.size() == 0) return true;
116 
117  // Check to see if the wire containers are the same length
118  if ((what == all || what == allWires) && theWireGroups.size() != otherWireGroups.size()) return false;
119 
120  // Check to see if the strip containers are the same length
121  if ((what == all || what == allStrips) && theStrips.size() != otherStrips.size()) return false;
122 
123  bool foundWire = false;
124  // Check to see if the wires are the same
125  if (what != allStrips && what != someStrips) {
126  for (ChannelContainer::const_iterator iWire = theWireGroups.begin(); iWire != theWireGroups.end(); ++iWire) {
127  bool found = false;
128  for (ChannelContainer::const_iterator jWire = otherWireGroups.begin(); jWire != otherWireGroups.end(); ++jWire) {
129  if (*iWire == *jWire) {
130  if (what == some || what == someWires) return true;
131  else {
132  found = true;
133  foundWire = true;
134  break;
135  }
136  }
137  }
138  if ((what == all || what == allWires) && !found) return false;
139  }
140  if (what == someWires && !foundWire) return false;
141  }
142 
143  // Check to see if the wires are the same
144  bool foundStrip = false;
145  if (what != allWires && what != someWires) {
146  for (ChannelContainer::const_iterator iStrip = theStrips.begin(); iStrip != theStrips.end(); ++iStrip) {
147  bool found = false;
148  for (ChannelContainer::const_iterator jStrip = otherStrips.begin(); jStrip != otherStrips.end(); ++jStrip) {
149  //a strip is a channel for all but ME1/1a chambers (where 3 ganged strips are a channel)
150  if(cscDetId().channel(*iStrip)==otherRecHit->cscDetId().channel(*jStrip)){
151  if (what == some || what == someStrips) return true;
152  else {
153  found = true;
154  foundStrip = true;
155  break;
156  }
157  }
158  }
159  if ((what == all || what == allStrips) && !found) return false;
160  }
161  if (what == someStrips && !foundStrip) return false;
162  }
163 
164  // In case we were looking for "some" and found absolutely nothing.
165  if (!foundWire && !foundStrip) return false;
166 
167  // If we made it this far, then:
168  // 1) the detector IDs are the same
169  // 2) the channel containers have the same number of entries
170  // 3) for each entry in my channel container, I can find the same value in the other RecHit's corresponding channel container
171  // I think that means we are the same.
172  return true;
173 }
174 
177 /*
178 void CSCRecHit2D::print() const {
179 std::cout << "CSCRecHit in CSC Detector: " << cscDetId() << std::endl;
180 std::cout << " local x = " << localPosition().x() << " +/- " << sqrt( localPositionError().xx() ) << " y = " << localPosition().y() << " +/- " << sqrt( localPositionError().yy() ) << std::endl;
181 
183 std::cout << " L1A+Channels: ";
184 for (int i=0; i<(int)channelsTotal().size(); i++) {std::cout
185  << std::hex << channelsTotal()[i] << " ";}
186 std::cout << std::endl;
187 
188 std::cout << " Channels: ";
189 for (int i=0; i<(int)channels().size(); i++) {std::cout << std::dec << channels()[i] << " "
190  << " (" << "HEX: " << std::hex << channels()[i] << ")" << " ";
191  }
192  std::cout << std::endl;
193 
194 
196 std::cout << " L1APhase: ";
197  for (int i=0; i<(int)channelsl1a().size(); i++) {
198  std::cout << "|";
199  for (int k=0; k<8 ; k++){
200  std::cout << ((channelsl1a()[i] >> (15-k)) & 0x1) << " ";}
201  std::cout << "| ";
202  }
203  std::cout << std::endl;
204 
205 
206 std::cout << " WireGroups: ";
207 for (int i=0; i<(int)wgroups().size(); i++) {std::cout << std::dec << wgroups()[i]
208  << " ";}
209  std::cout << std::endl;
210 }
211 */
212 
213 
214 void CSCRecHit2D::print() const {
215 std::cout << "CSCRecHit in CSC Detector: " << cscDetId() << std::endl;
216 std::cout << " local x = " << localPosition().x() << " +/- " << sqrt( localPositionError().xx() ) << " y = " << localPosition().y() << " +/- " << sqrt( localPositionError().yy() ) << std::endl;
217 
219 std::cout << " L1A+Channels: ";
220 for (int i=0; i<(int)channelsTotal().size(); i++) {std::cout
221  << std::hex << channelsTotal()[i] << " ";}
222 std::cout << std::endl;
223 
224 std::cout << " Channels: ";
225 for (int i=0; i<(int)channels().size(); i++) {std::cout << std::dec << channels()[i] << " "
226  << " (" << "HEX: " << std::hex << channels()[i] << ")" << " ";
227  }
228  std::cout << std::endl;
229 
230 
232 std::cout << " L1APhase: ";
233  for (int i=0; i<(int)channelsl1a().size(); i++) {
234  std::cout << "|";
235  for (int k=0; k<8 ; k++){
236  std::cout << ((channelsl1a()[i] >> (15-k)) & 0x1) << " ";}
237  std::cout << "| ";
238  }
239  std::cout << std::endl;
240 
241 std::cout << " BX + WireGroups combined: ";
242  for (int i=0; i<(int)wgroupsBXandWire().size(); i++) {std::cout //std::dec << wgroups()[i]
243  << "HEX: " << std::hex << wgroupsBXandWire()[i] << std::hex << " | ";
244  }
245 
246 std::cout << " WireGroups: ";
247 for (int i=0; i<(int)wgroups().size(); i++) {std::cout << std::dec << wgroups()[i]
248  << " | ";}
249 std::cout << " BX#: ";
250  for (int i=0; i<(int)wgroupsBX().size(); i++) {std::cout << std::dec << wgroupsBX()[i]
251  << " (" << "HEX: " << std::hex << wgroupsBX()[i] << ")" << " | ";
252  }
253 
254  std::cout << std::endl;
255 }
256 
257 
258 /*
259 void CSCRecHit2D::print() const {
260  std::cout << *this << std::endl;
261 }
262 */
263 
264 std::ostream& operator<<(std::ostream& os, const CSCRecHit2D& rh) {
265  os << "CSCRecHit2D: local x = " << rh.localPosition().x() << " +/- " << sqrt( rh.localPositionError().xx() ) <<
266  " y = " << rh.localPosition().y() << " +/- " << sqrt( rh.localPositionError().yy() ) <<
267  " in strip X = " << rh.positionWithinStrip() << " +/- = " << rh.errorWithinStrip()<<" quality = "<<rh.quality()<<"\n";
268  os << " strip # : ";
269  for(size_t iS =0;iS< rh.channels().size();++iS){
270  os <<rh.channels().at(iS)<<" ";
271  }
272 os << "\n wire # : ";
273  for(size_t iW =0;iW< rh.wgroups().size();++iW){
274  os <<rh.wgroups().at(iW)<<" ";
275  }
276  return os;
277 }
278 
279 
SharedInputType
definition of equality via shared input
ChannelContainer theWgroupsLowBits
BX.
Definition: CSCRecHit2D.h:120
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:19
ChannelContainer wgroupsBXandWire() const
The BX + wire group number.
Definition: CSCRecHit2D.h:70
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:47
ChannelContainer wgroups() const
Container of wire groups comprising the rechit.
Definition: CSCRecHit2D.h:64
ChannelContainer theStrips
Definition: CSCRecHit2D.h:107
T y() const
Definition: PV3DBase.h:57
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual bool sharesInput(const TrackingRecHit *other, TrackingRecHit::SharedInputType what) const
Returns true if the two TrackingRecHits are using the same input information, false otherwise...
Definition: CSCRecHit2D.cc:85
const ChannelContainer & channelsl1a() const
const ChannelContainer&amp; channels() const { return theStrips; }
Definition: CSCRecHit2D.h:54
static const int CSC
Definition: MuonSubdetId.h:15
const ChannelContainer & channelsTotal() const
L1A.
Definition: CSCRecHit2D.h:57
int channel(int istrip)
Definition: CSCDetId.h:120
void print() const
Print the content of the RecHit2D including L1A (for debugging)
Definition: CSCRecHit2D.cc:214
LocalError localPositionError() const
Definition: CSCRecHit2D.h:46
float yy() const
Definition: LocalError.h:21
T sqrt(T t)
Definition: SSEVec.h:28
ChannelContainer theStripsLowBits
Definition: CSCRecHit2D.h:117
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
ChannelContainer theStripsHighBits
L1A.
Definition: CSCRecHit2D.h:118
float positionWithinStrip() const
The estimated position within the strip.
Definition: CSCRecHit2D.h:76
int k[5][pyjets_maxn]
ChannelContainer theWireGroups
Definition: CSCRecHit2D.h:109
int quality() const
quality flag of the reconstruction
Definition: CSCRecHit2D.h:82
const ChannelContainer & channels() const
Extracting strip channel numbers comprising the rechit.
Definition: CSCRecHit2D.h:50
float errorWithinStrip() const
The uncertainty of the estimated position within the strip.
Definition: CSCRecHit2D.h:79
tuple cout
Definition: gather_cfg.py:41
DetId geographicalId() const
LocalPoint localPosition() const
Definition: CSCRecHit2D.h:45
T x() const
Definition: PV3DBase.h:56
ChannelContainer theWgroupsHighBits
L1A.
Definition: CSCRecHit2D.h:119
std::vector< int > ChannelContainer
Definition: CSCRecHit2D.h:22
ChannelContainer wgroupsBX() const
The BX number.
Definition: CSCRecHit2D.h:67