From 33293114b51d14236cbb171f2412f0ff28854c5f Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 12 Apr 2021 19:49:48 +0200 Subject: [PATCH] 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);