93 void endJob()
override;
95 virtual void analyzeTrajectory(
const Trajectory&,
115 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];
193 compressionSettings_(iConfig.getUntrackedParameter<
int>(
"compressionSettings", -1)),
194 addExtraBranches_(
false),
196 chi2ProbCut_(0.001) {
225 rootTree_ =
fs->make<TTree>(
"Overlaps",
"Overlaps");
275 desc.setComment(
"Overlap Validation analyzer plugin.");
278 desc.addUntracked<
int>(
"compressionSettings", -1);
280 desc.add<
bool>(
"barrelOnly",
false);
281 desc.add<
bool>(
"usePXB",
true);
282 desc.add<
bool>(
"usePXF",
true);
283 desc.add<
bool>(
"useTIB",
true);
284 desc.add<
bool>(
"useTOB",
true);
285 desc.add<
bool>(
"useTID",
true);
286 desc.add<
bool>(
"useTEC",
true);
343 for (
const auto& trajectory : *trajectoryCollection)
354 typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*>
Overlap;
355 typedef vector<Overlap> OverlapContainer;
358 OverlapContainer overlapHits;
371 vector<TrajectoryMeasurement> measurements(trajectory.
measurements());
372 for (vector<TrajectoryMeasurement>::const_iterator itm = measurements.begin(); itm != measurements.end(); ++itm) {
379 int subDet =
id.subdetId();
381 if (!
hit->isValid()) {
397 for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm - 1;
398 itmCompare >= measurements.begin() && itmCompare > itm - 4;
400 DetId compareId = itmCompare->recHit()->geographicalId();
404 if (!itmCompare->recHit()->isValid())
408 overlapHits.push_back(std::make_pair(&(*itmCompare), &(*itm)));
415 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " <<
id.rawId()
419 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " << compareId.
rawId()
436 for (
const auto& overlapHit : overlapHits) {
462 std::pair<TrajectoryStateOnSurface, double> tsosWithS =
propagator.propagateWithPath(comb1, fwdPred2.
surface());
481 for (
int i = 0;
i < 5; ++
i) {
493 for (
int i = 0;
i < 5; ++
i) {
514 double c00 = covComb1(3, 3);
517 for (
int i = 1;
i < 5; ++
i) {
518 c10 += jacobian(3,
i) * covComb1(
i, 3);
519 for (
int j = 1;
j < 5; ++
j)
520 c11 += jacobian(3,
i) * covComb1(
i,
j) * jacobian(3,
j);
523 double diff = c00 - 2 * fabs(c10) + c11;
529 double c00Y = covComb1(4, 4);
532 for (
int i = 1;
i < 5; ++
i) {
533 c10Y += jacobian(4,
i) * covComb1(
i, 4);
534 for (
int j = 1;
j < 5; ++
j)
535 c11Y += jacobian(4,
i) * covComb1(
i,
j) * jacobian(4,
j);
537 double diffY = c00Y - 2 * fabs(c10Y) + c11Y;
538 diffY = diffY > 0 ?
sqrt(diffY) : -
sqrt(-diffY);
543 overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
544 overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
547 moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
548 moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
549 moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
550 moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
551 moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
552 moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
553 subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
555 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
557 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
560 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
562 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
564 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
566 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
568 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
570 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
572 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
574 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
576 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
578 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
580 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
582 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
584 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
586 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
588 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
590 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
592 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
594 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
597 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo);
599 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 4;
601 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 10;
603 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 13;
605 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 20;
607 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 30;
613 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued()
615 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
618 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued()
620 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
636 DetId id1 = overlapHit.first->recHit()->geographicalId();
637 DetId id2 = overlapHit.second->recHit()->geographicalId();
639 int subDet1 =
id1.subdetId();
641 int subDet2 =
id2.subdetId();
643 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id1.rawId()
646 <<
" and layer = " << layer1 << endl;
648 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id2.rawId()
651 <<
" and layer = " << layer2 << endl;
668 uint16_t firstStrip = cluster1->firstStrip();
669 uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).
size() - 1;
670 unsigned short Nstrips;
673 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
681 const auto& stripCharges = cluster1->amplitudes();
683 for (
uint i = 0;
i < stripCharges.size();
i++) {
697 uint16_t firstStrip = cluster2->firstStrip();
698 uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).
size() - 1;
699 unsigned short Nstrips;
702 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
710 const auto& stripCharges = cluster2->amplitudes();
712 for (
uint i = 0;
i < stripCharges.size();
i++) {
736 int minPixelRow = cluster1->minPixelRow();
737 int maxPixelRow = cluster1->maxPixelRow();
738 int minPixelCol = cluster1->minPixelCol();
739 int maxPixelCol = cluster1->maxPixelCol();
743 if (edgeHitX || edgeHitY)
768 int minPixelRow = cluster2->minPixelRow();
769 int maxPixelRow = cluster2->maxPixelRow();
770 int minPixelCol = cluster2->minPixelCol();
771 int maxPixelCol = cluster2->maxPixelCol();
775 if (edgeHitX || edgeHitY)
792 std::vector<PSimHit> psimHits1;
793 std::vector<PSimHit> psimHits2;
795 DetId id = overlapHit.first->recHit()->geographicalId();
798 int subDet =
id.subdetId();
801 psimHits1 =
associator.associateHit(*(firstRecHit->hit()));
803 edm::LogVerbatim(
"OverlapValidation") <<
"length of psimHits1: " << psimHits1.size();
804 if (!psimHits1.empty()) {
805 float closest_dist = 99999.9;
806 std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
807 for (std::vector<PSimHit>::const_iterator
m = psimHits1.begin();
m < psimHits1.end();
m++) {
809 float simX = (*m).localPosition().x();
810 float dist = fabs(simX - (overlapHit.first->recHit()->localPosition().x()));
812 <<
"simHit1 simX = " << simX <<
" hitX = " << overlapHit.first->recHit()->localPosition().x()
813 <<
" distX = " << dist <<
" layer = " <<
layer;
814 if (dist < closest_dist) {
825 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
829 LocalVector localdirection = (*closest_simhit).localDirection();
832 float scale = -lp.
z() / direction.
z();
849 psimHits2 =
associator.associateHit(*(secondRecHit->hit()));
850 if (!psimHits2.empty()) {
851 float closest_dist = 99999.9;
852 std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
853 for (std::vector<PSimHit>::const_iterator
m = psimHits2.begin();
m < psimHits2.end();
m++) {
854 float simX = (*m).localPosition().x();
855 float dist = fabs(simX - (overlapHit.second->recHit()->localPosition().x()));
856 if (dist < closest_dist) {
865 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
869 LocalVector localdirection = (*closest_simhit).localDirection();
872 float scale = -lp.
z() / direction.
z();
892 int layer = subdetandlayer.second;
ClusterRef cluster() const
edm::InputTag trajectoryTag_
static const std::string kSharedResource
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
const Point2DBase< float, LocalTag > zerozero
static constexpr auto TEC
int layerFromId(const DetId &, const TrackerTopology *const tTopo) const
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
TrajectoryStateCombiner combiner_
edm::EDGetTokenT< TrajectoryCollection > trajectoryToken_
T getParameter(std::string const &) const
unsigned int overlapIds_[2]
~OverlapValidation() override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static void fillPSetDescription(edm::ParameterSetDescription &descriptions)
const LocalTrajectoryError & localError() const
vector< bool > acceptLayer
float localydotglobalr_[2]
const bool addExtraBranches_
float localxdotglobalr_[2]
float localxdotglobaly_[2]
float predictedPositions_[3][2]
const Point2DBase< float, LocalTag > onezero
float predictedDeltaYError_
T const * product() const
float predictedDeltaXError_
const GlobalTrajectoryParameters & globalParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
float localxdotglobalphi_[2]
float localydotglobaly_[2]
float localxdotglobalx_[2]
const LocalTrajectoryParameters & localParameters() const
const SurfaceType & surface() const
float simHitPositionsY_[2]
LocalPoint toLocal(const GlobalPoint &gp) const
const Point2DBase< float, LocalTag > zeroone
unsigned short hitCounts_[2]
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
float localydotglobalx_[2]
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
DataContainer const & measurements() const
const MagneticField * magField_
virtual bool isItEdgePixelInX(int ixbin) const =0
float localydotglobalz_[2]
int ndof(bool bon=true) const
virtual void analyzeTrajectory(const Trajectory &, const Propagator &, TrackerHitAssociator &, const TrackerTopology *const tTopo)
GlobalPoint globalPosition() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
vector< Trajectory > TrajectoryCollection
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
AlgebraicVector5 vector() const
Abs< T >::type abs(const T &t)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
float ChiSquaredProbability(double chiSquared, double nrDOF)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const TrackerGeometry * trackerGeometry_
SiStripDetInfo read(std::string filePath)
float predictedLocalErrors_[5][2]
static constexpr auto TOB
float simHitPositions_[2]
float localxdotglobalz_[2]
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
const GeomDetUnit * monoDet() const
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Log< level::Info, false > LogInfo
Detector identifier class for the strip tracker.
OverlapValidation(const edm::ParameterSet &)
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const AlgebraicMatrix55 & jacobian() const
float predictedLocalParameters_[5][2]
static constexpr auto TIB
const Plane & surface() const
The nominal surface of the GeomDet.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
constexpr uint32_t rawId() const
get the raw id
edm::FileInPath FileInPath_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const int compressionSettings_
GlobalVector globalMomentum() const
edm::ParameterSet config_
virtual bool isItEdgePixelInY(int iybin) const =0
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
static int position[264][3]
const AlgebraicSymMatrix55 & matrix() const
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
static constexpr char const *const kDefaultFile
const std::string & fullPath() const
float localydotglobalphi_[2]
Log< level::Warning, false > LogWarning
ClusterRef cluster() const
static constexpr auto TID
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const