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  theTpeak( -999. ),
6  thePositionWithinStrip(-999.),
7  theErrorWithinStrip(-999.),
8  theEnergyDeposit( -994. ),
9  theQuality( 0 ),
10  theScaledWireTime( 0 ),
11  theBadStrip( 0 ),
12  theBadWireGroup( 0 ),
13  nStrips_(0),
14  nWireGroups_(0),
15  nTimeBins_(0),
16  theLocalPosition(0.,0.),
17  theLocalError(0.,0.,0.)
18 {
19  for ( unsigned int i=0; i< MAXSTRIPS; i++) theStrips_[i]=0;
20  for ( unsigned int i=0; i< MAXSTRIPS; i++)
21  for ( unsigned int j=0; j< MAXTIMEBINS; j++)
22  theADCs_[i*MAXTIMEBINS+j]=0;
23 }
24 
26  const LocalPoint& pos,
27  const LocalError& err,
28  const ChannelContainer& channels,
29  const ADCContainer& adcs,
30  const ChannelContainer& wgroups,
31  float tpeak,
32  float posInStrip,
33  float errInStrip,
34  int quality, short int badStrip, short int badWireGroup,
35  int scaledWireTime,
36  float energyDeposit):
37  RecHit2DLocalPos( id ),
38  theTpeak( tpeak ),
39  thePositionWithinStrip( posInStrip ),
40  theErrorWithinStrip( errInStrip ),
41  theEnergyDeposit( energyDeposit ),
42  theQuality( quality ),
43  theScaledWireTime ( scaledWireTime ),
44  theBadStrip( badStrip ), theBadWireGroup( badWireGroup ),
45  theLocalPosition( pos ),
46  theLocalError( err )
47 {
48  nStrips_=channels.size();
49  nWireGroups_=wgroups.size();
50 
51  if ( nStrips_ > MAXSTRIPS ) {
52  std::cout << "CSCRecHit2D: not enough strips in DataFormat! " << unsigned(nStrips_) << std::endl;
54  }
55 
56  for ( unsigned int i=0; i< MAXSTRIPS; i++) theStrips_[i]=0;
57  for ( unsigned int i=0; i< MAXSTRIPS; i++) theL1APhaseBits_[i]=0;
58  for ( unsigned int i=0; i< MAXSTRIPS; i++)
59  for ( unsigned int j=0; j< MAXTIMEBINS; j++)
60  theADCs_[i*MAXTIMEBINS+j]=0;
61 
62 
63  for ( unsigned int i=0; i<nStrips_; i++) {
64  theStrips_[i]=channels[i] & 0x000000FF;
65  theL1APhaseBits_[i]=channels[i] & 0x0000FF00;
66  }
67  if (nWireGroups_>0) {
68  //take only the low bits
69  hitWire_=wgroups[nWireGroups_/2] & 0x0000FFFF;
70  theWGroupsBX_= (wgroups[nWireGroups_/2] >> 16)& 0x0000FFFF;
71  }
72  else {
73  hitWire_=0;
74  theWGroupsBX_=0;
75  }
76  ADCContainer tmp(adcs); //must be a bug in RangeMap!!!???
77  nTimeBins_=tmp.size()/nStrips_;
78  unsigned int k=0;
79  for ( unsigned int i=0; i<nStrips_; i++)
80  for ( unsigned int j=0; j<nTimeBins_; j++) {
81  theADCs_[i*MAXTIMEBINS+j]=tmp[k];
82  k++;
83  }
84 }
85 
87 
89 
90  // This is to satisfy the base class virtual function
91 
92  // @@ Cast the enum (!) But what if the TRH::SIT changes?!
94  return sharesInput(other, cscWhat);
95 }
96 
98 
99  // Check to see if the TrackingRecHit is actually a CSCRecHit2D.
100  if (other->geographicalId().subdetId() != MuonSubdetId::CSC) return false;
101 
102  // Now I can static cast, because the previous guarantees that this is a CSCRecHit2D
103  const CSCRecHit2D *otherRecHit = static_cast<const CSCRecHit2D *>(other);
104 
105  return sharesInput(otherRecHit, what);
106 }
107 
108 
110 
111  // Check to see if the geographical ID of the two are the same
112  if (geographicalId() != otherRecHit->geographicalId()) return false;
113 
114  // Trivial cases
115  if (nStrips() == 0 && otherRecHit->nStrips() == 0 && nWireGroups() == 0 && otherRecHit->nWireGroups() == 0) return true;
116  if ((what == allWires || what == someWires) && nWireGroups() == 0 && otherRecHit->nWireGroups() == 0) return true;
117  if ((what == allStrips || what == someStrips) && nStrips() == 0 && otherRecHit->nStrips() == 0) return true;
118 
119  // Check to see if the wire containers are the same length
120  if ((what == all || what == allWires) && nWireGroups() != otherRecHit->nWireGroups()) return false;
121 
122  // Check to see if the strip containers are the same length
123  if ((what == all || what == allStrips) && nStrips() != otherRecHit->nStrips()) return false;
124 
125  bool foundWire = false;
126  // Check to see if the wires are the same
127  if (what != allStrips && what != someStrips) {
128  //can we do better here?
129  if ( hitWire() != otherRecHit->hitWire() ) return false;
130  }
131 
132  // Check to see if the wires are the same
133  bool foundStrip = false;
134  if (what != allWires && what != someWires) {
135  for (unsigned int i=0; i< nStrips(); i++) {
136  bool found = false;
137  for (unsigned int j=0; j< nStrips(); j++) {
138  //a strip is a channel for all but ME1/1a chambers (where 3 ganged strips are a channel)
139  if(cscDetId().channel(channels(i))==otherRecHit->cscDetId().channel(otherRecHit->channels(j))){
140  if (what == some || what == someStrips) return true;
141  else {
142  found = true;
143  foundStrip = true;
144  break;
145  }
146  }
147  }
148  if ((what == all || what == allStrips) && !found) return false;
149  }
150  if (what == someStrips && !foundStrip) return false;
151  }
152 
153  // In case we were looking for "some" and found absolutely nothing.
154  if (!foundWire && !foundStrip) return false;
155 
156  // If we made it this far, then:
157  // 1) the detector IDs are the same
158  // 2) the channel containers have the same number of entries
159  // 3) for each entry in my channel container, I can find the same value in the other RecHit's corresponding channel container
160  // I think that means we are the same.
161  return true;
162 }
163 
164 
165 void CSCRecHit2D::print() const {
166  std::cout << "CSCRecHit in CSC Detector: " << cscDetId() << std::endl;
167  std::cout << " local x = " << localPosition().x() << " +/- " << sqrt( localPositionError().xx() ) << " y = " << localPosition().y() << " +/- " << sqrt( localPositionError().yy() ) << std::endl;
168 
169  std::cout << " tpeak " << theTpeak << " psoInStrip " << thePositionWithinStrip << " errorinstrip " << theErrorWithinStrip << " " << " qual " << theQuality << " wiretime " << theScaledWireTime << " tbs " << theBadStrip << " bwg " << theBadWireGroup << std::endl;
170 
171  std::cout << " Channels: ";
172  for (unsigned int i=0; i<nStrips(); i++) {std::cout << std::dec << channels(i) << " "
173  << " (" << "HEX: " << std::hex << channels(i) << ")" << " ";
174  }
175  std::cout << std::endl;
176 
177 
179  std::cout << " L1APhase: ";
180  for (int i=0; i<(int)nStrips(); i++) {
181  std::cout << "|";
182  for (int k=0; k<8 ; k++){
183  std::cout << ((channelsl1a(i) >> (15-k)) & 0x1) << " ";}
184  std::cout << "| ";
185  }
186  std::cout << std::endl;
187 
188  std::cout << "nWireGroups " << (int)nWireGroups() << " central wire " << hitWire_ <<std::endl;
189 }
190 
191 
192 std::ostream& operator<<(std::ostream& os, const CSCRecHit2D& rh) {
193  os << "CSCRecHit2D: " <<
194  "local x: " << rh.localPosition().x() << " +/- " << sqrt( rh.localPositionError().xx() ) <<
195  " y: " << rh.localPosition().y() << " +/- " << sqrt( rh.localPositionError().yy() ) <<
196  " in strip X: " << rh.positionWithinStrip() << " +/- " << rh.errorWithinStrip() <<
197  " quality: " << rh.quality() << " tpeak: " << rh.tpeak() << " wireTime: " << rh.wireTime() << std::endl;
198  os << "strips: ";
199  for(size_t iS =0;iS< rh.nStrips();++iS){
200  os <<rh.channels(iS)<<" ";
201  }
202  int nwgs = rh.nWireGroups();
203  if ( nwgs == 1 ) {
204  os << "central wire: " << rh.hitWire() << " of " << nwgs << " wiregroup" << std::endl; }
205  else {
206  os << "central wire: " << rh.hitWire() << " of " << nwgs << " wiregroups" << std::endl; }
207  return os;
208 }
209 
210 
SharedInputType
definition of equality via shared input
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
unsigned char nTimeBins_
Definition: CSCRecHit2D.h:127
size_t size() const
return number of contained object
Definition: RangeMap.h:130
unsigned char nWireGroups_
Definition: CSCRecHit2D.h:127
float tpeak() const
Fitted peaking time.
Definition: CSCRecHit2D.h:73
unsigned char nStrips_
Definition: CSCRecHit2D.h:127
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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:88
short int hitWire_
Definition: CSCRecHit2D.h:122
static const unsigned int MAXSTRIPS
Definition: CSCRecHit2D.h:27
short int theBadStrip
Definition: CSCRecHit2D.h:124
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
static const int CSC
Definition: MuonSubdetId.h:13
short int theBadWireGroup
Definition: CSCRecHit2D.h:125
int channel(int istrip)
Definition: CSCDetId.h:118
void print() const
Print the content of the RecHit2D including L1A (for debugging)
Definition: CSCRecHit2D.cc:165
LocalError localPositionError() const
Definition: CSCRecHit2D.h:51
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
int j
Definition: DBlmapReader.cc:9
float theTpeak
Definition: CSCRecHit2D.h:116
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
float positionWithinStrip() const
The estimated position within the strip.
Definition: CSCRecHit2D.h:76
int theScaledWireTime
Definition: CSCRecHit2D.h:121
float thePositionWithinStrip
Definition: CSCRecHit2D.h:117
float theErrorWithinStrip
Definition: CSCRecHit2D.h:118
short int hitWire() const
L1A.
Definition: CSCRecHit2D.h:62
int quality() const
quality flag of the reconstruction
Definition: CSCRecHit2D.h:82
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
float wireTime() const
Definition: CSCRecHit2D.h:89
static const unsigned int MAXTIMEBINS
Definition: CSCRecHit2D.h:28
short int theWGroupsBX_
Definition: CSCRecHit2D.h:123
float theADCs_[N_ADC]
Definition: CSCRecHit2D.h:131
float errorWithinStrip() const
The uncertainty of the estimated position within the strip.
Definition: CSCRecHit2D.h:79
tuple cout
Definition: gather_cfg.py:145
GloballyPositioned< float >::LocalPoint LocalPoint
DetId geographicalId() const
LocalPoint localPosition() const
Definition: CSCRecHit2D.h:50
unsigned char theStrips_[MAXSTRIPS]
Definition: CSCRecHit2D.h:130
std::vector< int > ChannelContainer
Definition: CSCRecHit2D.h:22
unsigned char theL1APhaseBits_[MAXSTRIPS]
Definition: CSCRecHit2D.h:129
unsigned int nWireGroups() const
Definition: CSCRecHit2D.h:65