60 std::vector<GEMSegment> segments_temp;
61 std::vector<GEMSegment> segments;
69 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] preClustering :: use Chaining";
73 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] Clustering";
77 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] Loop over clusters and build segments";
78 for (
auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits) {
80 segments_temp.clear();
84 segments.insert(segments.end(), segments_temp.begin(), segments_temp.end());
101 float dXclus_box = 0.0;
102 float dYclus_box = 0.0;
107 std::vector<float> running_meanX;
108 running_meanX.reserve(
rechits.size());
109 std::vector<float> running_meanY;
110 running_meanY.reserve(
rechits.size());
112 std::vector<float> seed_minX;
113 seed_minX.reserve(
rechits.size());
114 std::vector<float> seed_maxX;
115 seed_maxX.reserve(
rechits.size());
116 std::vector<float> seed_minY;
117 seed_minY.reserve(
rechits.size());
118 std::vector<float> seed_maxY;
119 seed_maxY.reserve(
rechits.size());
124 for (
unsigned int i = 0;
i <
rechits.size(); ++
i) {
131 <<
"Corresponding GEMEtaPartition to GEMDetId: " << rhID <<
" not found in the GEMEnsemble";
137 running_meanX.push_back(rhLP_inChamberFrame.
x());
138 running_meanY.push_back(rhLP_inChamberFrame.
y());
141 seed_minX.push_back(rhLP_inChamberFrame.
x());
142 seed_maxX.push_back(rhLP_inChamberFrame.
x());
143 seed_minY.push_back(rhLP_inChamberFrame.
y());
144 seed_maxY.push_back(rhLP_inChamberFrame.
y());
149 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
150 for (
size_t MMM = NNN + 1; MMM <
seeds.size(); ++MMM) {
152 LogDebug(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::clusterHits]: ALARM! Skipping used seeds, this "
153 "should not happen - inform developers!";
161 if (running_meanX[NNN] > running_meanX[MMM])
162 dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
164 dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
165 if (running_meanY[NNN] > running_meanY[MMM])
166 dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
168 dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
176 running_meanX[MMM] = (running_meanX[NNN] *
seeds[NNN].size() + running_meanX[MMM] *
seeds[MMM].size()) /
178 running_meanY[MMM] = (running_meanY[NNN] *
seeds[NNN].size() + running_meanY[MMM] *
seeds[MMM].size()) /
183 if (seed_minX[NNN] < seed_minX[MMM])
184 seed_minX[MMM] = seed_minX[NNN];
185 if (seed_maxX[NNN] > seed_maxX[MMM])
186 seed_maxX[MMM] = seed_maxX[NNN];
187 if (seed_minY[NNN] < seed_minY[MMM])
188 seed_minY[MMM] = seed_minY[NNN];
189 if (seed_maxY[NNN] > seed_maxY[MMM])
190 seed_maxY[MMM] = seed_maxY[NNN];
208 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
211 rechits_clusters.push_back(
seeds[NNN]);
214 return rechits_clusters;
222 std::vector<bool> usedCluster(
rechits.size(),
false);
227 for (
unsigned int i = 0;
i <
rechits.size(); ++
i)
231 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
232 for (
size_t MMM = NNN + 1; MMM <
seeds.size(); ++MMM) {
233 if (usedCluster[MMM] || usedCluster[NNN]) {
256 usedCluster[NNN] =
true;
267 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
268 if (usedCluster[NNN])
270 rechits_chains.push_back(
seeds[NNN]);
275 return rechits_chains;
281 bool phiRequirementOK =
false;
282 bool etaRequirementOK =
false;
283 bool bxRequirementOK =
false;
285 for (
size_t iRH_new = 0; iRH_new < newChain.size(); ++iRH_new) {
286 int layer_new = (newChain[iRH_new]->gemId().station() - 1) * 2 + newChain[iRH_new]->gemId().layer();
291 for (
size_t iRH_old = 0; iRH_old < oldChain.size(); ++iRH_old) {
292 int layer_old = (oldChain[iRH_old]->gemId().station() - 1) * 2 + oldChain[iRH_old]->gemId().layer();
294 if (layer_new == layer_old)
301 if (phiRequirementOK ==
false)
303 if (etaRequirementOK ==
false)
307 if (bxRequirementOK ==
false) {
309 bxRequirementOK =
true;
311 if (newChain[iRH_new]->BunchX() == oldChain[iRH_old]->BunchX())
312 bxRequirementOK =
true;
316 if (phiRequirementOK && etaRequirementOK && bxRequirementOK)
325 std::vector<GEMSegment>& gemsegs) {
338 const GEMEtaPartition* thePartition = (ensemble.second.find((*rh)->gemId()))->second;
345 muonRecHits.push_back(trkRecHit);
348 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
350 <<
"[GEMSegmentAlgorithm::buildSegments] will now try to fit a GEMSegment from collection of " <<
rechits.size()
353 auto gemid = (*rh)->gemId();
354 auto rhLP = (*rh)->localPosition();
356 <<
"[RecHit :: Loc x = " << std::showpos << std::setw(9) << rhLP.x() <<
" Loc y = " << std::showpos
357 << std::setw(9) << rhLP.y() <<
" BX = " << std::showpos << (*rh)->BunchX() <<
" -- " << gemid.rawId() <<
" = "
363 sfit_ = std::make_unique<MuonSegFit>(muonRecHits);
364 bool goodfit =
sfit_->fit();
366 <<
"[GEMSegmentAlgorithm::buildSegments] GEMSegment fit done :: fit is good = " << goodfit;
370 for (
auto rh : muonRecHits)
378 double protoChi2 =
sfit_->chi2();
383 bx += (*rh)->BunchX();
414 <<
"[GEMSegmentAlgorithm::buildSegments] will now wrap fit info in GEMSegment dataformat";
419 <<
"[GEMSegmentAlgorithm::buildSegments] GEMSegment made in " <<
tmp.gemDetId();
422 for (
auto rh : muonRecHits)
424 gemsegs.push_back(
tmp);