diff --git a/Alignment/OfflineValidation/interface/TrackerValidationVariables.h b/Alignment/OfflineValidation/interface/TrackerValidationVariables.h index 2030a7e91b3e9..d656aae091d2a 100644 --- a/Alignment/OfflineValidation/interface/TrackerValidationVariables.h +++ b/Alignment/OfflineValidation/interface/TrackerValidationVariables.h @@ -81,10 +81,12 @@ class TrackerValidationVariables void fillTrackQuantities(const edm::Event&, const edm::EventSetup&, std::vector & v_avtrackout); - - // need the following method for MonitorTrackResiduals in DQM/TrackerMonitorTrack - void fillHitQuantities(const edm::Event&, std::vector & v_avhitout); - + // all Tracks are passed to the trackFilter first, and only processed if it returns true. + void fillTrackQuantities(const edm::Event& event, + const edm::EventSetup& eventSetup, + std::function trackFilter, + std::vector & v_avtrackout); + private: edm::EDGetTokenT > trajCollectionToken_; diff --git a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc index a46e7ad9f945d..647b43ef8302a 100644 --- a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc +++ b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc @@ -309,6 +309,18 @@ void TrackerValidationVariables::fillTrackQuantities(const edm::Event& event, const edm::EventSetup& eventSetup, std::vector & v_avtrackout) +{ + fillTrackQuantities(event, + eventSetup, + [](const reco::Track&) -> bool { return true; }, + v_avtrackout); +} + +void +TrackerValidationVariables::fillTrackQuantities(const edm::Event& event, + const edm::EventSetup& eventSetup, + std::function trackFilter, + std::vector & v_avtrackout) { edm::ESHandle magneticField; eventSetup.get().get(magneticField); @@ -327,6 +339,8 @@ TrackerValidationVariables::fillTrackQuantities(const edm::Event& event, trajectory = &(*(*iPair).key); track = &(*(*iPair).val); + if (!trackFilter(*track)) continue; + AVTrackStruct trackStruct; trackStruct.p = track->p(); @@ -355,18 +369,3 @@ TrackerValidationVariables::fillTrackQuantities(const edm::Event& event, } } -void -TrackerValidationVariables::fillHitQuantities(const edm::Event& event, std::vector & v_avhitout) -{ - edm::Handle > trajCollectionHandle; - event.getByToken(trajCollectionToken_, trajCollectionHandle); - - LogDebug("TrackerValidationVariables") << "trajColl->size(): " << trajCollectionHandle->size() ; - - for (std::vector::const_iterator it = trajCollectionHandle->begin(), itEnd = trajCollectionHandle->end(); - it!=itEnd; - ++it) { - - fillHitQuantities(&(*it), v_avhitout); - } -} diff --git a/DQM/SiPixelCommon/python/SiPixelOfflineDQM_source_cff.py b/DQM/SiPixelCommon/python/SiPixelOfflineDQM_source_cff.py index 6d222bb156be6..5075eec76fb96 100644 --- a/DQM/SiPixelCommon/python/SiPixelOfflineDQM_source_cff.py +++ b/DQM/SiPixelCommon/python/SiPixelOfflineDQM_source_cff.py @@ -31,6 +31,7 @@ from DQM.SiPixelMonitorTrack.SiPixelMonitorEfficiency_cfi import * SiPixelHitEfficiencySource.saveFile = False SiPixelHitEfficiencySource.trajectoryInput = cms.InputTag('generalTracks') +from DQM.TrackerMonitorTrack.SiPixelMonitorTrackResiduals_cfi import * ##online/offline #RawDataErrors @@ -141,7 +142,7 @@ #FED integrity from DQM.SiPixelMonitorRawData.SiPixelMonitorHLT_cfi import * -siPixelOfflineDQM_source = cms.Sequence(SiPixelHLTSource + SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource + SiPixelHitEfficiencySource + dqmInfo) +siPixelOfflineDQM_source = cms.Sequence(SiPixelHLTSource + SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource + SiPixelHitEfficiencySource + SiPixelMonitorTrackResiduals + dqmInfo) siPixelOfflineDQM_cosmics_source = cms.Sequence(SiPixelHLTSource + SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource_Cosmics + dqmInfo) diff --git a/DQM/SiPixelCommon/python/SiPixelP5DQM_source_cff.py b/DQM/SiPixelCommon/python/SiPixelP5DQM_source_cff.py index 4ee649abae0c4..16fe0955497ed 100644 --- a/DQM/SiPixelCommon/python/SiPixelP5DQM_source_cff.py +++ b/DQM/SiPixelCommon/python/SiPixelP5DQM_source_cff.py @@ -39,6 +39,7 @@ from DQM.SiPixelMonitorTrack.SiPixelMonitorEfficiency_cfi import * SiPixelHitEfficiencySource.saveFile = False SiPixelHitEfficiencySource.trajectoryInput = cms.InputTag('generalTracks') +from DQM.TrackerMonitorTrack.SiPixelMonitorTrackResiduals_cfi import * ##online/offline #RawDataErrors @@ -125,7 +126,7 @@ from DQM.SiPixelMonitorRawData.SiPixelMonitorHLT_cfi import * SiPixelHLTSource.DirName = cms.untracked.string('Pixel/FEDIntegrity/') -siPixelP5DQM_source = cms.Sequence(SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource + SiPixelHitEfficiencySource + dqmInfo) +siPixelP5DQM_source = cms.Sequence(SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource + SiPixelHitEfficiencySource + SiPixelMonitorTrackResiduals + dqmInfo) siPixelP5DQM_cosmics_source = cms.Sequence(SiPixelRawDataErrorSource + SiPixelDigiSource + SiPixelRecHitSource + SiPixelClusterSource + SiPixelTrackResidualSource_Cosmics + dqmInfo) diff --git a/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_Cosmic_cff.py b/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_Cosmic_cff.py index 7b11d435645d0..23024115f0802 100644 --- a/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_Cosmic_cff.py +++ b/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_Cosmic_cff.py @@ -82,15 +82,18 @@ import DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi MonitorTrackResiduals_cosmicTk = DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi.MonitorTrackResiduals.clone() MonitorTrackResiduals_cosmicTk.trajectoryInput = 'cosmictrackfinderP5' +MonitorTrackResiduals_cosmicTk.Tracks = 'cosmictrackfinderP5' MonitorTrackResiduals_cosmicTk.Mod_On = False # Clone for CKF Tracks MonitorTrackResiduals_ckf = DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi.MonitorTrackResiduals.clone() MonitorTrackResiduals_ckf.trajectoryInput = 'ctfWithMaterialTracksP5' +MonitorTrackResiduals_ckf.Tracks = 'ctfWithMaterialTracksP5' MonitorTrackResiduals_ckf.Mod_On = False # Clone for Road Search Tracks #import DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi #MonitorTrackResiduals_rs = DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi.MonitorTrackResiduals.clone() #MonitorTrackResiduals_rs.trajectoryInput = 'rsWithMaterialTracksP5' +#MonitorTrackResiduals_rs.Tracks = 'rsWithMaterialTracksP5' #MonitorTrackResiduals_rs.Mod_On = False # TrackingMonitor #### diff --git a/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_cff.py b/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_cff.py index c925d8a6193be..5c7c1decfb374 100644 --- a/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_cff.py +++ b/DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_cff.py @@ -94,6 +94,7 @@ ### TrackerMonitorTrack defined and used only for MinimumBias #### from DQM.TrackerMonitorTrack.MonitorTrackResiduals_cfi import * MonitorTrackResiduals.trajectoryInput = 'generalTracks' +MonitorTrackResiduals.Tracks = 'generalTracks' MonitorTrackResiduals.Mod_On = False MonitorTrackResiduals.andOr = cms.bool( False ) MonitorTrackResiduals.dbLabel = cms.string("SiStripDQMTrigger") diff --git a/DQM/TrackerMonitorTrack/README.md b/DQM/TrackerMonitorTrack/README.md index 3197f68afb36d..0c19dd781a6ad 100644 --- a/DQM/TrackerMonitorTrack/README.md +++ b/DQM/TrackerMonitorTrack/README.md @@ -1,94 +1,63 @@ ### Purpose -This code generates the `HitResiduals` and `NormalizedHitResiduals` histograms. +This code generates the `HitResiduals` and `NormalizedHitResiduals` histograms for SiStip and SiPixel. The source file `MonitorTrackResiduals.cc` actually implements two modules (using a template parameter) from the same code, such that the SiStrip and SiPixel configurations can be handled independently. The disadvantage of this is that every track has to be handled twice (which might hurt performance). ### Data displayed -The data shown in the histograms is computed by the Alignment/OfflineValidation code. It is computed for SiPixel and SiStrip in x- and y-direction (resXprime, resYprime values), however for the strips only the x-residual is relevant. +The data shown in the histograms is computed by the Alignment/OfflineValidation code. It is computed for SiPixel and SiStrip in x- and y-direction (resXprime, resYprime values), however for the strips only the x-residual is relevant. Simple cuts on pT and the significance of dxy are applied to only select good tracks. Additionally, a trigger can be applied. ### Options -* `MonitorTrackResiduals.Mod_On` setting this to `True` will generate plots for every module. By default, only one plot per layer and wheel/disk is generated. +`MonitorTrackResiduals` (for SiStrip) and `SiPixelMonitorTrackResiduals` (for SiPixel) accept the same options. -### Bugs - -* The plots for pixel disks appear hidden in the shell and half cylinder folders, even though they cover the full layer/disk. +* `Mod_On` setting this to `True` will generate plots for every module. By default, only one plot per layer and wheel/disk is generated. +* `Tracks` the sort of tracks to be used. (Note that `TrackerValidationVariables.cc` uses `trajcetoryInput` as well, but this should not affect this module.) +* The usual parameters of `GenericTriggerEventFlag`. ### Currently generated histograms -* `Pixel/Barrel/Shell_mI/Layer_1/HitResiduals_BPIX__Layer__1` -* `Pixel/Barrel/Shell_mI/Layer_1/HitResiduals_BPIX__Layer__1_Y` -* `Pixel/Barrel/Shell_mI/Layer_2/HitResiduals_BPIX__Layer__2` -* `Pixel/Barrel/Shell_mI/Layer_2/HitResiduals_BPIX__Layer__2_Y` -* `Pixel/Barrel/Shell_mI/Layer_3/HitResiduals_BPIX__Layer__3` -* `Pixel/Barrel/Shell_mI/Layer_3/HitResiduals_BPIX__Layer__3_Y` -* `Pixel/Endcap/HalfCylinder_pI/Disk_1/HitResiduals_FPIX__wheel__1` -* `Pixel/Endcap/HalfCylinder_pI/Disk_1/HitResiduals_FPIX__wheel__1_Y` -* `Pixel/Endcap/HalfCylinder_pI/Disk_2/HitResiduals_FPIX__wheel__2` -* `Pixel/Endcap/HalfCylinder_pI/Disk_2/HitResiduals_FPIX__wheel__2_Y` -* `Pixel/Endcap/HalfCylinder_mI/Disk_1/HitResiduals_FPIX__wheel__1` -* `Pixel/Endcap/HalfCylinder_mI/Disk_1/HitResiduals_FPIX__wheel__1_Y` -* `Pixel/Endcap/HalfCylinder_mI/Disk_2/HitResiduals_FPIX__wheel__2` -* `Pixel/Endcap/HalfCylinder_mI/Disk_2/HitResiduals_FPIX__wheel__2_Y` +* `Pixel/Barrel/HitResidualsX_L1` +* `Pixel/Barrel/HitResidualsX_L2` +* `Pixel/Barrel/HitResidualsX_L3` +* `Pixel/Barrel/HitResidualsY_L1` +* `Pixel/Barrel/HitResidualsY_L2` +* `Pixel/Barrel/HitResidualsY_L3` +* `Pixel/Endcap/HitResidualsX_Dm1` +* `Pixel/Endcap/HitResidualsX_Dm2` +* `Pixel/Endcap/HitResidualsX_Dp1` +* `Pixel/Endcap/HitResidualsX_Dp2` +* `Pixel/Endcap/HitResidualsY_Dm1` +* `Pixel/Endcap/HitResidualsY_Dm2` +* `Pixel/Endcap/HitResidualsY_Dp1` +* `Pixel/Endcap/HitResidualsY_Dp2` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_1/HitResiduals_TEC__wheel__1` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_2/HitResiduals_TEC__wheel__2` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_3/HitResiduals_TEC__wheel__3` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_4/HitResiduals_TEC__wheel__4` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_5/HitResiduals_TEC__wheel__5` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_6/HitResiduals_TEC__wheel__6` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_7/HitResiduals_TEC__wheel__7` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_8/HitResiduals_TEC__wheel__8` +* `SiStrip/MechanicalView/TEC/MINUS/wheel_9/HitResiduals_TEC__wheel__9` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_1/HitResiduals_TEC__wheel__1` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_2/HitResiduals_TEC__wheel__2` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_3/HitResiduals_TEC__wheel__3` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_4/HitResiduals_TEC__wheel__4` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_5/HitResiduals_TEC__wheel__5` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_6/HitResiduals_TEC__wheel__6` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_7/HitResiduals_TEC__wheel__7` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_8/HitResiduals_TEC__wheel__8` +* `SiStrip/MechanicalView/TEC/PLUS/wheel_9/HitResiduals_TEC__wheel__9` * `SiStrip/MechanicalView/TIB/layer_1/HitResiduals_TIB__Layer__1` -* `SiStrip/MechanicalView/TIB/layer_1/HitResiduals_TIB__Layer__1_Y` * `SiStrip/MechanicalView/TIB/layer_2/HitResiduals_TIB__Layer__2` -* `SiStrip/MechanicalView/TIB/layer_2/HitResiduals_TIB__Layer__2_Y` * `SiStrip/MechanicalView/TIB/layer_3/HitResiduals_TIB__Layer__3` -* `SiStrip/MechanicalView/TIB/layer_3/HitResiduals_TIB__Layer__3_Y` * `SiStrip/MechanicalView/TIB/layer_4/HitResiduals_TIB__Layer__4` -* `SiStrip/MechanicalView/TIB/layer_4/HitResiduals_TIB__Layer__4_Y` * `SiStrip/MechanicalView/TID/PLUS/wheel_1/HitResiduals_TID__wheel__1` -* `SiStrip/MechanicalView/TID/PLUS/wheel_1/HitResiduals_TID__wheel__1_Y` * `SiStrip/MechanicalView/TID/PLUS/wheel_2/HitResiduals_TID__wheel__2` -* `SiStrip/MechanicalView/TID/PLUS/wheel_2/HitResiduals_TID__wheel__2_Y` * `SiStrip/MechanicalView/TID/PLUS/wheel_3/HitResiduals_TID__wheel__3` -* `SiStrip/MechanicalView/TID/PLUS/wheel_3/HitResiduals_TID__wheel__3_Y` * `SiStrip/MechanicalView/TOB/layer_1/HitResiduals_TOB__Layer__1` -* `SiStrip/MechanicalView/TOB/layer_1/HitResiduals_TOB__Layer__1_Y` * `SiStrip/MechanicalView/TOB/layer_2/HitResiduals_TOB__Layer__2` -* `SiStrip/MechanicalView/TOB/layer_2/HitResiduals_TOB__Layer__2_Y` * `SiStrip/MechanicalView/TOB/layer_3/HitResiduals_TOB__Layer__3` -* `SiStrip/MechanicalView/TOB/layer_3/HitResiduals_TOB__Layer__3_Y` * `SiStrip/MechanicalView/TOB/layer_4/HitResiduals_TOB__Layer__4` -* `SiStrip/MechanicalView/TOB/layer_4/HitResiduals_TOB__Layer__4_Y` * `SiStrip/MechanicalView/TOB/layer_5/HitResiduals_TOB__Layer__5` -* `SiStrip/MechanicalView/TOB/layer_5/HitResiduals_TOB__Layer__5_Y` * `SiStrip/MechanicalView/TOB/layer_6/HitResiduals_TOB__Layer__6` -* `SiStrip/MechanicalView/TOB/layer_6/HitResiduals_TOB__Layer__6_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_1/HitResiduals_TEC__wheel__1` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_1/HitResiduals_TEC__wheel__1_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_2/HitResiduals_TEC__wheel__2` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_2/HitResiduals_TEC__wheel__2_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_3/HitResiduals_TEC__wheel__3` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_3/HitResiduals_TEC__wheel__3_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_4/HitResiduals_TEC__wheel__4` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_4/HitResiduals_TEC__wheel__4_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_5/HitResiduals_TEC__wheel__5` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_5/HitResiduals_TEC__wheel__5_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_6/HitResiduals_TEC__wheel__6` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_6/HitResiduals_TEC__wheel__6_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_7/HitResiduals_TEC__wheel__7` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_7/HitResiduals_TEC__wheel__7_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_8/HitResiduals_TEC__wheel__8` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_8/HitResiduals_TEC__wheel__8_Y` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_9/HitResiduals_TEC__wheel__9` -* `SiStrip/MechanicalView/TEC/PLUS/wheel_9/HitResiduals_TEC__wheel__9_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_1/HitResiduals_TEC__wheel__1` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_1/HitResiduals_TEC__wheel__1_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_2/HitResiduals_TEC__wheel__2` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_2/HitResiduals_TEC__wheel__2_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_3/HitResiduals_TEC__wheel__3` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_3/HitResiduals_TEC__wheel__3_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_4/HitResiduals_TEC__wheel__4` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_4/HitResiduals_TEC__wheel__4_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_5/HitResiduals_TEC__wheel__5` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_5/HitResiduals_TEC__wheel__5_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_6/HitResiduals_TEC__wheel__6` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_6/HitResiduals_TEC__wheel__6_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_7/HitResiduals_TEC__wheel__7` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_7/HitResiduals_TEC__wheel__7_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_8/HitResiduals_TEC__wheel__8` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_8/HitResiduals_TEC__wheel__8_Y` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_9/HitResiduals_TEC__wheel__9` -* `SiStrip/MechanicalView/TEC/MINUS/wheel_9/HitResiduals_TEC__wheel__9_Y` diff --git a/DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.h b/DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.h index 22c6324ab6f22..ee35884a9da7f 100644 --- a/DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.h +++ b/DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.h @@ -22,31 +22,30 @@ Monitoring source for track residuals on each detector module #include "FWCore/Framework/interface/Run.h" #include #include "Alignment/OfflineValidation/interface/TrackerValidationVariables.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" class MonitorElement; class DQMStore; class GenericTriggerEventFlag; namespace edm { class Event; } -class MonitorTrackResiduals : public DQMEDAnalyzer { +enum TrackerType { + TRACKERTYPE_STRIP, TRACKERTYPE_PIXEL +}; + +template +class MonitorTrackResidualsBase : public DQMEDAnalyzer { public: // constructors and EDAnalyzer Methods - explicit MonitorTrackResiduals(const edm::ParameterSet&); - ~MonitorTrackResiduals(); + explicit MonitorTrackResidualsBase(const edm::ParameterSet&); + ~MonitorTrackResidualsBase(); void dqmBeginRun(const edm::Run& , const edm::EventSetup& ) ; - virtual void endRun(const edm::Run&, const edm::EventSetup&); - virtual void beginJob(void); - virtual void endJob(void); virtual void analyze(const edm::Event&, const edm::EventSetup&); void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; - // Own methods - void createMEs( DQMStore::IBooker & , const edm::EventSetup&); private: - DQMStore * dqmStore_; - edm::ParameterSet conf_; - edm::ParameterSet Parameters; - + // Own methods + void createMEs( DQMStore::IBooker & , const edm::EventSetup&); std::pair findSubdetAndLayer(uint32_t ModuleID, const TrackerTopology* tTopo); struct HistoPair { @@ -63,9 +62,19 @@ class MonitorTrackResiduals : public DQMEDAnalyzer { HistoSet m_SubdetLayerResiduals; HistoSet m_ModuleResiduals; + edm::ParameterSet conf_; + edm::ParameterSet Parameters; + edm::EDGetTokenT offlinePrimaryVerticesToken_; + unsigned long long m_cacheID_; bool ModOn; + GenericTriggerEventFlag* genTriggerEventFlag_; TrackerValidationVariables avalidator_; }; + +// Naming is for legacy reasons. +typedef MonitorTrackResidualsBase MonitorTrackResiduals; +typedef MonitorTrackResidualsBase SiPixelMonitorTrackResiduals; + #endif diff --git a/DQM/TrackerMonitorTrack/python/MonitorTrackResiduals_cfi.py b/DQM/TrackerMonitorTrack/python/MonitorTrackResiduals_cfi.py index 30df52176ee23..387ac900122a6 100644 --- a/DQM/TrackerMonitorTrack/python/MonitorTrackResiduals_cfi.py +++ b/DQM/TrackerMonitorTrack/python/MonitorTrackResiduals_cfi.py @@ -5,7 +5,6 @@ OutputMEsInRootFile = cms.bool(False), # should histogramms on module level be booked and filled? Mod_On = cms.bool(True), - trajectoryInput = cms.string('TrackRefitter'), OutputFileName = cms.string('test_monitortracks.root'), # bining and range for absolute and normalized residual histogramms TH1ResModules = cms.PSet( @@ -21,6 +20,7 @@ # input for Tracks and Trajectories, should be TrackRefitter # or similar Tracks = cms.InputTag("TrackRefitter"), + trajectoryInput = cms.string('TrackRefitter'), # should all MEs be reset after each run? ResetAfterRun = cms.bool(True) ) diff --git a/DQM/TrackerMonitorTrack/python/SiPixelMonitorTrackResiduals_cfi.py b/DQM/TrackerMonitorTrack/python/SiPixelMonitorTrackResiduals_cfi.py new file mode 100644 index 0000000000000..0ed22c37c6e43 --- /dev/null +++ b/DQM/TrackerMonitorTrack/python/SiPixelMonitorTrackResiduals_cfi.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms + +# SiPixelMonitorTrackResiduals +SiPixelMonitorTrackResiduals = cms.EDAnalyzer("SiPixelMonitorTrackResiduals", + OutputMEsInRootFile = cms.bool(False), + # should histogramms on module level be booked and filled? + Mod_On = cms.bool(False), + OutputFileName = cms.string('test_monitortracks.root'), + # bining and range for absolute and normalized residual histogramms + TH1ResModules = cms.PSet( + xmin = cms.double(-0.05), # native unit in CMS is [cm], so these are 500um + Nbinx = cms.int32(100), + xmax = cms.double(0.05) + ), + TH1NormResModules = cms.PSet( + xmin = cms.double(-5.0), + Nbinx = cms.int32(100), + xmax = cms.double(5.0) + ), + # input for Tracks and Trajectories, should be TrackRefitter + # or similar + Tracks = cms.InputTag("generalTracks"), + trajectoryInput = cms.string("generalTracks"), + # should all MEs be reset after each run? + ResetAfterRun = cms.bool(True) +) + + diff --git a/DQM/TrackerMonitorTrack/src/MonitorTrackResiduals.cc b/DQM/TrackerMonitorTrack/src/MonitorTrackResiduals.cc index 1d957a321dd3e..0871db521501f 100644 --- a/DQM/TrackerMonitorTrack/src/MonitorTrackResiduals.cc +++ b/DQM/TrackerMonitorTrack/src/MonitorTrackResiduals.cc @@ -1,50 +1,54 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h" #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h" #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h" #include "DQM/SiStripCommon/interface/SiStripHistoId.h" #include "DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/VertexReco/interface/Vertex.h" #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/MonitorElement.h" #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h" -MonitorTrackResiduals::MonitorTrackResiduals(const edm::ParameterSet& iConfig) - : dqmStore_( edm::Service().operator->() ) - , conf_(iConfig), m_cacheID_(0) +template +MonitorTrackResidualsBase::MonitorTrackResidualsBase(const edm::ParameterSet& iConfig) + : conf_(iConfig), m_cacheID_(0) , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig, consumesCollector(), *this)) , avalidator_(iConfig, consumesCollector()) { ModOn = conf_.getParameter("Mod_On"); + offlinePrimaryVerticesToken_ = consumes(std::string("offlinePrimaryVertices")); } -MonitorTrackResiduals::~MonitorTrackResiduals() { +template +MonitorTrackResidualsBase::~MonitorTrackResidualsBase() { if (genTriggerEventFlag_) delete genTriggerEventFlag_; } - -void MonitorTrackResiduals::beginJob(void) { -} - -void MonitorTrackResiduals::bookHistograms(DQMStore::IBooker & ibooker , const edm::Run & run, const edm::EventSetup & iSetup) +template +void MonitorTrackResidualsBase::bookHistograms(DQMStore::IBooker & ibooker , const edm::Run & run, const edm::EventSetup & iSetup) { - unsigned long long cacheID = iSetup.get().cacheIdentifier(); + unsigned long long cacheID = iSetup.get().cacheIdentifier(); if (m_cacheID_ != cacheID) { m_cacheID_ = cacheID; this->createMEs( ibooker , iSetup); } } -void MonitorTrackResiduals::dqmBeginRun(edm::Run const& run, edm::EventSetup const& iSetup) { +template +void MonitorTrackResidualsBase::dqmBeginRun(edm::Run const& run, edm::EventSetup const& iSetup) { // Initialize the GenericTriggerEventFlag if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( run, iSetup ); } -std::pair MonitorTrackResiduals::findSubdetAndLayer(uint32_t ModuleID, const TrackerTopology* tTopo) { +template +std::pair MonitorTrackResidualsBase::findSubdetAndLayer(uint32_t ModuleID, const TrackerTopology* tTopo) { std::string subdet = ""; int32_t layer = 0; auto id = DetId(ModuleID); @@ -84,7 +88,8 @@ std::pair MonitorTrackResiduals::findSubdetAndLayer(uint32 } -void MonitorTrackResiduals::createMEs( DQMStore::IBooker & ibooker , const edm::EventSetup& iSetup){ +template +void MonitorTrackResidualsBase::createMEs( DQMStore::IBooker & ibooker , const edm::EventSetup& iSetup){ //Retrieve tracker topology and geometry edm::ESHandle tTopoHandle; @@ -111,18 +116,14 @@ void MonitorTrackResiduals::createMEs( DQMStore::IBooker & ibooker , const edm:: auto pixel_organizer = SiPixelFolderOrganizer(false); // Collect list of modules from Tracker Geometry - std::vector activeDets; - auto ids = TG->detIds(); // or detUnitIds? - for (DetId id : ids) { - activeDets.push_back(id.rawId()); - } - // book histo per each detector module - for(auto ModuleID : activeDets) + auto ids = TG->detIds(); // or detUnitIds? + for (DetId id : ids) { - auto id = DetId(ModuleID); + auto ModuleID = id.rawId(); + auto isPixel = id.subdetId() == 1 || id.subdetId() == 2; + if (isPixel != (pixel_or_strip == TRACKERTYPE_PIXEL)) continue; - // TODO: Not yet implemented for Pixel. // Book module histogramms? if (ModOn) { switch (id.subdetId()) { @@ -156,26 +157,34 @@ void MonitorTrackResiduals::createMEs( DQMStore::IBooker & ibooker , const edm:: auto& histos = m_SubdetLayerResiduals[subdetandlayer]; switch (id.subdetId()) { // Pixel Barrel, Endcap - case 1: pixel_organizer.setModuleFolder(ibooker, ModuleID, 2); break; - case 2: pixel_organizer.setModuleFolder(ibooker, ModuleID, 6); break; + // We can't use the folder organizer here (SiPixelActionExecutor.cc#1638 does the same) + case 1: ibooker.setCurrentFolder("Pixel/Barrel"); break; + case 2: ibooker.setCurrentFolder("Pixel/Endcap"); break; // All strip default: strip_organizer.setLayerFolder(ModuleID,tTopo,subdetandlayer.second); } + + auto isBarrel = subdetandlayer.first.find("B") != std::string::npos; auto xy = std::vector > { std::make_pair(std::ref(histos.x), "X"), std::make_pair(std::ref(histos.y), "Y") }; for (auto& histopair : xy) { // book histogramms on layer level, check for barrel/pixel only for correct labeling - auto isBarrel = subdetandlayer.first.find("B") != std::string::npos; - auto isPixel = subdetandlayer.first.find("X") != std::string::npos; - // TODO: We use a legacy name to stay compatible with other code. - // Check if this is necessary. - std::string histoname = Form("HitResiduals_%s__%s__%d%s", - subdetandlayer.first.c_str(), - isBarrel ? "Layer" : "wheel", - std::abs(subdetandlayer.second), - histopair.second[0] == 'X' ? "" : "_Y"); + + // Skip the Y plots for strips. + if (!isPixel && histopair.second[0] == 'Y') continue; + + std::string histoname = isPixel ? ( // Pixel name + Form("HitResiduals%s_%s%d", + histopair.second, + isBarrel ? "L" : (subdetandlayer.second > 0 ? "Dp" : "Dm"), + std::abs(subdetandlayer.second))) + : (Form("HitResiduals_%s__%s__%d", // Strip TODO: We use a legacy name. + subdetandlayer.first.c_str(), + isBarrel ? "Layer" : "wheel", + std::abs(subdetandlayer.second))); + std::string histotitle = Form("HitResiduals %s on %s%s full %s %d", histopair.second, subdetandlayer.first.c_str(), @@ -203,54 +212,58 @@ void MonitorTrackResiduals::createMEs( DQMStore::IBooker & ibooker , const edm:: } // end loop over activeDets } +template +void MonitorTrackResidualsBase::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { -void MonitorTrackResiduals::endRun(const edm::Run&, const edm::EventSetup&){ -} - - -void MonitorTrackResiduals::endJob(void){ - - //dqmStore_->showDirStructure(); - bool outputMEsInRootFile = conf_.getParameter("OutputMEsInRootFile"); - std::string outputFileName = conf_.getParameter("OutputFileName"); - if(outputMEsInRootFile){ - dqmStore_->save(outputFileName); - } -} - - -void MonitorTrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - + auto vtracks = std::vector(); // Filter out events if Trigger Filtering is requested if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return; + edm::Handle vertices; + iEvent.getByToken(offlinePrimaryVerticesToken_, vertices); + if (!vertices.isValid() || vertices->size() == 0) return; + const auto primaryVertex = vertices->at(0); + //Retrieve tracker topology from geometry edm::ESHandle tTopoHandle; iSetup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); - std::vector v_hitstruct; - avalidator_.fillHitQuantities(iEvent,v_hitstruct); - for (auto it : v_hitstruct) { - uint RawId = it.rawDetId; - - if (ModOn) { - auto& mod_histos = m_ModuleResiduals[std::make_pair("",RawId)]; - mod_histos.x.base->Fill(it.resXprime); - mod_histos.x.normed->Fill(it.resXprime/it.resXprimeErr); - mod_histos.y.base->Fill(it.resYprime); - mod_histos.y.normed->Fill(it.resYprime/it.resYprimeErr); - } - auto subdetandlayer = findSubdetAndLayer(RawId, tTopo); - auto histos = m_SubdetLayerResiduals[subdetandlayer]; - // fill if its error is not zero - if(it.resXprimeErr != 0 && histos.x.base) { - histos.x.base->Fill(it.resXprime); - histos.x.normed->Fill(it.resXprime/it.resXprimeErr); - } - if(it.resYprimeErr != 0 && histos.y.base) { - histos.y.base->Fill(it.resYprime); - histos.y.normed->Fill(it.resYprime/it.resYprimeErr); + avalidator_.fillTrackQuantities(iEvent, iSetup, + // tell the validator to only look at good tracks + [&](const reco::Track& track) -> bool { + return track.pt() > 0.75 + && abs( track.dxy(primaryVertex.position()) ) < 5*track.dxyError(); + }, vtracks); + + for (auto& track : vtracks) { + for (auto& it : track.hits) { + uint RawId = it.rawDetId; + + auto id = DetId(RawId); + auto isPixel = id.subdetId() == 1 || id.subdetId() == 2; + if (isPixel != (pixel_or_strip == TRACKERTYPE_PIXEL)) continue; + + + if (ModOn) { + auto& mod_histos = m_ModuleResiduals[std::make_pair("",RawId)]; + mod_histos.x.base->Fill(it.resXprime); + mod_histos.x.normed->Fill(it.resXprime/it.resXprimeErr); + mod_histos.y.base->Fill(it.resYprime); + mod_histos.y.normed->Fill(it.resYprime/it.resYprimeErr); + } + + auto subdetandlayer = findSubdetAndLayer(RawId, tTopo); + auto histos = m_SubdetLayerResiduals[subdetandlayer]; + // fill if its error is not zero + if(it.resXprimeErr != 0 && histos.x.base) { + histos.x.base->Fill(it.resXprime); + histos.x.normed->Fill(it.resXprime/it.resXprimeErr); + } + if(it.resYprimeErr != 0 && histos.y.base) { + histos.y.base->Fill(it.resYprime); + histos.y.normed->Fill(it.resYprime/it.resYprimeErr); + } } } } @@ -258,4 +271,5 @@ void MonitorTrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSe DEFINE_FWK_MODULE(MonitorTrackResiduals); +DEFINE_FWK_MODULE(SiPixelMonitorTrackResiduals);