20 const string metname =
"Muon|RecoMuon|SETPatternRecognition";
26 useRPCs = filterPSet.getParameter<
bool>(
"EnableRPCMeasurement");
42 std::vector<MuonRecHitContainer>& segments_clusters) {
43 const string metname =
"Muon|RecoMuon|SETMuonSeedSeed";
56 event.getByToken(
dtToken, dtRecHits);
57 std::vector<DTChamberId> chambers_DT;
58 std::vector<DTChamberId>::const_iterator chIt_DT;
61 for (chIt_DT = chambers_DT.begin(); chIt_DT != chambers_DT.end(); ++chIt_DT) {
62 if (((*rechit).chamberId().wheel()) == ((*chIt_DT).wheel()) &&
63 ((*rechit).chamberId().station() == (*chIt_DT).station()) &&
64 ((*rechit).chamberId().sector() == (*chIt_DT).sector())) {
69 chambers_DT.push_back((*rechit).chamberId());
72 rechit->localPosition(),
73 rechit->localPositionError(),
74 rechit->localDirection(),
75 rechit->localDirectionError(),
77 rechit->degreesOfFreedom())) {
80 if ((rechit->hasZed() && rechit->hasPhi())) {
82 theService->trackingGeometry()->idToDet((*rechit).geographicalId()), &*rechit));
83 }
else if (rechit->hasZed()) {
85 theService->trackingGeometry()->idToDet((*rechit).geographicalId()), &*rechit));
86 }
else if (rechit->hasPhi()) {
88 theService->trackingGeometry()->idToDet((*rechit).geographicalId()), &*rechit));
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(),
118 rechit->localPositionError(),
119 rechit->localDirection(),
120 rechit->localDirectionError(),
122 rechit->degreesOfFreedom())) {
126 theService->trackingGeometry()->idToDet((*rechit).geographicalId()), &*rechit));
135 event.getByToken(
rpcToken, rpcRecHits);
140 const LocalError localDirectionError(0., 0., 0.);
141 const double chi2 = 1.;
144 rechit->localPosition(),
145 rechit->localPositionError(),
153 theService->trackingGeometry()->idToDet((*rechit).geographicalId()), &*rechit));
161 edm::LogWarning(
"tooManyActiveChambers") <<
" Too many active chambers : nDT = " << chambers_DT.size()
162 <<
" nCSC = " << chambers_CSC.size() <<
" Skip them all.";
164 muonRecHits_DT2D_hasPhi.clear();
165 muonRecHits_DT2D_hasZed.clear();
166 muonRecHits_RPC.clear();
177 bool useDT2D_hasPhi =
true;
178 bool useDT2D_hasZed =
true;
179 double dXclusBoxMax = 0.60;
180 double dYclusBoxMax = 0.;
193 float dXclus_box = 0.0;
194 float dYclus_box = 0.0;
198 std::vector<MuonRecHitContainer>
seeds;
200 std::vector<float> running_meanX;
201 std::vector<float> running_meanY;
203 std::vector<float> seed_minX;
204 std::vector<float> seed_maxX;
205 std::vector<float> seed_minY;
206 std::vector<float> seed_maxY;
211 for (MuonRecHitContainer::const_iterator it = muonRecHits.begin(); it != muonRecHits.end(); ++it) {
220 temp.push_back((*it));
222 seeds.push_back(temp);
227 running_meanX.push_back((*it)->globalPosition().phi());
228 running_meanY.push_back((*it)->globalPosition().theta());
231 seed_minX.push_back((*it)->globalPosition().phi());
232 seed_maxX.push_back((*it)->globalPosition().phi());
233 seed_minY.push_back((*it)->globalPosition().theta());
234 seed_maxY.push_back((*it)->globalPosition().theta());
239 for (
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
240 for (
unsigned int MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
241 if (running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999.) {
249 double temp_meanX = running_meanX[NNN];
250 double temp_minX = seed_minX[NNN];
251 double temp_maxX = seed_maxX[NNN];
255 dXclus = running_meanX[NNN] - running_meanX[MMM];
257 temp_meanX = temp_meanX - 2. *
TMath::Pi();
258 temp_minX = temp_minX - 2. *
TMath::Pi();
259 temp_maxX = temp_maxX - 2. *
TMath::Pi();
262 temp_meanX = temp_meanX + 2. *
TMath::Pi();
263 temp_minX = temp_minX + 2. *
TMath::Pi();
264 temp_maxX = temp_maxX + 2. *
TMath::Pi();
272 if (temp_meanX > running_meanX[MMM])
273 dXclus_box = temp_minX - seed_maxX[MMM];
275 dXclus_box = seed_minX[MMM] - temp_maxX;
276 if (running_meanY[NNN] > running_meanY[MMM])
277 dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
279 dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
281 if (dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax) {
287 running_meanX[MMM] = (temp_meanX * seeds[NNN].size() + running_meanX[MMM] * seeds[MMM].size()) /
288 (seeds[NNN].
size() + seeds[MMM].size());
289 running_meanY[MMM] = (running_meanY[NNN] * seeds[NNN].size() + running_meanY[MMM] * seeds[MMM].size()) /
290 (seeds[NNN].
size() + seeds[MMM].size());
294 if (temp_minX <= seed_minX[MMM])
295 seed_minX[MMM] = temp_minX;
296 if (temp_maxX > seed_maxX[MMM])
297 seed_maxX[MMM] = temp_maxX;
298 if (seed_minY[NNN] <= seed_minY[MMM])
299 seed_minY[MMM] = seed_minY[NNN];
300 if (seed_maxY[NNN] > seed_maxY[MMM])
301 seed_maxY[MMM] = seed_maxY[NNN];
306 running_meanX[MMM] = running_meanX[MMM] - 2. *
TMath::Pi();
307 seed_minX[MMM] = seed_minX[MMM] - 2. *
TMath::Pi();
308 seed_maxX[MMM] = seed_maxX[MMM] - 2. *
TMath::Pi();
311 running_meanX[MMM] = running_meanX[MMM] + 2. *
TMath::Pi();
312 seed_minX[MMM] = seed_minX[MMM] + 2. *
TMath::Pi();
313 seed_maxX[MMM] = seed_maxX[MMM] + 2. *
TMath::Pi();
317 seeds[MMM].insert(seeds[MMM].
end(), seeds[NNN].
begin(), seeds[NNN].
end());
320 running_meanX[NNN] = 999999.;
321 running_meanY[NNN] = 999999.;
328 bool tooCloseClusters =
false;
329 if (seeds.size() > 1) {
330 std::vector<double> seedTheta(seeds.size());
331 for (
unsigned int iSeed = 0; iSeed < seeds.size(); ++iSeed) {
332 seedTheta[iSeed] = seeds[iSeed][0]->globalPosition().theta();
334 double dTheta = fabs(seedTheta[iSeed] - seedTheta[iSeed - 1]);
336 tooCloseClusters =
true;
347 for (
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
348 if (running_meanX[NNN] == 999999.)
352 if (useDT2D_hasZed) {
353 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_DT2D_hasZed.begin();
354 it2 != muonRecHits_DT2D_hasZed.end();
357 if (((*it2)->globalPosition().theta() < seed_maxY[NNN] + dYclusBoxMax) &&
358 ((*it2)->globalPosition().theta() > seed_minY[NNN] - dYclusBoxMax)) {
362 if (!((((*it2)->globalPosition().phi() + 0.09) < (seed_minX[NNN] - dXclusBoxMax) &&
363 ((*it2)->globalPosition().phi() - 0.09) < (seed_minX[NNN] - dXclusBoxMax)) ||
364 (((*it2)->globalPosition().phi() + 0.09) > (seed_maxX[NNN] + dXclusBoxMax) &&
366 ((*it2)->globalPosition().phi() - 0.09) > (seed_maxX[NNN] + dXclusBoxMax)))) {
367 seeds[NNN].push_back((*it2));
374 if (useDT2D_hasPhi) {
375 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_DT2D_hasPhi.begin();
376 it2 != muonRecHits_DT2D_hasPhi.end();
378 if (((*it2)->globalPosition().phi() < seed_maxX[NNN] + dXclusBoxMax) &&
379 ((*it2)->globalPosition().phi() > seed_minX[NNN] - dXclusBoxMax)) {
380 if (!((((*it2)->globalPosition().theta() + 0.3) < (seed_minY[NNN] - dYclusBoxMax) &&
381 ((*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)))) {
385 seeds[NNN].push_back((*it2));
394 if (seeds[NNN].
size() > 1) {
395 for (
unsigned int iRH = 0; iRH < seeds[NNN].size(); ++iRH) {
396 if (iRH && detId_prev != seeds[NNN][iRH]->
hit()->geographicalId()) {
400 detId_prev = seeds[NNN][iRH]->hit()->geographicalId();
404 if (
useRPCs && !secondCh && !tooCloseClusters) {
405 for (MuonRecHitContainer::const_iterator it2 = muonRecHits_RPC.begin(); it2 != muonRecHits_RPC.end(); ++it2) {
406 if (((*it2)->globalPosition().phi() < seed_maxX[NNN] + dXclusBoxMax) &&
407 ((*it2)->globalPosition().phi() > seed_minX[NNN] - dXclusBoxMax)) {
408 if (!((((*it2)->globalPosition().theta() + 0.3) < (seed_minY[NNN] - dYclusBoxMax) &&
409 ((*it2)->globalPosition().theta() - 0.3) < (seed_minY[NNN] - dYclusBoxMax)) ||
410 (((*it2)->globalPosition().theta() + 0.3) > (seed_maxY[NNN] + dYclusBoxMax) &&
412 ((*it2)->globalPosition().theta() - 0.3) > (seed_maxY[NNN] + dYclusBoxMax)))) {
413 seeds[NNN].push_back((*it2));
423 for (
unsigned int NNN = 0; NNN < seeds.size(); ++NNN) {
424 if (running_meanX[NNN] == 999999.)
427 segments_clusters.push_back(seeds[NNN]);
439 bool dropTheSegment =
true;
448 if (insideCh && !parallelSegment) {
449 dropTheSegment =
false;
453 return dropTheSegment;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< DTRecSegment4DCollection > dtToken
edm::EDGetTokenT< RPCRecHitCollection > rpcToken
edm::EDGetTokenT< CSCSegmentCollection > cscToken
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
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
double outsideChamberErrorScale
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
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)
T getParameter(std::string const &) const
Log< level::Warning, false > LogWarning
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
tuple size
Write out results.
void produce(const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result) override
edm::InputTag RPCRecSegmentLabel