21 const string metname =
"Muon|RecoMuon|SETPatternRecognition";
27 useRPCs = filterPSet.getParameter<
bool>(
"EnableRPCMeasurement");
43 std::vector<MuonRecHitContainer> & segments_clusters)
45 const string metname =
"Muon|RecoMuon|SETMuonSeedSeed";
58 event.getByToken(
dtToken, dtRecHits);
59 std::vector<DTChamberId> chambers_DT;
60 std::vector<DTChamberId>::const_iterator chIt_DT;
63 for(chIt_DT=chambers_DT.begin(); chIt_DT != chambers_DT.end(); ++chIt_DT){
65 ((*rechit).chamberId().wheel()) == ((*chIt_DT).wheel()) &&
66 ((*rechit).chamberId().station() == (*chIt_DT).station()) &&
67 ((*rechit).chamberId().sector() == (*chIt_DT).sector())){
72 chambers_DT.push_back((*rechit).chamberId());
75 rechit->localPosition(), rechit->localPositionError(),
76 rechit->localDirection(), rechit->localDirectionError(),
77 rechit->chi2(), rechit->degreesOfFreedom())){
80 if( (rechit->hasZed() && rechit->hasPhi()) ) {
83 else if(rechit->hasZed()) {
86 else if(rechit->hasPhi()) {
100 event.getByToken(
cscToken, cscSegments);
101 std::vector<CSCDetId> chambers_CSC;
102 std::vector<CSCDetId>::const_iterator chIt_CSC;
105 for(chIt_CSC=chambers_CSC.begin(); chIt_CSC != chambers_CSC.end(); ++chIt_CSC){
106 if (((*rechit).cscDetId().chamber() == (*chIt_CSC).chamber()) &&
107 ((*rechit).cscDetId().station() == (*chIt_CSC).station()) &&
108 ((*rechit).cscDetId().ring() == (*chIt_CSC).ring()) &&
109 ((*rechit).cscDetId().endcap() == (*chIt_CSC).endcap())){
114 chambers_CSC.push_back((*rechit).cscDetId().chamberId());
117 rechit->localPosition(), rechit->localPositionError(),
118 rechit->localDirection(), rechit->localDirectionError(),
119 rechit->chi2(), rechit->degreesOfFreedom())){
131 event.getByToken(
rpcToken, rpcRecHits);
136 const LocalError localDirectionError (0.,0.,0.);
137 const double chi2 = 1.;
140 rechit->localPosition(), rechit->localPositionError(),
141 localDirection, localDirectionError,
153 edm::LogWarning(
"tooManyActiveChambers")<<
" Too many active chambers : nDT = "<<chambers_DT.size()
154 <<
" nCSC = "<<chambers_CSC.size()<<
" Skip them all.";
156 muonRecHits_DT2D_hasPhi.clear();
157 muonRecHits_DT2D_hasZed.clear();
158 muonRecHits_RPC.clear();
169 bool useDT2D_hasPhi =
true;
170 bool useDT2D_hasZed =
true;
185 float dXclus_box = 0.0;
186 float dYclus_box = 0.0;
190 std::vector< MuonRecHitContainer > seeds;
192 std::vector<float> running_meanX;
193 std::vector<float> running_meanY;
195 std::vector<float> seed_minX;
196 std::vector<float> seed_maxX;
197 std::vector<float> seed_minY;
198 std::vector<float> seed_maxY;
203 for (MuonRecHitContainer::const_iterator it = muonRecHits.begin(); it != muonRecHits.end(); ++it ) {
213 temp.push_back((*it));
215 seeds.push_back(temp);
220 running_meanX.push_back( (*it)->globalPosition().phi() );
221 running_meanY.push_back( (*it)->globalPosition().theta() );
224 seed_minX.push_back( (*it)->globalPosition().phi() );
225 seed_maxX.push_back( (*it)->globalPosition().phi() );
226 seed_minY.push_back( (*it)->globalPosition().theta() );
227 seed_maxY.push_back( (*it)->globalPosition().theta() );
232 for(
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
234 for(
unsigned int MMM = NNN+1; MMM < seeds.size(); ++MMM) {
235 if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) {
243 double temp_meanX = running_meanX[NNN];
244 double temp_minX = seed_minX[NNN];
245 double temp_maxX = seed_maxX[NNN];
249 dXclus = running_meanX[NNN] - running_meanX[MMM];
251 temp_meanX = temp_meanX - 2.*
TMath::Pi();
256 temp_meanX = temp_meanX + 2.*
TMath::Pi();
266 if ( temp_meanX > running_meanX[MMM] ) dXclus_box = temp_minX - seed_maxX[MMM];
267 else dXclus_box = seed_minX[MMM] - temp_maxX;
268 if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
269 else dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
272 if( dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax ) {
278 running_meanX[MMM] = (temp_meanX*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
279 running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
283 if ( temp_minX <= seed_minX[MMM] ) seed_minX[MMM] = temp_minX;
284 if ( temp_maxX > seed_maxX[MMM] ) seed_maxX[MMM] = temp_maxX;
285 if ( seed_minY[NNN] <= seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN];
286 if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN];
291 running_meanX[MMM] = running_meanX[MMM] - 2.*
TMath::Pi();
292 seed_minX[MMM] = seed_minX[MMM] - 2.*
TMath::Pi();
293 seed_maxX[MMM] = seed_maxX[MMM] - 2.*
TMath::Pi();
296 running_meanX[MMM] = running_meanX[MMM] + 2.*
TMath::Pi();
297 seed_minX[MMM] = seed_minX[MMM] + 2.*
TMath::Pi();
298 seed_maxX[MMM] = seed_maxX[MMM] + 2.*
TMath::Pi();
302 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
305 running_meanX[NNN] = 999999.;
306 running_meanY[NNN] = 999999.;
314 bool tooCloseClusters =
false;
316 std::vector <double> seedTheta(seeds.size());
317 for(
unsigned int iSeed = 0;iSeed<seeds.size();++iSeed){
318 seedTheta[iSeed] = seeds[iSeed][0]->globalPosition().theta();
320 double dTheta = fabs(seedTheta[iSeed] - seedTheta[iSeed-1]);
322 tooCloseClusters =
true;
334 for(
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
335 if(running_meanX[NNN] == 999999.)
continue;
339 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_DT2D_hasZed.begin(); it2 != muonRecHits_DT2D_hasZed.end(); ++it2 ) {
341 if (((*it2)->globalPosition().theta() < seed_maxY[NNN] +
dYclusBoxMax) && ((*it2)->globalPosition().theta() > seed_minY[NNN] -
dYclusBoxMax)) {
348 ((*it2)->globalPosition().phi() + 0.09) < (seed_minX[NNN] -
dXclusBoxMax)
350 ((*it2)->globalPosition().phi() - 0.09) < (seed_minX[NNN] -
dXclusBoxMax)
354 ((*it2)->globalPosition().phi() + 0.09) > (seed_maxX[NNN] +
dXclusBoxMax)
356 ((*it2)->globalPosition().phi() - 0.09) > (seed_maxX[NNN] +
dXclusBoxMax)
360 seeds[NNN].push_back((*it2));
369 if (useDT2D_hasPhi) {
371 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_DT2D_hasPhi.begin(); it2 != muonRecHits_DT2D_hasPhi.end(); ++it2 ) {
372 if (((*it2)->globalPosition().phi() < seed_maxX[NNN] +
dXclusBoxMax) && ((*it2)->globalPosition().phi() > seed_minX[NNN] -
dXclusBoxMax)) {
376 ((*it2)->globalPosition().theta() + 0.3) < (seed_minY[NNN] -
dYclusBoxMax)
378 ((*it2)->globalPosition().theta() - 0.3) < (seed_minY[NNN] -
dYclusBoxMax)
382 ((*it2)->globalPosition().theta() + 0.3) > (seed_maxY[NNN] +
dYclusBoxMax)
384 ((*it2)->globalPosition().theta() - 0.3) > (seed_maxY[NNN] +
dYclusBoxMax)
388 seeds[NNN].push_back((*it2));
398 if(seeds[NNN].
size()>1){
399 for(
unsigned int iRH = 0 ;iRH<seeds[NNN].size() ;++iRH){
400 if( iRH && detId_prev != seeds[NNN][iRH]->
hit()->geographicalId()){
404 detId_prev = seeds[NNN][iRH]->hit()->geographicalId();
408 if (
useRPCs && !secondCh && !tooCloseClusters) {
409 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_RPC.begin(); it2 != muonRecHits_RPC.end(); ++it2 ) {
410 if (((*it2)->globalPosition().phi() < seed_maxX[NNN] +
dXclusBoxMax) && ((*it2)->globalPosition().phi() > seed_minX[NNN] -
dXclusBoxMax)) {
414 ((*it2)->globalPosition().theta() + 0.3) < (seed_minY[NNN] -
dYclusBoxMax)
416 ((*it2)->globalPosition().theta() - 0.3) < (seed_minY[NNN] -
dYclusBoxMax)
420 ((*it2)->globalPosition().theta() + 0.3) > (seed_maxY[NNN] +
dYclusBoxMax)
422 ((*it2)->globalPosition().theta() - 0.3) > (seed_maxY[NNN] +
dYclusBoxMax)
426 seeds[NNN].push_back((*it2));
437 for(
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
438 if(running_meanX[NNN] == 999999.)
continue;
440 segments_clusters.push_back(seeds[NNN]);
448 const double&
chi2,
const int& ndf){
450 bool dropTheSegment =
true;
459 if(insideCh && !parallelSegment){
460 dropTheSegment =
false;
465 return dropTheSegment;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > dtToken
edm::EDGetTokenT< RPCRecHitCollection > rpcToken
edm::EDGetTokenT< CSCSegmentCollection > cscToken
double minLocalSegmentAngle
const std::string metname
edm::InputTag CSCRecSegmentLabel
const Bounds & bounds() const
const Plane & surface() const
The nominal surface of the GeomDet.
C::const_iterator const_iterator
constant access iterator type
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
double outsideChamberErrorScale
bool segmentCleaning(const DetId &detId, const LocalPoint &localPosition, const LocalError &localError, const LocalVector &localDirection, const LocalError &localDirectionError, const double &chi2, const int &ndf)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
MuonServiceProxy * theService
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
edm::InputTag DTRecSegmentLabel
SETPatternRecognition(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
void produce(const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result) override
ParameterSet const & parameterSet(Provenance const &provenance)
edm::InputTag RPCRecSegmentLabel