CMS 3D CMS Logo

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,
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)
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?!
94  CSCRecHit2D::SharedInputType cscWhat = static_cast<CSCRecHit2D::SharedInputType>(what);
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 }
CSCRecHit2D::ChannelContainer
std::vector< int > ChannelContainer
Definition: CSCRecHit2D.h:20
CSCRecHit2D::quality
int quality() const
quality flag of the reconstruction
Definition: CSCRecHit2D.h:88
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
CSCRecHit2D::theQuality
int theQuality
Definition: CSCRecHit2D.h:125
mps_fire.i
i
Definition: mps_fire.py:428
CSCRecHit2D::print
void print() const
Print the content of the RecHit2D including L1A (for debugging)
Definition: CSCRecHit2D.cc:174
CSCRecHit2D::theStrips_
unsigned char theStrips_[MAXSTRIPS]
Definition: CSCRecHit2D.h:135
CSCRecHit2D::nStrips_
unsigned char nStrips_
Definition: CSCRecHit2D.h:132
CSCRecHit2D::~CSCRecHit2D
~CSCRecHit2D() override
Definition: CSCRecHit2D.cc:88
CSCRecHit2D::nTimeBins_
unsigned char nTimeBins_
Definition: CSCRecHit2D.h:132
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
CSCRecHit2D::MAXSTRIPS
static const unsigned int MAXSTRIPS
Definition: CSCRecHit2D.h:32
CSCRecHit2D::sharesInput
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
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
CSCRecHit2D::theBadStrip
short int theBadStrip
Definition: CSCRecHit2D.h:129
CSCRecHit2D::cscDetId
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
CSCDetId::channel
int channel(int istrip)
Definition: CSCDetId.h:105
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
CSCRecHit2D::errorWithinStrip
float errorWithinStrip() const
The uncertainty of the estimated position within the strip.
Definition: CSCRecHit2D.h:85
CSCRecHit2D::nWireGroups_
unsigned char nWireGroups_
Definition: CSCRecHit2D.h:132
CSCRecHit2D::nWireGroups
unsigned int nWireGroups() const
Definition: CSCRecHit2D.h:71
TrackingRecHit::SharedInputType
SharedInputType
definition of equality via shared input
Definition: TrackingRecHit.h:59
CSCRecHit2D::hitWire_
short int hitWire_
Definition: CSCRecHit2D.h:127
CSCRecHit2D::theTpeak
float theTpeak
Definition: CSCRecHit2D.h:121
CSCRecHit2D::adcs
float adcs(unsigned int strip, unsigned int timebin) const
Map of strip ADCs for strips comprising the rechit.
Definition: CSCRecHit2D.h:74
LocalError::xx
float xx() const
Definition: LocalError.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
RecHit2DLocalPos::LocalPoint
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: RecHit2DLocalPos.h:10
CSCRecHit2D::all
Definition: CSCRecHit2D.h:24
trackingPlots.other
other
Definition: trackingPlots.py:1464
dqmdumpme.k
k
Definition: dqmdumpme.py:60
CSCRecHit2D::tpeak
float tpeak() const
Fitted peaking time.
Definition: CSCRecHit2D.h:79
edm::RangeMap
Definition: RangeMap.h:32
CSCRecHit2D::theScaledWireTime
int theScaledWireTime
Definition: CSCRecHit2D.h:126
CSCRecHit2D
Definition: CSCRecHit2D.h:18
CSCRecHit2D::wireTime
float wireTime() const
Definition: CSCRecHit2D.h:95
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
CSCRecHit2D::someStrips
Definition: CSCRecHit2D.h:29
LocalError
Definition: LocalError.h:12
CSCRecHit2D::localPosition
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
CSCRecHit2D::theBadWireGroup
short int theBadWireGroup
Definition: CSCRecHit2D.h:130
CSCRecHit2D::thePositionWithinStrip
float thePositionWithinStrip
Definition: CSCRecHit2D.h:122
CSCDetId
Definition: CSCDetId.h:26
CSCRecHit2D::channelsl1a
int channelsl1a(unsigned int i) const
Extract the L1A phase bits from the StripChannelContainer - high.
Definition: CSCRecHit2D.h:65
createfilelist.int
int
Definition: createfilelist.py:10
CSCRecHit2D::some
Definition: CSCRecHit2D.h:25
CSCRecHit2D::localPositionError
LocalError localPositionError() const override
Definition: CSCRecHit2D.h:57
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
CSCRecHit2D::theWGroupsBX_
short int theWGroupsBX_
Definition: CSCRecHit2D.h:128
RecHit2DLocalPos
Definition: RecHit2DLocalPos.h:8
TrackingRecHit
Definition: TrackingRecHit.h:21
CSCRecHit2D::CSCRecHit2D
CSCRecHit2D()
Definition: CSCRecHit2D.cc:4
CSCRecHit2D::channels
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:61
CSCRecHit2D::someWires
Definition: CSCRecHit2D.h:27
CSCRecHit2D::MAXTIMEBINS
static const unsigned int MAXTIMEBINS
Definition: CSCRecHit2D.h:33
CSCRecHit2D::allWires
Definition: CSCRecHit2D.h:26
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CSCRecHit2D::positionWithinStrip
float positionWithinStrip() const
The estimated position within the strip.
Definition: CSCRecHit2D.h:82
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
operator<<
std::ostream & operator<<(std::ostream &os, const CSCRecHit2D &rh)
Output operator for CSCRecHit2D.
Definition: CSCRecHit2D.cc:207
CSCRecHit2D::theErrorWithinStrip
float theErrorWithinStrip
Definition: CSCRecHit2D.h:123
CSCRecHit2D.h
CSCRecHit2D::SharedInputType
SharedInputType
Definition: CSCRecHit2D.h:23
CSCRecHit2D::theADCs_
float theADCs_[N_ADC]
Definition: CSCRecHit2D.h:136
CSCRecHit2D::nStrips
unsigned int nStrips() const
Definition: CSCRecHit2D.h:62
CSCRecHit2D::allStrips
Definition: CSCRecHit2D.h:28
CSCRecHit2D::hitWire
short int hitWire() const
L1A.
Definition: CSCRecHit2D.h:68
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
LocalError::yy
float yy() const
Definition: LocalError.h:24
CSCRecHit2D::theL1APhaseBits_
unsigned char theL1APhaseBits_[MAXSTRIPS]
Definition: CSCRecHit2D.h:134
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19