98 void endJob()
override;
112 int overlapCounts_[3];
122 unsigned short hitCounts_[2];
124 unsigned int overlapIds_[2];
125 float predictedPositions_[3][2];
126 float predictedLocalParameters_[5][2];
127 float predictedLocalErrors_[5][2];
132 float hitPositions_[2];
134 float hitPositionsY_[2];
135 float hitErrorsY_[2];
136 float simHitPositions_[2];
137 float simHitPositionsY_[2];
138 float clusterWidthX_[2];
139 float clusterWidthY_[2];
140 float clusterSize_[2];
158 float localxdotglobalphi_[2];
159 float localxdotglobalr_[2];
160 float localxdotglobalz_[2];
161 float localxdotglobalx_[2];
162 float localxdotglobaly_[2];
163 float localydotglobalphi_[2];
164 float localydotglobalr_[2];
165 float localydotglobalz_[2];
166 float localydotglobalx_[2];
167 float localydotglobaly_[2];
185 FileInPath_(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"),
186 addExtraBranches_(
false),
188 chi2ProbCut_(0.001) {
212 rootTree_ = fs->make<TTree>(
"Overlaps",
"Overlaps");
320 for (
const auto& trajectory : *trajectoryCollection)
331 typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*>
Overlap;
332 typedef vector<Overlap> OverlapContainer;
335 OverlapContainer overlapHits;
348 vector<TrajectoryMeasurement> measurements(trajectory.
measurements());
349 for (vector<TrajectoryMeasurement>::const_iterator itm = measurements.begin(); itm != measurements.end(); ++itm) {
356 int subDet =
id.subdetId();
358 if (!
hit->isValid()) {
374 for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm - 1;
375 itmCompare >= measurements.begin() && itmCompare > itm - 4;
377 DetId compareId = itmCompare->recHit()->geographicalId();
381 if (!itmCompare->recHit()->isValid())
385 overlapHits.push_back(std::make_pair(&(*itmCompare), &(*itm)));
392 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " <<
id.rawId()
396 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " << compareId.
rawId()
413 for (
const auto& overlapHit : overlapHits) {
439 std::pair<TrajectoryStateOnSurface, double> tsosWithS =
propagator.propagateWithPath(comb1, fwdPred2.
surface());
458 for (
int i = 0;
i < 5; ++
i) {
470 for (
int i = 0;
i < 5; ++
i) {
491 double c00 = covComb1(3, 3);
494 for (
int i = 1;
i < 5; ++
i) {
495 c10 += jacobian(3,
i) * covComb1(
i, 3);
496 for (
int j = 1;
j < 5; ++
j)
497 c11 += jacobian(3,
i) * covComb1(
i,
j) * jacobian(3,
j);
500 double diff = c00 - 2 * fabs(c10) + c11;
506 double c00Y = covComb1(4, 4);
509 for (
int i = 1;
i < 5; ++
i) {
510 c10Y += jacobian(4,
i) * covComb1(
i, 4);
511 for (
int j = 1;
j < 5; ++
j)
512 c11Y += jacobian(4,
i) * covComb1(
i,
j) * jacobian(4,
j);
514 double diffY = c00Y - 2 * fabs(c10Y) + c11Y;
515 diffY = diffY > 0 ?
sqrt(diffY) : -
sqrt(-diffY);
520 overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
521 overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
524 moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
525 moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
526 moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
527 moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
528 moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
529 moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
530 subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
532 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
534 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
537 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
539 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
541 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
543 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
545 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
547 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
549 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
551 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
553 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
555 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
557 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
559 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
561 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
563 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
565 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
567 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
569 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
571 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
574 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo);
576 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 4;
578 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 10;
580 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 13;
582 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 20;
584 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 30;
590 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued()
592 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
595 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued()
597 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
613 DetId id1 = overlapHit.first->recHit()->geographicalId();
614 DetId id2 = overlapHit.second->recHit()->geographicalId();
616 int subDet1 =
id1.subdetId();
618 int subDet2 =
id2.subdetId();
620 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id1.rawId()
623 <<
" and layer = " << layer1 << endl;
625 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id2.rawId()
628 <<
" and layer = " << layer2 << endl;
636 const SiStripRecHit1D* hit1 = dynamic_cast<const SiStripRecHit1D*>((*thit1).hit());
645 uint16_t firstStrip = cluster1->firstStrip();
646 uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).
size() - 1;
647 unsigned short Nstrips;
650 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
658 const std::vector<uint8_t>& stripCharges = cluster1->amplitudes();
660 for (
uint i = 0;
i < stripCharges.size();
i++) {
667 const SiStripRecHit1D* hit2 = dynamic_cast<const SiStripRecHit1D*>((*thit2).hit());
674 uint16_t firstStrip = cluster2->firstStrip();
675 uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).
size() - 1;
676 unsigned short Nstrips;
679 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
687 const std::vector<uint8_t>& stripCharges = cluster2->amplitudes();
689 for (
uint i = 0;
i < stripCharges.size();
i++) {
700 const SiPixelRecHit* recHitPix1 = dynamic_cast<const SiPixelRecHit*>((*thit1).hit());
710 const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>((*trackerGeometry_).idToDet(
id1));
713 int minPixelRow = cluster1->minPixelRow();
714 int maxPixelRow = cluster1->maxPixelRow();
715 int minPixelCol = cluster1->minPixelCol();
716 int maxPixelCol = cluster1->maxPixelCol();
718 bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) || (topol->isItEdgePixelInX(maxPixelRow));
719 bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) || (topol->isItEdgePixelInY(maxPixelCol));
720 if (edgeHitX || edgeHitY)
733 const SiPixelRecHit* recHitPix2 = dynamic_cast<const SiPixelRecHit*>((*thit2).hit());
742 const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>((*trackerGeometry_).idToDet(
id2));
745 int minPixelRow = cluster2->minPixelRow();
746 int maxPixelRow = cluster2->maxPixelRow();
747 int minPixelCol = cluster2->minPixelCol();
748 int maxPixelCol = cluster2->maxPixelCol();
750 bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) || (topol->isItEdgePixelInX(maxPixelRow));
751 bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) || (topol->isItEdgePixelInY(maxPixelCol));
752 if (edgeHitX || edgeHitY)
769 std::vector<PSimHit> psimHits1;
770 std::vector<PSimHit> psimHits2;
772 DetId id = overlapHit.first->recHit()->geographicalId();
775 int subDet =
id.subdetId();
776 edm::LogVerbatim(
"OverlapValidation") <<
"Subdet = " << subDet <<
" ; layer = " << layer;
778 psimHits1 =
associator.associateHit(*(firstRecHit->hit()));
780 edm::LogVerbatim(
"OverlapValidation") <<
"length of psimHits1: " << psimHits1.size();
781 if (!psimHits1.empty()) {
782 float closest_dist = 99999.9;
783 std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
784 for (std::vector<PSimHit>::const_iterator
m = psimHits1.begin();
m < psimHits1.end();
m++) {
786 float simX = (*m).localPosition().x();
787 float dist = fabs(simX - (overlapHit.first->recHit()->localPosition().x()));
789 <<
"simHit1 simX = " << simX <<
" hitX = " << overlapHit.first->recHit()->localPosition().x()
790 <<
" distX = " << dist <<
" layer = " << layer;
791 if (dist < closest_dist) {
802 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
806 LocalVector localdirection = (*closest_simhit).localDirection();
809 float scale = -lp.
z() / direction.
z();
826 psimHits2 =
associator.associateHit(*(secondRecHit->hit()));
827 if (!psimHits2.empty()) {
828 float closest_dist = 99999.9;
829 std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
830 for (std::vector<PSimHit>::const_iterator
m = psimHits2.begin();
m < psimHits2.end();
m++) {
831 float simX = (*m).localPosition().x();
832 float dist = fabs(simX - (overlapHit.second->recHit()->localPosition().x()));
833 if (dist < closest_dist) {
842 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
846 LocalVector localdirection = (*closest_simhit).localDirection();
849 float scale = -lp.
z() / direction.
z();
869 int layer = subdetandlayer.second;