50 theCrackEtas(pset.getParameter<
std::vector<double> >(
"crackEtas")),
51 theCrackWindow(pset.getParameter<double>(
"crackWindow")),
52 theDeltaPhiWindow(pset.existsAs<double>(
"deltaPhiSearchWindow") ? pset.getParameter<double>(
"deltaPhiSearchWindow") : 0.25),
53 theDeltaEtaWindow(pset.existsAs<double>(
"deltaEtaSearchWindow") ? pset.getParameter<double>(
"deltaEtaSearchWindow") : 0.2),
54 theDeltaCrackWindow(pset.existsAs<double>(
"deltaEtaCrackSearchWindow") ? pset.getParameter<double>(
"deltaEtaCrackSearchWindow") : 0.25)
66 std::vector<MuonRecHitContainer> &
result)
77 vector<const DetLayer*> dtLayers = muonLayers->
allDTLayers();
88 const DetLayer* ME4Bwd = cscBackwardLayers[4];
89 const DetLayer* ME3Bwd = cscBackwardLayers[3];
90 const DetLayer* ME2Bwd = cscBackwardLayers[2];
91 const DetLayer* ME12Bwd = cscBackwardLayers[1];
92 const DetLayer* ME11Bwd = cscBackwardLayers[0];
95 const DetLayer* ME11Fwd = cscForwardLayers[0];
96 const DetLayer* ME12Fwd = cscForwardLayers[1];
97 const DetLayer* ME2Fwd = cscForwardLayers[2];
98 const DetLayer* ME3Fwd = cscForwardLayers[3];
99 const DetLayer* ME4Fwd = cscForwardLayers[4];
102 const DetLayer* MB4DL = dtLayers[3];
103 const DetLayer* MB3DL = dtLayers[2];
104 const DetLayer* MB2DL = dtLayers[1];
105 const DetLayer* MB1DL = dtLayers[0];
110 double barreldThetaCut = 0.2;
112 double endcapdThetaCut = 1.0;
124 bool* MB1 =
zero(list8.size());
125 bool* MB2 =
zero(list7.size());
126 bool* MB3 =
zero(list6.size());
130 if (!me0ForwardLayers.empty()){
131 const DetLayer* ME0Fwd = me0ForwardLayers[0];
134 if (!me0BackwardLayers.empty()){
135 const DetLayer* ME0Bwd = me0BackwardLayers[0];
146 MB1, MB2, MB3, result);
155 MB1, MB2, MB3, result);
160 if ( list9.size() < 100 ) {
161 for (MuonRecHitContainer::iterator iter=list9.begin(); iter!=list9.end(); iter++ ){
163 seedSegments.push_back(*iter);
167 if(
check(seedSegments)) result.push_back(seedSegments);
172 if ( list6.size() < 100 ) {
173 for ( counter = 0; counter<list6.size(); counter++ ){
174 if ( !MB3[counter] ) {
176 seedSegments.push_back(list6[counter]);
180 if(
check(seedSegments)) result.push_back(seedSegments);
186 if ( list7.size() < 100 ) {
187 for ( counter = 0; counter<list7.size(); counter++ ){
188 if ( !MB2[counter] ) {
190 seedSegments.push_back(list7[counter]);
194 if (seedSegments.size()>1 ||
195 (seedSegments.size()==1 && seedSegments[0]->dimension()==4) )
197 result.push_back(seedSegments);
204 if ( list8.size() < 100 ) {
205 for ( counter = 0; counter<list8.size(); counter++ ){
206 if ( !MB1[counter] ) {
208 seedSegments.push_back(list8[counter]);
212 if (seedSegments.size()>1 ||
213 (seedSegments.size()==1 && seedSegments[0]->dimension()==4) )
215 result.push_back(seedSegments);
221 if ( MB3 )
delete [] MB3;
222 if ( MB2 )
delete [] MB2;
223 if ( MB1 )
delete [] MB1;
228 barreldThetaCut = 0.2;
229 endcapdThetaCut = 0.2;
233 copy(tmp.begin(),tmp.end(),back_inserter(all));
236 copy(tmp.begin(),tmp.end(),back_inserter(all));
239 copy(tmp.begin(),tmp.end(),back_inserter(all));
242 copy(tmp.begin(),tmp.end(),back_inserter(all));
244 if (!me0BackwardLayers.empty()){
245 const DetLayer* ME0Bwd = me0BackwardLayers[0];
247 copy(tmp.begin(),tmp.end(),back_inserter(all));
249 if (!me0ForwardLayers.empty()){
250 const DetLayer* ME0Fwd = me0ForwardLayers[0];
252 copy(tmp.begin(),tmp.end(),back_inserter(all));
256 copy(tmp.begin(),tmp.end(),back_inserter(all));
259 copy(tmp.begin(),tmp.end(),back_inserter(all));
262 copy(tmp.begin(),tmp.end(),back_inserter(all));
265 copy(tmp.begin(),tmp.end(),back_inserter(all));
268 copy(tmp.begin(),tmp.end(),back_inserter(all));
271 copy(tmp.begin(),tmp.end(),back_inserter(all));
274 copy(tmp.begin(),tmp.end(),back_inserter(all));
277 copy(tmp.begin(),tmp.end(),back_inserter(all));
280 copy(tmp.begin(),tmp.end(),back_inserter(all));
284 for(MuonRecHitContainer::const_iterator segmentItr = all.begin();
285 segmentItr != all.end(); ++segmentItr)
288 singleSegmentContainer.push_back(*segmentItr);
289 result.push_back(singleSegmentContainer);
299 result =
new bool[listSize];
300 for (
size_t i=0;
i<listSize;
i++ ) result[
i]=
false;
311 bool * MB1,
bool * MB2,
bool * MB3,
312 std::vector<MuonRecHitContainer> &
result)
323 std::vector<MuonRecHitContainer> patterns;
341 list21.reserve(list21.size()+me0.size());
342 copy(me0.begin(),me0.end(),back_inserter(list21));
349 if ( list21.empty() ) {
350 list11 = list22; list5 = list21;
353 if ( list24.size() < list23.size() && !list24.empty() ) {
354 list13 = list24; list4 = list23;
357 if ( list23.empty() ) {
358 list13 = list24; list4 = list23;
366 if ( list12.empty() ) {
368 if ( list11.size() <= list13.size() && !list11.empty() ) {
369 list1 = list11; list2 = list13;}
370 else { list1 = list13; list2 = list11;}
373 if ( list13.empty() ) {
374 if ( list11.size() <= list12.size() && !list11.empty() ) {
375 list1 = list11; list2 = list12;}
376 else { list1 = list12; list2 = list11;}
379 if ( !list12.empty() && !list13.empty() ) {
380 if ( list11.size()<=list12.size() && list11.size()<=list13.size() && !list11.empty() ) {
381 if ( list12.size() > list13.size() ) {
382 list2 = list13; list3 = list12;}
384 else if ( list12.size() <= list13.size() ) {
386 if ( list11.size() <= list13.size() && !list11.empty() ) {
387 list2 = list11; list3 = list13;}
388 else { list2 = list13; list3 = list11;}
392 if ( list11.size() <= list12.size() && !list11.empty() ) {
393 list2 = list11; list3 = list12;}
394 else { list2 = list12; list3 = list11;}
399 bool* ME2 =
zero(list2.size());
400 bool* ME3 =
zero(list3.size());
401 bool* ME4 =
zero(list4.size());
402 bool* ME5 =
zero(list5.size());
405 for (MuonRecHitContainer::iterator iter = list1.begin(); iter!=list1.end(); iter++ ){
406 if ( (*iter)->recHits().size() < 4 && !list3.empty() )
continue;
409 seedSegments.push_back(*iter);
417 if(
check(seedSegments)) patterns.push_back(seedSegments);
423 for ( counter = 0; counter<list2.size(); counter++ ){
425 if ( !ME2[counter] ) {
427 seedSegments.push_back(list2[counter]);
434 if(
check(seedSegments)) patterns.push_back(seedSegments);
439 if ( list3.size() < 20 ) {
440 for ( counter = 0; counter<list3.size(); counter++ ){
441 if ( !ME3[counter] ) {
443 seedSegments.push_back(list3[counter]);
449 if(
check(seedSegments)) patterns.push_back(seedSegments);
454 if ( list4.size() < 20 ) {
455 for ( counter = 0; counter<list4.size(); counter++ ){
456 if ( !ME4[counter] ) {
458 seedSegments.push_back(list4[counter]);
463 if(
check(seedSegments)) patterns.push_back(seedSegments);
468 if ( ME5 )
delete [] ME5;
469 if ( ME4 )
delete [] ME4;
470 if ( ME3 )
delete [] ME3;
471 if ( ME2 )
delete [] ME2;
473 if(!patterns.empty())
475 result.insert(result.end(), patterns.begin(), patterns.end());
479 if(!crackSegments.empty())
482 for(MuonRecHitContainer::const_iterator crackSegmentItr = crackSegments.begin();
483 crackSegmentItr != crackSegments.end(); ++crackSegmentItr)
486 singleSegmentPattern.push_back(*crackSegmentItr);
487 result.push_back(singleSegmentPattern);
502 for (
unsigned nr = 0; nr < recHits.size(); ++nr ){
505 float deta = fabs (ptg1.eta()-ptg2.
eta());
516 good_rhit.push_back(recHit);
522 if(best && best->isValid() ) seedSegments.push_back(best);
532 if(good_rhit.size() == 1)
return good_rhit[0];
533 double bestDiscrim = 10000.;
534 for (MuonRecHitContainer::iterator iter=good_rhit.begin();
535 iter!=good_rhit.end(); iter++)
538 if(discrim < bestDiscrim)
540 bestDiscrim = discrim;
554 if(first->isDT() || other->isDT()) {
559 int nhits = other->recHits().size();
564 return fabs(dphig/penalty);
569 if (dphid2 >
M_PI*.5) dphid2 =
M_PI - dphid2;
574 float chisq = ((dphig/0.02)*(dphig/0.02)
575 + (dthetag/0.003)*(dthetag/0.003)
576 + (dphid2/0.06)*(dphid2/0.06)
577 + (dthetad2/0.08)*(dthetad2/0.08)
579 return chisq / penalty;
585 return (segments.size() > 1);
593 if(recHits[nr]->
isCSC())
595 CSCDetId detId(recHits[nr]->geographicalId().rawId());
596 if(detId.
ring() == 4)
598 std::vector<unsigned> chamberHitNs;
599 for(
unsigned i = 0;
i < recHits.size(); ++
i)
601 if(recHits[
i]->geographicalId().rawId() == detId.
rawId())
603 chamberHitNs.push_back(
i);
606 if(chamberHitNs.size() == 3)
608 for(
unsigned i = 0;
i < 3; ++
i)
610 used[chamberHitNs[
i]] =
true;
621 double absEta = fabs(segment->globalPosition().eta());
622 for(std::vector<double>::const_iterator crackItr =
theCrackEtas.begin();
636 for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
637 segmentItr != segments.end(); ++segmentItr)
639 if((**segmentItr).hit()->dimension() == 4 &&
isCrack(*segmentItr))
641 crackSegments.push_back(*segmentItr);
644 if ((*segmentItr)->isME0() &&
std::abs((*segmentItr)->globalPosition().eta()) > 2.4){
645 crackSegments.push_back(*segmentItr);
657 for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
658 segmentItr != segments.end(); ++segmentItr)
670 for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
671 segmentItr != segments.end(); ++segmentItr)
674 double dtheta = (*segmentItr)->globalDirection().theta() - (*segmentItr)->globalPosition().theta();
675 if((*segmentItr)->isDT())
678 if((*segmentItr)->dimension() == 2 || fabs(dtheta) < dThetaCut)
680 result.push_back(*segmentItr);
684 LogTrace(
metname) <<
"Cutting segment " << theDumper.
dumpMuonId((**segmentItr).geographicalId()) <<
" because dtheta = " << dtheta;
688 else if((*segmentItr)->isCSC())
690 if(fabs(dtheta) < dThetaCut)
692 result.push_back(*segmentItr);
696 LogTrace(
metname) <<
"Cutting segment " << theDumper.
dumpMuonId((**segmentItr).geographicalId()) <<
" because dtheta = " << dtheta;
699 else if((*segmentItr)->isME0())
701 if(fabs(dtheta) < dThetaCut)
703 result.push_back(*segmentItr);
707 LogTrace(
metname) <<
"Cutting segment " << theDumper.
dumpMuonId((**segmentItr).geographicalId()) <<
" because dtheta = " << dtheta;
718 if(segments.empty())
return;
721 double dphiCut = 0.05;
722 double detaCut = 0.05;
723 std::vector<unsigned> toKill;
724 std::vector<unsigned> me1aOverlaps;
727 unsigned nseg = segments.size();
728 for(
unsigned i = 0;
i < nseg-1; ++
i)
731 for(
unsigned j =
i+1; j < nseg; ++j)
734 if(segments[
i]->geographicalId().rawId() != segments[j]->geographicalId().rawId()
736 && fabs(pg1.
eta()-pg2.
eta()) < detaCut)
739 theDumper.
dumpMuonId(segments[j]->geographicalId());
744 me1aOverlaps.push_back(i);
745 me1aOverlaps.push_back(j);
751 if(toKill.empty())
return;
754 for(
unsigned i = 0;
i < me1aOverlaps.size(); ++
i)
756 DetId detId(segments[me1aOverlaps[
i]]->geographicalId());
757 vector<unsigned> inSameChamber;
758 for(
unsigned j = 0; j < nseg; ++j)
760 if(
i != j && segments[j]->geographicalId() == detId)
762 inSameChamber.push_back(j);
765 if(inSameChamber.size() == 2)
767 toKill.push_back(inSameChamber[0]);
768 toKill.push_back(inSameChamber[1]);
773 for(
unsigned i = 0;
i < nseg; ++
i)
775 if(
std::find(toKill.begin(), toKill.end(),
i) == toKill.end())
777 result.push_back(segments[
i]);
781 segments.swap(result);
787 return segment->isCSC() &&
CSCDetId(segment->geographicalId()).
ring() == 4;
793 vector<TrackingRecHit*>
components = (*segment).recHits();
794 for(vector<TrackingRecHit*>::const_iterator component = components.begin();
795 component != components.end(); ++component)
797 int componentSize = (**component).recHits().size();
798 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
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
uint32_t rawId() const
get the raw id
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
std::vector< std::vector< double > > tmp
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