diff --git a/DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h b/DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h new file mode 100644 index 0000000000000..c6a73cd4bf54c --- /dev/null +++ b/DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h @@ -0,0 +1,60 @@ +#ifndef _DQM_SiTrackerPhase2_Phase2TrackerValidationUtil_h +#define _DQM_SiTrackerPhase2_Phase2TrackerValidationUtil_h +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include +#include + +namespace phase2tkutil { + + std::string getITHistoId(uint32_t det_id, const TrackerTopology* tTopo); + std::string getOTHistoId(uint32_t det_id, const TrackerTopology* tTopo); + + typedef dqm::reco::MonitorElement MonitorElement; + typedef dqm::reco::DQMStore DQMStore; + MonitorElement* book1DFromPSet(const edm::ParameterSet& hpars, const std::string& hname, DQMStore::IBooker& ibooker) { + MonitorElement* temp = nullptr; + if (hpars.getParameter("switch")) { + temp = ibooker.book1D(hpars.getParameter("name"), + hpars.getParameter("title"), + hpars.getParameter("NxBins"), + hpars.getParameter("xmin"), + hpars.getParameter("xmax")); + } + return temp; + } + + MonitorElement* book2DFromPSet(const edm::ParameterSet& hpars, const std::string& hname, DQMStore::IBooker& ibooker) { + MonitorElement* temp = nullptr; + if (hpars.getParameter("switch")) { + temp = ibooker.book2D(hpars.getParameter("name"), + hpars.getParameter("title"), + hpars.getParameter("NxBins"), + hpars.getParameter("xmin"), + hpars.getParameter("xmax"), + hpars.getParameter("NyBins"), + hpars.getParameter("ymin"), + hpars.getParameter("ymax")); + } + return temp; + } + + MonitorElement* bookProfile1DFromPSet(const edm::ParameterSet& hpars, + const std::string& hname, + DQMStore::IBooker& ibooker) { + MonitorElement* temp = nullptr; + if (hpars.getParameter("switch")) { + temp = ibooker.bookProfile(hpars.getParameter("name"), + hpars.getParameter("title"), + hpars.getParameter("NxBins"), + hpars.getParameter("xmin"), + hpars.getParameter("xmax"), + hpars.getParameter("ymin"), + hpars.getParameter("ymax")); + } + return temp; + } +} // namespace phase2tkutil +#endif diff --git a/DQM/SiTrackerPhase2/plugins/BuildFile.xml b/DQM/SiTrackerPhase2/plugins/BuildFile.xml index 5d433e7811726..546493369403a 100644 --- a/DQM/SiTrackerPhase2/plugins/BuildFile.xml +++ b/DQM/SiTrackerPhase2/plugins/BuildFile.xml @@ -1,12 +1,14 @@ + + - + diff --git a/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorRecHit.cc b/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorRecHit.cc new file mode 100644 index 0000000000000..a75e7f7b8072c --- /dev/null +++ b/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorRecHit.cc @@ -0,0 +1,479 @@ +// Package: Phase2ITMonitorRecHit +// Class: Phase2ITMonitorRecHit +// +/**\class Phase2ITMonitorRecHit Phase2ITMonitorRecHit.cc + Description: Plugin for Phase2 RecHit validation +*/ +// +// Author: Shubhi Parolia, Suvankar Roy Chowdhury +// Date: July 2020 +// +// system include files +#include +#include +#include +#include +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/GeometrySurface/interface/LocalError.h" +#include "DataFormats/GeometryVector/interface/LocalPoint.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonDetUnit/interface/TrackerGeomDet.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +// DQM Histograming +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h" + +class Phase2ITMonitorRecHit : public DQMEDAnalyzer { +public: + explicit Phase2ITMonitorRecHit(const edm::ParameterSet&); + ~Phase2ITMonitorRecHit() override; + void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; + void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; + void dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void fillITHistos(const edm::Event& iEvent); + void bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id, std::string& subdir); + + edm::ParameterSet config_; + std::string geomType_; + const edm::EDGetTokenT tokenRecHitsIT_; + const edm::ESGetToken geomToken_; + const edm::ESGetToken topoToken_; + const TrackerGeometry* tkGeom_ = nullptr; + const TrackerTopology* tTopo_ = nullptr; + static constexpr float million = 1e6; + MonitorElement* numberRecHits_; + MonitorElement* globalXY_barrel_; + MonitorElement* globalXY_endcap_; + MonitorElement* globalRZ_barrel_; + MonitorElement* globalRZ_endcap_; + + struct RecHitME { + MonitorElement* numberRecHits = nullptr; + MonitorElement* globalPosXY = nullptr; + MonitorElement* globalPosRZ = nullptr; + MonitorElement* localPosXY = nullptr; + MonitorElement* posX = nullptr; + MonitorElement* posY = nullptr; + MonitorElement* poserrX = nullptr; + MonitorElement* poserrY = nullptr; + MonitorElement* clusterSizeX = nullptr; + MonitorElement* clusterSizeY = nullptr; + }; + std::map layerMEs_; +}; + +Phase2ITMonitorRecHit::Phase2ITMonitorRecHit(const edm::ParameterSet& iConfig) + : config_(iConfig), + tokenRecHitsIT_(consumes(iConfig.getParameter("rechitsSrc"))), + geomToken_(esConsumes()), + topoToken_(esConsumes()) { + edm::LogInfo("Phase2ITMonitorRecHit") << ">>> Construct Phase2ITMonitorRecHit "; +} + +Phase2ITMonitorRecHit::~Phase2ITMonitorRecHit() { + edm::LogInfo("Phase2ITMonitorRecHit") << ">>> Destroy Phase2ITMonitorRecHit "; +} +// -- Analyze +void Phase2ITMonitorRecHit::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { fillITHistos(iEvent); } + +void Phase2ITMonitorRecHit::fillITHistos(const edm::Event& iEvent) { + // Get the RecHits + edm::Handle rechits; + iEvent.getByToken(tokenRecHitsIT_, rechits); + if (!rechits.isValid()) + return; + std::map nrechitLayerMap; + unsigned long int nTotrechitsinevt = 0; + // Loop over modules + for (const auto& DSViter : *rechits) { + // Get the detector id + unsigned int rawid(DSViter.detId()); + DetId detId(rawid); + // Get the geomdet + const GeomDetUnit* geomDetunit(tkGeom_->idToDetUnit(detId)); + if (!geomDetunit) + continue; + std::string key = phase2tkutil::getITHistoId(detId.rawId(), tTopo_); + nTotrechitsinevt += DSViter.size(); + if (nrechitLayerMap.find(key) == nrechitLayerMap.end()) { + nrechitLayerMap.emplace(key, DSViter.size()); + } else { + nrechitLayerMap[key] += DSViter.size(); + } + + //loop over rechits for a single detId + for (const auto& rechit : DSViter) { + LocalPoint lp = rechit.localPosition(); + Global3DPoint globalPos = geomDetunit->surface().toGlobal(lp); + //in mm + double gx = globalPos.x() * 10.; + double gy = globalPos.y() * 10.; + double gz = globalPos.z() * 10.; + double gr = globalPos.perp() * 10.; + //Fill global positions + if (geomDetunit->subDetector() == GeomDetEnumerators::SubDetector::P2PXB) { + globalXY_barrel_->Fill(gx, gy); + globalRZ_barrel_->Fill(gz, gr); + } else if (geomDetunit->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC) { + globalXY_endcap_->Fill(gx, gy); + globalRZ_endcap_->Fill(gz, gr); + } + //layer wise histo + if (layerMEs_[key].clusterSizeX) + layerMEs_[key].clusterSizeX->Fill(rechit.cluster()->sizeX()); + if (layerMEs_[key].clusterSizeY) + layerMEs_[key].clusterSizeY->Fill(rechit.cluster()->sizeY()); + if (layerMEs_[key].globalPosXY) + layerMEs_[key].globalPosXY->Fill(gx, gy); + if (layerMEs_[key].globalPosRZ) + layerMEs_[key].globalPosRZ->Fill(gz, gr); + if (layerMEs_[key].localPosXY) + layerMEs_[key].localPosXY->Fill(lp.x(), lp.y()); + if (layerMEs_[key].posX) + layerMEs_[key].posX->Fill(lp.x()); + if (layerMEs_[key].posY) + layerMEs_[key].posY->Fill(lp.y()); + float eta = geomDetunit->surface().toGlobal(lp).eta(); + if (layerMEs_[key].poserrX) + layerMEs_[key].poserrX->Fill(eta, million * rechit.localPositionError().xx()); + if (layerMEs_[key].poserrY) + layerMEs_[key].poserrY->Fill(eta, million * rechit.localPositionError().yy()); + } //end loop over rechits of a detId + } //End loop over DetSetVector + + //fill nRecHits per event + numberRecHits_->Fill(nTotrechitsinevt); + //fill nRecHit counter per layer + for (const auto& lme : nrechitLayerMap) + if (layerMEs_[lme.first].numberRecHits) + layerMEs_[lme.first].numberRecHits->Fill(lme.second); +} + +void Phase2ITMonitorRecHit::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { + edm::ESHandle geomHandle = iSetup.getHandle(geomToken_); + tkGeom_ = &(*geomHandle); + edm::ESHandle tTopoHandle = iSetup.getHandle(topoToken_); + tTopo_ = tTopoHandle.product(); +} + +void Phase2ITMonitorRecHit::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + std::string top_folder = config_.getParameter("TopFolderName"); + ibooker.cd(); + edm::LogInfo("Phase2ITMonitorRecHit") << " Booking Histograms in : " << top_folder; + std::string dir = top_folder; + ibooker.setCurrentFolder(dir); + std::stringstream HistoName; + //Global histos for IT + HistoName.str(""); + HistoName << "NumberRecHits"; + numberRecHits_ = phase2tkutil::book1DFromPSet( + config_.getParameter("GlobalNumberRecHits"), HistoName.str(), ibooker); + HistoName.str(""); + HistoName << "Global_Position_XY_IT_barrel"; + globalXY_barrel_ = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionXY_PXB"), HistoName.str(), ibooker); + HistoName.str(""); + HistoName << "Global_Position_RZ_IT_barrel"; + globalRZ_barrel_ = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionRZ_PXB"), HistoName.str(), ibooker); + HistoName.str(""); + HistoName << "Global_Position_XY_IT_endcap"; + globalXY_endcap_ = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionXY_PXEC"), HistoName.str(), ibooker); + HistoName.str(""); + HistoName << "Global_Position_RZ_IT_endcap"; + globalRZ_endcap_ = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionRZ_PXEC"), HistoName.str(), ibooker); + + //Now book layer wise histos + edm::ESWatcher theTkDigiGeomWatcher; + if (theTkDigiGeomWatcher.check(iSetup)) { + edm::ESHandle geomHandle = iSetup.getHandle(geomToken_); + for (auto const& det_u : tkGeom_->detUnits()) { + //Always check TrackerNumberingBuilder before changing this part + if (!(det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXB || + det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC)) + continue; + unsigned int detId_raw = det_u->geographicalId().rawId(); + edm::LogInfo("Phase2ITMonitorRecHit") << "Detid:" << detId_raw << "\tsubdet=" << det_u->subDetector() + << "\t key=" << phase2tkutil::getITHistoId(detId_raw, tTopo_) << std::endl; + bookLayerHistos(ibooker, detId_raw, dir); + } + } +} +// -- Book Layer Histograms +void Phase2ITMonitorRecHit::bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id, std::string& subdir) { + std::string key = phase2tkutil::getITHistoId(det_id, tTopo_); + if (key.empty()) + return; + if (layerMEs_.find(key) == layerMEs_.end()) { + ibooker.cd(); + RecHitME local_histos; + std::ostringstream histoName; + ibooker.setCurrentFolder(subdir + "/" + key); + edm::LogInfo("Phase2ITMonitorRecHit") << " Booking Histograms in : " << (subdir + "/" + key); + histoName.str(""); + histoName << "Number_RecHits"; + local_histos.numberRecHits = phase2tkutil::book1DFromPSet( + config_.getParameter("LocalNumberRecHits"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "RecHit_X"; + local_histos.posX = + phase2tkutil::book1DFromPSet(config_.getParameter("RecHitPosX"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "RecHit_Y"; + local_histos.posY = + phase2tkutil::book1DFromPSet(config_.getParameter("RecHitPosY"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "RecHit_X_error_Vs_eta"; + local_histos.poserrX = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("RecHitPosErrorX_Eta"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "RecHit_Y_error_Vs_eta"; + local_histos.poserrY = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("RecHitPosErrorY_Eta"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "Cluster_SizeX"; + local_histos.clusterSizeX = phase2tkutil::book1DFromPSet( + config_.getParameter("LocalClusterSizeX"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "Cluster_SizeY"; + local_histos.clusterSizeY = phase2tkutil::book1DFromPSet( + config_.getParameter("LocalClusterSizeY"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "Global_Position_XY"; + local_histos.globalPosXY = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionXY_perlayer"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "Global_Position_RZ"; + local_histos.globalPosRZ = phase2tkutil::book2DFromPSet( + config_.getParameter("GlobalPositionRZ_perlayer"), histoName.str(), ibooker); + + histoName.str(""); + histoName << "Local_Position_XY"; + local_histos.localPosXY = phase2tkutil::book2DFromPSet( + config_.getParameter("LocalPositionXY"), histoName.str(), ibooker); + layerMEs_.emplace(key, local_histos); + } +} + +void Phase2ITMonitorRecHit::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // rechitMonitorIT + edm::ParameterSetDescription desc; + { + edm::ParameterSetDescription psd0; + psd0.add("name", "NumberRecHits"); + psd0.add("title", "NumberRecHits;Number of RecHits;"); + psd0.add("xmin", 0.0); + psd0.add("switch", true); + psd0.add("xmax", 0.0); + psd0.add("NxBins", 50); + desc.add("GlobalNumberRecHits", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_RZ_IT_barrel"); + psd0.add("title", "Global_Position_RZ_IT_barrel;z [mm];r [mm]"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 1500); + psd0.add("NyBins", 300); + psd0.add("switch", true); + psd0.add("xmax", 3000.0); + psd0.add("xmin", -3000.0); + psd0.add("ymin", 0.0); + desc.add("GlobalPositionRZ_PXB", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_XY_IT_barrel"); + psd0.add("title", "Global_Position_XY_IT_barrel;x [mm];y [mm];"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 600); + psd0.add("NyBins", 600); + psd0.add("switch", true); + psd0.add("xmax", 300.0); + psd0.add("xmin", -300.0); + psd0.add("ymin", -300.0); + desc.add("GlobalPositionXY_PXB", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_RZ_IT_endcap"); + psd0.add("title", "Global_Position_RZ_IT_endcap;z [mm];r [mm]"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 1500); + psd0.add("NyBins", 300); + psd0.add("switch", true); + psd0.add("xmax", 3000.0); + psd0.add("xmin", -3000.0); + psd0.add("ymin", 0.0); + desc.add("GlobalPositionRZ_PXEC", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_XY_IT_endcap"); + psd0.add("title", "Global_Position_XY_IT_endcap; x [mm]; y [mm]"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 600); + psd0.add("NyBins", 600); + psd0.add("switch", true); + psd0.add("xmax", 300.0); + psd0.add("xmin", -300.0); + psd0.add("ymin", -300.0); + desc.add("GlobalPositionXY_PXEC", psd0); + } + //Per layer/ring histos + { + edm::ParameterSetDescription psd0; + psd0.add("name", "LocalNumberRecHits"); + psd0.add("title", "NumberRecHits;Number of RecHits;"); + psd0.add("xmin", 0.0); + psd0.add("switch", true); + psd0.add("xmax", 0.0); + psd0.add("NxBins", 50); + desc.add("LocalNumberRecHits", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_RZ"); + psd0.add("title", "Global_Position_RZ;z [mm];r [mm]"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 1500); + psd0.add("NyBins", 300); + psd0.add("switch", true); + psd0.add("xmax", 3000.0); + psd0.add("xmin", -3000.0); + psd0.add("ymin", 0.0); + desc.add("GlobalPositionRZ_perlayer", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Global_Position_XY"); + psd0.add("title", "Global_Position_XY;x [mm]; y[mm]"); + psd0.add("ymax", 300.0); + psd0.add("NxBins", 600); + psd0.add("NyBins", 600); + psd0.add("switch", true); + psd0.add("xmax", 300.0); + psd0.add("xmin", -300.0); + psd0.add("ymin", -300.0); + desc.add("GlobalPositionXY_perlayer", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Local_Position_XY"); + psd0.add("title", "Local_Position_XY; x; y"); + psd0.add("ymax", 0.0); + psd0.add("NxBins", 500); + psd0.add("NyBins", 500); + psd0.add("switch", true); + psd0.add("xmax", 0.0); + psd0.add("xmin", 0.0); + psd0.add("ymin", 0.0); + desc.add("LocalPositionXY", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Cluster_SizeX"); + psd0.add("title", "Cluster_SizeX; cluster size y;"); + psd0.add("xmin", -0.5); + psd0.add("switch", true); + psd0.add("xmax", 20.5); + psd0.add("NxBins", 21); + desc.add("LocalClusterSizeX", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Cluster_SizeY"); + psd0.add("title", "Cluster_SizeY;cluster size y;"); + psd0.add("xmin", -0.5); + psd0.add("switch", true); + psd0.add("xmax", 20.5); + psd0.add("NxBins", 21); + desc.add("LocalClusterSizeY", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "RecHit_X"); + psd0.add("title", "RecHit_X;RecHit position X dimension;"); + psd0.add("xmin", -2.5); + psd0.add("switch", true); + psd0.add("xmax", 2.5); + psd0.add("NxBins", 100); + desc.add("RecHitPosX", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "RecHit_Y"); + psd0.add("title", "RecHit_Y;RecHit position X dimension;"); + psd0.add("xmin", -2.5); + psd0.add("switch", true); + psd0.add("xmax", 2.5); + psd0.add("NxBins", 100); + desc.add("RecHitPosY", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "RecHit_X_error_Vs_eta"); + psd0.add("title", "RecHit_X_error_Vs_eta;#eta;x error #times 10^{6}"); + psd0.add("switch", true); + psd0.add("NxBins", 82); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymax", 10.0); + psd0.add("ymin", 0.); + desc.add("RecHitPosErrorX_Eta", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "RecHit_Y_error_Vs_eta"); + psd0.add("title", "RecHit_Y_error_Vs_eta;#eta;y error #times 10^{6}"); + psd0.add("switch", true); + psd0.add("NxBins", 82); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymax", 10.0); + psd0.add("ymin", 0.); + desc.add("RecHitPosErrorY_Eta", psd0); + } + desc.add("TopFolderName", "TrackerPhase2ITRecHit"); + desc.add("rechitsSrc", edm::InputTag("siPixelRecHits")); + descriptions.add("Phase2ITMonitorRecHit", desc); +} +//define this as a plug-in +DEFINE_FWK_MODULE(Phase2ITMonitorRecHit); diff --git a/DQM/SiTrackerPhase2/python/Phase2ITMonitorRecHit_cff.py b/DQM/SiTrackerPhase2/python/Phase2ITMonitorRecHit_cff.py new file mode 100644 index 0000000000000..a72ec04912847 --- /dev/null +++ b/DQM/SiTrackerPhase2/python/Phase2ITMonitorRecHit_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms +from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer +from DQM.SiTrackerPhase2.Phase2ITMonitorRecHit_cfi import Phase2ITMonitorRecHit + +rechitMonitorIT = Phase2ITMonitorRecHit.clone() diff --git a/DQM/SiTrackerPhase2/python/Phase2TrackerDQMFirstStep_cff.py b/DQM/SiTrackerPhase2/python/Phase2TrackerDQMFirstStep_cff.py index 9e0540cdc71f0..9ce8db692ceee 100644 --- a/DQM/SiTrackerPhase2/python/Phase2TrackerDQMFirstStep_cff.py +++ b/DQM/SiTrackerPhase2/python/Phase2TrackerDQMFirstStep_cff.py @@ -1,7 +1,8 @@ import FWCore.ParameterSet.Config as cms from DQM.SiTrackerPhase2.Phase2TrackerMonitorDigi_cff import * +from DQM.SiTrackerPhase2.Phase2ITMonitorRecHit_cff import * -trackerphase2DQMSource = cms.Sequence( - pixDigiMon - + otDigiMon +trackerphase2DQMSource = cms.Sequence( pixDigiMon + + otDigiMon + +rechitMonitorIT ) diff --git a/DQM/SiTrackerPhase2/src/BuildFile.xml b/DQM/SiTrackerPhase2/src/BuildFile.xml new file mode 100644 index 0000000000000..6e0fbf4cc057f --- /dev/null +++ b/DQM/SiTrackerPhase2/src/BuildFile.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/DQM/SiTrackerPhase2/src/TrackerPhase2DQMUtil.cc b/DQM/SiTrackerPhase2/src/TrackerPhase2DQMUtil.cc new file mode 100644 index 0000000000000..77523e0f06501 --- /dev/null +++ b/DQM/SiTrackerPhase2/src/TrackerPhase2DQMUtil.cc @@ -0,0 +1,46 @@ +#include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h" +std::string phase2tkutil::getITHistoId(uint32_t det_id, const TrackerTopology* tTopo) { + std::string Disc; + std::ostringstream fname1; + int layer = tTopo->getITPixelLayerNumber(det_id); + + if (layer < 0) + return ""; + if (layer < 100) { + fname1 << "Barrel/"; + fname1 << "Layer" << layer; + fname1 << ""; + } else { + int side = tTopo->pxfSide(det_id); + fname1 << "EndCap_Side" << side << "/"; + int disc = tTopo->pxfDisk(det_id); + Disc = (disc < 9) ? "EPix" : "FPix"; + fname1 << Disc << "/"; + int ring = tTopo->pxfBlade(det_id); + fname1 << "Ring" << ring; + } + return fname1.str(); +} + +std::string phase2tkutil::getOTHistoId(uint32_t det_id, const TrackerTopology* tTopo) { + std::string Disc; + std::ostringstream fname1; + int layer = tTopo->getOTLayerNumber(det_id); + + if (layer < 0) + return ""; + if (layer < 100) { + fname1 << "Barrel/"; + fname1 << "Layer" << layer; + fname1 << ""; + } else { + int side = tTopo->tidSide(det_id); + fname1 << "EndCap_Side" << side << "/"; + int disc = tTopo->tidWheel(det_id); + Disc = (disc < 3) ? "TEDD_1" : "TEDD_2"; + fname1 << Disc << "/"; + int ring = tTopo->tidRing(det_id); + fname1 << "Ring" << ring; + } + return fname1.str(); +} diff --git a/Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h b/Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h new file mode 100644 index 0000000000000..a3b492be26e36 --- /dev/null +++ b/Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h @@ -0,0 +1,11 @@ +#ifndef _Validation_SiTrackerPhase2V_TrackerPhase2ValidationUtil_h +#define _Validation_SiTrackerPhase2V_TrackerPhase2ValidationUtil_h +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/Track/interface/SimTrack.h" + +namespace phase2tkutil { + + bool isPrimary(const SimTrack& simTrk, const PSimHit* simHit); + +} // namespace phase2tkutil +#endif diff --git a/Validation/SiTrackerPhase2V/plugins/BuildFile.xml b/Validation/SiTrackerPhase2V/plugins/BuildFile.xml index eff5680c0ac29..611a15d830f3f 100644 --- a/Validation/SiTrackerPhase2V/plugins/BuildFile.xml +++ b/Validation/SiTrackerPhase2V/plugins/BuildFile.xml @@ -1,14 +1,27 @@ + - - + + + + + + + + + + + + + + - + - - + + diff --git a/Validation/SiTrackerPhase2V/plugins/Phase2ITValidateRecHit.cc b/Validation/SiTrackerPhase2V/plugins/Phase2ITValidateRecHit.cc new file mode 100644 index 0000000000000..e44f339b943c4 --- /dev/null +++ b/Validation/SiTrackerPhase2V/plugins/Phase2ITValidateRecHit.cc @@ -0,0 +1,495 @@ +// Package: Phase2ITValidateRecHit +// Class: Phase2ITValidateRecHit +// +/**\class Phase2ITValidateRecHit Phase2ITValidateRecHit.cc + Description: Plugin for Phase2 RecHit validation +*/ +// +// Author: Shubhi Parolia, Suvankar Roy Chowdhury +// Date: June 2020 +// +// system include files +#include +#include +#include +#include +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/GeometrySurface/interface/LocalError.h" +#include "DataFormats/GeometryVector/interface/LocalPoint.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonDetUnit/interface/TrackerGeomDet.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +//--- for SimHit association +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" +#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" +//DQM +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "DQMServices/Core/interface/MonitorElement.h" +#include "Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h" +#include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h" + +class Phase2ITValidateRecHit : public DQMEDAnalyzer { +public: + explicit Phase2ITValidateRecHit(const edm::ParameterSet&); + ~Phase2ITValidateRecHit() override; + void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; + void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; + void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void fillITHistos(const edm::Event& iEvent, + const TrackerHitAssociator& associateRecHit, + const std::vector>& simHits, + const std::map& selectedSimTrackMap); + + void bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id, std::string& subdir); + + edm::ParameterSet config_; + TrackerHitAssociator::Config trackerHitAssociatorConfig_; + const double simtrackminpt_; + std::string geomType_; + const edm::EDGetTokenT tokenRecHitsIT_; + const edm::EDGetTokenT simTracksToken_; + std::vector> simHitTokens_; + const edm::ESGetToken geomToken_; + const edm::ESGetToken topoToken_; + const TrackerGeometry* tkGeom_ = nullptr; + const TrackerTopology* tTopo_ = nullptr; + struct RecHitME { + MonitorElement* deltaX = nullptr; + MonitorElement* deltaY = nullptr; + MonitorElement* pullX = nullptr; + MonitorElement* pullY = nullptr; + MonitorElement* deltaX_eta = nullptr; + MonitorElement* deltaY_eta = nullptr; + MonitorElement* pullX_eta = nullptr; + MonitorElement* pullY_eta = nullptr; + //For rechits matched to primary simhits + MonitorElement* numberRecHitsprimary = nullptr; + MonitorElement* pullX_primary; + MonitorElement* pullY_primary; + MonitorElement* deltaX_primary; + MonitorElement* deltaY_primary; + }; + std::map layerMEs_; +}; + +Phase2ITValidateRecHit::Phase2ITValidateRecHit(const edm::ParameterSet& iConfig) + : config_(iConfig), + trackerHitAssociatorConfig_(iConfig, consumesCollector()), + simtrackminpt_(iConfig.getParameter("SimTrackMinPt")), + tokenRecHitsIT_(consumes(iConfig.getParameter("rechitsSrc"))), + simTracksToken_(consumes(iConfig.getParameter("simTracksSrc"))), + geomToken_(esConsumes()), + topoToken_(esConsumes()) { + edm::LogInfo("Phase2ITValidateRecHit") << ">>> Construct Phase2ITValidateRecHit "; + for (const auto& itName : config_.getParameter>("ROUList")) { + simHitTokens_.push_back(consumes>(edm::InputTag("g4SimHits", itName))); + } +} +// +Phase2ITValidateRecHit::~Phase2ITValidateRecHit() { + edm::LogInfo("Phase2ITValidateRecHit") << ">>> Destroy Phase2ITValidateRecHit "; +} + +void Phase2ITValidateRecHit::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + std::vector> simHits; + for (const auto& itoken : simHitTokens_) { + edm::Handle simHitHandle; + iEvent.getByToken(itoken, simHitHandle); + if (!simHitHandle.isValid()) + continue; + simHits.emplace_back(simHitHandle); + } + // Get the SimTracks and push them in a map of id, SimTrack + edm::Handle simTracks; + iEvent.getByToken(simTracksToken_, simTracks); + + std::map selectedSimTrackMap; + for (const auto& simTrackIt : *simTracks) { + if (simTrackIt.momentum().pt() > simtrackminpt_) { + selectedSimTrackMap.insert(std::make_pair(simTrackIt.trackId(), simTrackIt)); + } + } + TrackerHitAssociator associateRecHit(iEvent, trackerHitAssociatorConfig_); + fillITHistos(iEvent, associateRecHit, simHits, selectedSimTrackMap); +} + +void Phase2ITValidateRecHit::fillITHistos(const edm::Event& iEvent, + const TrackerHitAssociator& associateRecHit, + const std::vector>& simHits, + const std::map& selectedSimTrackMap) { + // Get the RecHits + edm::Handle rechits; + iEvent.getByToken(tokenRecHitsIT_, rechits); + if (!rechits.isValid()) + return; + std::map nrechitLayerMap_primary; + // Loop over modules + for (const auto& DSViter : *rechits) { + // Get the detector unit's id + unsigned int rawid(DSViter.detId()); + DetId detId(rawid); + // Get the geomdet + const GeomDetUnit* geomDetunit(tkGeom_->idToDetUnit(detId)); + if (!geomDetunit) + continue; + // determine the detector we are in + std::string key = phase2tkutil::getITHistoId(detId.rawId(), tTopo_); + if (nrechitLayerMap_primary.find(key) == nrechitLayerMap_primary.end()) { + nrechitLayerMap_primary.emplace(key, DSViter.size()); + } else { + nrechitLayerMap_primary[key] += DSViter.size(); + } + //loop over rechits for a single detId + for (const auto& rechit : DSViter) { + //GetSimHits + const std::vector& matchedId = associateRecHit.associateHitId(rechit); + const PSimHit* simhitClosest = nullptr; + float minx = 10000; + LocalPoint lp = rechit.localPosition(); + for (const auto& simHitCol : simHits) { + for (const auto& simhitIt : *simHitCol) { + if (detId.rawId() != simhitIt.detUnitId()) + continue; + for (const auto& mId : matchedId) { + if (simhitIt.trackId() == mId.first) { + if (!simhitClosest || abs(simhitIt.localPosition().x() - lp.x()) < minx) { + minx = abs(simhitIt.localPosition().x() - lp.x()); + simhitClosest = &simhitIt; + } + } + } + } //end loop over PSimhitcontainers + } //end loop over simHits + if (!simhitClosest) + continue; + auto simTrackIt(selectedSimTrackMap.find(simhitClosest->trackId())); + bool isPrimary = false; + //check if simhit is primary + if (simTrackIt != selectedSimTrackMap.end()) + isPrimary = phase2tkutil::isPrimary(simTrackIt->second, simhitClosest); + Local3DPoint simlp(simhitClosest->localPosition()); + const LocalError& lperr = rechit.localPositionError(); + double dx = lp.x() - simlp.x(); + double dy = lp.y() - simlp.y(); + double pullx = 999.; + double pully = 999.; + if (lperr.xx()) + pullx = (lp.x() - simlp.x()) / std::sqrt(lperr.xx()); + if (lperr.yy()) + pully = (lp.y() - simlp.y()) / std::sqrt(lperr.yy()); + float eta = geomDetunit->surface().toGlobal(lp).eta(); + layerMEs_[key].deltaX->Fill(dx); + layerMEs_[key].deltaY->Fill(dy); + layerMEs_[key].pullX->Fill(pullx); + layerMEs_[key].pullY->Fill(pully); + layerMEs_[key].deltaX_eta->Fill(eta, dx); + layerMEs_[key].deltaY_eta->Fill(eta, dy); + layerMEs_[key].pullX_eta->Fill(eta, pullx); + layerMEs_[key].pullY_eta->Fill(eta, pully); + if (isPrimary) { + layerMEs_[key].deltaX_primary->Fill(dx); + layerMEs_[key].deltaY_primary->Fill(dy); + layerMEs_[key].pullX_primary->Fill(pullx); + layerMEs_[key].pullY_primary->Fill(pully); + } else + nrechitLayerMap_primary[key]--; + } //end loop over rechits of a detId + } //End loop over DetSetVector + + //fill nRecHit counter per layer + for (const auto& lme : nrechitLayerMap_primary) { + layerMEs_[lme.first].numberRecHitsprimary->Fill(nrechitLayerMap_primary[lme.first]); + } +} + +void Phase2ITValidateRecHit::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { + edm::ESHandle geomHandle = iSetup.getHandle(geomToken_); + tkGeom_ = &(*geomHandle); + edm::ESHandle tTopoHandle = iSetup.getHandle(topoToken_); + tTopo_ = tTopoHandle.product(); +} +// +// -- Book Histograms +// +void Phase2ITValidateRecHit::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { + std::string top_folder = config_.getParameter("TopFolderName"); + edm::LogInfo("Phase2ITValidateRecHit") << " Booking Histograms in : " << top_folder; + edm::ESWatcher theTkDigiGeomWatcher; + if (theTkDigiGeomWatcher.check(iSetup)) { + for (auto const& det_u : tkGeom_->detUnits()) { + //Always check TrackerNumberingBuilder before changing this part + if (!(det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXB || + det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC)) + continue; + unsigned int detId_raw = det_u->geographicalId().rawId(); + bookLayerHistos(ibooker, detId_raw, top_folder); + } + } +} +// +void Phase2ITValidateRecHit::bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id, std::string& subdir) { + ibooker.cd(); + std::string key = phase2tkutil::getITHistoId(det_id, tTopo_); + if (key.empty()) + return; + if (layerMEs_.find(key) == layerMEs_.end()) { + ibooker.cd(); + RecHitME local_histos; + std::ostringstream histoName; + ibooker.setCurrentFolder(subdir + "/" + key); + edm::LogInfo("Phase2ITValidateRecHit") << " Booking Histograms in : " << (subdir + "/" + key); + histoName.str(""); + histoName << "Delta_X"; + local_histos.deltaX = + phase2tkutil::book1DFromPSet(config_.getParameter("DeltaX"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Delta_Y"; + local_histos.deltaY = + phase2tkutil::book1DFromPSet(config_.getParameter("DeltaY"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_X"; + local_histos.pullX = + phase2tkutil::book1DFromPSet(config_.getParameter("PullX"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_Y"; + local_histos.pullY = + phase2tkutil::book1DFromPSet(config_.getParameter("PullY"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Delta_X_vs_Eta"; + local_histos.deltaX_eta = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("DeltaX_eta"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Delta_Y_vs_Eta"; + local_histos.deltaY_eta = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("DeltaX_eta"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_X_vs_Eta"; + local_histos.pullX_eta = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("PullX_eta"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_Y_vs_Eta"; + local_histos.pullY_eta = phase2tkutil::bookProfile1DFromPSet( + config_.getParameter("PullY_eta"), histoName.str(), ibooker); + ibooker.setCurrentFolder(subdir + "/" + key + "/PrimarySimHits"); + //all histos for Primary particles + histoName.str(""); + histoName << "Number_RecHits_matched_PrimarySimTrack"; + local_histos.numberRecHitsprimary = phase2tkutil::book1DFromPSet( + config_.getParameter("nRecHits_primary"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Delta_X_SimHitPrimary"; + local_histos.deltaX_primary = phase2tkutil::book1DFromPSet( + config_.getParameter("DeltaX_primary"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Delta_Y_SimHitPrimary"; + local_histos.deltaY_primary = phase2tkutil::book1DFromPSet( + config_.getParameter("DeltaY_primary"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_X_SimHitPrimary"; + local_histos.pullX_primary = phase2tkutil::book1DFromPSet( + config_.getParameter("PullX_primary"), histoName.str(), ibooker); + histoName.str(""); + histoName << "Pull_Y_SimHitPrimary"; + local_histos.pullY_primary = phase2tkutil::book1DFromPSet( + config_.getParameter("PullY_primary"), histoName.str(), ibooker); + layerMEs_.emplace(key, local_histos); + } +} +void Phase2ITValidateRecHit::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // rechitValidIT + edm::ParameterSetDescription desc; + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_X"); + psd0.add("title", "Delta_X;RecHit resolution X dimension"); + psd0.add("xmin", -0.2); + psd0.add("switch", true); + psd0.add("xmax", 0.2); + psd0.add("NxBins", 100); + desc.add("DeltaX", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_Y"); + psd0.add("title", "Delta_Y;RecHit resolution Y dimension;"); + psd0.add("xmin", -0.2); + psd0.add("switch", true); + psd0.add("xmax", 0.2); + psd0.add("NxBins", 100); + desc.add("DeltaY", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_X"); + psd0.add("title", "Pull_X;pull x;"); + psd0.add("xmin", -4.0); + psd0.add("switch", true); + psd0.add("xmax", 4.0); + psd0.add("NxBins", 100); + desc.add("PullX", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_Y"); + psd0.add("title", "Pull_Y;pull y;"); + psd0.add("xmin", -4.0); + psd0.add("switch", true); + psd0.add("xmax", 4.0); + psd0.add("NxBins", 100); + desc.add("PullY", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_X_vs_Eta"); + psd0.add("title", "Delta_X_vs_Eta;#eta;#Delta x"); + psd0.add("ymax", 0.02); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -0.02); + desc.add("DeltaX_eta", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_Y_vs_Eta"); + psd0.add("title", "Delta_Y_vs_Eta;#eta;#Delta y"); + psd0.add("ymax", 0.02); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -0.02); + desc.add("DeltaY_eta", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_X_vs_Eta"); + psd0.add("title", "Pull_X_vs_Eta;#eta;pull x"); + psd0.add("ymax", 4.0); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -4.0); + desc.add("PullX_eta", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_Y_vs_Eta"); + psd0.add("title", "Pull_Y_vs_Eta;#eta;pull y"); + psd0.add("ymax", 4.0); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -4.0); + desc.add("PullY_eta", psd0); + } + //simhits primary + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Number_RecHits_matched_PrimarySimTrack"); + psd0.add("title", "Number of RecHits matched to primary SimTrack;;"); + psd0.add("xmin", 0.0); + psd0.add("switch", true); + psd0.add("xmax", 0.0); + psd0.add("NxBins", 100); + desc.add("nRecHits_primary", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_X_SimHitPrimary"); + psd0.add("title", "Delta_X_SimHitPrimary;#delta x;"); + psd0.add("xmin", -0.2); + psd0.add("switch", true); + psd0.add("xmax", 0.2); + psd0.add("NxBins", 100); + desc.add("DeltaX_primary", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Delta_Y_SimHitPrimary"); + psd0.add("title", "Delta_Y_SimHitPrimary;#Delta y;"); + psd0.add("xmin", -0.2); + psd0.add("switch", true); + psd0.add("xmax", 0.2); + psd0.add("NxBins", 100); + desc.add("DeltaY_primary", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_X_SimHitPrimary"); + psd0.add("title", "Pull_X_SimHitPrimary;pull x;"); + psd0.add("ymax", 4.0); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -4.0); + desc.add("PullX_primary", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("name", "Pull_Y_SimHitPrimary"); + psd0.add("title", "Pull_Y_SimHitPrimary;pull y;"); + psd0.add("ymax", 4.0); + psd0.add("NxBins", 82); + psd0.add("switch", true); + psd0.add("xmax", 4.1); + psd0.add("xmin", -4.1); + psd0.add("ymin", -4.0); + desc.add("PullY_primary", psd0); + } + //to be used in TrackerHitAssociator + desc.add("associatePixel", true); + desc.add("associateStrip", false); + desc.add("usePhase2Tracker", true); + desc.add("associateRecoTracks", false); + desc.add("associateHitbySimTrack", true); + desc.add("pixelSimLinkSrc", edm::InputTag("simSiPixelDigis", "Pixel")); + desc.add>("ROUList", + { + "TrackerHitsPixelBarrelLowTof", + "TrackerHitsPixelBarrelHighTof", + "TrackerHitsPixelEndcapLowTof", + "TrackerHitsPixelEndcapHighTof", + }); + // + desc.add("simTracksSrc", edm::InputTag("g4SimHits")); + desc.add("SimVertexSource", edm::InputTag("g4SimHits")); + desc.add("SimTrackMinPt", 2.0); + desc.add("rechitsSrc", edm::InputTag("siPixelRecHits")); + desc.add("TopFolderName", "TrackerPhase2ITRecHitV"); + desc.add("Verbosity", false); + descriptions.add("Phase2ITValidateRecHit", desc); +} +//define this as a plug-in +DEFINE_FWK_MODULE(Phase2ITValidateRecHit); diff --git a/Validation/SiTrackerPhase2V/python/Phase2ITValidateRecHit_cff.py b/Validation/SiTrackerPhase2V/python/Phase2ITValidateRecHit_cff.py new file mode 100644 index 0000000000000..affc43237f52c --- /dev/null +++ b/Validation/SiTrackerPhase2V/python/Phase2ITValidateRecHit_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms +from Validation.SiTrackerPhase2V.Phase2ITValidateRecHit_cfi import Phase2ITValidateRecHit +rechitValidIT = Phase2ITValidateRecHit.clone() + +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(rechitValidIT, + pixelSimLinkSrc = "mixData:PixelDigiSimLink", +) diff --git a/Validation/SiTrackerPhase2V/python/Phase2TrackerValidationFirstStep_cff.py b/Validation/SiTrackerPhase2V/python/Phase2TrackerValidationFirstStep_cff.py index 47cfa29845a05..49948e6688d0d 100644 --- a/Validation/SiTrackerPhase2V/python/Phase2TrackerValidationFirstStep_cff.py +++ b/Validation/SiTrackerPhase2V/python/Phase2TrackerValidationFirstStep_cff.py @@ -1,4 +1,7 @@ import FWCore.ParameterSet.Config as cms from Validation.SiTrackerPhase2V.Phase2TrackerValidateDigi_cff import * - -trackerphase2ValidationSource = cms.Sequence(pixDigiValid + otDigiValid ) +from Validation.SiTrackerPhase2V.Phase2ITValidateRecHit_cff import * +trackerphase2ValidationSource = cms.Sequence(pixDigiValid + + otDigiValid + + rechitValidIT +) diff --git a/Validation/SiTrackerPhase2V/src/BuildFile.xml b/Validation/SiTrackerPhase2V/src/BuildFile.xml new file mode 100644 index 0000000000000..f03a5a7df2841 --- /dev/null +++ b/Validation/SiTrackerPhase2V/src/BuildFile.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Validation/SiTrackerPhase2V/src/TrackerPhase2ValidationUtil.cc b/Validation/SiTrackerPhase2V/src/TrackerPhase2ValidationUtil.cc new file mode 100644 index 0000000000000..66d8867a57f4f --- /dev/null +++ b/Validation/SiTrackerPhase2V/src/TrackerPhase2ValidationUtil.cc @@ -0,0 +1,10 @@ +#include "Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h" +bool phase2tkutil::isPrimary(const SimTrack& simTrk, const PSimHit* simHit) { + bool retval = false; + unsigned int trkId = simTrk.trackId(); + if (trkId != simHit->trackId()) + return retval; + int vtxIndex = simTrk.vertIndex(); + int ptype = simHit->processType(); + return ((vtxIndex == 0) && (ptype == 0)); +} diff --git a/Validation/SiTrackerPhase2V/test/ValidateRecHit_TrackerPhase2Standalone_cfg.py b/Validation/SiTrackerPhase2V/test/ValidateRecHit_TrackerPhase2Standalone_cfg.py new file mode 100644 index 0000000000000..2eb196b01c90e --- /dev/null +++ b/Validation/SiTrackerPhase2V/test/ValidateRecHit_TrackerPhase2Standalone_cfg.py @@ -0,0 +1,98 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Era_Phase2_cff import Phase2 +process = cms.Process('recHitTest',Phase2) + +#process.MessageLogger = cms.Service("MessageLogger", +# debugModules = cms.untracked.vstring('siPixelRawData'), +# destinations = cms.untracked.vstring("cout"), +# cout = cms.untracked.PSet( +# threshold = cms.untracked.string('ERROR') +# ) +#) +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.RecoSim_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T15', '') + +# list of files + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:/eos/cms/store/relval/CMSSW_11_2_0_pre5/RelValTTbar_14TeV/GEN-SIM-RECO/PU25ns_110X_mcRun4_realistic_v3_2026D49PU200-v1/20000/CA4DC8DF-AAEC-DA43-931B-BF234D979A9D.root' + ) +) +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string('$Revision: 1.19 $'), + annotation = cms.untracked.string('step1 nevts:1'), + name = cms.untracked.string('Applications') +) +# Output definition + +process.DQMoutput = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + outputCommands = process.DQMEventContent.outputCommands, + fileName = cms.untracked.string('step1_rechitTest.root'), + dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('') + ) +) + +process.load('RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi') +process.load('RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEESProducer_cfi') +process.load('RecoLocalTracker.Phase2TrackerRecHits.Phase2TrackerRecHits_cfi') +process.load('RecoLocalTracker.SiPixelRecHits.SiPixelRecHits_cfi') +#process.rechits_step = cms.Path(process.siPhase2RecHits * process.siPixelRecHits) +process.rechits_step = cms.Path(process.siPixelRecHits) + + +#Setup FWK for multithreaded +process.options.numberOfThreads=cms.untracked.uint32(8) +process.options.numberOfStreams=cms.untracked.uint32(0) +process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1) + +#process.load('Validation.SiTrackerPhase2V.Phase2OTValidateRecHit_cfi') +process.load('Validation.SiTrackerPhase2V.Phase2ITValidateRecHit_cfi') + +#process.rechitval_seq = cms.Sequence(process.rechitValidIT) + +process.load('DQMServices.Components.DQMEventInfo_cfi') +#process.dqmEnv.subSystemFolder = cms.untracked.string('Ph2Tk') +process.dqm_comm = cms.Sequence(process.dqmEnv) + +# Path and EndPath definitions +process.endjob_step = cms.EndPath(process.endOfProcess) +process.DQMoutput_step = cms.EndPath(process.DQMoutput) +''' +process.Timing = cms.Service("Timing", + summaryOnly = cms.untracked.bool(False), + useJobReport = cms.untracked.bool(True) +) + +process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck", + ignoreTotal = cms.untracked.int32(1), + moduleMemorySummary = cms.untracked.bool(True) +) +''' +process.p = cms.Path(process.siPixelRecHits + #*process.siPhase2RecHits + * process.rechitValidIT + #* process.rechitValidOT + * process.dqm_comm )