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) {
197 overlapCounts_[1] = 0;
198 overlapCounts_[2] = 0;
212 rootTree_ = fs->make<TTree>(
"Overlaps",
"Overlaps");
266 w <<
" Number of valid hits: " << overlapCounts_[1];
267 w <<
" Number of overlaps: " << overlapCounts_[2];
302 associator =
nullptr;
320 for (
const auto& trajectory : *trajectoryCollection)
321 analyze(trajectory, propagator, *associator, tTopo);
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) {
354 DetId id = hit->geographicalId();
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) {
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;
501 diff = diff > 0 ?
sqrt(diff) : -
sqrt(-diff);
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;
608 hitPositionsY_[1] = secondRecHit->localPosition().y();
613 DetId id1 = overlapHit.first->recHit()->geographicalId();
614 DetId id2 = overlapHit.second->recHit()->geographicalId();
616 int subDet1 = id1.subdetId();
619 if (
abs(hitPositions_[0]) > 5)
620 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " << id1.rawId()
623 <<
" and layer = " << layer1 << endl;
624 if (
abs(hitPositions_[1]) > 5)
628 <<
" and layer = " << layer2 << endl;
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++) {
661 charge += stripCharges.at(
i);
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++) {
690 charge += stripCharges.at(
i);
713 int minPixelRow = cluster1->minPixelRow();
714 int maxPixelRow = cluster1->maxPixelRow();
715 int minPixelCol = cluster1->minPixelCol();
716 int maxPixelCol = cluster1->maxPixelCol();
720 if (edgeHitX || edgeHitY)
745 int minPixelRow = cluster2->minPixelRow();
746 int maxPixelRow = cluster2->maxPixelRow();
747 int minPixelCol = cluster2->minPixelCol();
748 int maxPixelCol = cluster2->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();
810 LocalPoint projectedPos = lp + scale * direction;
819 edm::LogVerbatim(
"OverlapValidation") <<
"hit position = " << hitPositions_[0];
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();
850 LocalPoint projectedPos = lp + scale * direction;
869 int layer = subdetandlayer.second;
ClusterRef cluster() const
edm::InputTag trajectoryTag_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const Point2DBase< float, LocalTag > zerozero
T getParameter(std::string const &) const
EventNumber_t event() const
static constexpr auto TEC
TrajectoryStateCombiner combiner_
edm::EDGetTokenT< TrajectoryCollection > trajectoryToken_
unsigned int overlapIds_[2]
~OverlapValidation() override
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
vector< bool > acceptLayer
const GeomDetUnit * monoDet() const
const LocalTrajectoryParameters & localParameters() const
float localydotglobalr_[2]
const bool addExtraBranches_
float localxdotglobalr_[2]
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float localxdotglobaly_[2]
float predictedPositions_[3][2]
virtual bool isItEdgePixelInX(int ixbin) const =0
const Point2DBase< float, LocalTag > onezero
float predictedDeltaYError_
float predictedDeltaXError_
constexpr uint32_t rawId() const
get the raw id
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
float localxdotglobalphi_[2]
GlobalPoint globalPosition() const
virtual bool isItEdgePixelInY(int iybin) const =0
float localydotglobaly_[2]
float localxdotglobalx_[2]
float simHitPositionsY_[2]
const Point2DBase< float, LocalTag > zeroone
unsigned short hitCounts_[2]
const Plane & surface() const
The nominal surface of the GeomDet.
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
float localydotglobalx_[2]
void analyze(const edm::Event &, const edm::EventSetup &) override
const MagneticField * magField_
DataContainer const & measurements() const
AlgebraicVector5 vector() const
float localydotglobalz_[2]
const SurfaceType & surface() const
#define DEFINE_FWK_MODULE(type)
int layerFromId(const DetId &, const TrackerTopology *const tTopo) const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
vector< Trajectory > TrajectoryCollection
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
LocalPoint toLocal(const GlobalPoint &gp) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Abs< T >::type abs(const T &t)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
float ChiSquaredProbability(double chiSquared, double nrDOF)
const AlgebraicSymMatrix55 & matrix() const
const TrackerGeometry * trackerGeometry_
float predictedLocalErrors_[5][2]
const LocalTrajectoryError & localError() const
static constexpr auto TOB
float simHitPositions_[2]
float localxdotglobalz_[2]
Detector identifier class for the strip tracker.
OverlapValidation(const edm::ParameterSet &)
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
int ndof(bool bon=true) const
float predictedLocalParameters_[5][2]
static constexpr auto TIB
T const * product() const
const GlobalTrajectoryParameters & globalParameters() const
edm::FileInPath FileInPath_
ClusterRef cluster() const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
SiStripDetInfoFileReader * reader
edm::ParameterSet config_
GlobalVector globalMomentum() const
static int position[264][3]
const AlgebraicMatrix55 & jacobian() const
std::string fullPath() const
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
float localydotglobalphi_[2]
static constexpr auto TID
T const * product() const