From 9c31d3382cf34dcdac63768c24f4fb19731d946d Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 21 Sep 2020 11:57:31 +0200 Subject: [PATCH] Allow also pixel input from tracks. --- .../interface/StraightTrackAlignment.h | 4 +- .../plugins/PPSStraightTrackAligner.cc | 16 ++++- .../python/ppsStraightTrackAligner_cfi.py | 2 +- .../src/StraightTrackAlignment.cc | 70 ++++++++++++++++++- 4 files changed, 87 insertions(+), 5 deletions(-) diff --git a/Alignment/PPSTrackBased/interface/StraightTrackAlignment.h b/Alignment/PPSTrackBased/interface/StraightTrackAlignment.h index 64e16343e6cee..8c469259be394 100644 --- a/Alignment/PPSTrackBased/interface/StraightTrackAlignment.h +++ b/Alignment/PPSTrackBased/interface/StraightTrackAlignment.h @@ -20,6 +20,7 @@ #include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" #include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h" #include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h" #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h" @@ -54,7 +55,8 @@ class StraightTrackAlignment virtual void begin(const edm::EventSetup&); virtual void processEvent(const edm::EventID &eventId, const edm::DetSetVector &uvPatternsStrip, - const edm::DetSetVector &hitsDiamond, const edm::DetSetVector &hitsPixel); + const edm::DetSetVector &hitsDiamond, const edm::DetSetVector &hitsPixel, + const edm::DetSetVector &tracksPixel); /// performs analyses and fill results variable virtual void finish(); diff --git a/Alignment/PPSTrackBased/plugins/PPSStraightTrackAligner.cc b/Alignment/PPSTrackBased/plugins/PPSStraightTrackAligner.cc index e8fcea55baed7..aecd8714ffb4b 100644 --- a/Alignment/PPSTrackBased/plugins/PPSStraightTrackAligner.cc +++ b/Alignment/PPSTrackBased/plugins/PPSStraightTrackAligner.cc @@ -22,6 +22,7 @@ #include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" #include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h" #include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h" /** *\brief An EDAnalyzer that runs StraightTrackAlignment. @@ -38,10 +39,12 @@ class PPSStraightTrackAligner : public edm::EDAnalyzer edm::InputTag tagUVPatternsStrip; edm::InputTag tagDiamondHits; edm::InputTag tagPixelHits; + edm::InputTag tagPixelLocalTracks; edm::EDGetTokenT> tokenUVPatternsStrip; edm::EDGetTokenT> tokenDiamondHits; edm::EDGetTokenT> tokenPixelHits; + edm::EDGetTokenT> tokenPixelLocalTracks; bool worker_initialized; StraightTrackAlignment worker; @@ -68,10 +71,12 @@ PPSStraightTrackAligner::PPSStraightTrackAligner(const ParameterSet &ps) : tagUVPatternsStrip(ps.getParameter("tagUVPatternsStrip")), tagDiamondHits(ps.getParameter("tagDiamondHits")), tagPixelHits(ps.getParameter("tagPixelHits")), + tagPixelLocalTracks(ps.getParameter("tagPixelLocalTracks")), tokenUVPatternsStrip(consumes>(tagUVPatternsStrip)), tokenDiamondHits(consumes>(tagDiamondHits)), tokenPixelHits(consumes>(tagPixelHits)), + tokenPixelLocalTracks(consumes>(tagPixelLocalTracks)), worker_initialized(false), worker(ps) @@ -131,8 +136,17 @@ void PPSStraightTrackAligner::analyze(const edm::Event &event, const edm::EventS pPixelHits = &(*inputPixelHits); } + DetSetVector defaultPixelLocalTracks; + const DetSetVector *pPixelLocalTracks = &defaultPixelLocalTracks; + Handle> inputPixelLocalTracks; + if (!tagPixelLocalTracks.label().empty()) + { + event.getByToken(tokenPixelLocalTracks, inputPixelLocalTracks); + pPixelLocalTracks = &(*inputPixelLocalTracks); + } + // feed worker - worker.processEvent(event.id(), *pStripUVPatterns, *pDiamondHits, *pPixelHits); + worker.processEvent(event.id(), *pStripUVPatterns, *pDiamondHits, *pPixelHits, *pPixelLocalTracks); } //---------------------------------------------------------------------------------------------------- diff --git a/Alignment/PPSTrackBased/python/ppsStraightTrackAligner_cfi.py b/Alignment/PPSTrackBased/python/ppsStraightTrackAligner_cfi.py index 12e51b41c3552..6e6a259e01ff8 100644 --- a/Alignment/PPSTrackBased/python/ppsStraightTrackAligner_cfi.py +++ b/Alignment/PPSTrackBased/python/ppsStraightTrackAligner_cfi.py @@ -7,7 +7,7 @@ tagUVPatternsStrip = cms.InputTag("totemRPUVPatternFinder"), tagDiamondHits = cms.InputTag("ctppsFastLocalSimulation"), - tagPixelHits = cms.InputTag("ctppsFastLocalSimulation"), + tagPixelLocalTracks = cms.InputTag("ctppsFastLocalSimulation"), # list of RPs for which the alignment parameters shall be optimized rpIds = cms.vuint32(), diff --git a/Alignment/PPSTrackBased/src/StraightTrackAlignment.cc b/Alignment/PPSTrackBased/src/StraightTrackAlignment.cc index 169f53a6192f1..a4625054b818e 100644 --- a/Alignment/PPSTrackBased/src/StraightTrackAlignment.cc +++ b/Alignment/PPSTrackBased/src/StraightTrackAlignment.cc @@ -306,7 +306,8 @@ void StraightTrackAlignment::begin(const EventSetup &es) //---------------------------------------------------------------------------------------------------- void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const DetSetVector &uvPatternsStrip, - const DetSetVector &hitsDiamond, const DetSetVector &hitsPixel) + const DetSetVector &hitsDiamond, const edm::DetSetVector &hitsPixel, + const DetSetVector &tracksPixel) { eventsTotal++; @@ -395,7 +396,7 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det hitSelection.emplace_back(Hit(pv.detId(), 1, h.x(), h.xWidth() / sqrt(12.), z)); } - // pixels + // pixels: data from rec hits map pixelPlaneMultiplicity; for (const auto &pv : hitsPixel) pixelPlaneMultiplicity[pv.detId()] += pv.size(); @@ -428,6 +429,8 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det double x_unc = sqrt(h.error().xx()); double y_unc = sqrt(h.error().yy()); + // TODO: Check this + if (x_unc <= 0.) x_unc = 10E-3; // mm if (y_unc <= 0.) @@ -438,6 +441,69 @@ void StraightTrackAlignment::processEvent(const edm::EventID &eventId, const Det } } + // pixels: data from tracks + for (const auto &pv : tracksPixel) + { + const CTPPSDetId rpId(pv.detId()); + const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + // skip if RP not selected + if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end()) + continue; + + // skip if more than 1 (valid) track in the RP + unsigned int n_valid_tracks = 0; + for (const auto &tr : pv) + { + if (tr.isValid()) + n_valid_tracks++; + } + + if (n_valid_tracks > 1) + continue; + + // go through all valid tracks + for (const auto &tr : pv) + { + if (!tr.isValid()) + continue; + + // go through all associated rec hits + for (const auto &hv : tr.hits()) + { + const CTPPSPixelDetId senId(hv.detId()); + const unsigned int senDecId = senId.arm()*1000 + senId.station()*100 + senId.rp()*10 + senId.plane(); + + // skip if sensor not in geometry + if (! task.geometry.isValidSensorId(senId)) + continue; + + for (const auto &h : hv) + { + // skip hit if not used for fit + if (!h.isUsedForFit()) + continue; + + const auto &dg = task.geometry.get(senId); + const double dz1 = dg.getDirectionData(1).dz; + const double dz2 = dg.getDirectionData(2).dz; + const double z = dg.z + h.point().x() * dz1 + h.point().y() * dz2; + + double x_unc = sqrt(h.error().xx()); + double y_unc = sqrt(h.error().yy()); + + if (x_unc <= 0.) + x_unc = 10E-3; // mm + if (y_unc <= 0.) + y_unc = 10E-3; // mm + + hitSelection.emplace_back(Hit(senId, 1, h.point().x(), x_unc, z)); + hitSelection.emplace_back(Hit(senId, 2, h.point().y(), y_unc, z)); + } + } + } + } + if (hitSelection.empty()) return;