CMS 3D CMS Logo

MuonCSCSeedFromRecHits.cc
Go to the documentation of this file.
13 #include <iomanip>
14 
16 
19  if (theRhits.size() == 1) {
20  //return createSeed(100., 100., theRhits[0]);
22  return result;
23  }
24  //@@ doesn't handle overlap between ME11 and ME12 correctly
25  // sort by station
26  MuonRecHitContainer station1Hits, station2Hits, station3Hits, station4Hits;
27  for (MuonRecHitContainer::const_iterator iter = theRhits.begin(), end = theRhits.end(); iter != end; ++iter) {
28  int station = CSCDetId((*iter)->geographicalId().rawId()).station();
29  if ((*iter)->isME0()) {
30  station = 1; //ME0DetId((*iter)->geographicalId().rawId()).station();
31  }
32 
33  if (station == 1) {
34  station1Hits.push_back(*iter);
35  } else if (station == 2) {
36  station2Hits.push_back(*iter);
37  } else if (station == 3) {
38  station3Hits.push_back(*iter);
39  } else if (station == 4) {
40  station4Hits.push_back(*iter);
41  }
42  }
43 
44  //std::cout << "Station hits " << station1Hits.size() << " "
45  // << station2Hits.size() << " "
46  // << station3Hits.size() << std::endl;
47 
48  // see whether station 2 or station 3 is better
49  MuonRecHitContainer* betterSecondHits = &station2Hits;
50  MuonRecHitContainer* notAsGoodSecondHits = &station3Hits;
51  if (!station2Hits.empty() && !station3Hits.empty()) {
52  // swap if station 3 has better quailty
53  if (segmentQuality(station3Hits[0]) < segmentQuality(station2Hits[0])) {
54  betterSecondHits = &station3Hits;
55  notAsGoodSecondHits = &station2Hits;
56  }
57  }
58 
59  // now try to make pairs
60  if (makeSeed(station1Hits, *betterSecondHits, result)) {
61  return result;
62  }
63  if (makeSeed(station1Hits, *notAsGoodSecondHits, result)) {
64  return result;
65  }
66  if (makeSeed(station2Hits, station3Hits, result)) {
67  return result;
68  }
69  if (makeSeed(station1Hits, station4Hits, result)) {
70  return result;
71  }
72 
73  // no luck
75  return result;
76 }
77 
79  const MuonRecHitContainer& hits2,
80  TrajectorySeed& seed) const {
81  for (MuonRecHitContainer::const_iterator itr1 = hits1.begin(), end1 = hits1.end(); itr1 != end1; ++itr1) {
82  CSCDetId cscId1((*itr1)->geographicalId().rawId());
83  //int type1 = CSCChamberSpecs::whatChamberType(cscId1.station(), cscId1.ring());
84 
85  for (MuonRecHitContainer::const_iterator itr2 = hits2.begin(), end2 = hits2.end(); itr2 != end2; ++itr2) {
86  CSCDetId cscId2((*itr2)->geographicalId().rawId());
87  //int type2 = CSCChamberSpecs::whatChamberType(cscId2.station(), cscId2.ring());
88 
89  // take the first pair that comes along. Probably want to rank them later
90  std::vector<double> pts = thePtExtractor->pT_extract(*itr1, *itr2);
91 
92  double pt = pts[0];
93  double sigmapt = pts[1];
94  double minpt = 3.;
95 
96  // if too small, probably an error. Keep trying.
97  if (fabs(pt) > minpt) {
98  double maxpt = 2000.;
99  if (pt > maxpt) {
100  pt = maxpt;
101  sigmapt = maxpt;
102  }
103  if (pt < -maxpt) {
104  pt = -maxpt;
105  sigmapt = maxpt;
106  }
107 
108  // get the position and direction from the higher-quality segment
110  seed = createSeed(pt, sigmapt, bestSeg);
111 
112  //std::cout << "FITTED TIMESPT " << pt << " dphi " << dphi << " eta " << eta << std::endl;
113  return true;
114  }
115  }
116  }
117 
118  // guess it didn't find one
119  //std::cout << "NOTHING FOUND ! " << std::endl;
120  return false;
121 }
122 
123 //typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
125  int Nchi2 = 0;
126  int quality = 0;
127  int nhits = segment->recHits().size();
128  if (segment->chi2() / (nhits * 2. - 4.) > 3.)
129  Nchi2 = 1;
130  if (segment->chi2() / (nhits * 2. - 4.) > 9.)
131  Nchi2 = 2;
132 
133  if (nhits > 4)
134  quality = 1 + Nchi2;
135  if (nhits == 4)
136  quality = 3 + Nchi2;
137  if (nhits == 3)
138  quality = 5 + Nchi2;
139 
140  float dPhiGloDir = fabs(deltaPhi(segment->globalPosition().barePhi(), segment->globalDirection().barePhi()));
141 
142  if (dPhiGloDir > .2)
143  ++quality;
144  // add a penalty for being ME1A if the chamber is ganged
145  if (segment->isCSC() and CSCDetId(segment->geographicalId()).ring() == 4) {
146  const auto chamber = dynamic_cast<const CSCChamber*>(segment->det());
147  if (chamber->specs()->gangedStrips())
148  ++quality;
149  }
150 
151  return quality;
152 }
153 
155  const MuonRecHitContainer& endcapHits) const {
156  MuonRecHitPointer me1 = nullptr, meit = nullptr;
157  float dPhiGloDir = .0; // +v
158  float bestdPhiGloDir = M_PI; // +v
159  int quality1 = 0, quality = 0; // +v I= 5,6-p. / II= 4p. / III= 3p.
160 
161  for (MuonRecHitContainer::const_iterator iter = endcapHits.begin(); iter != endcapHits.end(); iter++) {
162  if (!(*iter)->isCSC() && !(*iter)->isME0())
163  continue;
164 
165  // tmp compar. Glob-Dir for the same tr-segm:
166 
167  meit = *iter;
168 
169  quality = segmentQuality(meit);
170 
171  dPhiGloDir = fabs(deltaPhi(meit->globalPosition().barePhi(), meit->globalDirection().barePhi()));
172 
173  if (!me1) {
174  me1 = meit;
175  quality1 = quality;
176  bestdPhiGloDir = dPhiGloDir;
177  }
178 
179  if (me1) {
180  if (!me1->isValid()) {
181  me1 = meit;
182  quality1 = quality;
183  bestdPhiGloDir = dPhiGloDir;
184  }
185 
186  if (me1->isValid() && quality < quality1) {
187  me1 = meit;
188  quality1 = quality;
189  bestdPhiGloDir = dPhiGloDir;
190  }
191 
192  if (me1->isValid() && bestdPhiGloDir > .03) {
193  if (dPhiGloDir < bestdPhiGloDir - .01 && quality == quality1) {
194  me1 = meit;
195  quality1 = quality;
196  bestdPhiGloDir = dPhiGloDir;
197  }
198  }
199  }
200 
201  } // iter
202 
203  return me1;
204 }
205 
207  //Search ME1 ...
209  // bool good=false;
210 
211  if (me1 && me1->isValid()) {
212  //revert if a LogTrace or smth is necessary good =
214  }
215 }
216 
218  //float momentum = computeDefaultPt(last);
219  std::vector<double> momentum = thePtExtractor->pT_extract(last, last);
220  seed = createSeed(momentum[0], momentum[1], last);
221  return true;
222 }
223 
225  for (MuonRecHitContainer::const_iterator iter = theRhits.begin(); iter != theRhits.end(); iter++) {
226  if (!(*iter)->isCSC())
227  continue;
228  for (MuonRecHitContainer::const_iterator iter2 = iter + 1; iter2 != theRhits.end(); ++iter2) {
229  if (!(*iter2)->isCSC())
230  continue;
231 
232  CSCDetId cscId1((*iter)->geographicalId().rawId());
233  CSCDetId cscId2((*iter2)->geographicalId().rawId());
234  double dphi = deltaPhi((**iter).globalPosition().barePhi(), (**iter2).globalPosition().barePhi());
235 
236  int type1 = cscId1.iChamberType();
237  int type2 = cscId2.iChamberType();
238 
239  // say the lower station first
240  if (type1 < type2) {
241  std::cout << "HITPAIRA," << type1 << type2 << "," << dphi << "," << (**iter).globalPosition().eta()
242  << std::endl;
243  }
244  if (type2 < type1) {
245  std::cout << "HITPAIRB," << type2 << type1 << "," << -dphi << "," << (**iter2).globalPosition().eta()
246  << std::endl;
247  }
248  if (type1 == type2) {
249  std::cout << "HITPAIRSAMESTATION," << type1 << cscId1.ring() << cscId2.ring() << "," << dphi << ","
250  << (**iter).globalPosition().eta() << std::endl;
251  }
252  }
253  }
254 }
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
virtual TrajectorySeed seed() const
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
const MuonSeedPtExtractor * thePtExtractor
bool makeSeed(const MuonRecHitContainer &hits1, const MuonRecHitContainer &hits2, TrajectorySeed &seed) const
static const double pts[33]
Definition: Constants.h:30
void makeDefaultSeed(TrajectorySeed &seed) const
string quality
ConstMuonRecHitPointer bestEndcapHit(const MuonRecHitContainer &endcapHits) const
#define M_PI
bool createDefaultEndcapSeed(ConstMuonRecHitPointer last, TrajectorySeed &seed) const
TrajectorySeed createSeed(float ptmean, float sptmean, MuonTransientTrackingRecHit::ConstMuonRecHitPointer last) const
int segmentQuality(ConstMuonRecHitPointer muon) const
virtual std::vector< double > pT_extract(MuonTransientTrackingRecHit::ConstMuonRecHitPointer firstHit, MuonTransientTrackingRecHit::ConstMuonRecHitPointer secondHit) const