46 theCrackEtas(pset.getParameter<std::
vector<double> >(
"crackEtas")),
47 theCrackWindow(pset.getParameter<double>(
"crackWindow")),
49 pset.existsAs<double>(
"deltaPhiSearchWindow") ? pset.getParameter<double>(
"deltaPhiSearchWindow") : 0.25),
51 pset.existsAs<double>(
"deltaEtaSearchWindow") ? pset.getParameter<double>(
"deltaEtaSearchWindow") : 0.2),
52 theDeltaCrackWindow(pset.existsAs<double>(
"deltaEtaCrackSearchWindow")
53 ? pset.getParameter<double>(
"deltaEtaCrackSearchWindow")
72 std::vector<MuonRecHitContainer>&
result) {
80 vector<const DetLayer*> dtLayers = muonLayers->allDTLayers();
83 vector<const DetLayer*> cscForwardLayers = muonLayers->forwardCSCLayers();
84 vector<const DetLayer*> cscBackwardLayers = muonLayers->backwardCSCLayers();
87 vector<const DetLayer*> me0ForwardLayers = muonLayers->forwardME0Layers();
88 vector<const DetLayer*> me0BackwardLayers = muonLayers->backwardME0Layers();
91 const DetLayer* ME4Bwd = cscBackwardLayers[4];
92 const DetLayer* ME3Bwd = cscBackwardLayers[3];
93 const DetLayer* ME2Bwd = cscBackwardLayers[2];
94 const DetLayer* ME12Bwd = cscBackwardLayers[1];
95 const DetLayer* ME11Bwd = cscBackwardLayers[0];
98 const DetLayer* ME11Fwd = cscForwardLayers[0];
99 const DetLayer* ME12Fwd = cscForwardLayers[1];
100 const DetLayer* ME2Fwd = cscForwardLayers[2];
101 const DetLayer* ME3Fwd = cscForwardLayers[3];
102 const DetLayer* ME4Fwd = cscForwardLayers[4];
105 const DetLayer* MB4DL = dtLayers[3];
106 const DetLayer* MB3DL = dtLayers[2];
107 const DetLayer* MB2DL = dtLayers[1];
108 const DetLayer* MB1DL = dtLayers[0];
113 double barreldThetaCut = 0.2;
115 double endcapdThetaCut = 1.0;
127 bool* MB1 =
zero(list8.size());
128 bool* MB2 =
zero(list7.size());
129 bool* MB3 =
zero(list6.size());
133 if (!me0ForwardLayers.empty()) {
134 const DetLayer* ME0Fwd = me0ForwardLayers[0];
137 if (!me0BackwardLayers.empty()) {
138 const DetLayer* ME0Bwd = me0BackwardLayers[0];
173 if (list9.size() < 100) {
174 for (MuonRecHitContainer::iterator iter = list9.begin(); iter != list9.end(); iter++) {
176 seedSegments.push_back(*iter);
180 if (
check(seedSegments))
181 result.push_back(seedSegments);
185 if (list6.size() < 100) {
186 for (counter = 0; counter < list6.size(); counter++) {
189 seedSegments.push_back(list6[counter]);
193 if (
check(seedSegments))
194 result.push_back(seedSegments);
199 if (list7.size() < 100) {
200 for (counter = 0; counter < list7.size(); counter++) {
203 seedSegments.push_back(list7[counter]);
207 if (seedSegments.size() > 1 || (seedSegments.size() == 1 && seedSegments[0]->dimension() == 4)) {
208 result.push_back(seedSegments);
214 if (list8.size() < 100) {
215 for (counter = 0; counter < list8.size(); counter++) {
218 seedSegments.push_back(list8[counter]);
222 if (seedSegments.size() > 1 || (seedSegments.size() == 1 && seedSegments[0]->dimension() == 4)) {
223 result.push_back(seedSegments);
236 if (result.empty()) {
238 barreldThetaCut = 0.2;
239 endcapdThetaCut = 0.2;
243 copy(tmp.begin(), tmp.end(), back_inserter(all));
246 copy(tmp.begin(), tmp.end(), back_inserter(all));
249 copy(tmp.begin(), tmp.end(), back_inserter(all));
252 copy(tmp.begin(), tmp.end(), back_inserter(all));
254 if (!me0BackwardLayers.empty()) {
255 const DetLayer* ME0Bwd = me0BackwardLayers[0];
257 copy(tmp.begin(), tmp.end(), back_inserter(all));
259 if (!me0ForwardLayers.empty()) {
260 const DetLayer* ME0Fwd = me0ForwardLayers[0];
262 copy(tmp.begin(), tmp.end(), back_inserter(all));
266 copy(tmp.begin(), tmp.end(), back_inserter(all));
269 copy(tmp.begin(), tmp.end(), back_inserter(all));
272 copy(tmp.begin(), tmp.end(), back_inserter(all));
275 copy(tmp.begin(), tmp.end(), back_inserter(all));
278 copy(tmp.begin(), tmp.end(), back_inserter(all));
281 copy(tmp.begin(), tmp.end(), back_inserter(all));
284 copy(tmp.begin(), tmp.end(), back_inserter(all));
287 copy(tmp.begin(), tmp.end(), back_inserter(all));
290 copy(tmp.begin(), tmp.end(), back_inserter(all));
294 for (MuonRecHitContainer::const_iterator segmentItr = all.begin(); segmentItr != all.end(); ++segmentItr) {
296 singleSegmentContainer.push_back(*segmentItr);
297 result.push_back(singleSegmentContainer);
305 result =
new bool[listSize];
306 for (
size_t i = 0;
i < listSize;
i++)
324 std::vector<MuonRecHitContainer>&
result) {
332 std::vector<MuonRecHitContainer> patterns;
349 list21.reserve(list21.size() + me0.size());
350 copy(me0.begin(), me0.end(), back_inserter(list21));
357 if (list21.empty()) {
362 if (list24.size() < list23.size() && !list24.empty()) {
367 if (list23.empty()) {
376 if (list12.empty()) {
378 if (list11.size() <= list13.size() && !list11.empty()) {
387 if (list13.empty()) {
388 if (list11.size() <= list12.size() && !list11.empty()) {
397 if (!list12.empty() && !list13.empty()) {
398 if (list11.size() <= list12.size() && list11.size() <= list13.size() && !list11.empty()) {
399 if (list12.size() > list13.size()) {
403 }
else if (list12.size() <= list13.size()) {
405 if (list11.size() <= list13.size() && !list11.empty()) {
414 if (list11.size() <= list12.size() && !list11.empty()) {
424 bool* ME2 =
zero(list2.size());
425 bool* ME3 =
zero(list3.size());
426 bool* ME4 =
zero(list4.size());
427 bool* ME5 =
zero(list5.size());
430 for (MuonRecHitContainer::iterator iter = list1.begin(); iter != list1.end(); iter++) {
431 if ((*iter)->recHits().size() < 4 && !list3.empty())
435 seedSegments.push_back(*iter);
443 if (
check(seedSegments))
444 patterns.push_back(seedSegments);
449 for (counter = 0; counter < list2.size(); counter++) {
452 seedSegments.push_back(list2[counter]);
459 if (
check(seedSegments))
460 patterns.push_back(seedSegments);
464 if (list3.size() < 20) {
465 for (counter = 0; counter < list3.size(); counter++) {
468 seedSegments.push_back(list3[counter]);
474 if (
check(seedSegments))
475 patterns.push_back(seedSegments);
480 if (list4.size() < 20) {
481 for (counter = 0; counter < list4.size(); counter++) {
484 seedSegments.push_back(list4[counter]);
489 if (
check(seedSegments))
490 patterns.push_back(seedSegments);
504 if (!patterns.empty()) {
505 result.insert(result.end(), patterns.begin(), patterns.end());
507 if (!crackSegments.empty()) {
509 for (MuonRecHitContainer::const_iterator crackSegmentItr = crackSegments.begin();
510 crackSegmentItr != crackSegments.end();
513 singleSegmentPattern.push_back(*crackSegmentItr);
514 result.push_back(singleSegmentPattern);
528 for (
unsigned nr = 0; nr < recHits.size(); ++nr) {
531 float deta = fabs(ptg1.eta() - ptg2.
eta());
542 good_rhit.push_back(recHit);
549 if (best && best->isValid())
550 seedSegments.push_back(best);
556 if (good_rhit.size() == 1)
558 double bestDiscrim = 10000.;
559 for (MuonRecHitContainer::iterator iter = good_rhit.begin(); iter != good_rhit.end(); iter++) {
561 if (discrim < bestDiscrim) {
562 bestDiscrim = discrim;
575 if (first->isDT() || other->isDT()) {
580 int nhits = other->recHits().size();
581 int penalty =
std::max(nhits - 2, 1);
585 return fabs(dphig / penalty);
590 if (dphid2 >
M_PI * .5)
591 dphid2 =
M_PI - dphid2;
596 float chisq = ((dphig / 0.02) * (dphig / 0.02) + (dthetag / 0.003) * (dthetag / 0.003) +
597 (dphid2 / 0.06) * (dphid2 / 0.06) + (dthetad2 / 0.08) * (dthetad2 / 0.08));
598 return chisq / penalty;
606 if (recHits[nr]->
isCSC()) {
607 CSCDetId detId(recHits[nr]->geographicalId().rawId());
608 if (detId.
ring() == 4) {
609 std::vector<unsigned> chamberHitNs;
610 for (
unsigned i = 0;
i < recHits.size(); ++
i) {
611 if (recHits[
i]->geographicalId().rawId() == detId.
rawId()) {
612 chamberHitNs.push_back(
i);
615 if (chamberHitNs.size() == 3) {
616 for (
unsigned i = 0;
i < 3; ++
i) {
617 used[chamberHitNs[
i]] =
true;
626 double absEta = fabs(segment->globalPosition().eta());
638 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
639 if ((**segmentItr).hit()->dimension() == 4 &&
isCrack(*segmentItr)) {
640 crackSegments.push_back(*segmentItr);
643 if ((*segmentItr)->isME0() &&
std::abs((*segmentItr)->globalPosition().eta()) > 2.4) {
644 crackSegments.push_back(*segmentItr);
653 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
662 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
663 double dtheta = (*segmentItr)->globalDirection().theta() - (*segmentItr)->globalPosition().theta();
664 if ((*segmentItr)->isDT()) {
666 if ((*segmentItr)->dimension() == 2 || fabs(dtheta) < dThetaCut) {
667 result.push_back(*segmentItr);
670 <<
" because dtheta = " << dtheta;
673 }
else if ((*segmentItr)->isCSC()) {
674 if (fabs(dtheta) < dThetaCut) {
675 result.push_back(*segmentItr);
678 <<
" because dtheta = " << dtheta;
680 }
else if ((*segmentItr)->isME0()) {
681 if (fabs(dtheta) < dThetaCut) {
682 result.push_back(*segmentItr);
685 <<
" because dtheta = " << dtheta;
694 if (segments.empty())
698 double dphiCut = 0.05;
699 double detaCut = 0.05;
700 std::vector<unsigned> toKill;
701 std::vector<unsigned> me1aOverlaps;
704 unsigned nseg = segments.size();
705 for (
unsigned i = 0;
i < nseg - 1; ++
i) {
707 for (
unsigned j =
i + 1;
j < nseg; ++
j) {
709 if (segments[
i]->geographicalId().rawId() != segments[
j]->geographicalId().rawId() &&
712 << theDumper.
dumpMuonId(segments[
j]->geographicalId());
715 if (
isME1A(segments[i])) {
716 me1aOverlaps.push_back(i);
717 me1aOverlaps.push_back(j);
727 for (
unsigned i = 0;
i < me1aOverlaps.size(); ++
i) {
728 DetId detId(segments[me1aOverlaps[
i]]->geographicalId());
729 vector<unsigned> inSameChamber;
730 for (
unsigned j = 0;
j < nseg; ++
j) {
731 if (
i !=
j && segments[
j]->geographicalId() == detId) {
732 inSameChamber.push_back(
j);
735 if (inSameChamber.size() == 2) {
736 toKill.push_back(inSameChamber[0]);
737 toKill.push_back(inSameChamber[1]);
742 for (
unsigned i = 0;
i < nseg; ++
i) {
743 if (
std::find(toKill.begin(), toKill.end(),
i) == toKill.end()) {
744 result.push_back(segments[
i]);
747 segments.swap(result);
751 return segment->isCSC() &&
CSCDetId(segment->geographicalId()).
ring() == 4;
756 vector<TrackingRecHit*>
components = (*segment).recHits();
757 for (vector<TrackingRecHit*>::const_iterator component = components.begin(); component != components.end();
759 int componentSize = (**component).recHits().size();
760 count += (componentSize == 0) ? 1 : componentSize;
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
MuonRecHitPointer bestMatch(const ConstMuonRecHitPointer &first, MuonRecHitContainer &good_rhit) const
bool enableME0Measurement
Enable the ME0 measurement.
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
const std::string metname
void filterOverlappingChambers(MuonRecHitContainer &segments) const
bool isCrack(const ConstMuonRecHitPointer &segment) const
constexpr uint32_t rawId() const
get the raw id
bool check(const MuonRecHitContainer &segments)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::string dumpMuonId(const DetId &id) const
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=nullptr) const
Geom::Theta< T > theta() const
double theDeltaCrackWindow
bool enableCSCMeasurement
Enable the CSC measurement.
int countHits(const MuonRecHitPointer &segment) const
void endcapPatterns(const MuonRecHitContainer &me11, const MuonRecHitContainer &me12, const MuonRecHitContainer &me2, const MuonRecHitContainer &me3, const MuonRecHitContainer &me4, const MuonRecHitContainer &me0, const MuonRecHitContainer &mb1, const MuonRecHitContainer &mb2, const MuonRecHitContainer &mb3, bool *MB1, bool *MB2, bool *MB3, std::vector< MuonRecHitContainer > &result)
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
bool * zero(unsigned listSize)
Abs< T >::type abs(const T &t)
void rememberCrackSegments(const MuonRecHitContainer &segments, MuonRecHitContainer &crackSegments) const
edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > muonLayersToken
MuonDetLayerMeasurements * muonMeasurements
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
bool isME1A(const ConstMuonRecHitPointer &segment) const
edm::InputTag theME0RecSegmentLabel
the name of the ME0 rec hits collection
void markAsUsed(int nr, const MuonRecHitContainer &recHits, bool *used) const
MuonSeedOrcaPatternRecognition(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
static std::atomic< unsigned int > counter
bool isCSC(GeomDetEnumerators::SubDetector m)
bool enableDTMeasurement
Enable the DT measurement.
std::vector< double > theCrackEtas
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void produce(const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result) override
void dumpLayer(const char *name, const MuonRecHitContainer &segments) const
double discriminator(const ConstMuonRecHitPointer &first, MuonRecHitPointer &other) const
edm::InputTag theCSCRecSegmentLabel
the name of the CSC rec hits collection
edm::InputTag theDTRecSegmentLabel
the name of the DT rec hits collection
MuonRecHitContainer filterSegments(const MuonRecHitContainer &segments, double dThetaCut) const
apply some cuts to segments before using them