99 void endJob()
override;
101 virtual void analyzeTrajectory(
const Trajectory&,
121 int overlapCounts_[3];
132 unsigned short hitCounts_[2];
134 unsigned int overlapIds_[2];
135 float predictedPositions_[3][2];
136 float predictedLocalParameters_[5][2];
137 float predictedLocalErrors_[5][2];
142 float hitPositions_[2];
144 float hitPositionsY_[2];
145 float hitErrorsY_[2];
146 float simHitPositions_[2];
147 float simHitPositionsY_[2];
148 float clusterWidthX_[2];
149 float clusterWidthY_[2];
150 float clusterSize_[2];
168 float localxdotglobalphi_[2];
169 float localxdotglobalr_[2];
170 float localxdotglobalz_[2];
171 float localxdotglobalx_[2];
172 float localxdotglobaly_[2];
173 float localydotglobalphi_[2];
174 float localydotglobalr_[2];
175 float localydotglobalz_[2];
176 float localydotglobalx_[2];
177 float localydotglobaly_[2];
199 compressionSettings_(iConfig.getUntrackedParameter<int>(
"compressionSettings", -1)),
200 addExtraBranches_(
false),
202 chi2ProbCut_(0.001) {
211 overlapCounts_[1] = 0;
212 overlapCounts_[2] = 0;
230 rootTree_ = fs->make<TTree>(
"Overlaps",
"Overlaps");
284 w <<
" Number of valid hits: " << overlapCounts_[1];
285 w <<
" Number of overlaps: " << overlapCounts_[2];
315 associator =
nullptr;
331 for (
const auto& trajectory : *trajectoryCollection)
342 typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*> Overlap;
343 typedef vector<Overlap> OverlapContainer;
346 OverlapContainer overlapHits;
359 vector<TrajectoryMeasurement> measurements(trajectory.
measurements());
360 for (vector<TrajectoryMeasurement>::const_iterator itm = measurements.begin(); itm != measurements.end(); ++itm) {
365 DetId id = hit->geographicalId();
367 int subDet =
id.subdetId();
369 if (!hit->isValid()) {
385 for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm - 1;
386 itmCompare >= measurements.begin() && itmCompare > itm - 4;
388 DetId compareId = itmCompare->recHit()->geographicalId();
392 if (!itmCompare->recHit()->isValid())
396 overlapHits.push_back(std::make_pair(&(*itmCompare), &(*itm)));
403 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " <<
id.rawId()
407 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " << compareId.
rawId()
424 for (
const auto& overlapHit : overlapHits) {
469 for (
int i = 0;
i < 5; ++
i) {
481 for (
int i = 0;
i < 5; ++
i) {
502 double c00 = covComb1(3, 3);
505 for (
int i = 1;
i < 5; ++
i) {
506 c10 += jacobian(3,
i) * covComb1(
i, 3);
507 for (
int j = 1;
j < 5; ++
j)
508 c11 += jacobian(3,
i) * covComb1(
i,
j) * jacobian(3,
j);
511 double diff = c00 - 2 * fabs(c10) + c11;
512 diff = diff > 0 ?
sqrt(diff) : -
sqrt(-diff);
517 double c00Y = covComb1(4, 4);
520 for (
int i = 1;
i < 5; ++
i) {
521 c10Y += jacobian(4,
i) * covComb1(
i, 4);
522 for (
int j = 1;
j < 5; ++
j)
523 c11Y += jacobian(4,
i) * covComb1(
i,
j) * jacobian(4,
j);
525 double diffY = c00Y - 2 * fabs(c10Y) + c11Y;
526 diffY = diffY > 0 ?
sqrt(diffY) : -
sqrt(-diffY);
531 overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
532 overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
535 moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
536 moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
537 moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
538 moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
539 moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
540 moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
541 subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
543 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
545 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
548 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
550 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
552 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
554 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
556 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
558 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
560 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
562 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
564 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
566 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
568 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
570 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
572 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
574 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
576 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
578 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
580 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
582 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
585 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo);
587 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 4;
589 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 10;
591 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 13;
593 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 20;
595 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 30;
601 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued()
603 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
606 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued()
608 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
619 hitPositionsY_[1] = secondRecHit->localPosition().y();
624 DetId id1 = overlapHit.first->recHit()->geographicalId();
625 DetId id2 = overlapHit.second->recHit()->geographicalId();
627 int subDet1 = id1.subdetId();
630 if (
abs(hitPositions_[0]) > 5)
631 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " << id1.rawId()
634 <<
" and layer = " << layer1 << endl;
635 if (
abs(hitPositions_[1]) > 5)
639 <<
" and layer = " << layer2 << endl;
656 uint16_t firstStrip = cluster1->firstStrip();
657 uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).
size() - 1;
658 unsigned short Nstrips;
661 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
669 const auto& stripCharges = cluster1->amplitudes();
671 for (
uint i = 0;
i < stripCharges.size();
i++) {
672 charge += stripCharges[
i];
685 uint16_t firstStrip = cluster2->firstStrip();
686 uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).
size() - 1;
687 unsigned short Nstrips;
690 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
698 const auto& stripCharges = cluster2->amplitudes();
700 for (
uint i = 0;
i < stripCharges.size();
i++) {
701 charge += stripCharges[
i];
724 int minPixelRow = cluster1->minPixelRow();
725 int maxPixelRow = cluster1->maxPixelRow();
726 int minPixelCol = cluster1->minPixelCol();
727 int maxPixelCol = cluster1->maxPixelCol();
731 if (edgeHitX || edgeHitY)
756 int minPixelRow = cluster2->minPixelRow();
757 int maxPixelRow = cluster2->maxPixelRow();
758 int minPixelCol = cluster2->minPixelCol();
759 int maxPixelCol = cluster2->maxPixelCol();
763 if (edgeHitX || edgeHitY)
780 std::vector<PSimHit> psimHits1;
781 std::vector<PSimHit> psimHits2;
783 DetId id = overlapHit.first->recHit()->geographicalId();
786 int subDet =
id.subdetId();
789 psimHits1 = associator.
associateHit(*(firstRecHit->hit()));
791 edm::LogVerbatim(
"OverlapValidation") <<
"length of psimHits1: " << psimHits1.size();
792 if (!psimHits1.empty()) {
793 float closest_dist = 99999.9;
794 std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
795 for (std::vector<PSimHit>::const_iterator
m = psimHits1.begin();
m < psimHits1.end();
m++) {
797 float simX = (*m).localPosition().x();
798 float dist = fabs(simX - (overlapHit.first->recHit()->localPosition().x()));
800 <<
"simHit1 simX = " << simX <<
" hitX = " << overlapHit.first->recHit()->localPosition().x()
801 <<
" distX = " << dist <<
" layer = " <<
layer;
802 if (dist < closest_dist) {
813 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
817 LocalVector localdirection = (*closest_simhit).localDirection();
820 float scale = -lp.
z() / direction.
z();
821 LocalPoint projectedPos = lp + scale * direction;
830 edm::LogVerbatim(
"OverlapValidation") <<
"hit position = " << hitPositions_[0];
837 psimHits2 = associator.
associateHit(*(secondRecHit->hit()));
838 if (!psimHits2.empty()) {
839 float closest_dist = 99999.9;
840 std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
841 for (std::vector<PSimHit>::const_iterator
m = psimHits2.begin();
m < psimHits2.end();
m++) {
842 float simX = (*m).localPosition().x();
843 float dist = fabs(simX - (overlapHit.second->recHit()->localPosition().x()));
844 if (dist < closest_dist) {
853 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
857 LocalVector localdirection = (*closest_simhit).localDirection();
860 float scale = -lp.
z() / direction.
z();
861 LocalPoint projectedPos = lp + scale * direction;
880 int layer = subdetandlayer.second;
ClusterRef cluster() const
edm::InputTag trajectoryTag_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const Point2DBase< float, LocalTag > zerozero
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]
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float localxdotglobaly_[2]
float predictedPositions_[3][2]
#define DEFINE_FWK_MODULE(type)
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
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
constexpr std::array< uint8_t, layerIndexSize > layer
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
const MagneticField * magField_
bool getData(T &iHolder) const
DataContainer const & measurements() const
AlgebraicVector5 vector() const
virtual bool isItEdgePixelInX(int ixbin) const =0
float localydotglobalz_[2]
const SurfaceType & surface() const
virtual void analyzeTrajectory(const Trajectory &, const Propagator &, TrackerHitAssociator &, const TrackerTopology *const tTopo)
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) ...
Abs< T >::type abs(const T &t)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
float ChiSquaredProbability(double chiSquared, double nrDOF)
const AlgebraicSymMatrix55 & matrix() const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
const TrackerGeometry * trackerGeometry_
SiStripDetInfo read(std::string filePath)
float predictedLocalErrors_[5][2]
const LocalTrajectoryError & localError() const
static constexpr auto TOB
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
float simHitPositions_[2]
float localxdotglobalz_[2]
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Log< level::Info, false > LogInfo
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
const GlobalTrajectoryParameters & globalParameters() const
edm::FileInPath FileInPath_
ClusterRef cluster() const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
T getParameter(std::string const &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const int compressionSettings_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
edm::ParameterSet config_
virtual bool isItEdgePixelInY(int iybin) const =0
GlobalVector globalMomentum() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
static int position[264][3]
const AlgebraicMatrix55 & jacobian() const
std::string fullPath() const
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
static constexpr char const *const kDefaultFile
float localydotglobalphi_[2]
Log< level::Warning, false > LogWarning
static constexpr auto TID
tuple size
Write out results.
tuple AnalyticalPropagator