From 8b947f76d48c70f1a86000bb2a4ae597d400b4f0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 29 Mar 2021 17:29:49 +0200 Subject: [PATCH 1/6] add ALCARECOSiPixelCalSingleMuonTight and ALCARECOSiPixelCalSingleMuonLoose --- .../TkAlCaRecoProducers/plugins/BuildFile.xml | 18 + .../plugins/NearbyPixelClustersAnalyzer.cc | 517 ++++++++++++++++++ .../plugins/NearbyPixelClustersProducer.cc | 440 +++++++++++++++ ...ECOSiPixelCalSingleMuonLoose_Output_cff.py | 16 + .../ALCARECOSiPixelCalSingleMuonLoose_cff.py | 34 ++ ...ECOSiPixelCalSingleMuonTight_Output_cff.py | 16 + .../ALCARECOSiPixelCalSingleMuonTight_cff.py | 92 ++++ ...ALCARECOSiPixelCalSingleMuon_Output_cff.py | 5 +- .../ALCARECOSiPixelCalSingleMuon_cff.py | 16 +- .../python/NearbyPixelClustersProducer_cfi.py | 8 + .../test/inspectNearByPixelClusters_cfg.py | 95 ++++ Configuration/AlCa/python/autoAlca.py | 4 +- .../python/AlCaRecoOutput_RelVal_cff.py | 2 + .../EventContent/python/AlCaRecoOutput_cff.py | 2 + .../python/relval_steps.py | 16 +- .../python/AlCaRecoStreamsHeavyIons_cff.py | 24 +- .../python/AlCaRecoStreams_cff.py | 22 + 17 files changed, 1307 insertions(+), 20 deletions(-) create mode 100644 Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc create mode 100644 Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc create mode 100644 Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_Output_cff.py create mode 100644 Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_cff.py create mode 100644 Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py create mode 100644 Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py create mode 100644 Calibration/TkAlCaRecoProducers/python/NearbyPixelClustersProducer_cfi.py create mode 100644 Calibration/TkAlCaRecoProducers/test/inspectNearByPixelClusters_cfg.py diff --git a/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml b/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml index 90ac441775da4..7b881f869abf4 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml +++ b/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml @@ -35,3 +35,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc new file mode 100644 index 0000000000000..b2fb503a2d64c --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc @@ -0,0 +1,517 @@ +// -*- C++ -*- +// +// Package: Calibration/TkAlCaRecoProducers +// Class: NearbyPixelClustersAnalyzer +// +/**\class NearbyPixelClustersAnalyzer NearbyPixelClustersAnalyzer.cc Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc + + Description: Analysis of the closebyPixelClusters collections +*/ +// +// Original Author: Marco Musich +// Created: Tue, 30 Mar 2021 09:22:07 GMT +// +// + +// system include files +#include + +// user include files +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" +#include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h" +#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" +#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h" +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +#include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h" +#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" + +#include "TH2F.h" +// +// class declaration +// + +class NearbyPixelClustersAnalyzer : public edm::one::EDAnalyzer { +public: + explicit NearbyPixelClustersAnalyzer(const edm::ParameterSet&); + ~NearbyPixelClustersAnalyzer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void beginRun(edm::Run const&, edm::EventSetup const&) override; + void endRun(edm::Run const&, edm::EventSetup const&) override{}; + std::map bookModuleHistograms(const TrackerTopology* tTopo); + std::tuple setTopoInfo(uint32_t detId, const TrackerTopology* tTopo); + void endJob() override; + + void countClusters(const edm::Handle& handle, + //const TrackerGeometry* tkGeom_, + unsigned int& nClusGlobal); + + bool detidIsOnPixel(const DetId& detid); + TrajectoryStateOnSurface getTrajectoryStateOnSurface(const TrajectoryMeasurement& measurement); + std::pair findClosestCluster(const edm::Handle& handle, + const PixelClusterParameterEstimator* pixelCPE_, + const TrackerGeometry* trackerGeometry_, + uint32_t rawId, + float traj_lx, + float traj_ly); + + void fillClusterFrames(const edm::Handle& handle); + + // ----------member data --------------------------- + const edm::ESGetToken geomEsToken_; + const edm::ESGetToken pixelCPEEsToken_; + const edm::ESGetToken geomEsTokenBR_; + const edm::ESGetToken topoEsTokenBR_; + + edm::EDGetTokenT clustersToken_; + edm::EDGetTokenT nearByClustersToken_; + edm::EDGetTokenT trajTrackCollectionToken_; + + edm::Service fs; + + TH1I* h_nALCARECOClusters; + TH1I* h_nCloseByClusters; + TH1F* h_distClosestValid; + TH1F* h_distClosestMissing; + TH1F* h_distClosestInactive; + + SiPixelDetInfoFileReader reader_; + std::map outputFolders_; + std::map histoMap_; + bool phase_; +}; + +// +// constructors and destructor +// +NearbyPixelClustersAnalyzer::NearbyPixelClustersAnalyzer(const edm::ParameterSet& iConfig) + : geomEsToken_(esConsumes()), + pixelCPEEsToken_(esConsumes(edm::ESInputTag("", "PixelCPEGeneric"))), + geomEsTokenBR_(esConsumes()), + topoEsTokenBR_(esConsumes()), + clustersToken_(consumes(iConfig.getParameter("clusterCollection"))), + nearByClustersToken_( + consumes(iConfig.getParameter("nearByClusterCollection"))), + trajTrackCollectionToken_( + consumes(iConfig.getParameter("trajectoryInput"))), + reader_(edm::FileInPath(iConfig.getParameter("skimmedGeometryPath")).fullPath()) { + usesResource(TFileService::kSharedResource); +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + // get the Tracker geometry from event setup + const TrackerGeometry* trackerGeometry_ = &iSetup.getData(geomEsToken_); + + // get the Pixel CPE from event setup + const PixelClusterParameterEstimator* pixelCPE_ = &iSetup.getData(pixelCPEEsToken_); + + // Get cluster collection + edm::Handle clusterCollectionHandle; + iEvent.getByToken(clustersToken_, clusterCollectionHandle); + + unsigned int nClusGlobal = 0; + countClusters(clusterCollectionHandle, nClusGlobal); + + h_nALCARECOClusters->Fill(nClusGlobal); + edm::LogInfo("NearbyPixelClustersAnalyzer") << "total ALCARECO clusters: " << nClusGlobal << std::endl; + + // Get nearby cluster collection + edm::Handle nearByClusterCollectionHandle; + iEvent.getByToken(nearByClustersToken_, /*trackerGeometry_,*/ nearByClusterCollectionHandle); + + unsigned int nNearByClusGlobal = 0; + countClusters(nearByClusterCollectionHandle, /*trackerGeometry_,*/ nNearByClusGlobal); + + h_nCloseByClusters->Fill(nNearByClusGlobal); + edm::LogInfo("NearbyPixelClustersAnalyzer") << "total close-by clusters: " << nNearByClusGlobal << std::endl; + + // fill the detector frames + fillClusterFrames(nearByClusterCollectionHandle); + + // Get Traj-Track Collection + edm::Handle trajTrackCollectionHandle; + iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle); + + if (!trajTrackCollectionHandle.isValid()) + return; + + for (const auto& pair : *trajTrackCollectionHandle) { + const edm::Ref> traj = pair.key; + const reco::TrackRef track = pair.val; + + for (const TrajectoryMeasurement& measurement : traj->measurements()) { + if (!measurement.updatedState().isValid()) + return; + + const TransientTrackingRecHit::ConstRecHitPointer& recHit = measurement.recHit(); + + // Only looking for pixel hits + DetId r_rawId = recHit->geographicalId(); + + if (!this->detidIsOnPixel(r_rawId)) + continue; + + // Skipping hits with undeterminable positions + TrajectoryStateOnSurface trajStateOnSurface = this->getTrajectoryStateOnSurface(measurement); + + if (!(trajStateOnSurface.isValid())) + continue; + + // Position measurements + // Looking for valid and missing hits + LocalPoint localPosition = trajStateOnSurface.localPosition(); + + const auto& traj_lx = localPosition.x(); + const auto& traj_ly = localPosition.y(); + + const auto loc = this->findClosestCluster( + nearByClusterCollectionHandle, pixelCPE_, trackerGeometry_, r_rawId.rawId(), traj_lx, traj_ly); + + float dist = (loc.first != -999.) ? std::sqrt(loc.first * loc.first + loc.second * loc.second) : -0.1; + + if (recHit->getType() == TrackingRecHit::valid) { + edm::LogInfo("NearbyPixelClustersAnalyzer") + << "RawID:" << r_rawId.rawId() << " (valid hit), distance: " << dist << std::endl; + h_distClosestValid->Fill(dist); + } + + if (recHit->getType() == TrackingRecHit::missing) { + edm::LogInfo("NearbyPixelClustersAnalyzer") + << "RawID:" << r_rawId.rawId() << " (missing hit), distance: " << dist << std::endl; + h_distClosestMissing->Fill(dist); + } + + if (recHit->getType() == TrackingRecHit::inactive) { + edm::LogInfo("NearbyPixelClustersAnalyzer") + << "RawID:" << r_rawId.rawId() << " (inactive hit), distance: " << dist << std::endl; + h_distClosestInactive->Fill(dist); + } + } + } +} + +// ------------ method called once each job just before starting event loop ------------ +void NearbyPixelClustersAnalyzer::beginJob() { + TFileDirectory ClusterCounts = fs->mkdir("ClusterCounts"); + h_nALCARECOClusters = ClusterCounts.make( + "h_nALCARECOClusters", "Number of Pixel clusters per event (ALCARECO) ;N_{clusters};events", 20, 0, 20); + h_nCloseByClusters = ClusterCounts.make( + "h_nCloseByClusters", "Number of Pixel clusters per event (close-by) ;N_{clusters};events", 20, 0, 20); + + TFileDirectory Distances = fs->mkdir("TrajDistance"); + h_distClosestValid = Distances.make( + "h_distClosestValid", + "Distance of Closest cluster to trajectory (valid);distance (cm); valid trajectory measurements", + 110, + -0.105, + 0.995); + h_distClosestMissing = Distances.make( + "h_distClosestMissing", + "Distance of Closest cluster to trajectory (missing);distance (cm);missing trajectory measurements", + 110, + -0.105, + 0.995); + h_distClosestInactive = Distances.make( + "h_distClosestInactive", + "Distance of Closest cluster to trajectory (inactive);distance (cm);inactive trajectory measurements", + 110, + -0.105, + 0.995); +} + +// ------------ method called once each job just after ending the event loop ------------ +void NearbyPixelClustersAnalyzer::endJob() { + // please remove this method if not needed +} + +/*--------------------------------------------------------------------*/ +bool NearbyPixelClustersAnalyzer::detidIsOnPixel(const DetId& detid) +/*--------------------------------------------------------------------*/ +{ + if (detid.det() != DetId::Tracker) + return false; + if (detid.subdetId() == PixelSubdetector::PixelBarrel) + return true; + if (detid.subdetId() == PixelSubdetector::PixelEndcap) + return true; + return false; +} + +/*--------------------------------------------------------------------*/ +TrajectoryStateOnSurface NearbyPixelClustersAnalyzer::getTrajectoryStateOnSurface( + const TrajectoryMeasurement& measurement) +/*--------------------------------------------------------------------*/ +{ + static TrajectoryStateCombiner trajStateCombiner; + + const auto& forwardPredictedState = measurement.forwardPredictedState(); + const auto& backwardPredictedState = measurement.backwardPredictedState(); + + if (forwardPredictedState.isValid() && backwardPredictedState.isValid()) + return trajStateCombiner(forwardPredictedState, backwardPredictedState); + + else if (backwardPredictedState.isValid()) + return backwardPredictedState; + + else if (forwardPredictedState.isValid()) + return forwardPredictedState; + + edm::LogError("NearbyPixelClusterProducer") << "Error saving traj. measurement data." + << " Trajectory state on surface cannot be determined." << std::endl; + + return TrajectoryStateOnSurface(); +} + +/*--------------------------------------------------------------------*/ +void NearbyPixelClustersAnalyzer::countClusters(const edm::Handle& handle, + //const TrackerGeometry* tkGeom_, + unsigned int& nClusGlobal) +/*--------------------------------------------------------------------*/ +{ + for (const auto& DSVItr : *handle) { + uint32_t rawid(DSVItr.detId()); + DetId detId(rawid); + LogDebug("NearbyPixelClustersAnalyzer") << "DetId: " << detId.rawId() << " size: " << DSVItr.size() << std::endl; + nClusGlobal += DSVItr.size(); + } +} + +/*--------------------------------------------------------------------*/ +std::pair NearbyPixelClustersAnalyzer::findClosestCluster( + const edm::Handle& handle, + const PixelClusterParameterEstimator* pixelCPE_, + const TrackerGeometry* trackerGeometry_, + uint32_t rawId, + float traj_lx, + float traj_ly) +/*--------------------------------------------------------------------*/ +{ + const SiPixelClusterCollectionNew& clusterCollection = *handle; + SiPixelClusterCollectionNew::const_iterator itClusterSet = clusterCollection.begin(); + + float minD = 10000.; + + auto loc = std::make_pair(-999., -999.); + + for (; itClusterSet != clusterCollection.end(); itClusterSet++) { + DetId detId(itClusterSet->id()); + if (detId.rawId() != rawId) + continue; + + unsigned int subDetId = detId.subdetId(); + if (subDetId != PixelSubdetector::PixelBarrel && subDetId != PixelSubdetector::PixelEndcap) { + edm::LogError("NearByPixelClustersAnalyzer") + << "ERROR: not a pixel cluster!!!" << std::endl; // should not happen + continue; + } + + const PixelGeomDetUnit* pixdet = (const PixelGeomDetUnit*)trackerGeometry_->idToDetUnit(detId); + edmNew::DetSet::const_iterator itCluster = itClusterSet->begin(); + for (; itCluster != itClusterSet->end(); ++itCluster) { + LocalPoint lp(itCluster->x(), itCluster->y(), 0.); + PixelClusterParameterEstimator::ReturnType params = pixelCPE_->getParameters(*itCluster, *pixdet); + lp = std::get<0>(params); + + float D = sqrt((lp.x() - traj_lx) * (lp.x() - traj_lx) + (lp.y() - traj_ly) * (lp.y() - traj_ly)); + if (D < minD) { + minD = D; + loc.first = (lp.x() - traj_lx); + loc.second = (lp.y() - traj_ly); + } + } // loop on cluster sets + } + return loc; +} + +void NearbyPixelClustersAnalyzer::fillClusterFrames(const edm::Handle& handle) { + const SiPixelClusterCollectionNew& clusterCollection = *handle; + SiPixelClusterCollectionNew::const_iterator itClusterSet = clusterCollection.begin(); + + for (; itClusterSet != clusterCollection.end(); itClusterSet++) { + DetId detId(itClusterSet->id()); + + edmNew::DetSet::const_iterator itCluster = itClusterSet->begin(); + for (; itCluster != itClusterSet->end(); ++itCluster) { + const std::vector pixelsVec = (*itCluster).pixels(); + for (unsigned int i = 0; i < pixelsVec.size(); ++i) { + float pixx = pixelsVec[i].x; // index as float=iteger, row index + float pixy = pixelsVec[i].y; // same, col index + float pixel_charge = pixelsVec[i].adc; + histoMap_[detId.rawId()]->Fill(pixy, pixx, pixel_charge); + } + } + } +} + +// ------------ method called for each run ------------------------------------------ +void NearbyPixelClustersAnalyzer::beginRun(const edm::Run& iRun, edm::EventSetup const& iSetup) +/*-----------------------------------------------------------------------------------*/ +{ + edm::LogInfo("NearbyPixelClustersAnalyzer") + << "@SUB=NearbyPixelClustersAnalyzer::beginRun() before booking histoMap_.size(): " << histoMap_.size() + << std::endl; + + const TrackerTopology* tTopo_ = &iSetup.getData(topoEsTokenBR_); + const TrackerGeometry* pDD_ = &iSetup.getData(geomEsTokenBR_); + + if ((pDD_->isThere(GeomDetEnumerators::P1PXB)) || (pDD_->isThere(GeomDetEnumerators::P1PXEC))) { + phase_ = true; + } else { + phase_ = false; + } + + unsigned nPixelDets = 0; + for (const auto& it : pDD_->detUnits()) { + const PixelGeomDetUnit* mit = dynamic_cast(it); + if (mit != nullptr) { + nPixelDets++; + } + } + + const auto& detIds = reader_.getAllDetIds(); + if (detIds.size() != nPixelDets) { + throw cms::Exception("Inconsistent Data") + << "The size of the detId list specified from file (" << detIds.size() + << ") differs from the one in TrackerGeometry (" << nPixelDets << ")! Please cross-check" << std::endl; + } + + for (const auto& it : detIds) { + auto topolInfo = setTopoInfo(it, tTopo_); + + std::string thePart = std::get<0>(topolInfo); + + // book the TFileDirectory if it's not already done + if (!outputFolders_.count(thePart)) { + LogDebug("NearbyPixelClustersAnalyzer") << "booking " << thePart << std::endl; + outputFolders_[thePart] = fs->mkdir(thePart); + } + } + + if (histoMap_.empty()) { + histoMap_ = bookModuleHistograms(tTopo_); + } + + edm::LogInfo("NearbyPixelClusterAnalyzer") + << "@SUB=NearbyPixelClusterAnalyzer::beginRun() After booking histoMap_.size(): " << histoMap_.size() + << std::endl; +} + +// ------------ method called to determine the topology ------------ +std::tuple NearbyPixelClustersAnalyzer::setTopoInfo(uint32_t detId, + const TrackerTopology* tTopo) +/*-----------------------------------------------------------------------------------*/ +{ + int subdetId_(-999), layer_(-999), side_(-999); + std::string ret = ""; + + subdetId_ = DetId(detId).subdetId(); + switch (subdetId_) { + case PixelSubdetector::PixelBarrel: // PXB + layer_ = tTopo->pxbLayer(detId); + side_ = 0; + ret += Form("BPix_Layer%i", layer_); + break; + case PixelSubdetector::PixelEndcap: //PXF + side_ = tTopo->pxfSide(detId); + layer_ = tTopo->pxfDisk(detId); + ret += ("FPix_"); + ret += (side_ == 1) ? Form("P_disk%i", layer_) : Form("M_disk%i", layer_); + break; + default: + edm::LogError("NearbyPixelClusterAnalyzer") << "we should never be here!" << std::endl; + break; + } + + return std::make_tuple(ret, subdetId_, layer_, side_); +} + +/* ------------ method called once to book all the module level histograms ---------*/ +std::map NearbyPixelClustersAnalyzer::bookModuleHistograms(const TrackerTopology* tTopo_) +/*-----------------------------------------------------------------------------------*/ +{ + std::map hd; + + const auto& detIds = reader_.getAllDetIds(); + for (const auto& it : detIds) { + // check if det id is correct and if it is actually cabled in the detector + if (it == 0 || it == 0xFFFFFFFF) { + edm::LogError("DetIdNotGood") << "@SUB=analyze" + << "Wrong det id: " << it << " ... neglecting!" << std::endl; + continue; + } + + auto topolInfo = setTopoInfo(it, tTopo_); + std::string thePart = std::get<0>(topolInfo); + + unsigned int nCols = reader_.getDetUnitDimensions(it).first; + unsigned int nRows = reader_.getDetUnitDimensions(it).second; + + int subdetId = DetId(it).subdetId(); + + std::string moduleName = (subdetId == PixelSubdetector::PixelBarrel) ? PixelBarrelName(it, tTopo_, phase_).name() + : PixelEndcapName(it, tTopo_, phase_).name(); + + hd[it] = outputFolders_[thePart].make( + Form("ClusterFrame_%s", moduleName.c_str()), + Form("Cluster Map for module %s;n. cols;n. rows;pixel charge [ADC counts]", moduleName.c_str()), + nCols, + 0, + nCols, + nRows, + 0, + nRows); + } + + return hd; +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void NearbyPixelClustersAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Analysis of the closebyPixelClusters collections"); + desc.add("clusterCollection", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight")); + desc.add("nearByClusterCollection", edm::InputTag("closebyPixelClusters")); + desc.add("trajectoryInput", edm::InputTag("refittedTracks")); + desc.add("skimmedGeometryPath", + "SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt"); + descriptions.addWithDefaultLabel(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(NearbyPixelClustersAnalyzer); diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc new file mode 100644 index 0000000000000..153252dce6878 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc @@ -0,0 +1,440 @@ +// -*- C++ -*- +// +// Package: Calibration/TkAlCaRecoProducers +// Class: NearbyPixelClustersProducer +// +/**\class NearbyPixelClustersProducer NearbyPixelClustersProducer.cc Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc + + Description: Class to produce the collection of SiPixelClusters closest, hit by hit, to the trajectory measurements of a given track + + Implementation: + Implementation of this class is heavily endebted to https://github.com/jkarancs/PhaseIPixelNtuplizer/blob/master/plugins/PhaseIPixelNtuplizer.h + +*/ +// +// Original Author: Marco Musich +// Created: Mon, 29 Mar 2021 12:29:30 GMT +// +// + +// system include files +#include +#include + +// user include files +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" +#include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h" +#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" +#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h" +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +#include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h" +#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" + +using trajCrossings_t = std::map>; + +// +// class declaration +// + +class NearbyPixelClustersProducer : public edm::stream::EDProducer<> { +public: + explicit NearbyPixelClustersProducer(const edm::ParameterSet&); + ~NearbyPixelClustersProducer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + const trajCrossings_t findAllTrajectoriesCrossings( + const edm::Handle& trajTrackCollectionHandle); + + const std::vector::const_iterator> findAllNearbyClusters( + const SiPixelClusterCollectionNew::const_iterator& clusterSet, + const uint32_t rawId, + const std::vector& vLocalPos); + + const std::vector::const_iterator> findAllNearbyClusters( + const SiPixelClusterCollectionNew& clusterSet, const uint32_t rawId, const std::vector& vLocalPos); + + TrajectoryStateOnSurface getTrajectoryStateOnSurface(const TrajectoryMeasurement& measurement); + bool detidIsOnPixel(const DetId& detid); + + // ----------member data --------------------------- + + // switches + const bool throwBadComponents_; + const bool dumpWholeDetId_; + + // esTokens + const edm::ESGetToken geomEsToken_; + const edm::ESGetToken pixelCPEEsToken_; + const edm::ESGetToken badModuleToken_; + + // edToken + edm::EDGetTokenT clustersToken_; + edm::EDGetTokenT trajTrackCollectionToken_; + + // putToken + edm::EDPutTokenT clusterPutToken_; + + // event setup + const TrackerGeometry* trackerGeometry_; + const PixelClusterParameterEstimator* pixelCPE_; +}; + +// +// constructors and destructor +// +NearbyPixelClustersProducer::NearbyPixelClustersProducer(const edm::ParameterSet& iConfig) + : throwBadComponents_(iConfig.getParameter("throwBadComponents")), + dumpWholeDetId_(iConfig.getParameter("dumpWholeDetIds")), + geomEsToken_(esConsumes()), + pixelCPEEsToken_(esConsumes(edm::ESInputTag("", "PixelCPEGeneric"))), + badModuleToken_(esConsumes()), + clustersToken_(consumes(iConfig.getParameter("clusterCollection"))), + trajTrackCollectionToken_( + consumes(iConfig.getParameter("trajectoryInput"))), + clusterPutToken_(produces()) { + if (dumpWholeDetId_) { + edm::LogPrint("NearbyPixelClustersProducer") << "WARNING: selected to dump the whole DetId's worth of clusters.\n " + "This will have consequences on the event size!" + << std::endl; + } +} + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void NearbyPixelClustersProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + auto outputClusters = std::make_unique(); + + // get the Tracker geometry from event setup + trackerGeometry_ = &iSetup.getData(geomEsToken_); + + // get the Pixel CPE from event setup + pixelCPE_ = &iSetup.getData(pixelCPEEsToken_); + + const auto& SiPixelBadModule_ = &iSetup.getData(badModuleToken_); + + // get cluster collection + edm::Handle clusterCollectionHandle; + iEvent.getByToken(clustersToken_, clusterCollectionHandle); + const SiPixelClusterCollectionNew& clusterCollection = *clusterCollectionHandle; + + // get Traj-Track Collection + edm::Handle trajTrackCollectionHandle; + iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle); + if (!trajTrackCollectionHandle.isValid()) + return; + + // find all trajectory crossings in the event + const auto& allCrossings = this->findAllTrajectoriesCrossings(trajTrackCollectionHandle); + + LogDebug("NearbyPixelClustersProducer") << allCrossings.size() << std::endl; + + // now find all nearby clusters + for (const auto& [id, vLocalPos] : allCrossings) { + // prepare the filler + SiPixelClusterCollectionNew::FastFiller spc(*outputClusters, id); + + // retrieve the clusters of the right detId + const auto& clustersOnDet = clusterCollection.find(DetId(id)); + + if (clustersOnDet == clusterCollection.end()) + continue; + + // if the cluster DetSet is not valid, move on + if (!(*clustersOnDet).isValid()) + continue; + + // if the module is bad continue + if (throwBadComponents_ && SiPixelBadModule_->IsModuleBad(id)) + continue; + + // find all the clusters to put into the event + const auto& clustersToPut = this->findAllNearbyClusters(clustersOnDet, id, vLocalPos); + + // find all the clusters to put into the event (different interface) + //const auto& clustersToPut = this->findAllNearbyClusters(clusterCollection, id, vLocalPos); + + for (const auto& cluster : clustersToPut) { + spc.push_back(*cluster); + } + + if (spc.empty()) + spc.abort(); + + } // loop on trajectory crossings + + iEvent.put(clusterPutToken_, std::move(outputClusters)); +} + +/*--------------------------------------------------------------------*/ +const trajCrossings_t NearbyPixelClustersProducer::findAllTrajectoriesCrossings( + const edm::Handle& trajTrackCollectionHandle) +/*--------------------------------------------------------------------*/ +{ + trajCrossings_t crossings; + + std::vector treatedIds; + + for (const auto& pair : *trajTrackCollectionHandle) { + const edm::Ref> traj = pair.key; + + for (const TrajectoryMeasurement& measurement : traj->measurements()) { + //Check if the measurement infos can be read + if (!measurement.updatedState().isValid()) + continue; + + const TransientTrackingRecHit::ConstRecHitPointer& recHit = measurement.recHit(); + + // Only looking for pixel hits + DetId recHitDetid = recHit->geographicalId(); + const auto& rawId = recHitDetid.rawId(); + + if (!this->detidIsOnPixel(recHitDetid)) + continue; + + // Skipping hits with undeterminable positions + TrajectoryStateOnSurface trajStateOnSurface = this->getTrajectoryStateOnSurface(measurement); + + if (!(trajStateOnSurface.isValid())) + continue; + + // Position measurements + // Looking for valid and missing hits + LocalPoint localPosition = trajStateOnSurface.localPosition(); + + if (std::find(treatedIds.begin(), treatedIds.end(), rawId) != treatedIds.end()) { + crossings.at(rawId).push_back(localPosition); + } else { + crossings.insert(std::pair>(rawId, {localPosition})); + treatedIds.push_back(rawId); + } + } // loop on measurements in trajectory + } // loop on trajectories + + return crossings; +} + +/*--------------------------------------------------------------------*/ +const std::vector::const_iterator> NearbyPixelClustersProducer::findAllNearbyClusters( + const SiPixelClusterCollectionNew::const_iterator& clusterSet, + const uint32_t rawId, + const std::vector& vLocalPos) +/*--------------------------------------------------------------------*/ +{ + std::vector::const_iterator> outputClusters; + + static constexpr unsigned int k_maxClustersInDet = 1024; + + // something funny is going on here ... + if ((*clusterSet).size() > k_maxClustersInDet) { + edm::LogWarning("NearbyPixelClustersProducer") + << __func__ << "() number of clusters in det " << rawId /*(*clusterSet).id()*/ << " is " << (*clusterSet).size() + << ", which is larger than maximum (1024).\n Something funny with the data is going on!" << std::endl; + return outputClusters; + } + + const PixelGeomDetUnit* pixdet = (const PixelGeomDetUnit*)trackerGeometry_->idToDetUnit(rawId); + edmNew::DetSet::const_iterator itCluster = clusterSet->begin(); + + // just copy straight the whole set of clusters in the detid + if (dumpWholeDetId_) { + for (; itCluster != clusterSet->end(); ++itCluster) { + outputClusters.push_back(itCluster); + } + return outputClusters; + } + + int count = 0; + for (const auto& localPos : vLocalPos) { + count++; + //trajectory crossing local coordinates + const auto& traj_lx = localPos.x(); + const auto& traj_ly = localPos.y(); + + float minD = 10000.; + edmNew::DetSet::const_iterator closest = nullptr; + + //std::cout<< rawId << " count: " << count << " n. clusters: " << (*clusterSet).size() << std::endl; + LogDebug("NearbyPixelClustersProducer") + << __func__ << rawId << " count: " << count << " n. clusters: " << (*clusterSet).size() << std::endl; + + for (; itCluster != clusterSet->end(); ++itCluster) { + LocalPoint lp(itCluster->x(), itCluster->y(), 0.); + const auto& params = pixelCPE_->getParameters(*itCluster, *pixdet); + lp = std::get<0>(params); + + float D = sqrt((lp.x() - traj_lx) * (lp.x() - traj_lx) + (lp.y() - traj_ly) * (lp.y() - traj_ly)); + if (D < minD) { + closest = itCluster; + minD = D; + } + } // loop on cluster sets + + if (closest) { + outputClusters.push_back(closest); + } + } // loop on the trajectory crossings + + return outputClusters; +} + +// overloaded method: use the whole DetSet +/*--------------------------------------------------------------------*/ +const std::vector::const_iterator> NearbyPixelClustersProducer::findAllNearbyClusters( + const SiPixelClusterCollectionNew& clusterCollection, + const uint32_t rawId, + const std::vector& vLocalPos) +/*--------------------------------------------------------------------*/ +{ + std::vector::const_iterator> outputClusters; + + int count = 0; + for (const auto& localPos : vLocalPos) { + count++; + + //trajectory crossing local coordinates + const auto& traj_lx = localPos.x(); + const auto& traj_ly = localPos.y(); + + float minD = 10000.; + + SiPixelClusterCollectionNew::const_iterator itClusterSet = clusterCollection.begin(); + for (; itClusterSet != clusterCollection.end(); itClusterSet++) { + DetId detId(itClusterSet->id()); + if (detId.rawId() != rawId) + continue; + + unsigned int subDetId = detId.subdetId(); + if (subDetId != PixelSubdetector::PixelBarrel && subDetId != PixelSubdetector::PixelEndcap) { + edm::LogError("NearByPixelClusterProducer") + << "ERROR: not a pixel cluster!!!" << std::endl; // should not happen + continue; + } + + edmNew::DetSet::const_iterator itCluster = itClusterSet->begin(); + + // just copy straight the whole set of clusters in the detid + if (dumpWholeDetId_ && count == 1) { + for (; itCluster != itClusterSet->end(); ++itCluster) { + outputClusters.push_back(itCluster); + } + return outputClusters; + } + + //std::cout<< rawId << " count: " << count << " n. clusters: " << (*clusterSet).size() << std::endl; + LogDebug("NearbyPixelClustersProducer") + << __func__ << rawId << " count: " << count << " n. clusters: " << (*itClusterSet).size() << std::endl; + + const PixelGeomDetUnit* pixdet = (const PixelGeomDetUnit*)trackerGeometry_->idToDetUnit(rawId); + + edmNew::DetSet::const_iterator closest = nullptr; + + for (; itCluster != itClusterSet->end(); ++itCluster) { + LocalPoint lp(itCluster->x(), itCluster->y(), 0.); + const auto& params = pixelCPE_->getParameters(*itCluster, *pixdet); + lp = std::get<0>(params); + + float D = sqrt((lp.x() - traj_lx) * (lp.x() - traj_lx) + (lp.y() - traj_ly) * (lp.y() - traj_ly)); + if (D < minD) { + closest = itCluster; + minD = D; + } + } // loop on cluster sets + + if (closest) { + outputClusters.push_back(closest); + } + } // loop on all clusters + } // loop on the trajectory crossings + + return outputClusters; +} + +/*--------------------------------------------------------------------*/ +bool NearbyPixelClustersProducer::detidIsOnPixel(const DetId& detid) +/*--------------------------------------------------------------------*/ +{ + if (detid.det() != DetId::Tracker) + return false; + if (detid.subdetId() == PixelSubdetector::PixelBarrel) + return true; + if (detid.subdetId() == PixelSubdetector::PixelEndcap) + return true; + return false; +} + +/*--------------------------------------------------------------------*/ +TrajectoryStateOnSurface NearbyPixelClustersProducer::getTrajectoryStateOnSurface( + const TrajectoryMeasurement& measurement) +/*--------------------------------------------------------------------*/ +{ + static TrajectoryStateCombiner trajStateCombiner; + + const auto& forwardPredictedState = measurement.forwardPredictedState(); + const auto& backwardPredictedState = measurement.backwardPredictedState(); + + if (forwardPredictedState.isValid() && backwardPredictedState.isValid()) + return trajStateCombiner(forwardPredictedState, backwardPredictedState); + + else if (backwardPredictedState.isValid()) + return backwardPredictedState; + + else if (forwardPredictedState.isValid()) + return forwardPredictedState; + + edm::LogError("NearbyPixelClustersProducer") << "Error saving traj. measurement data." + << " Trajectory state on surface cannot be determined." << std::endl; + + return TrajectoryStateOnSurface(); +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void NearbyPixelClustersProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment( + "Produces the collection of SiPixelClusters closest, hit by hit, to the trajectory measurements of a given " + "track"); + desc.add("throwBadComponents", false) + ->setComment( + "do not consider modules flagged as bad components. Careful, it changes the efficiency denominator!"); + desc.add("dumpWholeDetIds", false) + ->setComment("put in the event all the pixel cluster on the impacted module, by default only the closest"); + ; + desc.add("clusterCollection", edm::InputTag("siPixelClusters")); + desc.add("trajectoryInput", edm::InputTag("myRefitter")); + descriptions.addWithDefaultLabel(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(NearbyPixelClustersProducer); diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_Output_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_Output_cff.py new file mode 100644 index 0000000000000..acc29836ec878 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_Output_cff.py @@ -0,0 +1,16 @@ +import FWCore.ParameterSet.Config as cms + +OutALCARECOSiPixelCalSingleMuonLoose_noDrop = cms.PSet( + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOSiPixelCalSingleMuonLoose') + ), + outputCommands = cms.untracked.vstring( + 'keep *_ALCARECOSiPixelCalSingleMuonLoose_*_*', + 'keep *_muons__*', + 'keep *_offlinePrimaryVertices_*_*', + 'keep *_*riggerResults_*_HLT' + ) +) + +OutALCARECOSiPixelCalSingleMuonLoose=OutALCARECOSiPixelCalSingleMuonLoose_noDrop.clone() +OutALCARECOSiPixelCalSingleMuonLoose.outputCommands.insert(0, "drop *") diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_cff.py new file mode 100644 index 0000000000000..26c8d8e54625a --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonLoose_cff.py @@ -0,0 +1,34 @@ +import FWCore.ParameterSet.Config as cms + +################################################################## +# AlCaReco for track based calibration using single muon events +################################################################## +from HLTrigger.HLTfilters.hltHighLevel_cfi import * +ALCARECOSiPixelCalSingleMuonLooseHLTFilter = hltHighLevel.clone() +ALCARECOSiPixelCalSingleMuonLooseHLTFilter.andOr = True ## choose logical OR between Triggerbits +ALCARECOSiPixelCalSingleMuonLooseHLTFilter.throw = False ## dont throw on unknown path names +ALCARECOSiPixelCalSingleMuonLooseHLTFilter.eventSetupPathsKey = 'SiPixelCalSingleMuon' + +################################################################## +# Basic track selection +################################################################## +import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi +ALCARECOSiPixelCalSingleMuonLoose = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone() +ALCARECOSiPixelCalSingleMuonLoose.filter = True ##do not store empty events +ALCARECOSiPixelCalSingleMuonLoose.applyBasicCuts = True +ALCARECOSiPixelCalSingleMuonLoose.ptMin = 3.0 #GeV +ALCARECOSiPixelCalSingleMuonLoose.etaMin = -3.5 +ALCARECOSiPixelCalSingleMuonLoose.etaMax = 3.5 + +################################################################## +# Prescale events +################################################################## +import CalibTracker.SiStripCommon.prescaleEvent_cfi +scalerForSiPixelCalSingleMuonLoose = CalibTracker.SiStripCommon.prescaleEvent_cfi.prescaleEvent.clone(prescale = 100) + +################################################################## +# Loose Sequence +################################################################## +seqALCARECOSiPixelCalSingleMuonLoose = cms.Sequence(ALCARECOSiPixelCalSingleMuonLooseHLTFilter+ + scalerForSiPixelCalSingleMuonLoose+ + ALCARECOSiPixelCalSingleMuonLoose) diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py new file mode 100644 index 0000000000000..9b54c5595b086 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py @@ -0,0 +1,16 @@ +import FWCore.ParameterSet.Config as cms + +OutALCARECOSiPixelCalSingleMuonTight_noDrop = cms.PSet( + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('pathALCARECOSiPixelCalSingleMuonTight') + ), + outputCommands = cms.untracked.vstring( + 'keep *_ALCARECOSiPixelCalSingleMuonTight_*_*', + 'keep *_muons__*', + 'keep *_offlinePrimaryVertices_*_*', + 'keep *_*riggerResults_*_HLT', + 'keep *_*closebyPixelClusters*_*_*' + ) +) +OutALCARECOSiPixelCalSingleMuonTight=OutALCARECOSiPixelCalSingleMuonTight_noDrop.clone() +OutALCARECOSiPixelCalSingleMuonTight.outputCommands.insert(0, "drop *") diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py new file mode 100644 index 0000000000000..ee5bae5da79db --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py @@ -0,0 +1,92 @@ +import FWCore.ParameterSet.Config as cms + +################################################################## +# AlCaReco for track based monitoring using single muon events +################################################################## +from HLTrigger.HLTfilters.hltHighLevel_cfi import * +ALCARECOSiPixelCalSingleMuonTightHLTFilter = hltHighLevel.clone() +ALCARECOSiPixelCalSingleMuonTightHLTFilter.andOr = True ## choose logical OR between Triggerbits +ALCARECOSiPixelCalSingleMuonTightHLTFilter.throw = False ## dont throw on unknown path names +ALCARECOSiPixelCalSingleMuonTightHLTFilter.HLTPaths = ["HLT_*"] +#ALCARECOSiPixelCalSingleMuonTightHLTFilter.eventSetupPathsKey = 'SiPixelCalSingleMuonTight' ## FIXME: to be changed once trigger bit is updated + +################################################################## +# Filter on the DCS partitions +################################################################## +import DPGAnalysis.Skims.skim_detstatus_cfi +ALCARECOSiPixelCalSingleMuonTightDCSFilter = DPGAnalysis.Skims.skim_detstatus_cfi.dcsstatus.clone( + DetectorType = cms.vstring('TIBTID','TOB','TECp','TECm','BPIX','FPIX', + 'DT0','DTp','DTm','CSCp','CSCm'), + ApplyFilter = cms.bool(True), + AndOr = cms.bool(True), + DebugOn = cms.untracked.bool(False) +) + +################################################################## +# Isolated muons Track selector +################################################################## +import Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi +ALCARECOSiPixelCalSingleMuonTightGoodMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlGoodIdMuonSelector.clone() +ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons = Alignment.CommonAlignmentProducer.TkAlMuonSelectors_cfi.TkAlRelCombIsoMuonSelector.clone( + src = 'ALCARECOSiPixelCalSingleMuonTightGoodMuons' +) + +################################################################## +# Basic Track selection +################################################################## +import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi +ALCARECOSiPixelCalSingleMuonTight = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone( + filter = True, ##do not store empty events + applyBasicCuts = True, + ptMin = 2.0, ##GeV + etaMin = -3.5, + etaMax = 3.5, + nHitMin = 0 +) + +################################################################## +# Muon selection +################################################################## +ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.muonSource = 'ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons' +# Isolation is shifted to the muon preselection, and then applied intrinsically if applyGlobalMuonFilter = True +ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.applyIsolationtest = False +ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.minJetDeltaR = 0.1 +ALCARECOSiPixelCalSingleMuonTight.GlobalSelector.applyGlobalMuonFilter = True +ALCARECOSiPixelCalSingleMuonTight.TwoBodyDecaySelector.applyMassrangeFilter = False +ALCARECOSiPixelCalSingleMuonTight.TwoBodyDecaySelector.applyChargeFilter = False +ALCARECOSiPixelCalSingleMuonTight.TwoBodyDecaySelector.applyAcoplanarityFilter = False + +################################################################## +# Track refitter +################################################################## +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * +from RecoTracker.Configuration.RecoTrackerP5_cff import * +from RecoTracker.TrackProducer.TrackRefitter_cfi import * + +ALCARECOSiPixelCalSingleMuonTightTracksRefit = TrackRefitter.clone(src = cms.InputTag("ALCARECOSiPixelCalSingleMuonTight"), + NavigationSchool = cms.string("") + ) + +################################################################## +# Producer or close-by-pixels +################################################################## +import Calibration.TkAlCaRecoProducers.NearbyPixelClustersProducer_cfi as NearbyPixelClusters +closebyPixelClusters = NearbyPixelClusters.NearbyPixelClustersProducer.clone(clusterCollection = 'siPixelClusters', + trajectoryInput = 'ALCARECOSiPixelCalSingleMuonTightTracksRefit') + +################################################################## +# Sequence: track refit + close-by-pixel producer +################################################################## +ALCARECOSiPixelCalSingleMuonTightOffTrackClusters = cms.Sequence(ALCARECOSiPixelCalSingleMuonTightTracksRefit + + closebyPixelClusters) + +################################################################## +# Final Tight sequence +################################################################## +seqALCARECOSiPixelCalSingleMuonTight = cms.Sequence(offlineBeamSpot+ + ALCARECOSiPixelCalSingleMuonTightHLTFilter+ + ALCARECOSiPixelCalSingleMuonTightDCSFilter+ + ALCARECOSiPixelCalSingleMuonTightGoodMuons+ + ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons+ + ALCARECOSiPixelCalSingleMuonTight+ + ALCARECOSiPixelCalSingleMuonTightOffTrackClusters) diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_Output_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_Output_cff.py index 6dfa18b1df673..81d4f66ed16fb 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_Output_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_Output_cff.py @@ -11,7 +11,6 @@ 'keep *_*riggerResults_*_HLT' ) ) -import copy -OutALCARECOSiPixelCalSingleMuon=copy.deepcopy(OutALCARECOSiPixelCalSingleMuon_noDrop) -OutALCARECOSiPixelCalSingleMuon.outputCommands.insert(0, "drop *") \ No newline at end of file +OutALCARECOSiPixelCalSingleMuon=OutALCARECOSiPixelCalSingleMuon_noDrop.clone() +OutALCARECOSiPixelCalSingleMuon.outputCommands.insert(0, "drop *") diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_cff.py index 70d4df13ffb22..53d634ca44b06 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuon_cff.py @@ -1,22 +1,26 @@ import FWCore.ParameterSet.Config as cms -import copy +################################################################## +# AlCaReco for track based calibration using single muon events +################################################################## from HLTrigger.HLTfilters.hltHighLevel_cfi import * -# AlCaReco for track based calibration using min. bias events -ALCARECOSiPixelCalSingleMuonHLTFilter = copy.deepcopy(hltHighLevel) -#seqALCARECOSiPixelCalSingleMuon = cms.Sequence(ALCARECOSiPixelCalSingleMuonHLTFilter) +ALCARECOSiPixelCalSingleMuonHLTFilter = hltHighLevel.clone() ALCARECOSiPixelCalSingleMuonHLTFilter.andOr = True ## choose logical OR between Triggerbits ALCARECOSiPixelCalSingleMuonHLTFilter.throw = False ## dont throw on unknown path names ALCARECOSiPixelCalSingleMuonHLTFilter.eventSetupPathsKey = 'SiPixelCalSingleMuon' +################################################################## +# Basic track selection +################################################################## import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi ALCARECOSiPixelCalSingleMuon = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone() - ALCARECOSiPixelCalSingleMuon.filter = True ##do not store empty events ALCARECOSiPixelCalSingleMuon.applyBasicCuts = True ALCARECOSiPixelCalSingleMuon.ptMin = 3.0 #GeV ALCARECOSiPixelCalSingleMuon.etaMin = -3.5 ALCARECOSiPixelCalSingleMuon.etaMax = 3.5 -# Sequence # +################################################################## +# Loose Sequence +################################################################## seqALCARECOSiPixelCalSingleMuon = cms.Sequence(ALCARECOSiPixelCalSingleMuonHLTFilter+ALCARECOSiPixelCalSingleMuon) diff --git a/Calibration/TkAlCaRecoProducers/python/NearbyPixelClustersProducer_cfi.py b/Calibration/TkAlCaRecoProducers/python/NearbyPixelClustersProducer_cfi.py new file mode 100644 index 0000000000000..51d715ef88874 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/NearbyPixelClustersProducer_cfi.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +NearbyPixelClustersProducer = cms.EDProducer('NearbyPixelClustersProducer', + clusterCollection = cms.InputTag('siPixelClusters'), # input clusters + trajectoryInput = cms.InputTag('TrackerRefitter'), # input trajectories + throwBadComponents = cms.bool(False), # do not use bad components + dumpWholeDetIds = cms.bool(False) # write all clusters in Det + ) diff --git a/Calibration/TkAlCaRecoProducers/test/inspectNearByPixelClusters_cfg.py b/Calibration/TkAlCaRecoProducers/test/inspectNearByPixelClusters_cfg.py new file mode 100644 index 0000000000000..100c190906790 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/test/inspectNearByPixelClusters_cfg.py @@ -0,0 +1,95 @@ +import glob +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +options = VarParsing.VarParsing() + +################################################################### +# Setup 'standard' options +################################################################### + +options.register('OutFileName', + "test.root", # default value + VarParsing.VarParsing.multiplicity.singleton, # singleton or list + VarParsing.VarParsing.varType.string, # string, int, or float + "name of the output file (test.root is default)") + +options.register('myGT', + "auto:run2_data", # default value + VarParsing.VarParsing.multiplicity.singleton, # singleton or list + VarParsing.VarParsing.varType.string, # string, int, or float + "name of the input Global Tag") + +options.register('maxEvents', + -1, + VarParsing.VarParsing.multiplicity.singleton, # singleton or list + VarParsing.VarParsing.varType.int, # string, int, or float + "num. events to run") + +options.parseArguments() + +process = cms.Process("AlCaRECOAnalysis") + +################################################################### +# Message logger service +################################################################### +process.load("FWCore.MessageService.MessageLogger_cfi") +process.MessageLogger.cerr.FwkReport.reportEvery = 1 + +################################################################### +# Geometry producer and standard includes +################################################################### +process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff") +process.load("Configuration.StandardSequences.Services_cff") +process.load("Configuration.StandardSequences.GeometryRecoDB_cff") +process.load('Configuration.StandardSequences.MagneticField_cff') +#process.load("Configuration.StandardSequences.MagneticField_0T_cff") +process.load("CondCore.CondDB.CondDB_cfi") + +#################################################################### +# Get the GlogalTag +#################################################################### +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag,options.myGT, '') + +################################################################### +# Source +################################################################### +readFiles = cms.untracked.vstring() +readFiles.extend(['file:SiPixelCalSingleMuonTight.root']) +#readFiles.extend(['file:SiPixelCalSingleMuonTight_fullDetId.root']) +process.source = cms.Source("PoolSource",fileNames = readFiles) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents)) + +################################################################### +# The TrackRefitter +################################################################### +process.load("RecoTracker.TrackProducer.TrackRefitters_cff") +import RecoTracker.TrackProducer.TrackRefitters_cff +process.TrackRefitter = process.TrackRefitterP5.clone(src = 'ALCARECOSiPixelCalSingleMuonTight', + TrajectoryInEvent = True, + TTRHBuilder = "WithAngleAndTemplate", + NavigationSchool = "", + ) + +################################################################### +# The analysis module +################################################################### +process.myanalysis = cms.EDAnalyzer("NearbyPixelClustersAnalyzer", + trajectoryInput = cms.InputTag("TrackRefitter"), + #skimmedGeometryPath = cms.string("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt") # phase-0 + skimmedGeometryPath = cms.string("SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt") #phase-1 + ) + +################################################################### +# Output name +################################################################### +process.TFileService = cms.Service("TFileService", + fileName = cms.string(options.OutFileName)) + +################################################################### +# Path +################################################################### +process.p1 = cms.Path(process.offlineBeamSpot* + process.TrackRefitter* + process.myanalysis) diff --git a/Configuration/AlCa/python/autoAlca.py b/Configuration/AlCa/python/autoAlca.py index b66b54bdcc6d5..4f3dac82fca6b 100644 --- a/Configuration/AlCa/python/autoAlca.py +++ b/Configuration/AlCa/python/autoAlca.py @@ -12,7 +12,7 @@ "MuOnia" : "TkAlUpsilonMuMu", "NoBPTX" : "TkAlCosmicsInCollisions", "SingleElectron" : "EcalUncalWElectron+EcalUncalZElectron+HcalCalIterativePhiSym+EcalESAlign", - "SingleMuon" : "SiPixelCalSingleMuon+TkAlMuonIsolated+MuAlCalIsolatedMu+MuAlOverlaps+MuAlZMuMu+HcalCalHO+HcalCalIterativePhiSym+HcalCalHBHEMuonFilter+HcalCalHEMuonFilter", + "SingleMuon" : "SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+TkAlMuonIsolated+MuAlCalIsolatedMu+MuAlOverlaps+MuAlZMuMu+HcalCalHO+HcalCalIterativePhiSym+HcalCalHBHEMuonFilter+HcalCalHEMuonFilter", "SinglePhoton" : "HcalCalGammaJet", "ZeroBias" : "SiStripCalZeroBias+TkAlMinBias+LumiPixelsMinBias+SiStripCalMinBias+AlCaPCCZeroBiasFromRECO", @@ -96,7 +96,7 @@ 'MuOnia' : 'TkAlUpsilonMuMu', 'SingleElectron' : 'EcalUncalWElectron+EcalUncalZElectron+EcalESAlign+HcalCalIterativePhiSym+HcalCalIsoTrkFilter', 'SingleMu' : 'MuAlCalIsolatedMu+MuAlOverlaps+TkAlMuonIsolated+MuAlZMuMu+HcalCalHO', - 'SingleMuon' : 'SiPixelCalSingleMuon+TkAlMuonIsolated+MuAlCalIsolatedMu+MuAlOverlaps+MuAlZMuMu+HcalCalIterativePhiSym+HcalCalHO', + 'SingleMuon' : 'SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+TkAlMuonIsolated+MuAlCalIsolatedMu+MuAlOverlaps+MuAlZMuMu+HcalCalIterativePhiSym+HcalCalHO', 'SinglePhoton' : 'HcalCalGammaJet', 'ZeroBias' : 'SiStripCalZeroBias+TkAlMinBias+LumiPixelsMinBias+SiStripCalMinBias+SiStripCalMinBiasAfterAbortGap', 'HcalNZS' : 'HcalCalMinBias' diff --git a/Configuration/EventContent/python/AlCaRecoOutput_RelVal_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_RelVal_cff.py index 297a7e193a5ff..cae150ddc772f 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_RelVal_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_RelVal_cff.py @@ -26,6 +26,8 @@ 'keep *_ALCARECOMuAlOverlaps_*_*', 'keep *_ALCARECOMuAlCalIsolatedMu_*_*', 'keep *_ALCARECOSiPixelCalSingleMuon_*_*', + 'keep *_ALCARECOSiPixelCalSingleMuonLoose_*_*', + 'keep *_ALCARECOSiPixelCalSingleMuonTight_*_*', 'keep *_ALCARECOSiPixelCalCosmics_*_*', 'keep *_cosmicMuons_*_*', 'keep *_cosmictrackfinderP5_*_*', diff --git a/Configuration/EventContent/python/AlCaRecoOutput_cff.py b/Configuration/EventContent/python/AlCaRecoOutput_cff.py index f9e64e4508cae..7399f0f001a8c 100644 --- a/Configuration/EventContent/python/AlCaRecoOutput_cff.py +++ b/Configuration/EventContent/python/AlCaRecoOutput_cff.py @@ -40,6 +40,8 @@ # AlCaReco for pixel calibration using muons from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuon_Output_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonLoose_Output_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonTight_Output_cff import * # AlCaReco for tracker calibration using MinBias events from Calibration.TkAlCaRecoProducers.ALCARECOSiStripCalMinBias_Output_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripCalMinBiasAAG_Output_cff import * diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 54c56c1f41cab..129aa24f54947 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2246,15 +2246,15 @@ def gen2021HiMix(fragment,howMuch): steps['RECODR2_2017reHLTSiPixelCalZeroBias']=merge([{'--hltProcess':'reHLT','--conditions':'auto:run2_data_relval','-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiPixelCalZeroBias,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2017']]) steps['RECODR2_2018reHLTAlCaTkCosmics']=merge([{'--hltProcess':'reHLT','--conditions':'auto:run2_data_relval','-s':'RAW2DIGI,L1Reco,RECO,SKIM:EXONoBPTXSkim,EI,PAT,ALCA:TkAlCosmicsInCollisions,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2018']]) -steps['RECODR2_2016reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2016reHLT']]) +steps['RECODR2_2016reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_skimDoubleEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:ZElectron,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) -steps['RECODR2_2016reHLT_skimMuonEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:TopMuEG,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) +steps['RECODR2_2016reHLT_skimMuonEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:TopMuEG,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_skimJetHT']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:JetHTJetPlusHOFilter,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_skimMET']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:HighMET+EXOMONOPOLE,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_skimSinglePh']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:SinglePhotonJetPlusHOFilter+EXOMONOPOLE,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_skimMuOnia']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:BPHSkim,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2016reHLT']]) -steps['RECODR2_2017reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2017reHLT']]) +steps['RECODR2_2017reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2017reHLT']]) steps['RECODR2_2017reHLT_skimDoubleEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:ZElectron,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2017reHLT']]) steps['RECODR2_2017reHLT_skimMuonEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:TopMuEG,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2017reHLT']]) steps['RECODR2_2017reHLT_skimJetHT']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:JetHTJetPlusHOFilter,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2017reHLT']]) @@ -2265,7 +2265,7 @@ def gen2021HiMix(fragment,howMuch): steps['RECODR2_2017reHLT_skimCharmonium']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGJPsiSkim+BPHSkim,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2017reHLT']]) steps['RECODR2_2018reHLT']=merge([{'--hltProcess':'reHLT','--conditions':'auto:run2_data_relval'},steps['RECODR2_2018']]) -steps['RECODR2_2018reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+SiStripCalSmallBiasScan+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2018reHLT']]) +steps['RECODR2_2018reHLT_skimSingleMu']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+SiStripCalSmallBiasScan+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TMuon'},steps['RECODR2_2018reHLT']]) steps['RECODR2_2018reHLT_skimEGamma_L1TEgDQM']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:ZElectron+SinglePhotonJetPlusHOFilter+EXOMONOPOLE,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+SiStripCalSmallBiasScan+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@L1TEgamma'},steps['RECODR2_2018reHLT']]) steps['RECODR2_2018reHLT_skimMuonEG']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:TopMuEG,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+SiStripCalSmallBiasScan+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2018reHLT']]) steps['RECODR2_2018reHLT_skimJetHT']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:JetHTJetPlusHOFilter,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+SiStripCalSmallBiasScan+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM'},steps['RECODR2_2018reHLT']]) @@ -2313,7 +2313,7 @@ def gen2021HiMix(fragment,howMuch): steps['RECODR2_2017reHLT_skimSinglePh_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimSinglePh']]) steps['RECODR2_2017reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimMuOnia']]) steps['RECODR2_2017reHLT_skimCharmonium_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimCharmonium']]) -steps['RECODR2_2017reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2017reHLT_skimSingleMu_Prompt']]) +steps['RECODR2_2017reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2017reHLT_skimSingleMu_Prompt']]) steps['RECODR2_2017reHLTAlCaTkCosmics_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLTAlCaTkCosmics']]) steps['RECODR2_2017reHLTSiPixelCalZeroBias_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLTSiPixelCalZeroBias']]) @@ -2346,8 +2346,8 @@ def gen2021HiMix(fragment,howMuch): steps['RECODR2_2018reHLT_skimCharmonium_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimCharmonium']]) steps['RECODR2_2018reHLT_skimParkingBPH_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimParkingBPH']]) steps['RECODR2_2018reHLT_skimParkingBPH_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimParkingBPH']]) -steps['RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Prompt']]) -steps['RECODR2_2018reHLT_skimSingleMu_Offline_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuon+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Offline']]) +steps['RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Prompt']]) +steps['RECODR2_2018reHLT_skimSingleMu_Offline_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQMFakeHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Offline']]) steps['RECODR2_2018reHLTAlCaTkCosmics_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLTAlCaTkCosmics']]) steps['RECODR2_2018reHLTAlCaTkCosmics_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLTAlCaTkCosmics']]) steps['RECODR2_2018reHLT_Prompt_hBStar']=merge([{'--era':'Run2_2018_highBetaStar'},steps['RECODR2_2018reHLT_Prompt']]) @@ -3388,7 +3388,7 @@ def gen2021HiMix(fragment,howMuch): upgradeStepDict['HARVESTGlobal'][k] = merge([{'-s': 'HARVESTING:@phase2Validation+@phase2+@miniAODValidation+@miniAODDQM'}, upgradeStepDict['HARVEST'][k]]) - upgradeStepDict['ALCA'][k] = {'-s':'ALCA:SiPixelCalSingleMuon+TkAlMuonIsolated+TkAlMinBias+MuAlOverlaps+EcalESAlign+TkAlZMuMu+HcalCalHBHEMuonFilter+TkAlUpsilonMuMu+TkAlJpsiMuMu+SiStripCalMinBias', + upgradeStepDict['ALCA'][k] = {'-s':'ALCA:SiPixelCalSingleMuonLoose+SiPixelCalSingleMuonTight+TkAlMuonIsolated+TkAlMinBias+MuAlOverlaps+EcalESAlign+TkAlZMuMu+HcalCalHBHEMuonFilter+TkAlUpsilonMuMu+TkAlJpsiMuMu+SiStripCalMinBias', '--conditions':gt, '--datatier':'ALCARECO', '-n':'10', diff --git a/Configuration/StandardSequences/python/AlCaRecoStreamsHeavyIons_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreamsHeavyIons_cff.py index 03eee48c24810..f36faf4d865f3 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreamsHeavyIons_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreamsHeavyIons_cff.py @@ -27,8 +27,10 @@ ############################################################### # Tracker Calibration ############################################################### -# AlCaReco for pixel calibration using muons +# AlCaReco for pixel calibration using muons from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuon_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonLoose_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonTight_cff import * # AlCaReco for tracker calibration using MinBias events from Calibration.TkAlCaRecoProducers.ALCARECOSiStripCalMinBiasHI_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiStripCalMinBiasAAGHI_cff import * @@ -121,6 +123,8 @@ pathALCARECOTkAlUpsilonMuMuHI = cms.Path(seqALCARECOTkAlUpsilonMuMuHI*ALCARECOTkAlUpsilonMuMuHIDQM) pathALCARECOTkAlMinBiasHI = cms.Path(seqALCARECOTkAlMinBiasHI*ALCARECOTkAlMinBiasHIDQM) pathALCARECOSiPixelCalSingleMuon = cms.Path(seqALCARECOSiPixelCalSingleMuon) +pathALCARECOSiPixelCalSingleMuonLoose = cms.Path(seqALCARECOSiPixelCalSingleMuonLoose) +pathALCARECOSiPixelCalSingleMuonTight = cms.Path(seqALCARECOSiPixelCalSingleMuonTight) pathALCARECOSiStripCalMinBias = cms.Path(seqALCARECOSiStripCalMinBias*ALCARECOSiStripCalMinBiasDQM) pathALCARECOSiStripCalMinBiasAAG = cms.Path(seqALCARECOSiStripCalMinBiasAAG*ALCARECOSiStripCalMinBiasAAGDQM) pathALCARECOSiStripCalCosmics = cms.Path(seqALCARECOSiStripCalCosmics) @@ -231,6 +235,24 @@ dataTier = cms.untracked.string('ALCARECO') ) +ALCARECOStreamSiPixelCalSingleMuonTight = cms.FilteredStream( + responsible = 'Marco Musich', + name = 'SiPixelCalSingleMuonTight', + paths = (pathALCARECOSiPixelCalSingleMuonTight), + content = OutALCARECOSiPixelCalSingleMuonTight.outputCommands, + selectEvents = OutALCARECOSiPixelCalSingleMuonTight.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + +ALCARECOStreamSiPixelCalSingleMuonLoose = cms.FilteredStream( + responsible = 'Marco Musich', + name = 'SiPixelCalSingleMuonLoose', + paths = (pathALCARECOSiPixelCalSingleMuonLoose), + content = OutALCARECOSiPixelCalSingleMuonLoose.outputCommands, + selectEvents = OutALCARECOSiPixelCalSingleMuonLoose.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + ALCARECOStreamSiStripCalMinBias = cms.FilteredStream( responsible = 'Vitaliano Ciulli', name = 'SiStripCalMinBias', diff --git a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py index 00806b7280dda..ee33f3a32bddd 100644 --- a/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py +++ b/Configuration/StandardSequences/python/AlCaRecoStreams_cff.py @@ -35,6 +35,8 @@ ############################################################### # AlCaReco for pixel calibration using muons from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuon_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonLoose_cff import * +from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalSingleMuonTight_cff import * from Calibration.TkAlCaRecoProducers.ALCARECOSiPixelCalCosmics_cff import * # AlCaReco for tracker calibration using MinBias events from Calibration.TkAlCaRecoProducers.ALCARECOSiStripCalMinBias_cff import * @@ -166,6 +168,8 @@ pathALCARECOTkAlMinBias = cms.Path(seqALCARECOTkAlMinBias*ALCARECOTkAlMinBiasDQM) pathALCARECOTkAlMinBias = cms.Path(seqALCARECOTkAlMinBias*ALCARECOTkAlMinBiasDQM) pathALCARECOSiPixelCalSingleMuon = cms.Path(seqALCARECOSiPixelCalSingleMuon) +pathALCARECOSiPixelCalSingleMuonLoose = cms.Path(seqALCARECOSiPixelCalSingleMuonLoose) +pathALCARECOSiPixelCalSingleMuonTight = cms.Path(seqALCARECOSiPixelCalSingleMuonTight) pathALCARECOSiPixelCalCosmics = cms.Path(seqALCARECOSiPixelCalCosmics) pathALCARECOSiStripCalMinBias = cms.Path(seqALCARECOSiStripCalMinBias*ALCARECOSiStripCalMinBiasDQM) pathALCARECOSiStripCalCosmics = cms.Path(seqALCARECOSiStripCalCosmics) @@ -351,6 +355,24 @@ dataTier = cms.untracked.string('ALCARECO') ) +ALCARECOStreamSiPixelCalSingleMuonLoose = cms.FilteredStream( + responsible = 'Marco Musich', + name = 'SiPixelCalSingleMuonLoose', + paths = (pathALCARECOSiPixelCalSingleMuonLoose), + content = OutALCARECOSiPixelCalSingleMuonLoose.outputCommands, + selectEvents = OutALCARECOSiPixelCalSingleMuonLoose.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + +ALCARECOStreamSiPixelCalSingleMuonTight = cms.FilteredStream( + responsible = 'Marco Musich', + name = 'SiPixelCalSingleMuonTight', + paths = (pathALCARECOSiPixelCalSingleMuonTight), + content = OutALCARECOSiPixelCalSingleMuonTight.outputCommands, + selectEvents = OutALCARECOSiPixelCalSingleMuonTight.SelectEvents, + dataTier = cms.untracked.string('ALCARECO') + ) + ALCARECOStreamSiPixelCalCosmics = cms.FilteredStream( responsible = 'Tamas Almos Vami', name = 'SiPixelCalCosmics', From 243da818bf0efc2785225f81d1e26d44244a1bda Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 12 Apr 2021 19:54:54 +0200 Subject: [PATCH 2/6] fix issues with clang tidy and static analyzer --- .../plugins/NearbyPixelClustersAnalyzer.cc | 11 ++++------- .../plugins/NearbyPixelClustersProducer.cc | 8 +++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc index b2fb503a2d64c..960e8b79890e9 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc @@ -142,8 +142,7 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E const PixelClusterParameterEstimator* pixelCPE_ = &iSetup.getData(pixelCPEEsToken_); // Get cluster collection - edm::Handle clusterCollectionHandle; - iEvent.getByToken(clustersToken_, clusterCollectionHandle); + const auto& clusterCollectionHandle = iEvent.getHandle(clustersToken_); unsigned int nClusGlobal = 0; countClusters(clusterCollectionHandle, nClusGlobal); @@ -152,8 +151,7 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E edm::LogInfo("NearbyPixelClustersAnalyzer") << "total ALCARECO clusters: " << nClusGlobal << std::endl; // Get nearby cluster collection - edm::Handle nearByClusterCollectionHandle; - iEvent.getByToken(nearByClustersToken_, /*trackerGeometry_,*/ nearByClusterCollectionHandle); + const auto& nearByClusterCollectionHandle = iEvent.getHandle(nearByClustersToken_); unsigned int nNearByClusGlobal = 0; countClusters(nearByClusterCollectionHandle, /*trackerGeometry_,*/ nNearByClusGlobal); @@ -165,8 +163,7 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E fillClusterFrames(nearByClusterCollectionHandle); // Get Traj-Track Collection - edm::Handle trajTrackCollectionHandle; - iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle); + const auto& trajTrackCollectionHandle = iEvent.getHandle(trajTrackCollectionToken_); if (!trajTrackCollectionHandle.isValid()) return; @@ -278,7 +275,7 @@ TrajectoryStateOnSurface NearbyPixelClustersAnalyzer::getTrajectoryStateOnSurfac const TrajectoryMeasurement& measurement) /*--------------------------------------------------------------------*/ { - static TrajectoryStateCombiner trajStateCombiner; + const static TrajectoryStateCombiner trajStateCombiner; const auto& forwardPredictedState = measurement.forwardPredictedState(); const auto& backwardPredictedState = measurement.backwardPredictedState(); diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc index 153252dce6878..0411b72144457 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersProducer.cc @@ -145,13 +145,11 @@ void NearbyPixelClustersProducer::produce(edm::Event& iEvent, const edm::EventSe const auto& SiPixelBadModule_ = &iSetup.getData(badModuleToken_); // get cluster collection - edm::Handle clusterCollectionHandle; - iEvent.getByToken(clustersToken_, clusterCollectionHandle); + const auto& clusterCollectionHandle = iEvent.getHandle(clustersToken_); const SiPixelClusterCollectionNew& clusterCollection = *clusterCollectionHandle; // get Traj-Track Collection - edm::Handle trajTrackCollectionHandle; - iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle); + const auto& trajTrackCollectionHandle = iEvent.getHandle(trajTrackCollectionToken_); if (!trajTrackCollectionHandle.isValid()) return; @@ -399,7 +397,7 @@ TrajectoryStateOnSurface NearbyPixelClustersProducer::getTrajectoryStateOnSurfac const TrajectoryMeasurement& measurement) /*--------------------------------------------------------------------*/ { - static TrajectoryStateCombiner trajStateCombiner; + const static TrajectoryStateCombiner trajStateCombiner; const auto& forwardPredictedState = measurement.forwardPredictedState(); const auto& backwardPredictedState = measurement.backwardPredictedState(); From cd85e8c9b3b34e39c418f5a665087c3a3d752b7b Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 12 Apr 2021 16:11:16 +0200 Subject: [PATCH 3/6] add valueMap producer for the track distances --- .../TkAlCaRecoProducers/plugins/BuildFile.xml | 5 + .../plugins/TrackDistanceValueMapProducer.cc | 136 ++++++++++++++++++ ...ECOSiPixelCalSingleMuonTight_Output_cff.py | 3 +- .../ALCARECOSiPixelCalSingleMuonTight_cff.py | 9 +- .../TrackDistanceValueMapProducer_cfi.py | 6 + 5 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc create mode 100644 Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py diff --git a/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml b/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml index 7b881f869abf4..77617fc58ce2c 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml +++ b/Calibration/TkAlCaRecoProducers/plugins/BuildFile.xml @@ -53,3 +53,8 @@ + + + + + diff --git a/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc new file mode 100644 index 0000000000000..35d0d983a4bec --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc @@ -0,0 +1,136 @@ +// -*- C++ -*- +// +// Package: Calibration/TkAlCaRecoProducers +// Class: TrackDistanceValueMapProducer +// +/**\class TrackDistanceValueMapProducer TrackDistanceValueMapProducer.cc Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc + + Description: creates a value map for each saved muon track with all the distances of the other track w.r.t. the muon track + +*/ +// +// Original Author: Marco Musich +// Created: Mon, 12 Apr 2021 11:59:39 GMT +// +// + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" + +#include "DataFormats/Math/interface/deltaR.h" +// +// class declaration +// + +class TrackDistanceValueMapProducer : public edm::stream::EDProducer<> { +public: + explicit TrackDistanceValueMapProducer(const edm::ParameterSet&); + ~TrackDistanceValueMapProducer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + + // ----------member data --------------------------- + // edToken + edm::EDGetTokenT> muonTracksToken_; + edm::EDGetTokenT> otherTracksToken_; + + // putToken + edm::EDPutTokenT>> distancesPutToken_; +}; + +// +// constructors and destructor +// +TrackDistanceValueMapProducer::TrackDistanceValueMapProducer(const edm::ParameterSet& iConfig) + : muonTracksToken_(consumes>(iConfig.getParameter("muonTracks"))), + otherTracksToken_(consumes>(iConfig.getParameter("allTracks"))), + distancesPutToken_(produces>>()) {} + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void TrackDistanceValueMapProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + //======================================================= + // Retrieve the muon Track information + //======================================================= + + edm::Handle> muonTrackCollectionHandle; + iEvent.getByToken(muonTracksToken_, muonTrackCollectionHandle); + if (!muonTrackCollectionHandle.isValid()) + return; + auto const& muonTracks = *muonTrackCollectionHandle; + + //======================================================= + // Retrieve the general Track information + //======================================================= + + edm::Handle> allTrackCollectionHandle; + iEvent.getByToken(otherTracksToken_, allTrackCollectionHandle); + if (!allTrackCollectionHandle.isValid()) + return; + auto const& allTracks = *allTrackCollectionHandle; + + //======================================================= + // fill the distance vector + //======================================================= + + // the map cannot be filled straight away, so create an intermediate vector + unsigned int Nit = muonTracks.size(); + unsigned int Nall = allTracks.size(); + std::vector> v2_dR2; + + for (unsigned int iit = 0; iit < Nit; iit++) { + const auto& muontrack = muonTracks.ptrAt(iit); + + std::vector v_dR2; + for (unsigned int iAll = 0; iAll < Nall; iAll++) { + const auto& recotrack = allTracks.ptrAt(iAll); + const float dR2 = ::deltaR2(*muontrack, *recotrack); + v_dR2.push_back(dR2); + } + v2_dR2.push_back(v_dR2); + } + + //======================================================= + // Populate the event with the value map + //======================================================= + + std::unique_ptr>> vm_dR2(new edm::ValueMap>()); + edm::ValueMap>::Filler filler(*vm_dR2); + filler.insert(muonTrackCollectionHandle, v2_dR2.begin(), v2_dR2.end()); + filler.fill(); + iEvent.put(distancesPutToken_, std::move(vm_dR2)); +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void TrackDistanceValueMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Produces a value map with all the distances with the other tracks in the event"); + desc.add("muonTracks", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight")) + ->setComment("the probe muon tracks"); + desc.add("allTracks", edm::InputTag("generalTracks"))->setComment("all tracks in the event"); + descriptions.addWithDefaultLabel(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(TrackDistanceValueMapProducer); diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py index 9b54c5595b086..3349e359c81b6 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_Output_cff.py @@ -9,7 +9,8 @@ 'keep *_muons__*', 'keep *_offlinePrimaryVertices_*_*', 'keep *_*riggerResults_*_HLT', - 'keep *_*closebyPixelClusters*_*_*' + 'keep *_*closebyPixelClusters*_*_*', + 'keep *_*trackDistances*_*_*', ) ) OutALCARECOSiPixelCalSingleMuonTight=OutALCARECOSiPixelCalSingleMuonTight_noDrop.clone() diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py index ee5bae5da79db..419e54fabe48e 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOSiPixelCalSingleMuonTight_cff.py @@ -60,7 +60,7 @@ # Track refitter ################################################################## from RecoVertex.BeamSpotProducer.BeamSpot_cff import * -from RecoTracker.Configuration.RecoTrackerP5_cff import * +#from RecoTracker.Configuration.RecoTrackerP5_cff import * from RecoTracker.TrackProducer.TrackRefitter_cfi import * ALCARECOSiPixelCalSingleMuonTightTracksRefit = TrackRefitter.clone(src = cms.InputTag("ALCARECOSiPixelCalSingleMuonTight"), @@ -80,6 +80,12 @@ ALCARECOSiPixelCalSingleMuonTightOffTrackClusters = cms.Sequence(ALCARECOSiPixelCalSingleMuonTightTracksRefit + closebyPixelClusters) +################################################################## +# Producer of distances value map +################################################################## +import Calibration.TkAlCaRecoProducers.TrackDistanceValueMapProducer_cfi as TrackDistanceValueMap +trackDistances = TrackDistanceValueMap.TrackDistanceValueMapProducer.clone(muonTracks = 'ALCARECOSiPixelCalSingleMuonTight') + ################################################################## # Final Tight sequence ################################################################## @@ -89,4 +95,5 @@ ALCARECOSiPixelCalSingleMuonTightGoodMuons+ ALCARECOSiPixelCalSingleMuonTightRelCombIsoMuons+ ALCARECOSiPixelCalSingleMuonTight+ + trackDistances + ALCARECOSiPixelCalSingleMuonTightOffTrackClusters) diff --git a/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py b/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py new file mode 100644 index 0000000000000..e724edc95a997 --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +TrackDistanceValueMapProducer = cms.EDProducer('TrackDistanceValueMapProducer', + muonTracks = cms.InputTag('muonTracks'), # input muon tracks + allTracks = cms.InputTag('generalTracks') # input generalTracks + ) From 823b3180979a4a57e146e8ff84e719eb4a802645 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 12 Apr 2021 19:49:48 +0200 Subject: [PATCH 4/6] add monitoring of closest track --- .../plugins/NearbyPixelClustersAnalyzer.cc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc index 960e8b79890e9..4a9abbe3dca80 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc @@ -95,6 +95,8 @@ class NearbyPixelClustersAnalyzer : public edm::one::EDAnalyzer clustersToken_; edm::EDGetTokenT nearByClustersToken_; edm::EDGetTokenT trajTrackCollectionToken_; + edm::EDGetTokenT>> distanceToken_; + edm::EDGetTokenT> muonTracksToken_; edm::Service fs; @@ -103,6 +105,7 @@ class NearbyPixelClustersAnalyzer : public edm::one::EDAnalyzer outputFolders_; @@ -123,6 +126,8 @@ NearbyPixelClustersAnalyzer::NearbyPixelClustersAnalyzer(const edm::ParameterSet consumes(iConfig.getParameter("nearByClusterCollection"))), trajTrackCollectionToken_( consumes(iConfig.getParameter("trajectoryInput"))), + distanceToken_(consumes>>(iConfig.getParameter("distToTrack"))), + muonTracksToken_(consumes>(iConfig.getParameter("muonTracks"))), reader_(edm::FileInPath(iConfig.getParameter("skimmedGeometryPath")).fullPath()) { usesResource(TFileService::kSharedResource); } @@ -141,6 +146,36 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E // get the Pixel CPE from event setup const PixelClusterParameterEstimator* pixelCPE_ = &iSetup.getData(pixelCPEEsToken_); + // get the muon track collection + edm::Handle> muonTrackCollectionHandle; + iEvent.getByToken(muonTracksToken_, muonTrackCollectionHandle); + auto const& muonTracks = *muonTrackCollectionHandle; + + // get the track distances + edm::Handle>> distancesToTrack; + iEvent.getByToken(distanceToken_, distancesToTrack); + + unsigned int nMuons = muonTracks.size(); + for (unsigned int ij = 0; ij < nMuons; ij++) { + auto muon = muonTrackCollectionHandle->ptrAt(ij); + edm::RefToBase trackRef = muonTrackCollectionHandle->refAt(ij); + const auto& distances = (*distancesToTrack)[trackRef]; + + LogDebug("NearbyPixelClustersAnalyzer") << "distances size: " << distances.size() << std::endl; + + unsigned counter = 0; + double closestDR = 999.; + for (const auto& distance : distances) { + counter++; + LogDebug("NearbyPixelClustersAnalyzer") << "track: " << counter << " distance:" << distance << std::endl; + if (distance < closestDR && distance > 0) { + closestDR = distance; + } + } + + h_distClosestTrack->Fill(std::sqrt(closestDR)); + } + // Get cluster collection const auto& clusterCollectionHandle = iEvent.getHandle(clustersToken_); @@ -250,6 +285,14 @@ void NearbyPixelClustersAnalyzer::beginJob() { 110, -0.105, 0.995); + + TFileDirectory TkDistances = fs->mkdir("OtherTrackDistance"); + h_distClosestTrack = TkDistances.make( + "h_distClosestTrack", + "#DeltaR Distance of Closest track to the muon trajectory;#DeltaR distance; muon trajectories", + 100, + 0., + 5.); } // ------------ method called once each job just after ending the event loop ------------ @@ -505,6 +548,8 @@ void NearbyPixelClustersAnalyzer::fillDescriptions(edm::ConfigurationDescription desc.add("clusterCollection", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight")); desc.add("nearByClusterCollection", edm::InputTag("closebyPixelClusters")); desc.add("trajectoryInput", edm::InputTag("refittedTracks")); + desc.add("muonTracks", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight")); + desc.add("distToTrack", edm::InputTag("trackDistances")); desc.add("skimmedGeometryPath", "SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt"); descriptions.addWithDefaultLabel(desc); From d18d180ac196755fbf13121d24f09c670f6fc5dd Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 12 Apr 2021 23:17:40 +0200 Subject: [PATCH 5/6] use the iEvent.getHandle syntax and make TrackDistanceValueMapProducer a global EDProducer --- .../plugins/NearbyPixelClustersAnalyzer.cc | 6 ++---- .../plugins/TrackDistanceValueMapProducer.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc index 4a9abbe3dca80..2b09a71d41816 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc @@ -147,13 +147,11 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E const PixelClusterParameterEstimator* pixelCPE_ = &iSetup.getData(pixelCPEEsToken_); // get the muon track collection - edm::Handle> muonTrackCollectionHandle; - iEvent.getByToken(muonTracksToken_, muonTrackCollectionHandle); + const auto& muonTrackCollectionHandle = iEvent.getHandle(muonTracksToken_); auto const& muonTracks = *muonTrackCollectionHandle; // get the track distances - edm::Handle>> distancesToTrack; - iEvent.getByToken(distanceToken_, distancesToTrack); + const auto& distancesToTrack = iEvent.getHandle(distanceToken_); unsigned int nMuons = muonTracks.size(); for (unsigned int ij = 0; ij < nMuons; ij++) { diff --git a/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc index 35d0d983a4bec..89c3899012b98 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc @@ -19,7 +19,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -35,7 +35,7 @@ // class declaration // -class TrackDistanceValueMapProducer : public edm::stream::EDProducer<> { +class TrackDistanceValueMapProducer : public edm::global::EDProducer<> { public: explicit TrackDistanceValueMapProducer(const edm::ParameterSet&); ~TrackDistanceValueMapProducer() override = default; @@ -43,7 +43,7 @@ class TrackDistanceValueMapProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; // ----------member data --------------------------- // edToken @@ -67,15 +67,16 @@ TrackDistanceValueMapProducer::TrackDistanceValueMapProducer(const edm::Paramete // // ------------ method called to produce the data ------------ -void TrackDistanceValueMapProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void TrackDistanceValueMapProducer::produce(edm::StreamID streamID, + edm::Event& iEvent, + const edm::EventSetup& iSetup) const { using namespace edm; //======================================================= // Retrieve the muon Track information //======================================================= - edm::Handle> muonTrackCollectionHandle; - iEvent.getByToken(muonTracksToken_, muonTrackCollectionHandle); + const auto& muonTrackCollectionHandle = iEvent.getHandle(muonTracksToken_); if (!muonTrackCollectionHandle.isValid()) return; auto const& muonTracks = *muonTrackCollectionHandle; @@ -84,8 +85,7 @@ void TrackDistanceValueMapProducer::produce(edm::Event& iEvent, const edm::Event // Retrieve the general Track information //======================================================= - edm::Handle> allTrackCollectionHandle; - iEvent.getByToken(otherTracksToken_, allTrackCollectionHandle); + const auto& allTrackCollectionHandle = iEvent.getHandle(otherTracksToken_); if (!allTrackCollectionHandle.isValid()) return; auto const& allTracks = *allTrackCollectionHandle; From 3e850549308a326549898670e18b1aaac7b6a22e Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 13 Apr 2021 17:09:18 +0200 Subject: [PATCH 6/6] add the possibility to save only the first nth closest track distances --- .../plugins/NearbyPixelClustersAnalyzer.cc | 3 ++- .../plugins/TrackDistanceValueMapProducer.cc | 18 ++++++++++++++++-- .../TrackDistanceValueMapProducer_cfi.py | 5 +++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc index 2b09a71d41816..77adc0f8981e6 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc @@ -165,7 +165,8 @@ void NearbyPixelClustersAnalyzer::analyze(const edm::Event& iEvent, const edm::E double closestDR = 999.; for (const auto& distance : distances) { counter++; - LogDebug("NearbyPixelClustersAnalyzer") << "track: " << counter << " distance:" << distance << std::endl; + LogDebug("NearbyPixelClustersAnalyzer") + << "track: " << counter << " distance:" << std::sqrt(distance) << std::endl; if (distance < closestDR && distance > 0) { closestDR = distance; } diff --git a/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc index 89c3899012b98..8e94b94e8b3b6 100644 --- a/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc +++ b/Calibration/TkAlCaRecoProducers/plugins/TrackDistanceValueMapProducer.cc @@ -50,6 +50,9 @@ class TrackDistanceValueMapProducer : public edm::global::EDProducer<> { edm::EDGetTokenT> muonTracksToken_; edm::EDGetTokenT> otherTracksToken_; + // save in the event only up to the n-th closest + unsigned int nthClosestTrack_; + // putToken edm::EDPutTokenT>> distancesPutToken_; }; @@ -60,6 +63,7 @@ class TrackDistanceValueMapProducer : public edm::global::EDProducer<> { TrackDistanceValueMapProducer::TrackDistanceValueMapProducer(const edm::ParameterSet& iConfig) : muonTracksToken_(consumes>(iConfig.getParameter("muonTracks"))), otherTracksToken_(consumes>(iConfig.getParameter("allTracks"))), + nthClosestTrack_(iConfig.getParameter("saveUpToNthClosest")), distancesPutToken_(produces>>()) {} // @@ -106,9 +110,18 @@ void TrackDistanceValueMapProducer::produce(edm::StreamID streamID, for (unsigned int iAll = 0; iAll < Nall; iAll++) { const auto& recotrack = allTracks.ptrAt(iAll); const float dR2 = ::deltaR2(*muontrack, *recotrack); - v_dR2.push_back(dR2); + if (dR2 != 0.f) { // exclude the track itself + v_dR2.push_back(dR2); + } } - v2_dR2.push_back(v_dR2); + + // sort the tracks in ascending order of distance + std::sort(v_dR2.begin(), v_dR2.end(), [](const float& lhs, const float& rhs) { return lhs < rhs; }); + + // just copy the first nth + std::vector reduced_vdR2; + std::copy(v_dR2.begin(), v_dR2.begin() + nthClosestTrack_, std::back_inserter(reduced_vdR2)); + v2_dR2.push_back(reduced_vdR2); } //======================================================= @@ -129,6 +142,7 @@ void TrackDistanceValueMapProducer::fillDescriptions(edm::ConfigurationDescripti desc.add("muonTracks", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight")) ->setComment("the probe muon tracks"); desc.add("allTracks", edm::InputTag("generalTracks"))->setComment("all tracks in the event"); + desc.add("saveUpToNthClosest", 1)->setComment("save the distance only for the nth closest tracks"); descriptions.addWithDefaultLabel(desc); } diff --git a/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py b/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py index e724edc95a997..5a136fe4285a6 100644 --- a/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py +++ b/Calibration/TkAlCaRecoProducers/python/TrackDistanceValueMapProducer_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms TrackDistanceValueMapProducer = cms.EDProducer('TrackDistanceValueMapProducer', - muonTracks = cms.InputTag('muonTracks'), # input muon tracks - allTracks = cms.InputTag('generalTracks') # input generalTracks + muonTracks = cms.InputTag('muonTracks'), # input muon tracks + allTracks = cms.InputTag('generalTracks'), # input generalTracks + saveUpToNthClosest = cms.uint32(1) # save only closest track )