102 void endJob()
override ;
116 int overlapCounts_[3];
126 unsigned short hitCounts_[2];
128 unsigned int overlapIds_[2];
129 float predictedPositions_[3][2];
130 float predictedLocalParameters_[5][2];
131 float predictedLocalErrors_[5][2];
136 float hitPositions_[2];
138 float hitPositionsY_[2];
139 float hitErrorsY_[2];
140 float simHitPositions_[2];
141 float simHitPositionsY_[2];
142 float clusterWidthX_[2];
143 float clusterWidthY_[2];
144 float clusterSize_[2];
162 float localxdotglobalphi_[2];
163 float localxdotglobalr_[2];
164 float localxdotglobalz_[2];
165 float localxdotglobalx_[2];
166 float localxdotglobaly_[2];
167 float localydotglobalphi_[2];
168 float localydotglobalr_[2];
169 float localydotglobalz_[2];
170 float localydotglobalx_[2];
171 float localydotglobaly_[2];
188 config_(iConfig), rootTree_(
nullptr),
189 FileInPath_(
"CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"),
190 addExtraBranches_(
false),
204 overlapCounts_[1] = 0;
205 overlapCounts_[2] = 0;
220 rootTree_ = fs->make<TTree>(
"Overlaps",
"Overlaps");
230 "predQP[2]/F:predDX[2]/F:predDY[2]/F:predX[2]/F:predY[2]/F");
232 "predEQP[2]/F:predEDX[2]/F:predEDY[2]/F:predEX[2]/F:predEY[2]/F");
279 w <<
" Number of valid hits: " << overlapCounts_[1];
280 w <<
" Number of overlaps: " << overlapCounts_[2];
320 associator =
nullptr;
347 for (
const auto& trajectory : *trajectoryCollection)
analyze(trajectory,propagator,*associator, tTopo);
362 typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*>
Overlap;
363 typedef vector<Overlap> OverlapContainer;
366 OverlapContainer overlapHits;
378 vector<TrajectoryMeasurement> measurements(trajectory.
measurements());
379 for ( vector<TrajectoryMeasurement>::const_iterator itm=measurements.begin();
380 itm!=measurements.end(); ++itm ) {
385 DetId id = hit->geographicalId();
387 int subDet =
id.subdetId();
389 if ( !hit->isValid() ) {
404 for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm-1;
405 itmCompare >= measurements.begin() && itmCompare > itm - 4;
408 DetId compareId = itmCompare->recHit()->geographicalId();
411 if (!itmCompare->recHit()->isValid())
continue;
414 overlapHits.push_back(std::make_pair(&(*itmCompare),&(*itm)));
437 for (
const auto& overlapHit : overlapHits) {
444 if ( !bwdPred1.
isValid() )
continue;
449 if ( !fwdPred2.
isValid() )
continue;
452 if ( !fwdPred2At1.
isValid() )
continue;
455 if ( !comb1.
isValid() )
continue;
459 std::pair<TrajectoryStateOnSurface,double> tsosWithS =
462 if ( !comb1At2.
isValid() )
continue;
477 for (
int i=0;
i<5; ++
i ) {
489 for (
int i=0;
i<5; ++
i ) {
514 jacLocToCurv.
jacobian()*jacCurvToCurv.jacobian()*jacCurvToLoc.jacobian();
518 double c00 = covComb1(3,3);
521 for (
int i=1;
i<5; ++
i ) {
522 c10 += jacobian(3,
i)*covComb1(
i,3);
523 for (
int j=1; j<5; ++j ) c11 += jacobian(3,
i)*covComb1(
i,j)*jacobian(3,j);
526 double diff = c00 - 2*fabs(c10) + c11;
527 diff = diff>0 ?
sqrt(diff) : -
sqrt(-diff);
532 double c00Y = covComb1(4,4);
535 for (
int i=1;
i<5; ++
i ) {
536 c10Y += jacobian(4,
i)*covComb1(
i,4);
537 for (
int j=1; j<5; ++j ) c11Y += jacobian(4,
i)*covComb1(
i,j)*jacobian(4,j);
539 double diffY = c00Y - 2*fabs(c10Y) + c11Y;
540 diffY = diffY>0 ?
sqrt(diffY) : -
sqrt(-diffY);
545 overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
546 overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
549 moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
550 moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
551 moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
552 moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
553 moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
554 moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
555 subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
556 localxdotglobalphi_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
onezero).phi() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
557 localxdotglobalphi_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
onezero).phi() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
559 localxdotglobalr_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
onezero).perp() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
560 localxdotglobalr_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
onezero).perp() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
561 localxdotglobalz_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
onezero).z() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
562 localxdotglobalz_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
onezero).z() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
563 localxdotglobalx_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
onezero).x() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
564 localxdotglobalx_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
onezero).x() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
565 localxdotglobaly_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
onezero).y() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
566 localxdotglobaly_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
onezero).y() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
567 localydotglobalr_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
zeroone).perp() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
568 localydotglobalr_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
zeroone).perp() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
569 localydotglobalz_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
zeroone).z() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
570 localydotglobalz_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
zeroone).z() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
571 localydotglobalx_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
zeroone).x() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
572 localydotglobalx_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
zeroone).x() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
573 localydotglobaly_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
zeroone).y() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
574 localydotglobaly_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
zeroone).y() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
575 localydotglobalphi_[0] = overlapHit.first->recHit()->det()->surface().toGlobal(
zeroone).phi() - overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
576 localydotglobalphi_[1] = overlapHit.second->recHit()->det()->surface().toGlobal(
zeroone).phi() - overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
591 edm::LogWarning(
"Overlaps") <<
"BAD GLUED: First Id = " <<
overlapIds_[0] <<
" has glued = " <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued() <<
" and stereo = " <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
593 edm::LogWarning(
"Overlaps") <<
"BAD GLUED: Second Id = " <<
overlapIds_[1] <<
" has glued = " <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued() <<
" and stereo = " <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
604 hitPositionsY_[1] = secondRecHit->localPosition().y();
609 DetId id1 = overlapHit.first->recHit()->geographicalId();
610 DetId id2 = overlapHit.second->recHit()->geographicalId();
612 int subDet1 = id1.subdetId();
615 if (
abs(hitPositions_[0])>5)
edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " << id1.rawId() <<
" stereo = " <<
SiStripDetId(id1).
stereo() <<
" glued = " <<
SiStripDetId(id1).
glued() <<
" from subdet = " << subDet1 <<
" and layer = " << layer1 << endl;
634 uint16_t firstStrip = cluster1->firstStrip();
635 uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).
size() -1;
636 unsigned short Nstrips;
639 if (firstStrip == 0 || lastStrip == (Nstrips-1) ) atEdge =
true;
643 const std::vector<uint8_t>& stripCharges = cluster1->amplitudes();
645 for (
uint i = 0;
i < stripCharges.size();
i++) {
646 charge += stripCharges.at(
i);
659 uint16_t firstStrip = cluster2->firstStrip();
660 uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).
size() -1;
661 unsigned short Nstrips;
664 if (firstStrip == 0 || lastStrip == (Nstrips-1) ) atEdge =
true;
668 const std::vector<uint8_t>& stripCharges = cluster2->amplitudes();
670 for (
uint i = 0;
i < stripCharges.size();
i++) {
671 charge += stripCharges.at(
i);
699 int minPixelRow = cluster1->minPixelRow();
700 int maxPixelRow = cluster1->maxPixelRow();
701 int minPixelCol = cluster1->minPixelCol();
702 int maxPixelCol = cluster1->maxPixelCol();
708 if (edgeHitX||edgeHitY)
edge_[0] = 1;
else edge_[0] = -1;
732 int minPixelRow = cluster2->minPixelRow();
733 int maxPixelRow = cluster2->maxPixelRow();
734 int minPixelCol = cluster2->minPixelCol();
735 int maxPixelCol = cluster2->maxPixelCol();
741 if (edgeHitX||edgeHitY)
edge_[1] = 1;
else edge_[1] = -1;
758 std::vector<PSimHit> psimHits1;
759 std::vector<PSimHit> psimHits2;
761 DetId id = overlapHit.first->recHit()->geographicalId();
764 int subDet =
id.subdetId();
765 edm::LogVerbatim(
"OverlapValidation") <<
"Subdet = " << subDet <<
" ; layer = " << layer;
767 psimHits1 = associator.
associateHit( *(firstRecHit->hit()) );
769 edm::LogVerbatim(
"OverlapValidation") <<
"length of psimHits1: " << psimHits1.size();
770 if ( !psimHits1.empty() ) {
771 float closest_dist = 99999.9;
772 std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
773 for (std::vector<PSimHit>::const_iterator
m = psimHits1.begin();
m < psimHits1.end();
m++) {
775 float simX = (*m).localPosition().x();
776 float dist = fabs( simX - (overlapHit.first->recHit()->localPosition().x()) );
777 edm::LogVerbatim(
"OverlapValidation") <<
"simHit1 simX = " << simX <<
" hitX = " << overlapHit.first->recHit()->localPosition().x() <<
" distX = " << dist <<
" layer = " << layer;
778 if (dist<closest_dist) {
788 const GluedGeomDet* gluedDet = (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
792 LocalVector localdirection = (*closest_simhit).localDirection();
795 float scale = -lp.
z() / direction.
z();
796 LocalPoint projectedPos = lp + scale*direction;
805 edm::LogVerbatim(
"OverlapValidation") <<
"hit position = " << hitPositions_[0];
813 psimHits2 = associator.
associateHit( *(secondRecHit->hit()) );
814 if ( !psimHits2.empty() ) {
815 float closest_dist = 99999.9;
816 std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
817 for (std::vector<PSimHit>::const_iterator
m = psimHits2.begin();
m < psimHits2.end();
m++) {
818 float simX = (*m).localPosition().x();
819 float dist = fabs( simX - (overlapHit.second->recHit()->localPosition().x()) );
820 if (dist<closest_dist) {
828 const GluedGeomDet* gluedDet = (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
832 LocalVector localdirection = (*closest_simhit).localDirection();
835 float scale = -lp.
z() / direction.
z();
836 LocalPoint projectedPos = lp + scale*direction;
857 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
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
float localxdotglobalphi_[2]
GlobalPoint globalPosition() const
virtual bool isItEdgePixelInY(int iybin) const =0
float localydotglobaly_[2]
float localxdotglobalx_[2]
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
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)
float ChiSquaredProbability(double chiSquared, double nrDOF)
const AlgebraicSymMatrix55 & matrix() const
const TrackerGeometry * trackerGeometry_
float predictedLocalErrors_[5][2]
const LocalTrajectoryError & localError() const
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]
ROOT::Math::SVector< double, 5 > AlgebraicVector5
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.
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]
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
T const * product() const