59 std::vector<GEMSegment> segments_temp;
60 std::vector<GEMSegment> segments;
68 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] preClustering :: use Chaining";
72 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] Clustering";
76 edm::LogVerbatim(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::run] Loop over clusters and build segments";
77 for (
auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits) {
79 segments_temp.clear();
83 segments.insert(segments.end(), segments_temp.begin(), segments_temp.end());
100 float dXclus_box = 0.0;
101 float dYclus_box = 0.0;
106 std::vector<float> running_meanX;
107 running_meanX.reserve(
rechits.size());
108 std::vector<float> running_meanY;
109 running_meanY.reserve(
rechits.size());
111 std::vector<float> seed_minX;
112 seed_minX.reserve(
rechits.size());
113 std::vector<float> seed_maxX;
114 seed_maxX.reserve(
rechits.size());
115 std::vector<float> seed_minY;
116 seed_minY.reserve(
rechits.size());
117 std::vector<float> seed_maxY;
118 seed_maxY.reserve(
rechits.size());
123 for (
unsigned int i = 0;
i <
rechits.size(); ++
i) {
130 <<
"Corresponding GEMEtaPartition to GEMDetId: " << rhID <<
" not found in the GEMEnsemble";
136 running_meanX.push_back(rhLP_inChamberFrame.
x());
137 running_meanY.push_back(rhLP_inChamberFrame.
y());
140 seed_minX.push_back(rhLP_inChamberFrame.
x());
141 seed_maxX.push_back(rhLP_inChamberFrame.
x());
142 seed_minY.push_back(rhLP_inChamberFrame.
y());
143 seed_maxY.push_back(rhLP_inChamberFrame.
y());
148 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
149 for (
size_t MMM = NNN + 1; MMM <
seeds.size(); ++MMM) {
151 LogDebug(
"GEMSegmentAlgorithm") <<
"[GEMSegmentAlgorithm::clusterHits]: ALARM! Skipping used seeds, this "
152 "should not happen - inform developers!";
160 if (running_meanX[NNN] > running_meanX[MMM])
161 dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
163 dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
164 if (running_meanY[NNN] > running_meanY[MMM])
165 dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
167 dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
175 running_meanX[MMM] = (running_meanX[NNN] *
seeds[NNN].size() + running_meanX[MMM] *
seeds[MMM].size()) /
177 running_meanY[MMM] = (running_meanY[NNN] *
seeds[NNN].size() + running_meanY[MMM] *
seeds[MMM].size()) /
182 if (seed_minX[NNN] < seed_minX[MMM])
183 seed_minX[MMM] = seed_minX[NNN];
184 if (seed_maxX[NNN] > seed_maxX[MMM])
185 seed_maxX[MMM] = seed_maxX[NNN];
186 if (seed_minY[NNN] < seed_minY[MMM])
187 seed_minY[MMM] = seed_minY[NNN];
188 if (seed_maxY[NNN] > seed_maxY[MMM])
189 seed_maxY[MMM] = seed_maxY[NNN];
207 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
210 rechits_clusters.push_back(
seeds[NNN]);
213 return rechits_clusters;
221 std::vector<bool> usedCluster(
rechits.size(),
false);
226 for (
unsigned int i = 0;
i <
rechits.size(); ++
i)
230 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
231 for (
size_t MMM = NNN + 1; MMM <
seeds.size(); ++MMM) {
232 if (usedCluster[MMM] || usedCluster[NNN]) {
255 usedCluster[NNN] =
true;
266 for (
size_t NNN = 0; NNN <
seeds.size(); ++NNN) {
267 if (usedCluster[NNN])
269 rechits_chains.push_back(
seeds[NNN]);
274 return rechits_chains;
280 bool phiRequirementOK =
false;
281 bool etaRequirementOK =
false;
282 bool bxRequirementOK =
false;
284 for (
size_t iRH_new = 0; iRH_new < newChain.size(); ++iRH_new) {
285 int layer_new = (newChain[iRH_new]->gemId().station() - 1) * 2 + newChain[iRH_new]->gemId().layer();
290 for (
size_t iRH_old = 0; iRH_old < oldChain.size(); ++iRH_old) {
291 int layer_old = (oldChain[iRH_old]->gemId().station() - 1) * 2 + oldChain[iRH_old]->gemId().layer();
293 if (layer_new == layer_old)
300 if (phiRequirementOK ==
false)
302 if (etaRequirementOK ==
false)
306 if (bxRequirementOK ==
false) {
308 bxRequirementOK =
true;
310 if (newChain[iRH_new]->BunchX() == oldChain[iRH_old]->BunchX())
311 bxRequirementOK =
true;
315 if (phiRequirementOK && etaRequirementOK && bxRequirementOK)
324 std::vector<GEMSegment>& gemsegs) {
337 const GEMEtaPartition* thePartition = (ensemble.second.find((*rh)->gemId()))->second;
344 muonRecHits.push_back(trkRecHit);
347 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
349 <<
"[GEMSegmentAlgorithm::buildSegments] will now try to fit a GEMSegment from collection of " <<
rechits.size()
352 auto gemid = (*rh)->gemId();
353 auto rhLP = (*rh)->localPosition();
355 <<
"[RecHit :: Loc x = " << std::showpos << std::setw(9) << rhLP.x() <<
" Loc y = " << std::showpos
356 << std::setw(9) << rhLP.y() <<
" BX = " << std::showpos << (*rh)->BunchX() <<
" -- " << gemid.rawId() <<
" = "
362 sfit_ = std::make_unique<MuonSegFit>(muonRecHits);
363 bool goodfit =
sfit_->fit();
365 <<
"[GEMSegmentAlgorithm::buildSegments] GEMSegment fit done :: fit is good = " << goodfit;
369 for (
auto rh : muonRecHits)
377 double protoChi2 =
sfit_->chi2();
382 bx += (*rh)->BunchX();
413 <<
"[GEMSegmentAlgorithm::buildSegments] will now wrap fit info in GEMSegment dataformat";
418 <<
"[GEMSegmentAlgorithm::buildSegments] GEMSegment made in " <<
tmp.gemDetId();
421 for (
auto rh : muonRecHits)
423 gemsegs.push_back(
tmp);