CMS 3D CMS Logo

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