94 void endJob()
override;
96 virtual void analyzeTrajectory(
const Trajectory&,
116 int overlapCounts_[3];
127 unsigned short hitCounts_[2];
129 unsigned int overlapIds_[2];
130 float predictedPositions_[3][2];
131 float predictedLocalParameters_[5][2];
132 float predictedLocalErrors_[5][2];
137 float hitPositions_[2];
139 float hitPositionsY_[2];
140 float hitErrorsY_[2];
141 float simHitPositions_[2];
142 float simHitPositionsY_[2];
143 float clusterWidthX_[2];
144 float clusterWidthY_[2];
145 float clusterSize_[2];
163 float localxdotglobalphi_[2];
164 float localxdotglobalr_[2];
165 float localxdotglobalz_[2];
166 float localxdotglobalx_[2];
167 float localxdotglobaly_[2];
168 float localydotglobalphi_[2];
169 float localydotglobalr_[2];
170 float localydotglobalz_[2];
171 float localydotglobalx_[2];
172 float localydotglobaly_[2];
194 compressionSettings_(iConfig.getUntrackedParameter<
int>(
"compressionSettings", -1)),
195 addExtraBranches_(
false),
197 chi2ProbCut_(0.001) {
226 rootTree_ =
fs->make<TTree>(
"Overlaps",
"Overlaps");
276 desc.setComment(
"Overlap Validation analyzer plugin.");
279 desc.addUntracked<
int>(
"compressionSettings", -1);
281 desc.add<
bool>(
"barrelOnly",
false);
282 desc.add<
bool>(
"usePXB",
true);
283 desc.add<
bool>(
"usePXF",
true);
284 desc.add<
bool>(
"useTIB",
true);
285 desc.add<
bool>(
"useTOB",
true);
286 desc.add<
bool>(
"useTID",
true);
287 desc.add<
bool>(
"useTEC",
true);
344 for (
const auto& trajectory : *trajectoryCollection)
355 typedef std::pair<const TrajectoryMeasurement*, const TrajectoryMeasurement*>
Overlap;
356 typedef vector<Overlap> OverlapContainer;
359 OverlapContainer overlapHits;
372 vector<TrajectoryMeasurement> measurements(trajectory.
measurements());
373 for (vector<TrajectoryMeasurement>::const_iterator itm = measurements.begin(); itm != measurements.end(); ++itm) {
380 int subDet =
id.subdetId();
382 if (!
hit->isValid()) {
398 for (vector<TrajectoryMeasurement>::const_iterator itmCompare = itm - 1;
399 itmCompare >= measurements.begin() && itmCompare > itm - 4;
401 DetId compareId = itmCompare->recHit()->geographicalId();
405 if (!itmCompare->recHit()->isValid())
409 overlapHits.push_back(std::make_pair(&(*itmCompare), &(*itm)));
416 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " <<
id.rawId()
420 edm::LogInfo(
"Overlaps") <<
"BAD GLUED: Have glued layer with id = " << compareId.
rawId()
437 for (
const auto& overlapHit : overlapHits) {
463 std::pair<TrajectoryStateOnSurface, double> tsosWithS =
propagator.propagateWithPath(comb1, fwdPred2.
surface());
482 for (
int i = 0;
i < 5; ++
i) {
494 for (
int i = 0;
i < 5; ++
i) {
515 double c00 = covComb1(3, 3);
518 for (
int i = 1;
i < 5; ++
i) {
519 c10 += jacobian(3,
i) * covComb1(
i, 3);
520 for (
int j = 1;
j < 5; ++
j)
521 c11 += jacobian(3,
i) * covComb1(
i,
j) * jacobian(3,
j);
524 double diff = c00 - 2 * fabs(c10) + c11;
530 double c00Y = covComb1(4, 4);
533 for (
int i = 1;
i < 5; ++
i) {
534 c10Y += jacobian(4,
i) * covComb1(
i, 4);
535 for (
int j = 1;
j < 5; ++
j)
536 c11Y += jacobian(4,
i) * covComb1(
i,
j) * jacobian(4,
j);
538 double diffY = c00Y - 2 * fabs(c10Y) + c11Y;
539 diffY = diffY > 0 ?
sqrt(diffY) : -
sqrt(-diffY);
544 overlapIds_[0] = overlapHit.first->recHit()->geographicalId().rawId();
545 overlapIds_[1] = overlapHit.second->recHit()->geographicalId().rawId();
548 moduleX_[0] = overlapHit.first->recHit()->det()->surface().position().x();
549 moduleX_[1] = overlapHit.second->recHit()->det()->surface().position().x();
550 moduleY_[0] = overlapHit.first->recHit()->det()->surface().position().y();
551 moduleY_[1] = overlapHit.second->recHit()->det()->surface().position().y();
552 moduleZ_[0] = overlapHit.first->recHit()->det()->surface().position().z();
553 moduleZ_[1] = overlapHit.second->recHit()->det()->surface().position().z();
554 subdetID = overlapHit.first->recHit()->geographicalId().subdetId();
556 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
558 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
561 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
563 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
565 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
567 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
569 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
571 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
573 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
575 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
577 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).perp();
579 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).perp();
581 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).z();
583 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).z();
585 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).x();
587 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).x();
589 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).y();
591 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).y();
593 overlapHit.first->recHit()->det()->surface().toGlobal(
zerozero).phi();
595 overlapHit.second->recHit()->det()->surface().toGlobal(
zerozero).phi();
598 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo);
600 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 4;
602 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 10;
604 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 13;
606 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 20;
608 layer_ =
layerFromId(overlapHit.first->recHit()->geographicalId().rawId(), tTopo) + 30;
614 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).glued()
616 <<
SiStripDetId(overlapHit.first->recHit()->geographicalId()).stereo() << endl;
619 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).glued()
621 <<
SiStripDetId(overlapHit.second->recHit()->geographicalId()).stereo() << endl;
637 DetId id1 = overlapHit.first->recHit()->geographicalId();
638 DetId id2 = overlapHit.second->recHit()->geographicalId();
640 int subDet1 =
id1.subdetId();
642 int subDet2 =
id2.subdetId();
644 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id1.rawId()
647 <<
" and layer = " << layer1 << endl;
649 edm::LogInfo(
"Overlaps") <<
"BAD: Bad hit position: Id = " <<
id2.rawId()
652 <<
" and layer = " << layer2 << endl;
669 uint16_t firstStrip = cluster1->firstStrip();
670 uint16_t lastStrip = firstStrip + (cluster1->amplitudes()).
size() - 1;
671 unsigned short Nstrips;
674 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
682 const auto& stripCharges = cluster1->amplitudes();
684 for (
uint i = 0;
i < stripCharges.size();
i++) {
698 uint16_t firstStrip = cluster2->firstStrip();
699 uint16_t lastStrip = firstStrip + (cluster2->amplitudes()).
size() - 1;
700 unsigned short Nstrips;
703 if (firstStrip == 0 || lastStrip == (Nstrips - 1))
711 const auto& stripCharges = cluster2->amplitudes();
713 for (
uint i = 0;
i < stripCharges.size();
i++) {
737 int minPixelRow = cluster1->minPixelRow();
738 int maxPixelRow = cluster1->maxPixelRow();
739 int minPixelCol = cluster1->minPixelCol();
740 int maxPixelCol = cluster1->maxPixelCol();
744 if (edgeHitX || edgeHitY)
769 int minPixelRow = cluster2->minPixelRow();
770 int maxPixelRow = cluster2->maxPixelRow();
771 int minPixelCol = cluster2->minPixelCol();
772 int maxPixelCol = cluster2->maxPixelCol();
776 if (edgeHitX || edgeHitY)
793 std::vector<PSimHit> psimHits1;
794 std::vector<PSimHit> psimHits2;
796 DetId id = overlapHit.first->recHit()->geographicalId();
799 int subDet =
id.subdetId();
802 psimHits1 =
associator.associateHit(*(firstRecHit->hit()));
804 edm::LogVerbatim(
"OverlapValidation") <<
"length of psimHits1: " << psimHits1.size();
805 if (!psimHits1.empty()) {
806 float closest_dist = 99999.9;
807 std::vector<PSimHit>::const_iterator closest_simhit = psimHits1.begin();
808 for (std::vector<PSimHit>::const_iterator
m = psimHits1.begin();
m < psimHits1.end();
m++) {
810 float simX = (*m).localPosition().x();
811 float dist = fabs(simX - (overlapHit.first->recHit()->localPosition().x()));
813 <<
"simHit1 simX = " << simX <<
" hitX = " << overlapHit.first->recHit()->localPosition().x()
814 <<
" distX = " << dist <<
" layer = " <<
layer;
815 if (dist < closest_dist) {
826 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*firstRecHit).hit()->geographicalId());
830 LocalVector localdirection = (*closest_simhit).localDirection();
833 float scale = -lp.
z() / direction.
z();
850 psimHits2 =
associator.associateHit(*(secondRecHit->hit()));
851 if (!psimHits2.empty()) {
852 float closest_dist = 99999.9;
853 std::vector<PSimHit>::const_iterator closest_simhit = psimHits2.begin();
854 for (std::vector<PSimHit>::const_iterator
m = psimHits2.begin();
m < psimHits2.end();
m++) {
855 float simX = (*m).localPosition().x();
856 float dist = fabs(simX - (overlapHit.second->recHit()->localPosition().x()));
857 if (dist < closest_dist) {
866 (
const GluedGeomDet*)(*trackerGeometry_).idToDet((*secondRecHit).hit()->geographicalId());
870 LocalVector localdirection = (*closest_simhit).localDirection();
873 float scale = -lp.
z() / direction.
z();
893 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
std::string fullPath() const
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
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
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
float localydotglobalphi_[2]
Log< level::Warning, false > LogWarning
ClusterRef cluster() const
static constexpr auto TID
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const