124 std::vector<TrajectorySeed> rawSeeds;
125 std::vector<float> etaOfSeed;
126 std::vector<float> phiOfSeed;
127 std::vector<int> nSegOnSeed;
150 std::cout <<
"*** Number of DT segments is: " << DTlist4.size() + DTlist3.size() + DTlist2.size() + DTlist1.size()
152 std::cout <<
"In MB1: " << DTlist1.size() << std::endl;
153 std::cout <<
"In MB2: " << DTlist2.size() << std::endl;
154 std::cout <<
"In MB3: " << DTlist3.size() << std::endl;
155 std::cout <<
"In MB4: " << DTlist4.size() << std::endl;
188 std::cout <<
"*** Number of CSC segments is "
189 << CSClist4F.size() + CSClist3F.size() + CSClist2F.size() + CSClist1F.size() + CSClist0F.size() +
190 CSClist4B.size() + CSClist3B.size() + CSClist2B.size() + CSClist1B.size() + CSClist0B.size()
192 std::cout <<
"In ME11: " << CSClist0F.size() + CSClist0B.size() << std::endl;
193 std::cout <<
"In ME12: " << CSClist1F.size() + CSClist1B.size() << std::endl;
194 std::cout <<
"In ME2 : " << CSClist2F.size() + CSClist2B.size() << std::endl;
195 std::cout <<
"In ME3 : " << CSClist3F.size() + CSClist3B.size() << std::endl;
196 std::cout <<
"In ME4 : " << CSClist4F.size() + CSClist4B.size() << std::endl;
207 for (SegmentContainer::iterator it = DTlist1.begin(); it != DTlist1.end(); ++it) {
210 if (usedDTlist1[index] ==
true)
214 if ((*it)->dimension() != 4)
222 float eta_temp = gp.
eta();
223 float phi_temp = gp.
phi();
224 bool showeringBefore =
false;
227 showeringBefore =
true;
229 if (showeringBefore) {
235 protoTrack.push_back(*it);
238 layers.push_back(-1);
242 3, protoTrack, DTlist2, usedDTlist2, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
243 layers.push_back(-2);
247 3, protoTrack, DTlist3, usedDTlist3, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
248 layers.push_back(-3);
252 3, protoTrack, DTlist4, usedDTlist4, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
253 layers.push_back(-4);
258 if (eta_temp > 0.8) {
260 2, protoTrack, CSClist1F, usedCSClist1F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
265 2, protoTrack, CSClist2F, usedCSClist2F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
270 2, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
274 }
else if (eta_temp < -0.8) {
276 2, protoTrack, CSClist1B, usedCSClist1B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
281 2, protoTrack, CSClist2B, usedCSClist2B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
286 2, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
314 if (layers.size() < 2) {
317 if (layers[layers.size() - 1] > 0) {
324 rawSeeds.push_back(thisSeed);
325 etaOfSeed.push_back(eta_temp);
326 phiOfSeed.push_back(phi_temp);
327 nSegOnSeed.push_back(protoTrack.size());
330 usedDTlist1[
index] =
true;
335 for (SegmentContainer::iterator it = DTlist2.begin(); it != DTlist2.end(); ++it) {
338 if (usedDTlist2[index] ==
true)
342 if ((*it)->dimension() != 4)
350 float eta_temp = gp.
eta();
351 float phi_temp = gp.
phi();
352 bool showeringBefore =
false;
355 showeringBefore =
true;
357 if (showeringBefore) {
363 protoTrack.push_back(*it);
366 layers.push_back(-2);
370 3, protoTrack, DTlist3, usedDTlist3, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
371 layers.push_back(-3);
375 3, protoTrack, DTlist4, usedDTlist4, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
376 layers.push_back(-4);
381 if (eta_temp > 0.8) {
383 2, protoTrack, CSClist1F, usedCSClist1F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
388 2, protoTrack, CSClist2F, usedCSClist2F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
393 2, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
397 }
else if (eta_temp < -0.8) {
399 2, protoTrack, CSClist1B, usedCSClist1B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
404 2, protoTrack, CSClist2B, usedCSClist2B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
409 2, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
437 if (layers.size() < 2) {
440 if (layers[layers.size() - 1] > 0) {
447 rawSeeds.push_back(thisSeed);
448 etaOfSeed.push_back(eta_temp);
449 phiOfSeed.push_back(phi_temp);
450 nSegOnSeed.push_back(protoTrack.size());
453 usedDTlist2[
index] =
true;
458 for (SegmentContainer::iterator it = DTlist3.begin(); it != DTlist3.end(); ++it) {
461 if (usedDTlist3[index] ==
true)
465 if ((*it)->dimension() != 4)
473 float eta_temp = gp.
eta();
474 float phi_temp = gp.
phi();
475 bool showeringBefore =
false;
478 showeringBefore =
true;
480 if (showeringBefore) {
486 protoTrack.push_back(*it);
489 layers.push_back(-3);
493 3, protoTrack, DTlist4, usedDTlist4, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
494 layers.push_back(-4);
499 if (eta_temp > 0.8) {
501 2, protoTrack, CSClist1F, usedCSClist1F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
506 2, protoTrack, CSClist2F, usedCSClist2F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
511 2, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
515 }
else if (eta_temp < -0.8) {
517 2, protoTrack, CSClist1B, usedCSClist1B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
522 2, protoTrack, CSClist2B, usedCSClist2B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
527 2, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
554 if (layers.size() < 2) {
557 if (layers[layers.size() - 1] > 0) {
565 rawSeeds.push_back(thisSeed);
566 etaOfSeed.push_back(eta_temp);
567 phiOfSeed.push_back(phi_temp);
568 nSegOnSeed.push_back(protoTrack.size());
571 usedDTlist3[
index] =
true;
583 for (SegmentContainer::iterator it = CSClist0B.begin(); it != CSClist0B.end(); ++it) {
586 if (usedCSClist0B[index] ==
true)
596 float eta_temp = gp.
eta();
597 float phi_temp = gp.
phi();
598 bool showeringBefore =
false;
601 showeringBefore =
true;
603 if (showeringBefore) {
609 protoTrack.push_back(*it);
616 1, protoTrack, CSClist1B, usedCSClist1B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
621 1, protoTrack, CSClist2B, usedCSClist2B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
626 1, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
631 1, protoTrack, CSClist4B, usedCSClist4B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
649 if (layers.size() < 2) {
652 if (fabs(gp.
eta()) > 1.7) {
660 rawSeeds.push_back(thisSeed);
661 etaOfSeed.push_back(eta_temp);
662 phiOfSeed.push_back(phi_temp);
663 nSegOnSeed.push_back(protoTrack.size());
666 usedCSClist0B[
index] =
true;
671 for (SegmentContainer::iterator it = CSClist1B.begin(); it != CSClist1B.end(); ++it) {
674 if (usedCSClist1B[index] ==
true)
684 float eta_temp = gp.
eta();
685 float phi_temp = gp.
phi();
686 bool showeringBefore =
false;
689 showeringBefore =
true;
691 if (showeringBefore) {
697 protoTrack.push_back(*it);
704 1, protoTrack, CSClist2B, usedCSClist2B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
709 1, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
714 1, protoTrack, CSClist4B, usedCSClist4B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
732 if (layers.size() < 2) {
738 rawSeeds.push_back(thisSeed);
739 etaOfSeed.push_back(eta_temp);
740 phiOfSeed.push_back(phi_temp);
741 nSegOnSeed.push_back(protoTrack.size());
744 usedCSClist1B[
index] =
true;
749 for (SegmentContainer::iterator it = CSClist2B.begin(); it != CSClist2B.end(); ++it) {
752 if (usedCSClist2B[index] ==
true)
757 double dof =
static_cast<double>((*it)->degreesOfFreedom());
758 if (((*it)->chi2() /
dof) > 20000.0)
763 float eta_temp = gp.
eta();
764 float phi_temp = gp.
phi();
765 bool showeringBefore =
false;
768 showeringBefore =
true;
770 if (showeringBefore) {
776 protoTrack.push_back(*it);
783 1, protoTrack, CSClist3B, usedCSClist3B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
788 1, protoTrack, CSClist4B, usedCSClist4B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
806 if (layers.size() < 2) {
813 rawSeeds.push_back(thisSeed);
814 etaOfSeed.push_back(eta_temp);
815 phiOfSeed.push_back(phi_temp);
816 nSegOnSeed.push_back(protoTrack.size());
818 usedCSClist2B[
index] =
true;
823 for (SegmentContainer::iterator it = CSClist3B.begin(); it != CSClist3B.end(); ++it) {
826 if (usedCSClist3B[index] ==
true)
831 double dof =
static_cast<double>((*it)->degreesOfFreedom());
832 if (((*it)->chi2() /
dof) > 20000.0)
837 float eta_temp = gp.
eta();
838 float phi_temp = gp.
phi();
839 bool showeringBefore =
false;
842 showeringBefore =
true;
844 if (showeringBefore) {
850 protoTrack.push_back(*it);
857 1, protoTrack, CSClist4B, usedCSClist4B, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
875 usedCSClist3B[
index] =
true;
877 if (layers.size() < 2)
882 rawSeeds.push_back(thisSeed);
883 etaOfSeed.push_back(eta_temp);
884 phiOfSeed.push_back(phi_temp);
885 nSegOnSeed.push_back(protoTrack.size());
896 for (SegmentContainer::iterator it = CSClist0F.begin(); it != CSClist0F.end(); ++it) {
899 if (usedCSClist0F[index] ==
true)
909 float eta_temp = gp.
eta();
910 float phi_temp = gp.
phi();
911 bool showeringBefore =
false;
914 showeringBefore =
true;
916 if (showeringBefore) {
922 protoTrack.push_back(*it);
929 1, protoTrack, CSClist1F, usedCSClist1F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
934 1, protoTrack, CSClist2F, usedCSClist2F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
939 1, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
944 1, protoTrack, CSClist4F, usedCSClist4F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
962 if (layers.size() < 2) {
965 if (fabs(gp.
eta()) > 1.7) {
972 rawSeeds.push_back(thisSeed);
973 etaOfSeed.push_back(eta_temp);
974 phiOfSeed.push_back(phi_temp);
975 nSegOnSeed.push_back(protoTrack.size());
978 usedCSClist0F[
index] =
true;
983 for (SegmentContainer::iterator it = CSClist1F.begin(); it != CSClist1F.end(); ++it) {
986 if (usedCSClist1F[index] ==
true)
996 float eta_temp = gp.
eta();
997 float phi_temp = gp.
phi();
998 bool showeringBefore =
false;
1001 showeringBefore =
true;
1003 if (showeringBefore) {
1009 protoTrack.push_back(*it);
1012 layers.push_back(1);
1016 1, protoTrack, CSClist2F, usedCSClist2F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1017 layers.push_back(2);
1018 if (showeringBefore)
1021 1, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1022 layers.push_back(3);
1023 if (showeringBefore)
1026 1, protoTrack, CSClist4F, usedCSClist4F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1027 layers.push_back(4);
1028 if (showeringBefore)
1044 if (layers.size() < 2) {
1051 rawSeeds.push_back(thisSeed);
1052 etaOfSeed.push_back(eta_temp);
1053 phiOfSeed.push_back(phi_temp);
1054 nSegOnSeed.push_back(protoTrack.size());
1057 usedCSClist1F[
index] =
true;
1062 for (SegmentContainer::iterator it = CSClist2F.begin(); it != CSClist2F.end(); ++it) {
1065 if (usedCSClist2F[index] ==
true)
1070 double dof =
static_cast<double>((*it)->degreesOfFreedom());
1071 if (((*it)->chi2() /
dof) > 20000.0)
1076 float eta_temp = gp.
eta();
1077 float phi_temp = gp.
phi();
1078 bool showeringBefore =
false;
1081 showeringBefore =
true;
1083 if (showeringBefore) {
1089 protoTrack.push_back(*it);
1092 layers.push_back(2);
1096 1, protoTrack, CSClist3F, usedCSClist3F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1097 layers.push_back(3);
1098 if (showeringBefore)
1101 1, protoTrack, CSClist4F, usedCSClist4F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1102 layers.push_back(4);
1103 if (showeringBefore)
1119 if (layers.size() < 2) {
1126 rawSeeds.push_back(thisSeed);
1127 etaOfSeed.push_back(eta_temp);
1128 phiOfSeed.push_back(phi_temp);
1129 nSegOnSeed.push_back(protoTrack.size());
1132 usedCSClist2F[
index] =
true;
1137 for (SegmentContainer::iterator it = CSClist3F.begin(); it != CSClist3F.end(); ++it) {
1140 if (usedCSClist3F[index] ==
true)
1145 double dof =
static_cast<double>((*it)->degreesOfFreedom());
1146 if (((*it)->chi2() /
dof) > 20000.0)
1151 float eta_temp = gp.
eta();
1152 float phi_temp = gp.
phi();
1153 bool showeringBefore =
false;
1156 showeringBefore =
true;
1158 if (showeringBefore) {
1164 protoTrack.push_back(*it);
1167 layers.push_back(2);
1171 1, protoTrack, CSClist4F, usedCSClist4F, eta_temp, phi_temp, layers[layers.size() - 1], showeringBefore))
1172 layers.push_back(4);
1173 if (showeringBefore)
1189 usedCSClist3F[
index] =
true;
1191 if (layers.size() < 2)
1197 rawSeeds.push_back(thisSeed);
1198 etaOfSeed.push_back(eta_temp);
1199 phiOfSeed.push_back(phi_temp);
1200 nSegOnSeed.push_back(protoTrack.size());
1208 std::cout <<
"*** CLEAN UP " << std::endl;
1210 std::cout <<
"Number of seeds BEFORE " << rawSeeds.size() << std::endl;
1215 goodSeeds = theSeeds.size();
1221 std::cout <<
"Number of seeds AFTER " << goodSeeds << std::endl;
1242 bool& showeringBefore) {
1244 int scanlayer = (lastLayer < 0) ? (lastLayer - 1) : (lastLayer + 1);
1247 showeringBefore =
true;
1258 if (lastLayer == 0 || lastLayer == 1) {
1259 if (fabs(eta_last) < 2.1) {
1264 }
else if (lastLayer == 2) {
1270 }
else if (type == 2) {
1273 if (lastLayer == -1) {
1282 if (lastLayer == -1) {
1284 }
else if (lastLayer == -2) {
1292 if (showeringBefore && maxdPhi > 0.03)
1295 showeringBefore =
false;
1298 float eta_temp = eta_last;
1299 float phi_temp = phi_last;
1303 int best_match =
index;
1304 float best_R =
sqrt((maxdEta * maxdEta) + (maxdPhi * maxdPhi));
1305 float best_chi2 = 200;
1306 int best_dimension = 2;
1311 for (SegmentContainer::iterator it = segs.begin(); it != segs.end(); ++it) {
1317 double dh = fabs(gp2.
eta() - eta_temp);
1318 double df = fabs(gp2.
phi() - phi_temp);
1319 double dR =
sqrt((dh * dh) + (df * df));
1322 bool case1 = (dh < maxdEta && df < maxdPhi) ?
true :
false;
1324 bool case2 = (((*it)->dimension() != 4) && (dh < 0.5) && (df < maxdPhi)) ?
true :
false;
1325 if (!case1 && !case2)
1330 if (NRechits < best_nhits)
1332 best_nhits = NRechits;
1335 if ((*it)->dimension() < best_dimension)
1337 best_dimension = (*it)->dimension();
1344 double dof =
static_cast<double>((*it)->degreesOfFreedom());
1346 if ((*it)->chi2() / dof < 0.001 && NRechits < 6 && type == 1)
1348 if ((*it)->chi2() / dof > best_chi2)
1350 best_chi2 = (*it)->chi2() /
dof;
1353 if ((*it)->dimension() != 4) {
1359 phi_last = gp2.
phi();
1360 eta_last = gp2.
eta();
1369 for (SegmentContainer::iterator it = segs.begin(); it != segs.end(); ++it) {
1371 if (index != best_match)
1373 protoTrack.push_back(*it);
1374 usedSeg[best_match] =
true;
1385 int& NShoweringSegments) {
1386 bool showering =
false;
1390 double nChi2 = 9999.;
1392 std::vector<int> badtag;
1394 double aveEta = 0.0;
1395 for (SegmentContainer::iterator it = segs.begin(); it != segs.end(); ++it) {
1398 double dh = gp.
eta() - eta_last;
1399 double df = gp.
phi() - phi_last;
1400 double dR =
sqrt((dh * dh) + (df * df));
1402 double dof =
static_cast<double>((*it)->degreesOfFreedom());
1403 double nX2 = (*it)->chi2() /
dof;
1406 DetId geoId = (*it)->geographicalId();
1412 badtag.push_back(index);
1413 aveEta += fabs(gp.
eta());
1416 if (rh < 6 && !isDT)
1418 if (rh < 12 && isDT)
1424 if (layer != 0 && layer != 1 && layer != -1) {
1430 aveEta = aveEta /
static_cast<double>(nSeg);
1431 bool isME11A = (aveEta >= 2.1 && layer == 0) ?
true :
false;
1432 bool isME12 = (aveEta > 1.2 && aveEta <= 1.65 && layer == 1) ?
true :
false;
1433 bool isME11 = (aveEta > 1.65 && aveEta <= 2.1 && layer == 0) ?
true :
false;
1434 bool is1stLayer = (layer == -1 || layer == 0 || isME12 || isME11 || isME11A) ?
true :
false;
1436 NShoweringSegments += nSeg;
1438 if (nSeg > 3 && !isME11A)
1440 if (nSeg > 6 && isME11A)
1445 if (showering && !is1stLayer) {
1446 for (std::vector<int>::iterator it = badtag.begin(); it != badtag.end(); ++it) {
1447 usedSeg[*it] =
true;
1448 if ((*it) != theOrigin)
1458 double dHdTheta = 0.0;
1459 double dThetadR = 0.0;
1460 double etaErr = 1.0;
1462 if (gp.
perp() != 0) {
1463 dHdTheta = (gp.
mag() + gp.
z()) / gp.
perp();
1464 dThetadR = gp.
z() / gp.
perp2();
1465 etaErr = 0.25 * (dHdTheta * dThetadR) * (dHdTheta * dThetadR) * rErr;
bool debug
group the seeds
double etaError(const GlobalPoint gp, double rErr)
calculate the eta error from global R error
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
MuonTransientTrackingRecHit::MuonRecHitContainer SegmentContainer
SegmentContainer ShoweringSegments
float maxPhiResolutionCSC
bool IdentifyShowering(SegmentContainer &segs, BoolContainer &usedSeg, float &eta_last, float &phi_last, int layer, int &NShoweringSegments)
identify the showering layer
int build(edm::Event &event, const edm::EventSetup &eventSetup, TrajectorySeedCollection &seeds)
Build seed collection.
bool foundMatchingSegment(int type, SegmentContainer &protoTrack, SegmentContainer &segments, BoolContainer &usedSeg, float &eta_temp, float &phi_temp, int &lastLayer, bool &showeringBefore)
Find segment which matches protoTrack for endcap only.
Geom::Phi< T > phi() const
TrajectorySeed createSeed(int type, const SegmentContainer &seg, const std::vector< int > &layers, int NShower, int NShowerSeg)
Create a seed from set of segments.
bool isDT(GeomDetEnumerators::SubDetector m)
constexpr std::array< uint8_t, layerIndexSize > layer
MuonDetLayerMeasurements * muonMeasurements
MuonSeedCleaner * muonSeedClean_
const MagneticField * BField
edm::InputTag theCSCSegmentLabel
Name of the CSC segment collection.
std::deque< bool > BoolContainer
edm::InputTag theDTSegmentLabel
Name of the DT segment collection.
std::vector< int > ShoweringLayers
std::vector< TrajectorySeed > TrajectorySeedCollection
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
bool enableCSCMeasurement
void setBField(const MagneticField *theField)
Cache Magnetic Field for current event.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int NRecHitsFromSegment(const TrackingRecHit &rhit)
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
T getParameter(std::string const &) const
float maxEtaResolutionCSC
MuonSeedBuilder(const edm::ParameterSet &, edm::ConsumesCollector &)
Constructor.
~MuonSeedBuilder()
Destructor.
std::vector< TrajectorySeed > seedCleaner(const edm::EventSetup &eventSetup, std::vector< TrajectorySeed > &seeds)
Cache pointer to geometry.
const std::vector< const DetLayer * > & backwardCSCLayers() const
return the backward (-Z) CSC DetLayers, inside-out
MuonSeedCreator * muonSeedCreate_
Create seed according to region (CSC, DT, Overlap)
const MuonDetLayerGeometry * muonLayers