49 theCrackEtas(pset.getParameter<
std::vector<double> >(
"crackEtas")),
50 theCrackWindow(pset.getParameter<double>(
"crackWindow")),
52 pset.existsAs<double>(
"deltaPhiSearchWindow") ? pset.getParameter<double>(
"deltaPhiSearchWindow") : 0.25),
54 pset.existsAs<double>(
"deltaEtaSearchWindow") ? pset.getParameter<double>(
"deltaEtaSearchWindow") : 0.2),
55 theDeltaCrackWindow(pset.existsAs<double>(
"deltaEtaCrackSearchWindow")
56 ? pset.getParameter<double>(
"deltaEtaCrackSearchWindow")
74 std::vector<MuonRecHitContainer>&
result) {
83 vector<const DetLayer*> dtLayers = muonLayers->
allDTLayers();
94 const DetLayer* ME4Bwd = cscBackwardLayers[4];
95 const DetLayer* ME3Bwd = cscBackwardLayers[3];
96 const DetLayer* ME2Bwd = cscBackwardLayers[2];
97 const DetLayer* ME12Bwd = cscBackwardLayers[1];
98 const DetLayer* ME11Bwd = cscBackwardLayers[0];
101 const DetLayer* ME11Fwd = cscForwardLayers[0];
102 const DetLayer* ME12Fwd = cscForwardLayers[1];
103 const DetLayer* ME2Fwd = cscForwardLayers[2];
104 const DetLayer* ME3Fwd = cscForwardLayers[3];
105 const DetLayer* ME4Fwd = cscForwardLayers[4];
108 const DetLayer* MB4DL = dtLayers[3];
109 const DetLayer* MB3DL = dtLayers[2];
110 const DetLayer* MB2DL = dtLayers[1];
111 const DetLayer* MB1DL = dtLayers[0];
116 double barreldThetaCut = 0.2;
118 double endcapdThetaCut = 1.0;
130 bool* MB1 =
zero(list8.size());
131 bool* MB2 =
zero(list7.size());
132 bool* MB3 =
zero(list6.size());
136 if (!me0ForwardLayers.empty()) {
137 const DetLayer* ME0Fwd = me0ForwardLayers[0];
140 if (!me0BackwardLayers.empty()) {
141 const DetLayer* ME0Bwd = me0BackwardLayers[0];
176 if (list9.size() < 100) {
177 for (MuonRecHitContainer::iterator iter = list9.begin(); iter != list9.end(); iter++) {
179 seedSegments.push_back(*iter);
183 if (
check(seedSegments))
184 result.push_back(seedSegments);
188 if (list6.size() < 100) {
189 for (counter = 0; counter < list6.size(); counter++) {
192 seedSegments.push_back(list6[counter]);
196 if (
check(seedSegments))
197 result.push_back(seedSegments);
202 if (list7.size() < 100) {
203 for (counter = 0; counter < list7.size(); counter++) {
206 seedSegments.push_back(list7[counter]);
210 if (seedSegments.size() > 1 || (seedSegments.size() == 1 && seedSegments[0]->dimension() == 4)) {
211 result.push_back(seedSegments);
217 if (list8.size() < 100) {
218 for (counter = 0; counter < list8.size(); counter++) {
221 seedSegments.push_back(list8[counter]);
225 if (seedSegments.size() > 1 || (seedSegments.size() == 1 && seedSegments[0]->dimension() == 4)) {
226 result.push_back(seedSegments);
239 if (result.empty()) {
241 barreldThetaCut = 0.2;
242 endcapdThetaCut = 0.2;
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));
255 copy(tmp.begin(), tmp.end(), back_inserter(all));
257 if (!me0BackwardLayers.empty()) {
258 const DetLayer* ME0Bwd = me0BackwardLayers[0];
260 copy(tmp.begin(), tmp.end(), back_inserter(all));
262 if (!me0ForwardLayers.empty()) {
263 const DetLayer* ME0Fwd = me0ForwardLayers[0];
265 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));
293 copy(tmp.begin(), tmp.end(), back_inserter(all));
297 for (MuonRecHitContainer::const_iterator segmentItr = all.begin(); segmentItr != all.end(); ++segmentItr) {
299 singleSegmentContainer.push_back(*segmentItr);
300 result.push_back(singleSegmentContainer);
308 result =
new bool[listSize];
309 for (
size_t i = 0;
i < listSize;
i++)
327 std::vector<MuonRecHitContainer>&
result) {
335 std::vector<MuonRecHitContainer> patterns;
352 list21.reserve(list21.size() + me0.size());
353 copy(me0.begin(), me0.end(), back_inserter(list21));
360 if (list21.empty()) {
365 if (list24.size() < list23.size() && !list24.empty()) {
370 if (list23.empty()) {
379 if (list12.empty()) {
381 if (list11.size() <= list13.size() && !list11.empty()) {
390 if (list13.empty()) {
391 if (list11.size() <= list12.size() && !list11.empty()) {
400 if (!list12.empty() && !list13.empty()) {
401 if (list11.size() <= list12.size() && list11.size() <= list13.size() && !list11.empty()) {
402 if (list12.size() > list13.size()) {
406 }
else if (list12.size() <= list13.size()) {
408 if (list11.size() <= list13.size() && !list11.empty()) {
417 if (list11.size() <= list12.size() && !list11.empty()) {
427 bool* ME2 =
zero(list2.size());
428 bool* ME3 =
zero(list3.size());
429 bool* ME4 =
zero(list4.size());
430 bool* ME5 =
zero(list5.size());
433 for (MuonRecHitContainer::iterator iter = list1.begin(); iter != list1.end(); iter++) {
434 if ((*iter)->recHits().size() < 4 && !list3.empty())
438 seedSegments.push_back(*iter);
446 if (
check(seedSegments))
447 patterns.push_back(seedSegments);
452 for (counter = 0; counter < list2.size(); counter++) {
455 seedSegments.push_back(list2[counter]);
462 if (
check(seedSegments))
463 patterns.push_back(seedSegments);
467 if (list3.size() < 20) {
468 for (counter = 0; counter < list3.size(); counter++) {
471 seedSegments.push_back(list3[counter]);
477 if (
check(seedSegments))
478 patterns.push_back(seedSegments);
483 if (list4.size() < 20) {
484 for (counter = 0; counter < list4.size(); counter++) {
487 seedSegments.push_back(list4[counter]);
492 if (
check(seedSegments))
493 patterns.push_back(seedSegments);
507 if (!patterns.empty()) {
508 result.insert(result.end(), patterns.begin(), patterns.end());
510 if (!crackSegments.empty()) {
512 for (MuonRecHitContainer::const_iterator crackSegmentItr = crackSegments.begin();
513 crackSegmentItr != crackSegments.end();
516 singleSegmentPattern.push_back(*crackSegmentItr);
517 result.push_back(singleSegmentPattern);
531 for (
unsigned nr = 0;
nr < recHits.size(); ++
nr) {
534 float deta = fabs(ptg1.eta() - ptg2.
eta());
545 good_rhit.push_back(recHit);
552 if (best && best->isValid())
553 seedSegments.push_back(best);
559 if (good_rhit.size() == 1)
561 double bestDiscrim = 10000.;
562 for (MuonRecHitContainer::iterator iter = good_rhit.begin(); iter != good_rhit.end(); iter++) {
564 if (discrim < bestDiscrim) {
565 bestDiscrim = discrim;
578 if (first->isDT() || other->isDT()) {
583 int nhits = other->recHits().size();
584 int penalty =
std::max(nhits - 2, 1);
588 return fabs(dphig / penalty);
593 if (dphid2 >
M_PI * .5)
594 dphid2 =
M_PI - dphid2;
599 float chisq = ((dphig / 0.02) * (dphig / 0.02) + (dthetag / 0.003) * (dthetag / 0.003) +
600 (dphid2 / 0.06) * (dphid2 / 0.06) + (dthetad2 / 0.08) * (dthetad2 / 0.08));
601 return chisq / penalty;
609 if (recHits[nr]->
isCSC()) {
610 CSCDetId detId(recHits[nr]->geographicalId().rawId());
611 if (detId.
ring() == 4) {
612 std::vector<unsigned> chamberHitNs;
613 for (
unsigned i = 0;
i < recHits.size(); ++
i) {
614 if (recHits[
i]->geographicalId().rawId() == detId.
rawId()) {
615 chamberHitNs.push_back(
i);
618 if (chamberHitNs.size() == 3) {
619 for (
unsigned i = 0;
i < 3; ++
i) {
620 used[chamberHitNs[
i]] =
true;
629 double absEta = fabs(segment->globalPosition().eta());
641 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
642 if ((**segmentItr).hit()->dimension() == 4 &&
isCrack(*segmentItr)) {
643 crackSegments.push_back(*segmentItr);
646 if ((*segmentItr)->isME0() &&
std::abs((*segmentItr)->globalPosition().eta()) > 2.4) {
647 crackSegments.push_back(*segmentItr);
656 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
665 for (MuonRecHitContainer::const_iterator segmentItr = segments.begin(); segmentItr != segments.end(); ++segmentItr) {
666 double dtheta = (*segmentItr)->globalDirection().theta() - (*segmentItr)->globalPosition().theta();
667 if ((*segmentItr)->isDT()) {
669 if ((*segmentItr)->dimension() == 2 || fabs(dtheta) < dThetaCut) {
670 result.push_back(*segmentItr);
673 <<
" because dtheta = " << dtheta;
676 }
else if ((*segmentItr)->isCSC()) {
677 if (fabs(dtheta) < dThetaCut) {
678 result.push_back(*segmentItr);
681 <<
" because dtheta = " << dtheta;
683 }
else if ((*segmentItr)->isME0()) {
684 if (fabs(dtheta) < dThetaCut) {
685 result.push_back(*segmentItr);
688 <<
" because dtheta = " << dtheta;
697 if (segments.empty())
701 double dphiCut = 0.05;
702 double detaCut = 0.05;
703 std::vector<unsigned> toKill;
704 std::vector<unsigned> me1aOverlaps;
707 unsigned nseg = segments.size();
708 for (
unsigned i = 0;
i < nseg - 1; ++
i) {
710 for (
unsigned j =
i + 1;
j < nseg; ++
j) {
712 if (segments[
i]->geographicalId().rawId() != segments[
j]->geographicalId().rawId() &&
715 << theDumper.
dumpMuonId(segments[
j]->geographicalId());
718 if (
isME1A(segments[i])) {
719 me1aOverlaps.push_back(i);
720 me1aOverlaps.push_back(j);
730 for (
unsigned i = 0;
i < me1aOverlaps.size(); ++
i) {
731 DetId detId(segments[me1aOverlaps[
i]]->geographicalId());
732 vector<unsigned> inSameChamber;
733 for (
unsigned j = 0;
j < nseg; ++
j) {
734 if (
i !=
j && segments[
j]->geographicalId() == detId) {
735 inSameChamber.push_back(
j);
738 if (inSameChamber.size() == 2) {
739 toKill.push_back(inSameChamber[0]);
740 toKill.push_back(inSameChamber[1]);
745 for (
unsigned i = 0;
i < nseg; ++
i) {
746 if (
std::find(toKill.begin(), toKill.end(),
i) == toKill.end()) {
747 result.push_back(segments[
i]);
750 segments.swap(result);
754 return segment->isCSC() &&
CSCDetId(segment->geographicalId()).
ring() == 4;
759 vector<TrackingRecHit*>
components = (*segment).recHits();
760 for (vector<TrackingRecHit*>::const_iterator component = components.begin(); component != components.end();
762 int componentSize = (**component).recHits().size();
763 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)
const std::vector< const DetLayer * > & forwardME0Layers() const
return the forward (+Z) ME0 DetLayers, inside-out
std::string dumpMuonId(const DetId &id) 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
MuonDetLayerMeasurements * muonMeasurements
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & backwardME0Layers() const
return the backward (-Z) ME0 DetLayers, inside-out
bool isME1A(const ConstMuonRecHitPointer &segment) const
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
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
const std::vector< const DetLayer * > & backwardCSCLayers() const
return the backward (-Z) CSC DetLayers, inside-out
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