File indexing completed on 2024-04-06 12:26:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "CSCSegAlgoST.h"
0013 #include "CSCCondSegFit.h"
0014 #include "CSCSegAlgoShowering.h"
0015
0016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0017
0018 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
0019
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021
0022 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0023
0024 #include <algorithm>
0025 #include <cmath>
0026 #include <iostream>
0027 #include <string>
0028
0029
0030
0031
0032 CSCSegAlgoST::CSCSegAlgoST(const edm::ParameterSet& ps)
0033 : CSCSegmentAlgorithm(ps), myName_("CSCSegAlgoST"), ps_(ps), showering_(nullptr) {
0034 debug = ps.getUntrackedParameter<bool>("CSCDebug");
0035
0036
0037 minHitsPerSegment = ps.getParameter<int>("minHitsPerSegment");
0038
0039
0040 dXclusBoxMax = ps.getParameter<double>("dXclusBoxMax");
0041 dYclusBoxMax = ps.getParameter<double>("dYclusBoxMax");
0042 preClustering = ps.getParameter<bool>("preClustering");
0043 preClustering_useChaining = ps.getParameter<bool>("preClusteringUseChaining");
0044 Pruning = ps.getParameter<bool>("Pruning");
0045 BrutePruning = ps.getParameter<bool>("BrutePruning");
0046 BPMinImprovement = ps.getParameter<double>("BPMinImprovement");
0047
0048
0049
0050
0051 maxRecHitsInCluster = ps.getParameter<int>("maxRecHitsInCluster");
0052 onlyBestSegment = ps.getParameter<bool>("onlyBestSegment");
0053
0054 hitDropLimit4Hits = ps.getParameter<double>("hitDropLimit4Hits");
0055 hitDropLimit5Hits = ps.getParameter<double>("hitDropLimit5Hits");
0056 hitDropLimit6Hits = ps.getParameter<double>("hitDropLimit6Hits");
0057
0058 yweightPenaltyThreshold = ps.getParameter<double>("yweightPenaltyThreshold");
0059 yweightPenalty = ps.getParameter<double>("yweightPenalty");
0060
0061 curvePenaltyThreshold = ps.getParameter<double>("curvePenaltyThreshold");
0062 curvePenalty = ps.getParameter<double>("curvePenalty");
0063
0064 useShowering = ps.getParameter<bool>("useShowering");
0065 if (useShowering)
0066 showering_ = new CSCSegAlgoShowering(ps);
0067
0068
0069 adjustCovariance_ = ps.getParameter<bool>("CorrectTheErrors");
0070
0071 chi2Norm_3D_ = ps.getParameter<double>("NormChi2Cut3D");
0072 prePrun_ = ps.getParameter<bool>("prePrun");
0073 prePrunLimit_ = ps.getParameter<double>("prePrunLimit");
0074
0075 if (debug)
0076 edm::LogVerbatim("CSCSegment") << "CSCSegAlgoST: with factored conditioned segment fit";
0077 }
0078
0079
0080
0081
0082 CSCSegAlgoST::~CSCSegAlgoST() { delete showering_; }
0083
0084 std::vector<CSCSegment> CSCSegAlgoST::run(const CSCChamber* aChamber, const ChamberHitContainer& rechits) {
0085
0086 theChamber = aChamber;
0087
0088 LogTrace("CSCSegAlgoST") << "[CSCSegAlgoST::run] Start building segments in chamber " << theChamber->id();
0089
0090
0091 std::vector<CSCSegment> segments_temp;
0092 std::vector<CSCSegment> segments;
0093 std::vector<ChamberHitContainer> rechits_clusters;
0094
0095
0096
0097
0098 for (int a = 0; a < 5; ++a) {
0099 for (int b = 0; b < 5; ++b) {
0100 a_yweightPenaltyThreshold[a][b] = 0.0;
0101 }
0102 }
0103
0104 a_yweightPenaltyThreshold[1][1] = yweightPenaltyThreshold * 10.20;
0105 a_yweightPenaltyThreshold[1][2] = yweightPenaltyThreshold * 14.00;
0106 a_yweightPenaltyThreshold[1][3] = yweightPenaltyThreshold * 20.40;
0107 a_yweightPenaltyThreshold[1][4] = yweightPenaltyThreshold * 10.20;
0108 a_yweightPenaltyThreshold[2][1] = yweightPenaltyThreshold * 7.60;
0109 a_yweightPenaltyThreshold[2][2] = yweightPenaltyThreshold * 20.40;
0110 a_yweightPenaltyThreshold[3][1] = yweightPenaltyThreshold * 7.60;
0111 a_yweightPenaltyThreshold[3][2] = yweightPenaltyThreshold * 20.40;
0112 a_yweightPenaltyThreshold[4][1] = yweightPenaltyThreshold * 6.75;
0113 a_yweightPenaltyThreshold[4][2] = yweightPenaltyThreshold * 20.40;
0114
0115 if (preClustering) {
0116
0117 if (preClustering_useChaining) {
0118
0119
0120
0121
0122
0123 rechits_clusters = chainHits(theChamber, rechits);
0124 } else {
0125
0126 rechits_clusters = clusterHits(theChamber, rechits);
0127 }
0128
0129 for (std::vector<ChamberHitContainer>::iterator sub_rechits = rechits_clusters.begin();
0130 sub_rechits != rechits_clusters.end();
0131 ++sub_rechits) {
0132
0133 segments_temp.clear();
0134
0135 segments_temp = buildSegments((*sub_rechits));
0136
0137 segments.insert(segments.end(), segments_temp.begin(), segments_temp.end());
0138 }
0139
0140 if (Pruning) {
0141 segments_temp.clear();
0142 segments_temp = prune_bad_hits(theChamber, segments);
0143 segments.clear();
0144 segments.swap(segments_temp);
0145 }
0146
0147
0148 if (("ME1/a" == aChamber->specs()->chamberTypeName()) && aChamber->specs()->gangedStrips()) {
0149
0150 findDuplicates(segments);
0151 }
0152 return segments;
0153 } else {
0154 segments = buildSegments(rechits);
0155 if (Pruning) {
0156 segments_temp.clear();
0157 segments_temp = prune_bad_hits(theChamber, segments);
0158 segments.clear();
0159 segments.swap(segments_temp);
0160 }
0161
0162
0163 if (("ME1/a" == aChamber->specs()->chamberTypeName()) && aChamber->specs()->gangedStrips()) {
0164
0165 findDuplicates(segments);
0166 }
0167 return segments;
0168
0169 }
0170 }
0171
0172
0173
0174
0175
0176
0177 std::vector<CSCSegment> CSCSegAlgoST::prune_bad_hits(const CSCChamber* aChamber, std::vector<CSCSegment>& segments) {
0178
0179
0180
0181
0182 std::vector<CSCSegment> segments_temp;
0183 std::vector<ChamberHitContainer> rechits_clusters;
0184
0185 const float chi2ndfProbMin = 1.0e-4;
0186 bool use_brute_force = BrutePruning;
0187
0188 int hit_nr = 0;
0189 int hit_nr_worst = -1;
0190
0191
0192 for (std::vector<CSCSegment>::iterator it = segments.begin(); it != segments.end(); ++it) {
0193
0194 if ((*it).nRecHits() <= minHitsPerSegment)
0195 continue;
0196
0197 if (!use_brute_force) {
0198
0199 float chisq = (*it).chi2();
0200 int nhits = (*it).nRecHits();
0201 LocalPoint localPos = (*it).localPosition();
0202 LocalVector segDir = (*it).localDirection();
0203 const CSCChamber* cscchamber = theChamber;
0204 float globZ;
0205
0206 GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
0207 globZ = globalPosition.z();
0208
0209 if (ChiSquaredProbability((double)chisq, (double)(2 * nhits - 4)) < chi2ndfProbMin) {
0210
0211 std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
0212 std::vector<CSCRecHit2D>::const_iterator iRH_worst;
0213
0214
0215 float xdist_local_worst_sig = -99999.;
0216 float xdist_local_2ndworst_sig = -99999.;
0217 float xdist_local_sig = -99999.;
0218
0219 hit_nr = 0;
0220 hit_nr_worst = -1;
0221
0222
0223 for (std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); ++iRH) {
0224
0225
0226
0227
0228 float loc_x_at_target;
0229
0230
0231
0232
0233
0234
0235
0236 const CSCLayer* csclayerRH = theChamber->layer((*iRH).cscDetId().layer());
0237 LocalPoint localPositionRH = (*iRH).localPosition();
0238 GlobalPoint globalPositionRH = csclayerRH->toGlobal(localPositionRH);
0239
0240 LocalError rerrlocal = (*iRH).localPositionError();
0241 float xxerr = rerrlocal.xx();
0242
0243 float target_z = globalPositionRH.z();
0244
0245 if (target_z > 0.) {
0246 loc_x_at_target = localPos.x() + (segDir.x() / fabs(segDir.z()) * (target_z - globZ));
0247
0248
0249 } else {
0250 loc_x_at_target = localPos.x() + ((-1) * segDir.x() / fabs(segDir.z()) * (target_z - globZ));
0251
0252
0253 }
0254
0255
0256
0257 xdist_local_sig = fabs((localPositionRH.x() - loc_x_at_target) / (xxerr));
0258
0259 if (xdist_local_sig > xdist_local_worst_sig) {
0260 xdist_local_2ndworst_sig = xdist_local_worst_sig;
0261 xdist_local_worst_sig = xdist_local_sig;
0262 iRH_worst = iRH;
0263
0264 hit_nr_worst = hit_nr;
0265 } else if (xdist_local_sig > xdist_local_2ndworst_sig) {
0266 xdist_local_2ndworst_sig = xdist_local_sig;
0267
0268 }
0269 ++hit_nr;
0270 }
0271
0272
0273
0274
0275 if (xdist_local_worst_sig / xdist_local_2ndworst_sig < 1.5) {
0276 hit_nr_worst = -1;
0277
0278 }
0279 }
0280 }
0281
0282
0283
0284
0285 std::vector<CSCRecHit2D> buffer;
0286 std::vector<std::vector<CSCRecHit2D> > reduced_segments;
0287 std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
0288 float best_red_seg_prob = 0.0;
0289
0290 buffer.clear();
0291
0292 if (ChiSquaredProbability((double)(*it).chi2(), (double)((2 * (*it).nRecHits()) - 4)) < chi2ndfProbMin) {
0293 buffer = theseRecHits;
0294
0295
0296
0297 if (use_brute_force) {
0298 for (size_t bi = 0; bi < buffer.size(); ++bi) {
0299 reduced_segments.push_back(buffer);
0300 reduced_segments[bi].erase(reduced_segments[bi].begin() + (bi), reduced_segments[bi].begin() + (bi + 1));
0301 }
0302 } else {
0303
0304 if (hit_nr_worst >= 0 && hit_nr_worst <= int(buffer.size())) {
0305
0306 buffer.erase(buffer.begin() + (hit_nr_worst), buffer.begin() + (hit_nr_worst + 1));
0307 reduced_segments.push_back(buffer);
0308 } else {
0309
0310 reduced_segments.push_back(buffer);
0311 }
0312 }
0313 }
0314
0315
0316 for (size_t iSegment = 0; iSegment < reduced_segments.size(); ++iSegment) {
0317
0318 protoSegment.clear();
0319 for (size_t m = 0; m < reduced_segments[iSegment].size(); ++m) {
0320 protoSegment.push_back(&reduced_segments[iSegment][m]);
0321 }
0322
0323
0324 CSCCondSegFit* segfit = new CSCCondSegFit(pset(), chamber(), protoSegment);
0325 condpass1 = false;
0326 condpass2 = false;
0327 segfit->setScaleXError(1.0);
0328 segfit->fit(condpass1, condpass2);
0329
0330
0331
0332
0333 if (adjustCovariance()) {
0334 if (segfit->chi2() / segfit->ndof() > chi2Norm_3D_) {
0335 condpass1 = true;
0336 segfit->fit(condpass1, condpass2);
0337 }
0338 if ((segfit->scaleXError() < 1.00005) && (segfit->chi2() / segfit->ndof() > chi2Norm_3D_)) {
0339 condpass2 = true;
0340 segfit->fit(condpass1, condpass2);
0341 }
0342 }
0343
0344
0345
0346
0347
0348 CSCSegment temp(
0349 protoSegment, segfit->intercept(), segfit->localdir(), segfit->covarianceMatrix(), segfit->chi2());
0350
0351
0352 delete segfit;
0353
0354
0355
0356
0357 double oldchi2 = (*it).chi2();
0358 double olddof = 2 * (*it).nRecHits() - 4;
0359 double newchi2 = temp.chi2();
0360 double newdof = 2 * temp.nRecHits() - 4;
0361 if ((ChiSquaredProbability(oldchi2, olddof) < (1. / BPMinImprovement) * ChiSquaredProbability(newchi2, newdof)) &&
0362 (ChiSquaredProbability(newchi2, newdof) > best_red_seg_prob) &&
0363 (ChiSquaredProbability(newchi2, newdof) > 1e-10)) {
0364 best_red_seg_prob = ChiSquaredProbability(newchi2, newdof);
0365
0366
0367
0368 if (temp.nRecHits() >= minHitsPerSegment) {
0369 (*it) = temp;
0370 }
0371 }
0372 }
0373
0374 }
0375
0376 return segments;
0377 }
0378
0379
0380 std::vector<std::vector<const CSCRecHit2D*> > CSCSegAlgoST::clusterHits(const CSCChamber* aChamber,
0381 const ChamberHitContainer& rechits) {
0382 theChamber = aChamber;
0383
0384 std::vector<ChamberHitContainer> rechits_clusters;
0385
0386
0387
0388
0389
0390 float dXclus_box = 0.0;
0391 float dYclus_box = 0.0;
0392
0393 std::vector<const CSCRecHit2D*> temp;
0394
0395 std::vector<ChamberHitContainer> seeds;
0396
0397 std::vector<float> running_meanX;
0398 std::vector<float> running_meanY;
0399
0400 std::vector<float> seed_minX;
0401 std::vector<float> seed_maxX;
0402 std::vector<float> seed_minY;
0403 std::vector<float> seed_maxY;
0404
0405
0406
0407
0408
0409
0410
0411
0412 for (unsigned int i = 0; i < rechits.size(); ++i) {
0413 temp.clear();
0414
0415 temp.push_back(rechits[i]);
0416
0417 seeds.push_back(temp);
0418
0419
0420
0421
0422 running_meanX.push_back(rechits[i]->localPosition().x());
0423 running_meanY.push_back(rechits[i]->localPosition().y());
0424
0425
0426 seed_minX.push_back(rechits[i]->localPosition().x());
0427 seed_maxX.push_back(rechits[i]->localPosition().x());
0428 seed_minY.push_back(rechits[i]->localPosition().y());
0429 seed_maxY.push_back(rechits[i]->localPosition().y());
0430 }
0431
0432
0433
0434 for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
0435 for (size_t MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
0436 if (running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999.) {
0437 LogTrace("CSCSegment|CSC")
0438 << "[CSCSegAlgoST::clusterHits] ALARM! Skipping used seeds, this should not happen - inform CSC DPG";
0439
0440 continue;
0441 }
0442
0443
0444
0445
0446
0447
0448 if (running_meanX[NNN] > running_meanX[MMM])
0449 dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
0450 else
0451 dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
0452 if (running_meanY[NNN] > running_meanY[MMM])
0453 dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
0454 else
0455 dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
0456
0457 if (dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax) {
0458
0459
0460
0461
0462 running_meanX[MMM] = (running_meanX[NNN] * seeds[NNN].size() + running_meanX[MMM] * seeds[MMM].size()) /
0463 (seeds[NNN].size() + seeds[MMM].size());
0464 running_meanY[MMM] = (running_meanY[NNN] * seeds[NNN].size() + running_meanY[MMM] * seeds[MMM].size()) /
0465 (seeds[NNN].size() + seeds[MMM].size());
0466
0467
0468 if (seed_minX[NNN] <= seed_minX[MMM])
0469 seed_minX[MMM] = seed_minX[NNN];
0470 if (seed_maxX[NNN] > seed_maxX[MMM])
0471 seed_maxX[MMM] = seed_maxX[NNN];
0472 if (seed_minY[NNN] <= seed_minY[MMM])
0473 seed_minY[MMM] = seed_minY[NNN];
0474 if (seed_maxY[NNN] > seed_maxY[MMM])
0475 seed_maxY[MMM] = seed_maxY[NNN];
0476
0477
0478 seeds[MMM].insert(seeds[MMM].end(), seeds[NNN].begin(), seeds[NNN].end());
0479
0480
0481 running_meanX[NNN] = 999999.;
0482 running_meanY[NNN] = 999999.;
0483
0484
0485 break;
0486 }
0487 }
0488 }
0489
0490
0491
0492
0493 for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
0494 if (running_meanX[NNN] == 999999.)
0495 continue;
0496 rechits_clusters.push_back(seeds[NNN]);
0497 }
0498
0499
0500
0501 return rechits_clusters;
0502 }
0503
0504 std::vector<std::vector<const CSCRecHit2D*> > CSCSegAlgoST::chainHits(const CSCChamber* aChamber,
0505 const ChamberHitContainer& rechits) {
0506 std::vector<ChamberHitContainer> rechits_chains;
0507
0508 std::vector<const CSCRecHit2D*> temp;
0509
0510 std::vector<ChamberHitContainer> seeds;
0511
0512 std::vector<bool> usedCluster;
0513
0514
0515
0516
0517
0518 for (unsigned int i = 0; i < rechits.size(); ++i) {
0519 temp.clear();
0520 temp.push_back(rechits[i]);
0521 seeds.push_back(temp);
0522 usedCluster.push_back(false);
0523 }
0524
0525 bool gangedME11a = false;
0526 if (("ME1/a" == aChamber->specs()->chamberTypeName()) && aChamber->specs()->gangedStrips()) {
0527
0528 gangedME11a = true;
0529 }
0530
0531 for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
0532 for (size_t MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
0533 if (usedCluster[MMM] || usedCluster[NNN]) {
0534 continue;
0535 }
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547 bool goodToMerge = isGoodToMerge(gangedME11a, seeds[NNN], seeds[MMM]);
0548 if (goodToMerge) {
0549
0550
0551
0552
0553 seeds[MMM].insert(seeds[MMM].end(), seeds[NNN].begin(), seeds[NNN].end());
0554
0555
0556 usedCluster[NNN] = true;
0557
0558
0559 break;
0560 }
0561 }
0562 }
0563
0564
0565
0566
0567
0568 for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
0569 if (usedCluster[NNN])
0570 continue;
0571 rechits_chains.push_back(seeds[NNN]);
0572 }
0573
0574
0575
0576 return rechits_chains;
0577 }
0578
0579 bool CSCSegAlgoST::isGoodToMerge(bool gangedME11a, ChamberHitContainer& newChain, ChamberHitContainer& oldChain) {
0580 for (size_t iRH_new = 0; iRH_new < newChain.size(); ++iRH_new) {
0581 int layer_new = newChain[iRH_new]->cscDetId().layer() - 1;
0582 int middleStrip_new = newChain[iRH_new]->nStrips() / 2;
0583 int centralStrip_new = newChain[iRH_new]->channels(middleStrip_new);
0584 int centralWire_new = newChain[iRH_new]->hitWire();
0585 bool layerRequirementOK = false;
0586 bool stripRequirementOK = false;
0587 bool wireRequirementOK = false;
0588 bool goodToMerge = false;
0589 for (size_t iRH_old = 0; iRH_old < oldChain.size(); ++iRH_old) {
0590 int layer_old = oldChain[iRH_old]->cscDetId().layer() - 1;
0591 int middleStrip_old = oldChain[iRH_old]->nStrips() / 2;
0592 int centralStrip_old = oldChain[iRH_old]->channels(middleStrip_old);
0593 int centralWire_old = oldChain[iRH_old]->hitWire();
0594
0595
0596
0597
0598
0599
0600
0601
0602 if (layer_new == layer_old + 1 || layer_new == layer_old - 1 || layer_new == layer_old + 2 ||
0603 layer_new == layer_old - 2 || layer_new == layer_old + 3 || layer_new == layer_old - 3 ||
0604 layer_new == layer_old + 4 || layer_new == layer_old - 4) {
0605 layerRequirementOK = true;
0606 }
0607 int allStrips = 48;
0608
0609
0610
0611 if (centralStrip_new == centralStrip_old || centralStrip_new == centralStrip_old + 1 ||
0612 centralStrip_new == centralStrip_old - 1 || centralStrip_new == centralStrip_old + 2 ||
0613 centralStrip_new == centralStrip_old - 2) {
0614 stripRequirementOK = true;
0615 }
0616
0617 if (centralWire_new == centralWire_old || centralWire_new == centralWire_old + 1 ||
0618 centralWire_new == centralWire_old - 1 || centralWire_new == centralWire_old + 2 ||
0619 centralWire_new == centralWire_old - 2) {
0620 wireRequirementOK = true;
0621 }
0622
0623 if (gangedME11a) {
0624 if (centralStrip_new == centralStrip_old + 1 - allStrips ||
0625 centralStrip_new == centralStrip_old - 1 - allStrips ||
0626 centralStrip_new == centralStrip_old + 2 - allStrips ||
0627 centralStrip_new == centralStrip_old - 2 - allStrips ||
0628 centralStrip_new == centralStrip_old + 1 + allStrips ||
0629 centralStrip_new == centralStrip_old - 1 + allStrips ||
0630 centralStrip_new == centralStrip_old + 2 + allStrips ||
0631 centralStrip_new == centralStrip_old - 2 + allStrips) {
0632 stripRequirementOK = true;
0633 }
0634 }
0635 if (layerRequirementOK && stripRequirementOK && wireRequirementOK) {
0636 goodToMerge = true;
0637 return goodToMerge;
0638 }
0639 }
0640 }
0641 return false;
0642 }
0643
0644 double CSCSegAlgoST::theWeight(
0645 double coordinate_1, double coordinate_2, double coordinate_3, float layer_1, float layer_2, float layer_3) {
0646 double sub_weight = 0;
0647 sub_weight = fabs(((coordinate_2 - coordinate_3) / (layer_2 - layer_3)) -
0648 ((coordinate_1 - coordinate_2) / (layer_1 - layer_2)));
0649 return sub_weight;
0650 }
0651
0652
0653
0654
0655
0656 std::vector<CSCSegment> CSCSegAlgoST::buildSegments(const ChamberHitContainer& rechits) {
0657
0658 std::vector<CSCSegment> segmentInChamber;
0659 segmentInChamber.clear();
0660
0661
0662 unsigned int thering = 999;
0663 unsigned int thestation = 999;
0664
0665
0666 std::vector<int> hits_onLayerNumber(6);
0667
0668 unsigned int UpperLimit = maxRecHitsInCluster;
0669 if (int(rechits.size()) < minHitsPerSegment)
0670 return segmentInChamber;
0671
0672 for (int iarray = 0; iarray < 6; ++iarray) {
0673 PAhits_onLayer[iarray].clear();
0674 hits_onLayerNumber[iarray] = 0;
0675 }
0676
0677 chosen_Psegments.clear();
0678 chosen_weight_A.clear();
0679
0680 Psegments.clear();
0681 Psegments_noLx.clear();
0682 Psegments_noL1.clear();
0683 Psegments_noL2.clear();
0684 Psegments_noL3.clear();
0685 Psegments_noL4.clear();
0686 Psegments_noL5.clear();
0687 Psegments_noL6.clear();
0688
0689 Psegments_hits.clear();
0690
0691 weight_A.clear();
0692 weight_noLx_A.clear();
0693 weight_noL1_A.clear();
0694 weight_noL2_A.clear();
0695 weight_noL3_A.clear();
0696 weight_noL4_A.clear();
0697 weight_noL5_A.clear();
0698 weight_noL6_A.clear();
0699
0700 weight_B.clear();
0701 weight_noL1_B.clear();
0702 weight_noL2_B.clear();
0703 weight_noL3_B.clear();
0704 weight_noL4_B.clear();
0705 weight_noL5_B.clear();
0706 weight_noL6_B.clear();
0707
0708 curv_A.clear();
0709 curv_noL1_A.clear();
0710 curv_noL2_A.clear();
0711 curv_noL3_A.clear();
0712 curv_noL4_A.clear();
0713 curv_noL5_A.clear();
0714 curv_noL6_A.clear();
0715
0716
0717 int midlayer_pointer[6] = {0, 0, 2, 3, 3, 4};
0718
0719
0720 int n_layers_occupied_tot = 0;
0721 int n_layers_processed = 0;
0722
0723 float min_weight_A = 99999.9;
0724 float min_weight_noLx_A = 99999.9;
0725
0726
0727
0728
0729
0730
0731
0732 int best_pseg = -1;
0733 int best_noLx_pseg = -1;
0734 int best_Layer_noLx = -1;
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747 for (size_t M = 0; M < rechits.size(); ++M) {
0748
0749 hits_onLayerNumber[rechits[M]->cscDetId().layer() - 1] += 1;
0750 if (hits_onLayerNumber[rechits[M]->cscDetId().layer() - 1] == 1)
0751 n_layers_occupied_tot += 1;
0752
0753 PAhits_onLayer[rechits[M]->cscDetId().layer() - 1].push_back(rechits[M]);
0754 }
0755
0756
0757
0758 int tothits = 0;
0759 int maxhits = 0;
0760 int nexthits = 0;
0761 int maxlayer = -1;
0762 int nextlayer = -1;
0763
0764 for (size_t i = 0; i < hits_onLayerNumber.size(); ++i) {
0765
0766 tothits += hits_onLayerNumber[i];
0767 if (hits_onLayerNumber[i] > maxhits) {
0768 nextlayer = maxlayer;
0769 nexthits = maxhits;
0770 maxlayer = i;
0771 maxhits = hits_onLayerNumber[i];
0772 } else if (hits_onLayerNumber[i] > nexthits) {
0773 nextlayer = i;
0774 nexthits = hits_onLayerNumber[i];
0775 }
0776 }
0777
0778 if (tothits > (int)UpperLimit) {
0779 if (n_layers_occupied_tot > 4) {
0780 tothits = tothits - hits_onLayerNumber[maxlayer];
0781 n_layers_occupied_tot = n_layers_occupied_tot - 1;
0782 PAhits_onLayer[maxlayer].clear();
0783 hits_onLayerNumber[maxlayer] = 0;
0784 }
0785 }
0786
0787 if (tothits > (int)UpperLimit) {
0788 if (n_layers_occupied_tot > 4) {
0789 tothits = tothits - hits_onLayerNumber[nextlayer];
0790 n_layers_occupied_tot = n_layers_occupied_tot - 1;
0791 PAhits_onLayer[nextlayer].clear();
0792 hits_onLayerNumber[nextlayer] = 0;
0793 }
0794 }
0795
0796 if (tothits > (int)UpperLimit) {
0797
0798
0799
0800 if (useShowering) {
0801 CSCSegment segShower = showering_->showerSeg(theChamber, rechits);
0802 if (debug)
0803 dumpSegment(segShower);
0804
0805 if (segShower.nRecHits() < 3)
0806 return segmentInChamber;
0807 if (segShower.chi2() == -1)
0808 return segmentInChamber;
0809 segmentInChamber.push_back(segShower);
0810 return segmentInChamber;
0811 } else {
0812
0813
0814 CSCDetId id = rechits[0]->cscDetId();
0815 edm::LogVerbatim("CSCSegment|CSC") << "[CSCSegAlgoST::buildSegments] No. of rechits in the cluster/chamber > "
0816 << UpperLimit << " ... Segment finding canceled in CSC" << id;
0817 return segmentInChamber;
0818 }
0819 }
0820
0821
0822
0823
0824 if (!rechits.empty()) {
0825 thering = rechits[0]->cscDetId().ring();
0826 thestation = rechits[0]->cscDetId().station();
0827
0828 }
0829
0830
0831
0832
0833 if (n_layers_occupied_tot < minHitsPerSegment) {
0834 return segmentInChamber;
0835 }
0836
0837
0838
0839
0840
0841 for (int layer = 0; layer < 6; ++layer) {
0842
0843
0844
0845
0846
0847
0848
0849 if (!PAhits_onLayer[layer].empty()) {
0850 n_layers_processed += 1;
0851 }
0852
0853
0854 int orig_number_of_psegs = Psegments.size();
0855 int orig_number_of_noL1_psegs = Psegments_noL1.size();
0856 int orig_number_of_noL2_psegs = Psegments_noL2.size();
0857 int orig_number_of_noL3_psegs = Psegments_noL3.size();
0858 int orig_number_of_noL4_psegs = Psegments_noL4.size();
0859 int orig_number_of_noL5_psegs = Psegments_noL5.size();
0860 int orig_number_of_noL6_psegs = Psegments_noL6.size();
0861
0862
0863 for (int hit = 0; hit < int(PAhits_onLayer[layer].size()); ++hit) {
0864
0865
0866 if (orig_number_of_psegs == 0) {
0867
0868 Psegments_hits.push_back(PAhits_onLayer[layer][hit]);
0869
0870 Psegments.push_back(Psegments_hits);
0871 Psegments_noL6.push_back(Psegments_hits);
0872 Psegments_noL5.push_back(Psegments_hits);
0873 Psegments_noL4.push_back(Psegments_hits);
0874 Psegments_noL3.push_back(Psegments_hits);
0875 Psegments_noL2.push_back(Psegments_hits);
0876
0877
0878
0879 curv_A.push_back(0.0);
0880 curv_noL6_A.push_back(0.0);
0881 curv_noL5_A.push_back(0.0);
0882 curv_noL4_A.push_back(0.0);
0883 curv_noL3_A.push_back(0.0);
0884 curv_noL2_A.push_back(0.0);
0885
0886 weight_A.push_back(0.0);
0887 weight_noL6_A.push_back(0.0);
0888 weight_noL5_A.push_back(0.0);
0889 weight_noL4_A.push_back(0.0);
0890 weight_noL3_A.push_back(0.0);
0891 weight_noL2_A.push_back(0.0);
0892
0893 weight_B.push_back(0.0);
0894 weight_noL6_B.push_back(0.0);
0895 weight_noL5_B.push_back(0.0);
0896 weight_noL4_B.push_back(0.0);
0897 weight_noL3_B.push_back(0.0);
0898 weight_noL2_B.push_back(0.0);
0899
0900
0901 Psegments_hits.clear();
0902 } else {
0903 if (orig_number_of_noL1_psegs == 0) {
0904 Psegments_hits.push_back(PAhits_onLayer[layer][hit]);
0905
0906 Psegments_noL1.push_back(Psegments_hits);
0907
0908
0909
0910 curv_noL1_A.push_back(0.0);
0911
0912 weight_noL1_A.push_back(0.0);
0913
0914 weight_noL1_B.push_back(0.0);
0915
0916
0917 Psegments_hits.clear();
0918 }
0919
0920
0921
0922 for (int pseg = 0; pseg < orig_number_of_psegs; ++pseg) {
0923 int pseg_pos = (pseg) + ((hit)*orig_number_of_psegs);
0924 int pseg_noL1_pos = (pseg) + ((hit)*orig_number_of_noL1_psegs);
0925 int pseg_noL2_pos = (pseg) + ((hit)*orig_number_of_noL2_psegs);
0926 int pseg_noL3_pos = (pseg) + ((hit)*orig_number_of_noL3_psegs);
0927 int pseg_noL4_pos = (pseg) + ((hit)*orig_number_of_noL4_psegs);
0928 int pseg_noL5_pos = (pseg) + ((hit)*orig_number_of_noL5_psegs);
0929 int pseg_noL6_pos = (pseg) + ((hit)*orig_number_of_noL6_psegs);
0930
0931
0932
0933
0934
0935 if (!(hit == int(PAhits_onLayer[layer].size() -
0936 1))) {
0937
0938
0939 Psegments.push_back(Psegments[pseg_pos]);
0940 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
0941 Psegments_noL1.push_back(Psegments_noL1[pseg_noL1_pos]);
0942 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
0943 Psegments_noL2.push_back(Psegments_noL2[pseg_noL2_pos]);
0944 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
0945 Psegments_noL3.push_back(Psegments_noL3[pseg_noL3_pos]);
0946 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
0947 Psegments_noL4.push_back(Psegments_noL4[pseg_noL4_pos]);
0948 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
0949 Psegments_noL5.push_back(Psegments_noL5[pseg_noL5_pos]);
0950 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
0951 Psegments_noL6.push_back(Psegments_noL6[pseg_noL6_pos]);
0952
0953 weight_A.push_back(weight_A[pseg_pos]);
0954 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
0955 weight_noL1_A.push_back(weight_noL1_A[pseg_noL1_pos]);
0956 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
0957 weight_noL2_A.push_back(weight_noL2_A[pseg_noL2_pos]);
0958 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
0959 weight_noL3_A.push_back(weight_noL3_A[pseg_noL3_pos]);
0960 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
0961 weight_noL4_A.push_back(weight_noL4_A[pseg_noL4_pos]);
0962 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
0963 weight_noL5_A.push_back(weight_noL5_A[pseg_noL5_pos]);
0964 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
0965 weight_noL6_A.push_back(weight_noL6_A[pseg_noL6_pos]);
0966
0967 curv_A.push_back(curv_A[pseg_pos]);
0968 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
0969 curv_noL1_A.push_back(curv_noL1_A[pseg_noL1_pos]);
0970 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
0971 curv_noL2_A.push_back(curv_noL2_A[pseg_noL2_pos]);
0972 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
0973 curv_noL3_A.push_back(curv_noL3_A[pseg_noL3_pos]);
0974 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
0975 curv_noL4_A.push_back(curv_noL4_A[pseg_noL4_pos]);
0976 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
0977 curv_noL5_A.push_back(curv_noL5_A[pseg_noL5_pos]);
0978 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
0979 curv_noL6_A.push_back(curv_noL6_A[pseg_noL6_pos]);
0980
0981 weight_B.push_back(weight_B[pseg_pos]);
0982 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
0983 weight_noL1_B.push_back(weight_noL1_B[pseg_noL1_pos]);
0984 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
0985 weight_noL2_B.push_back(weight_noL2_B[pseg_noL2_pos]);
0986 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
0987 weight_noL3_B.push_back(weight_noL3_B[pseg_noL3_pos]);
0988 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
0989 weight_noL4_B.push_back(weight_noL4_B[pseg_noL4_pos]);
0990 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
0991 weight_noL5_B.push_back(weight_noL5_B[pseg_noL5_pos]);
0992 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
0993 weight_noL6_B.push_back(weight_noL6_B[pseg_noL6_pos]);
0994 }
0995
0996 Psegments[pseg_pos].push_back(PAhits_onLayer[layer][hit]);
0997 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
0998 Psegments_noL1[pseg_noL1_pos].push_back(PAhits_onLayer[layer][hit]);
0999 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
1000 Psegments_noL2[pseg_noL2_pos].push_back(PAhits_onLayer[layer][hit]);
1001 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
1002 Psegments_noL3[pseg_noL3_pos].push_back(PAhits_onLayer[layer][hit]);
1003 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
1004 Psegments_noL4[pseg_noL4_pos].push_back(PAhits_onLayer[layer][hit]);
1005 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
1006 Psegments_noL5[pseg_noL5_pos].push_back(PAhits_onLayer[layer][hit]);
1007 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
1008 Psegments_noL6[pseg_noL6_pos].push_back(PAhits_onLayer[layer][hit]);
1009
1010
1011
1012 if (Psegments[pseg_pos].size() > 2) {
1013
1014
1015
1016 weight_A[pseg_pos] += theWeight((*(Psegments[pseg_pos].end() - 1))->localPosition().x(),
1017 (*(Psegments[pseg_pos].end() - 2))->localPosition().x(),
1018 (*(Psegments[pseg_pos].end() - 3))->localPosition().x(),
1019 float((*(Psegments[pseg_pos].end() - 1))->cscDetId().layer()),
1020 float((*(Psegments[pseg_pos].end() - 2))->cscDetId().layer()),
1021 float((*(Psegments[pseg_pos].end() - 3))->cscDetId().layer()));
1022
1023 weight_B[pseg_pos] += theWeight((*(Psegments[pseg_pos].end() - 1))->localPosition().y(),
1024 (*(Psegments[pseg_pos].end() - 2))->localPosition().y(),
1025 (*(Psegments[pseg_pos].end() - 3))->localPosition().y(),
1026 float((*(Psegments[pseg_pos].end() - 1))->cscDetId().layer()),
1027 float((*(Psegments[pseg_pos].end() - 2))->cscDetId().layer()),
1028 float((*(Psegments[pseg_pos].end() - 3))->cscDetId().layer()));
1029
1030
1031
1032 if (int(Psegments[pseg_pos].size()) == n_layers_occupied_tot) {
1033 curv_A[pseg_pos] += theWeight(
1034 (*(Psegments[pseg_pos].end() - 1))->localPosition().x(),
1035 (*(Psegments[pseg_pos].end() - midlayer_pointer[n_layers_occupied_tot - 1]))->localPosition().x(),
1036 (*(Psegments[pseg_pos].end() - n_layers_occupied_tot))->localPosition().x(),
1037 float((*(Psegments[pseg_pos].end() - 1))->cscDetId().layer()),
1038 float(
1039 (*(Psegments[pseg_pos].end() - midlayer_pointer[n_layers_occupied_tot - 1]))->cscDetId().layer()),
1040 float((*(Psegments[pseg_pos].end() - n_layers_occupied_tot))->cscDetId().layer()));
1041
1042 if (curv_A[pseg_pos] > curvePenaltyThreshold)
1043 weight_A[pseg_pos] = weight_A[pseg_pos] * curvePenalty;
1044
1045 if (weight_B[pseg_pos] > a_yweightPenaltyThreshold[thestation][thering])
1046 weight_A[pseg_pos] = weight_A[pseg_pos] * yweightPenalty;
1047
1048 if (weight_A[pseg_pos] < min_weight_A) {
1049 min_weight_A = weight_A[pseg_pos];
1050
1051
1052 best_pseg = pseg_pos;
1053 }
1054 }
1055
1056
1057
1058 }
1059
1060 if (n_layers_occupied_tot > 3) {
1061 if (pseg < orig_number_of_noL1_psegs && (n_layers_processed != 2)) {
1062 if ((Psegments_noL1[pseg_noL1_pos].size() > 2)) {
1063
1064
1065
1066 weight_noL1_A[pseg_noL1_pos] +=
1067 theWeight((*(Psegments_noL1[pseg_noL1_pos].end() - 1))->localPosition().x(),
1068 (*(Psegments_noL1[pseg_noL1_pos].end() - 2))->localPosition().x(),
1069 (*(Psegments_noL1[pseg_noL1_pos].end() - 3))->localPosition().x(),
1070 float((*(Psegments_noL1[pseg_noL1_pos].end() - 1))->cscDetId().layer()),
1071 float((*(Psegments_noL1[pseg_noL1_pos].end() - 2))->cscDetId().layer()),
1072 float((*(Psegments_noL1[pseg_noL1_pos].end() - 3))->cscDetId().layer()));
1073
1074 weight_noL1_B[pseg_noL1_pos] +=
1075 theWeight((*(Psegments_noL1[pseg_noL1_pos].end() - 1))->localPosition().y(),
1076 (*(Psegments_noL1[pseg_noL1_pos].end() - 2))->localPosition().y(),
1077 (*(Psegments_noL1[pseg_noL1_pos].end() - 3))->localPosition().y(),
1078 float((*(Psegments_noL1[pseg_noL1_pos].end() - 1))->cscDetId().layer()),
1079 float((*(Psegments_noL1[pseg_noL1_pos].end() - 2))->cscDetId().layer()),
1080 float((*(Psegments_noL1[pseg_noL1_pos].end() - 3))->cscDetId().layer()));
1081
1082
1083
1084 if (int(Psegments_noL1[pseg_noL1_pos].size()) == n_layers_occupied_tot - 1) {
1085 curv_noL1_A[pseg_noL1_pos] += theWeight(
1086 (*(Psegments_noL1[pseg_noL1_pos].end() - 1))->localPosition().x(),
1087 (*(Psegments_noL1[pseg_noL1_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1088 ->localPosition()
1089 .x(),
1090 (*(Psegments_noL1[pseg_noL1_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1091 float((*(Psegments_noL1[pseg_noL1_pos].end() - 1))->cscDetId().layer()),
1092 float((*(Psegments_noL1[pseg_noL1_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1093 ->cscDetId()
1094 .layer()),
1095 float(
1096 (*(Psegments_noL1[pseg_noL1_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1097
1098 if (curv_noL1_A[pseg_noL1_pos] > curvePenaltyThreshold)
1099 weight_noL1_A[pseg_noL1_pos] = weight_noL1_A[pseg_noL1_pos] * curvePenalty;
1100
1101 if (weight_noL1_B[pseg_noL1_pos] > a_yweightPenaltyThreshold[thestation][thering])
1102 weight_noL1_A[pseg_noL1_pos] = weight_noL1_A[pseg_noL1_pos] * yweightPenalty;
1103
1104 if (weight_noL1_A[pseg_noL1_pos] < min_weight_noLx_A) {
1105 min_weight_noLx_A = weight_noL1_A[pseg_noL1_pos];
1106
1107
1108 best_noLx_pseg = pseg_noL1_pos;
1109 best_Layer_noLx = 1;
1110 }
1111 }
1112
1113
1114
1115 }
1116 }
1117 }
1118
1119 if (n_layers_occupied_tot > 3) {
1120 if (pseg < orig_number_of_noL2_psegs && (n_layers_processed != 2)) {
1121 if ((Psegments_noL2[pseg_noL2_pos].size() > 2)) {
1122
1123
1124
1125 weight_noL2_A[pseg_noL2_pos] +=
1126 theWeight((*(Psegments_noL2[pseg_noL2_pos].end() - 1))->localPosition().x(),
1127 (*(Psegments_noL2[pseg_noL2_pos].end() - 2))->localPosition().x(),
1128 (*(Psegments_noL2[pseg_noL2_pos].end() - 3))->localPosition().x(),
1129 float((*(Psegments_noL2[pseg_noL2_pos].end() - 1))->cscDetId().layer()),
1130 float((*(Psegments_noL2[pseg_noL2_pos].end() - 2))->cscDetId().layer()),
1131 float((*(Psegments_noL2[pseg_noL2_pos].end() - 3))->cscDetId().layer()));
1132
1133 weight_noL2_B[pseg_noL2_pos] +=
1134 theWeight((*(Psegments_noL2[pseg_noL2_pos].end() - 1))->localPosition().y(),
1135 (*(Psegments_noL2[pseg_noL2_pos].end() - 2))->localPosition().y(),
1136 (*(Psegments_noL2[pseg_noL2_pos].end() - 3))->localPosition().y(),
1137 float((*(Psegments_noL2[pseg_noL2_pos].end() - 1))->cscDetId().layer()),
1138 float((*(Psegments_noL2[pseg_noL2_pos].end() - 2))->cscDetId().layer()),
1139 float((*(Psegments_noL2[pseg_noL2_pos].end() - 3))->cscDetId().layer()));
1140
1141
1142
1143 if (int(Psegments_noL2[pseg_noL2_pos].size()) == n_layers_occupied_tot - 1) {
1144 curv_noL2_A[pseg_noL2_pos] += theWeight(
1145 (*(Psegments_noL2[pseg_noL2_pos].end() - 1))->localPosition().x(),
1146 (*(Psegments_noL2[pseg_noL2_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1147 ->localPosition()
1148 .x(),
1149 (*(Psegments_noL2[pseg_noL2_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1150 float((*(Psegments_noL2[pseg_noL2_pos].end() - 1))->cscDetId().layer()),
1151 float((*(Psegments_noL2[pseg_noL2_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1152 ->cscDetId()
1153 .layer()),
1154 float(
1155 (*(Psegments_noL2[pseg_noL2_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1156
1157 if (curv_noL2_A[pseg_noL2_pos] > curvePenaltyThreshold)
1158 weight_noL2_A[pseg_noL2_pos] = weight_noL2_A[pseg_noL2_pos] * curvePenalty;
1159
1160 if (weight_noL2_B[pseg_noL2_pos] > a_yweightPenaltyThreshold[thestation][thering])
1161 weight_noL2_A[pseg_noL2_pos] = weight_noL2_A[pseg_noL2_pos] * yweightPenalty;
1162
1163 if (weight_noL2_A[pseg_noL2_pos] < min_weight_noLx_A) {
1164 min_weight_noLx_A = weight_noL2_A[pseg_noL2_pos];
1165
1166
1167 best_noLx_pseg = pseg_noL2_pos;
1168 best_Layer_noLx = 2;
1169 }
1170 }
1171
1172
1173
1174 }
1175 }
1176 }
1177
1178 if (n_layers_occupied_tot > 3) {
1179 if (pseg < orig_number_of_noL3_psegs && (n_layers_processed != 3)) {
1180 if ((Psegments_noL3[pseg_noL3_pos].size() > 2)) {
1181
1182
1183
1184 weight_noL3_A[pseg_noL3_pos] +=
1185 theWeight((*(Psegments_noL3[pseg_noL3_pos].end() - 1))->localPosition().x(),
1186 (*(Psegments_noL3[pseg_noL3_pos].end() - 2))->localPosition().x(),
1187 (*(Psegments_noL3[pseg_noL3_pos].end() - 3))->localPosition().x(),
1188 float((*(Psegments_noL3[pseg_noL3_pos].end() - 1))->cscDetId().layer()),
1189 float((*(Psegments_noL3[pseg_noL3_pos].end() - 2))->cscDetId().layer()),
1190 float((*(Psegments_noL3[pseg_noL3_pos].end() - 3))->cscDetId().layer()));
1191
1192 weight_noL3_B[pseg_noL3_pos] +=
1193 theWeight((*(Psegments_noL3[pseg_noL3_pos].end() - 1))->localPosition().y(),
1194 (*(Psegments_noL3[pseg_noL3_pos].end() - 2))->localPosition().y(),
1195 (*(Psegments_noL3[pseg_noL3_pos].end() - 3))->localPosition().y(),
1196 float((*(Psegments_noL3[pseg_noL3_pos].end() - 1))->cscDetId().layer()),
1197 float((*(Psegments_noL3[pseg_noL3_pos].end() - 2))->cscDetId().layer()),
1198 float((*(Psegments_noL3[pseg_noL3_pos].end() - 3))->cscDetId().layer()));
1199
1200
1201
1202 if (int(Psegments_noL3[pseg_noL3_pos].size()) == n_layers_occupied_tot - 1) {
1203 curv_noL3_A[pseg_noL3_pos] += theWeight(
1204 (*(Psegments_noL3[pseg_noL3_pos].end() - 1))->localPosition().x(),
1205 (*(Psegments_noL3[pseg_noL3_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1206 ->localPosition()
1207 .x(),
1208 (*(Psegments_noL3[pseg_noL3_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1209 float((*(Psegments_noL3[pseg_noL3_pos].end() - 1))->cscDetId().layer()),
1210 float((*(Psegments_noL3[pseg_noL3_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1211 ->cscDetId()
1212 .layer()),
1213 float(
1214 (*(Psegments_noL3[pseg_noL3_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1215
1216 if (curv_noL3_A[pseg_noL3_pos] > curvePenaltyThreshold)
1217 weight_noL3_A[pseg_noL3_pos] = weight_noL3_A[pseg_noL3_pos] * curvePenalty;
1218
1219 if (weight_noL3_B[pseg_noL3_pos] > a_yweightPenaltyThreshold[thestation][thering])
1220 weight_noL3_A[pseg_noL3_pos] = weight_noL3_A[pseg_noL3_pos] * yweightPenalty;
1221
1222 if (weight_noL3_A[pseg_noL3_pos] < min_weight_noLx_A) {
1223 min_weight_noLx_A = weight_noL3_A[pseg_noL3_pos];
1224
1225
1226 best_noLx_pseg = pseg_noL3_pos;
1227 best_Layer_noLx = 3;
1228 }
1229 }
1230
1231
1232
1233 }
1234 }
1235 }
1236
1237 if (n_layers_occupied_tot > 3) {
1238 if (pseg < orig_number_of_noL4_psegs && (n_layers_processed != 4)) {
1239 if ((Psegments_noL4[pseg_noL4_pos].size() > 2)) {
1240
1241
1242
1243 weight_noL4_A[pseg_noL4_pos] +=
1244 theWeight((*(Psegments_noL4[pseg_noL4_pos].end() - 1))->localPosition().x(),
1245 (*(Psegments_noL4[pseg_noL4_pos].end() - 2))->localPosition().x(),
1246 (*(Psegments_noL4[pseg_noL4_pos].end() - 3))->localPosition().x(),
1247 float((*(Psegments_noL4[pseg_noL4_pos].end() - 1))->cscDetId().layer()),
1248 float((*(Psegments_noL4[pseg_noL4_pos].end() - 2))->cscDetId().layer()),
1249 float((*(Psegments_noL4[pseg_noL4_pos].end() - 3))->cscDetId().layer()));
1250
1251 weight_noL4_B[pseg_noL4_pos] +=
1252 theWeight((*(Psegments_noL4[pseg_noL4_pos].end() - 1))->localPosition().y(),
1253 (*(Psegments_noL4[pseg_noL4_pos].end() - 2))->localPosition().y(),
1254 (*(Psegments_noL4[pseg_noL4_pos].end() - 3))->localPosition().y(),
1255 float((*(Psegments_noL4[pseg_noL4_pos].end() - 1))->cscDetId().layer()),
1256 float((*(Psegments_noL4[pseg_noL4_pos].end() - 2))->cscDetId().layer()),
1257 float((*(Psegments_noL4[pseg_noL4_pos].end() - 3))->cscDetId().layer()));
1258
1259
1260
1261 if (int(Psegments_noL4[pseg_noL4_pos].size()) == n_layers_occupied_tot - 1) {
1262 curv_noL4_A[pseg_noL4_pos] += theWeight(
1263 (*(Psegments_noL4[pseg_noL4_pos].end() - 1))->localPosition().x(),
1264 (*(Psegments_noL4[pseg_noL4_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1265 ->localPosition()
1266 .x(),
1267 (*(Psegments_noL4[pseg_noL4_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1268 float((*(Psegments_noL4[pseg_noL4_pos].end() - 1))->cscDetId().layer()),
1269 float((*(Psegments_noL4[pseg_noL4_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1270 ->cscDetId()
1271 .layer()),
1272 float(
1273 (*(Psegments_noL4[pseg_noL4_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1274
1275 if (curv_noL4_A[pseg_noL4_pos] > curvePenaltyThreshold)
1276 weight_noL4_A[pseg_noL4_pos] = weight_noL4_A[pseg_noL4_pos] * curvePenalty;
1277
1278 if (weight_noL4_B[pseg_noL4_pos] > a_yweightPenaltyThreshold[thestation][thering])
1279 weight_noL4_A[pseg_noL4_pos] = weight_noL4_A[pseg_noL4_pos] * yweightPenalty;
1280
1281 if (weight_noL4_A[pseg_noL4_pos] < min_weight_noLx_A) {
1282 min_weight_noLx_A = weight_noL4_A[pseg_noL4_pos];
1283
1284
1285 best_noLx_pseg = pseg_noL4_pos;
1286 best_Layer_noLx = 4;
1287 }
1288 }
1289
1290
1291
1292 }
1293 }
1294 }
1295
1296 if (n_layers_occupied_tot > 4) {
1297 if (pseg < orig_number_of_noL5_psegs && (n_layers_processed != 5)) {
1298 if ((Psegments_noL5[pseg_noL5_pos].size() > 2)) {
1299
1300
1301
1302 weight_noL5_A[pseg_noL5_pos] +=
1303 theWeight((*(Psegments_noL5[pseg_noL5_pos].end() - 1))->localPosition().x(),
1304 (*(Psegments_noL5[pseg_noL5_pos].end() - 2))->localPosition().x(),
1305 (*(Psegments_noL5[pseg_noL5_pos].end() - 3))->localPosition().x(),
1306 float((*(Psegments_noL5[pseg_noL5_pos].end() - 1))->cscDetId().layer()),
1307 float((*(Psegments_noL5[pseg_noL5_pos].end() - 2))->cscDetId().layer()),
1308 float((*(Psegments_noL5[pseg_noL5_pos].end() - 3))->cscDetId().layer()));
1309
1310 weight_noL5_B[pseg_noL5_pos] +=
1311 theWeight((*(Psegments_noL5[pseg_noL5_pos].end() - 1))->localPosition().y(),
1312 (*(Psegments_noL5[pseg_noL5_pos].end() - 2))->localPosition().y(),
1313 (*(Psegments_noL5[pseg_noL5_pos].end() - 3))->localPosition().y(),
1314 float((*(Psegments_noL5[pseg_noL5_pos].end() - 1))->cscDetId().layer()),
1315 float((*(Psegments_noL5[pseg_noL5_pos].end() - 2))->cscDetId().layer()),
1316 float((*(Psegments_noL5[pseg_noL5_pos].end() - 3))->cscDetId().layer()));
1317
1318
1319
1320 if (int(Psegments_noL5[pseg_noL5_pos].size()) == n_layers_occupied_tot - 1) {
1321 curv_noL5_A[pseg_noL5_pos] += theWeight(
1322 (*(Psegments_noL5[pseg_noL5_pos].end() - 1))->localPosition().x(),
1323 (*(Psegments_noL5[pseg_noL5_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1324 ->localPosition()
1325 .x(),
1326 (*(Psegments_noL5[pseg_noL5_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1327 float((*(Psegments_noL5[pseg_noL5_pos].end() - 1))->cscDetId().layer()),
1328 float((*(Psegments_noL5[pseg_noL5_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1329 ->cscDetId()
1330 .layer()),
1331 float(
1332 (*(Psegments_noL5[pseg_noL5_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1333
1334 if (curv_noL5_A[pseg_noL5_pos] > curvePenaltyThreshold)
1335 weight_noL5_A[pseg_noL5_pos] = weight_noL5_A[pseg_noL5_pos] * curvePenalty;
1336
1337 if (weight_noL5_B[pseg_noL5_pos] > a_yweightPenaltyThreshold[thestation][thering])
1338 weight_noL5_A[pseg_noL5_pos] = weight_noL5_A[pseg_noL5_pos] * yweightPenalty;
1339
1340 if (weight_noL5_A[pseg_noL5_pos] < min_weight_noLx_A) {
1341 min_weight_noLx_A = weight_noL5_A[pseg_noL5_pos];
1342
1343
1344 best_noLx_pseg = pseg_noL5_pos;
1345 best_Layer_noLx = 5;
1346 }
1347 }
1348
1349
1350
1351 }
1352 }
1353 }
1354
1355 if (n_layers_occupied_tot > 5) {
1356 if (pseg < orig_number_of_noL6_psegs && (n_layers_processed != 6)) {
1357 if ((Psegments_noL6[pseg_noL6_pos].size() > 2)) {
1358
1359
1360
1361 weight_noL6_A[pseg_noL6_pos] +=
1362 theWeight((*(Psegments_noL6[pseg_noL6_pos].end() - 1))->localPosition().x(),
1363 (*(Psegments_noL6[pseg_noL6_pos].end() - 2))->localPosition().x(),
1364 (*(Psegments_noL6[pseg_noL6_pos].end() - 3))->localPosition().x(),
1365 float((*(Psegments_noL6[pseg_noL6_pos].end() - 1))->cscDetId().layer()),
1366 float((*(Psegments_noL6[pseg_noL6_pos].end() - 2))->cscDetId().layer()),
1367 float((*(Psegments_noL6[pseg_noL6_pos].end() - 3))->cscDetId().layer()));
1368
1369 weight_noL6_B[pseg_noL6_pos] +=
1370 theWeight((*(Psegments_noL6[pseg_noL6_pos].end() - 1))->localPosition().y(),
1371 (*(Psegments_noL6[pseg_noL6_pos].end() - 2))->localPosition().y(),
1372 (*(Psegments_noL6[pseg_noL6_pos].end() - 3))->localPosition().y(),
1373 float((*(Psegments_noL6[pseg_noL6_pos].end() - 1))->cscDetId().layer()),
1374 float((*(Psegments_noL6[pseg_noL6_pos].end() - 2))->cscDetId().layer()),
1375 float((*(Psegments_noL6[pseg_noL6_pos].end() - 3))->cscDetId().layer()));
1376
1377
1378
1379 if (int(Psegments_noL6[pseg_noL6_pos].size()) == n_layers_occupied_tot - 1) {
1380 curv_noL6_A[pseg_noL6_pos] += theWeight(
1381 (*(Psegments_noL6[pseg_noL6_pos].end() - 1))->localPosition().x(),
1382 (*(Psegments_noL6[pseg_noL6_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1383 ->localPosition()
1384 .x(),
1385 (*(Psegments_noL6[pseg_noL6_pos].end() - (n_layers_occupied_tot - 1)))->localPosition().x(),
1386 float((*(Psegments_noL6[pseg_noL6_pos].end() - 1))->cscDetId().layer()),
1387 float((*(Psegments_noL6[pseg_noL6_pos].end() - midlayer_pointer[n_layers_occupied_tot - 2]))
1388 ->cscDetId()
1389 .layer()),
1390 float(
1391 (*(Psegments_noL6[pseg_noL6_pos].end() - (n_layers_occupied_tot - 1)))->cscDetId().layer()));
1392
1393 if (curv_noL6_A[pseg_noL6_pos] > curvePenaltyThreshold)
1394 weight_noL6_A[pseg_noL6_pos] = weight_noL6_A[pseg_noL6_pos] * curvePenalty;
1395
1396 if (weight_noL6_B[pseg_noL6_pos] > a_yweightPenaltyThreshold[thestation][thering])
1397 weight_noL6_A[pseg_noL6_pos] = weight_noL6_A[pseg_noL6_pos] * yweightPenalty;
1398
1399 if (weight_noL6_A[pseg_noL6_pos] < min_weight_noLx_A) {
1400 min_weight_noLx_A = weight_noL6_A[pseg_noL6_pos];
1401
1402
1403 best_noLx_pseg = pseg_noL6_pos;
1404 best_Layer_noLx = 6;
1405 }
1406 }
1407
1408
1409
1410 }
1411 }
1412 }
1413 }
1414 }
1415 }
1416 }
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436 int chosen_pseg = best_pseg;
1437 if (best_pseg < 0) {
1438 return segmentInChamber;
1439 }
1440 chosen_Psegments = (Psegments);
1441 chosen_weight_A = (weight_A);
1442
1443 float hit_drop_limit = -999999.999;
1444
1445
1446 switch (n_layers_processed) {
1447 case 1:
1448
1449 break;
1450 case 2:
1451
1452 break;
1453 case 3:
1454
1455 break;
1456 case 4:
1457 hit_drop_limit = hitDropLimit6Hits * (1. / 2.) * hitDropLimit4Hits;
1458 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 4)) {
1459
1460 }
1461 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 3))
1462 hit_drop_limit = hit_drop_limit * (1. / 2.);
1463 break;
1464 case 5:
1465 hit_drop_limit = hitDropLimit6Hits * (2. / 3.) * hitDropLimit5Hits;
1466 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 5)) {
1467
1468 }
1469 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 4))
1470 hit_drop_limit = hit_drop_limit * (1. / 2.);
1471 if (best_Layer_noLx == 3)
1472 hit_drop_limit = hit_drop_limit * (1. / 3.);
1473 break;
1474 case 6:
1475 hit_drop_limit = hitDropLimit6Hits * (3. / 4.);
1476 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 6)) {
1477
1478 }
1479 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 5))
1480 hit_drop_limit = hit_drop_limit * (1. / 2.);
1481 if ((best_Layer_noLx == 3) || (best_Layer_noLx == 4))
1482 hit_drop_limit = hit_drop_limit * (1. / 3.);
1483 break;
1484
1485 default:
1486
1487 LogTrace("CSCSegment|CSC")
1488 << "[CSCSegAlgoST::buildSegments] Unexpected number of layers with hits - please inform CSC DPG.";
1489 hit_drop_limit = 0.1;
1490 }
1491
1492
1493 switch (best_Layer_noLx) {
1494 case 1:
1495 Psegments_noLx.clear();
1496 Psegments_noLx = Psegments_noL1;
1497 weight_noLx_A.clear();
1498 weight_noLx_A = weight_noL1_A;
1499 break;
1500 case 2:
1501 Psegments_noLx.clear();
1502 Psegments_noLx = Psegments_noL2;
1503 weight_noLx_A.clear();
1504 weight_noLx_A = weight_noL2_A;
1505 break;
1506 case 3:
1507 Psegments_noLx.clear();
1508 Psegments_noLx = Psegments_noL3;
1509 weight_noLx_A.clear();
1510 weight_noLx_A = weight_noL3_A;
1511 break;
1512 case 4:
1513 Psegments_noLx.clear();
1514 Psegments_noLx = Psegments_noL4;
1515 weight_noLx_A.clear();
1516 weight_noLx_A = weight_noL4_A;
1517 break;
1518 case 5:
1519 Psegments_noLx.clear();
1520 Psegments_noLx = Psegments_noL5;
1521 weight_noLx_A.clear();
1522 weight_noLx_A = weight_noL5_A;
1523 break;
1524 case 6:
1525 Psegments_noLx.clear();
1526 Psegments_noLx = Psegments_noL6;
1527 weight_noLx_A.clear();
1528 weight_noLx_A = weight_noL6_A;
1529 break;
1530
1531 default:
1532
1533 Psegments_noLx.clear();
1534 weight_noLx_A.clear();
1535 }
1536
1537 if (min_weight_A > 0.) {
1538 if (min_weight_noLx_A / min_weight_A < hit_drop_limit) {
1539
1540
1541
1542
1543 chosen_pseg = best_noLx_pseg;
1544 chosen_Psegments.clear();
1545 chosen_weight_A.clear();
1546 chosen_Psegments = (Psegments_noLx);
1547 chosen_weight_A = (weight_noLx_A);
1548 }
1549 }
1550
1551 if (onlyBestSegment) {
1552 ChooseSegments2a(chosen_Psegments, chosen_pseg);
1553 } else {
1554 ChooseSegments3(chosen_Psegments, chosen_weight_A, chosen_pseg);
1555 }
1556
1557 for (unsigned int iSegment = 0; iSegment < GoodSegments.size(); ++iSegment) {
1558 protoSegment = GoodSegments[iSegment];
1559
1560
1561 CSCCondSegFit* segfit = new CSCCondSegFit(pset(), chamber(), protoSegment);
1562 condpass1 = false;
1563 condpass2 = false;
1564 segfit->setScaleXError(1.0);
1565 segfit->fit(condpass1, condpass2);
1566
1567
1568
1569
1570 if (adjustCovariance()) {
1571
1572
1573
1574
1575
1576 if (segfit->chi2() / segfit->ndof() > chi2Norm_3D_) {
1577 condpass1 = true;
1578 segfit->fit(condpass1, condpass2);
1579 }
1580 if (segfit->scaleXError() < 1.00005) {
1581 LogTrace("CSCWeirdSegment") << "[CSCSegAlgoST::buildSegments] Segment ErrXX scaled and refit " << std::endl;
1582 if (segfit->chi2() / segfit->ndof() > chi2Norm_3D_) {
1583
1584
1585
1586
1587
1588 LogTrace("CSCWeirdSegment")
1589 << "[CSCSegAlgoST::buildSegments] Segment ErrXY changed to match cond. number and refit " << std::endl;
1590 condpass2 = true;
1591 segfit->fit(condpass1, condpass2);
1592 }
1593 }
1594
1595
1596
1597
1598
1599 if (prePrun_ && (sqrt(segfit->scaleXError()) > prePrunLimit_) && (segfit->nhits() > 3)) {
1600 LogTrace("CSCWeirdSegment")
1601 << "[CSCSegAlgoST::buildSegments] Scale factor chi2uCorrection too big, pre-Prune and refit " << std::endl;
1602 protoSegment.erase(protoSegment.begin() + segfit->worstHit(), protoSegment.begin() + segfit->worstHit() + 1);
1603
1604
1605
1606
1607 double tempcorr = segfit->scaleXError();
1608 delete segfit;
1609 segfit = new CSCCondSegFit(pset(), chamber(), protoSegment);
1610 segfit->setScaleXError(tempcorr);
1611 segfit->fit(condpass1, condpass2);
1612 }
1613 }
1614
1615
1616
1617
1618
1619 CSCSegment temp(protoSegment, segfit->intercept(), segfit->localdir(), segfit->covarianceMatrix(), segfit->chi2());
1620 delete segfit;
1621
1622 if (debug)
1623 dumpSegment(temp);
1624
1625 segmentInChamber.push_back(temp);
1626 }
1627 return segmentInChamber;
1628 }
1629
1630 void CSCSegAlgoST::ChooseSegments2a(std::vector<ChamberHitContainer>& chosen_segments, int chosen_seg) {
1631
1632 GoodSegments.clear();
1633 GoodSegments.push_back(chosen_segments[chosen_seg]);
1634 }
1635
1636 void CSCSegAlgoST::ChooseSegments3(std::vector<ChamberHitContainer>& chosen_segments,
1637 std::vector<float>& chosen_weight,
1638 int chosen_seg) {
1639 int SumCommonHits = 0;
1640 GoodSegments.clear();
1641 int nr_remaining_candidates;
1642 unsigned int nr_of_segment_candidates;
1643
1644 nr_remaining_candidates = nr_of_segment_candidates = chosen_segments.size();
1645
1646
1647 GoodSegments.push_back(chosen_segments[chosen_seg]);
1648
1649 float chosen_weight_temp = 999999.;
1650 int chosen_seg_temp = -1;
1651
1652
1653 while (nr_remaining_candidates > 0) {
1654 for (unsigned int iCand = 0; iCand < nr_of_segment_candidates; ++iCand) {
1655
1656 if (chosen_weight[iCand] < 0.)
1657 continue;
1658 SumCommonHits = 0;
1659
1660 for (int ihits = 0; ihits < int(chosen_segments[iCand].size());
1661 ++ihits) {
1662 if (chosen_segments[iCand][ihits] == chosen_segments[chosen_seg][ihits]) {
1663 ++SumCommonHits;
1664 }
1665 }
1666
1667
1668 if (SumCommonHits > 1) {
1669 chosen_weight[iCand] = -1.;
1670 nr_remaining_candidates -= 1;
1671 } else {
1672
1673 if (chosen_weight[iCand] < chosen_weight_temp) {
1674 chosen_weight_temp = chosen_weight[iCand];
1675 chosen_seg_temp = iCand;
1676 }
1677 }
1678 }
1679
1680 if (chosen_seg_temp > -1)
1681 GoodSegments.push_back(chosen_segments[chosen_seg_temp]);
1682
1683 chosen_seg = chosen_seg_temp;
1684
1685 chosen_weight_temp = 999999;
1686 chosen_seg_temp = -1;
1687 }
1688 }
1689
1690 void CSCSegAlgoST::ChooseSegments2(int best_seg) {
1691
1692 std::vector<unsigned int> BadCandidate;
1693 int SumCommonHits = 0;
1694 GoodSegments.clear();
1695 BadCandidate.clear();
1696 for (unsigned int iCand = 0; iCand < Psegments.size(); ++iCand) {
1697
1698 for (unsigned int iiCand = iCand + 1; iiCand < Psegments.size(); ++iiCand) {
1699
1700 SumCommonHits = 0;
1701 if (Psegments[iCand].size() != Psegments[iiCand].size()) {
1702 LogTrace("CSCSegment|CSC")
1703 << "[CSCSegAlgoST::ChooseSegments2] ALARM!! Should not happen - please inform CSC DPG";
1704 } else {
1705 for (int ihits = 0; ihits < int(Psegments[iCand].size());
1706 ++ihits) {
1707 if (Psegments[iCand][ihits] == Psegments[iiCand][ihits]) {
1708 ++SumCommonHits;
1709 }
1710 }
1711 }
1712 if (SumCommonHits > 1) {
1713 if (weight_A[iCand] > weight_A[iiCand]) {
1714 BadCandidate.push_back(iCand);
1715
1716 } else {
1717 BadCandidate.push_back(iiCand);
1718
1719 }
1720 }
1721 }
1722 }
1723 bool discard;
1724 for (unsigned int isegm = 0; isegm < Psegments.size(); ++isegm) {
1725
1726
1727 discard = false;
1728 for (unsigned int ibad = 0; ibad < BadCandidate.size(); ++ibad) {
1729
1730 if (isegm == BadCandidate[ibad]) {
1731 discard = true;
1732 }
1733 }
1734 if (!discard) {
1735 GoodSegments.push_back(Psegments[isegm]);
1736 }
1737 }
1738 }
1739
1740 void CSCSegAlgoST::findDuplicates(std::vector<CSCSegment>& segments) {
1741
1742
1743
1744
1745
1746 for (std::vector<CSCSegment>::iterator it = segments.begin(); it != segments.end(); ++it) {
1747 std::vector<CSCSegment*> duplicateSegments;
1748 for (std::vector<CSCSegment>::iterator it2 = segments.begin(); it2 != segments.end(); ++it2) {
1749
1750 bool allShared = true;
1751 if (it != it2) {
1752 allShared = it->sharesRecHits(*it2);
1753 } else {
1754 allShared = false;
1755 }
1756
1757 if (allShared) {
1758 duplicateSegments.push_back(&(*it2));
1759 }
1760 }
1761 it->setDuplicateSegments(duplicateSegments);
1762 }
1763 }
1764
1765 void CSCSegAlgoST::dumpSegment(const CSCSegment& seg) const {
1766
1767
1768 edm::LogVerbatim("CSCSegment") << "CSCSegment in " << chamber()->id() << "\nlocal position = " << seg.localPosition()
1769 << "\nerror = " << seg.localPositionError()
1770 << "\nlocal direction = " << seg.localDirection()
1771 << "\nerror =" << seg.localDirectionError() << "\ncovariance matrix"
1772 << seg.parametersError() << "chi2/ndf = " << seg.chi2() << "/"
1773 << seg.degreesOfFreedom() << "\n#rechits = " << seg.specificRecHits().size()
1774 << "\ntime = " << seg.time();
1775 }