diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/CMakeLists.txt b/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/CMakeLists.txt index 23bf8872da4fe23149938dcbc2f686eb8702281f..2326a19c2bfeba8bee6e022aa5ab071a0562c0ab 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/CMakeLists.txt +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/CMakeLists.txt @@ -14,7 +14,7 @@ atlas_add_component( MuonDQAMonitoring src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${TDAQ-COMMON_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${TDAQ-COMMON_LIBRARIES} AthenaMonitoringLib StoreGateLib SGtests GaudiKernel DataQualityInterfaces EventInfo TrigT1Result ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${TDAQ-COMMON_LIBRARIES} AthenaMonitoringLib StoreGateLib SGtests GaudiKernel EventInfo TrigT1Result ) # Install files from the package: atlas_install_headers( MuonDQAMonitoring ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/share/MuonDetMonitoring.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/share/MuonDetMonitoring.py index 40fa2cf38aadff7ef473f5b17f0e68fe255d09fd..a0b992c67339ddb6dbc8fbad231e35c8116695e6 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/share/MuonDetMonitoring.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/share/MuonDetMonitoring.py @@ -154,13 +154,23 @@ if DQMonFlags.doMuonSegmentMon(): #------------- ---------# # Muon track monitoring # #------------- ---------# +# switch between legacy and new code +Run3_test = False if DQMonFlags.doMuonTrackMon(): - if MuonESDMon: - try: + try: + if MuonESDMon and Run3_test: from MuonTrackMonitoring.MuonTrackMonitorAlgorithm import MuonTrackConfig topSequence += MuonTrackConfig(DQMonFlags,isOld=True) - except Exception: - treatException("DataQualitySteering_jobOptions.py: exception when setting up Muon track monitoring") + + # Legacy monitoring + elif MuonESDMon: + if DQMonFlags.useTrigger(): ## monitoring tool cannot have a dependence on TrigDecisionTool if DQMonFlags.useTrigger==False (ATLASRECTS-3549) + if MuonDQADetFlags.doMuonTrackMon(): + include ("MuonTrackMonitoring/MuonTrackDQA_options.py") + if MuonDQADetFlags.MuonTrkMonDoTrigger(): + include ("MuonTrackMonitoring/MuonTrigTrackDQA_options.py") + except Exception: + treatException("DataQualitySteering_jobOptions.py: exception when setting up Muon track monitoring") #-------------------------# # Muon physics monitoring # diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/CMakeLists.txt b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/CMakeLists.txt index 6d3192f60b81f00e5fe0189ade4fa8e3f00d7b4d..46f589b8c22a67547172511e1b20110c70f023f2 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/CMakeLists.txt +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/CMakeLists.txt @@ -18,4 +18,4 @@ atlas_add_component( MuonTrackMonitoring # Install files from the package: atlas_install_python_modules( python/*.py ) - +atlas_install_joboptions( share/*.py ) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/MuonGenericTracksMon.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/MuonGenericTracksMon.h new file mode 100644 index 0000000000000000000000000000000000000000..e8cce9860f10b7f4dce97118a32218ea27c9ef2f --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/MuonGenericTracksMon.h @@ -0,0 +1,145 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRKPHYSMONITORING_MUONGENERICTRACKSMON_H +#define MUONTRKPHYSMONITORING_MUONGENERICTRACKSMON_H + +// MuonGenericTracksMon.cxx +// AUTHORS: N. Benekos, E. Christidi, A. Eppig, Tony Liss + +#include "GaudiKernel/StatusCode.h" +#include "GaudiKernel/ToolHandle.h" +#include "StoreGate/StoreGate.h" + +#include "AthenaMonitoring/ManagedMonitorToolBase.h" + +#include "MuonTrackMonitoring/RecoMuonPlots.h" +#include "MuonTrackMonitoring/RecoMuonSegmentPlots.h" +#include "MuonTrackMonitoring/RecoMuonTrackPlots.h" +#include "MuonTrackMonitoring/RecoMuonIDTrackPlots.h" +#include "MuonTrackMonitoring/RecoLumiPlots.h" +#include "MuonTrackMonitoring/RecoPhysPlots.h" +#include "MuonTrackMonitoring/RecoVertexPlots.h" +#include "MuonHistUtils/MuonEnumDefs.h" + +#include "TrigConfL1Data/TriggerItem.h" + +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackCollection.h" +#include "TrkToolInterfaces/IResidualPullCalculator.h" +#include "TrkToolInterfaces/ITrackSelectorTool.h" + +#include "xAODTracking/TrackParticle.h" + +#include "GeoPrimitives/GeoPrimitives.h" +#include "EventPrimitives/EventPrimitives.h" +#include "EventPrimitives/EventPrimitivesHelpers.h" +#include "FourMomUtils/P4Helpers.h" + +#include "MuonRecHelperTools/IMuonEDMHelperSvc.h" +#include "MuonAnalysisInterfaces/IMuonSelectionTool.h" +#include "MuonResonanceTools/IMuonResonanceSelectionTool.h" +#include "MuonResonanceTools/IMuonResonancePairingTool.h" + +#include "xAODMuon/MuonContainer.h" +#include "xAODMuon/Muon.h" +#include "xAODMuon/MuonSegment.h" +#include "xAODMuon/MuonSegmentContainer.h" +#include "xAODEventInfo/EventInfo.h" + +#include <vector> +#include <string> +#include <algorithm> + +class MuonGenericTracksMon : public ManagedMonitorToolBase +{ + + public: + + MuonGenericTracksMon( const std::string & type, const std::string & name, const IInterface* parent ); + virtual ~MuonGenericTracksMon()=default; + + virtual StatusCode initialize(); + virtual StatusCode bookHistograms(); + virtual StatusCode fillHistograms(); + virtual StatusCode procHistograms(); + + //second argument is the souce type + void plot_lumi( std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances_Z, + std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances_jpsi, + const xAOD::MuonContainer* Muons, + const xAOD::TrackParticleContainer* tracksMS, + const xAOD::MuonSegmentContainer* MuonSegments); + void plot_lumi_notrig(const xAOD::MuonContainer* Muons, + const xAOD::TrackParticleContainer* tracksMS, + const xAOD::MuonSegmentContainer* MuonSegments); + //other plots + void plot_muon( const xAOD::Muon& muon, int source); + void plot_muon_notrig(const xAOD::Muon& muon, int source); + void plot_segment(const xAOD::MuonSegment& segment, int source); + void plot_track( const xAOD::TrackParticle& track, int source); + void plot_vertex( const xAOD::Vertex& aVx, int source); + void plot_resonances(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances, int source); + + void FillPullResid(RecoMuonTrackPlots *, const xAOD::TrackParticle*); + + float m_inst_lumi_bcid; + float m_inst_lumi_lb; + int m_current_lb; + + TH1* m_hNEvent;//a sample histogram to count the number of events + + // plot classes in vectors (one class per selection: Z, JPsi, all) + std::vector<RecoLumiPlots*> m_oRecoLumiPlots; + std::vector<RecoMuonSegmentPlots*> m_oRecoMuonSegmentPlots; + std::vector<RecoMuonTrackPlots*> m_oRecoMuonMSTrackPlots; + std::vector<RecoMuonTrackPlots*> m_oRecoMuonMETrackPlots; + std::vector<RecoMuonIDTrackPlots*> m_oRecoMuonIDTrackPlots; + std::vector<RecoMuonPlots*> m_oRecoMuonPlots; + std::vector<RecoPhysPlots*> m_oRecoPhysPlots; + std::vector<RecoVertexPlots*> m_oRecoVertexPlots; + + private: + + std::string m_muonsName; + std::string m_muonSegmentsName; + std::string m_muonTracksName; + std::string m_msVertexCollection; + std::string m_muonExtrapTracksName; + std::string m_innerTracksName; + + StatusCode setupTools(); + StatusCode bookInMongroup(TH1* hist, MonGroup& mongroup); + StatusCode bookInMongroup(HistData& hist, MonGroup& mongroup, std::string source); + StatusCode bookInMongroup(PlotBase& valPlots, MonGroup& mongroup, std::string source); + StatusCode bookInMongroup(PlotBase& valPlots, MonGroup& mongroup, std::string source, TString Montype); + + // define the different classes of plots; + enum SOURCE {Z = 0, JPSI, CBMUONS, NONCBMUONS, CONTAINER, N_SOURCE}; + std::string m_sources[SOURCE::N_SOURCE + 1] = {"Z", "Jpsi", "CBMuons", "NonCBMuons", "Container", "N_SOURCE"}; + enum MUON_COMPONENT {TRACK_MS=0, TRACK_ME, TRACK_ID, N_COMPONENTS}; + // Trigger items + bool m_useTrigger; + std::string m_MuonTriggerChainName; + std::vector<std::string> m_muon_triggers; + + // ATLAS Detector Description + // Handle for the trig decision tool + // MCP muon quality tool + ToolHandle<CP::IMuonSelectionTool> m_muonSelectionTool{this, "MuonSelectorTool", "CP::MuonSelectionTool/MuonSelectionTool"}; + ToolHandle<IMuonResonanceSelectionTool> m_ZmumuResonanceSelectionTool{this, "ZmumuResonanceSelectionTool", "MuonResonanceSelectionTool/ZmumuResonanceSelectionTool"}; + ToolHandle<IMuonResonancePairingTool> m_ZmumuResonancePairingTool{this, "ZmumuResonancePairingTool", "MuonResonancePairingTool/ZmumuResonancePairingTool"}; + ToolHandle<IMuonResonanceSelectionTool> m_JpsimumuResonanceSelectionTool{this, "JpsimumuResonanceSelectionTool", "MuonResonanceSelectionTool/JpsimumuResonanceSelectionTool"}; + ToolHandle<IMuonResonancePairingTool> m_JpsimumuResonancePairingTool{this, "JpsimumuResonancePairingTool", "MuonResonancePairingTool/JpsimumuResonancePairingTool"}; + + std::string pathToHistName(std::string str){ + std::replace( str.begin(), str.end(), '/', '_'); + return str; + } +}; + +#endif + + + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/MuonTrackMonitorAlgorithm.h similarity index 100% rename from MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.h rename to MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/MuonTrackMonitorAlgorithm.h diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/PlotMuons.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/PlotMuons.h new file mode 100644 index 0000000000000000000000000000000000000000..4372fdbd3d436d9f77ae8913f8c99e06553095b6 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/PlotMuons.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_PLOTMUONS_H +#define MUONTRACKMONITORING_PLOTMUONS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "TrkValHistUtils/ParamPlots.h" +#include "MuonHistUtils/RecoInfoPlots.h" +#include "MuonHistUtils/MomentumPullPlots.h" +#include "MuonHistUtils/MuonHitSummaryPlots.h" +#include "xAODMuon/Muon.h" + +class PlotMuons:public PlotBase{ + + public: + + PlotMuons(PlotBase* pParent, std::string sDir); + + void fill(const xAOD::Muon& muon); + + Trk::ParamPlots m_plots_All; + Muon::RecoInfoPlots m_plots_RecoInfo; + Muon::MomentumPullPlots m_plots_MomentumPull; + Muon::MuonHitSummaryPlots m_plots_MuonHitSummary; +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoLumiPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoLumiPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..ff6e605ba529dab62a986145d4dcd1fe6f572bd0 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoLumiPlots.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_RECOLUMIPLOTS_H +#define MUONTRACKMONITORING_RECOLUMIPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" + + +#include "MuonPrepRawData/MuonPrepDataContainer.h" +#include "xAODMuon/MuonSegmentContainer.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODMuon/MuonContainer.h" + +class RecoLumiPlots:public PlotBase { + + public: + RecoLumiPlots(PlotBase* pParent, std::string sDir, std::string recObj); + + void fill(const xAOD::MuonSegmentContainer* MuonSegments, int current_lb, float inst_lumi_bcid, float inst_lumi_lb); + void fill(const xAOD::TrackParticleContainer* MSTracks, int current_lb, float inst_lumi_bcid, float inst_lumi_lb); + void fill_CB(const xAOD::MuonContainer* Muons, int current_lb, float inst_lumi_bcid, float inst_lumi_lb); + void fill_Other(const xAOD::MuonContainer* Muons, int current_lb, float inst_lumi_bcid, float inst_lumi_lb); + void fill(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances, int current_lb, float inst_lumi_bcid, float inst_lumi_lb); + + TH1* m_hNSegment_LB_1D; + TH1* m_hNMuonTrack_LB_1D; + TH1* m_hNMuon_LB_1D; + TH1* m_hNResonance_LB_1D; + + TH2* m_hNSegment_LB; + TH2* m_hNMuonTrack_LB; + TH2* m_hNMuon_LB; + TH2* m_hNResonance_LB; + + int n_lbs; + + //for locating Z and Jpsi + std::string type; + std::string name; + + private: + void initializePlots(); + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonIDTrackPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonIDTrackPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..120005dbf4e56177c1aab7285cb0c202a224f2b6 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonIDTrackPlots.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_RECOMUONIDTRACKPLOTS_H +#define MUONTRACKMONITORING_RECOMUONIDTRACKPLOTS_H + +#include "xAODMuon/Muon.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODTracking/TrackParticle.h" +//#include "TrkEventPrimitives/ResidualPull.h" + +#include "TrkValHistUtils/PlotBase.h" +#include "TrkValHistUtils/ParamPlots.h" +#include "TrkValHistUtils/RecoInfoPlots.h" +#include "TrkValHistUtils/ImpactPlots.h" +#include "TrkValHistUtils/IDHitPlots.h" + + +class RecoMuonIDTrackPlots:public PlotBase { + public: + RecoMuonIDTrackPlots(PlotBase* pParent, std::string sDir); + + // Reco only information + Trk::ParamPlots m_oAllPlots; + Trk::ImpactPlots m_oImpactPlots; + Trk::RecoInfoPlots m_oTrkRecoInfoPlots; + Trk::IDHitPlots m_oIDHitPlots; + + TH1* m_pt_broad; + TH2* m_eta_phi_broad; + + //fill methods + void fill(const xAOD::Muon& mu, int component); + void fill(const xAOD::TrackParticle& muTP); + //void fill(const xAOD::TrackParticle& muTP, int LB_number, float LB_instant); + //void fill(const Trk::ResidualPull& resPull, int stationPhi, Muon::MuonStationIndex::TechnologyIndex techid, bool measuresPhi); + private: + void initializePlots(); + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..a00bdfa1c064e466b4225548fefbfa5573f801f8 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonPlots.h @@ -0,0 +1,111 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_RECOMUONPLOTS_H +#define MUONTRACKMONITORING_RECOMUONPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "TrkValHistUtils/ParamPlots.h" +#include "TrkValHistUtils/MSHitPlots.h" +#include "TrkValHistUtils/ImpactPlots.h" +#include "MuonHistUtils/RecoInfoPlots.h" +#include "MuonHistUtils/MomentumPullPlots.h" +#include "MuonHistUtils/MuonHitSummaryPlots.h" +#include "MuonHistUtils/MuonIsolationPlots.h" +#include "MuonHistUtils/MuonParamPlots.h" + +#include "xAODMuon/Muon.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODTracking/TrackingPrimitives.h" + +class RecoMuonPlots:public PlotBase { + public: + RecoMuonPlots(PlotBase* pParent, std::string sDir, bool detail=false); + void fill(const xAOD::Muon& mu); + void fill(const xAOD::Muon& mu, xAOD::Muon::Quality my_quality); + + // Reco only information + Trk::ParamPlots m_oAllPlots; + Muon::RecoInfoPlots m_oMuRecoInfoPlots; + Trk::ImpactPlots m_oImpactPlots; + Muon::MomentumPullPlots m_oMomentumPullPlots; + + //extra monitoring efficiency plots; filled in post processing + TH2* m_origin_eta_phi; + TH2* m_eff_tight; + TH2* m_eff_medium; + TH2* m_tight_eta_phi; + TH2* m_medium_eta_phi; + TH1* m_pt_broad; + TH2* m_eta_phi_broad; + + //extra monitoring efficiency plots, normalized in post processing + TH2* m_eff_nPrec; + TH2* m_eff_nPhi; + TH2* m_eff_nTrigEta; + TH2* m_eff_ndof; + TH2* m_eff_chi2; + TH2* m_ID_eff_ndof; + TH2* m_ID_eff_chi2; + TH2* m_MS_eff_ndof; + TH2* m_MS_eff_chi2; + + TH2* m_avg_hits_precision_inner; + TH2* m_avg_hits_precision_middle; + TH2* m_avg_hits_precision_outer; + TH2* m_avg_hits_precision_extended; + + TH2* m_avg_hits_trigger_layer1; + TH2* m_avg_hits_trigger_layer2; + TH2* m_avg_hits_trigger_layer3; + TH2* m_avg_hits_trigger_layer4; + + TH2* m_avg_hits_ibl; + TH2* m_avg_hits_pix; + TH2* m_avg_hits_sct; + TH2* m_avg_hits_trt; + + TH2* m_avg_ddpt_idme; + TH2* m_avg_dptsignif; + + // overview layers + uint8_t hitval_numberOfPrecisionLayers = 0; + uint8_t hitval_numberOfPhiLayers = 0; + uint8_t hitval_numberOfTriggerEtaLayers = 0; + + // precision hits + uint8_t hitval_innerSmallHits = 0; + uint8_t hitval_innerLargeHits = 0; + uint8_t hitval_middleSmallHits = 0; + uint8_t hitval_middleLargeHits = 0; + uint8_t hitval_outerSmallHits = 0; + uint8_t hitval_outerLargeHits = 0; + uint8_t hitval_extendedSmallHits = 0; + uint8_t hitval_extendedLargeHits = 0; + + // trigger hits + uint8_t hitval_etaLayer1Hits = 0; + uint8_t hitval_etaLayer2Hits = 0; + uint8_t hitval_etaLayer3Hits = 0; + uint8_t hitval_etaLayer4Hits = 0; + + // ID hits + uint8_t hitval_numberOfBLayerHits = 0; + uint8_t hitval_numberOfPixelHits = 0; + uint8_t hitval_numberOfSCTHits = 0; + uint8_t hitval_numberOfTRTHits = 0; + + // momentum balance + float ddpt_idme = 0; + float qoverp_diff = 0; + float qoverp_sigma = 0; + float qoverp_signif = 0; + + bool Detail; + + private: + void initializePlots(); +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonSegmentPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonSegmentPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..253d96b7c06cb006a331ea0264e062cad22d0262 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonSegmentPlots.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_RECOMUONSEGMENTPLOTS_H +#define MUONTRACKMONITORING_RECOMUONSEGMENTPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "MuonHistUtils/MuonSegmentPlots.h" +#include "MuonHistUtils/MuonSegmentSlimPlots.h" + +#include "xAODMuon/Muon.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODMuon/MuonSegment.h" +#include "xAODMuon/MuonSegmentContainer.h" +#include "xAODTracking/TrackParticleContainer.h" + +class RecoMuonSegmentPlots:public PlotBase { + public: + RecoMuonSegmentPlots(PlotBase* pParent, std::string sDir, bool detail=false); + + //fill methods + void fill(const xAOD::MuonContainer& muContainer); + void fill(const xAOD::Muon& mu); + void fill(const std::vector<ElementLink<DataVector<xAOD::MuonSegment_v1>>> Mu_Segments); + void fill(const xAOD::MuonSegment& muonSeg); + + //generic plots from MuonHistUtils + Muon::MuonSegmentPlots *m_oMuonSegmentPlots; + Muon::MuonSegmentSlimPlots *m_oMuonSegmentSlimPlots; + + //Monitoring justification plots + bool Detail; + + + private: + void initializePlots(); + + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonTrackPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonTrackPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..6aae71f53c97f1bb6d6e0ec807dfd9fa8ae53ac6 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoMuonTrackPlots.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRACKMONITORING_RECOMUONTRACKPLOTS_H +#define MUONTRACKMONITORING_RECOMUONTRACKPLOTS_H + +#include "xAODMuon/Muon.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODTracking/TrackParticle.h" +#include "TrkEventPrimitives/ResidualPull.h" + +#include "TrkValHistUtils/PlotBase.h" +#include "TrkValHistUtils/ParamPlots.h" +#include "TrkValHistUtils/MSHitPlots.h" +#include "TrkValHistUtils/RecoInfoPlots.h" +#include "TrkValHistUtils/ImpactPlots.h" + +#include "MuonHistUtils/MuonHitResidualPlots.h" +#include "TrkTrack/TrackStateOnSurface.h" +#include "TrkTrack/TrackCollection.h" +#include "TrkParameters/TrackParameters.h" + + +class RecoMuonTrackPlots:public PlotBase { + public: + RecoMuonTrackPlots(PlotBase* pParent, std::string sDir); + + // Reco only information + Trk::ParamPlots m_oAllPlots; + Trk::ImpactPlots m_oImpactPlots; + Trk::RecoInfoPlots m_oTrkRecoInfoPlots; + + TH1* m_pt_broad; + TH2* m_eta_phi_broad; + + //fill methods + void fill(const xAOD::Muon& mu, int component); + void fill(const xAOD::TrackParticle& muTP); + void fill(const xAOD::TrackParticle& muTP, int LB_number, float LB_instant); + private: + void initializePlots(); + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoPhysPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoPhysPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..effc089b25488233053b8100167efa45e1024419 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoPhysPlots.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRKPHYSMONITORING_RECOPHYSPLOTS_H +#define MUONTRKPHYSMONITORING_RECOPHYSPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "xAODMuon/Muon.h" + + +class RecoPhysPlots:public PlotBase { + public: + RecoPhysPlots(PlotBase *pParent, std::string sDir, std::string recObj); + + void fill(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > mumucandidates); + void fill(const float eta_mu_plus, const float eta_mu_minus, const float invariant_mass); + + float EtaRegionFine(double eta); + float EtaRegionCoarse(double eta); + bool LabelLargeEtaRegions(TAxis * axis); + bool LabelCombinedEtaRegions(TAxis * axis); + bool LabelSectorAxis(TAxis * axis); + + TH1* m_Mass; + TH1* m_occupancy; + TH1* m_2occupancy; + + // TH2* m_Efficiency; + // TH2* m_EffNumerator; + // TH2* m_EffDenominator; + + // TH1* m_Efficiency_eta; + // TH1* m_EffNumerator_eta; + // TH1* m_EffDenominator_eta; + + TH1* m_M_Mean; + TH1* m_M_Sigma; + + TH1* m_M_EA_EA; + TH1* m_M_EA_BA; + TH1* m_M_EA_BC; + TH1* m_M_EA_EC; + + TH1* m_M_BA_EA; + TH1* m_M_BA_BA; + TH1* m_M_BA_BC; + TH1* m_M_BA_EC; + + TH1* m_M_BC_EA; + TH1* m_M_BC_BA; + TH1* m_M_BC_BC; + TH1* m_M_BC_EC; + + TH1* m_M_EC_EA; + TH1* m_M_EC_BA; + TH1* m_M_EC_BC; + TH1* m_M_EC_EC; + + std::string type; + + void finalizeRecoPlots(); + private: + void SetResultsBin(int iBin, TH1* pInputHist); + void initializePlots(); + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoVertexPlots.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoVertexPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..ac11ba8e963c5e4d9def52aac8e0cb14c4154be3 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/MuonTrackMonitoring/RecoVertexPlots.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONTRKPHYSMONITORING_RecoVertexPLOTS_H +#define MUONTRKPHYSMONITORING_RecoVertexPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "xAODTracking/VertexContainer.h" + + +class RecoVertexPlots:public PlotBase { + public: + RecoVertexPlots(PlotBase *pParent, std::string sDir); + + void fill(const xAOD::Vertex& msVx); + + TH1* m_nMDT; + TH1* m_nRPC; + TH1* m_nTGC; + TH1* m_nTracklets; + TH2* m_VertexEtaPhi; + + private: + void initializePlots(); + +}; + +#endif diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackDQA_options.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackDQA_options.py new file mode 100755 index 0000000000000000000000000000000000000000..2ee157a640ae11efc49ee21547eec9fc21d13524 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackDQA_options.py @@ -0,0 +1,96 @@ +#====================================================================== +# JobOptions for MuonTrackMonitoring +#====================================================================== + +muTrackMonMan = AthenaMonManager(name="MuonTrackMonManager", + FileKey = DQMonFlags.monManFileKey(), + Environment = DQMonFlags.monManEnvironment(), + DataType = DQMonFlags.monManDataType(), + OutputLevel = WARNING) + +from RecExConfig.RecFlags import rec as recFlags +from MuonRecExample import MuonRecTools +from MuonTrackMonitoring.MuonTrackMonitoringConf import MuonGenericTracksMon +from AthenaCommon.AppMgr import ToolSvc + +############TriggerAware Trk Monitoring####################### +# set to true in case you would like to use trigger-aware monitoring +# only do trigger-aware monitoring if monTrigDecTool known by ToolSvc +# NoTrig requirement part is intended to run on all streams +MuonGenericTracksMon_NoTrig = MuonGenericTracksMon(name = "MuonGenericTracksMon_NoTrig", + MuonTriggerChainName = "NoTrig/", + OutputLevel = WARNING, + ) +#ToolSvc += MuonGenericTracksMon_NoTrig +muTrackMonMan.AthenaMonTools += [MuonGenericTracksMon_NoTrig] + +# L1_Trig part is intended to only select events passing L1_MU triggers +MuonGenericTracksMon_L1Trig = MuonGenericTracksMon(name = "MuonGenericTracksMon_L1Trig", + MuonTriggerChainName = "", + OutputLevel = WARNING, + ) + +if not DQMonFlags.useTrigger(): + from AthenaCommon.Logging import log + log.error("MuonTrigTrackDQA_options.py: trigger decision tool not found: don't run trigger-aware monitoring") +else: + MuonGenericTracksMon_L1Trig.TriggerChain = "L1_MU4, L1_MU6, L1_MU10, L1_MU11, L1_MU15, L1_MU20, L1_2MU4, L1_2MU6, L1_2MU10" + MuonGenericTracksMon_L1Trig.MuonTriggerChainName = "" + MuonGenericTracksMon_L1Trig.TrigDecisionTool = monTrigDecTool + #ToolSvc += MuonGenericTracksMon_L1Trig + muTrackMonMan.AthenaMonTools += [MuonGenericTracksMon_L1Trig] + +#for Muon Quality Selection +if not hasattr(ToolSvc,"MuonSelectorTool"): + from MuonSelectorTools.MuonSelectorToolsConf import CP__MuonSelectionTool + ToolSvc += CP__MuonSelectionTool("MuonSelectorTool", OutputLevel = ERROR) + ToolSvc.MuonSelectorTool.MaxEta = 2.5 + +#for Muon Resonance Selection +from MuonResonanceTools.MuonResonanceToolsConf import MuonResonanceSelectionTool +from MuonResonanceTools.MuonResonanceToolsConf import MuonResonancePairingTool + +ToolSvc += MuonResonanceSelectionTool("ZmumuResonanceSelectionTool") +ToolSvc += MuonResonancePairingTool("ZmumuResonancePairingTool") +ToolSvc.ZmumuResonanceSelectionTool.OutputLevel = ERROR +ToolSvc.ZmumuResonanceSelectionTool.PtCut = 20000.0 +ToolSvc.ZmumuResonanceSelectionTool.EtaCut = 2.5 +ToolSvc.ZmumuResonanceSelectionTool.IsoCaloCut = 0.2 +ToolSvc.ZmumuResonanceSelectionTool.IsoTrkCut = 0.2 +ToolSvc.ZmumuResonanceSelectionTool.z0Cut = 100 #to overwrite Z0 cut +ToolSvc.ZmumuResonanceSelectionTool.Max_d0 = 100 +ToolSvc.ZmumuResonanceSelectionTool.Calibrate = False +ToolSvc.ZmumuResonanceSelectionTool.EfficiencyCorr = False +ToolSvc.ZmumuResonanceSelectionTool.MuonSelectionTool.OutputLevel = ERROR +ToolSvc.ZmumuResonancePairingTool.OutputLevel = ERROR +ToolSvc.ZmumuResonancePairingTool.HighMassWindow = 106000.0 +ToolSvc.ZmumuResonancePairingTool.LowMassWindow = 76000.0 + +# J/psi configuration +ToolSvc += MuonResonanceSelectionTool("JpsimumuResonanceSelectionTool") +ToolSvc += MuonResonancePairingTool("JpsimumuResonancePairingTool") +ToolSvc.JpsimumuResonanceSelectionTool.OutputLevel = ERROR +### loose selections for J/psi ### +ToolSvc.JpsimumuResonanceSelectionTool.PtCut = 4000.0 +ToolSvc.JpsimumuResonanceSelectionTool.EtaCut = 2.5 +ToolSvc.JpsimumuResonanceSelectionTool.IsoCaloCut = 1 +ToolSvc.JpsimumuResonanceSelectionTool.IsoTrkCut = 1 +ToolSvc.JpsimumuResonanceSelectionTool.z0Cut = 100 +ToolSvc.JpsimumuResonanceSelectionTool.Max_d0 = 100 +ToolSvc.JpsimumuResonanceSelectionTool.Calibrate = False #no calibration on data +ToolSvc.JpsimumuResonanceSelectionTool.EfficiencyCorr = False #no efficiency correction on data +ToolSvc.JpsimumuResonanceSelectionTool.MuonSelectionTool.OutputLevel = ERROR +ToolSvc.JpsimumuResonancePairingTool.OutputLevel = ERROR +ToolSvc.JpsimumuResonancePairingTool.HighMassWindow = 3600.0 +ToolSvc.JpsimumuResonancePairingTool.LowMassWindow = 2600.0 + + +MuonGenericTracksMon_NoTrig.JpsimumuResonanceSelectionTool = ToolSvc.JpsimumuResonanceSelectionTool +MuonGenericTracksMon_NoTrig.ZmumuResonanceSelectionTool = ToolSvc.ZmumuResonanceSelectionTool +MuonGenericTracksMon_L1Trig.JpsimumuResonanceSelectionTool = ToolSvc.JpsimumuResonanceSelectionTool +MuonGenericTracksMon_L1Trig.ZmumuResonanceSelectionTool = ToolSvc.ZmumuResonanceSelectionTool + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() +topSequence += muTrackMonMan + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackMonitoring_options.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackMonitoring_options.py new file mode 100755 index 0000000000000000000000000000000000000000..1f701f9ee9e76bc245f3b34f1c0f43acd21b1ec1 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/share/MuonTrackMonitoring_options.py @@ -0,0 +1,191 @@ +#====================================================================== +# TOP JobOptions to run on MuonTrackMonitoring +#====================================================================== +from MuonDQAMonFlags.MuonDQAFlags import MuonDQAFlags as MuonDQAFlags +#############TriggerAware Trk Monitoring####################### +if MuonDQAFlags.MuonTrkMonDoTrigger or MuonDQAFlags.doMDTTGC: + from TrigDecisionMaker.TrigDecisionMakerConfig import TrigDecisionMaker + trigDecMaker = TrigDecisionMaker() + topSequence += trigDecMaker + #from TrigDecision.TrigDecisionConf import TrigDec__TrigDecisionTool + #tdt = TrigDec__TrigDecisionTool() + #ToolSvc += tdt + tdt = monTrigDecTool +############################################################### +#----------------------# +# Trk Level Monitoring # +#----------------------# +### Which Track Collections to read (set array element to 0 or 1): +# 1-> Moore, 2->MuonBoy +############################################################### +#############MuonSelectedTracksMon############# +from MuonTrackMonitoring.MuonTrackMonitoringConf import MuonSelectedTracksMon +#############MuonGenericTracksMon############# +from MuonTrackMonitoring.MuonTrackMonitoringConf import MuonGenericTracksMon +#############MuonGenericTracksMon############# +from MuonTrackMonitoring.MuonTrackMonitoringConf import TGCStandaloneTracksMon +############# NO TriggerAware Trk Monitoring ####################### +if MuonDQAFlags.doMuonTrackMon: + + #############MuonSelectedTracksMon############# + MuonSelectedTracksMon = MuonSelectedTracksMon(name = "MuonSelectedTracksMon", + WhichTrackCollections = [0,1,1], + MuonTrackCollections = ["ExtrapolatedMuonSpectrometerTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + NPhiBins = 360, + UseTriggerVector = False, + MuonTriggerChainName = "NoMuonTriggerSelection" ) + #############MuonGenericTracksMon############# + MuonGenericTracksMon = MuonGenericTracksMon(name = "MuonGenericTracksMon", + WhichTrackCollections = [0,1,1], + MuonTrackCollections = ["ExtrapolatedMuonSpectrometerTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + NPhiBins = 360, + UseTriggerVector = False, + MuonTriggerChainName = "NoMuonTriggerSelection" ) + #############TGCStandaloneTracksMon_Trig############ + TGCStandaloneTracksMon_NoTrig = TGCStandaloneTracksMon(name = "TGCStandaloneTracksMon", + TriggerAware = False, + MuonTriggerChainName = "TriggersInChain") + ToolSvc += MuonSelectedTracksMon + ToolSvc += MuonGenericTracksMon + ToolSvc += TGCStandaloneTracksMon + monMan.AthenaMonTools += [ MuonSelectedTracksMon ] + monMan.AthenaMonTools += [ MuonGenericTracksMon ] + monMan.AthenaMonTools += [ TGCStandaloneTracksMon ] + +#############TriggerAware Trk Monitoring####################### +## set to true in case you would like to use trigger-aware monitoring +## only do trigger-aware monitoring if DQMonFlags.useTrigger is true +if not DQMonFlags.useTrigger(): + print "IDPerfMon_jobOptions.py: trigger decision tool not found: don't run trigger-aware monitoring" +else: + if MuonDQAFlags.MuonTrkMonDoTrigger and MuonDQAFlags.doMuonTrackMon: + #############MuonSelectedTracksMon_Trig############# + MuonSelectedTracksMon_Trig = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_Trig", + WhichTrackCollections = [0,1,1], + MuonTrackCollections = ["MooreTracks","ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + NPhiBins = 360, + UseTriggerVector = True, + MuonTriggerDecisionTool = "TrigDec::TrigDecisionTool", + Muon_Trigger_Items = ["EF_2mu10", "EF_2mu4", "EF_2mu6", "EF_mu10", "EF_mu20", "EF_mu40"], + MuonTriggerChainName = "TriggersInChain") + #############MuonGenericTracksMon_Trig############ + MuonGenericTracksMon_Trig = MuonGenericTracksMon(name = "MuonGenericTracksMon_Trig", + WhichTrackCollections = [0,1,1], + MuonTrackCollections = ["MooreTracks","ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + NPhiBins = 360, + UseTriggerVector = True, + MuonTriggerDecisionTool = "TrigDec::TrigDecisionTool", + Muon_Trigger_Items = ["EF_2mu10", "EF_2mu4", "EF_2mu6", "EF_mu10", "EF_mu20", "EF_mu40"], + MuonTriggerChainName = "TriggersInChain") + #############TGCStandaloneTracksMon_Trig############ + TGCStandaloneTracksMon_Trig = TGCStandaloneTracksMon(name = "TGCStandaloneTracksMon_Trig", + TriggerAware = False, + MuonTriggerDecisionTool = "TrigDec::TrigDecisionTool", + Muon_Trigger_Items = ["MU0", "MU4", "MU6", "MU10", "MU11", "MU15", "MU20", "MU40", "MU0_TGC", "MU6_TGC", "MU0_TGC_HALO" ], + MuonTriggerChainName = "TriggersInChain") + monMan.AthenaMonTools += [ MuonSelectedTracksMon_Trig ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_Trig] + monMan.AthenaMonTools += [ TGCStandaloneTracksMon_Trig] + + #############MuonSelectedTracksMon_Trig############# + MuonSelectedTracksMon_trig2mu4 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trig2mu4", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonSelectedTracksMon_trig2mu6 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trig2mu6", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonSelectedTracksMon_trigmu10 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trigmu10", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonSelectedTracksMon_trigmu20 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trigmu20", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonSelectedTracksMon_trigmu40 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trigmu40", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonSelectedTracksMon_trig2mu10 = MuonSelectedTracksMon(name = "MuonSelectedTracksMon_trig2mu10", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + #############MuonGenericTracksMon_Trig############# + MuonGenericTracksMon_trig2mu4 = MuonSelectedTracksMon(name = "MuonGenericTracksMon_trig2mu4", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonGenericTracksMon_trig2mu6 = MuonSelectedTracksMon(name = "MuonGenericTracksMon_trig2mu6", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False ) + MuonGenericTracksMon_trigmu10 = MuonGenericTracksMon(name = "MuonGenericTracksMon_trigmu10", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False) + MuonGenericTracksMon_trigmu20 = MuonGenericTracksMon(name = "MuonGenericTracksMon_trigmu20", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False) + MuonGenericTracksMon_trigmu40 = MuonGenericTracksMon(name = "MuonGenericTracksMon_trigmu40", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False) + MuonGenericTracksMon_trig2mu10 = MuonGenericTracksMon(name = "MuonGenericTracksMon_trig2mu10", + WhichTrackCollections = [0,1,1], EnableLumi = True, + MuonTrackCollections = ["MooreTracks" ,"ConvertedMBoyTracks", "MuidExtrapolatedTracks" ], + UseTriggerVector = False) + MuonSelectedTracksMon_trig2mu4.TrigDecisionTool = tdt + MuonSelectedTracksMon_trig2mu6.TrigDecisionTool = tdt + MuonSelectedTracksMon_trigmu10.TrigDecisionTool = tdt + MuonSelectedTracksMon_trigmu20.TrigDecisionTool = tdt + MuonSelectedTracksMon_trigmu40.TrigDecisionTool = tdt + MuonSelectedTracksMon_trig2mu10.TrigDecisionTool = tdt + MuonGenericTracksMon_trig2mu4.TrigDecisionTool = tdt + MuonGenericTracksMon_trig2mu6.TrigDecisionTool = tdt + MuonGenericTracksMon_trigmu10.TrigDecisionTool = tdt + MuonGenericTracksMon_trigmu20.TrigDecisionTool = tdt + MuonGenericTracksMon_trigmu40.TrigDecisionTool = tdt + MuonGenericTracksMon_trig2mu10.TrigDecisionTool = tdt + ##############Trigger Items for Muons############### + ##############MuonSelectedTracksMon################# + MuonSelectedTracksMon_trig2mu4.TriggerChain = "EF_2mu4" + MuonSelectedTracksMon_trig2mu6.TriggerChain = "EF_2mu6" + MuonSelectedTracksMon_trigmu10.TriggerChain = "EF_mu10" + MuonSelectedTracksMon_trigmu20.TriggerChain = "EF_mu20" + MuonSelectedTracksMon_trigmu40.TriggerChain = "EF_mu40" + MuonSelectedTracksMon_trig2mu10.TriggerChain = "EF_2mu10" + MuonSelectedTracksMon_trig2mu4.MuonTriggerChainName = "EF_2mu4" + MuonSelectedTracksMon_trig2mu6.MuonTriggerChainName = "EF_2mu6" + MuonSelectedTracksMon_trigmu10.MuonTriggerChainName = "EF_mu10" + MuonSelectedTracksMon_trigmu20.MuonTriggerChainName = "EF_mu20" + MuonSelectedTracksMon_trigmu40.MuonTriggerChainName = "EF_mu40" + MuonSelectedTracksMon_trig2mu10.MuonTriggerChainName = "EF_2mu10" + ##############MuonGenericTracksMon################# + MuonGenericTracksMon_trig2mu4.TriggerChain = "EF_2mu4" + MuonGenericTracksMon_trig2mu6.TriggerChain = "EF_2mu6" + MuonGenericTracksMon_trigmu10.TriggerChain = "EF_mu10" + MuonGenericTracksMon_trigmu20.TriggerChain = "EF_mu20" + MuonGenericTracksMon_trigmu40.TriggerChain = "EF_mu40" + MuonGenericTracksMon_trig2mu10.TriggerChain = "EF_2mu10" + MuonGenericTracksMon_trig2mu4.MuonTriggerChainName = "EF_2mu4" + MuonGenericTracksMon_trig2mu6.MuonTriggerChainName = "EF_2mu6" + MuonGenericTracksMon_trigmu10.MuonTriggerChainName = "EF_mu10" + MuonGenericTracksMon_trigmu20.MuonTriggerChainName = "EF_mu20" + MuonGenericTracksMon_trigmu40.MuonTriggerChainName = "EF_mu40" + MuonGenericTracksMon_trig2mu10.MuonTriggerChainName = "EF_2mu10" + ################################################### + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trig2mu4 ] + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trig2mu6 ] + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trigmu10 ] + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trigmu20 ] + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trigmu40 ] + monMan.AthenaMonTools += [ MuonSelectedTracksMon_trig2mu10 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trig2mu4 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trig2mu6 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trigmu10 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trigmu20 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trigmu40 ] + monMan.AthenaMonTools += [ MuonGenericTracksMon_trig2mu10 ] diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonGenericTracksMon.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonGenericTracksMon.cxx new file mode 100755 index 0000000000000000000000000000000000000000..b7d0976cc5e97b43524b059fff86d73d5eadda4e --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonGenericTracksMon.cxx @@ -0,0 +1,641 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// ================================================================================ +// MuonGenericTracksMon.cxx +// ------------------------------ +// AUTHORS: N. Benekos, E. Christidi, A. Cortes, A. Eppig, I. Nomidis, T. Liss +// B. Tong, Y. Liu, G. Cree +// created: November 2007 +// modified June 2008: for Trigger Aware monitoring : A. Cortes (UIUC) +// modified March 2015: XAOD migration and combination of track / segment / muon +// description: Implementation code for the MuonGenericTracksMon +// ============================================================================== + +#include "MuonTrackMonitoring/MuonGenericTracksMon.h" +#include "xAODEventInfo/EventInfo.h" +#include "TrkMultiComponentStateOnSurface/MultiComponentStateOnSurface.h" +#include "TrkMultiComponentStateOnSurface/MultiComponentState.h" +#include "TrkEventPrimitives/ResidualPull.h" +#include "TrkMeasurementBase/MeasurementBase.h" +#include "TrkTrack/TrackStateOnSurface.h" +#include "TrkTrack/TrackCollection.h" +#include "GaudiKernel/MsgStream.h" +//include Root dependencies +#include <TH1F.h> + +// ********************************************************************* +// Public Methods +// ********************************************************************* + +MuonGenericTracksMon::MuonGenericTracksMon( const std::string & type, const std::string & name, const IInterface* parent ) + :ManagedMonitorToolBase( type, name, parent ), + m_inst_lumi_bcid(0.0), + m_inst_lumi_lb(0.0), + m_current_lb(-1), + m_hNEvent(nullptr), + m_oRecoLumiPlots(0), + m_oRecoMuonSegmentPlots(0), + m_oRecoMuonMSTrackPlots(0), + m_oRecoMuonMETrackPlots(0), + m_oRecoMuonIDTrackPlots(0), + m_oRecoMuonPlots(0), + m_oRecoPhysPlots(0), + m_oRecoVertexPlots(0), + m_useTrigger(true) +{ + + declareProperty("UseTriggerVector", m_useTrigger); + declareProperty("MuonTriggerChainName", m_MuonTriggerChainName); + declareProperty("Muon_Trigger_Items", m_muon_triggers); + declareProperty("MuonCollection", m_muonsName = "Muons"); + declareProperty("MuonSegmentCollection", m_muonSegmentsName = "MuonSegments"); + declareProperty("MuonTrackCollection", m_muonTracksName = "MuonSpectrometerTrackParticles"); + declareProperty("MuonExtrapolatedTrackCollection", m_muonExtrapTracksName = "ExtrapolatedMuonTrackParticles"); + declareProperty("InDetTrackParticles", m_innerTracksName = "InDetTrackParticles"); + declareProperty("MSVertexCollection", m_msVertexCollection = "MSDisplacedVertex"); +} + +StatusCode MuonGenericTracksMon::initialize() { + ATH_CHECK(ManagedMonitorToolBase::initialize()); + ATH_CHECK(setupTools()); + return StatusCode::SUCCESS; +} + +//======================================================================================// +StatusCode MuonGenericTracksMon::bookHistograms() +//======================================================================================// +{ + ATH_MSG_DEBUG("In bookHistograms()"); + + if(!(m_environment == AthenaMonManager::tier0 || + m_environment == AthenaMonManager::tier0ESD || + m_environment == AthenaMonManager::online || + m_environment == AthenaMonManager::AOD)){ + + return StatusCode::SUCCESS; + } + + MgmtAttr_t attr = ATTRIB_MANAGED; + + //set the path with trigger chain name + std::string rootpath = "MuonPhysics/"; + + if(newRunFlag()) { + + //example of how to register a new histogram + m_hNEvent = new TH1F("Overview_nEvent", "Number of Events;LumiBlock;Nevents", 2000, -0.5, 1999.5); + + std::string dirpath; + dirpath = rootpath + m_MuonTriggerChainName + "/Overview"; + + MonGroup mongroup_gen_overview(this, dirpath, run, attr ); + bookInMongroup(m_hNEvent, mongroup_gen_overview).ignore(); + + if (m_MuonTriggerChainName != ""){ + //book lumi associated info + dirpath = m_MuonTriggerChainName + "Overview/" + m_sources[SOURCE::CBMUONS];//redefine for hist name + MonGroup mongroup_overview2(this, rootpath + dirpath, run, attr); + m_oRecoLumiPlots.push_back(new RecoLumiPlots(0, dirpath + "_", m_sources[SOURCE::CBMUONS])); + bookInMongroup(*m_oRecoLumiPlots[0], mongroup_overview2, m_sources[SOURCE::CBMUONS]).ignore(); + + dirpath = m_MuonTriggerChainName + "Overview/" + m_sources[SOURCE::NONCBMUONS];//redefine for hist name + MonGroup mongroup_overview3(this, rootpath + dirpath, run, attr); + m_oRecoLumiPlots.push_back(new RecoLumiPlots(0, dirpath + "_", m_sources[SOURCE::NONCBMUONS])); + bookInMongroup(*m_oRecoLumiPlots[1], mongroup_overview3, m_sources[SOURCE::NONCBMUONS]).ignore(); + + dirpath = m_MuonTriggerChainName + "Overview/" + m_sources[SOURCE::CONTAINER];//redefine for hist name + MonGroup mongroup_overview(this, rootpath + dirpath, run, attr); + m_oRecoLumiPlots.push_back(new RecoLumiPlots(0, dirpath + "_", m_sources[SOURCE::CONTAINER])); + bookInMongroup(*m_oRecoLumiPlots[2], mongroup_overview, m_sources[SOURCE::CONTAINER]).ignore(); + + //book segments + dirpath = m_MuonTriggerChainName + "Segments/" + m_sources[SOURCE::CBMUONS]; + MonGroup mongroup_segments2(this, rootpath + dirpath, run, attr); + m_oRecoMuonSegmentPlots.push_back(new RecoMuonSegmentPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonSegmentPlots[0], mongroup_segments2, m_sources[SOURCE::CBMUONS]).ignore(); + + dirpath = m_MuonTriggerChainName + "Segments/" + m_sources[SOURCE::NONCBMUONS]; + MonGroup mongroup_segments3(this, rootpath + dirpath, run, attr); + m_oRecoMuonSegmentPlots.push_back(new RecoMuonSegmentPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonSegmentPlots[1], mongroup_segments3, m_sources[SOURCE::NONCBMUONS]).ignore(); + + dirpath = m_MuonTriggerChainName + "Segments/" + m_sources[SOURCE::CONTAINER]; + MonGroup mongroup_segments(this, rootpath + dirpath, run, attr); + m_oRecoMuonSegmentPlots.push_back(new RecoMuonSegmentPlots(0, dirpath, true)); + bookInMongroup(*m_oRecoMuonSegmentPlots[2], mongroup_segments, m_sources[SOURCE::CONTAINER]).ignore(); + + //book MS tracks + dirpath = m_MuonTriggerChainName + "TracksMS/" + m_sources[SOURCE::CONTAINER]; + MonGroup mongroup_mstracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonMSTrackPlots.push_back(new RecoMuonTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonMSTrackPlots[0], mongroup_mstracks, m_sources[SOURCE::CONTAINER], "MS").ignore(); + + //book muons + dirpath = m_MuonTriggerChainName + "Muons/" + m_sources[SOURCE::CBMUONS]; + MonGroup mongroup_mutracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonPlots.push_back(new RecoMuonPlots(0, dirpath, true)); + bookInMongroup(*m_oRecoMuonPlots[0], mongroup_mutracks, m_sources[SOURCE::CBMUONS], "").ignore(); + + dirpath = m_MuonTriggerChainName + "Muons/" + m_sources[SOURCE::NONCBMUONS]; + MonGroup mongroup_mutracks2(this, rootpath + dirpath, run, attr); + m_oRecoMuonPlots.push_back(new RecoMuonPlots(0, dirpath, false)); + bookInMongroup(*m_oRecoMuonPlots[1], mongroup_mutracks2, m_sources[SOURCE::NONCBMUONS], "NonCB").ignore(); + + //book id tracks + dirpath = m_MuonTriggerChainName + "TracksID/" + m_sources[SOURCE::CBMUONS]; + MonGroup mongroup_idtracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonIDTrackPlots.push_back(new RecoMuonIDTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonIDTrackPlots[0], mongroup_idtracks, m_sources[SOURCE::CBMUONS], "ID").ignore(); + + dirpath = m_MuonTriggerChainName + "TracksID/" + m_sources[SOURCE::NONCBMUONS]; + MonGroup mongroup_idtracks2(this, rootpath + dirpath, run, attr); + m_oRecoMuonIDTrackPlots.push_back(new RecoMuonIDTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonIDTrackPlots[1], mongroup_idtracks2, m_sources[SOURCE::NONCBMUONS], "ID").ignore(); + + dirpath = m_MuonTriggerChainName + "TracksME/" + m_sources[SOURCE::CBMUONS]; + MonGroup mongroup_metracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonMETrackPlots.push_back(new RecoMuonTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonMETrackPlots[0], mongroup_metracks, m_sources[SOURCE::CBMUONS], "ME").ignore(); + + dirpath = m_MuonTriggerChainName + "TracksME/" + m_sources[SOURCE::NONCBMUONS]; + MonGroup mongroup_metracks2(this, rootpath + dirpath, run, attr); + m_oRecoMuonMETrackPlots.push_back(new RecoMuonTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonMETrackPlots[1], mongroup_metracks2, m_sources[SOURCE::NONCBMUONS], "ME").ignore(); + + dirpath = m_MuonTriggerChainName + "MSVertices/"; + MonGroup mongroup_msvertices(this, rootpath + dirpath, run, attr); + m_oRecoVertexPlots.push_back(new RecoVertexPlots(0, dirpath)); + bookInMongroup(*m_oRecoVertexPlots[0], mongroup_msvertices, m_sources[SOURCE::CONTAINER]).ignore(); + + } + else{ + for (int i = 0; i < SOURCE::N_SOURCE; i++) { + dirpath = "Overview/" + m_sources[i];//redefine for hist name + MonGroup mongroup_overview(this, rootpath + dirpath, run, attr); + m_oRecoLumiPlots.push_back(new RecoLumiPlots(0, dirpath + "_", m_sources[i])); + bookInMongroup(*m_oRecoLumiPlots[i], mongroup_overview, m_sources[i]).ignore(); + + dirpath = "Segments/" + m_sources[i]; + MonGroup mongroup_segments(this, rootpath + dirpath, run, attr); + + if(i == SOURCE::CBMUONS || i == SOURCE::CONTAINER){ + m_oRecoMuonSegmentPlots.push_back(new RecoMuonSegmentPlots(0, dirpath, true)); + } + else{ + m_oRecoMuonSegmentPlots.push_back(new RecoMuonSegmentPlots(0, dirpath, false)); + } + + bookInMongroup(*m_oRecoMuonSegmentPlots[i], mongroup_segments, m_sources[i]).ignore(); + + if(i > SOURCE::CBMUONS){//for MS tracks, only do not CB muons, since it overlaps with ME + dirpath = "TracksMS/" + m_sources[i]; + MonGroup mongroup_mstracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonMSTrackPlots.push_back(new RecoMuonTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonMSTrackPlots[i - 3], mongroup_mstracks, m_sources[i], "MS").ignore(); + } + + if(i != SOURCE::CONTAINER){//for IDME tracks and Muon, do not do container + dirpath = "Muons/" + m_sources[i]; + MonGroup mongroup_mutracks(this, rootpath + dirpath, run, attr); + if(i > SOURCE::CBMUONS){ + m_oRecoMuonPlots.push_back(new RecoMuonPlots(0, dirpath, false)); + } + else{ + m_oRecoMuonPlots.push_back(new RecoMuonPlots(0, dirpath, true)); + } + bookInMongroup(*m_oRecoMuonPlots[i], mongroup_mutracks, m_sources[i], "").ignore(); + + dirpath = "TracksME/" + m_sources[i]; + MonGroup mongroup_metracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonMETrackPlots.push_back(new RecoMuonTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonMETrackPlots[i], mongroup_metracks, m_sources[i], "ME").ignore(); + + dirpath = "TracksID/" + m_sources[i]; + MonGroup mongroup_idtracks(this, rootpath + dirpath, run, attr); + m_oRecoMuonIDTrackPlots.push_back(new RecoMuonIDTrackPlots(0, dirpath)); + bookInMongroup(*m_oRecoMuonIDTrackPlots[i], mongroup_idtracks, m_sources[i], "ID").ignore(); + } + + if(i == SOURCE::Z){ + dirpath = rootpath + "/MuonTrkPhys/" + m_sources[i]; + MonGroup mongroup_Zsignal(this, dirpath, run, attr); + m_oRecoPhysPlots.push_back(new RecoPhysPlots(0, "", m_sources[i]));//the naming for res is slightly diff + bookInMongroup(*m_oRecoPhysPlots[i], mongroup_Zsignal, m_sources[i]).ignore(); + } + if(i == SOURCE::JPSI){ + dirpath = rootpath + "/MuonTrkPhys/" + m_sources[i]; + MonGroup mongroup_Jpsisignal(this, dirpath, run, attr); + m_oRecoPhysPlots.push_back(new RecoPhysPlots(0, "", m_sources[i]));//the naming for res is slightly diff + bookInMongroup(*m_oRecoPhysPlots[i], mongroup_Jpsisignal, m_sources[i]).ignore(); + } + }//end of loopoing over different m_sources + }//end of different trigger situations + }//end of new run condition + + return StatusCode::SUCCESS; +} + +StatusCode MuonGenericTracksMon::bookInMongroup(TH1* hist, MonGroup& mongroup) +{ + ATH_MSG_DEBUG ("Initializing " << hist << " " << hist->GetName() << "..."); + return (mongroup.regHist(hist)); +} + +StatusCode MuonGenericTracksMon::bookInMongroup(HistData& hist, MonGroup& mongroup, std::string source) +{ + ATH_MSG_INFO ("Initializing " << hist.first << " " << hist.first->GetName() << " " << hist.second << "..."); + //change hist title + TString sHistTitle = hist.first->GetTitle(); + source = m_MuonTriggerChainName + source;//add trig titles here + std::replace( source.begin(), source.end(), '/', ' ');//name clean + sHistTitle = sHistTitle.Insert(0, (source + ": ").c_str()); + hist.first->SetTitle(sHistTitle); + + ATH_CHECK(mongroup.regHist(hist.first)); + return StatusCode::SUCCESS; +} + +StatusCode MuonGenericTracksMon::bookInMongroup(PlotBase& valPlots, MonGroup& mongroup, std::string source) +{ + valPlots.initialize(); + std::vector<HistData> hists = valPlots.retrieveBookedHistograms(); // HistData -> std::pair<TH1*, std::string> + for (auto hist: hists){ + bookInMongroup(hist, mongroup, source).ignore(); + } + return StatusCode::SUCCESS; +} + +StatusCode MuonGenericTracksMon::bookInMongroup(PlotBase& valPlots, MonGroup& mongroup, std::string source, TString Montype) +{ + valPlots.initialize(); + std::vector<HistData> hists = valPlots.retrieveBookedHistograms(); // HistData -> std::pair<TH1*, std::string> + for (auto hist: hists) { + + TString sHistName = hist.first->GetName(); + TString sHistTitle = hist.first->GetTitle(); + + // rebin and/or change the axis range label + // move rebin of all 2D eta_phi plots to post processing + + if (sHistName.Contains("_eta_phi")){ + hist.first->GetXaxis()->SetTitle("#eta"); + hist.first->GetYaxis()->SetTitle("#phi"); + } + else if (sHistName.EndsWith("_eta_pt")){ + hist.first->GetYaxis()->SetTitle("p_{T} [GeV]"); + hist.first->GetXaxis()->SetTitle("#eta"); + } + else if (sHistName.EndsWith("_eta")){ + hist.first->RebinX(2); + hist.first->GetXaxis()->SetTitle("#eta"); + } + else if (sHistName.EndsWith("_phi")){ + hist.first->RebinX(2); + hist.first->GetXaxis()->SetTitle("#phi"); + } + else if (sHistName.EndsWith("_pt")){ + hist.first->RebinX(2); + hist.first->GetXaxis()->SetLimits(0, 100);//consider repace with SetLimits(0, 100) + hist.first->GetXaxis()->SetTitle("p_{T} [GeV]"); + } + else if (sHistName.EndsWith("_ddpt")){ + hist.first->RebinX(3); + } + else if (sHistName.EndsWith("_z0")){ + hist.first->RebinX(2); + } + else if (sHistName.EndsWith("_d0")){ + hist.first->RebinX(2); + } + + // for ID track hits, special treatment + if (sHistName.Contains("HitContent")){ + hist.first->SetName(pathToHistName(m_MuonTriggerChainName) + "Tracks" + Montype + "_" + source + "_" + sHistName); + } + + // change histogram title + if (Montype != ""){//do this only for tracks + if (sHistTitle.Contains("Track")) { + sHistTitle = sHistTitle.Replace(0, 6, Montype + " Track "); + hist.first->SetTitle(sHistTitle); + } + else if (sHistTitle.Contains("Reco Muon")) { + sHistTitle = sHistTitle.Replace(0, 9, Montype + " Track "); + hist.first->SetTitle(sHistTitle); + } + else hist.first->SetTitle(Montype + " Track " + sHistTitle); + } + + bookInMongroup(hist, mongroup, source).ignore(); + } + return StatusCode::SUCCESS; +} + +//======================================================================================// +StatusCode MuonGenericTracksMon::fillHistograms() +{ + ATH_MSG_DEBUG("In fillHistograms()"); + const xAOD::EventInfo* eventInfo=nullptr; + ATH_CHECK(evtStore()->retrieve(eventInfo)); + + if(!(m_environment == AthenaMonManager::tier0 || + m_environment == AthenaMonManager::tier0ESD || + m_environment == AthenaMonManager::online || + m_environment == AthenaMonManager::AOD)){ + + return StatusCode::SUCCESS; + } + + ATH_MSG_DEBUG("LB " << eventInfo->lumiBlock() << + " instant " << ManagedMonitorToolBase::lbLuminosityPerBCID() << + " average " << ManagedMonitorToolBase::lbAverageLuminosity() << + " duration " << ManagedMonitorToolBase::lbDuration() << + " lbint " << ManagedMonitorToolBase::lbInteractionsPerCrossing() + ); + m_current_lb = eventInfo->lumiBlock(); + m_hNEvent->Fill(m_current_lb, 1); + + m_inst_lumi_bcid = ManagedMonitorToolBase::lbLuminosityPerBCID(); + if(m_inst_lumi_bcid < 0){ + ATH_MSG_DEBUG("Weird instantaneous luminosity per bcid. Setting to 0."); + m_inst_lumi_bcid = 0; + } + m_inst_lumi_lb = ManagedMonitorToolBase::lbAverageLuminosity(); + if(m_inst_lumi_lb < 0){ + ATH_MSG_DEBUG("Weird instantaneous luminosity per lb. Setting to 0."); + m_inst_lumi_lb = 0; + } + + // retrieve containers + const xAOD::MuonSegmentContainer* MuonSegments=nullptr; + ATH_CHECK(evtStore()->retrieve(MuonSegments, m_muonSegmentsName)); + const xAOD::TrackParticleContainer* tracksMS=nullptr; + ATH_CHECK(evtStore()->retrieve(tracksMS, m_muonTracksName)); + const xAOD::MuonContainer* Muons=nullptr; + ATH_CHECK(evtStore()->retrieve(Muons, m_muonsName)); + const xAOD::VertexContainer* MSVertices=nullptr; + ATH_CHECK(evtStore()->retrieve(MSVertices, m_msVertexCollection)); + + // check validity + if (!MuonSegments){ + ATH_MSG_WARNING ("Couldn't retrieve MuonSegments container: " << m_muonSegmentsName); + return StatusCode::SUCCESS; + } + if (!tracksMS) { + ATH_MSG_WARNING ("Couldn't retrieve MS tracks container: " << m_muonTracksName); + return StatusCode::SUCCESS; + } + if (!Muons){ + ATH_MSG_WARNING ("Couldn't retrieve Muons container: " << m_muonsName); + return StatusCode::SUCCESS; + } + if (!MSVertices){ + ATH_MSG_WARNING ("Couldn't retrieve MS vertex container: " << m_msVertexCollection); + return StatusCode::SUCCESS; + } + + // fill the histograms + if (m_MuonTriggerChainName != ""){ + // plot luminosity related plots + plot_lumi_notrig(Muons, tracksMS, MuonSegments); + + // plot segments container + for (const xAOD::MuonSegment* segment : *MuonSegments) + { + plot_segment(*segment, 2);//be consistent! + } + + // plot tracks (MS) container + for (const xAOD::TrackParticle* track: *tracksMS) + { + plot_track(*track, 0); + } + + // plot Muon container + for (const xAOD::Muon* muon: *Muons) + { + if(muon->muonType() == xAOD::Muon::Combined) { + plot_muon_notrig(*muon, 0); + } + else { + plot_muon_notrig(*muon, 1); + } + } + // plot ms vertices + for (const xAOD::Vertex* aVx: *MSVertices) + { + plot_vertex(*aVx, 0); + } + } + else{ + // select muons from Jpsi & Z + auto muons_jpsi = m_JpsimumuResonanceSelectionTool->selectMuons(Muons, false, CP::SystematicSet()); + auto muons_Z = m_ZmumuResonanceSelectionTool->selectMuons(Muons, false, CP::SystematicSet()); + + // find J/psi & Z candidates + auto resonances_jpsi = m_JpsimumuResonancePairingTool->buildPairs(muons_jpsi); + auto resonances_Z = m_ZmumuResonancePairingTool->buildPairs(muons_Z); + // plot luminosity related plots + plot_lumi(resonances_Z, resonances_jpsi, Muons, tracksMS, MuonSegments); + + // plot muons, Z and Jpsi, only for collisions + if (m_dataType != AthenaMonManager::cosmics){ + for (auto resonance: resonances_Z) + { + plot_muon(*resonance.first, SOURCE::Z); + plot_muon(*resonance.second, SOURCE::Z); + } + plot_resonances(resonances_Z, SOURCE::Z); + + // plot muons, J/Psi + for (auto resonance: resonances_jpsi) + { + plot_muon(*resonance.first, SOURCE::JPSI); + plot_muon(*resonance.second, SOURCE::JPSI); + } + plot_resonances(resonances_jpsi, SOURCE::JPSI); + } + + // plot muons, all + for (const xAOD::Muon* muon: *Muons) + { + if(muon->muonType() == xAOD::Muon::Combined) { + plot_muon(*muon, SOURCE::CBMUONS); + } + else { + plot_muon(*muon, SOURCE::NONCBMUONS); + } + } + + // plot segments container + for (const xAOD::MuonSegment* segment : *MuonSegments) + { + plot_segment(*segment, SOURCE::CONTAINER); + } + + // plot tracks (MS) container + for (const xAOD::TrackParticle* track: *tracksMS) + { + plot_track(*track, SOURCE::CONTAINER - 3); + } + //clean the resonance candidates + for (const xAOD::Muon* muon : muons_jpsi.first) delete muon; + for (const xAOD::Muon* muon : muons_jpsi.second) delete muon; + for (const xAOD::Muon* muon : muons_Z.first) delete muon; + for (const xAOD::Muon* muon : muons_Z.second) delete muon; + }//end of different trigger situations + //finish all the plotting + return StatusCode::SUCCESS; +} + +//======================================================================================// +void MuonGenericTracksMon::plot_lumi( + std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances_Z, + std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances_jpsi, + const xAOD::MuonContainer* Muons, + const xAOD::TrackParticleContainer* tracksMS, + const xAOD::MuonSegmentContainer* MuonSegments) +//======================================================================================// +{ + //fill all the luminoisty related plot + m_oRecoLumiPlots[SOURCE::Z]->fill(resonances_Z, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[SOURCE::JPSI]->fill(resonances_jpsi, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[SOURCE::CBMUONS]->fill_CB(Muons, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[SOURCE::NONCBMUONS]->fill_Other(Muons, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[SOURCE::CONTAINER]->fill(tracksMS, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[SOURCE::CONTAINER]->fill(MuonSegments, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); +} + + +//======================================================================================// +void MuonGenericTracksMon::plot_lumi_notrig( + const xAOD::MuonContainer* Muons, + const xAOD::TrackParticleContainer* tracksMS, + const xAOD::MuonSegmentContainer* MuonSegments) +//======================================================================================// +{ + //fill all the luminoisty related plot + m_oRecoLumiPlots[0]->fill_CB(Muons, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[1]->fill_Other(Muons, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[2]->fill(tracksMS, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); + m_oRecoLumiPlots[2]->fill(MuonSegments, m_current_lb, m_inst_lumi_bcid, m_inst_lumi_lb); +} + +//======================================================================================// +void MuonGenericTracksMon::plot_muon(const xAOD::Muon& muon, int source) +//======================================================================================// +{ + + + xAOD::Muon::Quality my_quality = m_muonSelectionTool->getQuality(muon); + ATH_MSG_DEBUG ("Muon quality value: " << my_quality << " default value " << muon.quality()); + + m_oRecoMuonPlots[source]->fill(muon); + if (source == SOURCE::NONCBMUONS) m_oRecoMuonMSTrackPlots[source - 3]->fill(muon, MUON_COMPONENT::TRACK_MS); + m_oRecoMuonMETrackPlots[source]->fill(muon, MUON_COMPONENT::TRACK_ME); + m_oRecoMuonIDTrackPlots[source]->fill(muon, MUON_COMPONENT::TRACK_ID); + m_oRecoMuonSegmentPlots[source]->fill(muon); + m_oRecoMuonPlots[source]->fill(muon, my_quality); +} + +//======================================================================================// +void MuonGenericTracksMon::plot_muon_notrig(const xAOD::Muon& muon, int source) +//======================================================================================// +{ + xAOD::Muon::Quality my_quality = m_muonSelectionTool->getQuality(muon); + ATH_MSG_DEBUG ("Muon quality value: " << my_quality << " default value " << muon.quality()); + + m_oRecoMuonPlots[source]->fill(muon); + m_oRecoMuonPlots[source]->fill(muon, my_quality); + m_oRecoMuonIDTrackPlots[source]->fill(muon, MUON_COMPONENT::TRACK_ID); + m_oRecoMuonMETrackPlots[source]->fill(muon, MUON_COMPONENT::TRACK_ME); + m_oRecoMuonSegmentPlots[source]->fill(muon); +} + +//======================================================================================// +void MuonGenericTracksMon::plot_segment(const xAOD::MuonSegment& segment, int source) +//======================================================================================// +{ + + m_oRecoMuonSegmentPlots[source]->fill(segment); +} + +//======================================================================================// +void MuonGenericTracksMon::plot_track(const xAOD::TrackParticle& track, int source) +//======================================================================================// +{ + + m_oRecoMuonMSTrackPlots[source]->fill(track); +} +//======================================================================================// +void MuonGenericTracksMon::plot_vertex(const xAOD::Vertex& aVx, int source) +//======================================================================================// +{ + + m_oRecoVertexPlots[source]->fill(aVx); +} + +//======================================================================================// +void MuonGenericTracksMon::plot_resonances(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances, int source) +//======================================================================================// +{ + m_oRecoPhysPlots[source]->fill(resonances); + +} + +//======================================================================================// +StatusCode MuonGenericTracksMon::procHistograms() +//======================================================================================// +{ + if(!(m_environment == AthenaMonManager::tier0 || + m_environment == AthenaMonManager::tier0ESD || + m_environment == AthenaMonManager::online || + m_environment == AthenaMonManager::AOD)){ + + return StatusCode::SUCCESS; + } + + ATH_MSG_DEBUG("MuonTrackMonitoring procHistograms()"); + + if(endOfRunFlag()) { + + //finish the post processing + + //remove all the pointers + for (auto plots : m_oRecoLumiPlots) delete plots; + for (auto plots : m_oRecoMuonSegmentPlots) delete plots; + for (auto plots : m_oRecoMuonMSTrackPlots) delete plots; + for (auto plots : m_oRecoMuonMETrackPlots) delete plots; + for (auto plots : m_oRecoMuonIDTrackPlots) delete plots; + for (auto plots : m_oRecoMuonPlots) delete plots; + for (auto plots : m_oRecoPhysPlots) delete plots; + for (auto plots : m_oRecoVertexPlots) delete plots; + + } + + return StatusCode::SUCCESS; +} + +//======================================================================================// +StatusCode MuonGenericTracksMon::setupTools() +//======================================================================================// +{ + ATH_CHECK(m_ZmumuResonanceSelectionTool.retrieve()); + ATH_MSG_DEBUG( "Retrieved " << m_ZmumuResonanceSelectionTool ); + + ATH_CHECK(m_ZmumuResonancePairingTool.retrieve()); + ATH_MSG_DEBUG( "Retrieved " << m_ZmumuResonancePairingTool ); + + ATH_CHECK(m_JpsimumuResonanceSelectionTool.retrieve()); + ATH_MSG_DEBUG( "Retrieved " << m_JpsimumuResonanceSelectionTool ); + + ATH_CHECK(m_JpsimumuResonancePairingTool.retrieve()); + ATH_MSG_DEBUG( "Retrieved " << m_JpsimumuResonancePairingTool ); + + ATH_CHECK(m_muonSelectionTool.retrieve()); + ATH_MSG_DEBUG( "Retrieved " << m_muonSelectionTool ); + + return StatusCode::SUCCESS; +} diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.cxx index 732e53a50c501a28ab3682ca828eb570a7b49f66..fc7a344c1d6232e9375468df4c942652ea7dd242 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/MuonTrackMonitorAlgorithm.cxx @@ -3,7 +3,7 @@ 2020 Matthias Schott - Uni Mainz */ -#include "MuonTrackMonitorAlgorithm.h" +#include "MuonTrackMonitoring/MuonTrackMonitorAlgorithm.h" MuonTrackMonitorAlgorithm::MuonTrackMonitorAlgorithm (const std::string& name, ISvcLocator* pSvcLocator) :AthMonitorAlgorithm(name,pSvcLocator){} @@ -413,10 +413,8 @@ StatusCode MuonTrackMonitorAlgorithm::fillHistograms(const EventContext& ctx) co ATH_CHECK( analyseLowLevelMuonFeatures(*Muons, lumiBlockID) ); ATH_CHECK( analyseCombinedTracks(*Muons, lumiBlockID) ); - if (dataType() != DataType_t::cosmics) { - ATH_CHECK( analyseZBosonCandidates(*Muons, lumiBlockID) ); - ATH_CHECK( analyseJPsiCandidates(*Muons, lumiBlockID) ); - } + ATH_CHECK( analyseZBosonCandidates(*Muons, lumiBlockID) ); + ATH_CHECK( analyseJPsiCandidates(*Muons, lumiBlockID) ); return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/PlotMuons.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/PlotMuons.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2686219f6b16108a03e259c0db1f40288c389f0b --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/PlotMuons.cxx @@ -0,0 +1,21 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/PlotMuons.h" + +PlotMuons::PlotMuons(PlotBase* pParent, std::string sDir):PlotBase(pParent, sDir), + m_plots_All(this, "/", "Plot Muons"), + m_plots_RecoInfo(this, "/"), + m_plots_MomentumPull(this, "/"), + m_plots_MuonHitSummary(this, "/") +{} + +void PlotMuons::fill(const xAOD::Muon& muon){ + + m_plots_All.fill(muon); + m_plots_RecoInfo.fill(muon); + m_plots_MomentumPull.fill(muon); + m_plots_MuonHitSummary.fill(muon); + +} diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoLumiPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoLumiPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..012a689904b7efdbea3c938c255af5ca2e263dcf --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoLumiPlots.cxx @@ -0,0 +1,119 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoLumiPlots.h" + +RecoLumiPlots::RecoLumiPlots(PlotBase* pParent, std::string sDir, std::string recObj):PlotBase(pParent, sDir), + + m_hNSegment_LB_1D(nullptr), + m_hNMuonTrack_LB_1D(nullptr), + m_hNMuon_LB_1D(nullptr), + m_hNResonance_LB_1D(nullptr), + + m_hNSegment_LB(nullptr), + m_hNMuonTrack_LB(nullptr), + m_hNMuon_LB(nullptr), + m_hNResonance_LB(nullptr), + + type(recObj), + name("other") +{} + +void RecoLumiPlots::initializePlots() +{ + + //Specify the names for different resonances + std::string Zsig("Z"); + std::string Jsig("Jpsi"); + std::string CBMuons("CBMuons"); + std::string OtherMuons("NonCBMuons"); + + if (!type.compare(Zsig)) {name = "Z"; } + else if (!type.compare(Jsig)) {name = "J/#psi"; } + else if (!type.compare(CBMuons)) {name = "CBMuons"; } + else if (!type.compare(OtherMuons)) {name = "NonCBMuons";} + else {name = "other"; } + + n_lbs = 2500; + + //Make sure the 1D hists has the same dimension as the 2D! + if (name == "other"){ + m_hNSegment_LB = Book2D("nSegment_LB_2D", "Number of Muon Segments Per LumiBlock;LumiBlock;Number of Segments", n_lbs, -0.5, (float)(n_lbs)-0.5, 100, 0.5, 101.5); + m_hNMuonTrack_LB = Book2D("nMuonTrack_LB_2D", "Number of Muon MS Tracks Per LumiBlock;LumiBlock;Number of Tracks", n_lbs, -0.5, (float)(n_lbs)-0.5, 21, 0.5, 21.5); + m_hNSegment_LB_1D = Book1D("nSegment_LB", "Number of Muon Segments Per LumiBlock;LumiBlock;Number of Segments", n_lbs, -0.5, (float)(n_lbs)-0.5); + m_hNMuonTrack_LB_1D = Book1D("nMuonTrack_LB", "Number of Muon MS Tracks Per LumiBlock;LumiBlock;Number of Tracks", n_lbs, -0.5, (float)(n_lbs)-0.5); + } + else if (name == "CBMuons"){ + m_hNMuon_LB = Book2D("nMuon_LB_2D", "Number of Muons Per LumiBlock;LumiBlock;Nmuons", n_lbs, -0.5, (float)(n_lbs)-0.5, 21, 0.5, 21.5); + m_hNMuon_LB_1D = Book1D("nMuon_LB", "Number of Muons Per LumiBlock;LumiBlock;Nmuons", n_lbs, -0.5, (float)(n_lbs)-0.5); + } + else if (name == "NonCBMuons"){ + m_hNMuon_LB = Book2D("nMuon_LB_2D", "Number of non-CB Muons Per LumiBlock;LumiBlock;Nmuons", n_lbs, -0.5, (float)(n_lbs)-0.5, 21, 0.5, 21.5); + m_hNMuon_LB_1D = Book1D("nMuon_LB", "Number of non-CB Muons Per LumiBlock;LumiBlock;Nmuons", n_lbs, -0.5, (float)(n_lbs)-0.5); + } + else if (name == "Z" || name == "J/#psi"){ + m_hNResonance_LB = Book2D("n" + type + "_LB_2D", "Number of " + name + " Per LumiBlock;LumiBlock;Number of " + name, n_lbs, -0.5, (float)(n_lbs)-0.5, 5, 0.5, 5.5); + m_hNResonance_LB_1D = Book1D("n" + type + "_LB", "Number of " + name + " Per LumiBlock;LumiBlock;Number of " + name, n_lbs, -0.5, (float)(n_lbs)-0.5); + } + +} + +//fill Segment related lb plots +void RecoLumiPlots::fill(const xAOD::MuonSegmentContainer* MuonSegments, int current_lb, float inst_lumi_bcid, float inst_lumi_lb) { + + m_hNSegment_LB->Fill(current_lb, MuonSegments->size() + inst_lumi_bcid - inst_lumi_bcid + inst_lumi_lb - inst_lumi_lb); + +} + +//fill Track related plots +void RecoLumiPlots::fill(const xAOD::TrackParticleContainer* MSTracks, int current_lb, float inst_lumi_bcid, float inst_lumi_lb){ + + m_hNMuonTrack_LB->Fill(current_lb, MSTracks->size() + inst_lumi_bcid - inst_lumi_bcid + inst_lumi_lb - inst_lumi_lb); + +} + +//fill CB muon related plots +void RecoLumiPlots::fill_CB(const xAOD::MuonContainer* Muons, int current_lb, float inst_lumi_bcid, float inst_lumi_lb){ + + int NMuIDco = 0; + + for(const auto mu : *Muons) { + + //do a muon quality cut: 0 tight, 1 medium, 2 loss + if(mu->muonType() == xAOD::Muon::Combined){NMuIDco++;} + + } + + //only do this for combined muons + m_hNMuon_LB->Fill(current_lb, NMuIDco + inst_lumi_bcid - inst_lumi_bcid + inst_lumi_lb - inst_lumi_lb); + +} + +//fill other muon related plots +void RecoLumiPlots::fill_Other(const xAOD::MuonContainer* Muons, int current_lb, float inst_lumi_bcid, float inst_lumi_lb){ + + int NMuIDco = 0; + + for(const auto mu : *Muons) { + + //do a muon quality cut: 0 tight, 1 medium, 2 loss + if(mu->muonType() != xAOD::Muon::Combined){NMuIDco++;} + + } + + //only do this for combined muons + m_hNMuon_LB->Fill(current_lb, NMuIDco + inst_lumi_bcid - inst_lumi_bcid + inst_lumi_lb - inst_lumi_lb); + +} + +//fill muon related plots +void RecoLumiPlots::fill(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > resonances, int current_lb, float inst_lumi_bcid, float inst_lumi_lb){ + + int Nresonance = resonances.size(); + + //only do this for combined muons + m_hNResonance_LB->Fill(current_lb, Nresonance + inst_lumi_bcid - inst_lumi_bcid + inst_lumi_lb - inst_lumi_lb);//playing really dumb here + +} + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonIDTrackPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonIDTrackPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8721581deea9fba3da71004c59323fd0d3244463 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonIDTrackPlots.cxx @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoMuonIDTrackPlots.h" + +RecoMuonIDTrackPlots::RecoMuonIDTrackPlots(PlotBase* pParent, std::string sDir):PlotBase(pParent, sDir), +m_oAllPlots(this, "/", "Reco Muon"), +m_oImpactPlots(this, "/"), +m_oTrkRecoInfoPlots(this, "/"), +m_oIDHitPlots(this,"/"), +m_pt_broad(nullptr), +m_eta_phi_broad(nullptr) +{} + +void RecoMuonIDTrackPlots::initializePlots(){ + //booking histograms + m_pt_broad = Book1D("_pt_broad", "High p_{T} Distribution", 70, 100, 1500); + m_eta_phi_broad = Book2D("_eta_phi_broad", "High p_{T} Muon #eta #phi Distribution;;#eta;#phi", 52, -2.6, 2.6, 64, -3.2, 3.2); +} + +//when the plot function called with a Muon Container +//loop through each muon, get the corresponding link and fill it + +//when the plot function called with a Muon +//get's the corresponding link and fill it +void RecoMuonIDTrackPlots::fill(const xAOD::Muon& mu, int component){ + if (component == 2 ){ + ElementLink<xAOD::TrackParticleContainer> Mu_idtrack = mu.inDetTrackParticleLink(); + if(Mu_idtrack.isValid()){ + const xAOD::TrackParticle* trk = *Mu_idtrack; + fill(*trk); + } + } +} + + +void RecoMuonIDTrackPlots::fill(const xAOD::TrackParticle& muTP){ + m_oAllPlots.fill(muTP); + m_oImpactPlots.fill(muTP); + m_oTrkRecoInfoPlots.fill(muTP); + m_oIDHitPlots.fill(muTP); + if (muTP.pt()/1000.0 > 100) {//ony for high pt muons + m_pt_broad->Fill(muTP.pt()/1000.0); + m_eta_phi_broad->Fill(muTP.eta(), muTP.phi()); + } + +} + + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3567138624c20015302fe3e4b20b27b0404fcfb7 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonPlots.cxx @@ -0,0 +1,188 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoMuonPlots.h" +#include "MuonHistUtils/MuonEnumDefs.h" +typedef ElementLink< xAOD::TrackParticleContainer > TrackLink; +typedef ElementLink< xAOD::MuonContainer > MuonLink; + +RecoMuonPlots::RecoMuonPlots(PlotBase* pParent, std::string sDir, bool detail):PlotBase(pParent, sDir) + +, m_oAllPlots(this, "/", "Reco Muon") +, m_oMuRecoInfoPlots(this, "/") +, m_oImpactPlots(this, "/") +, m_oMomentumPullPlots(this, "/") +, m_origin_eta_phi(nullptr) +, m_eff_tight(nullptr) +, m_eff_medium(nullptr) +, m_tight_eta_phi(nullptr) +, m_medium_eta_phi(nullptr) +, m_pt_broad(nullptr) +, m_eta_phi_broad(nullptr) +, m_eff_nPrec(nullptr) +, m_eff_nPhi(nullptr) +, m_eff_nTrigEta(nullptr) +, m_eff_ndof(nullptr) +, m_eff_chi2(nullptr) +, m_ID_eff_ndof(nullptr) +, m_ID_eff_chi2(nullptr) +, m_MS_eff_ndof(nullptr) +, m_MS_eff_chi2(nullptr) +{ + Detail = detail; +} + +void RecoMuonPlots::initializePlots(){ + //be very careful here, bin size is the same as the defult value + std::vector<HistData> hists = m_oAllPlots.retrieveBookedHistograms(); // HistData -> std::pair<TH1*, std::string> + int xbins = 52; + int ybins = 64; + float xmin = -2.6; + float xmax = 2.6; + float ymin = -3.2; + float ymax = 3.2; + + //now register! + m_origin_eta_phi= Book2D("_Origin_eta_phi", "Original Distribution;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_tight = Book2D("_Tight_eff", "Tight Quality Efficiency;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_medium = Book2D("_Medium_eff", "Medium Quality Efficiency;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_tight_eta_phi = Book2D("_Tight_eta_phi", "Tight Muon #eta #phi Distribution;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_medium_eta_phi = Book2D("_Medium_eta_phi", "Medium Muon #eta #phi Distribution;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + if (Detail){ + m_pt_broad = Book1D("_pt_broad", "High p_{T} Distribution;p_{T} [GeV]", 70, 100, 1500); + m_eta_phi_broad = Book2D("_eta_phi_broad", "High p_{T} Muon #eta #phi Distribution;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + m_eff_nPrec = Book2D("_eff_nPrec", "average number of Precision Layers;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_nPhi = Book2D("_eff_nPhi", "average number of Phi Layers;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_nTrigEta = Book2D("_eff_nTrigEta","average number of Trigger Eta Layers;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_ndof = Book2D("_eff_ndof", "average number of hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_eff_chi2 = Book2D("_eff_chi2", "average #chi^{2} per DOF;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_ID_eff_ndof = Book2D("_ID_eff_ndof", "ID track average number of hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_ID_eff_chi2 = Book2D("_ID_eff_chi2", "ID track average #chi^{2} per DOF;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_MS_eff_ndof = Book2D("_MS_eff_ndof", "MS track average number of hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_MS_eff_chi2 = Book2D("_MS_eff_chi2", "MS track average #chi^{2} per DOF;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + m_avg_hits_precision_inner = Book2D("_avg_hits_precision_inner", "avg. precision hits, inner;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_precision_middle = Book2D("_avg_hits_precision_middle", "avg. precision hits, middle;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_precision_outer = Book2D("_avg_hits_precision_outer", "avg. precision hits, outer;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_precision_extended = Book2D("_avg_hits_precision_extended", "avg. precision hits, extended;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + m_avg_hits_trigger_layer1 = Book2D("_avg_hits_trigger_layer1", "avg. trigger hits, layer 1;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_trigger_layer2 = Book2D("_avg_hits_trigger_layer2", "avg. trigger hits, layer 2;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_trigger_layer3 = Book2D("_avg_hits_trigger_layer3", "avg. trigger hits, layer 3;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_trigger_layer4 = Book2D("_avg_hits_trigger_layer4", "avg. trigger hits, layer 4;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + m_avg_hits_ibl = Book2D("_avg_hits_ibl", "avg. IBL hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_pix = Book2D("_avg_hits_pix", "avg. Pix hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_sct = Book2D("_avg_hits_sct", "avg. SCT hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_hits_trt = Book2D("_avg_hits_trt", "avg. TRT hits;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + m_avg_ddpt_idme = Book2D("_avg_ddpt_idme", "avg. |pt_{ID} - pt_{ME}| / pt_{CB};#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + m_avg_dptsignif = Book2D("_avg_dptsignif", "avg. momentum diff. signif.;#eta;#phi", xbins, xmin, xmax, ybins, ymin, ymax); + + } +} + +void RecoMuonPlots::fill(const xAOD::Muon& mu){ + //General Plots + m_oAllPlots.fill(mu); + m_oMuRecoInfoPlots.fill(mu); + m_oMomentumPullPlots.fill(mu); + + const xAOD::TrackParticle* primaryTrk = mu.trackParticle(xAOD::Muon::Primary); + // tracking related plots + if (!primaryTrk) return; + m_oImpactPlots.fill(*primaryTrk); + //m_oMSHitPlots.fill(*primaryTrk); + +} + +void RecoMuonPlots::fill(const xAOD::Muon& mu, xAOD::Muon::Quality my_quality){ + + //always fill the origin plot + m_origin_eta_phi->Fill(mu.eta(), mu.phi()); + + //General Plots; inclusive + if (my_quality <= xAOD::Muon::Tight) m_tight_eta_phi->Fill(mu.eta(), mu.phi()); + if (my_quality <= xAOD::Muon::Medium) m_medium_eta_phi->Fill(mu.eta(), mu.phi()); + + if(!Detail) return; + if (mu.pt()/1000.0 > 100) {//ony for high pt muons + m_pt_broad->Fill(mu.pt()/1000.0); + m_eta_phi_broad->Fill(mu.eta(), mu.phi()); + } + const xAOD::TrackParticle* primaryTrk = mu.trackParticle(xAOD::Muon::Primary); + const xAOD::TrackParticle* inDetTrk = mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle); + int correctEnum = (int) xAOD::Muon::MuonSpectrometerTrackParticle; + if (mu.isAvailable< ElementLink<xAOD::TrackParticleContainer> >("extrapolatedMuonSpectrometerTrackParticleLink") && (mu.auxdata< ElementLink<xAOD::TrackParticleContainer> >("extrapolatedMuonSpectrometerTrackParticleLink")).isValid()) correctEnum+=2; //check correct numbering in Muon.h + const xAOD::TrackParticle* msExtrapTrk = mu.trackParticle((xAOD::Muon::TrackParticleType) correctEnum); + + //fill the ndof and chi2 as eta phi map; to calculate efficiencies in post processing + //if necessary, can use a quality cut here + if (primaryTrk) { + m_eff_ndof->Fill(primaryTrk->eta(), primaryTrk->phi(), primaryTrk->numberDoF()); + m_eff_chi2->Fill(primaryTrk->eta(), primaryTrk->phi(), primaryTrk->chiSquared()/(primaryTrk->numberDoF() * 1.0)); + } + if (inDetTrk) { + m_ID_eff_ndof->Fill(inDetTrk->eta(), inDetTrk->phi(), inDetTrk->numberDoF()); + m_ID_eff_chi2->Fill(inDetTrk->eta(), inDetTrk->phi(), inDetTrk->chiSquared()/(inDetTrk->numberDoF() * 1.0)); + } + if (msExtrapTrk) { + m_MS_eff_ndof->Fill(msExtrapTrk->eta(), msExtrapTrk->phi(), msExtrapTrk->numberDoF()); + m_MS_eff_chi2->Fill(msExtrapTrk->eta(), msExtrapTrk->phi(), msExtrapTrk->chiSquared()/(msExtrapTrk->numberDoF() * 1.0)); + } + + if (!primaryTrk->summaryValue(hitval_numberOfPrecisionLayers, xAOD::numberOfPrecisionLayers)) return; + if (!primaryTrk->summaryValue(hitval_numberOfPhiLayers, xAOD::numberOfPhiLayers)) return; + if (!primaryTrk->summaryValue(hitval_numberOfTriggerEtaLayers, xAOD::numberOfTriggerEtaLayers)) return; + + if (!mu.summaryValue(hitval_innerSmallHits, xAOD::MuonSummaryType::innerSmallHits)) return; + if (!mu.summaryValue(hitval_innerLargeHits, xAOD::MuonSummaryType::innerLargeHits)) return; + if (!mu.summaryValue(hitval_middleSmallHits, xAOD::MuonSummaryType::middleSmallHits)) return; + if (!mu.summaryValue(hitval_middleLargeHits, xAOD::MuonSummaryType::middleLargeHits)) return; + if (!mu.summaryValue(hitval_outerSmallHits, xAOD::MuonSummaryType::outerSmallHits)) return; + if (!mu.summaryValue(hitval_outerLargeHits, xAOD::MuonSummaryType::outerLargeHits)) return; + if (!mu.summaryValue(hitval_extendedSmallHits, xAOD::MuonSummaryType::extendedSmallHits)) return; + if (!mu.summaryValue(hitval_extendedLargeHits, xAOD::MuonSummaryType::extendedLargeHits)) return; + + if (!mu.summaryValue(hitval_etaLayer1Hits, xAOD::MuonSummaryType::etaLayer1Hits)) return; + if (!mu.summaryValue(hitval_etaLayer2Hits, xAOD::MuonSummaryType::etaLayer2Hits)) return; + if (!mu.summaryValue(hitval_etaLayer3Hits, xAOD::MuonSummaryType::etaLayer3Hits)) return; + if (!mu.summaryValue(hitval_etaLayer4Hits, xAOD::MuonSummaryType::etaLayer4Hits)) return; + + if (!mu.summaryValue(hitval_numberOfBLayerHits, xAOD::SummaryType::numberOfInnermostPixelLayerHits)) return; + if (!mu.summaryValue(hitval_numberOfPixelHits, xAOD::SummaryType::numberOfPixelHits)) return; + if (!mu.summaryValue(hitval_numberOfSCTHits, xAOD::SummaryType::numberOfSCTHits)) return; + if (!mu.summaryValue(hitval_numberOfTRTHits, xAOD::SummaryType::numberOfTRTHits)) return; + + m_eff_nPrec -> Fill(mu.eta(), mu.phi(), hitval_numberOfPrecisionLayers); + m_eff_nPhi -> Fill(mu.eta(), mu.phi(), hitval_numberOfPhiLayers); + m_eff_nTrigEta -> Fill(mu.eta(), mu.phi(), hitval_numberOfTriggerEtaLayers); + + m_avg_hits_precision_inner -> Fill(mu.eta(), mu.phi(), hitval_innerSmallHits + hitval_innerLargeHits); + m_avg_hits_precision_middle -> Fill(mu.eta(), mu.phi(), hitval_middleSmallHits + hitval_middleLargeHits); + m_avg_hits_precision_outer -> Fill(mu.eta(), mu.phi(), hitval_outerSmallHits + hitval_outerLargeHits); + m_avg_hits_precision_extended -> Fill(mu.eta(), mu.phi(), hitval_extendedSmallHits + hitval_extendedLargeHits); + + m_avg_hits_trigger_layer1 -> Fill(mu.eta(), mu.phi(), hitval_etaLayer1Hits); + m_avg_hits_trigger_layer2 -> Fill(mu.eta(), mu.phi(), hitval_etaLayer2Hits); + m_avg_hits_trigger_layer3 -> Fill(mu.eta(), mu.phi(), hitval_etaLayer3Hits); + m_avg_hits_trigger_layer4 -> Fill(mu.eta(), mu.phi(), hitval_etaLayer4Hits); + + m_avg_hits_ibl -> Fill(mu.eta(), mu.phi(), hitval_numberOfBLayerHits); + m_avg_hits_pix -> Fill(mu.eta(), mu.phi(), hitval_numberOfPixelHits); + m_avg_hits_sct -> Fill(mu.eta(), mu.phi(), hitval_numberOfSCTHits); + m_avg_hits_trt -> Fill(mu.eta(), mu.phi(), hitval_numberOfTRTHits); + + if (primaryTrk && inDetTrk && msExtrapTrk) { + qoverp_diff = fabs(inDetTrk->qOverP() - msExtrapTrk->qOverP()); + qoverp_sigma = sqrt(inDetTrk->definingParametersCovMatrix()(4,4) + msExtrapTrk->definingParametersCovMatrix()(4,4)); + qoverp_signif = (qoverp_sigma > 0) ? (qoverp_diff / qoverp_sigma) : -999; + ddpt_idme = (primaryTrk->pt() > 0) ? fabs(inDetTrk->pt() - msExtrapTrk->pt()) / primaryTrk->pt() : -999; + + m_avg_ddpt_idme -> Fill(mu.eta(), mu.phi(), ddpt_idme); + m_avg_dptsignif -> Fill(mu.eta(), mu.phi(), qoverp_signif); + } + +} diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonSegmentPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonSegmentPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..da495e1c3cdb9fbd780346b427e254c59e44ca7e --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonSegmentPlots.cxx @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoMuonSegmentPlots.h" + +RecoMuonSegmentPlots::RecoMuonSegmentPlots(PlotBase* pParent, std::string sDir, bool detail):PlotBase(pParent, sDir) + , m_oMuonSegmentPlots(nullptr) + , m_oMuonSegmentSlimPlots(nullptr) + //declare the histograms +{ + Detail = detail; + if(Detail) m_oMuonSegmentPlots = new Muon::MuonSegmentPlots(this,"/"); + else m_oMuonSegmentSlimPlots = new Muon::MuonSegmentSlimPlots(this,"/"); +} + +//when the plot function called with a Muon Container +//loop through each muon, get the corresponding link and fill it +void RecoMuonSegmentPlots::fill(const xAOD::MuonContainer& muContainer){ + for (const auto mu : muContainer) { + fill(*mu); + } +} + +//when the plot function called with a Muon +//get's the corresponding link and fill it +//Tony 2015.9.21: fix to go around the segment link problem for now +void RecoMuonSegmentPlots::fill(const xAOD::Muon& mu){ + const std::vector<ElementLink<DataVector<xAOD::MuonSegment_v1>>> Mu_Segments = mu.muonSegmentLinks(); + fill(Mu_Segments); +} + +//use the link to fill +void RecoMuonSegmentPlots::fill(const std::vector<ElementLink<DataVector<xAOD::MuonSegment_v1>>> Mu_Segments){ + + for(const auto Mu_Segment : Mu_Segments){ + const ElementLink<DataVector<xAOD::MuonSegment_v1>> Mu_seg = Mu_Segment; + if(Mu_seg.isValid()){ + const xAOD::MuonSegment* seg = *Mu_seg; + fill(*seg); + } + } +} + + +void RecoMuonSegmentPlots::fill(const xAOD::MuonSegment& muonSeg) { + //General Plots + if (Detail) m_oMuonSegmentPlots->fill(muonSeg); + else m_oMuonSegmentSlimPlots->fill(muonSeg); +} + +void RecoMuonSegmentPlots::initializePlots() +{ + //initialize temp plots +} + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonTrackPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonTrackPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9b7b4b5991f5a106e273c1f2494e4c01202e404b --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoMuonTrackPlots.cxx @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoMuonTrackPlots.h" + +RecoMuonTrackPlots::RecoMuonTrackPlots(PlotBase* pParent, std::string sDir):PlotBase(pParent, sDir), +m_oAllPlots(this, "/", "Reco Muon"), +m_oImpactPlots(this, "/"), +m_oTrkRecoInfoPlots(this, "/"), +m_pt_broad(nullptr), +m_eta_phi_broad(nullptr) +{} + +void RecoMuonTrackPlots::initializePlots(){ + //booking histograms + m_pt_broad = Book1D("_pt_broad", "High p_{T} Distribution", 70, 100, 1500); + m_eta_phi_broad = Book2D("_eta_phi_broad", "High p_{T} Muon #eta #phi Distribution;#eta;#phi", 52, -2.6, 2.6, 64, -3.2, 3.2); +} + +//when the plot function called with a Muon Container +//loop through each muon, get the corresponding link and fill it + +//when the plot function called with a Muon +//get's the corresponding link and fill it +void RecoMuonTrackPlots::fill(const xAOD::Muon& mu, int component){ + + if (component == 0 ) { + ElementLink<xAOD::TrackParticleContainer> Mu_MStrack = mu.muonSpectrometerTrackParticleLink(); + if(Mu_MStrack.isValid()){ + const xAOD::TrackParticle* trk = *Mu_MStrack; + fill(*trk); + } + } + + if (component == 1 ){ + + ElementLink<xAOD::TrackParticleContainer> Mu_metrack = mu.trackParticleLink(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle); + if(Mu_metrack.isValid()){ + const xAOD::TrackParticle* trk = *Mu_metrack; + fill(*trk); + } + } +} + + +void RecoMuonTrackPlots::fill(const xAOD::TrackParticle& muTP){ + m_oAllPlots.fill(muTP); + m_oImpactPlots.fill(muTP); + m_oTrkRecoInfoPlots.fill(muTP); + + if (muTP.pt()/1000.0 > 100) {//ony for high pt muons + m_pt_broad->Fill(muTP.pt()/1000.0); + m_eta_phi_broad->Fill(muTP.eta(), muTP.phi()); + } + +} + + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoPhysPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoPhysPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9601fcf74ca7801017bb0ef1a70b9884816f64b8 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoPhysPlots.cxx @@ -0,0 +1,257 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoPhysPlots.h" + + +RecoPhysPlots::RecoPhysPlots(PlotBase *pParent, std::string sDir, std::string recObj):PlotBase(pParent, sDir), + m_Mass(0), + m_occupancy(0), + m_2occupancy(0), + m_M_Mean(0), + m_M_Sigma(0), + m_M_EA_EA(0), + m_M_EA_BA(0), + m_M_EA_BC(0), + m_M_EA_EC(0), + m_M_BA_EA(0), + m_M_BA_BA(0), + m_M_BA_BC(0), + m_M_BA_EC(0), + m_M_BC_EA(0), + m_M_BC_BA(0), + m_M_BC_BC(0), + m_M_BC_EC(0), + m_M_EC_EA(0), + m_M_EC_BA(0), + m_M_EC_BC(0), + m_M_EC_EC(0), + type(recObj) +{} + +void RecoPhysPlots::initializePlots(){ + + std::string Zsig("Z"); + std::string Jsig("Jpsi"); + std::string name; + bool doZ = false; bool doJ = false; + + if (!type.compare(Zsig)) { name="Z"; doZ = true; } + else if (!type.compare(Jsig)) { name="J/#psi"; doJ = true; } + else { name="other"; } + + int nBins = 100; + double minBin = 0.0; + double maxBin = 1000.0; + + /// Error check for doZ and doJ both true here; + + if (doZ) { + nBins = 100; + minBin = 60.0; + maxBin = 120.0; + } + else if (doJ) { + nBins = 30; + minBin = 2.5; + maxBin = 3.5; + } + //resonance mass distributuioin + m_Mass = Book1D("m_"+type+"_Mass", "m_Mass: M_{"+name+"} Mass;Mass [GeV];", nBins, minBin, maxBin); + //resonance two muon distribution + m_occupancy = Book1D("m_"+type+"_occupancy", "m_occupancy: M_{"+name+"} Track Occupancy;;N_{#mu}", 8, 0.0, 8.0); + m_2occupancy = Book1D("m_"+type+"_2occupancy", "m_2occupancy: M_{"+name+"} Two Track Occupancy;;N_{#mu}", 16, 0.5, 16.5); + + //resonance mass distribution in each mass range + m_M_EA_EA = Book1D("m_"+type+"_M_EA_EA", "m_M_EA_EAM_{"+name+"} EA_{+} - EA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EA_BA = Book1D("m_"+type+"_M_EA_BA", "m_M_EA_BAM_{"+name+"} EA_{+} - BA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EA_BC = Book1D("m_"+type+"_M_EA_BC", "m_M_EA_BCM_{"+name+"} EA_{+} - BC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EA_EC = Book1D("m_"+type+"_M_EA_EC", "m_M_EA_ECM_{"+name+"} EA_{+} - EC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BA_EA = Book1D("m_"+type+"_M_BA_EA", "m_M_BA_EAM_{"+name+"} BA_{+} - EA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BA_BA = Book1D("m_"+type+"_M_BA_BA", "m_M_BA_BAM_{"+name+"} BA_{+} - BA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BA_BC = Book1D("m_"+type+"_M_BA_BC", "m_M_BA_BCM_{"+name+"} BA_{+} - BC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BA_EC = Book1D("m_"+type+"_M_BA_EC", "m_M_BA_ECM_{"+name+"} BA_{+} - EC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BC_EA = Book1D("m_"+type+"_M_BC_EA", "m_M_BC_EAM_{"+name+"} BC_{+} - EA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BC_BA = Book1D("m_"+type+"_M_BC_BA", "m_M_BC_BAM_{"+name+"} BC_{+} - BA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BC_BC = Book1D("m_"+type+"_M_BC_BC", "m_M_BC_BCM_{"+name+"} BC_{+} - BC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_BC_EC = Book1D("m_"+type+"_M_BC_EC", "m_M_BC_ECM_{"+name+"} BC_{+} - EC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EC_EA = Book1D("m_"+type+"_M_EC_EA", "m_M_EC_EAM_{"+name+"} EC_{+} - EA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EC_BA = Book1D("m_"+type+"_M_EC_BA", "m_M_EC_BAM_{"+name+"} EC_{+} - BA_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EC_BC = Book1D("m_"+type+"_M_EC_BC", "m_M_EC_BCM_{"+name+"} EC_{+} - BC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + m_M_EC_EC = Book1D("m_"+type+"_M_EC_EC", "m_M_EC_ECM_{"+name+"} EC_{+} - EC_{-}; M_{"+name+"}[GeV];", nBins, minBin, maxBin); + //for compare mass mean and sigma, done in post processing + m_M_Mean = Book1D("m_"+type+"_M_Mean", "m_M_Mean: M_{"+name+"} Mean;;M_{"+name+"}[GeV]", 16, 1.0, 17.0); + m_M_Sigma = Book1D("m_"+type+"_M_Sigma", "m_M_Sigma: #sigma(M_{"+name+"});;#sigma(M_{"+name+"})[GeV]", 16, 1.0, 17.0); + + //label the plots + LabelCombinedEtaRegions(m_M_Mean->GetXaxis()); + LabelCombinedEtaRegions(m_M_Sigma->GetXaxis()); + LabelCombinedEtaRegions(m_2occupancy->GetXaxis()); + LabelLargeEtaRegions(m_occupancy->GetXaxis()); +} + +void RecoPhysPlots::fill(std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > mumucandidates){ + for (auto mumu: mumucandidates){ + const float invariant_mass = (mumu.first->p4() + mumu.second->p4()).M(); + fill(mumu.first->eta(), mumu.second->eta(), invariant_mass); + } +} + +void RecoPhysPlots::fill(const float eta_mu_plus, const float eta_mu_minus, const float invariant_mass){ + + float etaRegionCoarsePlus = EtaRegionCoarse(eta_mu_plus); + float etaRegionCoarseMinus = EtaRegionCoarse(eta_mu_minus); + float etaRegionFinePlus = EtaRegionFine(eta_mu_plus); + float etaRegionFineMinus = EtaRegionFine(eta_mu_minus); + + if((etaRegionCoarsePlus == 3.5 && etaRegionCoarseMinus == 3.5)) {m_M_EA_EA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(16);} + if((etaRegionCoarsePlus == 3.5 && etaRegionCoarseMinus == 2.5)) {m_M_EA_BA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(15);} + if((etaRegionCoarsePlus == 3.5 && etaRegionCoarseMinus == 1.5)) {m_M_EA_BC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(14);} + if((etaRegionCoarsePlus == 3.5 && etaRegionCoarseMinus == 0.5)) {m_M_EA_EC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(13);} + + if((etaRegionCoarsePlus == 2.5 && etaRegionCoarseMinus == 3.5)) {m_M_BA_EA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(12);} + if((etaRegionCoarsePlus == 2.5 && etaRegionCoarseMinus == 2.5)) {m_M_BA_BA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(11);} + if((etaRegionCoarsePlus == 2.5 && etaRegionCoarseMinus == 1.5)) {m_M_BA_BC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(10);} + if((etaRegionCoarsePlus == 2.5 && etaRegionCoarseMinus == 0.5)) {m_M_BA_EC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(9);} + + if((etaRegionCoarsePlus == 1.5 && etaRegionCoarseMinus == 3.5)) {m_M_BC_EA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(8);} + if((etaRegionCoarsePlus == 1.5 && etaRegionCoarseMinus == 2.5)) {m_M_BC_BA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(7);} + if((etaRegionCoarsePlus == 1.5 && etaRegionCoarseMinus == 1.5)) {m_M_BC_BC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(6);} + if((etaRegionCoarsePlus == 1.5 && etaRegionCoarseMinus == 0.5)) {m_M_BC_EC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(5);} + + if((etaRegionCoarsePlus == 0.5 && etaRegionCoarseMinus == 3.5)) {m_M_EC_EA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(4);} + if((etaRegionCoarsePlus == 0.5 && etaRegionCoarseMinus == 2.5)) {m_M_EC_BA->Fill(invariant_mass/1000.0); m_2occupancy->Fill(3);} + if((etaRegionCoarsePlus == 0.5 && etaRegionCoarseMinus == 1.5)) {m_M_EC_BC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(2);} + if((etaRegionCoarsePlus == 0.5 && etaRegionCoarseMinus == 0.5)) {m_M_EC_EC->Fill(invariant_mass/1000.0); m_2occupancy->Fill(1);} + + m_Mass->Fill(invariant_mass/1000.0); + m_occupancy->Fill(etaRegionFinePlus); + m_occupancy->Fill(etaRegionFineMinus); + +} + +void RecoPhysPlots::finalizeRecoPlots(){ + SetResultsBin( 1, m_M_EC_EC); + SetResultsBin( 2, m_M_EC_BC); + SetResultsBin( 3, m_M_EC_BA); + SetResultsBin( 4, m_M_EC_EA); + SetResultsBin( 5, m_M_BC_EC); + SetResultsBin( 6, m_M_BC_BC); + SetResultsBin( 7, m_M_BC_BA); + SetResultsBin( 8, m_M_BC_EA); + SetResultsBin( 9, m_M_BA_EC); + SetResultsBin(10, m_M_BA_BC); + SetResultsBin(11, m_M_BA_BA); + SetResultsBin(12, m_M_BA_EA); + SetResultsBin(13, m_M_EA_EC); + SetResultsBin(14, m_M_EA_BC); + SetResultsBin(15, m_M_EA_BA); + SetResultsBin(16, m_M_EA_EA); +} + +float RecoPhysPlots::EtaRegionFine(double eta) +{ + if (eta < -2.50) {return -1.;} // underflow + if (eta < -2.00) {return 0.5;} // CSC C + if (eta < -1.70) {return 1.5;} // ENDCAP C + if (eta < -1.05) {return 2.5;} // Trans C + if (eta < 0.00) {return 3.5;} // Barrel C + if (eta > 2.50) {return 8.5;} // OverFlow + if (eta > 2.00) {return 7.5;} // CSC A + if (eta > 1.70) {return 6.5;} // ENDCAP A + if (eta > 1.05) {return 5.5;} // Trans A + if (eta > 0.00) {return 4.5;} // Barrel A + return -1.; +} + +float RecoPhysPlots::EtaRegionCoarse(double eta) +{ + + if(eta < -2.50) {return -1.;} // underflow + if(eta < -1.05) {return 0.5;} // EC + if(eta < 0.00) {return 1.5;} // BC + if(eta < 1.05) {return 2.5;} // BA + if(eta < 2.50) {return 3.5;} // BC + return 4.5; // Overflow + +} +bool RecoPhysPlots::LabelLargeEtaRegions(TAxis * axis) +{ + axis->SetBinLabel(1, "CSC C"); + axis->SetBinLabel(2, "EC C"); + axis->SetBinLabel(3, "TRANS C"); + axis->SetBinLabel(4, "BARR C"); + axis->SetBinLabel(5, "BARR A"); + axis->SetBinLabel(6, "TRANS A"); + axis->SetBinLabel(7, "EC A"); + axis->SetBinLabel(8," CSC A"); + axis->SetTitle("Detector #eta Regions"); + + return true; +} + +bool RecoPhysPlots::LabelCombinedEtaRegions(TAxis * axis) +{ + axis->SetBinLabel( 1, "EC-EC"); + axis->SetBinLabel( 2, "EC-BC"); + axis->SetBinLabel( 3, "EC-BA"); + axis->SetBinLabel( 4, "EC-EA"); + axis->SetBinLabel( 5, "BC-EC"); + axis->SetBinLabel( 6, "BC-BC"); + axis->SetBinLabel( 7, "BC-BA"); + axis->SetBinLabel( 8, "BC-EA"); + axis->SetBinLabel( 9, "BA-EC"); + axis->SetBinLabel(10, "BA-BC"); + axis->SetBinLabel(11, "BA-BA"); + axis->SetBinLabel(12, "BA-EA"); + axis->SetBinLabel(13, "EA-EC"); + axis->SetBinLabel(14, "EA-BC"); + axis->SetBinLabel(15, "EA-BA"); + axis->SetBinLabel(16, "EA-EA"); + + axis->SetTitle("#eta Region Permutations [+#mu, -#mu]"); + + return true; +} + +bool RecoPhysPlots::LabelSectorAxis(TAxis * axis){ + + axis->SetTitle("#phi Sectors 1-16"); + if(axis->GetNbins() == 16) axis->CenterLabels(kTRUE); + + // Sector Axis Label Error, not a multiple of 16 bins + if(axis->GetNbins()%16){ + return false; + } + + int nSectorDevisions = axis->GetNbins()/16; + int skip_counter = 1; + + axis->SetNdivisions(16,nSectorDevisions,0,kFALSE); + + + for (int i = 1; i <= axis->GetNbins(); i++) { + + if (skip_counter == nSectorDevisions) { + axis->SetBinLabel(i,Form("%d",i/nSectorDevisions)); + skip_counter = 1; + }else { + axis->SetBinLabel(i," "); + skip_counter++; + } + + } + + return true; +} + +void RecoPhysPlots::SetResultsBin(int iBin, TH1* pInputHist){ + + m_M_Mean-> SetBinContent(iBin, pInputHist->GetMean(1)); + m_M_Mean-> SetBinError( iBin, pInputHist->GetMeanError(1)); + m_M_Sigma->SetBinContent(iBin, pInputHist->GetRMS(1)); + +} + + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoVertexPlots.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoVertexPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..046299c950cc497a7f575da81425f35a81f4975e --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/RecoVertexPlots.cxx @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonTrackMonitoring/RecoVertexPlots.h" + + +RecoVertexPlots::RecoVertexPlots(PlotBase *pParent, std::string sDir):PlotBase(pParent, sDir), + m_nMDT(nullptr), + m_nRPC(nullptr), + m_nTGC(nullptr), + m_nTracklets(nullptr), + m_VertexEtaPhi(nullptr) +{} + +void RecoVertexPlots::initializePlots(){ + + m_nMDT = Book1D("m_MSVx_nMDT", "m MSVx nMDT: M MSVx MDT Hits;;N_{MDT}", 100, 0.0, 3000.); + m_nRPC = Book1D("m_MSVx_nRPC", "m MSVx nRPC: M MSVx RPC Hits;;N_{RPC}", 100, 0.0, 1000.); + m_nTGC = Book1D("m_MSVx_nTGC", "m MSVx nTGC: M MSVx TGC Hits;;N_{TGC}", 100, 0.0, 1000.); + + m_nTracklets = Book1D("m_MSVx_nTracklets", "MSVx nTracklets: M MSVx Number of Tracklets; N_{trackletS}", 20, 0.0, 20.); + m_VertexEtaPhi = Book2D("m_VertexEtaPhi", "Vertex Eta Phi: M MSVx #eta vs. #phi; #eta; #phi", 25, -2.5, 25, 32, -3.2, 3.2); + +} + +void RecoVertexPlots::fill(const xAOD::Vertex& msVx){ + TVector3 tmp_vx; tmp_vx.SetXYZ(msVx.x(),msVx.y(),msVx.z()); + m_nMDT->Fill(msVx.auxdata< int >( "nMDT" )); + m_nRPC->Fill(msVx.auxdata< int >( "nRPC" )); + m_nTGC->Fill(msVx.auxdata< int >( "nTGC" )); + m_nTracklets->Fill(msVx.numberDoF()+1.); + m_VertexEtaPhi->Fill(tmp_vx.Eta(),tmp_vx.Phi()); +} diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/components/MuonTrackMonitoring_entries.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/components/MuonTrackMonitoring_entries.cxx index 0d32f41b0e62f165d58d649f40d45f3989e57538..f6db046970432c6c5a7028f52743abc0344be152 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/components/MuonTrackMonitoring_entries.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonTrackMonitoring/src/components/MuonTrackMonitoring_entries.cxx @@ -3,6 +3,9 @@ 2020 Matthias Schott - Uni Mainz */ -#include "../MuonTrackMonitorAlgorithm.h" +#include "MuonTrackMonitoring/MuonTrackMonitorAlgorithm.h" +#include "MuonTrackMonitoring/MuonGenericTracksMon.h" + +DECLARE_COMPONENT( MuonGenericTracksMon ) DECLARE_COMPONENT( MuonTrackMonitorAlgorithm )