From a6247f951a4f9a00627c4bc8e6134278c11d9d6f Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Mon, 16 Mar 2020 15:23:56 +0100 Subject: [PATCH 1/6] add more monitoring --- .../TgcRawDataMonitoring/CMakeLists.txt | 7 +- .../python/TgcRawDataMonitorAlgorithm.py | 268 +++++-- .../src/TgcRawDataMonitorAlgorithm.cxx | 730 ++++++++++++------ .../src/TgcRawDataMonitorAlgorithm.h | 188 ++++- 4 files changed, 830 insertions(+), 363 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/CMakeLists.txt b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/CMakeLists.txt index b23eafc60cbf..8df4bfc0bf99 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/CMakeLists.txt +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/CMakeLists.txt @@ -24,7 +24,8 @@ atlas_depends_on_subdirs( PUBLIC PhysicsAnalysis/AnalysisTrigger/AnalysisTriggerEvent Reconstruction/MuonIdentification/muonEvent Trigger/TrigEvent/TrigSteeringEvent - Trigger/TrigAnalysis/TrigDecisionTool ) + Trigger/TrigAnalysis/TrigDecisionTool + Tracking/TrkExtrapolation/TrkExInterfaces) # External dependencies: @@ -33,8 +34,8 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread MathMore Minui atlas_add_component( TgcRawDataMonitoring src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel AthenaMonitoringLib - StoreGateLib SGtests MuonReadoutGeometry MuonIdHelpersLib MuonPrepRawData MuonTrigCoinData MuonDQAUtilsLib Identifier xAODEventInfo xAODMuon xAODTrigger MuonRDO AnalysisTriggerEvent muonEvent TrigSteeringEvent TrigDecisionToolLib ) + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel AthenaMonitoringLib AthenaMonitoringKernelLib + StoreGateLib SGtests MuonReadoutGeometry MuonIdHelpersLib MuonPrepRawData MuonTrigCoinData MuonDQAUtilsLib Identifier xAODEventInfo xAODMuon xAODTrigger MuonRDO AnalysisTriggerEvent muonEvent TrigSteeringEvent TrigDecisionToolLib TrkExInterfaces ) # Install files from the package: diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py index 54248b4a46e0..9d11f1326e70 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py @@ -10,6 +10,67 @@ ''' def TgcRawDataMonitoringConfig(inputFlags): + from AthenaConfiguration.ComponentFactory import CompFactory + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + result = ComponentAccumulator() + # from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg + # result.merge(MuonGeoModelCfg(inputFlags)) + # result.addPublicTool( CompFactory.Muon__MuonIdHelperTool() ) + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + result.merge(MagneticFieldSvcCfg(inputFlags)) + + from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg + trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) + geom_svc = trackGeomCfg.getPrimary() + geom_svc.GeometryBuilder.Compactify = False ######## To avoid crash ######## + result.merge(trackGeomCfg) + + # from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + # result.merge(MagneticFieldSvcCfg(inputFlags)) + + # from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg + # result.merge( TrackCollectionReadCfg (inputFlags, 'CombinedInDetTracks') ) + + # from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg + # result.merge (TrackCollectionReadCfg (inputFlags, 'CombinedInDetTracks')) + # result.merge (TrackCollectionReadCfg (inputFlags, 'Tracks')) + # from PixelConditionsAlgorithms.PixelConditionsConfig import PixelConfigCondAlgCfg + # result.merge(PixelConfigCondAlgCfg(inputFlags, + # UseCalibConditions=True, + # UseDeadmapConditions=True, + # UseDCSStateConditions=False, + # UseDCSStatusConditions=False, + # UseDCSHVConditions=True, + # UseDCSTemperatureConditions=True, + # UseTDAQConditions=False)) + # from PixelConditionsTools.PixelConditionsSummaryConfig import PixelConditionsSummaryCfg + # InDetPixelConditionsSummaryTool = result.popToolsAndMerge(PixelConditionsSummaryCfg(inputFlags)) + + # from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg + # trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) + # geom_svc = trackGeomCfg.getPrimary() + # geom_svc.GeometryBuilder.Compactify = False ######## To avoid crash ######## + # result.merge(trackGeomCfg) + # from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + # result.merge(MagneticFieldSvcCfg(inputFlags)) + + # from TrkExTools.TrkExToolsConf import Trk__Navigator + # AtlasNavigator = Trk__Navigator(name = 'AtlasNavigator') + # AtlasNavigator.TrackingGeometrySvc = geom_svc + # result.addPublicTool(AtlasNavigator) + + + + # from TrkExTools.TrkExToolsConf import Trk__Navigator + # AtlasNavigator = Trk__Navigator(name = 'AtlasNavigator') + # AtlasNavigator.TrackingGeometrySvc = geom_svc + # result.addPublicTool(AtlasNavigator) + # from TrigInDetConfig.InDetConfig import TrigInDetCondConfig + # result.merge(TrigInDetCondConfig(inputFlags)) + + # from PixelConditionsAlgorithms.PixelConditionsConfig import PixelConfigCondAlgCfg,PixelDetectorElementCondAlgCfg + # result.merge( PixelConfigCondAlgCfg(inputFlags,name="PixelConfigCondAlg") ) + # result.merge( PixelDetectorElementCondAlgCfg(inputFlags,name="PixelDetectorElementCondAlg") ) from AthenaMonitoring import AthMonitorCfgHelper helper = AthMonitorCfgHelper(inputFlags,'TgcRawDataMonitorCfg') @@ -17,7 +78,7 @@ def TgcRawDataMonitoringConfig(inputFlags): from AthenaConfiguration.ComponentFactory import CompFactory tgcRawDataMonAlg = helper.addAlgorithm(CompFactory.TgcRawDataMonitorAlgorithm,'TgcRawDataMonAlg') - tgcRawDataMonAlg.TagAndProbe = False + tgcRawDataMonAlg.TagAndProbe = True tgcRawDataMonAlg.TagTrigList = 'HLT_mu26_ivarmedium' tgcRawDataMonAlg.TagTrigList += ',HLT_mu26_ivarmedium' @@ -37,73 +98,114 @@ def TgcRawDataMonitoringConfig(inputFlags): myGroup = helper.addGroup(tgcRawDataMonAlg,'TgcRawDataMonitor',mainDir) - myGroup.defineHistogram('thrNumber_barrel',title='thrNumber_barrel;thrNumber;Events', - path=trigPath,xbins=16,xmin=0.0,xmax=16.0) - myGroup.defineHistogram('thrNumber_endcap',title='thrNumber_endcap;thrNumber;Events', - path=trigPath,xbins=16,xmin=0.0,xmax=16.0) - myGroup.defineHistogram('thrNumber_forward',title='thrNumber_forward;thrNumber;Events', - path=trigPath,xbins=16,xmin=0.0,xmax=16.0) + myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_RPC',title='MuonRoI Thresholds RPC;MuonRoI Threshold number;Number of events', + cutmask='roi_rpc',path=trigPath,xbins=20,xmin=-0.5,xmax=19.5) + myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_TGC',title='MuonRoI Thresholds TGC;MuonRoI Threshold number;Number of events', + cutmask='roi_tgc',path=trigPath,xbins=20,xmin=-0.5,xmax=19.5) + + for n in range(16): + myGroup.defineHistogram('roi_eta;MuonRoI_Eta_Thr'+str(n),title='MuonRoI Eta Thr'+str(n)+';MuonRoI Eta;Number of events', + cutmask='thrmask'+str(n),path=trigPath,xbins=60,xmin=-3,xmax=3) + myGroup.defineHistogram('roi_phi_rpc;MuonRoI_Phi_RPC_Thr'+str(n),title='MuonRoI Phi RPC Thr'+str(n)+';MuonRoI Phi;Number of events', + cutmask='thrmask'+str(n),path=trigPath,xbins=32,xmin=-math.pi,xmax=math.pi) + myGroup.defineHistogram('roi_phi_tgc;MuonRoI_Phi_TGC_Thr'+str(n),title='MuonRoI Phi TGC Thr'+str(n)+';MuonRoI Phi;Number of events', + cutmask='thrmask'+str(n),path=trigPath,xbins=48,xmin=-math.pi,xmax=math.pi) + myGroup.defineHistogram('roi_eta,roi_phi;MuonRoI_EtaVsPhi_Thr'+str(n),type='TH2F', + title='MuonRoI Eta vs Phi Thr'+str(n)+';MuonRoI Eta;MuonRoI Phi',cutmask='thrmask'+str(n),path=trigPath, + xbins=100,xmin=-2.5,xmax=2.5,ybins=48,ymin=-math.pi,ymax=math.pi) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_pt_rpc;MuonRoI_Eff_Pt_RPC_Thr'+str(n),title='MuonRoI_Eff_Pt_RPC_Thr'+str(n)+';Offline muon pT [GeV];Efficiency', + type='TEfficiency',path=trigPath,xbins=100,xmin=0,xmax=50) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_pt_tgc;MuonRoI_Eff_Pt_TGC_Thr'+str(n),title='MuonRoI_Eff_Pt_TGC_Thr'+str(n)+';Offline muon pT [GeV];Efficiency', + type='TEfficiency',path=trigPath,xbins=100,xmin=0,xmax=50) + + # myGroup.defineHistogram('pT_passed,pT', type='TEfficiency', title='Test TEfficiency;x;Eff', + # path='AndInTheDarkness', xbins=100, xmin=0.0, xmax=50.0) + + # myGroup.defineHistogram('eta;Test1',title='Hoge1;hoge2;hoge3', + # path=trigPath,xbins=60,xmin=-3,xmax=3) + + # # myGroup.defineHistogram('eta,phi;Test2',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, + # # xbins=100,xmin=-2.5,xmax=2.5, + # # ybins=48,ymin=-math.pi,ymax=math.pi) + + # myGroup.defineHistogram('eta,pt;Test3',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, + # xbins=100,xmin=-2.5,xmax=2.5, + # ybins=10,ymin=0,ymax=100) + + # myGroup.defineHistogram('eta,phi;Test2',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, + # xbins=100,xmin=-2.5,xmax=2.5, + # ybins=10,ymin=0,ymax=100) - array = helper.addArray([16],tgcRawDataMonAlg,'TgcRawDataMonitor') - array.defineHistogram('roiEta2,roiPhi2',title='roiEta2Phi;roiEta;roiPhi',type='TH2F',path=mainDir+trigPath, - xbins=100,xmin=-2.5,xmax=2.5, - ybins=48,ymin=-math.pi,ymax=math.pi) + # myGroup.defineHistogram('thrNumber_barrel',title='thrNumber_barrel;thrNumber;Events', + # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) + # myGroup.defineHistogram('thrNumber_endcap',title='thrNumber_endcap;thrNumber;Events', + # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) + # myGroup.defineHistogram('thrNumber_forward',title='thrNumber_forward;thrNumber;Events', + # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) + + # array = helper.addArray([16],tgcRawDataMonAlg,'TgcRawDataMonitor') + # array.defineHistogram('roi_eta,roi_phi;MuonRoI_EtaVsPhi_Thr',title='MuonRoI_EtaVsPhi_Thr;roiEta;roiPhi',type='TH2F',path=mainDir+trigPath, + # xbins=100,xmin=-2.5,xmax=2.5, + # ybins=48,ymin=-math.pi,ymax=math.pi) - array.defineHistogram('roiEta',title='roiEta;roiEta;Events',type='TH1F',path=mainDir+trigPath, - xbins=100,xmin=-2.5,xmax=2.5) - - array.defineHistogram('roiPhi_barrel_A',title='roiPhi_barrel_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=16,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('roiPhi_endcap_A',title='roiPhi_endcap_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=48,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('roiPhi_forward_A',title='roiPhi_forward_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=24,xmin=-math.pi,xmax=math.pi) - - array.defineHistogram('roiPhi_barrel_C',title='roiPhi_barrel_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=16,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('roiPhi_endcap_C',title='roiPhi_endcap_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=48,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('roiPhi_forward_C',title='roiPhi_forward_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=24,xmin=-math.pi,xmax=math.pi) - - array.defineHistogram('bcID_barrel',title='trig2bcid_barrel;BCID;Events',type='TH1F',path=mainDir+trigPath, - xbins=4000,xmin=0,xmax=4000) - array.defineHistogram('bcID_endcap',title='trig2bcid_endcap;BCID;Events',type='TH1F',path=mainDir+trigPath, - xbins=4000,xmin=0,xmax=4000) - array.defineHistogram('bcID_forward',title='trig2bcid_forward;BCID;Events',type='TH1F',path=mainDir+trigPath, - xbins=4000,xmin=0,xmax=4000) + # array.defineHistogram('roiEta',title='roiEta;roiEta;Events',type='TH1F',path=mainDir+trigPath, + # xbins=100,xmin=-2.5,xmax=2.5) + + # array.defineHistogram('roiPhi_barrel_A',title='roiPhi_barrel_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=16,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('roiPhi_endcap_A',title='roiPhi_endcap_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=48,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('roiPhi_forward_A',title='roiPhi_forward_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=24,xmin=-math.pi,xmax=math.pi) + + # array.defineHistogram('roiPhi_barrel_C',title='roiPhi_barrel_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=16,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('roiPhi_endcap_C',title='roiPhi_endcap_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=48,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('roiPhi_forward_C',title='roiPhi_forward_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=24,xmin=-math.pi,xmax=math.pi) + + # array.defineHistogram('bcID_barrel',title='trig2bcid_barrel;BCID;Events',type='TH1F',path=mainDir+trigPath, + # xbins=4000,xmin=0,xmax=4000) + # array.defineHistogram('bcID_endcap',title='trig2bcid_endcap;BCID;Events',type='TH1F',path=mainDir+trigPath, + # xbins=4000,xmin=0,xmax=4000) + # array.defineHistogram('bcID_forward',title='trig2bcid_forward;BCID;Events',type='TH1F',path=mainDir+trigPath, + # xbins=4000,xmin=0,xmax=4000) - array.defineHistogram('muEta,muPhi',title='muEta2Phi;muEta;muPhi',type='TH2F',path=mainDir+trigPath, - xbins=100,xmin=-2.5,xmax=2.5, - ybins=48,ymin=-math.pi,ymax=math.pi) - - array.defineHistogram('muEta',title='muEta;muEta;Events',type='TH1F',path=mainDir+trigPath, - xbins=100,xmin=-2.5,xmax=2.5) - - array.defineHistogram('muPt_barrel',title='muPt_barrel;muPt;Events',type='TH1F',path=mainDir+trigPath, - xbins=40,xmin=0,xmax=40) - array.defineHistogram('muPt_endcap',title='muPt_endcap;muPt;Events',type='TH1F',path=mainDir+trigPath, - xbins=40,xmin=0,xmax=40) - array.defineHistogram('muPt_forward',title='muPt_forward;muPt;Events',type='TH1F',path=mainDir+trigPath, - xbins=40,xmin=0,xmax=40) - - array.defineHistogram('muPhi_barrel_A',title='muPhi_barrel_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=16,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('muPhi_endcap_A',title='muPhi_endcap_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=48,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('muPhi_forward_A',title='muPhi_forward_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=24,xmin=-math.pi,xmax=math.pi) - - array.defineHistogram('muPhi_barrel_C',title='muPhi_barrel_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=16,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('muPhi_endcap_C',title='muPhi_endcap_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=48,xmin=-math.pi,xmax=math.pi) - array.defineHistogram('muPhi_forward_C',title='muPhi_forward_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - xbins=24,xmin=-math.pi,xmax=math.pi) - - - return helper.result() + # array.defineHistogram('muEta,muPhi',title='muEta2Phi;muEta;muPhi',type='TH2F',path=mainDir+trigPath, + # xbins=100,xmin=-2.5,xmax=2.5, + # ybins=48,ymin=-math.pi,ymax=math.pi) + + # array.defineHistogram('muEta',title='muEta;muEta;Events',type='TH1F',path=mainDir+trigPath, + # xbins=100,xmin=-2.5,xmax=2.5) + + # array.defineHistogram('muPt_barrel',title='muPt_barrel;muPt;Events',type='TH1F',path=mainDir+trigPath, + # xbins=40,xmin=0,xmax=40) + # array.defineHistogram('muPt_endcap',title='muPt_endcap;muPt;Events',type='TH1F',path=mainDir+trigPath, + # xbins=40,xmin=0,xmax=40) + # array.defineHistogram('muPt_forward',title='muPt_forward;muPt;Events',type='TH1F',path=mainDir+trigPath, + # xbins=40,xmin=0,xmax=40) + + # array.defineHistogram('muPhi_barrel_A',title='muPhi_barrel_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=16,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('muPhi_endcap_A',title='muPhi_endcap_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=48,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('muPhi_forward_A',title='muPhi_forward_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=24,xmin=-math.pi,xmax=math.pi) + + # array.defineHistogram('muPhi_barrel_C',title='muPhi_barrel_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=16,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('muPhi_endcap_C',title='muPhi_endcap_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=48,xmin=-math.pi,xmax=math.pi) + # array.defineHistogram('muPhi_forward_C',title='muPhi_forward_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, + # xbins=24,xmin=-math.pi,xmax=math.pi) + + #acc, seq = helper.result() + acc = helper.result() + result.merge(acc) + return result + # return helper.result() if __name__=='__main__': from AthenaCommon.Configurable import Configurable @@ -114,22 +216,50 @@ if __name__=='__main__': log.setLevel(INFO) from AthenaConfiguration.AllConfigFlags import ConfigFlags - nightly = '/afs/cern.ch/user/e/ebergeas/work/public/triggermonitoring/nigtly_2019-08-24T2130/' - file = 'AOD.pool.root' - ConfigFlags.Input.Files = [nightly+file] + # nightly = '/afs/cern.ch/user/e/ebergeas/work/public/triggermonitoring/nigtly_2019-08-24T2130/' + # file = 'AOD.pool.root' + # ConfigFlags.Input.Files = [nightly+file] + import glob + # inputs = glob.glob('/scratch/masato/L1MuonDevRun3/21.3-rerunLVL1/run_data_eb_nocos/*/AOD.pool.root') + # inputs = glob.glob('/data03/data/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.AOD.e4993_s3214_d1540_r11773_tid20245298_00//*') + # inputs = glob.glob('/data02/data/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.recon.AOD.e4993_s3214_d1546_r11767/AOD.20152803._000173.pool.root.1') + # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/tmp.ESD') + inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/AOD*') + # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/mc_scan_normal/*/tmp.ESD') + ConfigFlags.Input.Files = inputs ConfigFlags.Input.isMC = True ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput.root' - + # ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_e4993_s3214_d1540_r11773.root' + # ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_e4993_s3214_d1546_r11767.root' + + #ConfigFlags.IOVDb.GlobalTag = "'CONDBR2-BLKPA-2017-08" + ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" + + # from AthenaCommon.Include import Include, IncludeError, include + # include("RecExCommon/RecExCommon_topOptions.py") + + ConfigFlags.lock() + ConfigFlags.dump() + + from AthenaCommon.AppMgr import ServiceMgr + ServiceMgr.Dump = False from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg cfg = MainServicesSerialCfg() cfg.merge(PoolReadCfg(ConfigFlags)) + # Configuration of the ATLAS Geo Model + from AtlasGeoModel.AtlasGeoModelConfig import AtlasGeometryCfg + geoCfg = AtlasGeometryCfg(ConfigFlags) + cfg.merge(geoCfg) + tgcRawDataMonitorAcc = TgcRawDataMonitoringConfig(ConfigFlags) + tgcRawDataMonitorAcc.OutputLevel = DEBUG cfg.merge(tgcRawDataMonitorAcc) - cfg.printConfig(withDetails=False) + # cfg.printConfig(withDetails=False) + cfg.printConfig(withDetails=True, summariseProps = True) cfg.run() diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx index 6a176510de71..aa01ce56a690 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx @@ -4,23 +4,12 @@ #include "TgcRawDataMonitorAlgorithm.h" #include "TObjArray.h" +#include <memory> TgcRawDataMonitorAlgorithm::TgcRawDataMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) - : AthMonitorAlgorithm(name,pSvcLocator), - m_packageName("TgcRawDataMonitor"), - m_MuonContainerKey("Muons"), - m_MuonEFContainerKey("HLT_MuonsCB_RoI"), - m_MuonRoIContainerKey("LVL1MuonRoIs"), - m_trigTagList("HLT_mu26_ivarmedium_L1MU20"), - m_TagAndProbe(false) + : AthMonitorAlgorithm(name,pSvcLocator) { - declareProperty("PackageName",m_packageName); - declareProperty("MuonContainerName",m_MuonContainerKey); - declareProperty("MuonEFContainerName",m_MuonEFContainerKey); - declareProperty("MuonRoIContainerName",m_MuonRoIContainerKey); - declareProperty("TagTrigList",m_trigTagList); - declareProperty("TagAndProbe",m_TagAndProbe); } @@ -28,12 +17,30 @@ TgcRawDataMonitorAlgorithm::~TgcRawDataMonitorAlgorithm() {} StatusCode TgcRawDataMonitorAlgorithm::initialize() { - + + ATH_CHECK(m_MuonIdHelperTool.retrieve() ); + ATH_CHECK(m_extrapolator.retrieve()); + ATH_CHECK(m_MuonContainerKey.initialize()); ATH_CHECK(m_MuonEFContainerKey.initialize()); ATH_CHECK(m_MuonRoIContainerKey.initialize()); + ATH_CHECK(m_TgcPrepDataContainerKey.initialize()); + ATH_CHECK(m_TgcCoinDataContainerCurrBCKey.initialize()); + ATH_CHECK(m_TgcCoinDataContainerNextBCKey.initialize()); + ATH_CHECK(m_TgcCoinDataContainerPrevBCKey.initialize()); + + m_extZposition.push_back(m_M1_Z.value()); + m_extZposition.push_back(m_M2_Z.value()); + m_extZposition.push_back(m_M3_Z.value()); + m_extZposition.push_back(m_EI_Z.value()); + m_extZposition.push_back(m_FI_Z.value()); + m_extZposition.push_back(-m_M1_Z.value()); + m_extZposition.push_back(-m_M2_Z.value()); + m_extZposition.push_back(-m_M3_Z.value()); + m_extZposition.push_back(-m_EI_Z.value()); + m_extZposition.push_back(-m_FI_Z.value()); - TObjArray* tagList = TString(m_trigTagList).Tokenize(","); + TObjArray* tagList = TString(m_trigTagList.value()).Tokenize(","); std::set<TString> alllist; for(int i = 0 ; i < tagList->GetEntries(); i++){ TString tagTrig = tagList->At(i)->GetName(); @@ -43,288 +50,503 @@ StatusCode TgcRawDataMonitorAlgorithm::initialize() { if(arr->GetEntries()==0)continue; TagDef def; def.eventTrig = TString(arr->At(0)->GetName()); - TString matchTrig = def.eventTrig; - if(arr->GetEntries()==2)matchTrig = TString(arr->At(1)->GetName()); - def.isolated = matchTrig.Contains("ivarmedium"); - matchTrig.ReplaceAll("HLT_mu",""); - if(matchTrig.Contains("_")) matchTrig.Remove(matchTrig.Index("_"),matchTrig.Sizeof()); - def.threshold = matchTrig.Atof() * 1000.; + def.tagTrig = def.eventTrig; + if(arr->GetEntries()==2)def.tagTrig = TString(arr->At(1)->GetName()); m_trigTagDefs.push_back(def); } - m_Groups_trig2bcid = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiEta2Phi = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiEta = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_barrel_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_endcap_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_forward_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_barrel_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_endcap_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_roiPhi_forward_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muEta2Phi = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muEta = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_endcap_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_forward_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_barrel_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_endcap_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_forward_C = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPt_barrel = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPt_endcap = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPt_forward = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - m_Groups_muPhi_barrel_A = Monitored::buildToolMap<int>(m_tools,m_packageName,16); - + return AthMonitorAlgorithm::initialize(); } StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const { - bool ok = true; + auto bcid = GetEventInfo(ctx)->bcid(); + auto lumiPerBCID = lbAverageInteractionsPerCrossing(ctx); + auto lb = GetEventInfo(ctx)->lumiBlock(); + auto run = GetEventInfo(ctx)->runNumber(); + + /* raw LVL1MuonRoIs distributions */ SG::ReadHandle<xAOD::MuonRoIContainer> rois(m_MuonRoIContainerKey, ctx); if(!rois.isValid()){ ATH_MSG_ERROR("evtStore() does not contain muon RoI Collection with name "<< m_MuonRoIContainerKey); - ok = false; - } - if(!ok){ return StatusCode::FAILURE; } - - auto thrNumber_barrel = Monitored::Scalar<float>("thrNumber_barrel",0.0); - auto thrNumber_endcap = Monitored::Scalar<float>("thrNumber_endcap",0.0); - auto thrNumber_forward = Monitored::Scalar<float>("thrNumber_forward",0.0); - - auto roiEta = Monitored::Scalar<float>("roiEta",0.0); - auto roiEta2 = Monitored::Scalar<float>("roiEta2",0.0); - auto roiPhi2 = Monitored::Scalar<float>("roiPhi2",0.0); - auto roiPhi_barrel_A = Monitored::Scalar<float>("roiPhi_barrel_A",0.0); - auto roiPhi_endcap_A = Monitored::Scalar<float>("roiPhi_endcap_A",0.0); - auto roiPhi_forward_A = Monitored::Scalar<float>("roiPhi_forward_A",0.0); - auto roiPhi_barrel_C = Monitored::Scalar<float>("roiPhi_barrel_C",0.0); - auto roiPhi_endcap_C = Monitored::Scalar<float>("roiPhi_endcap_C",0.0); - auto roiPhi_forward_C = Monitored::Scalar<float>("roiPhi_forward_C",0.0); - - auto bcID_barrel = Monitored::Scalar<float>("bcID_barrel",0.0); - auto bcID_endcap = Monitored::Scalar<float>("bcID_endcap",0.0); - auto bcID_forward = Monitored::Scalar<float>("bcID_forward",0.0); - - auto bcid = GetEventInfo(ctx)->bcid(); - for(const auto& roi : *rois){ - roiEta = roi->eta(); - roiEta2 = roi->eta(); - roiPhi2 = roi->phi(); - fill(m_tools[m_Groups_roiEta2Phi[roi->getThrNumber()]],roiEta2,roiPhi2); - fill(m_tools[m_Groups_roiEta[roi->getThrNumber()]],roiEta); - - if(roi->getSource()==xAOD::MuonRoI::Barrel){ - thrNumber_barrel = roi->getThrNumber(); - fill(m_packageName,thrNumber_barrel); - bcID_barrel = bcid; - fill(m_tools[m_Groups_trig2bcid[roi->getThrNumber()]],bcID_barrel); - if(roi->getHemisphere()==xAOD::MuonRoI::Positive){ - roiPhi_barrel_A = roi->phi(); - fill(m_tools[m_Groups_roiPhi_barrel_A[roi->getThrNumber()]],roiPhi_barrel_A); - }else{ - roiPhi_barrel_C = roi->phi(); - fill(m_tools[m_Groups_roiPhi_barrel_C[roi->getThrNumber()]],roiPhi_barrel_C); - } - } - if(roi->getSource()==xAOD::MuonRoI::Endcap){ - thrNumber_endcap = roi->getThrNumber(); - fill(m_packageName,thrNumber_endcap); - bcID_endcap = bcid; - fill(m_tools[m_Groups_trig2bcid[roi->getThrNumber()]],bcID_endcap); - if(roi->getHemisphere()==xAOD::MuonRoI::Positive){ - roiPhi_endcap_A = roi->phi(); - fill(m_tools[m_Groups_roiPhi_endcap_A[roi->getThrNumber()]],roiPhi_endcap_A); - }else{ - roiPhi_endcap_C = roi->phi(); - fill(m_tools[m_Groups_roiPhi_endcap_C[roi->getThrNumber()]],roiPhi_endcap_C); - } - } - if(roi->getSource()==xAOD::MuonRoI::Forward){ - thrNumber_forward = roi->getThrNumber(); - fill(m_packageName,thrNumber_forward); - bcID_forward = bcid; - fill(m_tools[m_Groups_trig2bcid[roi->getThrNumber()]],bcID_forward); - if(roi->getHemisphere()==xAOD::MuonRoI::Positive){ - roiPhi_forward_A = roi->phi(); - fill(m_tools[m_Groups_roiPhi_forward_A[roi->getThrNumber()]],roiPhi_forward_A); - }else{ - roiPhi_forward_C = roi->phi(); - fill(m_tools[m_Groups_roiPhi_forward_C[roi->getThrNumber()]],roiPhi_forward_C); - } - } - } + std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables; + auto roi_eta = Monitored::Collection("roi_eta",*rois, []( const xAOD::MuonRoI* m ){return m->eta();}); variables.push_back( roi_eta ); + auto roi_phi = Monitored::Collection("roi_phi",*rois, []( const xAOD::MuonRoI* m ){return m->phi();}); variables.push_back( roi_phi ); + auto roi_phi_rpc = Monitored::Collection("roi_phi_rpc",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Barrel)?m->phi():-10;}); variables.push_back( roi_phi_rpc ); + auto roi_phi_tgc = Monitored::Collection("roi_phi_tgc",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()!=xAOD::MuonRoI::Barrel)?m->phi():-10;}); variables.push_back( roi_phi_tgc ); + auto roi_thr = Monitored::Collection("roi_thr",*rois, []( const xAOD::MuonRoI* m ){return m->getThrNumber();}); variables.push_back( roi_thr ); + auto roi_rpc = Monitored::Collection("roi_rpc",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()==xAOD::MuonRoI::Barrel;}); variables.push_back( roi_rpc ); + auto roi_tgc = Monitored::Collection("roi_tgc",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()!=xAOD::MuonRoI::Barrel;}); variables.push_back( roi_tgc ); + auto thrmask0 = Monitored::Collection("thrmask0",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==0;});variables.push_back(thrmask0); + auto thrmask1 = Monitored::Collection("thrmask1",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==1;});variables.push_back(thrmask1); + auto thrmask2 = Monitored::Collection("thrmask2",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==2;});variables.push_back(thrmask2); + auto thrmask3 = Monitored::Collection("thrmask3",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==3;});variables.push_back(thrmask3); + auto thrmask4 = Monitored::Collection("thrmask4",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==4;});variables.push_back(thrmask4); + auto thrmask5 = Monitored::Collection("thrmask5",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==5;});variables.push_back(thrmask5); + auto thrmask6 = Monitored::Collection("thrmask6",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==6;});variables.push_back(thrmask6); + auto thrmask7 = Monitored::Collection("thrmask7",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==7;});variables.push_back(thrmask7); + auto thrmask8 = Monitored::Collection("thrmask8",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==8;});variables.push_back(thrmask8); + auto thrmask9 = Monitored::Collection("thrmask9",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==9;});variables.push_back(thrmask9); + auto thrmask10 = Monitored::Collection("thrmask10",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==10;});variables.push_back(thrmask10); + auto thrmask11 = Monitored::Collection("thrmask11",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==11;});variables.push_back(thrmask11); + auto thrmask12 = Monitored::Collection("thrmask12",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==12;});variables.push_back(thrmask12); + auto thrmask13 = Monitored::Collection("thrmask13",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==13;});variables.push_back(thrmask13); + auto thrmask14 = Monitored::Collection("thrmask14",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==14;});variables.push_back(thrmask14); + auto thrmask15 = Monitored::Collection("thrmask15",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==15;});variables.push_back(thrmask15); + - if( !m_TagAndProbe ) return StatusCode::SUCCESS; - SG::ReadHandle<xAOD::MuonContainer> muons(m_MuonContainerKey, ctx); if(!muons.isValid()){ ATH_MSG_ERROR("evtStore() does not contain muon Collection with name "<< m_MuonContainerKey); - ok = false; - } - SG::ReadHandle<xAOD::MuonContainer> efmuons(m_MuonEFContainerKey, ctx); - if(!efmuons.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain muon Collection with name "<< m_MuonEFContainerKey); - ok = false; - } - if(!ok){ - return StatusCode::FAILURE; - } + return StatusCode::FAILURE; + } - std::vector<Muons> mymuons; + std::vector<MyMuon> mymuons; for(const auto& muon : *muons){ - if(muon->author()!=xAOD::Muon::MuidCo && muon->author()!=xAOD::Muon::STACO)continue; if(muon->muonType()!=xAOD::Muon::Combined)continue; + if(muon->author()!=xAOD::Muon::MuidCo && muon->author()!=xAOD::Muon::STACO)continue; if(muon->quality()!=xAOD::Muon::Tight && muon->quality()!=xAOD::Muon::Medium)continue; - Muons mymuon; + + MyMuon mymuon; + /* fill basic info */ mymuon.muon = muon; - mymuon.tagged = false; + mymuon.fourvec.SetPtEtaPhiM(muon->pt(),muon->eta(),muon->phi(),m_muonMass.value()); + /* fill tag of tag-and-probe info */ + mymuon.tagged = triggerMatching(muon,m_trigTagDefs)==StatusCode::SUCCESS ? true : false; + /* fill info of isolation among muons */ mymuon.isolated = true; - TVector3 muonvec; - muonvec.SetPtEtaPhi(muon->pt(),muon->eta(),muon->phi()); - for(auto tagdef : m_trigTagDefs){ - if(!m_trigDecTool->isPassed(tagdef.eventTrig.Data()))continue; - for(const auto& efmuon : *efmuons){ - if(efmuon->pt()<tagdef.threshold)continue; - if(tagdef.isolated){ - float ptcone30 = -1; - muon->isolation(ptcone30, xAOD::Iso::IsolationType::ptvarcone30); - float isolation = ptcone30 / muon->pt(); - if( isolation>0.07 )continue; - } - TVector3 efmuonvec; - efmuonvec.SetPtEtaPhi(efmuon->pt(),efmuon->eta(),efmuon->phi()); - if( efmuonvec.DeltaR(muonvec) < 0.05 ){ - mymuon.tagged = true; - break; - } - } - if(mymuon.tagged)break; - } for(const auto& muon2 : *muons){ if( muon == muon2 )continue; - TVector3 muonvec2; - muonvec2.SetPtEtaPhi(muon2->pt(),muon2->eta(),muon2->phi()); - float dr = muonvec2.DeltaR( muonvec ); - if( dr < 0.5 ){ - mymuon.isolated = false; - break; + TLorentzVector muonvec2; + muonvec2.SetPtEtaPhiM(muon2->pt(),muon2->eta(),muon2->phi(),m_muonMass.value()); + float dr = muonvec2.DeltaR( mymuon.fourvec ); + if( dr < m_isolationWindow.value() ){ + mymuon.isolated = false; + break; + } + } + /* fill extrapolation info (only to TGC) */ + extrapolate( muon, mymuon ); + /* L1Muon RoI matching */ + float max_dr = 999; + float pt = mymuon.muon->pt(); + if( pt/1000.>15.)max_dr = m_l1trigMatchWindow1.value(); + else if(pt/1000.>10.)max_dr = m_l1trigMatchWindow2.value() + m_l1trigMatchWindow3.value() * pt/1000.; + else max_dr = m_l1trigMatchWindow4.value() + m_l1trigMatchWindow5.value() * pt/1000.; + for(const auto& roi : *rois){ + TLorentzVector roivec; + roivec.SetPtEtaPhiM(1,roi->eta(),roi->phi(),1); + double dr = roivec.DeltaR( mymuon.fourvec ); + if( dr < max_dr ){ + mymuon.matchedL1ThrExclusive.insert( roi->getThrNumber() ); + } + } + for(int ithr = 0 ; ithr < 16 ; ithr++){ + bool pass = false; + for(const auto thr : mymuon.matchedL1ThrExclusive){ + if(thr >= ithr){ + pass = true; + break; + } } + if(pass) mymuon.matchedL1ThrInclusive.insert(ithr); } - mymuons.push_back(mymuon); + /* store MyMuon */ + mymuons.push_back( mymuon ); } - auto muEta = Monitored::Scalar<float>("muEta",0.0); - auto muEta2 = Monitored::Scalar<float>("muEta2",0.0); - auto muPhi2 = Monitored::Scalar<float>("muPhi2",0.0); - auto muPhi_barrel_A = Monitored::Scalar<float>("muPhi_barrel_A",0.0); - auto muPhi_endcap_A = Monitored::Scalar<float>("muPhi_endcap_A",0.0); - auto muPhi_forward_A = Monitored::Scalar<float>("muPhi_forward_A",0.0); - auto muPhi_barrel_C = Monitored::Scalar<float>("muPhi_barrel_C",0.0); - auto muPhi_endcap_C = Monitored::Scalar<float>("muPhi_endcap_C",0.0); - auto muPhi_forward_C = Monitored::Scalar<float>("muPhi_forward_C",0.0); - auto muPt_barrel = Monitored::Scalar<float>("muPt_barrel",0.0); - auto muPt_endcap = Monitored::Scalar<float>("muPt_endcap",0.0); - auto muPt_forward = Monitored::Scalar<float>("muPt_forward",0.0); - + /* fill probe of tag-and-probe info */ for(auto mymuon : mymuons){ - - bool canbeprobe = false; - for(auto mymuon2 : mymuons){ - if(mymuon.muon == mymuon2.muon)continue; - if(mymuon2.tagged){ - canbeprobe = true; - break; - } + mymuon.probeOK_any = false; + mymuon.probeOK_Z = false; + for(const auto mu2 : mymuons){ + if( mymuon.muon == mu2.muon )continue; + if( !mu2.tagged )continue; + mymuon.probeOK_any = true; + if( mymuon.muon->charge() == mu2.muon->charge() )continue; + double dimuon_mass = (mu2.fourvec + mymuon.fourvec).M(); + if( TMath::Abs( dimuon_mass - m_zMass.value()) > m_zMassWindow.value() )continue; + mymuon.probeOK_Z = true; + break; } - if(!canbeprobe)continue; - if(!mymuon.isolated)continue; - - // Added by M.Aoki (8/10/2019) - // pT-dependent matching window is introduced. - // This is an optimal selection for the matching - // between L1MU RoI and offline muons. - // Note: This will be re-visited once the muon - // track extrapolator is implemented, - // where no pT-dependent window is needed - float max_dr = 999; - float pt = mymuon.muon->pt(); - if( pt/1000.>15.)max_dr = 0.15; - else if(pt/1000.>10.)max_dr = 0.3 - 0.01 * pt/1000.; - else max_dr = 0.36 - 0.0016 * pt/1000.; + } - float muPt = mymuon.muon->pt()/1000.; - TVector3 muonvec; - muonvec.SetPtEtaPhi(mymuon.muon->pt(),mymuon.muon->eta(),mymuon.muon->phi()); + auto muon_eta = Monitored::Collection("muon_eta",mymuons,[](const MyMuon& m){return (m.muon->pt()/1000>30)?m.muon->eta():-10;});variables.push_back(muon_eta); + auto muon_phi_rpc = Monitored::Collection("muon_phi_rpc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())<1.05&&m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi_rpc); + auto muon_phi_tgc = Monitored::Collection("muon_phi_tgc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())>1.05&&TMath::Abs(m.muon->eta())<2.4&&m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi_tgc); + auto muon_pt_rpc = Monitored::Collection("muon_pt_rpc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())<1.05)?m.muon->pt()/1000:-10;});variables.push_back(muon_pt_rpc); + auto muon_pt_tgc = Monitored::Collection("muon_pt_tgc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())>1.05&&TMath::Abs(m.muon->eta())<2.4)?m.muon->pt()/1000:-10;});variables.push_back(muon_pt_tgc); - std::set<int> matchedThr; - for(const auto& roi : *rois){ - TVector3 roivec; - roivec.SetPtEtaPhi(1,roi->eta(),roi->phi()); - float dr = roivec.DeltaR( muonvec ); - if(dr < max_dr){ - matchedThr.insert( roi->getThrNumber() ); + auto muon_l1passThr1 = Monitored::Collection("muon_l1passThr1",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(1)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr1); + auto muon_l1passThr2 = Monitored::Collection("muon_l1passThr2",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(2)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr2); + auto muon_l1passThr3 = Monitored::Collection("muon_l1passThr3",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(3)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr3); + auto muon_l1passThr4 = Monitored::Collection("muon_l1passThr4",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(4)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr4); + auto muon_l1passThr5 = Monitored::Collection("muon_l1passThr5",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(5)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr5); + auto muon_l1passThr6 = Monitored::Collection("muon_l1passThr6",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(6)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr6); + auto muon_l1passThr7 = Monitored::Collection("muon_l1passThr7",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(7)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr7); + auto muon_l1passThr8 = Monitored::Collection("muon_l1passThr8",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(8)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr8); + auto muon_l1passThr9 = Monitored::Collection("muon_l1passThr9",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(9)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr9); + auto muon_l1passThr10 = Monitored::Collection("muon_l1passThr10",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(10)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr10); + auto muon_l1passThr11 = Monitored::Collection("muon_l1passThr11",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(11)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr11); + auto muon_l1passThr12 = Monitored::Collection("muon_l1passThr12",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(12)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr12); + auto muon_l1passThr13 = Monitored::Collection("muon_l1passThr13",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(13)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr13); + auto muon_l1passThr14 = Monitored::Collection("muon_l1passThr14",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(14)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr14); + auto muon_l1passThr15 = Monitored::Collection("muon_l1passThr15",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(15)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr15); + + + SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrd(m_TgcPrepDataContainerKey, ctx); + if(!tgcPrd.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcPrepDataContainer with name "<< m_TgcPrepDataContainerKey); + return StatusCode::FAILURE; + } + + const TgcIdHelper& tgcIdHelper = m_MuonIdHelperTool->tgcIdHelper(); + + std::vector<TgcHit> tgcHits; + for(auto tgccnt : *tgcPrd){ + for(auto data : *tgccnt){ + TgcHit tgcHit; + int bunch = -10; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) bunch = -1; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) bunch = 0; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) bunch = +1; + const MuonGM::TgcReadoutElement* element = data->detectorElement(); + const Identifier id = data->identify(); + const int gasGap = tgcIdHelper.gasGap(id); + const int channel = tgcIdHelper.channel(id); + const bool isStrip = tgcIdHelper.isStrip(id); + const Amg::Vector3D& pos = isStrip ? element->stripPos(gasGap, channel) : element->gangPos(gasGap, channel); + tgcHit.x = pos[0]; + tgcHit.y = pos[1]; + tgcHit.z = pos[2]; + if (isStrip) { + tgcHit.shortWidth = element->stripShortWidth(gasGap, channel); + tgcHit.longWidth = element->stripLongWidth(gasGap, channel); + tgcHit.length = element->stripLength(gasGap, channel); + } else { + tgcHit.shortWidth = element->gangShortWidth(gasGap, channel); + tgcHit.longWidth = element->gangLongWidth(gasGap, channel); + tgcHit.length = element->gangLength(gasGap, channel); } + tgcHit.isStrip = tgcIdHelper.isStrip(id); + tgcHit.gasGap = tgcIdHelper.gasGap(id); + tgcHit.channel = tgcIdHelper.channel(id); + tgcHit.eta = tgcIdHelper.stationEta(id); + tgcHit.phi = tgcIdHelper.stationPhi(id); + tgcHit.station = tgcIdHelper.stationName(id); + tgcHit.bunch = bunch; + tgcHits.push_back(tgcHit); } + } - for(int i = 0 ; i <= 15 ; i++){ - bool matched = false; - if(i==0){ - matched = true; - }else{ - for(int j = i ; j <= 15 ; j++){ - if( matchedThr.find(j)!=matchedThr.end() ){ - matched = true; - break; - } - } - } - if(!matched)continue; - if(muPt>25.){ - muEta = mymuon.muon->eta(); - muEta2 = mymuon.muon->eta(); - muPhi2 = mymuon.muon->phi(); - fill(m_tools[m_Groups_muEta2Phi[i]],muEta2,muPhi2); - fill(m_tools[m_Groups_muEta[i]],muEta); - } - if(TMath::Abs(mymuon.muon->eta())<1.05){ - muPt_barrel = muPt; - fill(m_tools[m_Groups_muPt_barrel[i]],muPt_barrel); - if(mymuon.muon->eta()>0){ - muPhi_barrel_A = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_barrel_A[i]],muPhi_barrel_A); - }else{ - muPhi_barrel_C = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_barrel_C[i]],muPhi_barrel_C); - } - }else if(TMath::Abs(mymuon.muon->eta())<2.0){ - muPt_endcap = muPt; - fill(m_tools[m_Groups_muPt_endcap[i]],muPt_endcap); - if(mymuon.muon->eta()>0){ - muPhi_endcap_A = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_endcap_A[i]],muPhi_endcap_A); - }else{ - muPhi_endcap_C = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_endcap_C[i]],muPhi_endcap_C); - } - }else if(TMath::Abs(mymuon.muon->eta())<2.4){ - muPt_forward = muPt; - fill(m_tools[m_Groups_muPt_forward[i]],muPt_forward); - if(mymuon.muon->eta()>0){ - muPhi_forward_A = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_forward_A[i]],muPhi_forward_A); - }else{ - muPhi_forward_C = mymuon.muon->phi(); - fill(m_tools[m_Groups_muPhi_forward_C[i]],muPhi_forward_C); - } + auto hit_n = Monitored::Scalar<int>("hit_n",tgcHits.size());variables.push_back(hit_n); + auto hit_bunch = Monitored::Collection("hit_bunch",tgcHits,[](const TgcHit& m){return m.bunch;});variables.push_back(hit_bunch); + auto hit_sideA = Monitored::Collection("hit_sideA",tgcHits,[](const TgcHit& m){return m.z>0;});variables.push_back(hit_sideA); + auto hit_sideC = Monitored::Collection("hit_sideC",tgcHits,[](const TgcHit& m){return m.z<0;});variables.push_back(hit_sideC); + + + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinCurr(m_TgcCoinDataContainerCurrBCKey, ctx); + if(!tgcCoinCurr.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerCurrBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinNext(m_TgcCoinDataContainerNextBCKey, ctx); + if(!tgcCoinNext.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerNextBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinPrev(m_TgcCoinDataContainerPrevBCKey, ctx); + if(!tgcCoinPrev.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerPrevBCKey); + return StatusCode::FAILURE; + } + + std::map<int, SG::ReadHandle<Muon::TgcCoinDataContainer> > tgcCoin; + tgcCoin[0] = tgcCoinCurr; + tgcCoin[+1] = tgcCoinNext; + tgcCoin[-1] = tgcCoinPrev; + + std::vector<TgcTrig> tgcTrigs; + for(auto thisCoin : tgcCoin){ + int bunch = thisCoin.first; + for(auto tgccnt : *(thisCoin.second)){ + for(auto data : *tgccnt){ + TgcTrig tgcTrig; + const int type = data->type(); + const Amg::Vector3D& posIn = data->globalposIn(); + tgcTrig.x_In = posIn[0]; + tgcTrig.y_In = posIn[1]; + tgcTrig.z_In = posIn[2]; + const Amg::Vector3D& posOut = data->globalposOut(); + tgcTrig.x_Out = posOut[0]; + tgcTrig.y_Out = posOut[1]; + tgcTrig.z_Out = posOut[2]; + tgcTrig.width_In = data->widthIn(); + tgcTrig.width_Out = data->widthOut(); + if (type == Muon::TgcCoinData::TYPE_SL) { + const Amg::MatrixX& matrix = data->errMat(); + tgcTrig.width_R = matrix(0,0); + tgcTrig.width_Phi = matrix(1,1); + } else { + tgcTrig.width_R = 0.; + tgcTrig.width_Phi = 0.; + } + tgcTrig.isAside = data->isAside(); + tgcTrig.isForward = data->isForward(); + tgcTrig.isStrip = data->isStrip(); + tgcTrig.isInner = data->isInner(); + tgcTrig.isPositiveDeltaR = data->isPositiveDeltaR(); + tgcTrig.type = type; + tgcTrig.trackletId = data->trackletId(); + tgcTrig.trackletIdStrip = data->trackletIdStrip(); + tgcTrig.phi = data->phi(); + tgcTrig.roi = data->roi(); + tgcTrig.pt = data->pt(); + tgcTrig.delta = data->delta(); + tgcTrig.sub = data->sub(); + tgcTrig.veto = data->veto(); + tgcTrig.bunch = bunch; + tgcTrig.inner = data->inner(); + tgcTrigs.push_back( tgcTrig ); } } - } + + + + fill(m_packageName,variables); + variables.clear(); + + // if( !m_TagAndProbe.value() ) return StatusCode::SUCCESS; + + + return StatusCode::SUCCESS; } + +/////////////////////////////////////////////////////////////// +StatusCode TgcRawDataMonitorAlgorithm::triggerMatching(const xAOD::Muon* offline_muon, const std::vector<TagDef>& list_of_triggers ) const +{ + TVector3 muonvec; muonvec.SetPtEtaPhi(offline_muon->pt(),offline_muon->eta(),offline_muon->phi()); + for(auto tagTrig : list_of_triggers ){ + if( !getTrigDecisionTool()->isPassed( tagTrig.eventTrig.Data() ) ) return StatusCode::FAILURE; + auto features = getTrigDecisionTool()->features<xAOD::MuonContainer>( tagTrig.tagTrig.Data() ,TrigDefs::Physics,"HLT_MuonsCB_RoI"); + for(auto aaa : features){ + ATH_CHECK( aaa.isValid() ); + auto trigmuon_link = aaa.link; + auto trigmuon = *trigmuon_link; + TVector3 trigvec; trigvec.SetPtEtaPhi(trigmuon->pt(),trigmuon->eta(),trigmuon->phi()); + if( trigvec.DeltaR( muonvec ) < 0.005 ) return StatusCode::SUCCESS; + } + } + return StatusCode::SUCCESS; +} +/////////////////////////////////////////////////////////////// +void TgcRawDataMonitorAlgorithm::extrapolate(const xAOD::Muon* muon, MyMuon& mymuon) const +{ + const ElementLink< xAOD::TrackParticleContainer >& el = muon->combinedTrackParticleLink(); + const xAOD::TrackParticle* track = *el; + for(const auto z : m_extZposition){ + Amg::Vector2D etaDeta(0,0); + Amg::Vector2D phiDphi(0,0); + Amg::Vector3D mom(0,0,0); + Amg::Vector3D extrapolateTo(0, 0, z); + if( extrapolate(track,extrapolateTo,TGC, etaDeta, phiDphi, mom) ){ + double pt = extrapolateTo.z() / TMath::SinH(etaDeta[0]); + TVector3 vec,pos; + pos.SetPtEtaPhi(pt,etaDeta[0],phiDphi[0]); + vec.SetXYZ(mom.x(),mom.y(),mom.z()); + mymuon.extPos.push_back(pos); + mymuon.extVec.push_back(vec); + } + } +} +/////////////////////////////////////////////////////////////// +/* track extrapolator tool */ +bool +TgcRawDataMonitorAlgorithm::extrapolate(const xAOD::TrackParticle* trackParticle, + const Amg::Vector3D& pos, + const int detector, + Amg::Vector2D& eta, + Amg::Vector2D& phi, + Amg::Vector3D& mom) const +{ + if (!trackParticle) { + return false; + } + const Trk::Track* track = trackParticle->track(); + if (!track) { + return false; + } + const DataVector<const Trk::TrackStateOnSurface>* trackOnSurf = track->trackStateOnSurfaces(); + if(!trackOnSurf){ + return false; + } + std::vector<double> vExtEta, vExtPhi, vExtPx, vExtPy, vExtPz, vExtDeltaEta, vExtDeltaPhi, vExtDistance; + int counter = 0; + for ( auto it : *trackOnSurf ) { + if ( ! it->type(Trk::TrackStateOnSurface::Measurement) ){ + continue; + } + const Trk::TrackParameters* point = NULL; + Amg::Vector2D distance(-1.e30, -1.e30); + if (detector == TgcRawDataMonitorAlgorithm::TGC) { + point = extrapolateToTGC(it, pos, distance); + } else if (detector == TgcRawDataMonitorAlgorithm::RPC) { + point = extrapolateToRPC(it, pos, distance); + } else { + continue; + } + if(!point){ + continue; + } + vExtEta.push_back(point->position().eta()); + vExtPhi.push_back(point->position().phi()); + vExtPx.push_back(point->momentum().x()); + vExtPy.push_back(point->momentum().y()); + vExtPz.push_back(point->momentum().z()); + vExtDistance.push_back(distance.y()); + counter++; + delete point; + } + if (counter==0){ + return false; + } + double minimum = 1.e30; + int number = -1; + for (int ii = 0; ii < counter; ii++) { + if (minimum>vExtDistance.at(ii)) { + minimum = vExtDistance.at(ii); + number = ii; + } + } + if (number==-1){ + return false; + } + eta[0] = vExtEta.at(number); + phi[0] = vExtPhi.at(number); + eta[1] = getError(vExtEta); + phi[1] = getError(vExtPhi); + mom[0] = vExtPx.at(number); + mom[1] = vExtPy.at(number); + mom[2] = vExtPz.at(number); + return true; +} +/////////////////////////////////////////////////////////////// +const Trk::TrackParameters* +TgcRawDataMonitorAlgorithm::extrapolateToTGC(const Trk::TrackStateOnSurface* tsos, + const Amg::Vector3D& pos, + Amg::Vector2D& distance) const +{ + const Trk::TrackParameters* track = tsos->trackParameters(); + if (!track || dynamic_cast<const Trk::AtaStraightLine*>(track) == 0) { + return 0; + } + double targetZ = pos.z(); + double trackZ = track->position().z(); + if (fabs(trackZ)<fabs(targetZ)-2000. || fabs(trackZ)>fabs(targetZ)+2000.){ + return 0; + } + Amg::Transform3D* matrix = new Amg::Transform3D; + matrix->setIdentity(); + matrix->translation().z() = targetZ; + Trk::DiscSurface* disc = new Trk::DiscSurface(matrix, + m_endcapPivotPlaneMinimumRadius.value(), + m_endcapPivotPlaneMaximumRadius.value()); + if(!disc){ + delete matrix; + matrix = 0; + return 0; + } + distance[0] = trackZ; + distance[1] = fabs(trackZ - targetZ); + const bool boundaryCheck = true; + const Trk::Surface* surface = disc; + const Trk::TrackParameters* param = m_extrapolator->extrapolate(*track, + *surface, + Trk::anyDirection, + boundaryCheck, + Trk::muon); + delete disc; + disc = 0; + surface = 0; + matrix = 0; + if (!param) { + return 0; + } + const Trk::AtaDisc* ataDisc = + dynamic_cast<const Trk::AtaDisc*>(param); + return ataDisc; +} +/////////////////////////////////////////////////////////////// +const Trk::TrackParameters* +TgcRawDataMonitorAlgorithm::extrapolateToRPC(const Trk::TrackStateOnSurface* tsos, + const Amg::Vector3D& pos, + Amg::Vector2D& distance) const +{ + const Trk::TrackParameters* track = tsos->trackParameters(); + if (!track || dynamic_cast<const Trk::AtaStraightLine*>(track) == 0) { + return 0; + } + double radius = pos.perp(); + double trackRadius = track->position().perp(); + if(trackRadius<radius-2000. || trackRadius>radius+2000.) return 0; + Amg::Transform3D* matrix = new Amg::Transform3D; + matrix->setIdentity(); + Trk::CylinderSurface* cylinder = + new Trk::CylinderSurface(matrix, + radius, + m_barrelPivotPlaneHalfLength.value()); + if (!cylinder) { + delete matrix; + matrix = 0; + return 0; + } + distance[0] = trackRadius; + distance[1] = trackRadius - radius; + const bool boundaryCheck = true; + const Trk::Surface* surface = cylinder; + const Trk::TrackParameters* param = m_extrapolator->extrapolate(*track, + *surface, + Trk::anyDirection, + boundaryCheck, + Trk::muon); + delete cylinder; + cylinder = 0; + surface = 0; + matrix = 0; + if (!param) { + return 0; + } + const Trk::AtaCylinder* ataCylinder = + dynamic_cast<const Trk::AtaCylinder*>(param); + return ataCylinder; +} +/////////////////////////////////////////////////////////////// +double +TgcRawDataMonitorAlgorithm::getError(const std::vector<double>& inputVec) const +{ + const int nSize = inputVec.size(); + double sum = 0; + double sum2 = 0; + for (int ii = 0; ii < nSize; ii++) { + sum = sum + inputVec.at(ii); + } + const double mean = sum/nSize; + for(int jj = 0; jj < nSize; jj++){ + sum2 = sum2 + pow((inputVec.at(jj)-mean),2); + } + const double stdDev = sqrt(sum2/nSize); + return stdDev; +} + + + diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h index 52b6b9e42239..7d78f0dc6cae 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h @@ -7,10 +7,34 @@ #include "AthenaMonitoring/AthMonitorAlgorithm.h" #include "AthenaMonitoringKernel/Monitored.h" - #include "StoreGate/ReadHandleKey.h" #include "xAODMuon/MuonContainer.h" #include "xAODTrigger/MuonRoIContainer.h" +#include "MuonPrepRawData/MuonPrepDataContainer.h" +#include "MuonTrigCoinData/TgcCoinDataContainer.h" +#include "MuonIdHelpers/MuonIdHelperTool.h" +/* #include "MuonReadoutGeometry/MuonDetectorManager.h" */ +#include "MuonReadoutGeometry/TgcReadoutElement.h" + +/* for track extrapolator */ +/* #include "GaudiKernel/ToolHandle.h" */ +/* #include "GaudiKernel/ServiceHandle.h" */ +/* #include "GaudiKernel/IAlgTool.h" */ +/* #include <string> */ +/* #include "xAODMuon/MuonContainer.h" */ +/* #include "AthenaKernel/errorcheck.h" */ +/* #include "TrkTrack/TrackStateOnSurface.h" */ + +#include "TrkExInterfaces/IExtrapolator.h" +/* #include "CLHEP/Vector/ThreeVector.h" */ + +/* namespace Rec { class TrackParticle; } */ +/* namespace Trk { class IExtrapolator; } */ +/* namespace Trk { class TrackStateOnSurface; } */ +/* namespace CLHEP { class Hep2Vector; } */ +/* namespace CLHEP { class Hep3Vector; } */ + + class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { public: @@ -18,49 +42,139 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { virtual ~TgcRawDataMonitorAlgorithm(); virtual StatusCode initialize() override; virtual StatusCode fillHistograms( const EventContext& ctx ) const override; - - private: - std::string m_packageName; - SG::ReadHandleKey<xAOD::MuonContainer> m_MuonContainerKey; - SG::ReadHandleKey<xAOD::MuonContainer> m_MuonEFContainerKey; - SG::ReadHandleKey<xAOD::MuonRoIContainer> m_MuonRoIContainerKey; - std::string m_trigTagList; - bool m_TagAndProbe; - - std::vector<int> m_Groups_trig2bcid; - - std::vector<int> m_Groups_roiEta2Phi; - std::vector<int> m_Groups_roiEta; - std::vector<int> m_Groups_roiPhi_barrel_A; - std::vector<int> m_Groups_roiPhi_endcap_A; - std::vector<int> m_Groups_roiPhi_forward_A; - std::vector<int> m_Groups_roiPhi_barrel_C; - std::vector<int> m_Groups_roiPhi_endcap_C; - std::vector<int> m_Groups_roiPhi_forward_C; - - std::vector<int> m_Groups_muEta2Phi; - std::vector<int> m_Groups_muEta; - std::vector<int> m_Groups_muPhi_barrel_A; - std::vector<int> m_Groups_muPhi_endcap_A; - std::vector<int> m_Groups_muPhi_forward_A; - std::vector<int> m_Groups_muPhi_barrel_C; - std::vector<int> m_Groups_muPhi_endcap_C; - std::vector<int> m_Groups_muPhi_forward_C; - std::vector<int> m_Groups_muPt_barrel; - std::vector<int> m_Groups_muPt_endcap; - std::vector<int> m_Groups_muPt_forward; - + + + struct TagDef{ TString eventTrig; - float threshold; - bool isolated; + TString tagTrig; }; - std::vector<TagDef> m_trigTagDefs; - struct Muons{ + struct MyMuon{ const xAOD::Muon* muon; + TLorentzVector fourvec; + std::vector<TVector3> extPos; + std::vector<TVector3> extVec; bool tagged; bool isolated; + bool probeOK_any; + bool probeOK_Z; + std::set<int> matchedL1ThrExclusive; + std::set<int> matchedL1ThrInclusive; + }; + + struct TgcHit{ + float x; + float y; + float z; + float shortWidth; + float longWidth; + float length; + int isStrip; + int gasGap; + int channel; + int eta; + int phi; + int station; + int bunch; + }; + struct TgcTrig{ + float x_In; + float y_In; + float z_In; + float x_Out; + float y_Out; + float z_Out; + float width_In; + float width_Out; + float width_R; + float width_Phi; + int isAside; + int isForward; + int isStrip; + int isInner; + int isPositiveDeltaR; + int type; + int trackletId; + int trackletIdStrip; + int phi; + int roi; + int pt; + int delta; + int sub; + int veto; + int bunch; + int inner; }; + + private: + + + SG::ReadHandleKey<xAOD::MuonContainer> m_MuonContainerKey{this,"MuonContainerName","Muons","Offline muon track container"}; + SG::ReadHandleKey<xAOD::MuonContainer> m_MuonEFContainerKey{this,"MuonEFContainerName","HLT_MuonsCB_RoI","HLT RoI-based muon track container"}; + SG::ReadHandleKey<xAOD::MuonRoIContainer> m_MuonRoIContainerKey{this,"MuonRoIContainerName","LVL1MuonRoIs","L1 muon RoI container"}; + /* ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"}; */ + + + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_TgcPrepDataContainerKey{this,"TgcPrepDataContainerName","TGC_MeasurementsAllBCs","current BC TGC PRD"}; + SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_TgcCoinDataContainerCurrBCKey{this,"TgcCoinDataContainerCurrBCName","TrigT1CoinDataCollection","TGC Coin Data Container CurrBC"}; + SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_TgcCoinDataContainerNextBCKey{this,"TgcCoinDataContainerNextBCName","TrigT1CoinDataCollectionNextBC","TGC Coin Data Container NextBC"}; + SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_TgcCoinDataContainerPrevBCKey{this,"TgcCoinDataContainerPrevBCName","TrigT1CoinDataCollectionPriorBC","TGC Coin Data Container PrevBC"}; + + ToolHandle<Muon::MuonIdHelperTool> m_MuonIdHelperTool{this, "MuonIdHelperTool", "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + /* SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", */ + /* "MuonDetectorManager", */ + /* "Key of input MuonDetectorManager condition data"}; */ + + StatusCode triggerMatching(const xAOD::Muon* , const std::vector<TagDef>& ) const; + + StringProperty m_trigTagList{this,"TagTrigList","HLT_mu26_ivarmedium_L1MU20","list of triggers to be used for trigger matching"}; + BooleanProperty m_TagAndProbe{this,"TagAndProbe",false,"switch to perform tag-and-probe method"}; + DoubleProperty m_trigMatchWindow{this,"TrigMatchingWindow",0.005,"Window size in R for trigger matching"}; + DoubleProperty m_l1trigMatchWindow1{this,"L1TrigMatchingWindow1",0.15,"Window size in R for L1 trigger matching: param 1"}; + DoubleProperty m_l1trigMatchWindow2{this,"L1TrigMatchingWindow2",0.3,"Window size in R for L1 trigger matching: param 2"}; + DoubleProperty m_l1trigMatchWindow3{this,"L1TrigMatchingWindow3",-0.01,"Window size in R for L1 trigger matching: param 3"}; + DoubleProperty m_l1trigMatchWindow4{this,"L1TrigMatchingWindow4",0.36,"Window size in R for L1 trigger matching: param 4"}; + DoubleProperty m_l1trigMatchWindow5{this,"L1TrigMatchingWindow5",-0.0016,"Window size in R for L1 trigger matching: param 5"}; + DoubleProperty m_isolationWindow{this,"IsolationWindow",0.1,"Window size in R for isolation with other muons"}; + StringProperty m_packageName{this,"PackageName","TgcRawDataMonitor","group name for histograming"}; + + DoubleProperty m_M1_Z{this,"M1_Z",13605.0,"z-position of TGC M1-station in mm for track extrapolate"}; + DoubleProperty m_M2_Z{this,"M2_Z",14860.0,"z-position of TGC M2-station in mm for track extrapolate"}; + DoubleProperty m_M3_Z{this,"M3_Z",15280.0,"z-position of TGC M3-station in mm for track extrapolate"}; + DoubleProperty m_EI_Z{this,"EI_Z",7425.0,"z-position of TGC EI-station in mm for track extrapolate"}; + DoubleProperty m_FI_Z{this,"FI_Z",7030.0,"z-position of TGC FI-station in mm for track extrapolate"}; + + DoubleProperty m_muonMass{this,"MuonMass",105.6583755,"muon invariant mass in MeV"}; + DoubleProperty m_zMass{this,"ZMass",91187.6,"muon invariant mass in MeV"}; + DoubleProperty m_zMassWindow{this,"ZMassWindow",10000,"muon invariant mass half-window in MeV"}; + + DoubleProperty m_endcapPivotPlaneMinimumRadius{this,"endcapPivotPlaneMinimumRadius",0.,"minimum radius of pivot plane in endcap region"}; + DoubleProperty m_endcapPivotPlaneMaximumRadius{this,"endcapPivotPlaneMaximumRadius", 11977.,"maximum radius of pivot plane in endcap region"}; + DoubleProperty m_barrelPivotPlaneHalfLength{this,"barrelPivotPlaneHalfLength", 9500.,"half length of pivot plane in barrel region"}; + + + std::vector<TagDef> m_trigTagDefs; + std::vector<double> m_extZposition; + + /* track extrapolator tool */ + enum TargetDetector { UNDEF, TGC, RPC }; + void extrapolate(const xAOD::Muon*, MyMuon&) const; + bool extrapolate(const xAOD::TrackParticle* trackParticle, + const Amg::Vector3D& pos, + const int detector, + Amg::Vector2D& eta, + Amg::Vector2D& phi, + Amg::Vector3D& mom) const; + const Trk::TrackParameters* + extrapolateToTGC(const Trk::TrackStateOnSurface* tsos, + const Amg::Vector3D& pos, + Amg::Vector2D& distance) const; + const Trk::TrackParameters* + extrapolateToRPC(const Trk::TrackStateOnSurface* tsos, + const Amg::Vector3D& pos, + Amg::Vector2D& distance) const; + double getError(const std::vector<double>& inputVec) const; + ToolHandle<Trk::IExtrapolator> m_extrapolator{this,"TrackExtrapolator","Trk::Extrapolator/AtlasExtrapolator","Track extrapolator"}; }; #endif -- GitLab From 4b7bdecb5a03760c7fc529a506faa20d166f1e59 Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Tue, 17 Mar 2020 13:25:44 +0100 Subject: [PATCH 2/6] update tgc dq --- .../python/TgcRawDataMonitorAlgorithm.py | 193 +++---------- .../src/TgcRawDataMonitorAlgorithm.cxx | 268 +++++++++--------- .../src/TgcRawDataMonitorAlgorithm.h | 25 +- 3 files changed, 193 insertions(+), 293 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py index 9d11f1326e70..e14de82cb16c 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py @@ -13,69 +13,18 @@ def TgcRawDataMonitoringConfig(inputFlags): from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator result = ComponentAccumulator() - # from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg - # result.merge(MuonGeoModelCfg(inputFlags)) - # result.addPublicTool( CompFactory.Muon__MuonIdHelperTool() ) + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg result.merge(MagneticFieldSvcCfg(inputFlags)) - from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) geom_svc = trackGeomCfg.getPrimary() geom_svc.GeometryBuilder.Compactify = False ######## To avoid crash ######## result.merge(trackGeomCfg) - - # from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg - # result.merge(MagneticFieldSvcCfg(inputFlags)) - - # from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg - # result.merge( TrackCollectionReadCfg (inputFlags, 'CombinedInDetTracks') ) - - # from TrkConfig.TrackCollectionReadConfig import TrackCollectionReadCfg - # result.merge (TrackCollectionReadCfg (inputFlags, 'CombinedInDetTracks')) - # result.merge (TrackCollectionReadCfg (inputFlags, 'Tracks')) - # from PixelConditionsAlgorithms.PixelConditionsConfig import PixelConfigCondAlgCfg - # result.merge(PixelConfigCondAlgCfg(inputFlags, - # UseCalibConditions=True, - # UseDeadmapConditions=True, - # UseDCSStateConditions=False, - # UseDCSStatusConditions=False, - # UseDCSHVConditions=True, - # UseDCSTemperatureConditions=True, - # UseTDAQConditions=False)) - # from PixelConditionsTools.PixelConditionsSummaryConfig import PixelConditionsSummaryCfg - # InDetPixelConditionsSummaryTool = result.popToolsAndMerge(PixelConditionsSummaryCfg(inputFlags)) - - # from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg - # trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) - # geom_svc = trackGeomCfg.getPrimary() - # geom_svc.GeometryBuilder.Compactify = False ######## To avoid crash ######## - # result.merge(trackGeomCfg) - # from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg - # result.merge(MagneticFieldSvcCfg(inputFlags)) - - # from TrkExTools.TrkExToolsConf import Trk__Navigator - # AtlasNavigator = Trk__Navigator(name = 'AtlasNavigator') - # AtlasNavigator.TrackingGeometrySvc = geom_svc - # result.addPublicTool(AtlasNavigator) - - - - # from TrkExTools.TrkExToolsConf import Trk__Navigator - # AtlasNavigator = Trk__Navigator(name = 'AtlasNavigator') - # AtlasNavigator.TrackingGeometrySvc = geom_svc - # result.addPublicTool(AtlasNavigator) - # from TrigInDetConfig.InDetConfig import TrigInDetCondConfig - # result.merge(TrigInDetCondConfig(inputFlags)) - - # from PixelConditionsAlgorithms.PixelConditionsConfig import PixelConfigCondAlgCfg,PixelDetectorElementCondAlgCfg - # result.merge( PixelConfigCondAlgCfg(inputFlags,name="PixelConfigCondAlg") ) - # result.merge( PixelDetectorElementCondAlgCfg(inputFlags,name="PixelDetectorElementCondAlg") ) from AthenaMonitoring import AthMonitorCfgHelper helper = AthMonitorCfgHelper(inputFlags,'TgcRawDataMonitorCfg') - from AthenaConfiguration.ComponentFactory import CompFactory tgcRawDataMonAlg = helper.addAlgorithm(CompFactory.TgcRawDataMonitorAlgorithm,'TgcRawDataMonAlg') tgcRawDataMonAlg.TagAndProbe = True @@ -87,9 +36,12 @@ def TgcRawDataMonitoringConfig(inputFlags): tgcRawDataMonAlg.TagTrigList += ',HLT_mu6_L1MU6' tgcRawDataMonAlg.TagTrigList += ',HLT_mu20_mu8noL1;HLT_mu20' - # Run 2 containers? if 'HLT_xAOD__MuonContainer_MuonEFInfo' in inputFlags.Input.Collections: tgcRawDataMonAlg.MuonEFContainerName='HLT_xAOD__MuonContainer_MuonEFInfo' + if 'TGC_MeasurementsAllBCs' in inputFlags.Input.Collections: + tgcRawDataMonAlg.AnaTgcPrd=True + if 'TrigT1CoinDataCollection' in inputFlags.Input.Collections: + tgcRawDataMonAlg.AnaTgcCoin=True mainDir = 'Muon/MuonRawDataMonitoring/TGC/' import math @@ -98,14 +50,32 @@ def TgcRawDataMonitoringConfig(inputFlags): myGroup = helper.addGroup(tgcRawDataMonAlg,'TgcRawDataMonitor',mainDir) + myGroup.defineHistogram('random', title='LB;x;Events', + path='ToBringThemAll',xbins=30,xmin=0,xmax=1,opt='kLBNHistoryDepth=10') + myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_RPC',title='MuonRoI Thresholds RPC;MuonRoI Threshold number;Number of events', cutmask='roi_rpc',path=trigPath,xbins=20,xmin=-0.5,xmax=19.5) myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_TGC',title='MuonRoI Thresholds TGC;MuonRoI Threshold number;Number of events', cutmask='roi_tgc',path=trigPath,xbins=20,xmin=-0.5,xmax=19.5) - for n in range(16): + myGroup.defineHistogram('lb,roi_phi_barrel;MuonRoI_PhiVsLB_Barrel_sideA',title='MuonRoI PhiVsLB Barrel sideA;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideA',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=8,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + myGroup.defineHistogram('lb,roi_phi_barrel;MuonRoI_PhiVsLB_Barrel_sideC',title='MuonRoI PhiVsLB Barrel sideC;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideC',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=8,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + + myGroup.defineHistogram('lb,roi_phi_endcap;MuonRoI_PhiVsLB_Endcap_sideA',title='MuonRoI PhiVsLB Endcap sideA;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideA',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=48,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + myGroup.defineHistogram('lb,roi_phi_endcap;MuonRoI_PhiVsLB_Endcap_sideC',title='MuonRoI PhiVsLB Endcap sideC;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideC',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=48,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + + myGroup.defineHistogram('lb,roi_phi_forward;MuonRoI_PhiVsLB_Forward_sideA',title='MuonRoI PhiVsLB Forward sideA;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideA',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=24,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + myGroup.defineHistogram('lb,roi_phi_forward;MuonRoI_PhiVsLB_Forward_sideC',title='MuonRoI PhiVsLB Forward sideC;Luminosity block;Trigger sector',type='TH2F', + cutmask='roi_sideC',path=trigPath,xbins=100,xmin=-0.5,xmax=99.5,ybins=24,ymin=-math.pi,ymax=math.pi,opt='kAddBinsDynamically') + + for n in range(1,16): myGroup.defineHistogram('roi_eta;MuonRoI_Eta_Thr'+str(n),title='MuonRoI Eta Thr'+str(n)+';MuonRoI Eta;Number of events', - cutmask='thrmask'+str(n),path=trigPath,xbins=60,xmin=-3,xmax=3) + cutmask='thrmask'+str(n),path=trigPath,xbins=100,xmin=-2.5,xmax=2.5) myGroup.defineHistogram('roi_phi_rpc;MuonRoI_Phi_RPC_Thr'+str(n),title='MuonRoI Phi RPC Thr'+str(n)+';MuonRoI Phi;Number of events', cutmask='thrmask'+str(n),path=trigPath,xbins=32,xmin=-math.pi,xmax=math.pi) myGroup.defineHistogram('roi_phi_tgc;MuonRoI_Phi_TGC_Thr'+str(n),title='MuonRoI Phi TGC Thr'+str(n)+';MuonRoI Phi;Number of events', @@ -114,98 +84,22 @@ def TgcRawDataMonitoringConfig(inputFlags): title='MuonRoI Eta vs Phi Thr'+str(n)+';MuonRoI Eta;MuonRoI Phi',cutmask='thrmask'+str(n),path=trigPath, xbins=100,xmin=-2.5,xmax=2.5,ybins=48,ymin=-math.pi,ymax=math.pi) myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_pt_rpc;MuonRoI_Eff_Pt_RPC_Thr'+str(n),title='MuonRoI_Eff_Pt_RPC_Thr'+str(n)+';Offline muon pT [GeV];Efficiency', - type='TEfficiency',path=trigPath,xbins=100,xmin=0,xmax=50) + type='TEfficiency',path=trigPath,xbins=50,xmin=0,xmax=50) myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_pt_tgc;MuonRoI_Eff_Pt_TGC_Thr'+str(n),title='MuonRoI_Eff_Pt_TGC_Thr'+str(n)+';Offline muon pT [GeV];Efficiency', - type='TEfficiency',path=trigPath,xbins=100,xmin=0,xmax=50) + type='TEfficiency',path=trigPath,xbins=50,xmin=0,xmax=50) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_phi_rpc;MuonRoI_Eff_Phi_RPC_Thr'+str(n),title='MuonRoI_Eff_Phi_RPC_Thr'+str(n)+';Offline muon phi [rad.];Efficiency', + type='TEfficiency',path=trigPath,xbins=32,xmin=-math.pi,xmax=math.pi) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_phi_tgc;MuonRoI_Eff_Phi_TGC_Thr'+str(n),title='MuonRoI_Eff_Phi_TGC_Thr'+str(n)+';Offline muon phi [rad.];Efficiency', + type='TEfficiency',path=trigPath,xbins=48,xmin=-math.pi,xmax=math.pi) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_eta;MuonRoI_Eff_Eta_Thr'+str(n),title='MuonRoI_Eff_Eta_Thr'+str(n)+';Offline muon eta;Efficiency', + type='TEfficiency',path=trigPath,xbins=100,xmin=-2.5,xmax=2.5) + myGroup.defineHistogram('muon_l1passThr'+str(n)+',muon_eta,muon_phi;MuonRoI_Eff_EtaVsPhi_Thr'+str(n),title='MuonRoI_Eff_EtaVsPhi_Thr'+str(n)+';Offline muon eta; Offline muon phi', + type='TEfficiency',path=trigPath,xbins=100,xmin=-2.5,xmax=2.5,ybins=48,ymin=-math.pi,ymax=math.pi) - # myGroup.defineHistogram('pT_passed,pT', type='TEfficiency', title='Test TEfficiency;x;Eff', - # path='AndInTheDarkness', xbins=100, xmin=0.0, xmax=50.0) - - # myGroup.defineHistogram('eta;Test1',title='Hoge1;hoge2;hoge3', - # path=trigPath,xbins=60,xmin=-3,xmax=3) - - # # myGroup.defineHistogram('eta,phi;Test2',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, - # # xbins=100,xmin=-2.5,xmax=2.5, - # # ybins=48,ymin=-math.pi,ymax=math.pi) - # myGroup.defineHistogram('eta,pt;Test3',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, - # xbins=100,xmin=-2.5,xmax=2.5, - # ybins=10,ymin=0,ymax=100) - - # myGroup.defineHistogram('eta,phi;Test2',title='Hoge1;hoge2;hoge3',type='TH2F',path=trigPath, - # xbins=100,xmin=-2.5,xmax=2.5, - # ybins=10,ymin=0,ymax=100) - - - # myGroup.defineHistogram('thrNumber_barrel',title='thrNumber_barrel;thrNumber;Events', - # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) - # myGroup.defineHistogram('thrNumber_endcap',title='thrNumber_endcap;thrNumber;Events', - # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) - # myGroup.defineHistogram('thrNumber_forward',title='thrNumber_forward;thrNumber;Events', - # path=trigPath,xbins=16,xmin=0.0,xmax=16.0) - - # array = helper.addArray([16],tgcRawDataMonAlg,'TgcRawDataMonitor') - # array.defineHistogram('roi_eta,roi_phi;MuonRoI_EtaVsPhi_Thr',title='MuonRoI_EtaVsPhi_Thr;roiEta;roiPhi',type='TH2F',path=mainDir+trigPath, - # xbins=100,xmin=-2.5,xmax=2.5, - # ybins=48,ymin=-math.pi,ymax=math.pi) - - # array.defineHistogram('roiEta',title='roiEta;roiEta;Events',type='TH1F',path=mainDir+trigPath, - # xbins=100,xmin=-2.5,xmax=2.5) - - # array.defineHistogram('roiPhi_barrel_A',title='roiPhi_barrel_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=16,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('roiPhi_endcap_A',title='roiPhi_endcap_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=48,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('roiPhi_forward_A',title='roiPhi_forward_A;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=24,xmin=-math.pi,xmax=math.pi) - - # array.defineHistogram('roiPhi_barrel_C',title='roiPhi_barrel_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=16,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('roiPhi_endcap_C',title='roiPhi_endcap_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=48,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('roiPhi_forward_C',title='roiPhi_forward_C;roiPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=24,xmin=-math.pi,xmax=math.pi) - - # array.defineHistogram('bcID_barrel',title='trig2bcid_barrel;BCID;Events',type='TH1F',path=mainDir+trigPath, - # xbins=4000,xmin=0,xmax=4000) - # array.defineHistogram('bcID_endcap',title='trig2bcid_endcap;BCID;Events',type='TH1F',path=mainDir+trigPath, - # xbins=4000,xmin=0,xmax=4000) - # array.defineHistogram('bcID_forward',title='trig2bcid_forward;BCID;Events',type='TH1F',path=mainDir+trigPath, - # xbins=4000,xmin=0,xmax=4000) - - # array.defineHistogram('muEta,muPhi',title='muEta2Phi;muEta;muPhi',type='TH2F',path=mainDir+trigPath, - # xbins=100,xmin=-2.5,xmax=2.5, - # ybins=48,ymin=-math.pi,ymax=math.pi) - - # array.defineHistogram('muEta',title='muEta;muEta;Events',type='TH1F',path=mainDir+trigPath, - # xbins=100,xmin=-2.5,xmax=2.5) - - # array.defineHistogram('muPt_barrel',title='muPt_barrel;muPt;Events',type='TH1F',path=mainDir+trigPath, - # xbins=40,xmin=0,xmax=40) - # array.defineHistogram('muPt_endcap',title='muPt_endcap;muPt;Events',type='TH1F',path=mainDir+trigPath, - # xbins=40,xmin=0,xmax=40) - # array.defineHistogram('muPt_forward',title='muPt_forward;muPt;Events',type='TH1F',path=mainDir+trigPath, - # xbins=40,xmin=0,xmax=40) - - # array.defineHistogram('muPhi_barrel_A',title='muPhi_barrel_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=16,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('muPhi_endcap_A',title='muPhi_endcap_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=48,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('muPhi_forward_A',title='muPhi_forward_A;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=24,xmin=-math.pi,xmax=math.pi) - - # array.defineHistogram('muPhi_barrel_C',title='muPhi_barrel_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=16,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('muPhi_endcap_C',title='muPhi_endcap_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=48,xmin=-math.pi,xmax=math.pi) - # array.defineHistogram('muPhi_forward_C',title='muPhi_forward_C;muPhi;Events',type='TH1F',path=mainDir+trigPath, - # xbins=24,xmin=-math.pi,xmax=math.pi) - - #acc, seq = helper.result() acc = helper.result() result.merge(acc) return result - # return helper.result() if __name__=='__main__': from AthenaCommon.Configurable import Configurable @@ -216,21 +110,18 @@ if __name__=='__main__': log.setLevel(INFO) from AthenaConfiguration.AllConfigFlags import ConfigFlags - # nightly = '/afs/cern.ch/user/e/ebergeas/work/public/triggermonitoring/nigtly_2019-08-24T2130/' - # file = 'AOD.pool.root' - # ConfigFlags.Input.Files = [nightly+file] import glob - # inputs = glob.glob('/scratch/masato/L1MuonDevRun3/21.3-rerunLVL1/run_data_eb_nocos/*/AOD.pool.root') - # inputs = glob.glob('/data03/data/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.AOD.e4993_s3214_d1540_r11773_tid20245298_00//*') - # inputs = glob.glob('/data02/data/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.recon.AOD.e4993_s3214_d1546_r11767/AOD.20152803._000173.pool.root.1') - # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/tmp.ESD') - inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/AOD*') + inputs = glob.glob('/afs/cern.ch/user/e/ebergeas/work/public/triggermonitoring/nightly_2020-03-01T2140/TrigP1Test_test_trigP1_v1PhysP1_T0Mon_build/AOD.pool.root') + + inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/tmp.ESD') + # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/AOD*') # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/mc_scan_normal/*/tmp.ESD') + + ConfigFlags.Input.Files = inputs ConfigFlags.Input.isMC = True ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput.root' - # ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_e4993_s3214_d1540_r11773.root' - # ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_e4993_s3214_d1546_r11767.root' + #ConfigFlags.IOVDb.GlobalTag = "'CONDBR2-BLKPA-2017-08" ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx index aa01ce56a690..d050a95b95f9 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx @@ -18,11 +18,10 @@ TgcRawDataMonitorAlgorithm::~TgcRawDataMonitorAlgorithm() {} StatusCode TgcRawDataMonitorAlgorithm::initialize() { - ATH_CHECK(m_MuonIdHelperTool.retrieve() ); + ATH_CHECK(m_MuonIdHelperTool.retrieve()); ATH_CHECK(m_extrapolator.retrieve()); ATH_CHECK(m_MuonContainerKey.initialize()); - ATH_CHECK(m_MuonEFContainerKey.initialize()); ATH_CHECK(m_MuonRoIContainerKey.initialize()); ATH_CHECK(m_TgcPrepDataContainerKey.initialize()); ATH_CHECK(m_TgcCoinDataContainerCurrBCKey.initialize()); @@ -60,11 +59,17 @@ StatusCode TgcRawDataMonitorAlgorithm::initialize() { } StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const { + std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables; + + auto bcid = Monitored::Scalar<int>("bcid",GetEventInfo(ctx)->bcid()); + auto lumiPerBCID = Monitored::Scalar<int>("lumiPerBCID",lbAverageInteractionsPerCrossing(ctx)); + auto lb = Monitored::Scalar<int>("lb",GetEventInfo(ctx)->lumiBlock()); + auto run = Monitored::Scalar<int>("run",GetEventInfo(ctx)->runNumber()); - auto bcid = GetEventInfo(ctx)->bcid(); - auto lumiPerBCID = lbAverageInteractionsPerCrossing(ctx); - auto lb = GetEventInfo(ctx)->lumiBlock(); - auto run = GetEventInfo(ctx)->runNumber(); + variables.push_back(bcid); + variables.push_back(lumiPerBCID); + variables.push_back(lb); + variables.push_back(run); /* raw LVL1MuonRoIs distributions */ SG::ReadHandle<xAOD::MuonRoIContainer> rois(m_MuonRoIContainerKey, ctx); @@ -74,7 +79,6 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) } - std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables; auto roi_eta = Monitored::Collection("roi_eta",*rois, []( const xAOD::MuonRoI* m ){return m->eta();}); variables.push_back( roi_eta ); auto roi_phi = Monitored::Collection("roi_phi",*rois, []( const xAOD::MuonRoI* m ){return m->phi();}); variables.push_back( roi_phi ); auto roi_phi_rpc = Monitored::Collection("roi_phi_rpc",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Barrel)?m->phi():-10;}); variables.push_back( roi_phi_rpc ); @@ -83,7 +87,17 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto roi_rpc = Monitored::Collection("roi_rpc",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()==xAOD::MuonRoI::Barrel;}); variables.push_back( roi_rpc ); auto roi_tgc = Monitored::Collection("roi_tgc",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()!=xAOD::MuonRoI::Barrel;}); variables.push_back( roi_tgc ); - auto thrmask0 = Monitored::Collection("thrmask0",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==0;});variables.push_back(thrmask0); + auto roi_barrel = Monitored::Collection("roi_barrel",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()==xAOD::MuonRoI::Barrel;}); variables.push_back( roi_barrel ); + auto roi_endcap = Monitored::Collection("roi_endcap",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()==xAOD::MuonRoI::Endcap;}); variables.push_back( roi_endcap ); + auto roi_forward = Monitored::Collection("roi_forward",*rois, []( const xAOD::MuonRoI* m ){return m->getSource()==xAOD::MuonRoI::Forward;}); variables.push_back( roi_forward ); + + auto roi_phi_barrel = Monitored::Collection("roi_phi_barrel",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Barrel)?m->phi():-10;}); variables.push_back( roi_phi_barrel ); + auto roi_phi_endcap = Monitored::Collection("roi_phi_endcap",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Endcap)?m->phi():-10;}); variables.push_back( roi_phi_endcap ); + auto roi_phi_forward = Monitored::Collection("roi_phi_forward",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Forward)?m->phi():-10;}); variables.push_back( roi_phi_forward ); + + auto roi_sideA = Monitored::Collection("roi_sideA",*rois, []( const xAOD::MuonRoI* m ){return m->getHemisphere()==xAOD::MuonRoI::Positive;}); variables.push_back( roi_sideA ); + auto roi_sideC = Monitored::Collection("roi_sideC",*rois, []( const xAOD::MuonRoI* m ){return m->getHemisphere()==xAOD::MuonRoI::Negative;}); variables.push_back( roi_sideC ); + auto thrmask1 = Monitored::Collection("thrmask1",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==1;});variables.push_back(thrmask1); auto thrmask2 = Monitored::Collection("thrmask2",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==2;});variables.push_back(thrmask2); auto thrmask3 = Monitored::Collection("thrmask3",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==3;});variables.push_back(thrmask3); @@ -99,8 +113,7 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto thrmask13 = Monitored::Collection("thrmask13",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==13;});variables.push_back(thrmask13); auto thrmask14 = Monitored::Collection("thrmask14",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==14;});variables.push_back(thrmask14); auto thrmask15 = Monitored::Collection("thrmask15",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==15;});variables.push_back(thrmask15); - - + SG::ReadHandle<xAOD::MuonContainer> muons(m_MuonContainerKey, ctx); if(!muons.isValid()){ ATH_MSG_ERROR("evtStore() does not contain muon Collection with name "<< m_MuonContainerKey); @@ -176,14 +189,14 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) break; } } - - + + auto muon_eta = Monitored::Collection("muon_eta",mymuons,[](const MyMuon& m){return (m.muon->pt()/1000>30)?m.muon->eta():-10;});variables.push_back(muon_eta); + auto muon_phi = Monitored::Collection("muon_phi",mymuons,[](const MyMuon& m){return (m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi); auto muon_phi_rpc = Monitored::Collection("muon_phi_rpc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())<1.05&&m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi_rpc); auto muon_phi_tgc = Monitored::Collection("muon_phi_tgc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())>1.05&&TMath::Abs(m.muon->eta())<2.4&&m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi_tgc); auto muon_pt_rpc = Monitored::Collection("muon_pt_rpc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())<1.05)?m.muon->pt()/1000:-10;});variables.push_back(muon_pt_rpc); auto muon_pt_tgc = Monitored::Collection("muon_pt_tgc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())>1.05&&TMath::Abs(m.muon->eta())<2.4)?m.muon->pt()/1000:-10;});variables.push_back(muon_pt_tgc); - auto muon_l1passThr1 = Monitored::Collection("muon_l1passThr1",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(1)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr1); auto muon_l1passThr2 = Monitored::Collection("muon_l1passThr2",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(2)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr2); auto muon_l1passThr3 = Monitored::Collection("muon_l1passThr3",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(3)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr3); @@ -201,128 +214,125 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto muon_l1passThr15 = Monitored::Collection("muon_l1passThr15",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(15)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr15); - SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrd(m_TgcPrepDataContainerKey, ctx); - if(!tgcPrd.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcPrepDataContainer with name "<< m_TgcPrepDataContainerKey); - return StatusCode::FAILURE; - } - - const TgcIdHelper& tgcIdHelper = m_MuonIdHelperTool->tgcIdHelper(); - - std::vector<TgcHit> tgcHits; - for(auto tgccnt : *tgcPrd){ - for(auto data : *tgccnt){ - TgcHit tgcHit; - int bunch = -10; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) bunch = -1; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) bunch = 0; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) bunch = +1; - const MuonGM::TgcReadoutElement* element = data->detectorElement(); - const Identifier id = data->identify(); - const int gasGap = tgcIdHelper.gasGap(id); - const int channel = tgcIdHelper.channel(id); - const bool isStrip = tgcIdHelper.isStrip(id); - const Amg::Vector3D& pos = isStrip ? element->stripPos(gasGap, channel) : element->gangPos(gasGap, channel); - tgcHit.x = pos[0]; - tgcHit.y = pos[1]; - tgcHit.z = pos[2]; - if (isStrip) { - tgcHit.shortWidth = element->stripShortWidth(gasGap, channel); - tgcHit.longWidth = element->stripLongWidth(gasGap, channel); - tgcHit.length = element->stripLength(gasGap, channel); - } else { - tgcHit.shortWidth = element->gangShortWidth(gasGap, channel); - tgcHit.longWidth = element->gangLongWidth(gasGap, channel); - tgcHit.length = element->gangLength(gasGap, channel); + if(m_anaTgcPrd.value()){ + SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrd(m_TgcPrepDataContainerKey, ctx); + if(!tgcPrd.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcPrepDataContainer with name "<< m_TgcPrepDataContainerKey); + return StatusCode::FAILURE; + } + const TgcIdHelper& tgcIdHelper = m_MuonIdHelperTool->tgcIdHelper(); + std::vector<TgcHit> tgcHits; + for(auto tgccnt : *tgcPrd){ + for(auto data : *tgccnt){ + TgcHit tgcHit; + int bunch = -10; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) bunch = -1; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) bunch = 0; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) bunch = +1; + const MuonGM::TgcReadoutElement* element = data->detectorElement(); + const Identifier id = data->identify(); + const int gasGap = tgcIdHelper.gasGap(id); + const int channel = tgcIdHelper.channel(id); + const bool isStrip = tgcIdHelper.isStrip(id); + const Amg::Vector3D& pos = isStrip ? element->stripPos(gasGap, channel) : element->gangPos(gasGap, channel); + tgcHit.x = pos[0]; + tgcHit.y = pos[1]; + tgcHit.z = pos[2]; + if (isStrip) { + tgcHit.shortWidth = element->stripShortWidth(gasGap, channel); + tgcHit.longWidth = element->stripLongWidth(gasGap, channel); + tgcHit.length = element->stripLength(gasGap, channel); + } else { + tgcHit.shortWidth = element->gangShortWidth(gasGap, channel); + tgcHit.longWidth = element->gangLongWidth(gasGap, channel); + tgcHit.length = element->gangLength(gasGap, channel); + } + tgcHit.isStrip = tgcIdHelper.isStrip(id); + tgcHit.gasGap = tgcIdHelper.gasGap(id); + tgcHit.channel = tgcIdHelper.channel(id); + tgcHit.eta = tgcIdHelper.stationEta(id); + tgcHit.phi = tgcIdHelper.stationPhi(id); + tgcHit.station = tgcIdHelper.stationName(id); + tgcHit.bunch = bunch; + tgcHits.push_back(tgcHit); } - tgcHit.isStrip = tgcIdHelper.isStrip(id); - tgcHit.gasGap = tgcIdHelper.gasGap(id); - tgcHit.channel = tgcIdHelper.channel(id); - tgcHit.eta = tgcIdHelper.stationEta(id); - tgcHit.phi = tgcIdHelper.stationPhi(id); - tgcHit.station = tgcIdHelper.stationName(id); - tgcHit.bunch = bunch; - tgcHits.push_back(tgcHit); } + auto hit_n = Monitored::Scalar<int>("hit_n",tgcHits.size());variables.push_back(hit_n); + auto hit_bunch = Monitored::Collection("hit_bunch",tgcHits,[](const TgcHit& m){return m.bunch;});variables.push_back(hit_bunch); + auto hit_sideA = Monitored::Collection("hit_sideA",tgcHits,[](const TgcHit& m){return m.z>0;});variables.push_back(hit_sideA); + auto hit_sideC = Monitored::Collection("hit_sideC",tgcHits,[](const TgcHit& m){return m.z<0;});variables.push_back(hit_sideC); } - - auto hit_n = Monitored::Scalar<int>("hit_n",tgcHits.size());variables.push_back(hit_n); - auto hit_bunch = Monitored::Collection("hit_bunch",tgcHits,[](const TgcHit& m){return m.bunch;});variables.push_back(hit_bunch); - auto hit_sideA = Monitored::Collection("hit_sideA",tgcHits,[](const TgcHit& m){return m.z>0;});variables.push_back(hit_sideA); - auto hit_sideC = Monitored::Collection("hit_sideC",tgcHits,[](const TgcHit& m){return m.z<0;});variables.push_back(hit_sideC); - - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinCurr(m_TgcCoinDataContainerCurrBCKey, ctx); - if(!tgcCoinCurr.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerCurrBCKey); - return StatusCode::FAILURE; - } - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinNext(m_TgcCoinDataContainerNextBCKey, ctx); - if(!tgcCoinNext.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerNextBCKey); - return StatusCode::FAILURE; - } - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinPrev(m_TgcCoinDataContainerPrevBCKey, ctx); - if(!tgcCoinPrev.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerPrevBCKey); - return StatusCode::FAILURE; - } - - std::map<int, SG::ReadHandle<Muon::TgcCoinDataContainer> > tgcCoin; - tgcCoin[0] = tgcCoinCurr; - tgcCoin[+1] = tgcCoinNext; - tgcCoin[-1] = tgcCoinPrev; - - std::vector<TgcTrig> tgcTrigs; - for(auto thisCoin : tgcCoin){ - int bunch = thisCoin.first; - for(auto tgccnt : *(thisCoin.second)){ - for(auto data : *tgccnt){ - TgcTrig tgcTrig; - const int type = data->type(); - const Amg::Vector3D& posIn = data->globalposIn(); - tgcTrig.x_In = posIn[0]; - tgcTrig.y_In = posIn[1]; - tgcTrig.z_In = posIn[2]; - const Amg::Vector3D& posOut = data->globalposOut(); - tgcTrig.x_Out = posOut[0]; - tgcTrig.y_Out = posOut[1]; - tgcTrig.z_Out = posOut[2]; - tgcTrig.width_In = data->widthIn(); - tgcTrig.width_Out = data->widthOut(); - if (type == Muon::TgcCoinData::TYPE_SL) { - const Amg::MatrixX& matrix = data->errMat(); - tgcTrig.width_R = matrix(0,0); - tgcTrig.width_Phi = matrix(1,1); - } else { - tgcTrig.width_R = 0.; - tgcTrig.width_Phi = 0.; - } - tgcTrig.isAside = data->isAside(); - tgcTrig.isForward = data->isForward(); - tgcTrig.isStrip = data->isStrip(); - tgcTrig.isInner = data->isInner(); - tgcTrig.isPositiveDeltaR = data->isPositiveDeltaR(); - tgcTrig.type = type; - tgcTrig.trackletId = data->trackletId(); - tgcTrig.trackletIdStrip = data->trackletIdStrip(); - tgcTrig.phi = data->phi(); - tgcTrig.roi = data->roi(); - tgcTrig.pt = data->pt(); - tgcTrig.delta = data->delta(); - tgcTrig.sub = data->sub(); - tgcTrig.veto = data->veto(); - tgcTrig.bunch = bunch; - tgcTrig.inner = data->inner(); - tgcTrigs.push_back( tgcTrig ); + if(m_anaTgcCoin.value()){ + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinCurr(m_TgcCoinDataContainerCurrBCKey, ctx); + if(!tgcCoinCurr.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerCurrBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinNext(m_TgcCoinDataContainerNextBCKey, ctx); + if(!tgcCoinNext.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerNextBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinPrev(m_TgcCoinDataContainerPrevBCKey, ctx); + if(!tgcCoinPrev.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerPrevBCKey); + return StatusCode::FAILURE; + } + std::map<int, SG::ReadHandle<Muon::TgcCoinDataContainer> > tgcCoin; + tgcCoin[0] = tgcCoinCurr; + tgcCoin[+1] = tgcCoinNext; + tgcCoin[-1] = tgcCoinPrev; + std::vector<TgcTrig> tgcTrigs; + for(auto thisCoin : tgcCoin){ + int bunch = thisCoin.first; + for(auto tgccnt : *(thisCoin.second)){ + for(auto data : *tgccnt){ + TgcTrig tgcTrig; + const int type = data->type(); + const Amg::Vector3D& posIn = data->globalposIn(); + tgcTrig.x_In = posIn[0]; + tgcTrig.y_In = posIn[1]; + tgcTrig.z_In = posIn[2]; + const Amg::Vector3D& posOut = data->globalposOut(); + tgcTrig.x_Out = posOut[0]; + tgcTrig.y_Out = posOut[1]; + tgcTrig.z_Out = posOut[2]; + tgcTrig.width_In = data->widthIn(); + tgcTrig.width_Out = data->widthOut(); + if (type == Muon::TgcCoinData::TYPE_SL) { + const Amg::MatrixX& matrix = data->errMat(); + tgcTrig.width_R = matrix(0,0); + tgcTrig.width_Phi = matrix(1,1); + } else { + tgcTrig.width_R = 0.; + tgcTrig.width_Phi = 0.; + } + tgcTrig.isAside = data->isAside(); + tgcTrig.isForward = data->isForward(); + tgcTrig.isStrip = data->isStrip(); + tgcTrig.isInner = data->isInner(); + tgcTrig.isPositiveDeltaR = data->isPositiveDeltaR(); + tgcTrig.type = type; + tgcTrig.trackletId = data->trackletId(); + tgcTrig.trackletIdStrip = data->trackletIdStrip(); + tgcTrig.phi = data->phi(); + tgcTrig.roi = data->roi(); + tgcTrig.pt = data->pt(); + tgcTrig.delta = data->delta(); + tgcTrig.sub = data->sub(); + tgcTrig.veto = data->veto(); + tgcTrig.bunch = bunch; + tgcTrig.inner = data->inner(); + tgcTrigs.push_back( tgcTrig ); + } } } } - - - - - fill(m_packageName,variables); + + + + fill(m_packageName,variables); variables.clear(); // if( !m_TagAndProbe.value() ) return StatusCode::SUCCESS; @@ -338,7 +348,7 @@ StatusCode TgcRawDataMonitorAlgorithm::triggerMatching(const xAOD::Muon* offline TVector3 muonvec; muonvec.SetPtEtaPhi(offline_muon->pt(),offline_muon->eta(),offline_muon->phi()); for(auto tagTrig : list_of_triggers ){ if( !getTrigDecisionTool()->isPassed( tagTrig.eventTrig.Data() ) ) return StatusCode::FAILURE; - auto features = getTrigDecisionTool()->features<xAOD::MuonContainer>( tagTrig.tagTrig.Data() ,TrigDefs::Physics,"HLT_MuonsCB_RoI"); + auto features = getTrigDecisionTool()->features<xAOD::MuonContainer>( tagTrig.tagTrig.Data() ,TrigDefs::Physics,m_MuonEFContainerName.value()); for(auto aaa : features){ ATH_CHECK( aaa.isValid() ); auto trigmuon_link = aaa.link; diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h index 7d78f0dc6cae..1c8fa3ed2ee9 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h @@ -43,8 +43,6 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { virtual StatusCode initialize() override; virtual StatusCode fillHistograms( const EventContext& ctx ) const override; - - struct TagDef{ TString eventTrig; TString tagTrig; @@ -105,15 +103,13 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { int bunch; int inner; }; + private: SG::ReadHandleKey<xAOD::MuonContainer> m_MuonContainerKey{this,"MuonContainerName","Muons","Offline muon track container"}; - SG::ReadHandleKey<xAOD::MuonContainer> m_MuonEFContainerKey{this,"MuonEFContainerName","HLT_MuonsCB_RoI","HLT RoI-based muon track container"}; SG::ReadHandleKey<xAOD::MuonRoIContainer> m_MuonRoIContainerKey{this,"MuonRoIContainerName","LVL1MuonRoIs","L1 muon RoI container"}; - /* ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"}; */ - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_TgcPrepDataContainerKey{this,"TgcPrepDataContainerName","TGC_MeasurementsAllBCs","current BC TGC PRD"}; SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_TgcCoinDataContainerCurrBCKey{this,"TgcCoinDataContainerCurrBCName","TrigT1CoinDataCollection","TGC Coin Data Container CurrBC"}; @@ -121,14 +117,17 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_TgcCoinDataContainerPrevBCKey{this,"TgcCoinDataContainerPrevBCName","TrigT1CoinDataCollectionPriorBC","TGC Coin Data Container PrevBC"}; ToolHandle<Muon::MuonIdHelperTool> m_MuonIdHelperTool{this, "MuonIdHelperTool", "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; - /* SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", */ - /* "MuonDetectorManager", */ - /* "Key of input MuonDetectorManager condition data"}; */ - - StatusCode triggerMatching(const xAOD::Muon* , const std::vector<TagDef>& ) const; StringProperty m_trigTagList{this,"TagTrigList","HLT_mu26_ivarmedium_L1MU20","list of triggers to be used for trigger matching"}; - BooleanProperty m_TagAndProbe{this,"TagAndProbe",false,"switch to perform tag-and-probe method"}; + BooleanProperty m_TagAndProbe{this,"TagAndProbe",false,"switch to perform tag-and-probe method"}; + + BooleanProperty m_anaTgcPrd{this,"AnaTgcPrd",false,"switch to perform analysis on TGC PRD"}; + BooleanProperty m_anaTgcCoin{this,"AnaTgcCoin",false,"switch to perform analysis on TGC Coin"}; + BooleanProperty m_anaOfflMuon{this,"AnaOfflMuon",true,"switch to perform analysis on xAOD::Muon"}; + BooleanProperty m_anaMuonRoI{this,"AnaMuonRoI",true,"switch to perform analysis on xAOD::LVL1MuonRoI"}; + + StringProperty m_MuonEFContainerName{this,"MuonEFContainerName","HLT_MuonsCB_RoI","HLT RoI-based muon track container"}; + DoubleProperty m_trigMatchWindow{this,"TrigMatchingWindow",0.005,"Window size in R for trigger matching"}; DoubleProperty m_l1trigMatchWindow1{this,"L1TrigMatchingWindow1",0.15,"Window size in R for L1 trigger matching: param 1"}; DoubleProperty m_l1trigMatchWindow2{this,"L1TrigMatchingWindow2",0.3,"Window size in R for L1 trigger matching: param 2"}; @@ -152,10 +151,10 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { DoubleProperty m_endcapPivotPlaneMaximumRadius{this,"endcapPivotPlaneMaximumRadius", 11977.,"maximum radius of pivot plane in endcap region"}; DoubleProperty m_barrelPivotPlaneHalfLength{this,"barrelPivotPlaneHalfLength", 9500.,"half length of pivot plane in barrel region"}; - std::vector<TagDef> m_trigTagDefs; std::vector<double> m_extZposition; - + + StatusCode triggerMatching(const xAOD::Muon* , const std::vector<TagDef>& ) const; /* track extrapolator tool */ enum TargetDetector { UNDEF, TGC, RPC }; -- GitLab From 1b6403cb8cd929edbd2f928a09ab4325b29396a0 Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Tue, 17 Mar 2020 13:27:12 +0100 Subject: [PATCH 3/6] update tgc dq --- .../TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py index e14de82cb16c..1a4296dc3f09 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py @@ -106,7 +106,7 @@ if __name__=='__main__': Configurable.configurableRun3Behavior = 1 from AthenaCommon.Logging import log - from AthenaCommon.Constants import INFO + from AthenaCommon.Constants import INFO,DEBUG log.setLevel(INFO) from AthenaConfiguration.AllConfigFlags import ConfigFlags -- GitLab From a72ec94c3578dcebffc9bedbe69d396475b62e07 Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Tue, 17 Mar 2020 21:38:01 +0100 Subject: [PATCH 4/6] add more histograms in TGC DQ --- .../python/TgcRawDataMonitorAlgorithm.py | 39 ++- .../src/TgcRawDataMonitorAlgorithm.cxx | 257 +++++++++--------- .../src/TgcRawDataMonitorAlgorithm.h | 35 +-- 3 files changed, 156 insertions(+), 175 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py index 1a4296dc3f09..d20436797b9b 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # ''' @@ -16,6 +16,10 @@ def TgcRawDataMonitoringConfig(inputFlags): from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg result.merge(MagneticFieldSvcCfg(inputFlags)) + + from AtlasGeoModel.AtlasGeoModelConfig import AtlasGeometryCfg + result.merge(AtlasGeometryCfg(inputFlags)) + from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) geom_svc = trackGeomCfg.getPrimary() @@ -27,8 +31,6 @@ def TgcRawDataMonitoringConfig(inputFlags): tgcRawDataMonAlg = helper.addAlgorithm(CompFactory.TgcRawDataMonitorAlgorithm,'TgcRawDataMonAlg') - tgcRawDataMonAlg.TagAndProbe = True - tgcRawDataMonAlg.TagTrigList = 'HLT_mu26_ivarmedium' tgcRawDataMonAlg.TagTrigList += ',HLT_mu26_ivarmedium' tgcRawDataMonAlg.TagTrigList += ',HLT_mu26_ivarmedium_L1MU20' @@ -40,8 +42,6 @@ def TgcRawDataMonitoringConfig(inputFlags): tgcRawDataMonAlg.MuonEFContainerName='HLT_xAOD__MuonContainer_MuonEFInfo' if 'TGC_MeasurementsAllBCs' in inputFlags.Input.Collections: tgcRawDataMonAlg.AnaTgcPrd=True - if 'TrigT1CoinDataCollection' in inputFlags.Input.Collections: - tgcRawDataMonAlg.AnaTgcCoin=True mainDir = 'Muon/MuonRawDataMonitoring/TGC/' import math @@ -50,9 +50,6 @@ def TgcRawDataMonitoringConfig(inputFlags): myGroup = helper.addGroup(tgcRawDataMonAlg,'TgcRawDataMonitor',mainDir) - myGroup.defineHistogram('random', title='LB;x;Events', - path='ToBringThemAll',xbins=30,xmin=0,xmax=1,opt='kLBNHistoryDepth=10') - myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_RPC',title='MuonRoI Thresholds RPC;MuonRoI Threshold number;Number of events', cutmask='roi_rpc',path=trigPath,xbins=20,xmin=-0.5,xmax=19.5) myGroup.defineHistogram('roi_thr;MuonRoI_Thresholds_TGC',title='MuonRoI Thresholds TGC;MuonRoI Threshold number;Number of events', @@ -97,6 +94,18 @@ def TgcRawDataMonitoringConfig(inputFlags): type='TEfficiency',path=trigPath,xbins=100,xmin=-2.5,xmax=2.5,ybins=48,ymin=-math.pi,ymax=math.pi) + hitPath = 'Hit/' + myGroup.defineHistogram('hit_n;TgcPrd_nHits',title='TgcPrd_nHits;Number of hits;Number of events', + path=hitPath,xbins=100,xmin=0,xmax=1000,opt='kAddBinsDynamically') + myGroup.defineHistogram('hit_bunch;TgcPrd_Timing',title='TgcPrd_Timing;Timing;Number of events', + path=hitPath,xbins=4,xmin=-1.5,xmax=1.5,xlabels=['Previous','Current','Next']) + + coinPath = 'Coin/' + myGroup.defineHistogram('coin_n;TgcCoin_nCoins',title='TgcPrd_nCoins;Number of coincidences;Number of events', + path=coinPath,xbins=100,xmin=0,xmax=1000,opt='kAddBinsDynamically') + myGroup.defineHistogram('coin_bunch;TgcCoin_Timing',title='TgcCoin_Timing;Timing;Number of events', + path=coinPath,xbins=4,xmin=-1.5,xmax=1.5,xlabels=['Previous','Current','Next']) + acc = helper.result() result.merge(acc) return result @@ -111,25 +120,17 @@ if __name__=='__main__': from AthenaConfiguration.AllConfigFlags import ConfigFlags import glob - inputs = glob.glob('/afs/cern.ch/user/e/ebergeas/work/public/triggermonitoring/nightly_2020-03-01T2140/TrigP1Test_test_trigP1_v1PhysP1_T0Mon_build/AOD.pool.root') inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/tmp.ESD') # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/AOD*') # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/mc_scan_normal/*/tmp.ESD') - ConfigFlags.Input.Files = inputs ConfigFlags.Input.isMC = True ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput.root' - - #ConfigFlags.IOVDb.GlobalTag = "'CONDBR2-BLKPA-2017-08" ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" - # from AthenaCommon.Include import Include, IncludeError, include - # include("RecExCommon/RecExCommon_topOptions.py") - - ConfigFlags.lock() ConfigFlags.dump() @@ -141,16 +142,10 @@ if __name__=='__main__': cfg = MainServicesSerialCfg() cfg.merge(PoolReadCfg(ConfigFlags)) - # Configuration of the ATLAS Geo Model - from AtlasGeoModel.AtlasGeoModelConfig import AtlasGeometryCfg - geoCfg = AtlasGeometryCfg(ConfigFlags) - cfg.merge(geoCfg) - tgcRawDataMonitorAcc = TgcRawDataMonitoringConfig(ConfigFlags) tgcRawDataMonitorAcc.OutputLevel = DEBUG cfg.merge(tgcRawDataMonitorAcc) - # cfg.printConfig(withDetails=False) cfg.printConfig(withDetails=True, summariseProps = True) cfg.run() diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx index d050a95b95f9..28faff67e0f4 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "TgcRawDataMonitorAlgorithm.h" @@ -54,7 +54,6 @@ StatusCode TgcRawDataMonitorAlgorithm::initialize() { m_trigTagDefs.push_back(def); } - return AthMonitorAlgorithm::initialize(); } @@ -71,6 +70,12 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) variables.push_back(lb); variables.push_back(run); + + if( !m_anaMuonRoI.value()){ + fill(m_packageName,variables); + variables.clear(); + return StatusCode::SUCCESS; + } /* raw LVL1MuonRoIs distributions */ SG::ReadHandle<xAOD::MuonRoIContainer> rois(m_MuonRoIContainerKey, ctx); if(!rois.isValid()){ @@ -78,7 +83,6 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) return StatusCode::FAILURE; } - auto roi_eta = Monitored::Collection("roi_eta",*rois, []( const xAOD::MuonRoI* m ){return m->eta();}); variables.push_back( roi_eta ); auto roi_phi = Monitored::Collection("roi_phi",*rois, []( const xAOD::MuonRoI* m ){return m->phi();}); variables.push_back( roi_phi ); auto roi_phi_rpc = Monitored::Collection("roi_phi_rpc",*rois, []( const xAOD::MuonRoI* m ){return (m->getSource()==xAOD::MuonRoI::Barrel)?m->phi():-10;}); variables.push_back( roi_phi_rpc ); @@ -114,12 +118,18 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto thrmask14 = Monitored::Collection("thrmask14",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==14;});variables.push_back(thrmask14); auto thrmask15 = Monitored::Collection("thrmask15",*rois,[](const xAOD::MuonRoI* m){return m->getThrNumber()==15;});variables.push_back(thrmask15); + if( !m_anaOfflMuon.value() ){ + fill(m_packageName,variables); + variables.clear(); + return StatusCode::SUCCESS; + } + SG::ReadHandle<xAOD::MuonContainer> muons(m_MuonContainerKey, ctx); if(!muons.isValid()){ ATH_MSG_ERROR("evtStore() does not contain muon Collection with name "<< m_MuonContainerKey); return StatusCode::FAILURE; - } - + } + std::vector<MyMuon> mymuons; for(const auto& muon : *muons){ if(muon->muonType()!=xAOD::Muon::Combined)continue; @@ -190,7 +200,6 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) } } - auto muon_eta = Monitored::Collection("muon_eta",mymuons,[](const MyMuon& m){return (m.muon->pt()/1000>30)?m.muon->eta():-10;});variables.push_back(muon_eta); auto muon_phi = Monitored::Collection("muon_phi",mymuons,[](const MyMuon& m){return (m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi); auto muon_phi_rpc = Monitored::Collection("muon_phi_rpc",mymuons,[](const MyMuon& m){return (TMath::Abs(m.muon->eta())<1.05&&m.muon->pt()/1000>30)?m.muon->phi():-10;});variables.push_back(muon_phi_rpc); @@ -213,138 +222,142 @@ StatusCode TgcRawDataMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto muon_l1passThr14 = Monitored::Collection("muon_l1passThr14",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(14)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr14); auto muon_l1passThr15 = Monitored::Collection("muon_l1passThr15",mymuons,[](const MyMuon& m){return m.matchedL1ThrInclusive.find(15)!=m.matchedL1ThrInclusive.end();});variables.push_back(muon_l1passThr15); + + if(!m_anaTgcPrd.value()){ + fill(m_packageName,variables); + variables.clear(); + return StatusCode::SUCCESS; + } - if(m_anaTgcPrd.value()){ - SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrd(m_TgcPrepDataContainerKey, ctx); - if(!tgcPrd.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcPrepDataContainer with name "<< m_TgcPrepDataContainerKey); - return StatusCode::FAILURE; - } - const TgcIdHelper& tgcIdHelper = m_MuonIdHelperTool->tgcIdHelper(); - std::vector<TgcHit> tgcHits; - for(auto tgccnt : *tgcPrd){ - for(auto data : *tgccnt){ - TgcHit tgcHit; - int bunch = -10; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) bunch = -1; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) bunch = 0; - if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) bunch = +1; - const MuonGM::TgcReadoutElement* element = data->detectorElement(); - const Identifier id = data->identify(); - const int gasGap = tgcIdHelper.gasGap(id); - const int channel = tgcIdHelper.channel(id); - const bool isStrip = tgcIdHelper.isStrip(id); - const Amg::Vector3D& pos = isStrip ? element->stripPos(gasGap, channel) : element->gangPos(gasGap, channel); - tgcHit.x = pos[0]; - tgcHit.y = pos[1]; - tgcHit.z = pos[2]; - if (isStrip) { - tgcHit.shortWidth = element->stripShortWidth(gasGap, channel); - tgcHit.longWidth = element->stripLongWidth(gasGap, channel); - tgcHit.length = element->stripLength(gasGap, channel); - } else { - tgcHit.shortWidth = element->gangShortWidth(gasGap, channel); - tgcHit.longWidth = element->gangLongWidth(gasGap, channel); - tgcHit.length = element->gangLength(gasGap, channel); - } - tgcHit.isStrip = tgcIdHelper.isStrip(id); - tgcHit.gasGap = tgcIdHelper.gasGap(id); - tgcHit.channel = tgcIdHelper.channel(id); - tgcHit.eta = tgcIdHelper.stationEta(id); - tgcHit.phi = tgcIdHelper.stationPhi(id); - tgcHit.station = tgcIdHelper.stationName(id); - tgcHit.bunch = bunch; - tgcHits.push_back(tgcHit); + + SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrd(m_TgcPrepDataContainerKey, ctx); + if(!tgcPrd.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcPrepDataContainer with name "<< m_TgcPrepDataContainerKey); + return StatusCode::FAILURE; + } + const TgcIdHelper& tgcIdHelper = m_MuonIdHelperTool->tgcIdHelper(); + std::vector<TgcHit> tgcHits; + for(auto tgccnt : *tgcPrd){ + for(auto data : *tgccnt){ + TgcHit tgcHit; + int bunch = -10; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) bunch = -1; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) bunch = 0; + if ((data->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) bunch = +1; + const MuonGM::TgcReadoutElement* element = data->detectorElement(); + const Identifier id = data->identify(); + const int gasGap = tgcIdHelper.gasGap(id); + const int channel = tgcIdHelper.channel(id); + const bool isStrip = tgcIdHelper.isStrip(id); + const Amg::Vector3D& pos = isStrip ? element->stripPos(gasGap, channel) : element->gangPos(gasGap, channel); + tgcHit.x = pos[0]; + tgcHit.y = pos[1]; + tgcHit.z = pos[2]; + if (isStrip) { + tgcHit.shortWidth = element->stripShortWidth(gasGap, channel); + tgcHit.longWidth = element->stripLongWidth(gasGap, channel); + tgcHit.length = element->stripLength(gasGap, channel); + } else { + tgcHit.shortWidth = element->gangShortWidth(gasGap, channel); + tgcHit.longWidth = element->gangLongWidth(gasGap, channel); + tgcHit.length = element->gangLength(gasGap, channel); } + tgcHit.isStrip = tgcIdHelper.isStrip(id); + tgcHit.gasGap = tgcIdHelper.gasGap(id); + tgcHit.channel = tgcIdHelper.channel(id); + tgcHit.eta = tgcIdHelper.stationEta(id); + tgcHit.phi = tgcIdHelper.stationPhi(id); + tgcHit.station = tgcIdHelper.stationName(id); + tgcHit.bunch = bunch; + tgcHits.push_back(tgcHit); } - auto hit_n = Monitored::Scalar<int>("hit_n",tgcHits.size());variables.push_back(hit_n); - auto hit_bunch = Monitored::Collection("hit_bunch",tgcHits,[](const TgcHit& m){return m.bunch;});variables.push_back(hit_bunch); - auto hit_sideA = Monitored::Collection("hit_sideA",tgcHits,[](const TgcHit& m){return m.z>0;});variables.push_back(hit_sideA); - auto hit_sideC = Monitored::Collection("hit_sideC",tgcHits,[](const TgcHit& m){return m.z<0;});variables.push_back(hit_sideC); } + + auto hit_n = Monitored::Scalar<int>("hit_n",tgcHits.size());variables.push_back(hit_n); + auto hit_bunch = Monitored::Collection("hit_bunch",tgcHits,[](const TgcHit& m){return m.bunch;});variables.push_back(hit_bunch); + auto hit_sideA = Monitored::Collection("hit_sideA",tgcHits,[](const TgcHit& m){return m.z>0;});variables.push_back(hit_sideA); + auto hit_sideC = Monitored::Collection("hit_sideC",tgcHits,[](const TgcHit& m){return m.z<0;});variables.push_back(hit_sideC); - if(m_anaTgcCoin.value()){ - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinCurr(m_TgcCoinDataContainerCurrBCKey, ctx); - if(!tgcCoinCurr.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerCurrBCKey); - return StatusCode::FAILURE; - } - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinNext(m_TgcCoinDataContainerNextBCKey, ctx); - if(!tgcCoinNext.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerNextBCKey); - return StatusCode::FAILURE; - } - SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinPrev(m_TgcCoinDataContainerPrevBCKey, ctx); - if(!tgcCoinPrev.isValid()){ - ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerPrevBCKey); - return StatusCode::FAILURE; - } - std::map<int, SG::ReadHandle<Muon::TgcCoinDataContainer> > tgcCoin; - tgcCoin[0] = tgcCoinCurr; - tgcCoin[+1] = tgcCoinNext; - tgcCoin[-1] = tgcCoinPrev; - std::vector<TgcTrig> tgcTrigs; - for(auto thisCoin : tgcCoin){ - int bunch = thisCoin.first; - for(auto tgccnt : *(thisCoin.second)){ - for(auto data : *tgccnt){ - TgcTrig tgcTrig; - const int type = data->type(); - const Amg::Vector3D& posIn = data->globalposIn(); - tgcTrig.x_In = posIn[0]; - tgcTrig.y_In = posIn[1]; - tgcTrig.z_In = posIn[2]; - const Amg::Vector3D& posOut = data->globalposOut(); - tgcTrig.x_Out = posOut[0]; - tgcTrig.y_Out = posOut[1]; - tgcTrig.z_Out = posOut[2]; - tgcTrig.width_In = data->widthIn(); - tgcTrig.width_Out = data->widthOut(); - if (type == Muon::TgcCoinData::TYPE_SL) { - const Amg::MatrixX& matrix = data->errMat(); - tgcTrig.width_R = matrix(0,0); - tgcTrig.width_Phi = matrix(1,1); - } else { - tgcTrig.width_R = 0.; - tgcTrig.width_Phi = 0.; - } - tgcTrig.isAside = data->isAside(); - tgcTrig.isForward = data->isForward(); - tgcTrig.isStrip = data->isStrip(); - tgcTrig.isInner = data->isInner(); - tgcTrig.isPositiveDeltaR = data->isPositiveDeltaR(); - tgcTrig.type = type; - tgcTrig.trackletId = data->trackletId(); - tgcTrig.trackletIdStrip = data->trackletIdStrip(); - tgcTrig.phi = data->phi(); - tgcTrig.roi = data->roi(); - tgcTrig.pt = data->pt(); - tgcTrig.delta = data->delta(); - tgcTrig.sub = data->sub(); - tgcTrig.veto = data->veto(); - tgcTrig.bunch = bunch; - tgcTrig.inner = data->inner(); - tgcTrigs.push_back( tgcTrig ); + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinCurr(m_TgcCoinDataContainerCurrBCKey, ctx); + if(!tgcCoinCurr.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerCurrBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinNext(m_TgcCoinDataContainerNextBCKey, ctx); + if(!tgcCoinNext.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerNextBCKey); + return StatusCode::FAILURE; + } + SG::ReadHandle<Muon::TgcCoinDataContainer> tgcCoinPrev(m_TgcCoinDataContainerPrevBCKey, ctx); + if(!tgcCoinPrev.isValid()){ + ATH_MSG_ERROR("evtStore() does not contain TgcCoinDataContainer with name "<< m_TgcCoinDataContainerPrevBCKey); + return StatusCode::FAILURE; + } + std::map<int, SG::ReadHandle<Muon::TgcCoinDataContainer> > tgcCoin; + tgcCoin[0] = tgcCoinCurr; + tgcCoin[+1] = tgcCoinNext; + tgcCoin[-1] = tgcCoinPrev; + std::vector<TgcTrig> tgcTrigs; + for(auto thisCoin : tgcCoin){ + int bunch = thisCoin.first; + for(auto tgccnt : *(thisCoin.second)){ + for(auto data : *tgccnt){ + TgcTrig tgcTrig; + const int type = data->type(); + const Amg::Vector3D& posIn = data->globalposIn(); + tgcTrig.x_In = posIn[0]; + tgcTrig.y_In = posIn[1]; + tgcTrig.z_In = posIn[2]; + const Amg::Vector3D& posOut = data->globalposOut(); + tgcTrig.x_Out = posOut[0]; + tgcTrig.y_Out = posOut[1]; + tgcTrig.z_Out = posOut[2]; + tgcTrig.width_In = data->widthIn(); + tgcTrig.width_Out = data->widthOut(); + if (type == Muon::TgcCoinData::TYPE_SL) { + const Amg::MatrixX& matrix = data->errMat(); + tgcTrig.width_R = matrix(0,0); + tgcTrig.width_Phi = matrix(1,1); + } else { + tgcTrig.width_R = 0.; + tgcTrig.width_Phi = 0.; } + tgcTrig.isAside = data->isAside(); + tgcTrig.isForward = data->isForward(); + tgcTrig.isStrip = data->isStrip(); + tgcTrig.isInner = data->isInner(); + tgcTrig.isPositiveDeltaR = data->isPositiveDeltaR(); + tgcTrig.type = type; + tgcTrig.trackletId = data->trackletId(); + tgcTrig.trackletIdStrip = data->trackletIdStrip(); + tgcTrig.phi = data->phi(); + tgcTrig.roi = data->roi(); + tgcTrig.pt = data->pt(); + tgcTrig.delta = data->delta(); + tgcTrig.sub = data->sub(); + tgcTrig.veto = data->veto(); + tgcTrig.bunch = bunch; + tgcTrig.inner = data->inner(); + tgcTrigs.push_back( tgcTrig ); } } } - - - - fill(m_packageName,variables); - variables.clear(); - // if( !m_TagAndProbe.value() ) return StatusCode::SUCCESS; + auto coin_n = Monitored::Scalar<int>("coin_n",tgcTrigs.size());variables.push_back(coin_n); + auto coin_bunch = Monitored::Collection("coin_bunch",tgcTrigs,[](const TgcTrig& m){return m.bunch;});variables.push_back(coin_bunch); + auto coin_sideA = Monitored::Collection("coin_sideA",tgcTrigs,[](const TgcTrig& m){return m.isAside==1;});variables.push_back(coin_sideA); + auto coin_sideC = Monitored::Collection("coin_sideC",tgcTrigs,[](const TgcTrig& m){return m.isAside!=1;});variables.push_back(coin_sideC); - + fill(m_packageName,variables); + variables.clear(); return StatusCode::SUCCESS; } /////////////////////////////////////////////////////////////// StatusCode TgcRawDataMonitorAlgorithm::triggerMatching(const xAOD::Muon* offline_muon, const std::vector<TagDef>& list_of_triggers ) const { + if( !m_TagAndProbe.value() )return StatusCode::SUCCESS; TVector3 muonvec; muonvec.SetPtEtaPhi(offline_muon->pt(),offline_muon->eta(),offline_muon->phi()); for(auto tagTrig : list_of_triggers ){ if( !getTrigDecisionTool()->isPassed( tagTrig.eventTrig.Data() ) ) return StatusCode::FAILURE; @@ -354,10 +367,10 @@ StatusCode TgcRawDataMonitorAlgorithm::triggerMatching(const xAOD::Muon* offline auto trigmuon_link = aaa.link; auto trigmuon = *trigmuon_link; TVector3 trigvec; trigvec.SetPtEtaPhi(trigmuon->pt(),trigmuon->eta(),trigmuon->phi()); - if( trigvec.DeltaR( muonvec ) < 0.005 ) return StatusCode::SUCCESS; + if( trigvec.DeltaR( muonvec ) < m_trigMatchWindow.value() ) return StatusCode::SUCCESS; } } - return StatusCode::SUCCESS; + return StatusCode::FAILURE; } /////////////////////////////////////////////////////////////// void TgcRawDataMonitorAlgorithm::extrapolate(const xAOD::Muon* muon, MyMuon& mymuon) const diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h index 1c8fa3ed2ee9..01962b0daade 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataMonitorAlgorithm.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TGCRAWDATAMONITORING_TGCRAWDATAMONITORALGORITHM_H @@ -13,28 +13,8 @@ #include "MuonPrepRawData/MuonPrepDataContainer.h" #include "MuonTrigCoinData/TgcCoinDataContainer.h" #include "MuonIdHelpers/MuonIdHelperTool.h" -/* #include "MuonReadoutGeometry/MuonDetectorManager.h" */ #include "MuonReadoutGeometry/TgcReadoutElement.h" - -/* for track extrapolator */ -/* #include "GaudiKernel/ToolHandle.h" */ -/* #include "GaudiKernel/ServiceHandle.h" */ -/* #include "GaudiKernel/IAlgTool.h" */ -/* #include <string> */ -/* #include "xAODMuon/MuonContainer.h" */ -/* #include "AthenaKernel/errorcheck.h" */ -/* #include "TrkTrack/TrackStateOnSurface.h" */ - #include "TrkExInterfaces/IExtrapolator.h" -/* #include "CLHEP/Vector/ThreeVector.h" */ - -/* namespace Rec { class TrackParticle; } */ -/* namespace Trk { class IExtrapolator; } */ -/* namespace Trk { class TrackStateOnSurface; } */ -/* namespace CLHEP { class Hep2Vector; } */ -/* namespace CLHEP { class Hep3Vector; } */ - - class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { public: @@ -118,16 +98,13 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { ToolHandle<Muon::MuonIdHelperTool> m_MuonIdHelperTool{this, "MuonIdHelperTool", "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + StringProperty m_packageName{this,"PackageName","TgcRawDataMonitor","group name for histograming"}; StringProperty m_trigTagList{this,"TagTrigList","HLT_mu26_ivarmedium_L1MU20","list of triggers to be used for trigger matching"}; - BooleanProperty m_TagAndProbe{this,"TagAndProbe",false,"switch to perform tag-and-probe method"}; - - BooleanProperty m_anaTgcPrd{this,"AnaTgcPrd",false,"switch to perform analysis on TGC PRD"}; - BooleanProperty m_anaTgcCoin{this,"AnaTgcCoin",false,"switch to perform analysis on TGC Coin"}; + BooleanProperty m_TagAndProbe{this,"TagAndProbe",true,"switch to perform tag-and-probe method"}; + BooleanProperty m_anaTgcPrd{this,"AnaTgcPrd",false,"switch to perform analysis on TGC PRD/Coin"}; BooleanProperty m_anaOfflMuon{this,"AnaOfflMuon",true,"switch to perform analysis on xAOD::Muon"}; BooleanProperty m_anaMuonRoI{this,"AnaMuonRoI",true,"switch to perform analysis on xAOD::LVL1MuonRoI"}; - StringProperty m_MuonEFContainerName{this,"MuonEFContainerName","HLT_MuonsCB_RoI","HLT RoI-based muon track container"}; - DoubleProperty m_trigMatchWindow{this,"TrigMatchingWindow",0.005,"Window size in R for trigger matching"}; DoubleProperty m_l1trigMatchWindow1{this,"L1TrigMatchingWindow1",0.15,"Window size in R for L1 trigger matching: param 1"}; DoubleProperty m_l1trigMatchWindow2{this,"L1TrigMatchingWindow2",0.3,"Window size in R for L1 trigger matching: param 2"}; @@ -135,18 +112,14 @@ class TgcRawDataMonitorAlgorithm : public AthMonitorAlgorithm { DoubleProperty m_l1trigMatchWindow4{this,"L1TrigMatchingWindow4",0.36,"Window size in R for L1 trigger matching: param 4"}; DoubleProperty m_l1trigMatchWindow5{this,"L1TrigMatchingWindow5",-0.0016,"Window size in R for L1 trigger matching: param 5"}; DoubleProperty m_isolationWindow{this,"IsolationWindow",0.1,"Window size in R for isolation with other muons"}; - StringProperty m_packageName{this,"PackageName","TgcRawDataMonitor","group name for histograming"}; - DoubleProperty m_M1_Z{this,"M1_Z",13605.0,"z-position of TGC M1-station in mm for track extrapolate"}; DoubleProperty m_M2_Z{this,"M2_Z",14860.0,"z-position of TGC M2-station in mm for track extrapolate"}; DoubleProperty m_M3_Z{this,"M3_Z",15280.0,"z-position of TGC M3-station in mm for track extrapolate"}; DoubleProperty m_EI_Z{this,"EI_Z",7425.0,"z-position of TGC EI-station in mm for track extrapolate"}; DoubleProperty m_FI_Z{this,"FI_Z",7030.0,"z-position of TGC FI-station in mm for track extrapolate"}; - DoubleProperty m_muonMass{this,"MuonMass",105.6583755,"muon invariant mass in MeV"}; DoubleProperty m_zMass{this,"ZMass",91187.6,"muon invariant mass in MeV"}; DoubleProperty m_zMassWindow{this,"ZMassWindow",10000,"muon invariant mass half-window in MeV"}; - DoubleProperty m_endcapPivotPlaneMinimumRadius{this,"endcapPivotPlaneMinimumRadius",0.,"minimum radius of pivot plane in endcap region"}; DoubleProperty m_endcapPivotPlaneMaximumRadius{this,"endcapPivotPlaneMaximumRadius", 11977.,"maximum radius of pivot plane in endcap region"}; DoubleProperty m_barrelPivotPlaneHalfLength{this,"barrelPivotPlaneHalfLength", 9500.,"half length of pivot plane in barrel region"}; -- GitLab From 3e4827d6bb68fd617169fc047bf8534ac016872e Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Fri, 12 Jun 2020 14:49:15 +0200 Subject: [PATCH 5/6] use AllBCs TGC hit PRD --- .../TgcRawDataMonitoring/TgcRawDataValAlg.h | 6 ++--- .../share/TgcRaw_MonitoringOptions.py | 3 +-- .../src/TgcRawDataValAlg.cxx | 23 ++++--------------- .../src/TgcRawDataValAlg_ReadContainer.cxx | 6 ++++- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataValAlg.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataValAlg.h index d10309fa3092..3195dd3a1b6e 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataValAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataMonitoring/TgcRawDataValAlg.h @@ -66,9 +66,7 @@ private: std::string m_generic_path_tgcmonitoring; // Keys and Locations for retrieving collections - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepDataContainerName{this,"TgcPrepDataContainer","TGC_Measurements","current BC TGC PRD"}; - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepDataPreviousContainerName{this,"TgcPrepDataPreviousContainer","TGC_MeasurementsPriorBC","previous BC TGC PRD"}; - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepDataNextContainerName{this,"TgcPrepDataNextContainer","TGC_MeasurementsNextBC","next BC TGC PRD"}; + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrepDataContainerName{this,"TgcPrepDataContainerAllBCs","TGC_MeasurementsAllBCs","TGC PRD"}; SG::ReadHandleKey<Muon::TgcCoinDataContainer> m_outputCoinCollectionLocation{this,"OutputCoinCollection","TrigT1CoinDataCollection","TGC T1 coincidences"}; SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this,"EventInfo","EventInfo","EventInfo"}; @@ -116,7 +114,7 @@ private: std::vector<double> m_hitPosPhi[2][2]; //[ac][ws] // read Tgc PRD Container - void readTgcPrepDataContainer(const Muon::TgcPrepDataContainer *tgc_prep_container, int pcn); + void readTgcPrepDataContainer(const Muon::TgcPrepDataContainer *tgc_prep_container, int pcn = -1); /////////////////////////////////////////////////////////////////////////// diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/share/TgcRaw_MonitoringOptions.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/share/TgcRaw_MonitoringOptions.py index 4aef14a00236..9cdb7a6ee1f7 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/share/TgcRaw_MonitoringOptions.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/share/TgcRaw_MonitoringOptions.py @@ -17,8 +17,7 @@ tgcLv1RawMonMan = AthenaMonManager(name="TgcLv1RawMonManager", OutputLevel = muonOutputLevel) ############## TgcRawDataValAlg ############# from TgcRawDataMonitoring.TgcRawDataMonitoringConf import TgcRawDataValAlg -tgcRawDataValAlg = TgcRawDataValAlg(name='tgcRawDataValAlg', - TgcPrepDataContainer="TGC_Measurements") +tgcRawDataValAlg = TgcRawDataValAlg(name='tgcRawDataValAlg') #ToolSvc += tgcRawDataValAlg tgcRawMonMan.AthenaMonTools += [ tgcRawDataValAlg ] topSequence += tgcRawMonMan diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg.cxx index e5317518bae0..ed663040d57c 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg.cxx @@ -61,8 +61,6 @@ TgcRawDataValAlg::initialize(){ m_mon_profile=true; ATH_CHECK(m_tgcPrepDataContainerName.initialize()); - ATH_CHECK(m_tgcPrepDataPreviousContainerName.initialize()); - ATH_CHECK(m_tgcPrepDataNextContainerName.initialize()); ATH_CHECK(m_outputCoinCollectionLocation.initialize()); ATH_CHECK(m_eventInfo.initialize()); @@ -121,20 +119,9 @@ TgcRawDataValAlg::fillHistograms(){ ///////////////////////////////////// // Get TGC Hit PRD Containers - SG::ReadHandle<Muon::TgcPrepDataContainer> tgc_previous_prd_container(m_tgcPrepDataContainerName); - SG::ReadHandle<Muon::TgcPrepDataContainer> tgc_current_prd_container(m_tgcPrepDataPreviousContainerName); - SG::ReadHandle<Muon::TgcPrepDataContainer> tgc_next_prd_container(m_tgcPrepDataNextContainerName); - - // Previous - ATH_MSG_DEBUG( "****** tgc previous prd container size() : " << tgc_previous_prd_container->size() ); - - // Current - ATH_MSG_DEBUG( "****** tgc current prd container size() : " << tgc_current_prd_container->size() ); - - // Next - ATH_MSG_DEBUG( "****** tgc next prd container size() : " << tgc_next_prd_container->size() ); - - + SG::ReadHandle<Muon::TgcPrepDataContainer> tgc_prd_container(m_tgcPrepDataContainerName); + ATH_MSG_DEBUG( "****** tgc prd container size() : " << tgc_prd_container->size() ); + // Increment event counter m_nEvent++; ATH_MSG_DEBUG("event : " << m_nEvent ); @@ -144,9 +131,7 @@ TgcRawDataValAlg::fillHistograms(){ // Get Data from TGC Containers clearVectorsArrays(); // fill vectors and arrays from TgcPrepData - readTgcPrepDataContainer(tgc_previous_prd_container.cptr(), PREV); - readTgcPrepDataContainer( tgc_current_prd_container.cptr(), CURR); - readTgcPrepDataContainer( tgc_next_prd_container.cptr(), NEXT); + readTgcPrepDataContainer(tgc_prd_container.cptr()); /////////////////////////////////////////////////////////////////////////// diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg_ReadContainer.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg_ReadContainer.cxx index 360855306553..c07746b8fa79 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg_ReadContainer.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/src/TgcRawDataValAlg_ReadContainer.cxx @@ -75,7 +75,6 @@ TgcRawDataValAlg::readTgcPrepDataContainer(const Muon::TgcPrepDataContainer* tgc /////////////////////////////////////////////////////////////////////////// // Loop over TgcPrepDataContainer if(pcn!=TOTA){ - // MuonDetectorManager from the conditions store SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); @@ -130,6 +129,11 @@ TgcRawDataValAlg::readTgcPrepDataContainer(const Muon::TgcPrepDataContainer* tgc for(Muon::TgcPrepDataCollection::const_iterator collectionIt=(*containerIt)->begin(); collectionIt!= collection_end; ++collectionIt){ + if(pcn<0){ + if (((*collectionIt)->getBcBitMap()&Muon::TgcPrepData::BCBIT_PREVIOUS)==Muon::TgcPrepData::BCBIT_PREVIOUS) pcn=PREV; + if (((*collectionIt)->getBcBitMap()&Muon::TgcPrepData::BCBIT_CURRENT)==Muon::TgcPrepData::BCBIT_CURRENT) pcn=CURR; + if (((*collectionIt)->getBcBitMap()&Muon::TgcPrepData::BCBIT_NEXT)==Muon::TgcPrepData::BCBIT_NEXT) pcn=NEXT; + } // Increment Prd Counter if(pcn==CURR)m_nPrd++; -- GitLab From 9647d45dc69ef6c970ae9c230130f3c736a4b6bc Mon Sep 17 00:00:00 2001 From: Masato Aoki <masato.aoki@cern.ch> Date: Fri, 10 Jul 2020 15:04:48 +0200 Subject: [PATCH 6/6] clean-up config to avoid a crash when run with Run3DQTestingDriver.py --- .../python/TgcRawDataMonitorAlgorithm.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py index 265d2c9fee9e..3de766bd0c59 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/TgcRawDataMonitoring/python/TgcRawDataMonitorAlgorithm.py @@ -14,18 +14,6 @@ def TgcRawDataMonitoringConfig(inputFlags): from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator result = ComponentAccumulator() - from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg - result.merge(MagneticFieldSvcCfg(inputFlags)) - - from AtlasGeoModel.AtlasGeoModelConfig import AtlasGeometryCfg - result.merge(AtlasGeometryCfg(inputFlags)) - - from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg - trackGeomCfg = TrackingGeometrySvcCfg(inputFlags) - geom_svc = trackGeomCfg.getPrimary() - geom_svc.GeometryBuilder.Compactify = False ######## To avoid crash ######## - result.merge(trackGeomCfg) - from AthenaMonitoring import AthMonitorCfgHelper helper = AthMonitorCfgHelper(inputFlags,'TgcRawDataMonitorCfg') @@ -121,9 +109,7 @@ if __name__=='__main__': from AthenaConfiguration.AllConfigFlags import ConfigFlags import glob - inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/tmp.ESD') - # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/run_mc_zmumu_normal/*/AOD*') - # inputs = glob.glob('/data01/masato/L1MuonDevRun3/athenaMT/mc_scan_normal/*/tmp.ESD') + inputs = glob.glob('/data03/mySamples/run_mc_zmumu/*/tmp.ESD') ConfigFlags.Input.Files = inputs ConfigFlags.Input.isMC = True @@ -146,6 +132,13 @@ if __name__=='__main__': tgcRawDataMonitorAcc.OutputLevel = DEBUG cfg.merge(tgcRawDataMonitorAcc) + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + from AtlasGeoModel.AtlasGeoModelConfig import AtlasGeometryCfg + from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg + cfg.merge(MagneticFieldSvcCfg(ConfigFlags)) + cfg.merge(AtlasGeometryCfg(ConfigFlags)) + cfg.merge(TrackingGeometrySvcCfg(ConfigFlags)) + cfg.printConfig(withDetails=True, summariseProps = True) cfg.run() -- GitLab