From 59538f06a6f51aa0b90ed95c9685f46a3ac74581 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 17 Jul 2018 12:45:28 +0900 Subject: [PATCH 01/50] update for 2018 --- MuonAnalyser/test/runSliceTestAnalysis.py | 2 +- MuonAnalyser/test/step3_RAW2DIGI_L1Reco_RECO.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 2150ecd87c4..8bedeb4621a 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -22,7 +22,7 @@ process.source.skipEvents = cms.untracked.uint32(17601) #process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') +process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_313.root') #fname = 'singleMuon.txt' #f = open(fname) diff --git a/MuonAnalyser/test/step3_RAW2DIGI_L1Reco_RECO.py b/MuonAnalyser/test/step3_RAW2DIGI_L1Reco_RECO.py index 933721f86b6..b0368a661bb 100644 --- a/MuonAnalyser/test/step3_RAW2DIGI_L1Reco_RECO.py +++ b/MuonAnalyser/test/step3_RAW2DIGI_L1Reco_RECO.py @@ -2,12 +2,12 @@ # using: # Revision: 1.19 # Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2018 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2018 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('reRECO',eras.Run2_2017,eras.run3_GEM) +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -26,7 +26,7 @@ # Input source process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + fileNames = cms.untracked.vstring('file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/337/00000/EEE24158-BE82-E811-8419-FA163E00EF28.root'), secondaryFileNames = cms.untracked.vstring() ) #import FWCore.PythonUtilities.LumiList as LumiList @@ -58,9 +58,9 @@ # Additional output definition -# Other statements +# Other statements 101X_dataRun2_Prompt_v11 from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v11', '') # Path and EndPath definitions process.raw2digi_step = cms.Path(process.RawToDigi) @@ -77,10 +77,10 @@ # customisation of the process. # Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2018 -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -process = customisePostEra_Run2_2017(process) +#call to customisation function customisePostEra_Run2_2018 imported from Configuration.DataProcessing.RecoTLR +process = customisePostEra_Run2_2018(process) # End of customisation functions #do not add changes to your config after this point (unless you know what you are doing) From 2610bf8a2e73443d6d7ba724a4fbbf200b488239 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Thu, 19 Jul 2018 22:43:54 +0900 Subject: [PATCH 02/50] add lumiScalers --- MuonAnalyser/plugins/BuildFile.xml | 1 + MuonAnalyser/plugins/SliceTestAnalysis.cc | 28 +++++++++++++++++-- MuonAnalyser/test/runSliceTestAnalysis.py | 1 + MuonAnalyser/test/runSliceTestAnalysis2018.py | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/MuonAnalyser/plugins/BuildFile.xml b/MuonAnalyser/plugins/BuildFile.xml index b5754384aa2..92d339873c0 100644 --- a/MuonAnalyser/plugins/BuildFile.xml +++ b/MuonAnalyser/plugins/BuildFile.xml @@ -12,6 +12,7 @@ + diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 99abb2be707..545a3fc5319 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -24,6 +24,7 @@ #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" #include "MagneticField/Engine/interface/MagneticField.h" +#include "DataFormats/Scalers/interface/LumiScalers.h" #include "DataFormats/PatCandidates/interface/Muon.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -35,6 +36,7 @@ #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" @@ -68,6 +70,7 @@ class SliceTestAnalysis : public edm::EDAnalyzer { edm::EDGetTokenT gemRecHits_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; + edm::EDGetTokenT lumiScalers_; edm::Service fs; MuonServiceProxy* theService_; @@ -77,7 +80,9 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; + TH2D* h_allStrips_area[36][2]; TH2D* h_globalPosOnGem; + TH1D* h_instLumi; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; TH1D* h_hitEta[36][2]; @@ -106,11 +111,13 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); muons_ = consumes >(iConfig.getParameter("muons")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); + lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); theService_ = new MuonServiceProxy(serviceParameters); h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); + h_instLumi=fs->make(Form("instLumi"),"instLumi",20000,0,2000000000); h_bxtotal=fs->make(Form("bx"),"bx",31,-15,15); h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); @@ -150,11 +157,17 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + h_allStrips_area[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i area",ichamber, ilayer),"allStrips",384,1,385,8,0.5,8.5); + h_allStrips_area[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); + h_allStrips_area[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber, ilayer),"inEta",8,0.5,8.5); h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber, ilayer),"hitEta",8,0.5,8.5); h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber, ilayer),"trkEta",8,0.5,8.5); } } + + } SliceTestAnalysis::~SliceTestAnalysis() @@ -183,7 +196,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::ESHandle hGeom; iSetup.get().get(hGeom); const GEMGeometry* GEMGeometry_ = &*hGeom; - + iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); // iSetup.get().get("SteppingHelixPropagatorAny",propagator_); // iSetup.get().get(bField_); @@ -200,6 +213,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet // std::cout << "vertex->size() " << vertexCollection->size() < lumiScalers; + iEvent.getByToken( lumiScalers_, lumiScalers ); + Handle > muons; iEvent.getByToken(muons_, muons); //std::cout << "muons->size() " << muons->size() <size() " << gemRecHits->size() <at(0)).instantLumi(); + h_instLumi->Fill(instLumi); for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); + const int nstrips(roll->nstrips()); + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + double trStripArea = (roll->pitch()) * striplength; + double trArea = trStripArea * nstrips; + //std::cout << "rId " << rId <get(rId); auto gemRecHit = recHitsRange.first; @@ -358,6 +381,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll()); + h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea)); } b_firstStrip = hit->firstClusterStrip(); diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 7c6c61668ef..4920ea4d33a 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -40,5 +40,6 @@ gemRecHits = cms.InputTag("gemRecHits"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), ) process.p = cms.Path(process.SliceTestAnalysis) diff --git a/MuonAnalyser/test/runSliceTestAnalysis2018.py b/MuonAnalyser/test/runSliceTestAnalysis2018.py index 9f46c9ace38..1a5a94c276e 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis2018.py +++ b/MuonAnalyser/test/runSliceTestAnalysis2018.py @@ -56,5 +56,6 @@ gemRecHits = cms.InputTag("gemRecHits"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), ) process.p = cms.Path(process.SliceTestAnalysis) From 826693fd74530474334c142c30440e8f88c798ad Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 20 Jul 2018 02:27:03 +0900 Subject: [PATCH 03/50] add instant luminosity info --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 545a3fc5319..4c53b6a5bde 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -83,6 +83,8 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_allStrips_area[36][2]; TH2D* h_globalPosOnGem; TH1D* h_instLumi; + TH1D* h_time; + TH1D* h_pileup; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; TH1D* h_hitEta[36][2]; @@ -117,7 +119,9 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_instLumi=fs->make(Form("instLumi"),"instLumi",20000,0,2000000000); + h_instLumi=fs->make(Form("instLumi"),"instLumi",100,0,10); + h_time=fs->make(Form("time"),"time",20000,0,2); + h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); h_bxtotal=fs->make(Form("bx"),"bx",31,-15,15); h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); @@ -357,8 +361,10 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet // std::cout << "gemRecHits->size() " << gemRecHits->size() <at(0)).instantLumi(); + auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; + auto pileup = (lumiScalers->at(0)).pileup(); h_instLumi->Fill(instLumi); + h_pileup->Fill(pileup); for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); @@ -381,7 +387,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll()); - h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea)); + h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea*instLumi)); } b_firstStrip = hit->firstClusterStrip(); From bc92587177a295ebcfd0ad5b24bc454010144952 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Mon, 23 Jul 2018 16:08:29 +0900 Subject: [PATCH 04/50] add digicollection --- MuonAnalyser/plugins/BuildFile.xml | 1 + MuonAnalyser/plugins/SliceTestAnalysis.cc | 6 ++++++ MuonAnalyser/test/runSliceTestAnalysis2018.py | 1 + 3 files changed, 8 insertions(+) diff --git a/MuonAnalyser/plugins/BuildFile.xml b/MuonAnalyser/plugins/BuildFile.xml index 92d339873c0..6d0c093a814 100644 --- a/MuonAnalyser/plugins/BuildFile.xml +++ b/MuonAnalyser/plugins/BuildFile.xml @@ -11,6 +11,7 @@ + diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 4c53b6a5bde..87fc548d056 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -30,6 +30,7 @@ #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" @@ -68,6 +69,7 @@ class SliceTestAnalysis : public edm::EDAnalyzer { // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT gemDigis_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; @@ -111,6 +113,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : nGEMTrackWithMuon(0) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + gemDigis_ = consumes(iConfig.getParameter("gemDigis")); muons_ = consumes >(iConfig.getParameter("muons")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); @@ -210,6 +213,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); + edm::Handle gemDigis; + iEvent.getByToken(gemDigis_, gemDigis); + edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { diff --git a/MuonAnalyser/test/runSliceTestAnalysis2018.py b/MuonAnalyser/test/runSliceTestAnalysis2018.py index 1a5a94c276e..def258daa59 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis2018.py +++ b/MuonAnalyser/test/runSliceTestAnalysis2018.py @@ -54,6 +54,7 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), + gemDigis = cms.InputTag("muonGEMDigis"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), From 75ce5424c968e62fa935386edd5d0354c7a764ab Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 24 Jul 2018 15:53:39 +0900 Subject: [PATCH 05/50] add nBxing info to output --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 51 +++++++++++++++++++---- MuonAnalyser/test/runSliceTestAnalysis.py | 1 + 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index bd9185fecb4..d343dcad44e 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -97,10 +97,11 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_hit; int b_run, b_lumi, b_event; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality; - float b_x, b_y, b_z; + float b_x, b_y, b_z, b_area; int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; - int b_nMuons, b_nMuonsWithGEMHit; + int b_nMuons, b_nMuonsWithGEMHit, b_nBx; + float b_instLumi; int b_nGEMHits; @@ -127,7 +128,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : h_instLumi=fs->make(Form("instLumi"),"instLumi",100,0,10); h_time=fs->make(Form("time"),"time",20000,0,2); h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); - h_bxtotal=fs->make(Form("bx"),"bx",31,-15,15); + h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); @@ -140,6 +141,8 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); + t_event->Branch("nBx", &b_nBx, "nBx/I"); + t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); h_res_x=fs->make(Form("res_x"),"res_x",100,-50,50); h_res_y=fs->make(Form("res_y"),"res_y",100,-50,50); @@ -159,6 +162,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_hit->Branch("x", &b_x, "x/F"); t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); + t_hit->Branch("area", &b_area, "area/F"); for (int ichamber=0; ichamber<36;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { @@ -199,7 +203,10 @@ void SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { nEvents++; - + + int maxBx = 0; + int minBx = 0; + b_nMuons = 0; b_nMuonsWithGEMHit = 0; b_nGEMHits = 0; @@ -388,6 +395,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; auto pileup = (lumiScalers->at(0)).pileup(); h_instLumi->Fill(instLumi); + b_instLumi = instLumi; h_pileup->Fill(pileup); for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { @@ -404,15 +412,16 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet auto gemRecHit = recHitsRange.first; for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); +// h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); h_firstStrip[rId.chamber()][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; - h_allStrips[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll()); - h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea*instLumi)); +// h_allStrips[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll()); +// h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea*instLumi)); } + b_area = trArea; b_firstStrip = hit->firstClusterStrip(); b_nStrips = hit->clusterSize(); @@ -447,6 +456,34 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } } + + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + + const int nstrips(roll->nstrips()); + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + double trStripArea = (roll->pitch()) * striplength; + double trArea = trStripArea * nstrips; + + auto digisRange = gemDigis->get(rId); + auto gemDigi = digisRange.first; + for (auto hit = gemDigi; hit != digisRange.second; ++hit) { + + h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); + int bx = hit->bx(); + if (bx < minBx) minBx = bx; + if (bx > maxBx) maxBx = bx; + //h_bxtotal->Fill(hit->bx()); + h_allStrips[rId.chamber()][rId.layer()-1]->Fill(hit->strip(), rId.roll()); + h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(hit->strip(), rId.roll(), 1/(trArea*instLumi)); + + } + } + } + + b_nBx = (maxBx - minBx + 1); h_totalStrips->Fill(totalStrips); t_event->Fill(); diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 4920ea4d33a..5475719838e 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -38,6 +38,7 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), + gemDigis = cms.InputTag("muonGEMDigis"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), From 87d873b762ac8ddc11b2f1e86b2eaa835a9e442a Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 3 Aug 2018 17:37:50 +0900 Subject: [PATCH 06/50] update --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 112 +++++++++++++----- MuonAnalyser/test/runSliceTestAnalysis.py | 1 - MuonAnalyser/test/runSliceTestAnalysis2018.py | 1 + 3 files changed, 83 insertions(+), 31 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index d343dcad44e..d7ba334cf96 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -75,6 +75,8 @@ class SliceTestAnalysis : public edm::EDAnalyzer { edm::EDGetTokenT lumiScalers_; edm::Service fs; + int runNum_; + MuonServiceProxy* theService_; edm::ESHandle propagator_; edm::ESHandle ttrackBuilder_; @@ -82,7 +84,8 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; - TH2D* h_allStrips_area[36][2]; + TH2D* h_chInfo[36][2]; + TH2D* h_globalPosOnGem; TH1D* h_instLumi; TH1D* h_time; @@ -96,14 +99,19 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_hit; int b_run, b_lumi, b_event; + ULong64_t b_runTime; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality; - float b_x, b_y, b_z, b_area; + int b_detId; + float b_x, b_y, b_z; int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; int b_nMuons, b_nMuonsWithGEMHit, b_nBx; - float b_instLumi; + float b_instLumi, b_area, b_chArea; + + int b_nGEMHits, b_nDigis; - int b_nGEMHits; + TTree *t_digi; + int b_strip; TTree *t_run; TTree *t_event; @@ -122,6 +130,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); theService_ = new MuonServiceProxy(serviceParameters); + runNum_ = iConfig.getParameter("runNum"); h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); @@ -134,11 +143,13 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_run = fs->make("Run", "Run"); t_run->Branch("run", &b_run, "run/I"); + t_run->Branch("runTime", &b_runTime, "runTime/l"); t_event = fs->make("Event", "Event"); t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); + t_event->Branch("nDigis", &b_nDigis, "nDigis/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); t_event->Branch("nBx", &b_nBx, "nBx/I"); @@ -157,31 +168,39 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); t_hit->Branch("chamber", &b_chamber, "chamber/I"); t_hit->Branch("layer", &b_layer, "layer/I"); + t_hit->Branch("area", &b_area, "area/F"); + t_hit->Branch("chArea", &b_chArea, "chArea/F"); t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); t_hit->Branch("x", &b_x, "x/F"); t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); - t_hit->Branch("area", &b_area, "area/F"); + + t_digi = fs->make("Digi", "Digi"); + t_digi->Branch("run", &b_run, "run/I"); + t_digi->Branch("lumi", &b_lumi, "lumi/I"); + t_digi->Branch("strip", &b_strip, "strip/I"); + t_digi->Branch("chamber", &b_chamber, "chamber/I"); + t_digi->Branch("layer", &b_layer, "layer/I"); + t_digi->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + t_digi->Branch("area", &b_area, "area/F"); for (int ichamber=0; ichamber<36;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { for (int ilayer=0; ilayer<2;++ilayer) { - h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber, ilayer),"firstStrip",384,1,385,8,0.5,8.5); + h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber+1, ilayer+1),"firstStrip",384,1,385,8,0.5,8.5); h_firstStrip[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); h_firstStrip[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - h_allStrips[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i",ichamber, ilayer),"allStrips",384,1,385,8,0.5,8.5); + h_allStrips[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i",ichamber+1, ilayer+1),"allStrips",384,1,385,8,0.5,8.5); h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - h_allStrips_area[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i area",ichamber, ilayer),"allStrips",384,1,385,8,0.5,8.5); - h_allStrips_area[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_allStrips_area[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + h_chInfo[ichamber][ilayer] = fs->make(Form("chInfo ch %i lay %i", ichamber+1, ilayer+1), "1:detId 2:area", 2, 0.5, 2.5, 8, 0.5, 8.5); - h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber, ilayer),"inEta",8,0.5,8.5); - h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber, ilayer),"hitEta",8,0.5,8.5); - h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber, ilayer),"trkEta",8,0.5,8.5); + h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); + h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); + h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); } } @@ -202,6 +221,11 @@ SliceTestAnalysis::~SliceTestAnalysis() void SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + b_run = iEvent.run(); + b_lumi = iEvent.luminosityBlock(); + + if (b_run != runNum_) return; + nEvents++; int maxBx = 0; @@ -210,10 +234,8 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_nMuons = 0; b_nMuonsWithGEMHit = 0; b_nGEMHits = 0; + b_nDigis = 0; - b_run = iEvent.run(); - b_lumi = iEvent.luminosityBlock(); - edm::ESHandle hGeom; iSetup.get().get(hGeom); const GEMGeometry* GEMGeometry_ = &*hGeom; @@ -398,30 +420,51 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_instLumi = instLumi; h_pileup->Fill(pileup); for (auto ch : GEMGeometry_->chambers()) { + double chArea = 0; for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - const int nstrips(roll->nstrips()); const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); const float striplength(top_->stripLength()); double trStripArea = (roll->pitch()) * striplength; double trArea = trStripArea * nstrips; - + chArea += trArea; + } + b_chArea = chArea; + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + //std::cout << "rId " << rId <get(rId); auto gemRecHit = recHitsRange.first; + + const int nstrips(roll->nstrips()); + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + double trStripArea = (roll->pitch()) * striplength; + double trArea = trStripArea * nstrips; + + auto axis = h_chInfo[rId.chamber()-1][rId.layer()-1]->GetXaxis(); + auto idBin = axis->FindBin(1.); + auto areaBin = axis->FindBin(2.); + auto rollBin = h_chInfo[rId.chamber()-1][rId.layer()-1]->GetYaxis()->FindBin(rId.roll()); + h_chInfo[rId.chamber()-1][rId.layer()-1]->SetBinContent(areaBin, rollBin, trArea); + h_chInfo[rId.chamber()-1][rId.layer()-1]->SetBinContent(idBin, rollBin, rId.rawId()); + + b_area = trArea; + for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { -// h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); - h_firstStrip[rId.chamber()][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); +// h_hitEta[rId.chamber()-1][rId.layer()-1]->Fill(rId.roll()); + h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); + int bx = hit->BunchX(); + if (maxBx < bx) maxBx = bx; + if (minBx > bx) minBx = bx; for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; -// h_allStrips[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll()); -// h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(nstrip, rId.roll(), 1/(trArea*instLumi)); + h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); } - b_area = trArea; b_firstStrip = hit->firstClusterStrip(); b_nStrips = hit->clusterSize(); @@ -466,19 +509,26 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet const float striplength(top_->stripLength()); double trStripArea = (roll->pitch()) * striplength; double trArea = trStripArea * nstrips; - + + b_area = trArea; + auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; + + b_chamber = rId.chamber(); + b_layer = rId.layer(); + b_etaPartition = rId.roll(); + for (auto hit = gemDigi; hit != digisRange.second; ++hit) { - h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); + h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); int bx = hit->bx(); if (bx < minBx) minBx = bx; if (bx > maxBx) maxBx = bx; - //h_bxtotal->Fill(hit->bx()); - h_allStrips[rId.chamber()][rId.layer()-1]->Fill(hit->strip(), rId.roll()); - h_allStrips_area[rId.chamber()][rId.layer()-1]->Fill(hit->strip(), rId.roll(), 1/(trArea*instLumi)); - + //h_bxtotal->Fill(hit->bx()); + b_strip = hit->strip(); + b_nDigis++; + t_digi->Fill(); } } } @@ -494,6 +544,8 @@ void SliceTestAnalysis::endJob(){} void SliceTestAnalysis::beginRun(Run const& run, EventSetup const&){ b_run = run.run(); + if (b_run != runNum_) return; + b_runTime = run.endTime().value() - run.beginTime().value(); t_run->Fill(); } void SliceTestAnalysis::endRun(Run const&, EventSetup const&){} diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 5475719838e..4920ea4d33a 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -38,7 +38,6 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), - gemDigis = cms.InputTag("muonGEMDigis"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), diff --git a/MuonAnalyser/test/runSliceTestAnalysis2018.py b/MuonAnalyser/test/runSliceTestAnalysis2018.py index def258daa59..2cf199ffcf2 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis2018.py +++ b/MuonAnalyser/test/runSliceTestAnalysis2018.py @@ -58,5 +58,6 @@ muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), + runNum = cms.int32(319348), ) process.p = cms.Path(process.SliceTestAnalysis) From eebaf6f04431e91a4ed27ceb87a47c7c48827b81 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Thu, 16 Aug 2018 21:30:46 +0900 Subject: [PATCH 07/50] checkpoint --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 142 +++++------------- MuonAnalyser/test/runSliceTestAnalysis2018.py | 2 - 2 files changed, 39 insertions(+), 105 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index d7ba334cf96..346483d2273 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -69,14 +69,13 @@ class SliceTestAnalysis : public edm::EDAnalyzer { // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT cscRecHits_; edm::EDGetTokenT gemDigis_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; edm::Service fs; - int runNum_; - MuonServiceProxy* theService_; edm::ESHandle propagator_; edm::ESHandle ttrackBuilder_; @@ -84,11 +83,9 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; - TH2D* h_chInfo[36][2]; TH2D* h_globalPosOnGem; TH1D* h_instLumi; - TH1D* h_time; TH1D* h_pileup; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; @@ -99,19 +96,20 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_hit; int b_run, b_lumi, b_event; - ULong64_t b_runTime; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality; - int b_detId; float b_x, b_y, b_z; int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; int b_nMuons, b_nMuonsWithGEMHit, b_nBx; - float b_instLumi, b_area, b_chArea; + float b_instLumi; + float b_stripLength[2][8]; + float b_stripPitch[2][8]; + float b_area[2]; - int b_nGEMHits, b_nDigis; + int b_nGEMHits; - TTree *t_digi; - int b_strip; + TTree *t_setup; + int b_maxBx, b_minBx; TTree *t_run; TTree *t_event; @@ -121,21 +119,19 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : nEvents(0), nMuonTotal(0), nGEMFiducialMuon(0), - nGEMTrackWithMuon(0) + nGEMTrackWithMuon(0), + b_maxBx(0), b_minBx(0) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - gemDigis_ = consumes(iConfig.getParameter("gemDigis")); muons_ = consumes >(iConfig.getParameter("muons")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); theService_ = new MuonServiceProxy(serviceParameters); - runNum_ = iConfig.getParameter("runNum"); h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); h_instLumi=fs->make(Form("instLumi"),"instLumi",100,0,10); - h_time=fs->make(Form("time"),"time",20000,0,2); h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); @@ -143,13 +139,17 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_run = fs->make("Run", "Run"); t_run->Branch("run", &b_run, "run/I"); - t_run->Branch("runTime", &b_runTime, "runTime/l"); - + + t_setup = fs->make("Setup", "Setup"); + t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); + t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); + t_setup->Branch("maxBx", &b_maxBx, "maxBx/I"); + t_setup->Branch("minBx", &b_minBx, "minBx/I"); + t_event = fs->make("Event", "Event"); t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); - t_event->Branch("nDigis", &b_nDigis, "nDigis/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); t_event->Branch("nBx", &b_nBx, "nBx/I"); @@ -168,23 +168,12 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); t_hit->Branch("chamber", &b_chamber, "chamber/I"); t_hit->Branch("layer", &b_layer, "layer/I"); - t_hit->Branch("area", &b_area, "area/F"); - t_hit->Branch("chArea", &b_chArea, "chArea/F"); t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); t_hit->Branch("x", &b_x, "x/F"); t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); - t_digi = fs->make("Digi", "Digi"); - t_digi->Branch("run", &b_run, "run/I"); - t_digi->Branch("lumi", &b_lumi, "lumi/I"); - t_digi->Branch("strip", &b_strip, "strip/I"); - t_digi->Branch("chamber", &b_chamber, "chamber/I"); - t_digi->Branch("layer", &b_layer, "layer/I"); - t_digi->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_digi->Branch("area", &b_area, "area/F"); - for (int ichamber=0; ichamber<36;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { for (int ilayer=0; ilayer<2;++ilayer) { @@ -196,8 +185,6 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - h_chInfo[ichamber][ilayer] = fs->make(Form("chInfo ch %i lay %i", ichamber+1, ilayer+1), "1:detId 2:area", 2, 0.5, 2.5, 8, 0.5, 8.5); - h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); @@ -209,6 +196,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : SliceTestAnalysis::~SliceTestAnalysis() { + t_setup->Fill(); std::cout << "::: GEM Slice Test Results :::" << std::endl; std::cout << ": From " << nEvents << " events" << std::endl; std::cout << std::endl; @@ -224,17 +212,11 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_run = iEvent.run(); b_lumi = iEvent.luminosityBlock(); - if (b_run != runNum_) return; - nEvents++; - int maxBx = 0; - int minBx = 0; - b_nMuons = 0; b_nMuonsWithGEMHit = 0; b_nGEMHits = 0; - b_nDigis = 0; edm::ESHandle hGeom; iSetup.get().get(hGeom); @@ -249,9 +231,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); - edm::Handle gemDigis; - iEvent.getByToken(gemDigis_, gemDigis); - edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { @@ -420,16 +399,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_instLumi = instLumi; h_pileup->Fill(pileup); for (auto ch : GEMGeometry_->chambers()) { - double chArea = 0; - for(auto roll : ch->etaPartitions()) { - const int nstrips(roll->nstrips()); - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - double trStripArea = (roll->pitch()) * striplength; - double trArea = trStripArea * nstrips; - chArea += trArea; - } - b_chArea = chArea; for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); @@ -437,21 +406,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet auto recHitsRange = gemRecHits->get(rId); auto gemRecHit = recHitsRange.first; - const int nstrips(roll->nstrips()); - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - double trStripArea = (roll->pitch()) * striplength; - double trArea = trStripArea * nstrips; - - auto axis = h_chInfo[rId.chamber()-1][rId.layer()-1]->GetXaxis(); - auto idBin = axis->FindBin(1.); - auto areaBin = axis->FindBin(2.); - auto rollBin = h_chInfo[rId.chamber()-1][rId.layer()-1]->GetYaxis()->FindBin(rId.roll()); - h_chInfo[rId.chamber()-1][rId.layer()-1]->SetBinContent(areaBin, rollBin, trArea); - h_chInfo[rId.chamber()-1][rId.layer()-1]->SetBinContent(idBin, rollBin, rId.rawId()); - - b_area = trArea; - for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { // h_hitEta[rId.chamber()-1][rId.layer()-1]->Fill(rId.roll()); @@ -459,8 +413,8 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); int bx = hit->BunchX(); - if (maxBx < bx) maxBx = bx; - if (minBx > bx) minBx = bx; + if (b_maxBx < bx) b_maxBx = bx; + if (b_minBx > bx) b_minBx = bx; for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); @@ -500,40 +454,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - - const int nstrips(roll->nstrips()); - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - double trStripArea = (roll->pitch()) * striplength; - double trArea = trStripArea * nstrips; - - b_area = trArea; - - auto digisRange = gemDigis->get(rId); - auto gemDigi = digisRange.first; - - b_chamber = rId.chamber(); - b_layer = rId.layer(); - b_etaPartition = rId.roll(); - - for (auto hit = gemDigi; hit != digisRange.second; ++hit) { - - h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); - int bx = hit->bx(); - if (bx < minBx) minBx = bx; - if (bx > maxBx) maxBx = bx; - //h_bxtotal->Fill(hit->bx()); - b_strip = hit->strip(); - b_nDigis++; - t_digi->Fill(); - } - } - } - - b_nBx = (maxBx - minBx + 1); + b_nBx = (b_maxBx - b_minBx + 1); h_totalStrips->Fill(totalStrips); t_event->Fill(); @@ -542,10 +463,25 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet void SliceTestAnalysis::beginJob(){} void SliceTestAnalysis::endJob(){} -void SliceTestAnalysis::beginRun(Run const& run, EventSetup const&){ +void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ + edm::ESHandle hGeom; + iSetup.get().get(hGeom); + const GEMGeometry* GEMGeometry_ = &*hGeom; + + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + + b_stripLength[rId.chamber()%2][rId.roll()-1] = striplength; + b_stripPitch[rId.chamber()%2][rId.roll()-1] = pitch; + } + } + b_run = run.run(); - if (b_run != runNum_) return; - b_runTime = run.endTime().value() - run.beginTime().value(); t_run->Fill(); } void SliceTestAnalysis::endRun(Run const&, EventSetup const&){} diff --git a/MuonAnalyser/test/runSliceTestAnalysis2018.py b/MuonAnalyser/test/runSliceTestAnalysis2018.py index 2cf199ffcf2..1a5a94c276e 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis2018.py +++ b/MuonAnalyser/test/runSliceTestAnalysis2018.py @@ -54,10 +54,8 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), - gemDigis = cms.InputTag("muonGEMDigis"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), - runNum = cms.int32(319348), ) process.p = cms.Path(process.SliceTestAnalysis) From e0b95162e2ced35c0ef325d4a17e1aa57ede4743 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 24 Aug 2018 18:23:24 +0900 Subject: [PATCH 08/50] add scripts for background plots --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 177 +--------------- MuonAnalyser/test/makeHisto.cc | 234 ++++++++++++++++++++++ MuonAnalyser/test/runSliceTestAnalysis.py | 1 + 3 files changed, 240 insertions(+), 172 deletions(-) create mode 100644 MuonAnalyser/test/makeHisto.cc diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 346483d2273..b3dd9b99978 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -96,7 +96,7 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_hit; int b_run, b_lumi, b_event; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; float b_x, b_y, b_z; int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; @@ -123,6 +123,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : b_maxBx(0), b_minBx(0) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); muons_ = consumes >(iConfig.getParameter("muons")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); @@ -169,7 +170,6 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_hit->Branch("chamber", &b_chamber, "chamber/I"); t_hit->Branch("layer", &b_layer, "layer/I"); t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); t_hit->Branch("x", &b_x, "x/F"); t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); @@ -223,19 +223,19 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet const GEMGeometry* GEMGeometry_ = &*hGeom; iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - // iSetup.get().get("SteppingHelixPropagatorAny",propagator_); - // iSetup.get().get(bField_); theService_->update(iSetup); auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); + edm::Handle cscRecHits; + iEvent.getByToken(cscRecHits_, cscRecHits); + edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { vertexCollection->size(); - // std::cout << "vertex->size() " << vertexCollection->size() < lumiScalers; @@ -243,155 +243,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet Handle > muons; iEvent.getByToken(muons_, muons); - //std::cout << "muons->size() " << muons->size() < tightMuHits; - std::vector looseMuHits; - std::vector noidMuHits; - - for (size_t i = 0; i < muons->size(); ++i) { - b_nMuons++; - nMuonTotal++; - - edm::RefToBase muRef = muons->refAt(i); - const reco::Muon* mu = muRef.get(); - - // if (mu->isGEMMuon()) { - // std::cout << "isGEMMuon " <globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - if (muonTrack) { - - std::set detLists; - - reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - bool onDet = false; - - // prepropagate to near the GEM region, to speedup per/etapart prop. w/o loss of generatlity - TrajectoryStateOnSurface tsos_ = propagator->propagate(ttTrack.outermostMeasurementState(), - GEMGeometry_->etaPartitions()[0]->surface()); - if (!tsos_.isValid()) continue; - - // GlobalPoint tsosGP = tsos.globalPosition(); - - for (auto ch : GEMGeometry_->etaPartitions()) { - TrajectoryStateOnSurface tsos = propagator->propagate(tsos_, // ttTrack.outermostMeasurementState(), - ch->surface()); - if (!tsos.isValid()) continue; - - GlobalPoint tsosGP = tsos.globalPosition(); - //if ( !detLists.insert( ch->surface().position().z() ).second ) continue; - const LocalPoint pos = ch->toLocal(tsosGP); - const LocalPoint pos2D(pos.x(), pos.y(), 0); - const BoundPlane& bps(ch->surface()); - //cout << "tsos gp "<< tsosGP << ch->id() <Fill(tsosGP.x(), tsosGP.y()); - - if (bps.bounds().inside(pos2D)) { - onDet = true; - auto gemid = ch->id(); - h_inEta[gemid.chamber()][gemid.layer()]->Fill(gemid.roll()); - // cout << " in chamber "<< ch->id() << " pos = "<recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - if ((*hit)->rawId() == ch->id().rawId() ) { - GEMDetId gemid((*hit)->geographicalId()); - auto etaPart = GEMGeometry_->etaPartition(gemid); - // cout << "found it "<< gemid - // << " lp " << (*hit)->localPosition() - // << " gp " << etaPart->toGlobal((*hit)->localPosition()) - // << endl; - } - } - } - } - } - - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - GEMDetId gemid((*hit)->geographicalId()); - h_trkEta[gemid.chamber()][gemid.layer()]->Fill(gemid.roll()); - if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) - tightMuHits.push_back(static_cast(*hit)); - else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) - looseMuHits.push_back(static_cast(*hit)); - else - noidMuHits.push_back(static_cast(*hit)); - } - } - - if (onDet) ++nGEMFiducialMuon; - - if (muonTrack->hitPattern().numberOfValidMuonGEMHits()) { - ++b_nMuonsWithGEMHit; - ++nGEMTrackWithMuon; - // std::cout << "numberOfValidMuonGEMHits->size() " << muonTrack->hitPattern().numberOfValidMuonGEMHits() - // << " recHitsSize " << muonTrack->recHitsSize() - // << " pt " << muonTrack->pt() - // <recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - //if ((*hit)->rawId() == ch->id().rawId() ) { - GEMDetId gemid((*hit)->geographicalId()); - auto etaPart = GEMGeometry_->etaPartition(gemid); - - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),etaPart->surface()); - if (!tsos.isValid()) continue; - // GlobalPoint tsosGP = tsos.globalPosition(); - - LocalPoint && tsos_localpos = tsos.localPosition(); - LocalError && tsos_localerr = tsos.localError().positionError(); - LocalPoint && dethit_localpos = (*hit)->localPosition(); - LocalError && dethit_localerr = (*hit)->localPositionError(); - auto res_x = (dethit_localpos.x() - tsos_localpos.x()); - auto res_y = (dethit_localpos.y() - tsos_localpos.y()); - auto pull_x = (dethit_localpos.x() - tsos_localpos.x()) / - std::sqrt(dethit_localerr.xx() + tsos_localerr.xx()); - auto pull_y = (dethit_localpos.y() - tsos_localpos.y()) / - std::sqrt(dethit_localerr.yy() + tsos_localerr.yy()); - - h_res_x->Fill(res_x); - h_res_y->Fill(res_y); - h_pull_x->Fill(pull_x); - h_pull_y->Fill(pull_y); - - // cout << "gem hit "<< gemid<< endl; - // cout << " gp " << etaPart->toGlobal((*hit)->localPosition())<< endl; - // cout << " tsosGP "<< tsosGP << endl; - // cout << " res_x " << res_x - // << " res_y " << res_y - // << " pull_x " << pull_x - // << " pull_y " << pull_y - // << endl; - } - - } - // auto res = muonTrack->residuals(); - // for (unsigned int i = 0; i < muonTrack->recHitsSize(); ++i) { - // cout << " res x "<< res.residualX(i) - // << " res y "<< res.residualY(i) - // << " pull x "<< res.pullX(i) - // << " pull y "<< res.pullY(i) - // < 0) { - // std::cout << "POOR MU "; - // for (auto & hit : looseMuHits) std::cout << hit << " "; - // std::cout << std::endl; - // } - - // if (gemRecHits->size()) { - // std::cout << "gemRecHits->size() " << gemRecHits->size() <at(0)).instantLumi()/10000; auto pileup = (lumiScalers->at(0)).pileup(); @@ -402,13 +254,11 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); - //std::cout << "rId " << rId <get(rId); auto gemRecHit = recHitsRange.first; for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { -// h_hitEta[rId.chamber()-1][rId.layer()-1]->Fill(rId.roll()); h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); @@ -425,23 +275,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_chamber = rId.chamber(); b_layer = rId.layer(); b_etaPartition = rId.roll(); - b_muonQuality = -1; - for (auto muHit : noidMuHits) { - if (*hit == *muHit) { - b_muonQuality = 0; - } - } - - for (auto muHit : looseMuHits) { - if (*hit == *muHit) { - b_muonQuality = 1; - } - } - - for (auto muHit : tightMuHits) { - if (*hit == *muHit) - b_muonQuality = 2; - } auto globalPosition = roll->toGlobal(hit->localPosition()); b_x = globalPosition.x(); diff --git a/MuonAnalyser/test/makeHisto.cc b/MuonAnalyser/test/makeHisto.cc new file mode 100644 index 00000000000..eabba1a77f6 --- /dev/null +++ b/MuonAnalyser/test/makeHisto.cc @@ -0,0 +1,234 @@ +double findCuts (TH2D* [36][2], int); + +void makeHisto() { + int runNumber = 321396; + TFile* input = TFile::Open(Form("histo_%i.root", runNumber), "READ"); + + int iHit = 0; + int iCSC = 0; + int run_; + + TFile* output = TFile::Open(Form("output_%i.root", runNumber), "RECREATE"); + TTree* runTree = new TTree("runTree", "runTree"); + runTree->Branch("run", &run_, "run/I"); + + // Load Geometry Setup + float stripLength[2][8]; + float stripPitch[2][8]; + float cscArea; + TTree* t_setup = (TTree*) input->Get("SliceTestAnalysis/Setup"); + t_setup->SetBranchAddress("stripLength", stripLength); + t_setup->SetBranchAddress("stripPitch", stripPitch); + t_setup->SetBranchAddress("cscArea", &cscArea); + t_setup->GetEntry(0); + float trArea[36][2][8]; + float chArea[36][2]; + float vfatArea[36][2][8][3]; + float totArea; + + // Prepare get info about active areas + TH2D* hAllStrip[36][2]; + TH2D* hMaskedStrip[36][2]; + int nOfActiveStrip[36][2][8]; + int nOfActiveStripVfat[36][2][8][3]; + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + hAllStrip[iChamber][iLayer] = (TH2D*) input->Get(Form("SliceTestAnalysis/allStrips ch %i lay %i", iChamber+1, iLayer+1)); + + hMaskedStrip[iChamber][iLayer] = new TH2D(Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); + hMaskedStrip[iChamber][iLayer]->GetXaxis()->SetTitle("Strip"); + hMaskedStrip[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + + for (int iEta = 1; iEta < 9; iEta++) { + nOfActiveStrip[iChamber][iLayer][iEta-1] = 0; + for (int iStrip = 1; iStrip < 385; iStrip++) { + hMaskedStrip[iChamber][iLayer]->Fill(iStrip, iEta); + } + for (int iStrip = 0; iStrip < 3; iStrip++) { + nOfActiveStripVfat[iChamber][iLayer][iEta-1][iStrip] =0; + } + } + } + } + + // Load Event + int run, lumi, nGEMHits, nCSCHits; + float instLumi; + TTree* t_Event = (TTree*) input->Get("SliceTestAnalysis/Event"); + t_Event->SetBranchAddress("run", &run); + t_Event->SetBranchAddress("lumi", &lumi); + t_Event->SetBranchAddress("nGEMHits", &nGEMHits); + t_Event->SetBranchAddress("nCSCHits", &nCSCHits); + t_Event->SetBranchAddress("instLumi", &instLumi); + + int nEvent = t_Event->GetEntries(); + map nRunEvent; + map> nLumiEvent; + map hInstLumi; + map hHitRateLumi; + map hAllStrips; + map hHitRateVfat; + map hHitRateCSC; + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + nRunEvent[run]++; + nLumiEvent[run][lumi]++; + } + for (auto iter = nRunEvent.begin(); iter != nRunEvent.end(); iter++) { + run_ = iter->first; + hInstLumi[run_] = new TH1D(Form("instLumi %i", iter->first), "instLumi", 50, 0, 2); + hInstLumi[run_]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hInstLumi[run_]->GetYaxis()->SetTitle("Event"); + + hHitRateLumi[run_][0][0] = new TH1D(Form("%i hitRate", run_), Form("Run number %i", run_), 50, 0, 2); + hHitRateLumi[run_][0][0]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hHitRateLumi[run_][0][0]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + hHitRateLumi[run_][iChamber][iLayer] = new TH1D(Form("%i hitRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); + hHitRateLumi[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hHitRateLumi[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + hHitRateLumi[run_][iChamber][iLayer]->SetMarkerSize(2); + + //hHitRateCSC[run_][iChamber][iLayer] = new TH1D(Form("%i cscRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); + //hHitRateCSC[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + //hHitRateCSC[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + //hHitRateCSC[run_][iChamber][iLayer]->SetMarkerSize(2); + + hHitRateVfat[run_][iChamber][iLayer] = new TH2D(Form("%i vfat ch %i layer %i", run_, iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 3, 0.5, 384.5, 8, 0.5, 8.5); + hHitRateVfat[run_][iChamber][iLayer]->GetXaxis()->SetTitle("strip"); + hHitRateVfat[run_][iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + + hAllStrips[run_][iChamber][iLayer] = new TH2D(Form("%i allStrips ch %i layer %i", run_, iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); + hAllStrips[run_][iChamber][iLayer]->GetXaxis()->SetTitle("strip"); + hAllStrips[run_][iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + } + } + runTree->Fill(); + } + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + hInstLumi[run]->Fill(instLumi); + } + + // Load RecHits + int chamber, layer, etaPartition, firstStrip, nStrips; + TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); + t_Hit->SetBranchAddress("chamber", &chamber); + t_Hit->SetBranchAddress("layer", &layer); + t_Hit->SetBranchAddress("etaPartition", &etaPartition); + t_Hit->SetBranchAddress("firstStrip", &firstStrip); + t_Hit->SetBranchAddress("nStrips", &nStrips); + + //int chamber_, layer_, nStrips_; + //TTree* t_csc = (TTree*) input->Get("SliceTestAnalysis/csc"); + //t_csc->SetBranchAddress("chamber", &chamber_); + //t_csc->SetBranchAddress("layer", &layer_); + //t_csc->SetBranchAddress("nStrips", &nStrips_); + + double cut = findCuts(hAllStrip, nEvent); + + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); + auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); + for (int iEta = 1; iEta < 9; iEta++) { + auto yBin = yAxis->FindBin(iEta); + for (int iStrip = 1; iStrip < 385; iStrip++) { + auto xBin = xAxis->FindBin(iStrip); + double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); + if (val < 1) continue; + val = double(val/nEvent); + if (val > cut) continue; + hMaskedStrip[iChamber][iLayer]->SetBinContent(xBin, yBin, 0); + nOfActiveStrip[iChamber][iLayer][iEta-1]++; + nOfActiveStripVfat[iChamber][iLayer][iEta-1][iStrip/128]++; + } + } + } + } + + totArea = 0; + for ( int ch = 0; ch < 36; ch++ ) { + for ( int ly = 0; ly < 2; ly++) { + chArea[ch][ly] = 0; + for ( int et = 0; et < 8; et++) { + trArea[ch][ly][et] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStrip[ch][ly][et]); + chArea[ch][ly] += trArea[ch][ly][et]; + for ( int ix = 0; ix < 3; ix++) vfatArea[ch][ly][et][ix] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStripVfat[ch][ly][et][ix]); + } + totArea += chArea[ch][ly]; + } + } + + bool flag; + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + flag = false; + int nEvent_ = hInstLumi[run]->GetBinContent(hInstLumi[run]->GetXaxis()->FindBin(instLumi)); + for (int j = 0; j < nGEMHits; j++) { + t_Hit->GetEntry(iHit); + iHit++; + + auto etaBin = hAllStrip[chamber-1][layer-1]->GetYaxis()->FindBin(etaPartition); + + double normFactor = (chArea[chamber-1][layer-1]*nEvent_*25E-9); + + for (int k = 0; k < nStrips; k++) { + hAllStrips[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition); + auto xBin = hAllStrip[chamber-1][layer-1]->GetXaxis()->FindBin(firstStrip+k); + if(hAllStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin)/nEvent > cut) continue; + hHitRateLumi[run][chamber-1][layer-1]->Fill(instLumi, 1./(normFactor)); + double normFactorVfat = (vfatArea[chamber-1][layer-1][etaPartition-1][(firstStrip+k)/128]*nEvent_*25E-9); + hHitRateVfat[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition, 1./(normFactorVfat)); + flag = true; + } + } + if (flag) hHitRateLumi[run][0][0]->Fill(instLumi, 1./(totArea*nEvent_*25E-9)); + //for (int j = 0; j < nGEMHits; j++) { + // t_csc->GetEntry(iCSC); + // iCSC++; + + // double normFactor = (cscArea*nEvent_*25E-9); + + // for (int k = 0; k < nStrips_; k++) { + // hHitRateCSC[run][chamber_-1][layer_-1]->Fill(instLumi, 1./(normFactor)); + // flag = true; + // } + //} + } + + output->Write(); + output->Close(); +} + + +double findCuts(TH2D* hAllStrip[36][2], int nEvent) { + TH1D* hitHist = new TH1D( "hitHist", "hits per each strip", 500, 0, 4e-4); + hitHist->GetXaxis()->SetTitle("number of hits per each strip"); + hitHist->GetYaxis()->SetTitle("strips"); + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); + auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); + for (int iEta = 1; iEta < 9; iEta++) { + auto yBin = yAxis->FindBin(iEta); + for (int iStrip = 1; iStrip < 385; iStrip++) { + auto xBin = xAxis->FindBin(iStrip); + double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); + val = double(val/nEvent); + if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; + else if(val >= 4E-4) val = 3.99E-4; + hitHist->Fill((double)val); + } + } + } + } + hitHist->Write(); + double res = (hitHist->GetMean() + 2*hitHist->GetRMS()); + delete hitHist; + return res; +} diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 4920ea4d33a..5973a3b110e 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -38,6 +38,7 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), + cscRecHits = cms.InputTag("csc2DRecHits"), muons = cms.InputTag("muons"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), From 34509073cef96e5be43303e1365c0dc3663d3fde Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 31 Aug 2018 13:08:42 +0900 Subject: [PATCH 09/50] add cscrechits --- MuonAnalyser/plugins/BuildFile.xml | 1 + MuonAnalyser/plugins/SliceTestAnalysis.cc | 131 +++++++++++++--------- 2 files changed, 77 insertions(+), 55 deletions(-) diff --git a/MuonAnalyser/plugins/BuildFile.xml b/MuonAnalyser/plugins/BuildFile.xml index 6d0c093a814..9855fc3e5e1 100644 --- a/MuonAnalyser/plugins/BuildFile.xml +++ b/MuonAnalyser/plugins/BuildFile.xml @@ -20,6 +20,7 @@ + diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index b3dd9b99978..78292134fe6 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -29,11 +29,16 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCLayer.h" +#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" @@ -94,33 +99,27 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH1D* h_res_x, *h_res_y, *h_pull_x, *h_pull_y; - TTree *t_hit; - int b_run, b_lumi, b_event; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; - float b_x, b_y, b_z; - - int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; - int b_nMuons, b_nMuonsWithGEMHit, b_nBx; - float b_instLumi; + TTree *t_setup; float b_stripLength[2][8]; float b_stripPitch[2][8]; - float b_area[2]; - - int b_nGEMHits; - - TTree *t_setup; - int b_maxBx, b_minBx; - + float b_cscArea[2]; + TTree *t_run; + TTree *t_event; + int b_run, b_lumi; + int b_nGEMHits, b_nCSCHits; + float b_instLumi; + + TTree *t_hit; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; + float b_x, b_y, b_z; + + TTree *t_csc; + }; -SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : - nEvents(0), - nMuonTotal(0), - nGEMFiducialMuon(0), - nGEMTrackWithMuon(0), - b_maxBx(0), b_minBx(0) +SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); @@ -144,27 +143,15 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_setup = fs->make("Setup", "Setup"); t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); - t_setup->Branch("maxBx", &b_maxBx, "maxBx/I"); - t_setup->Branch("minBx", &b_minBx, "minBx/I"); + t_setup->Branch("cscArea", &b_cscArea, "cscArea[2]/F"); t_event = fs->make("Event", "Event"); - t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); - t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); - t_event->Branch("nBx", &b_nBx, "nBx/I"); t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); - h_res_x=fs->make(Form("res_x"),"res_x",100,-50,50); - h_res_y=fs->make(Form("res_y"),"res_y",100,-50,50); - h_pull_x=fs->make(Form("pull_x"),"pull_x",100,-50,50); - h_pull_y=fs->make(Form("pull_y"),"pull_y",100,-50,50); - t_hit = fs->make("Hit", "Hit"); - t_hit->Branch("run", &b_run, "run/I"); - t_hit->Branch("lumi", &b_lumi, "lumi/I"); - t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); t_hit->Branch("chamber", &b_chamber, "chamber/I"); @@ -174,6 +161,11 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); + t_csc = fs->make("CSC", "CSC"); + t_csc->Branch("chamber", &b_chamber, "chamber/I"); + t_csc->Branch("layer", &b_layer, "layer/I"); + t_csc->Branch("nStrips", &b_nStrips, "nStrips/I"); + for (int ichamber=0; ichamber<36;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { for (int ilayer=0; ilayer<2;++ilayer) { @@ -197,13 +189,6 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : SliceTestAnalysis::~SliceTestAnalysis() { t_setup->Fill(); - std::cout << "::: GEM Slice Test Results :::" << std::endl; - std::cout << ": From " << nEvents << " events" << std::endl; - std::cout << std::endl; - std::cout << " # Muons " << nMuonTotal << std::endl; - std::cout << " # FidMu " << nGEMFiducialMuon << std::endl; - std::cout << " # GEMMu " << nGEMTrackWithMuon << std::endl; - std::cout << std::endl; } void @@ -212,15 +197,15 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_run = iEvent.run(); b_lumi = iEvent.luminosityBlock(); - nEvents++; - - b_nMuons = 0; - b_nMuonsWithGEMHit = 0; b_nGEMHits = 0; - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const GEMGeometry* GEMGeometry_ = &*hGeom; + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); theService_->update(iSetup); @@ -250,6 +235,7 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet h_instLumi->Fill(instLumi); b_instLumi = instLumi; h_pileup->Fill(pileup); + for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); @@ -262,9 +248,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); - int bx = hit->BunchX(); - if (b_maxBx < bx) b_maxBx = bx; - if (b_minBx > bx) b_minBx = bx; for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); @@ -287,7 +270,27 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } - b_nBx = (b_maxBx - b_minBx + 1); + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + if (lId.station() != 1) continue; + if (lId.endcap() != 2) continue; + if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + auto recHitsRange = cscRecHits->get(lId); + auto cscRecHit = recHitsRange.first; + + for (auto hit = cscRecHit; hit != recHitsRange.second; ++hit) { + b_nStrips = hit->nStrips(); + b_chamber = lId.chamber(); + b_layer = lId.layer(); + + t_csc->Fill(); + b_nCSCHits++; + } + } + } + h_totalStrips->Fill(totalStrips); t_event->Fill(); @@ -297,9 +300,13 @@ void SliceTestAnalysis::beginJob(){} void SliceTestAnalysis::endJob(){} void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const GEMGeometry* GEMGeometry_ = &*hGeom; + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { @@ -313,6 +320,20 @@ void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ b_stripPitch[rId.chamber()%2][rId.roll()-1] = pitch; } } + + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + if (lId.station() != 1) continue; + if (lId.endcap() != 2) continue; + if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + const OffsetRadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + const float striplength(top_->stripLength()); + const float pitch(top_->pitch()); + b_cscArea[lId.chamber()%2] = striplength * pitch * top_->nstrips(); + } + } b_run = run.run(); t_run->Fill(); From 98850c60e076effae55412e645388d820be2d5f7 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Thu, 6 Sep 2018 15:16:16 +0900 Subject: [PATCH 10/50] update latency --- MuonAnalyser/plugins/BuildFile.xml | 1 + MuonAnalyser/plugins/SliceTestAnalysis.cc | 95 +++--- MuonAnalyser/test/fillHisto.cc | 337 ++++++++++++++++++++++ MuonAnalyser/test/makeHisto.cc | 122 +++++--- 4 files changed, 474 insertions(+), 81 deletions(-) create mode 100644 MuonAnalyser/test/fillHisto.cc diff --git a/MuonAnalyser/plugins/BuildFile.xml b/MuonAnalyser/plugins/BuildFile.xml index 9855fc3e5e1..b0c0f29738a 100644 --- a/MuonAnalyser/plugins/BuildFile.xml +++ b/MuonAnalyser/plugins/BuildFile.xml @@ -9,6 +9,7 @@ + diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 78292134fe6..f1b61640772 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -32,7 +32,10 @@ #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" + #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" @@ -76,6 +79,7 @@ class SliceTestAnalysis : public edm::EDAnalyzer { edm::EDGetTokenT gemRecHits_; edm::EDGetTokenT cscRecHits_; edm::EDGetTokenT gemDigis_; + edm::EDGetTokenT> gemDigisAMC_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; @@ -107,9 +111,10 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_run; TTree *t_event; - int b_run, b_lumi; + int b_run, b_lumi, b_latency; int b_nGEMHits, b_nCSCHits; float b_instLumi; + unsigned int b_timeLow, b_timeHigh; TTree *t_hit; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; @@ -124,6 +129,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); muons_ = consumes >(iConfig.getParameter("muons")); + gemDigisAMC_ = consumes>(iConfig.getParameter("gemDigisAMC")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); @@ -149,7 +155,10 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); + t_event->Branch("latency", &b_latency, "latency/I"); t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); + t_event->Branch("timeLow", &b_timeLow, "timeLow/i"); + t_event->Branch("timeHigh", &b_timeHigh, "timeHigh/i"); t_hit = fs->make("Hit", "Hit"); t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); @@ -203,9 +212,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - edm::ESHandle hCSCGeom; - iSetup.get().get(hCSCGeom); - const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + //edm::ESHandle hCSCGeom; + //iSetup.get().get(hCSCGeom); + //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); theService_->update(iSetup); @@ -217,6 +226,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::Handle cscRecHits; iEvent.getByToken(cscRecHits_, cscRecHits); + edm::Handle> gemDigisAMC; + iEvent.getByToken(gemDigisAMC_, gemDigisAMC); + edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { @@ -234,8 +246,17 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet auto pileup = (lumiScalers->at(0)).pileup(); h_instLumi->Fill(instLumi); b_instLumi = instLumi; + b_timeHigh = iEvent.time().unixTime(); + b_timeLow = iEvent.time().microsecondOffset(); h_pileup->Fill(pileup); + b_latency = -1; + for (auto g : *gemDigisAMC) { + for (auto a = g.second.first; a != g.second.second; a++) { + b_latency = a->Param1(); + } + } + for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); @@ -270,26 +291,26 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } - for (auto ch : CSCGeometry_->chambers()) { - for (auto layer : ch->layers()) { - CSCDetId lId = layer->id(); - if (lId.station() != 1) continue; - if (lId.endcap() != 2) continue; - if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - auto recHitsRange = cscRecHits->get(lId); - auto cscRecHit = recHitsRange.first; - - for (auto hit = cscRecHit; hit != recHitsRange.second; ++hit) { - b_nStrips = hit->nStrips(); - b_chamber = lId.chamber(); - b_layer = lId.layer(); - - t_csc->Fill(); - b_nCSCHits++; - } - } - } + //for (auto ch : CSCGeometry_->chambers()) { + // for (auto layer : ch->layers()) { + // CSCDetId lId = layer->id(); + // if (lId.station() != 1) continue; + // if (lId.endcap() != 2) continue; + // if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + // auto recHitsRange = cscRecHits->get(lId); + // auto cscRecHit = recHitsRange.first; + // + // for (auto hit = cscRecHit; hit != recHitsRange.second; ++hit) { + // b_nStrips = hit->nStrips(); + // b_chamber = lId.chamber(); + // b_layer = lId.layer(); + + // t_csc->Fill(); + // b_nCSCHits++; + // } + // } + //} h_totalStrips->Fill(totalStrips); @@ -321,19 +342,19 @@ void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ } } - for (auto ch : CSCGeometry_->chambers()) { - for (auto layer : ch->layers()) { - CSCDetId lId = layer->id(); - if (lId.station() != 1) continue; - if (lId.endcap() != 2) continue; - if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - const OffsetRadialStripTopology* top_(dynamic_cast(&(layer->topology()))); - const float striplength(top_->stripLength()); - const float pitch(top_->pitch()); - b_cscArea[lId.chamber()%2] = striplength * pitch * top_->nstrips(); - } - } + //for (auto ch : CSCGeometry_->chambers()) { + // for (auto layer : ch->layers()) { + // CSCDetId lId = layer->id(); + // if (lId.station() != 1) continue; + // if (lId.endcap() != 2) continue; + // if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + // const OffsetRadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + // const float striplength(top_->stripLength()); + // const float pitch(top_->pitch()); + // b_cscArea[lId.chamber()%2] = striplength * pitch * top_->nstrips(); + // } + //} b_run = run.run(); t_run->Fill(); diff --git a/MuonAnalyser/test/fillHisto.cc b/MuonAnalyser/test/fillHisto.cc new file mode 100644 index 00000000000..c8648ed2e18 --- /dev/null +++ b/MuonAnalyser/test/fillHisto.cc @@ -0,0 +1,337 @@ +array findCuts(TH2D*[36][2], TH1D*[36][2][24]); +array findCuts(TH2D*[36][2], TH1D*[36][2]); + +void rebinHisto(TH1D* h); + +void fillHisto() { + int lumiFill = 7058; + TFile* input = TFile::Open(Form("data/histo_%i.root", lumiFill), "READ"); + + int iHit = 0; + int iCSC = 0; + int run_; + + TFile* output = TFile::Open(Form("output_%i.root", lumiFill), "RECREATE"); + TTree* runTree = new TTree("runTree", "runTree"); + + // Load Geometry Setup + float stripLength[2][8]; + float stripPitch[2][8]; + float cscArea; + TTree* t_setup = (TTree*) input->Get("SliceTestAnalysis/Setup"); + t_setup->SetBranchAddress("stripLength", stripLength); + t_setup->SetBranchAddress("stripPitch", stripPitch); + t_setup->SetBranchAddress("cscArea", &cscArea); + t_setup->GetEntry(0); + float trArea[36][2][8]; + float chArea[36][2]; + float vfatArea[36][2][24]; + float totArea; + + // Load RecHits + int chamber, layer, etaPartition, firstStrip, nStrips; + TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); + t_Hit->SetBranchAddress("chamber", &chamber); + t_Hit->SetBranchAddress("layer", &layer); + t_Hit->SetBranchAddress("etaPartition", &etaPartition); + t_Hit->SetBranchAddress("firstStrip", &firstStrip); + t_Hit->SetBranchAddress("nStrips", &nStrips); + + // Prepare get info about active areas + TH2D* hAllStrip[36][2]; + TH2D* hMaskedStrip[36][2]; + int nOfActiveStrip[36][2][8]; + int nOfActiveStripVfat[36][2][24]; + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + hAllStrip[iChamber][iLayer] = (TH2D*) input->Get(Form("SliceTestAnalysis/allStrips ch %i lay %i", iChamber+1, iLayer+1)); + + hMaskedStrip[iChamber][iLayer] = new TH2D(Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); + hMaskedStrip[iChamber][iLayer]->GetXaxis()->SetTitle("Strip"); + hMaskedStrip[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + + for (int iEta = 1; iEta < 9; iEta++) { + nOfActiveStrip[iChamber][iLayer][iEta-1] = 0; + for (int iStrip = 1; iStrip < 385; iStrip++) { + hMaskedStrip[iChamber][iLayer]->Fill(iStrip, iEta); + } + } + for (int vfat = 0; vfat < 24; vfat++) { + nOfActiveStripVfat[iChamber][iLayer][vfat] =0; + } + } + } + + // Load Event + int run, lumi, nGEMHits, nCSCHits; + float instLumi; + TTree* t_Event = (TTree*) input->Get("SliceTestAnalysis/Event"); + t_Event->SetBranchAddress("run", &run); + t_Event->SetBranchAddress("lumi", &lumi); + t_Event->SetBranchAddress("nGEMHits", &nGEMHits); + t_Event->SetBranchAddress("nCSCHits", &nCSCHits); + t_Event->SetBranchAddress("instLumi", &instLumi); + + int nEvent = t_Event->GetEntries(); + map nRunEvent; + map> nLumiEvent; + map> hLumiStatus; + map hActiveLumi; + TH1D* hInstLumi [36][2][24]; + TH1D* hHitRateEta [36][2][8]; + TH1D* hHitRateLumi[36][2]; + TH2D* hAllStrips [36][2]; + TH2D* hHitRateVfat[36][2]; + TH1D* hHitRateCSC [36][2]; + + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + for (int vfat = 0; vfat < 24; vfat++) { + hInstLumi[iChamber][iLayer][vfat] = new TH1D(Form("instLumi ch %i layer %i vfat %i", iChamber+1, iLayer+1, vfat), "instLumi", 50, 0, 2); + hInstLumi[iChamber][iLayer][vfat]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hInstLumi[iChamber][iLayer][vfat]->GetYaxis()->SetTitle("Event"); + } + + hHitRateLumi[iChamber][iLayer] = new TH1D(Form("hitRate ch %i layer %i", iChamber+1, iLayer+1), Form("Run number"), 50, 0, 2); + hHitRateLumi[iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hHitRateLumi[iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + hHitRateLumi[iChamber][iLayer]->SetMarkerSize(2); + + for (int iEta = 0; iEta < 8; iEta++) { + hHitRateEta[iChamber][iLayer][iEta] = new TH1D(Form("hitRate ch %i layer %i eta %i", iChamber+1, iLayer+1, iEta+1), Form("Run number"), 50, 0, 2); + hHitRateEta[iChamber][iLayer][iEta]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hHitRateEta[iChamber][iLayer][iEta]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + hHitRateEta[iChamber][iLayer][iEta]->SetMarkerSize(2); + } + + hHitRateVfat[iChamber][iLayer] = new TH2D(Form("vfat ch %i layer %i", iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 3, 0.5, 384.5, 8, 0.5, 8.5); + hHitRateVfat[iChamber][iLayer]->GetXaxis()->SetTitle("strip"); + hHitRateVfat[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + + hAllStrips[iChamber][iLayer] = new TH2D(Form("allStrips ch %i layer %i", iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); + hAllStrips[iChamber][iLayer]->GetXaxis()->SetTitle("strip"); + hAllStrips[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); + } + } + + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + nRunEvent[run]++; + nLumiEvent[run][lumi]++; + } + for (auto iter = nRunEvent.begin(); iter != nRunEvent.end(); iter++) { + run_ = iter->first; + hActiveLumi[run_] = new TH2D(Form("%i activeLumi", run_), Form("Run number %i", run_), 1000, 0, 4000, 400, 27, 31); + hActiveLumi[run_]->GetXaxis()->SetTitle("luminosityBlock"); + hActiveLumi[run_]->GetYaxis()->SetTitle("chamber + layer/2 + vfat/48"); + } + for (auto iter = nLumiEvent.begin(); iter != nLumiEvent.end(); iter++) { + run_ = iter->first; + auto lumiMap = iter->second; + for (auto iter_ = lumiMap.begin(); iter_ != lumiMap.end(); iter_++) { + auto lumi_ = iter_->first; + hLumiStatus[run_][lumi_] = new TH1D(Form("%i %i lumiStatus", run_, lumi_), Form("Run number %i lumi %i", run_, lumi_), 1000, 0, 2); + hLumiStatus[run_][lumi_]->GetXaxis()->SetTitle("Instantaneous Luminosity [10^{34}cm^{-2}s^{-1}]"); + } + } + + iHit = 0; + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + hLumiStatus[run][lumi]->Fill(instLumi); + for (int j = 0; j < nGEMHits; j++) { + t_Hit->GetEntry(iHit); + auto vfat = (8-etaPartition)+8*((firstStrip-1)/128); + iHit++; + hActiveLumi[run]->Fill(lumi,(chamber+(layer-1)*0.5+vfat/48.)); + } + } + + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + if (hLumiStatus[run][lumi]->GetRMS() > 0.01) continue; + auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); + for (int iChamber = 27; iChamber < 31; iChamber++) { + for (int iLayer = 1; iLayer < 3; iLayer++) { + for (int vfat = 0; vfat < 24; vfat++) { + //auto fromBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5); + //auto toBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+23/48.); + auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+vfat/48.); + if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) != 0) hInstLumi[iChamber-1][iLayer-1][vfat]->Fill(instLumi); + } + } + } + } + + cout << "test\n"; + auto cut = findCuts(hAllStrip, hInstLumi); + + cout << "test\n"; + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); + auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); + for (int iEta = 1; iEta < 9; iEta++) { + auto yBin = yAxis->FindBin(iEta); + for (int iStrip = 1; iStrip < 385; iStrip++) { + auto xBin = xAxis->FindBin(iStrip); + auto vfat = (8-iEta)+8*((iStrip-1)/128); + double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); + if (val < 1) continue; + int nEvent_ = hInstLumi[iChamber][iLayer][vfat]->GetEntries(); + val = double(val/nEvent_); + if (val > cut[iEta-1]) continue; + hMaskedStrip[iChamber][iLayer]->SetBinContent(xBin, yBin, 0); + nOfActiveStrip[iChamber][iLayer][iEta-1]++; + nOfActiveStripVfat[iChamber][iLayer][vfat]++; + } + } + } + } + + totArea = 0; + for ( int ch = 0; ch < 36; ch++ ) { + for ( int ly = 0; ly < 2; ly++) { + chArea[ch][ly] = 0; + for ( int et = 0; et < 8; et++) { + trArea[ch][ly][et] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStrip[ch][ly][et]); + chArea[ch][ly] += trArea[ch][ly][et]; + for ( int ix = 0; ix < 3; ix++) { + auto vfat = (8-et+1)+8*(ix); + vfatArea[ch][ly][vfat] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStripVfat[ch][ly][vfat]); + } + } + totArea += chArea[ch][ly]; + } + } + + cout << "test\n"; + bool flag; + iHit = 0; + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + flag = false; + auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); + for (int j = 0; j < nGEMHits; j++) { + t_Hit->GetEntry(iHit); + iHit++; + if(hLumiStatus[run][lumi]->GetRMS() > 0.01) continue; + auto vfat = (8-etaPartition)+8*((firstStrip-1)/128); + auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat/48.); + if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) < 1) continue; + + double chArea_ = 0; + for (int vfat_ = 0; vfat_ < 24; vfat_++) { + auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat_/48.); + if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) > 0) + chArea_ += vfatArea[chamber-1][layer-1][vfat_]; + } + double etaArea_ = 0; + for (int ix = 0; ix < 3; ix++) { + auto vfat_ = (8-etaPartition)+8*ix; + auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat_/48.); + if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) > 0) + etaArea_ += vfatArea[chamber-1][layer-1][vfat_]; + } + + int nEvent_ = hInstLumi[chamber-1][layer-1][vfat]->GetBinContent(hInstLumi[chamber-1][layer-1][vfat]->GetXaxis()->FindBin(instLumi)); + auto etaBin = hAllStrip[chamber-1][layer-1]->GetYaxis()->FindBin(etaPartition); + + double normFactor = (chArea_*nEvent_*25E-9); + + auto xBin = hMaskedStrip[chamber-1][layer-1]->GetXaxis()->FindBin(firstStrip); + if(hMaskedStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin) != 0) continue; + hAllStrips[chamber-1][layer-1]->Fill(firstStrip, etaPartition); + hHitRateLumi[chamber-1][layer-1]->Fill(instLumi, 1./(normFactor)); + hHitRateEta[chamber-1][layer-1][etaPartition-1]->Fill(instLumi, 1./(etaArea_*nEvent_*25E-9)); + double normFactorVfat = (vfatArea[chamber-1][layer-1][vfat]*nEvent_*25E-9); + hHitRateVfat[chamber-1][layer-1]->Fill(firstStrip, etaPartition, 1./(normFactorVfat)); + flag = true; + } + } + cout << "test\n"; + + output->Write(); + output->Close(); +} + + +array findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2]) { + TH1D* hitHist[8]; + for (int iEta = 0; iEta < 8; iEta++) { + hitHist[iEta] = new TH1D( Form("hitHist eta %i", iEta+1), + "hits per each strip", 500, 0, 1e-4); + hitHist[iEta]->GetXaxis()->SetTitle("Average number of hits on Strip"); + hitHist[iEta]->GetYaxis()->SetTitle("strips"); + } + array res; + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); + auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); + for (int iEta = 1; iEta < 9; iEta++) { + auto yBin = yAxis->FindBin(iEta); + for (int iStrip = 1; iStrip < 386; iStrip++) { + auto nEvent_ = hInstLumi[iChamber][iLayer]->GetEntries(); + auto xBin = xAxis->FindBin(iStrip); + double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); + val = double(val/nEvent_); + if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; + hitHist[iEta-1]->Fill((double)val); + } + } + } + } + for (int iEta = 0; iEta < 8; iEta++) { + res[iEta] = (hitHist[iEta]->GetMean() + 2*hitHist[iEta]->GetRMS()); + } + return res; +} + +void rebinHisto(TH1D* h) { + double bins[19]; + for (int i = 0; i < 6; i++) { + bins[i] = i * 0.2; + } + for (int i = 0; i < 13; i++) { + bins[i+6] = i * 0.05 + 1.2; + } + h->SetBins(18, bins); +} + +array findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2][24]) { + TH1D* hitHist[8]; + for (int iEta = 0; iEta < 8; iEta++) { + hitHist[iEta] = new TH1D( Form("hitHist eta %i", iEta+1), + "hits per each strip", 500, 0, 1e-4); + hitHist[iEta]->GetXaxis()->SetTitle("Average number of hits on Strip"); + hitHist[iEta]->GetYaxis()->SetTitle("strips"); + } + array res; + for (int iChamber = 26; iChamber < 30; iChamber++) { + for (int iLayer = 0; iLayer < 2; iLayer++) { + if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); + auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); + for (int iEta = 1; iEta < 9; iEta++) { + auto yBin = yAxis->FindBin(iEta); + for (int iStrip = 1; iStrip < 385; iStrip++) { + auto vfat = (8-iEta)+8*((iStrip-1)/128); + auto nEvent_ = hInstLumi[iChamber][iLayer][vfat]->GetEntries(); + auto xBin = xAxis->FindBin(iStrip); + double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); + val = double(val/nEvent_); + if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; + hitHist[iEta-1]->Fill((double)val); + } + } + } + } + for (int iEta = 0; iEta < 8; iEta++) { + res[iEta] = (hitHist[iEta]->GetMean() + 2*hitHist[iEta]->GetRMS()); + } + return res; +} + diff --git a/MuonAnalyser/test/makeHisto.cc b/MuonAnalyser/test/makeHisto.cc index eabba1a77f6..eeaf0dc5173 100644 --- a/MuonAnalyser/test/makeHisto.cc +++ b/MuonAnalyser/test/makeHisto.cc @@ -1,14 +1,17 @@ -double findCuts (TH2D* [36][2], int); +array, 36> findCuts(TH2D*[36][2], TH1D*[36][2]); + +void rebinHisto(TH1D* h); void makeHisto() { - int runNumber = 321396; - TFile* input = TFile::Open(Form("histo_%i.root", runNumber), "READ"); + int runNumber = 321397; + int lumiFill = 7058; + TFile* input = TFile::Open(Form("data/histo_%i.root", lumiFill), "READ"); int iHit = 0; int iCSC = 0; int run_; - TFile* output = TFile::Open(Form("output_%i.root", runNumber), "RECREATE"); + TFile* output = TFile::Open(Form("output_%i.root", lumiFill), "RECREATE"); TTree* runTree = new TTree("runTree", "runTree"); runTree->Branch("run", &run_, "run/I"); @@ -26,6 +29,15 @@ void makeHisto() { float vfatArea[36][2][8][3]; float totArea; + // Load RecHits + int chamber, layer, etaPartition, firstStrip, nStrips; + TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); + t_Hit->SetBranchAddress("chamber", &chamber); + t_Hit->SetBranchAddress("layer", &layer); + t_Hit->SetBranchAddress("etaPartition", &etaPartition); + t_Hit->SetBranchAddress("firstStrip", &firstStrip); + t_Hit->SetBranchAddress("nStrips", &nStrips); + // Prepare get info about active areas TH2D* hAllStrip[36][2]; TH2D* hMaskedStrip[36][2]; @@ -64,7 +76,8 @@ void makeHisto() { int nEvent = t_Event->GetEntries(); map nRunEvent; map> nLumiEvent; - map hInstLumi; + map hActiveLumi; + map hInstLumi; map hHitRateLumi; map hAllStrips; map hHitRateVfat; @@ -76,20 +89,26 @@ void makeHisto() { } for (auto iter = nRunEvent.begin(); iter != nRunEvent.end(); iter++) { run_ = iter->first; - hInstLumi[run_] = new TH1D(Form("instLumi %i", iter->first), "instLumi", 50, 0, 2); - hInstLumi[run_]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hInstLumi[run_]->GetYaxis()->SetTitle("Event"); - hHitRateLumi[run_][0][0] = new TH1D(Form("%i hitRate", run_), Form("Run number %i", run_), 50, 0, 2); hHitRateLumi[run_][0][0]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); hHitRateLumi[run_][0][0]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); + hActiveLumi[run_] = new TH2D(Form("%i activeLumi", run_), Form("Run number %i", run_), 4000, 0, 4000, 10000, 27, 31); + hActiveLumi[run_]->GetXaxis()->SetTitle("lumi block"); + hActiveLumi[run_]->GetYaxis()->SetTitle("chamber + layer/2 + iEta/20"); + for (int iChamber = 26; iChamber < 30; iChamber++) { for (int iLayer = 0; iLayer < 2; iLayer++) { + hInstLumi[run_][iChamber][iLayer] = new TH1D(Form("%i instLumi ch %i layer %i", run_, iChamber+1, iLayer+1), "instLumi", 50, 0, 2); + hInstLumi[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + hInstLumi[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Event"); + //rebinHisto(hInstLumi[run_]); + hHitRateLumi[run_][iChamber][iLayer] = new TH1D(Form("%i hitRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); hHitRateLumi[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); hHitRateLumi[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); hHitRateLumi[run_][iChamber][iLayer]->SetMarkerSize(2); + //rebinHisto(hHitRateLumi[run_][iChamber][iLayer]); //hHitRateCSC[run_][iChamber][iLayer] = new TH1D(Form("%i cscRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); //hHitRateCSC[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); @@ -107,19 +126,28 @@ void makeHisto() { } runTree->Fill(); } + iHit = 0; for (int i = 0; i < nEvent; i++) { t_Event->GetEntry(i); - hInstLumi[run]->Fill(instLumi); + for (int j = 0; j < nGEMHits; j++) { + t_Hit->GetEntry(iHit); + iHit++; + hActiveLumi[run]->Fill(lumi,(chamber+(layer-1)*0.5+etaPartition*0.05)); + } } - // Load RecHits - int chamber, layer, etaPartition, firstStrip, nStrips; - TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); - t_Hit->SetBranchAddress("chamber", &chamber); - t_Hit->SetBranchAddress("layer", &layer); - t_Hit->SetBranchAddress("etaPartition", &etaPartition); - t_Hit->SetBranchAddress("firstStrip", &firstStrip); - t_Hit->SetBranchAddress("nStrips", &nStrips); + for (int i = 0; i < nEvent; i++) { + t_Event->GetEntry(i); + for (int iChamber = 27; iChamber < 31; iChamber++) { + for (int iLayer = 1; iLayer < 3; iLayer++) { + auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); + auto fromBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+0.05); + auto toBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+0.05*8); + if (hActiveLumi[run]->Integral(lumiBin, lumiBin, fromBin, toBin) != 0) + hInstLumi[run][iChamber-1][iLayer-1]->Fill(instLumi); + } + } + } //int chamber_, layer_, nStrips_; //TTree* t_csc = (TTree*) input->Get("SliceTestAnalysis/csc"); @@ -127,7 +155,7 @@ void makeHisto() { //t_csc->SetBranchAddress("layer", &layer_); //t_csc->SetBranchAddress("nStrips", &nStrips_); - double cut = findCuts(hAllStrip, nEvent); + auto cut = findCuts(hAllStrip, hInstLumi[runNumber]); for (int iChamber = 26; iChamber < 30; iChamber++) { for (int iLayer = 0; iLayer < 2; iLayer++) { @@ -140,8 +168,9 @@ void makeHisto() { auto xBin = xAxis->FindBin(iStrip); double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); if (val < 1) continue; + int nEvent_ = hInstLumi[runNumber][iChamber][iLayer]->GetEntries(); val = double(val/nEvent); - if (val > cut) continue; + if (val > cut[iChamber][iLayer]) continue; hMaskedStrip[iChamber][iLayer]->SetBinContent(xBin, yBin, 0); nOfActiveStrip[iChamber][iLayer][iEta-1]++; nOfActiveStripVfat[iChamber][iLayer][iEta-1][iStrip/128]++; @@ -164,40 +193,31 @@ void makeHisto() { } bool flag; + iHit = 0; for (int i = 0; i < nEvent; i++) { t_Event->GetEntry(i); flag = false; - int nEvent_ = hInstLumi[run]->GetBinContent(hInstLumi[run]->GetXaxis()->FindBin(instLumi)); for (int j = 0; j < nGEMHits; j++) { t_Hit->GetEntry(iHit); iHit++; + int nEvent_ = hInstLumi[run][chamber-1][layer-1]->GetBinContent(hInstLumi[run][chamber-1][layer-1]->GetXaxis()->FindBin(instLumi)); + if (nEvent_ == 0) continue; auto etaBin = hAllStrip[chamber-1][layer-1]->GetYaxis()->FindBin(etaPartition); double normFactor = (chArea[chamber-1][layer-1]*nEvent_*25E-9); for (int k = 0; k < nStrips; k++) { - hAllStrips[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition); auto xBin = hAllStrip[chamber-1][layer-1]->GetXaxis()->FindBin(firstStrip+k); - if(hAllStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin)/nEvent > cut) continue; + if(hAllStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin)/nEvent > cut[chamber-1][layer-1]) continue; + hAllStrips[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition); hHitRateLumi[run][chamber-1][layer-1]->Fill(instLumi, 1./(normFactor)); double normFactorVfat = (vfatArea[chamber-1][layer-1][etaPartition-1][(firstStrip+k)/128]*nEvent_*25E-9); hHitRateVfat[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition, 1./(normFactorVfat)); flag = true; } } - if (flag) hHitRateLumi[run][0][0]->Fill(instLumi, 1./(totArea*nEvent_*25E-9)); - //for (int j = 0; j < nGEMHits; j++) { - // t_csc->GetEntry(iCSC); - // iCSC++; - - // double normFactor = (cscArea*nEvent_*25E-9); - - // for (int k = 0; k < nStrips_; k++) { - // hHitRateCSC[run][chamber_-1][layer_-1]->Fill(instLumi, 1./(normFactor)); - // flag = true; - // } - //} + //if (flag) hHitRateLumi[run][0][0]->Fill(instLumi, 1./(totArea*nEvent_*25E-9)); } output->Write(); @@ -205,13 +225,17 @@ void makeHisto() { } -double findCuts(TH2D* hAllStrip[36][2], int nEvent) { - TH1D* hitHist = new TH1D( "hitHist", "hits per each strip", 500, 0, 4e-4); - hitHist->GetXaxis()->SetTitle("number of hits per each strip"); - hitHist->GetYaxis()->SetTitle("strips"); +array, 36> findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2]) { + array, 36> hitHist; + array, 36> res; for (int iChamber = 26; iChamber < 30; iChamber++) { for (int iLayer = 0; iLayer < 2; iLayer++) { + hitHist[iChamber][iLayer] = new TH1D( Form("hitHist ch %i lay %i", iChamber+1, iLayer+1), + "hits per each strip", 500, 0, 1e-4); + hitHist[iChamber][iLayer]->GetXaxis()->SetTitle("Average number of hits on Strip"); + hitHist[iChamber][iLayer]->GetYaxis()->SetTitle("strips"); if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; + auto nEvent = hInstLumi[iChamber][iLayer]->GetEntries(); auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); for (int iEta = 1; iEta < 9; iEta++) { @@ -221,14 +245,24 @@ double findCuts(TH2D* hAllStrip[36][2], int nEvent) { double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); val = double(val/nEvent); if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; - else if(val >= 4E-4) val = 3.99E-4; - hitHist->Fill((double)val); + //else if(val >= 4E-4) val = 3.99E-4; + hitHist[iChamber][iLayer]->Fill((double)val); } } + hitHist[iChamber][iLayer]->Write(); + res[iChamber][iLayer] = (hitHist[iChamber][iLayer]->GetMean() + 2*hitHist[iChamber][iLayer]->GetRMS()); } } - hitHist->Write(); - double res = (hitHist->GetMean() + 2*hitHist->GetRMS()); - delete hitHist; return res; } + +void rebinHisto(TH1D* h) { + double bins[19]; + for (int i = 0; i < 6; i++) { + bins[i] = i * 0.2; + } + for (int i = 0; i < 13; i++) { + bins[i+6] = i * 0.05 + 1.2; + } + h->SetBins(18, bins); +} From f1a85faf824c7f9108c579e1919dbafa516cc91a Mon Sep 17 00:00:00 2001 From: yechanKang Date: Thu, 6 Sep 2018 15:23:28 +0900 Subject: [PATCH 11/50] update missing part --- MuonAnalyser/test/runSliceTestAnalysis.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index 5973a3b110e..d7d3671e615 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -22,8 +22,9 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -from glob import glob -process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) +process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') +#from glob import glob +#process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) #process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') #fname = 'singleMuon.txt' @@ -40,6 +41,9 @@ gemRecHits = cms.InputTag("gemRecHits"), cscRecHits = cms.InputTag("csc2DRecHits"), muons = cms.InputTag("muons"), + gemDigisAMC = cms.InputTag("muonGEMDigis","AMCStatus"), + gemDigisGEB = cms.InputTag("muonGEMDigis","GEBStatus"), + gemDigisvfat = cms.InputTag("muonGEMDigis","vfatStatus"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), ) From 49e416123e39f8b3a057584069c98a96ff0a6878 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Sun, 9 Sep 2018 19:02:14 +0900 Subject: [PATCH 12/50] add some histogram for drawing background plots --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 46 +++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index f1b61640772..9603b414968 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -51,6 +51,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" #include "TH1D.h" #include "TH2D.h" @@ -75,6 +76,9 @@ class SliceTestAnalysis : public edm::EDAnalyzer { virtual void beginRun(Run const&, EventSetup const&) override; virtual void endRun(Run const&, EventSetup const&) override; + virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; + virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; + // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; edm::EDGetTokenT cscRecHits_; @@ -93,8 +97,13 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; + TH2D* h_activeLumi; + TH1D* h_lumiStatus; + + bool vfatStatus[36][2][24]; + TH2D* h_globalPosOnGem; - TH1D* h_instLumi; + TH1D* h_instLumi[36][2][24]; TH1D* h_pileup; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; @@ -137,7 +146,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_instLumi=fs->make(Form("instLumi"),"instLumi",100,0,10); + h_instLumi[0][0][0]=fs->make(Form("instLumi"),"instLumi",100,0,10); h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); @@ -175,7 +184,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) t_csc->Branch("layer", &b_layer, "layer/I"); t_csc->Branch("nStrips", &b_nStrips, "nStrips/I"); - for (int ichamber=0; ichamber<36;++ichamber) { + for (int ichamber=26; ichamber<30;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { for (int ilayer=0; ilayer<2;++ilayer) { h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber+1, ilayer+1),"firstStrip",384,1,385,8,0.5,8.5); @@ -189,6 +198,13 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); + + for (int vfat = 0; vfat < 24; vfat++) { + h_instLumi[ichamber][ilayer][vfat] = fs->make(Form("instLumi ch %i lay %i", ichamber+1, ilayer+1),"instlumi", 50, 0, 2); + h_instLumi[ichamber][ilayer][vfat]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); + h_instLumi[ichamber][ilayer][vfat]->GetYaxis()->SetTitle("Event"); + vfatStatus[ichamber][ilayer][vfat] = false; + } } } @@ -244,7 +260,8 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet int totalStrips = 0; auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; auto pileup = (lumiScalers->at(0)).pileup(); - h_instLumi->Fill(instLumi); + h_instLumi[0][0][0]->Fill(instLumi); + h_lumiStatus->Fill(instLumi); b_instLumi = instLumi; b_timeHigh = iEvent.time().unixTime(); b_timeLow = iEvent.time().microsecondOffset(); @@ -279,6 +296,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_chamber = rId.chamber(); b_layer = rId.layer(); b_etaPartition = rId.roll(); + int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); + h_activeLumi->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); + vfatStatus[b_chamber-1][b_layer-1][vfat] = true; auto globalPosition = roll->toGlobal(hit->localPosition()); b_x = globalPosition.x(); @@ -291,6 +311,17 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } + for (int ichamber=26; ichamber<30;++ichamber) { + // for (int ichamber=27; ichamber<=30;++ichamber) { + for (int ilayer=0; ilayer<2;++ilayer) { + for (int vfat = 0; vfat < 24; vfat++) { + if (!vfatStatus[ichamber][ilayer][vfat]) continue; + h_instLumi[ichamber][ilayer][vfat]->Fill(instLumi); + vfatStatus[ichamber][ilayer][vfat] = false; + } + } + } + //for (auto ch : CSCGeometry_->chambers()) { // for (auto layer : ch->layers()) { // CSCDetId lId = layer->id(); @@ -321,6 +352,8 @@ void SliceTestAnalysis::beginJob(){} void SliceTestAnalysis::endJob(){} void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ + h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),5000, 0, 5000, 400, 27, 31); + edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; @@ -361,5 +394,10 @@ void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ } void SliceTestAnalysis::endRun(Run const&, EventSetup const&){} +void SliceTestAnalysis::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ + h_lumiStatus = fs->make(Form("%i %i status", lumiBlock.run(), lumiBlock.luminosityBlock()), "", 1000, 0, 2); +} +void SliceTestAnalysis::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} + //define this as a plug-in DEFINE_FWK_MODULE(SliceTestAnalysis); From 0434c17e44d3f7b47041441606dbbeef03eb7de1 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Mon, 10 Sep 2018 13:05:29 +0900 Subject: [PATCH 13/50] checkpoint --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 9603b414968..7ae025977a0 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -34,7 +34,7 @@ #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonData/interface/MuonDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" +//#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" @@ -83,7 +83,7 @@ class SliceTestAnalysis : public edm::EDAnalyzer { edm::EDGetTokenT gemRecHits_; edm::EDGetTokenT cscRecHits_; edm::EDGetTokenT gemDigis_; - edm::EDGetTokenT> gemDigisAMC_; +// edm::EDGetTokenT> gemDigisAMC_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; @@ -138,7 +138,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); muons_ = consumes >(iConfig.getParameter("muons")); - gemDigisAMC_ = consumes>(iConfig.getParameter("gemDigisAMC")); +// gemDigisAMC_ = consumes>(iConfig.getParameter("gemDigisAMC")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); @@ -200,7 +200,7 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); for (int vfat = 0; vfat < 24; vfat++) { - h_instLumi[ichamber][ilayer][vfat] = fs->make(Form("instLumi ch %i lay %i", ichamber+1, ilayer+1),"instlumi", 50, 0, 2); + h_instLumi[ichamber][ilayer][vfat] = fs->make(Form("instLumi ch %i lay %i vfat %i", ichamber+1, ilayer+1, vfat),"instlumi", 50, 0, 2); h_instLumi[ichamber][ilayer][vfat]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); h_instLumi[ichamber][ilayer][vfat]->GetYaxis()->SetTitle("Event"); vfatStatus[ichamber][ilayer][vfat] = false; @@ -242,8 +242,8 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::Handle cscRecHits; iEvent.getByToken(cscRecHits_, cscRecHits); - edm::Handle> gemDigisAMC; - iEvent.getByToken(gemDigisAMC_, gemDigisAMC); +// edm::Handle> gemDigisAMC; +// iEvent.getByToken(gemDigisAMC_, gemDigisAMC); edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); @@ -268,11 +268,11 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet h_pileup->Fill(pileup); b_latency = -1; - for (auto g : *gemDigisAMC) { - for (auto a = g.second.first; a != g.second.second; a++) { - b_latency = a->Param1(); - } - } +// for (auto g : *gemDigisAMC) { +// for (auto a = g.second.first; a != g.second.second; a++) { +// b_latency = a->Param1(); +// } +// } for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { @@ -352,7 +352,7 @@ void SliceTestAnalysis::beginJob(){} void SliceTestAnalysis::endJob(){} void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ - h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),5000, 0, 5000, 400, 27, 31); + h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); From cd88a2f3558cd36043bff6d2496d5813865fa33d Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 11 Sep 2018 22:39:09 +0900 Subject: [PATCH 14/50] add muon branch and csc segment --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 174 ++++++++++++---------- MuonAnalyser/test/runSliceTestAnalysis.py | 12 +- 2 files changed, 103 insertions(+), 83 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 7ae025977a0..b9544e094bc 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -30,11 +30,12 @@ #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonData/interface/MuonDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -//#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" +#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" @@ -46,6 +47,7 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" @@ -81,9 +83,10 @@ class SliceTestAnalysis : public edm::EDAnalyzer { // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; - edm::EDGetTokenT cscRecHits_; + //edm::EDGetTokenT cscRecHits_; + edm::EDGetTokenT cscSegments_; edm::EDGetTokenT gemDigis_; -// edm::EDGetTokenT> gemDigisAMC_; + //edm::EDGetTokenT gemDigisvfat_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; @@ -98,12 +101,10 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TH2D* h_allStrips[36][2]; TH2D* h_activeLumi; + TH2D* h_activeLumi_; TH1D* h_lumiStatus; - bool vfatStatus[36][2][24]; - TH2D* h_globalPosOnGem; - TH1D* h_instLumi[36][2][24]; TH1D* h_pileup; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; @@ -115,19 +116,22 @@ class SliceTestAnalysis : public edm::EDAnalyzer { TTree *t_setup; float b_stripLength[2][8]; float b_stripPitch[2][8]; - float b_cscArea[2]; + float b_cscArea; TTree *t_run; TTree *t_event; int b_run, b_lumi, b_latency; - int b_nGEMHits, b_nCSCHits; + int b_nGEMHits, b_nCSCHits, b_nMuons; float b_instLumi; unsigned int b_timeLow, b_timeHigh; TTree *t_hit; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; float b_x, b_y, b_z; + + TTree *t_muon; + float b_pt, b_eta, b_phi; TTree *t_csc; @@ -136,9 +140,10 @@ class SliceTestAnalysis : public edm::EDAnalyzer { SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); + //cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); + cscSegments_ = consumes(iConfig.getParameter("cscSegments")); muons_ = consumes >(iConfig.getParameter("muons")); -// gemDigisAMC_ = consumes>(iConfig.getParameter("gemDigisAMC")); + //gemDigisvfat_ = consumes(iConfig.getParameter("gemDigisvfat")); vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); @@ -146,7 +151,6 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_instLumi[0][0][0]=fs->make(Form("instLumi"),"instLumi",100,0,10); h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); @@ -158,10 +162,12 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) t_setup = fs->make("Setup", "Setup"); t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); - t_setup->Branch("cscArea", &b_cscArea, "cscArea[2]/F"); + t_setup->Branch("cscArea", &b_cscArea, "cscArea/F"); t_event = fs->make("Event", "Event"); t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); + t_event->Branch("nCSCHits", &b_nCSCHits, "nCSCHits/I"); + t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); t_event->Branch("run", &b_run, "run/I"); t_event->Branch("lumi", &b_lumi, "lumi/I"); t_event->Branch("latency", &b_latency, "latency/I"); @@ -182,7 +188,11 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) t_csc = fs->make("CSC", "CSC"); t_csc->Branch("chamber", &b_chamber, "chamber/I"); t_csc->Branch("layer", &b_layer, "layer/I"); - t_csc->Branch("nStrips", &b_nStrips, "nStrips/I"); + + t_muon = fs->make("muon", "muon"); + t_muon->Branch("pt", &b_pt, "pt/F"); + t_muon->Branch("eta", &b_eta, "eta/F"); + t_muon->Branch("phi", &b_phi, "phi/F"); for (int ichamber=26; ichamber<30;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { @@ -198,13 +208,6 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); - - for (int vfat = 0; vfat < 24; vfat++) { - h_instLumi[ichamber][ilayer][vfat] = fs->make(Form("instLumi ch %i lay %i vfat %i", ichamber+1, ilayer+1, vfat),"instlumi", 50, 0, 2); - h_instLumi[ichamber][ilayer][vfat]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - h_instLumi[ichamber][ilayer][vfat]->GetYaxis()->SetTitle("Event"); - vfatStatus[ichamber][ilayer][vfat] = false; - } } } @@ -223,14 +226,16 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_lumi = iEvent.luminosityBlock(); b_nGEMHits = 0; + b_nCSCHits = 0; + b_nMuons = 0; edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - //edm::ESHandle hCSCGeom; - //iSetup.get().get(hCSCGeom); - //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); theService_->update(iSetup); @@ -239,11 +244,14 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); - edm::Handle cscRecHits; - iEvent.getByToken(cscRecHits_, cscRecHits); + //edm::Handle cscRecHits; + //iEvent.getByToken(cscRecHits_, cscRecHits); + + edm::Handle cscSegments; + iEvent.getByToken(cscSegments_, cscSegments); -// edm::Handle> gemDigisAMC; -// iEvent.getByToken(gemDigisAMC_, gemDigisAMC); + //edm::Handle gemDigisvfat; + //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); @@ -260,7 +268,6 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet int totalStrips = 0; auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; auto pileup = (lumiScalers->at(0)).pileup(); - h_instLumi[0][0][0]->Fill(instLumi); h_lumiStatus->Fill(instLumi); b_instLumi = instLumi; b_timeHigh = iEvent.time().unixTime(); @@ -268,18 +275,33 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet h_pileup->Fill(pileup); b_latency = -1; -// for (auto g : *gemDigisAMC) { -// for (auto a = g.second.first; a != g.second.second; a++) { -// b_latency = a->Param1(); -// } -// } + for (size_t i = 0; i < muons->size(); ++i) { + edm::RefToBase muRef = muons->refAt(i); + const reco::Muon* mu = muRef.get(); + + const reco::Track* muonTrack = 0; + if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + if (muonTrack) { + b_pt = muonTrack->pt(); + b_eta = muonTrack->eta(); + b_phi = muonTrack->phi(); + if (b_eta < -2.15 or b_eta > -1.6) continue; + t_muon->Fill(); + b_nMuons++; + } + } + for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); auto recHitsRange = gemRecHits->get(rId); auto gemRecHit = recHitsRange.first; + b_chamber = rId.chamber(); + b_layer = rId.layer(); + b_etaPartition = rId.roll(); for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { @@ -293,12 +315,8 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_firstStrip = hit->firstClusterStrip(); b_nStrips = hit->clusterSize(); - b_chamber = rId.chamber(); - b_layer = rId.layer(); - b_etaPartition = rId.roll(); int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); h_activeLumi->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); - vfatStatus[b_chamber-1][b_layer-1][vfat] = true; auto globalPosition = roll->toGlobal(hit->localPosition()); b_x = globalPosition.x(); @@ -308,41 +326,40 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet t_hit->Fill(); b_nGEMHits++; } + + //auto gemVfatRange = gemDigisvfat->get(rId); + // + //for (auto vfatStatus = gemVfatRange.first; vfatStatus != gemVfatRange.second; vfatStatus++) { + // auto ix = vfatStatus->position(); + // int vfat = 8-b_etaPartition+8*ix; + // bool flag = int(vfatStatus->flag()) != 0; + // flag = int(vfatStatus->quality()) != 0; + // if (!flag) h_activeLumi_->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); + //} } + } - for (int ichamber=26; ichamber<30;++ichamber) { - // for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=0; ilayer<2;++ilayer) { - for (int vfat = 0; vfat < 24; vfat++) { - if (!vfatStatus[ichamber][ilayer][vfat]) continue; - h_instLumi[ichamber][ilayer][vfat]->Fill(instLumi); - vfatStatus[ichamber][ilayer][vfat] = false; + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + if (lId.station() != 1) continue; + if (lId.endcap() != 2) continue; + if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + auto segmentsRange = cscSegments->get(lId); + auto cscSegment = segmentsRange.first; + + for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { + b_chamber = lId.chamber(); + b_layer = lId.layer(); + + t_csc->Fill(); + b_nCSCHits++; } } } - //for (auto ch : CSCGeometry_->chambers()) { - // for (auto layer : ch->layers()) { - // CSCDetId lId = layer->id(); - // if (lId.station() != 1) continue; - // if (lId.endcap() != 2) continue; - // if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - // auto recHitsRange = cscRecHits->get(lId); - // auto cscRecHit = recHitsRange.first; - // - // for (auto hit = cscRecHit; hit != recHitsRange.second; ++hit) { - // b_nStrips = hit->nStrips(); - // b_chamber = lId.chamber(); - // b_layer = lId.layer(); - - // t_csc->Fill(); - // b_nCSCHits++; - // } - // } - //} - h_totalStrips->Fill(totalStrips); t_event->Fill(); @@ -353,6 +370,7 @@ void SliceTestAnalysis::endJob(){} void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); + h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); @@ -375,19 +393,19 @@ void SliceTestAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ } } - //for (auto ch : CSCGeometry_->chambers()) { - // for (auto layer : ch->layers()) { - // CSCDetId lId = layer->id(); - // if (lId.station() != 1) continue; - // if (lId.endcap() != 2) continue; - // if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - // const OffsetRadialStripTopology* top_(dynamic_cast(&(layer->topology()))); - // const float striplength(top_->stripLength()); - // const float pitch(top_->pitch()); - // b_cscArea[lId.chamber()%2] = striplength * pitch * top_->nstrips(); - // } - //} + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + if (lId.station() != 1) continue; + if (lId.endcap() != 2) continue; + if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + const float striplength(top_->stripLength()); + const float pitch(layer->geometry()->stripPitch()); + b_cscArea = striplength * pitch * top_->nstrips(); + } + } b_run = run.run(); t_run->Fill(); diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py index d7d3671e615..c3224775d67 100644 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ b/MuonAnalyser/test/runSliceTestAnalysis.py @@ -22,7 +22,8 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') +process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv5/AOD_000.root') +#process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') #from glob import glob #process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) #process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') @@ -39,11 +40,12 @@ process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), - cscRecHits = cms.InputTag("csc2DRecHits"), + #cscRecHits = cms.InputTag("csc2DRecHits"), + cscSegments = cms.InputTag("cscSegments"), muons = cms.InputTag("muons"), - gemDigisAMC = cms.InputTag("muonGEMDigis","AMCStatus"), - gemDigisGEB = cms.InputTag("muonGEMDigis","GEBStatus"), - gemDigisvfat = cms.InputTag("muonGEMDigis","vfatStatus"), + #gemDigisAMC = cms.InputTag("muonGEMDigis","AMCStatus"), + #gemDigisGEB = cms.InputTag("muonGEMDigis","GEBStatus"), + #gemDigisvfat = cms.InputTag("muonGEMDigis","vfatStatus"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), ) From a06024aedb88f56c90748b2cc13c10a14e101baf Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 11 Sep 2018 23:02:38 +0900 Subject: [PATCH 15/50] fix csc segments --- MuonAnalyser/plugins/SliceTestAnalysis.cc | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index b9544e094bc..437f6519531 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -341,22 +341,19 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } for (auto ch : CSCGeometry_->chambers()) { - for (auto layer : ch->layers()) { - CSCDetId lId = layer->id(); - if (lId.station() != 1) continue; - if (lId.endcap() != 2) continue; - if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - auto segmentsRange = cscSegments->get(lId); - auto cscSegment = segmentsRange.first; - - for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { - b_chamber = lId.chamber(); - b_layer = lId.layer(); - - t_csc->Fill(); - b_nCSCHits++; - } + CSCDetId cId = ch->id(); + if (cId.station() != 1) continue; + if (cId.endcap() != 2) continue; + if (cId.chamber() < 27 or cId.chamber() > 30) continue; + + auto segmentsRange = cscSegments->get(cId); + auto cscSegment = segmentsRange.first; + + for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { + b_chamber = cId.chamber(); + + t_csc->Fill(); + b_nCSCHits++; } } From 0622afe74fa69405e973218c3c328183e69a877b Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 11 Sep 2018 23:13:21 +0900 Subject: [PATCH 16/50] remove personal script --- MuonAnalyser/test/fillHisto.cc | 337 --------------------------------- MuonAnalyser/test/makeHisto.cc | 268 -------------------------- 2 files changed, 605 deletions(-) delete mode 100644 MuonAnalyser/test/fillHisto.cc delete mode 100644 MuonAnalyser/test/makeHisto.cc diff --git a/MuonAnalyser/test/fillHisto.cc b/MuonAnalyser/test/fillHisto.cc deleted file mode 100644 index c8648ed2e18..00000000000 --- a/MuonAnalyser/test/fillHisto.cc +++ /dev/null @@ -1,337 +0,0 @@ -array findCuts(TH2D*[36][2], TH1D*[36][2][24]); -array findCuts(TH2D*[36][2], TH1D*[36][2]); - -void rebinHisto(TH1D* h); - -void fillHisto() { - int lumiFill = 7058; - TFile* input = TFile::Open(Form("data/histo_%i.root", lumiFill), "READ"); - - int iHit = 0; - int iCSC = 0; - int run_; - - TFile* output = TFile::Open(Form("output_%i.root", lumiFill), "RECREATE"); - TTree* runTree = new TTree("runTree", "runTree"); - - // Load Geometry Setup - float stripLength[2][8]; - float stripPitch[2][8]; - float cscArea; - TTree* t_setup = (TTree*) input->Get("SliceTestAnalysis/Setup"); - t_setup->SetBranchAddress("stripLength", stripLength); - t_setup->SetBranchAddress("stripPitch", stripPitch); - t_setup->SetBranchAddress("cscArea", &cscArea); - t_setup->GetEntry(0); - float trArea[36][2][8]; - float chArea[36][2]; - float vfatArea[36][2][24]; - float totArea; - - // Load RecHits - int chamber, layer, etaPartition, firstStrip, nStrips; - TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); - t_Hit->SetBranchAddress("chamber", &chamber); - t_Hit->SetBranchAddress("layer", &layer); - t_Hit->SetBranchAddress("etaPartition", &etaPartition); - t_Hit->SetBranchAddress("firstStrip", &firstStrip); - t_Hit->SetBranchAddress("nStrips", &nStrips); - - // Prepare get info about active areas - TH2D* hAllStrip[36][2]; - TH2D* hMaskedStrip[36][2]; - int nOfActiveStrip[36][2][8]; - int nOfActiveStripVfat[36][2][24]; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - hAllStrip[iChamber][iLayer] = (TH2D*) input->Get(Form("SliceTestAnalysis/allStrips ch %i lay %i", iChamber+1, iLayer+1)); - - hMaskedStrip[iChamber][iLayer] = new TH2D(Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); - hMaskedStrip[iChamber][iLayer]->GetXaxis()->SetTitle("Strip"); - hMaskedStrip[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - - for (int iEta = 1; iEta < 9; iEta++) { - nOfActiveStrip[iChamber][iLayer][iEta-1] = 0; - for (int iStrip = 1; iStrip < 385; iStrip++) { - hMaskedStrip[iChamber][iLayer]->Fill(iStrip, iEta); - } - } - for (int vfat = 0; vfat < 24; vfat++) { - nOfActiveStripVfat[iChamber][iLayer][vfat] =0; - } - } - } - - // Load Event - int run, lumi, nGEMHits, nCSCHits; - float instLumi; - TTree* t_Event = (TTree*) input->Get("SliceTestAnalysis/Event"); - t_Event->SetBranchAddress("run", &run); - t_Event->SetBranchAddress("lumi", &lumi); - t_Event->SetBranchAddress("nGEMHits", &nGEMHits); - t_Event->SetBranchAddress("nCSCHits", &nCSCHits); - t_Event->SetBranchAddress("instLumi", &instLumi); - - int nEvent = t_Event->GetEntries(); - map nRunEvent; - map> nLumiEvent; - map> hLumiStatus; - map hActiveLumi; - TH1D* hInstLumi [36][2][24]; - TH1D* hHitRateEta [36][2][8]; - TH1D* hHitRateLumi[36][2]; - TH2D* hAllStrips [36][2]; - TH2D* hHitRateVfat[36][2]; - TH1D* hHitRateCSC [36][2]; - - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - for (int vfat = 0; vfat < 24; vfat++) { - hInstLumi[iChamber][iLayer][vfat] = new TH1D(Form("instLumi ch %i layer %i vfat %i", iChamber+1, iLayer+1, vfat), "instLumi", 50, 0, 2); - hInstLumi[iChamber][iLayer][vfat]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hInstLumi[iChamber][iLayer][vfat]->GetYaxis()->SetTitle("Event"); - } - - hHitRateLumi[iChamber][iLayer] = new TH1D(Form("hitRate ch %i layer %i", iChamber+1, iLayer+1), Form("Run number"), 50, 0, 2); - hHitRateLumi[iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hHitRateLumi[iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); - hHitRateLumi[iChamber][iLayer]->SetMarkerSize(2); - - for (int iEta = 0; iEta < 8; iEta++) { - hHitRateEta[iChamber][iLayer][iEta] = new TH1D(Form("hitRate ch %i layer %i eta %i", iChamber+1, iLayer+1, iEta+1), Form("Run number"), 50, 0, 2); - hHitRateEta[iChamber][iLayer][iEta]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hHitRateEta[iChamber][iLayer][iEta]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); - hHitRateEta[iChamber][iLayer][iEta]->SetMarkerSize(2); - } - - hHitRateVfat[iChamber][iLayer] = new TH2D(Form("vfat ch %i layer %i", iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 3, 0.5, 384.5, 8, 0.5, 8.5); - hHitRateVfat[iChamber][iLayer]->GetXaxis()->SetTitle("strip"); - hHitRateVfat[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - - hAllStrips[iChamber][iLayer] = new TH2D(Form("allStrips ch %i layer %i", iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); - hAllStrips[iChamber][iLayer]->GetXaxis()->SetTitle("strip"); - hAllStrips[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - } - } - - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - nRunEvent[run]++; - nLumiEvent[run][lumi]++; - } - for (auto iter = nRunEvent.begin(); iter != nRunEvent.end(); iter++) { - run_ = iter->first; - hActiveLumi[run_] = new TH2D(Form("%i activeLumi", run_), Form("Run number %i", run_), 1000, 0, 4000, 400, 27, 31); - hActiveLumi[run_]->GetXaxis()->SetTitle("luminosityBlock"); - hActiveLumi[run_]->GetYaxis()->SetTitle("chamber + layer/2 + vfat/48"); - } - for (auto iter = nLumiEvent.begin(); iter != nLumiEvent.end(); iter++) { - run_ = iter->first; - auto lumiMap = iter->second; - for (auto iter_ = lumiMap.begin(); iter_ != lumiMap.end(); iter_++) { - auto lumi_ = iter_->first; - hLumiStatus[run_][lumi_] = new TH1D(Form("%i %i lumiStatus", run_, lumi_), Form("Run number %i lumi %i", run_, lumi_), 1000, 0, 2); - hLumiStatus[run_][lumi_]->GetXaxis()->SetTitle("Instantaneous Luminosity [10^{34}cm^{-2}s^{-1}]"); - } - } - - iHit = 0; - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - hLumiStatus[run][lumi]->Fill(instLumi); - for (int j = 0; j < nGEMHits; j++) { - t_Hit->GetEntry(iHit); - auto vfat = (8-etaPartition)+8*((firstStrip-1)/128); - iHit++; - hActiveLumi[run]->Fill(lumi,(chamber+(layer-1)*0.5+vfat/48.)); - } - } - - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - if (hLumiStatus[run][lumi]->GetRMS() > 0.01) continue; - auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); - for (int iChamber = 27; iChamber < 31; iChamber++) { - for (int iLayer = 1; iLayer < 3; iLayer++) { - for (int vfat = 0; vfat < 24; vfat++) { - //auto fromBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5); - //auto toBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+23/48.); - auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+vfat/48.); - if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) != 0) hInstLumi[iChamber-1][iLayer-1][vfat]->Fill(instLumi); - } - } - } - } - - cout << "test\n"; - auto cut = findCuts(hAllStrip, hInstLumi); - - cout << "test\n"; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; - auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); - auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); - for (int iEta = 1; iEta < 9; iEta++) { - auto yBin = yAxis->FindBin(iEta); - for (int iStrip = 1; iStrip < 385; iStrip++) { - auto xBin = xAxis->FindBin(iStrip); - auto vfat = (8-iEta)+8*((iStrip-1)/128); - double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); - if (val < 1) continue; - int nEvent_ = hInstLumi[iChamber][iLayer][vfat]->GetEntries(); - val = double(val/nEvent_); - if (val > cut[iEta-1]) continue; - hMaskedStrip[iChamber][iLayer]->SetBinContent(xBin, yBin, 0); - nOfActiveStrip[iChamber][iLayer][iEta-1]++; - nOfActiveStripVfat[iChamber][iLayer][vfat]++; - } - } - } - } - - totArea = 0; - for ( int ch = 0; ch < 36; ch++ ) { - for ( int ly = 0; ly < 2; ly++) { - chArea[ch][ly] = 0; - for ( int et = 0; et < 8; et++) { - trArea[ch][ly][et] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStrip[ch][ly][et]); - chArea[ch][ly] += trArea[ch][ly][et]; - for ( int ix = 0; ix < 3; ix++) { - auto vfat = (8-et+1)+8*(ix); - vfatArea[ch][ly][vfat] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStripVfat[ch][ly][vfat]); - } - } - totArea += chArea[ch][ly]; - } - } - - cout << "test\n"; - bool flag; - iHit = 0; - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - flag = false; - auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); - for (int j = 0; j < nGEMHits; j++) { - t_Hit->GetEntry(iHit); - iHit++; - if(hLumiStatus[run][lumi]->GetRMS() > 0.01) continue; - auto vfat = (8-etaPartition)+8*((firstStrip-1)/128); - auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat/48.); - if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) < 1) continue; - - double chArea_ = 0; - for (int vfat_ = 0; vfat_ < 24; vfat_++) { - auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat_/48.); - if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) > 0) - chArea_ += vfatArea[chamber-1][layer-1][vfat_]; - } - double etaArea_ = 0; - for (int ix = 0; ix < 3; ix++) { - auto vfat_ = (8-etaPartition)+8*ix; - auto chanBin = hActiveLumi[run]->GetYaxis()->FindBin(chamber+(layer-1)*0.5+vfat_/48.); - if (hActiveLumi[run]->Integral(lumiBin, lumiBin, chanBin, chanBin) > 0) - etaArea_ += vfatArea[chamber-1][layer-1][vfat_]; - } - - int nEvent_ = hInstLumi[chamber-1][layer-1][vfat]->GetBinContent(hInstLumi[chamber-1][layer-1][vfat]->GetXaxis()->FindBin(instLumi)); - auto etaBin = hAllStrip[chamber-1][layer-1]->GetYaxis()->FindBin(etaPartition); - - double normFactor = (chArea_*nEvent_*25E-9); - - auto xBin = hMaskedStrip[chamber-1][layer-1]->GetXaxis()->FindBin(firstStrip); - if(hMaskedStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin) != 0) continue; - hAllStrips[chamber-1][layer-1]->Fill(firstStrip, etaPartition); - hHitRateLumi[chamber-1][layer-1]->Fill(instLumi, 1./(normFactor)); - hHitRateEta[chamber-1][layer-1][etaPartition-1]->Fill(instLumi, 1./(etaArea_*nEvent_*25E-9)); - double normFactorVfat = (vfatArea[chamber-1][layer-1][vfat]*nEvent_*25E-9); - hHitRateVfat[chamber-1][layer-1]->Fill(firstStrip, etaPartition, 1./(normFactorVfat)); - flag = true; - } - } - cout << "test\n"; - - output->Write(); - output->Close(); -} - - -array findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2]) { - TH1D* hitHist[8]; - for (int iEta = 0; iEta < 8; iEta++) { - hitHist[iEta] = new TH1D( Form("hitHist eta %i", iEta+1), - "hits per each strip", 500, 0, 1e-4); - hitHist[iEta]->GetXaxis()->SetTitle("Average number of hits on Strip"); - hitHist[iEta]->GetYaxis()->SetTitle("strips"); - } - array res; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; - auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); - auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); - for (int iEta = 1; iEta < 9; iEta++) { - auto yBin = yAxis->FindBin(iEta); - for (int iStrip = 1; iStrip < 386; iStrip++) { - auto nEvent_ = hInstLumi[iChamber][iLayer]->GetEntries(); - auto xBin = xAxis->FindBin(iStrip); - double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); - val = double(val/nEvent_); - if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; - hitHist[iEta-1]->Fill((double)val); - } - } - } - } - for (int iEta = 0; iEta < 8; iEta++) { - res[iEta] = (hitHist[iEta]->GetMean() + 2*hitHist[iEta]->GetRMS()); - } - return res; -} - -void rebinHisto(TH1D* h) { - double bins[19]; - for (int i = 0; i < 6; i++) { - bins[i] = i * 0.2; - } - for (int i = 0; i < 13; i++) { - bins[i+6] = i * 0.05 + 1.2; - } - h->SetBins(18, bins); -} - -array findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2][24]) { - TH1D* hitHist[8]; - for (int iEta = 0; iEta < 8; iEta++) { - hitHist[iEta] = new TH1D( Form("hitHist eta %i", iEta+1), - "hits per each strip", 500, 0, 1e-4); - hitHist[iEta]->GetXaxis()->SetTitle("Average number of hits on Strip"); - hitHist[iEta]->GetYaxis()->SetTitle("strips"); - } - array res; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; - auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); - auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); - for (int iEta = 1; iEta < 9; iEta++) { - auto yBin = yAxis->FindBin(iEta); - for (int iStrip = 1; iStrip < 385; iStrip++) { - auto vfat = (8-iEta)+8*((iStrip-1)/128); - auto nEvent_ = hInstLumi[iChamber][iLayer][vfat]->GetEntries(); - auto xBin = xAxis->FindBin(iStrip); - double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); - val = double(val/nEvent_); - if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; - hitHist[iEta-1]->Fill((double)val); - } - } - } - } - for (int iEta = 0; iEta < 8; iEta++) { - res[iEta] = (hitHist[iEta]->GetMean() + 2*hitHist[iEta]->GetRMS()); - } - return res; -} - diff --git a/MuonAnalyser/test/makeHisto.cc b/MuonAnalyser/test/makeHisto.cc deleted file mode 100644 index eeaf0dc5173..00000000000 --- a/MuonAnalyser/test/makeHisto.cc +++ /dev/null @@ -1,268 +0,0 @@ -array, 36> findCuts(TH2D*[36][2], TH1D*[36][2]); - -void rebinHisto(TH1D* h); - -void makeHisto() { - int runNumber = 321397; - int lumiFill = 7058; - TFile* input = TFile::Open(Form("data/histo_%i.root", lumiFill), "READ"); - - int iHit = 0; - int iCSC = 0; - int run_; - - TFile* output = TFile::Open(Form("output_%i.root", lumiFill), "RECREATE"); - TTree* runTree = new TTree("runTree", "runTree"); - runTree->Branch("run", &run_, "run/I"); - - // Load Geometry Setup - float stripLength[2][8]; - float stripPitch[2][8]; - float cscArea; - TTree* t_setup = (TTree*) input->Get("SliceTestAnalysis/Setup"); - t_setup->SetBranchAddress("stripLength", stripLength); - t_setup->SetBranchAddress("stripPitch", stripPitch); - t_setup->SetBranchAddress("cscArea", &cscArea); - t_setup->GetEntry(0); - float trArea[36][2][8]; - float chArea[36][2]; - float vfatArea[36][2][8][3]; - float totArea; - - // Load RecHits - int chamber, layer, etaPartition, firstStrip, nStrips; - TTree* t_Hit = (TTree*) input->Get("SliceTestAnalysis/Hit"); - t_Hit->SetBranchAddress("chamber", &chamber); - t_Hit->SetBranchAddress("layer", &layer); - t_Hit->SetBranchAddress("etaPartition", &etaPartition); - t_Hit->SetBranchAddress("firstStrip", &firstStrip); - t_Hit->SetBranchAddress("nStrips", &nStrips); - - // Prepare get info about active areas - TH2D* hAllStrip[36][2]; - TH2D* hMaskedStrip[36][2]; - int nOfActiveStrip[36][2][8]; - int nOfActiveStripVfat[36][2][8][3]; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - hAllStrip[iChamber][iLayer] = (TH2D*) input->Get(Form("SliceTestAnalysis/allStrips ch %i lay %i", iChamber+1, iLayer+1)); - - hMaskedStrip[iChamber][iLayer] = new TH2D(Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), Form("maskedStrip ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); - hMaskedStrip[iChamber][iLayer]->GetXaxis()->SetTitle("Strip"); - hMaskedStrip[iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - - for (int iEta = 1; iEta < 9; iEta++) { - nOfActiveStrip[iChamber][iLayer][iEta-1] = 0; - for (int iStrip = 1; iStrip < 385; iStrip++) { - hMaskedStrip[iChamber][iLayer]->Fill(iStrip, iEta); - } - for (int iStrip = 0; iStrip < 3; iStrip++) { - nOfActiveStripVfat[iChamber][iLayer][iEta-1][iStrip] =0; - } - } - } - } - - // Load Event - int run, lumi, nGEMHits, nCSCHits; - float instLumi; - TTree* t_Event = (TTree*) input->Get("SliceTestAnalysis/Event"); - t_Event->SetBranchAddress("run", &run); - t_Event->SetBranchAddress("lumi", &lumi); - t_Event->SetBranchAddress("nGEMHits", &nGEMHits); - t_Event->SetBranchAddress("nCSCHits", &nCSCHits); - t_Event->SetBranchAddress("instLumi", &instLumi); - - int nEvent = t_Event->GetEntries(); - map nRunEvent; - map> nLumiEvent; - map hActiveLumi; - map hInstLumi; - map hHitRateLumi; - map hAllStrips; - map hHitRateVfat; - map hHitRateCSC; - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - nRunEvent[run]++; - nLumiEvent[run][lumi]++; - } - for (auto iter = nRunEvent.begin(); iter != nRunEvent.end(); iter++) { - run_ = iter->first; - hHitRateLumi[run_][0][0] = new TH1D(Form("%i hitRate", run_), Form("Run number %i", run_), 50, 0, 2); - hHitRateLumi[run_][0][0]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hHitRateLumi[run_][0][0]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); - - hActiveLumi[run_] = new TH2D(Form("%i activeLumi", run_), Form("Run number %i", run_), 4000, 0, 4000, 10000, 27, 31); - hActiveLumi[run_]->GetXaxis()->SetTitle("lumi block"); - hActiveLumi[run_]->GetYaxis()->SetTitle("chamber + layer/2 + iEta/20"); - - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - hInstLumi[run_][iChamber][iLayer] = new TH1D(Form("%i instLumi ch %i layer %i", run_, iChamber+1, iLayer+1), "instLumi", 50, 0, 2); - hInstLumi[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hInstLumi[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Event"); - //rebinHisto(hInstLumi[run_]); - - hHitRateLumi[run_][iChamber][iLayer] = new TH1D(Form("%i hitRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); - hHitRateLumi[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - hHitRateLumi[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); - hHitRateLumi[run_][iChamber][iLayer]->SetMarkerSize(2); - //rebinHisto(hHitRateLumi[run_][iChamber][iLayer]); - - //hHitRateCSC[run_][iChamber][iLayer] = new TH1D(Form("%i cscRate ch %i layer %i", run_, iChamber+1, iLayer+1), Form("Run number %i", run_), 50, 0, 2); - //hHitRateCSC[run_][iChamber][iLayer]->GetXaxis()->SetTitle("instantaneous luminosity[cm^{-2}s^{-1}]"); - //hHitRateCSC[run_][iChamber][iLayer]->GetYaxis()->SetTitle("Hit rate[Hz/cm^{2}]"); - //hHitRateCSC[run_][iChamber][iLayer]->SetMarkerSize(2); - - hHitRateVfat[run_][iChamber][iLayer] = new TH2D(Form("%i vfat ch %i layer %i", run_, iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 3, 0.5, 384.5, 8, 0.5, 8.5); - hHitRateVfat[run_][iChamber][iLayer]->GetXaxis()->SetTitle("strip"); - hHitRateVfat[run_][iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - - hAllStrips[run_][iChamber][iLayer] = new TH2D(Form("%i allStrips ch %i layer %i", run_, iChamber+1, iLayer+1), Form("ch %i layer %i", iChamber+1, iLayer+1), 384, 1, 385, 8, 0.5, 8.5); - hAllStrips[run_][iChamber][iLayer]->GetXaxis()->SetTitle("strip"); - hAllStrips[run_][iChamber][iLayer]->GetYaxis()->SetTitle("iEta"); - } - } - runTree->Fill(); - } - iHit = 0; - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - for (int j = 0; j < nGEMHits; j++) { - t_Hit->GetEntry(iHit); - iHit++; - hActiveLumi[run]->Fill(lumi,(chamber+(layer-1)*0.5+etaPartition*0.05)); - } - } - - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - for (int iChamber = 27; iChamber < 31; iChamber++) { - for (int iLayer = 1; iLayer < 3; iLayer++) { - auto lumiBin = hActiveLumi[run]->GetXaxis()->FindBin(lumi); - auto fromBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+0.05); - auto toBin = hActiveLumi[run]->GetYaxis()->FindBin(iChamber+(iLayer-1)*0.5+0.05*8); - if (hActiveLumi[run]->Integral(lumiBin, lumiBin, fromBin, toBin) != 0) - hInstLumi[run][iChamber-1][iLayer-1]->Fill(instLumi); - } - } - } - - //int chamber_, layer_, nStrips_; - //TTree* t_csc = (TTree*) input->Get("SliceTestAnalysis/csc"); - //t_csc->SetBranchAddress("chamber", &chamber_); - //t_csc->SetBranchAddress("layer", &layer_); - //t_csc->SetBranchAddress("nStrips", &nStrips_); - - auto cut = findCuts(hAllStrip, hInstLumi[runNumber]); - - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; - auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); - auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); - for (int iEta = 1; iEta < 9; iEta++) { - auto yBin = yAxis->FindBin(iEta); - for (int iStrip = 1; iStrip < 385; iStrip++) { - auto xBin = xAxis->FindBin(iStrip); - double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); - if (val < 1) continue; - int nEvent_ = hInstLumi[runNumber][iChamber][iLayer]->GetEntries(); - val = double(val/nEvent); - if (val > cut[iChamber][iLayer]) continue; - hMaskedStrip[iChamber][iLayer]->SetBinContent(xBin, yBin, 0); - nOfActiveStrip[iChamber][iLayer][iEta-1]++; - nOfActiveStripVfat[iChamber][iLayer][iEta-1][iStrip/128]++; - } - } - } - } - - totArea = 0; - for ( int ch = 0; ch < 36; ch++ ) { - for ( int ly = 0; ly < 2; ly++) { - chArea[ch][ly] = 0; - for ( int et = 0; et < 8; et++) { - trArea[ch][ly][et] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStrip[ch][ly][et]); - chArea[ch][ly] += trArea[ch][ly][et]; - for ( int ix = 0; ix < 3; ix++) vfatArea[ch][ly][et][ix] = stripLength[(ch+1)%2][et] * stripPitch[(ch+1)%2][et] * (nOfActiveStripVfat[ch][ly][et][ix]); - } - totArea += chArea[ch][ly]; - } - } - - bool flag; - iHit = 0; - for (int i = 0; i < nEvent; i++) { - t_Event->GetEntry(i); - flag = false; - for (int j = 0; j < nGEMHits; j++) { - t_Hit->GetEntry(iHit); - iHit++; - - int nEvent_ = hInstLumi[run][chamber-1][layer-1]->GetBinContent(hInstLumi[run][chamber-1][layer-1]->GetXaxis()->FindBin(instLumi)); - if (nEvent_ == 0) continue; - auto etaBin = hAllStrip[chamber-1][layer-1]->GetYaxis()->FindBin(etaPartition); - - double normFactor = (chArea[chamber-1][layer-1]*nEvent_*25E-9); - - for (int k = 0; k < nStrips; k++) { - auto xBin = hAllStrip[chamber-1][layer-1]->GetXaxis()->FindBin(firstStrip+k); - if(hAllStrip[chamber-1][layer-1]->GetBinContent(xBin, etaBin)/nEvent > cut[chamber-1][layer-1]) continue; - hAllStrips[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition); - hHitRateLumi[run][chamber-1][layer-1]->Fill(instLumi, 1./(normFactor)); - double normFactorVfat = (vfatArea[chamber-1][layer-1][etaPartition-1][(firstStrip+k)/128]*nEvent_*25E-9); - hHitRateVfat[run][chamber-1][layer-1]->Fill(firstStrip+k, etaPartition, 1./(normFactorVfat)); - flag = true; - } - } - //if (flag) hHitRateLumi[run][0][0]->Fill(instLumi, 1./(totArea*nEvent_*25E-9)); - } - - output->Write(); - output->Close(); -} - - -array, 36> findCuts(TH2D* hAllStrip[36][2], TH1D* hInstLumi[36][2]) { - array, 36> hitHist; - array, 36> res; - for (int iChamber = 26; iChamber < 30; iChamber++) { - for (int iLayer = 0; iLayer < 2; iLayer++) { - hitHist[iChamber][iLayer] = new TH1D( Form("hitHist ch %i lay %i", iChamber+1, iLayer+1), - "hits per each strip", 500, 0, 1e-4); - hitHist[iChamber][iLayer]->GetXaxis()->SetTitle("Average number of hits on Strip"); - hitHist[iChamber][iLayer]->GetYaxis()->SetTitle("strips"); - if (hAllStrip[iChamber][iLayer]->GetEntries() == 0) continue; - auto nEvent = hInstLumi[iChamber][iLayer]->GetEntries(); - auto xAxis = hAllStrip[iChamber][iLayer]->GetXaxis(); - auto yAxis = hAllStrip[iChamber][iLayer]->GetYaxis(); - for (int iEta = 1; iEta < 9; iEta++) { - auto yBin = yAxis->FindBin(iEta); - for (int iStrip = 1; iStrip < 385; iStrip++) { - auto xBin = xAxis->FindBin(iStrip); - double val = hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin); - val = double(val/nEvent); - if (hAllStrip[iChamber][iLayer]->GetBinContent(xBin, yBin) == 0) continue; - //else if(val >= 4E-4) val = 3.99E-4; - hitHist[iChamber][iLayer]->Fill((double)val); - } - } - hitHist[iChamber][iLayer]->Write(); - res[iChamber][iLayer] = (hitHist[iChamber][iLayer]->GetMean() + 2*hitHist[iChamber][iLayer]->GetRMS()); - } - } - return res; -} - -void rebinHisto(TH1D* h) { - double bins[19]; - for (int i = 0; i < 6; i++) { - bins[i] = i * 0.2; - } - for (int i = 0; i < 13; i++) { - bins[i+6] = i * 0.05 + 1.2; - } - h->SetBins(18, bins); -} From 9b589f72ccf9c717e84b2a73b3c883829ad8d2bd Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 28 Sep 2018 20:46:37 +0900 Subject: [PATCH 17/50] rename bkg analysis to avoid confilict --- MuonAnalyser/plugins/SliceTestAnalysisBkg.cc | 418 +++++++++++++++++++ MuonAnalyser/test/runSliceTestAnalysisBkg.py | 52 +++ 2 files changed, 470 insertions(+) create mode 100644 MuonAnalyser/plugins/SliceTestAnalysisBkg.cc create mode 100644 MuonAnalyser/test/runSliceTestAnalysisBkg.py diff --git a/MuonAnalyser/plugins/SliceTestAnalysisBkg.cc b/MuonAnalyser/plugins/SliceTestAnalysisBkg.cc new file mode 100644 index 00000000000..4f222b4d640 --- /dev/null +++ b/MuonAnalyser/plugins/SliceTestAnalysisBkg.cc @@ -0,0 +1,418 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +#include "DataFormats/Scalers/interface/LumiScalers.h" +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" + +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCLayer.h" +#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class SliceTestAnalysisBkg : public edm::EDAnalyzer { +public: + explicit SliceTestAnalysisBkg(const edm::ParameterSet&); + ~SliceTestAnalysisBkg(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; + virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; + + // ----------member data --------------------------- + edm::EDGetTokenT gemRecHits_; + //edm::EDGetTokenT cscRecHits_; + edm::EDGetTokenT cscSegments_; + edm::EDGetTokenT gemDigis_; + //edm::EDGetTokenT gemDigisvfat_; + edm::EDGetTokenT > muons_; + edm::EDGetTokenT vertexCollection_; + edm::EDGetTokenT lumiScalers_; + edm::Service fs; + + MuonServiceProxy* theService_; + edm::ESHandle propagator_; + edm::ESHandle ttrackBuilder_; + edm::ESHandle bField_; + + TH2D* h_firstStrip[36][2]; + TH2D* h_allStrips[36][2]; + + TH2D* h_activeLumi; + TH2D* h_activeLumi_; + TH1D* h_lumiStatus; + + TH2D* h_globalPosOnGem; + TH1D* h_pileup; + TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; + TH1D* h_inEta[36][2]; + TH1D* h_hitEta[36][2]; + TH1D* h_trkEta[36][2]; + + TH1D* h_res_x, *h_res_y, *h_pull_x, *h_pull_y; + + TTree *t_setup; + float b_stripLength[2][8]; + float b_stripPitch[2][8]; + float b_cscArea; + + TTree *t_run; + + TTree *t_event; + int b_run, b_lumi, b_latency; + int b_nGEMHits, b_nCSCHits, b_nMuons; + float b_instLumi; + unsigned int b_timeLow, b_timeHigh; + + TTree *t_hit; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; + float b_x, b_y, b_z; + + TTree *t_muon; + float b_pt, b_eta, b_phi; + + TTree *t_csc; + +}; + +SliceTestAnalysisBkg::SliceTestAnalysisBkg(const edm::ParameterSet& iConfig) +{ + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + //cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); + cscSegments_ = consumes(iConfig.getParameter("cscSegments")); + muons_ = consumes >(iConfig.getParameter("muons")); + //gemDigisvfat_ = consumes(iConfig.getParameter("gemDigisvfat")); + vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); + lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); + edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); + theService_ = new MuonServiceProxy(serviceParameters); + + h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); + h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); + h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); + h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); + + h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); + + t_run = fs->make("Run", "Run"); + t_run->Branch("run", &b_run, "run/I"); + + t_setup = fs->make("Setup", "Setup"); + t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); + t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); + t_setup->Branch("cscArea", &b_cscArea, "cscArea/F"); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); + t_event->Branch("nCSCHits", &b_nCSCHits, "nCSCHits/I"); + t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); + t_event->Branch("run", &b_run, "run/I"); + t_event->Branch("lumi", &b_lumi, "lumi/I"); + t_event->Branch("latency", &b_latency, "latency/I"); + t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); + t_event->Branch("timeLow", &b_timeLow, "timeLow/i"); + t_event->Branch("timeHigh", &b_timeHigh, "timeHigh/i"); + + t_hit = fs->make("Hit", "Hit"); + t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); + t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); + t_hit->Branch("chamber", &b_chamber, "chamber/I"); + t_hit->Branch("layer", &b_layer, "layer/I"); + t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + t_hit->Branch("x", &b_x, "x/F"); + t_hit->Branch("y", &b_y, "y/F"); + t_hit->Branch("z", &b_z, "z/F"); + + t_csc = fs->make("CSC", "CSC"); + t_csc->Branch("chamber", &b_chamber, "chamber/I"); + t_csc->Branch("layer", &b_layer, "layer/I"); + + t_muon = fs->make("muon", "muon"); + t_muon->Branch("pt", &b_pt, "pt/F"); + t_muon->Branch("eta", &b_eta, "eta/F"); + t_muon->Branch("phi", &b_phi, "phi/F"); + + for (int ichamber=26; ichamber<30;++ichamber) { + // for (int ichamber=27; ichamber<=30;++ichamber) { + for (int ilayer=0; ilayer<2;++ilayer) { + h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber+1, ilayer+1),"firstStrip",384,1,385,8,0.5,8.5); + h_firstStrip[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); + h_firstStrip[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + + h_allStrips[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i",ichamber+1, ilayer+1),"allStrips",384,1,385,8,0.5,8.5); + h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); + h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + + h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); + h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); + h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); + } + } + + +} + +SliceTestAnalysisBkg::~SliceTestAnalysisBkg() +{ + t_setup->Fill(); +} + +void +SliceTestAnalysisBkg::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + b_run = iEvent.run(); + b_lumi = iEvent.luminosityBlock(); + + b_nGEMHits = 0; + b_nCSCHits = 0; + b_nMuons = 0; + + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); + theService_->update(iSetup); + auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + //edm::Handle cscRecHits; + //iEvent.getByToken(cscRecHits_, cscRecHits); + + edm::Handle cscSegments; + iEvent.getByToken(cscSegments_, cscSegments); + + //edm::Handle gemDigisvfat; + //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); + + edm::Handle vertexCollection; + iEvent.getByToken( vertexCollection_, vertexCollection ); + if(vertexCollection.isValid()) { + vertexCollection->size(); + } + + edm::Handle lumiScalers; + iEvent.getByToken( lumiScalers_, lumiScalers ); + + Handle > muons; + iEvent.getByToken(muons_, muons); + + int totalStrips = 0; + auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; + auto pileup = (lumiScalers->at(0)).pileup(); + h_lumiStatus->Fill(instLumi); + b_instLumi = instLumi; + b_timeHigh = iEvent.time().unixTime(); + b_timeLow = iEvent.time().microsecondOffset(); + h_pileup->Fill(pileup); + + b_latency = -1; + + for (size_t i = 0; i < muons->size(); ++i) { + edm::RefToBase muRef = muons->refAt(i); + const reco::Muon* mu = muRef.get(); + + const reco::Track* muonTrack = 0; + if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + if (muonTrack) { + b_pt = muonTrack->pt(); + b_eta = muonTrack->eta(); + b_phi = muonTrack->phi(); + if (b_eta < -2.15 or b_eta > -1.6) continue; + t_muon->Fill(); + b_nMuons++; + } + } + + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + + auto recHitsRange = gemRecHits->get(rId); + auto gemRecHit = recHitsRange.first; + b_chamber = rId.chamber(); + b_layer = rId.layer(); + b_etaPartition = rId.roll(); + + for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { + + h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); + h_clusterSize->Fill(hit->clusterSize()); + h_bxtotal->Fill(hit->BunchX()); + for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { + totalStrips++; + h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); + } + + b_firstStrip = hit->firstClusterStrip(); + b_nStrips = hit->clusterSize(); + int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); + h_activeLumi->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); + + auto globalPosition = roll->toGlobal(hit->localPosition()); + b_x = globalPosition.x(); + b_y = globalPosition.y(); + b_z = globalPosition.z(); + + t_hit->Fill(); + b_nGEMHits++; + } + + //auto gemVfatRange = gemDigisvfat->get(rId); + // + //for (auto vfatStatus = gemVfatRange.first; vfatStatus != gemVfatRange.second; vfatStatus++) { + // auto ix = vfatStatus->position(); + // int vfat = 8-b_etaPartition+8*ix; + // bool flag = int(vfatStatus->flag()) != 0; + // flag = int(vfatStatus->quality()) != 0; + // if (!flag) h_activeLumi_->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); + //} + } + + } + + for (auto ch : CSCGeometry_->chambers()) { + CSCDetId cId = ch->id(); + if (cId.station() != 1) continue; + if (cId.endcap() != 2) continue; + if (cId.chamber() < 27 or cId.chamber() > 30) continue; + + auto segmentsRange = cscSegments->get(cId); + auto cscSegment = segmentsRange.first; + + for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { + b_chamber = cId.chamber(); + + t_csc->Fill(); + b_nCSCHits++; + } + } + + h_totalStrips->Fill(totalStrips); + + t_event->Fill(); +} + +void SliceTestAnalysisBkg::beginJob(){} +void SliceTestAnalysisBkg::endJob(){} + +void SliceTestAnalysisBkg::beginRun(Run const& run, EventSetup const& iSetup){ + h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); + h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); + + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + + b_stripLength[rId.chamber()%2][rId.roll()-1] = striplength; + b_stripPitch[rId.chamber()%2][rId.roll()-1] = pitch; + } + } + + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + if (lId.station() != 1) continue; + if (lId.endcap() != 2) continue; + if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + const float striplength(top_->stripLength()); + const float pitch(layer->geometry()->stripPitch()); + b_cscArea = striplength * pitch * top_->nstrips(); + } + } + + b_run = run.run(); + t_run->Fill(); +} +void SliceTestAnalysisBkg::endRun(Run const&, EventSetup const&){} + +void SliceTestAnalysisBkg::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ + h_lumiStatus = fs->make(Form("%i %i status", lumiBlock.run(), lumiBlock.luminosityBlock()), "", 1000, 0, 2); +} +void SliceTestAnalysisBkg::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} + +//define this as a plug-in +DEFINE_FWK_MODULE(SliceTestAnalysisBkg); diff --git a/MuonAnalyser/test/runSliceTestAnalysisBkg.py b/MuonAnalyser/test/runSliceTestAnalysisBkg.py new file mode 100644 index 00000000000..3bce686c8c1 --- /dev/null +++ b/MuonAnalyser/test/runSliceTestAnalysisBkg.py @@ -0,0 +1,52 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('SliceTestAnalaysisBkg',eras.Run2_2017,eras.run3_GEM) + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') +process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') +process.MessageLogger.cerr.FwkReport.reportEvery = 5000 + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +#process.maxEvents.input = cms.untracked.int32(10) +# Input source +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) +process.source.skipEvents = cms.untracked.uint32(0) + +#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') +process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv5/AOD_606.root') +#process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') +#from glob import glob +#process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) +#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') + +#fname = 'singleMuon.txt' +#f = open(fname) +#for line in f: +# process.source.fileNames.append(line) + +process.options = cms.untracked.PSet() + +process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) + +process.SliceTestAnalaysisBkg = cms.EDAnalyzer('SliceTestAnalysisBkg', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits"), + #cscRecHits = cms.InputTag("csc2DRecHits"), + cscSegments = cms.InputTag("cscSegments"), + muons = cms.InputTag("muons"), + #gemDigisAMC = cms.InputTag("muonGEMDigis","AMCStatus"), + #gemDigisGEB = cms.InputTag("muonGEMDigis","GEBStatus"), + #gemDigisvfat = cms.InputTag("muonGEMDigis","vfatStatus"), + vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), +) +process.p = cms.Path(process.SliceTestAnalaysisBkg) From 2634dd05296311535b4bd45221a940ee9f45cc7e Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 28 Sep 2018 20:59:02 +0900 Subject: [PATCH 18/50] change name for consistency --- ...AnalysisBkg.cc => SliceTestBkgAnalysis.cc} | 26 +++++++++---------- ...lysisBkg.py => runSliceTestBkgAnalysis.py} | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) rename MuonAnalyser/plugins/{SliceTestAnalysisBkg.cc => SliceTestBkgAnalysis.cc} (95%) rename MuonAnalyser/test/{runSliceTestAnalysisBkg.py => runSliceTestBkgAnalysis.py} (97%) diff --git a/MuonAnalyser/plugins/SliceTestAnalysisBkg.cc b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc similarity index 95% rename from MuonAnalyser/plugins/SliceTestAnalysisBkg.cc rename to MuonAnalyser/plugins/SliceTestBkgAnalysis.cc index 4f222b4d640..bb6090ef7bc 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysisBkg.cc +++ b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc @@ -65,10 +65,10 @@ using namespace std; using namespace edm; -class SliceTestAnalysisBkg : public edm::EDAnalyzer { +class SliceTestBkgAnalysis : public edm::EDAnalyzer { public: - explicit SliceTestAnalysisBkg(const edm::ParameterSet&); - ~SliceTestAnalysisBkg(); + explicit SliceTestBkgAnalysis(const edm::ParameterSet&); + ~SliceTestBkgAnalysis(); private: virtual void analyze(const edm::Event&, const edm::EventSetup&); @@ -137,7 +137,7 @@ class SliceTestAnalysisBkg : public edm::EDAnalyzer { }; -SliceTestAnalysisBkg::SliceTestAnalysisBkg(const edm::ParameterSet& iConfig) +SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); //cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); @@ -214,13 +214,13 @@ SliceTestAnalysisBkg::SliceTestAnalysisBkg(const edm::ParameterSet& iConfig) } -SliceTestAnalysisBkg::~SliceTestAnalysisBkg() +SliceTestBkgAnalysis::~SliceTestBkgAnalysis() { t_setup->Fill(); } void -SliceTestAnalysisBkg::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { b_run = iEvent.run(); b_lumi = iEvent.luminosityBlock(); @@ -362,10 +362,10 @@ SliceTestAnalysisBkg::analyze(const edm::Event& iEvent, const edm::EventSetup& i t_event->Fill(); } -void SliceTestAnalysisBkg::beginJob(){} -void SliceTestAnalysisBkg::endJob(){} +void SliceTestBkgAnalysis::beginJob(){} +void SliceTestBkgAnalysis::endJob(){} -void SliceTestAnalysisBkg::beginRun(Run const& run, EventSetup const& iSetup){ +void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); @@ -407,12 +407,12 @@ void SliceTestAnalysisBkg::beginRun(Run const& run, EventSetup const& iSetup){ b_run = run.run(); t_run->Fill(); } -void SliceTestAnalysisBkg::endRun(Run const&, EventSetup const&){} +void SliceTestBkgAnalysis::endRun(Run const&, EventSetup const&){} -void SliceTestAnalysisBkg::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ +void SliceTestBkgAnalysis::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ h_lumiStatus = fs->make(Form("%i %i status", lumiBlock.run(), lumiBlock.luminosityBlock()), "", 1000, 0, 2); } -void SliceTestAnalysisBkg::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} +void SliceTestBkgAnalysis::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} //define this as a plug-in -DEFINE_FWK_MODULE(SliceTestAnalysisBkg); +DEFINE_FWK_MODULE(SliceTestBkgAnalysis); diff --git a/MuonAnalyser/test/runSliceTestAnalysisBkg.py b/MuonAnalyser/test/runSliceTestBkgAnalysis.py similarity index 97% rename from MuonAnalyser/test/runSliceTestAnalysisBkg.py rename to MuonAnalyser/test/runSliceTestBkgAnalysis.py index 3bce686c8c1..16e23f2f4da 100644 --- a/MuonAnalyser/test/runSliceTestAnalysisBkg.py +++ b/MuonAnalyser/test/runSliceTestBkgAnalysis.py @@ -37,7 +37,7 @@ process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) -process.SliceTestAnalaysisBkg = cms.EDAnalyzer('SliceTestAnalysisBkg', +process.SliceTestAnalaysisBkg = cms.EDAnalyzer('SliceTestBkgAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), #cscRecHits = cms.InputTag("csc2DRecHits"), From 4a2a3f09bafdb920e756261cc02fadfd226a005d Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 28 Sep 2018 21:18:58 +0900 Subject: [PATCH 19/50] clean up --- MuonAnalyser/plugins/SliceTestBkgAnalysis.cc | 72 ++++++++------------ 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc index bb6090ef7bc..cffbc3a325a 100644 --- a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc @@ -17,13 +17,6 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" -#include "MagneticField/Engine/interface/MagneticField.h" - #include "DataFormats/Scalers/interface/LumiScalers.h" #include "DataFormats/PatCandidates/interface/Muon.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -31,26 +24,27 @@ #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonData/interface/MuonDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" +//Geometry +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" + #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" + #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Geometry/CSCGeometry/interface/CSCLayer.h" #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonTopologies/interface/StripTopology.h" -#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" #include "Geometry/CommonTopologies/interface/RadialStripTopology.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" - #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/Framework/interface/LuminosityBlock.h" @@ -83,19 +77,14 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; - //edm::EDGetTokenT cscRecHits_; edm::EDGetTokenT cscSegments_; edm::EDGetTokenT gemDigis_; - //edm::EDGetTokenT gemDigisvfat_; edm::EDGetTokenT > muons_; edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; edm::Service fs; - - MuonServiceProxy* theService_; - edm::ESHandle propagator_; - edm::ESHandle ttrackBuilder_; - edm::ESHandle bField_; + //edm::EDGetTokenT cscRecHits_; + //edm::EDGetTokenT gemDigisvfat_; TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; @@ -104,8 +93,6 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { TH2D* h_activeLumi_; TH1D* h_lumiStatus; - TH2D* h_globalPosOnGem; - TH1D* h_pileup; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; TH1D* h_inEta[36][2]; TH1D* h_hitEta[36][2]; @@ -123,7 +110,7 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { TTree *t_event; int b_run, b_lumi, b_latency; int b_nGEMHits, b_nCSCHits, b_nMuons; - float b_instLumi; + float b_instLumi, b_pileup; unsigned int b_timeLow, b_timeHigh; TTree *t_hit; @@ -147,14 +134,11 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - theService_ = new MuonServiceProxy(serviceParameters); h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_pileup=fs->make(Form("pileup"),"pileup",80,0,80); h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); - h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); t_run = fs->make("Run", "Run"); t_run->Branch("run", &b_run, "run/I"); @@ -237,22 +221,12 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i iSetup.get().get(hCSCGeom); const CSCGeometry* CSCGeometry_ = &*hCSCGeom; - iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - theService_->update(iSetup); - auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); - //edm::Handle cscRecHits; - //iEvent.getByToken(cscRecHits_, cscRecHits); - edm::Handle cscSegments; iEvent.getByToken(cscSegments_, cscSegments); - //edm::Handle gemDigisvfat; - //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); - edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { @@ -265,14 +239,19 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i Handle > muons; iEvent.getByToken(muons_, muons); + //edm::Handle gemDigisvfat; + //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); + + //edm::Handle cscRecHits; + //iEvent.getByToken(cscRecHits_, cscRecHits); + int totalStrips = 0; auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; - auto pileup = (lumiScalers->at(0)).pileup(); h_lumiStatus->Fill(instLumi); b_instLumi = instLumi; + b_pileup = (lumiScalers->at(0)).pileup(); b_timeHigh = iEvent.time().unixTime(); b_timeLow = iEvent.time().microsecondOffset(); - h_pileup->Fill(pileup); b_latency = -1; @@ -308,6 +287,7 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); + for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); @@ -315,8 +295,10 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_firstStrip = hit->firstClusterStrip(); b_nStrips = hit->clusterSize(); + int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); - h_activeLumi->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); + float vfatNu = b_chamber+(b_layer-1)/2.+vfat/48.; + h_activeLumi->Fill(b_lumi, vfatNu); auto globalPosition = roll->toGlobal(hit->localPosition()); b_x = globalPosition.x(); @@ -342,6 +324,7 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i for (auto ch : CSCGeometry_->chambers()) { CSCDetId cId = ch->id(); + // Selection for CSC chambers are in same regime with GEMINI if (cId.station() != 1) continue; if (cId.endcap() != 2) continue; if (cId.chamber() < 27 or cId.chamber() > 30) continue; @@ -366,9 +349,7 @@ void SliceTestBkgAnalysis::beginJob(){} void SliceTestBkgAnalysis::endJob(){} void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ - h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); - h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); - + edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; @@ -376,6 +357,9 @@ void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ edm::ESHandle hCSCGeom; iSetup.get().get(hCSCGeom); const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); + h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { From dd3fe37bae3dac9ef5e4e2ad13518781c7ecd22d Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 9 Oct 2018 19:20:38 +0900 Subject: [PATCH 20/50] add more position information --- MuonAnalyser/plugins/SliceTestBkgAnalysis.cc | 194 +++++++++++++++---- MuonAnalyser/test/runSliceTestBkgAnalysis.py | 4 +- 2 files changed, 161 insertions(+), 37 deletions(-) diff --git a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc index cffbc3a325a..e4bc8525d9c 100644 --- a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc @@ -28,7 +28,7 @@ #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" -//Geometry +//Libraries for Geometry #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" @@ -45,6 +45,14 @@ #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" #include "Geometry/CommonTopologies/interface/RadialStripTopology.h" +//Libraries for tracking +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "MagneticField/Engine/interface/MagneticField.h" + #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/Framework/interface/LuminosityBlock.h" @@ -74,6 +82,8 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; + + const GEMEtaPartition* findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP); // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; @@ -86,6 +96,10 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { //edm::EDGetTokenT cscRecHits_; //edm::EDGetTokenT gemDigisvfat_; + MuonServiceProxy* theService_; + edm::ESHandle ttrackBuilder_; + edm::ESHandle bField_; + TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; @@ -115,10 +129,14 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { TTree *t_hit; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; - float b_x, b_y, b_z; + float b_x, b_y, b_z, b_eta, b_mag; TTree *t_muon; - float b_pt, b_eta, b_phi; + bool b_isValid; + int b_id; + float b_pt, b_phi; + float b_resX, b_resY, b_resPhi; + float b_pullX, b_pullY; TTree *t_csc; @@ -134,6 +152,7 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); + theService_ = new MuonServiceProxy(serviceParameters); h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); @@ -168,15 +187,27 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) t_hit->Branch("x", &b_x, "x/F"); t_hit->Branch("y", &b_y, "y/F"); t_hit->Branch("z", &b_z, "z/F"); + t_hit->Branch("eta", &b_eta, "eta/F"); + t_hit->Branch("mag", &b_mag, "mag/F"); t_csc = fs->make("CSC", "CSC"); t_csc->Branch("chamber", &b_chamber, "chamber/I"); t_csc->Branch("layer", &b_layer, "layer/I"); t_muon = fs->make("muon", "muon"); + t_muon->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); + t_muon->Branch("nStrips", &b_nStrips, "nStrips/I"); + t_muon->Branch("chamber", &b_chamber, "chamber/I"); + t_muon->Branch("layer", &b_layer, "layer/I"); + t_muon->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + t_muon->Branch("id", &b_id, "id/I"); t_muon->Branch("pt", &b_pt, "pt/F"); t_muon->Branch("eta", &b_eta, "eta/F"); t_muon->Branch("phi", &b_phi, "phi/F"); + t_muon->Branch("resX", &b_resX, "resX/F"); + t_muon->Branch("resY", &b_resY, "resY/F"); + t_muon->Branch("resPhi", &b_resPhi, "resPhi/F"); + t_muon->Branch("isValid", &b_isValid, "isValid/O"); for (int ichamber=26; ichamber<30;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { @@ -227,6 +258,10 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i edm::Handle cscSegments; iEvent.getByToken(cscSegments_, cscSegments); + iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); + theService_->update(iSetup); + auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + edm::Handle vertexCollection; iEvent.getByToken( vertexCollection_, vertexCollection ); if(vertexCollection.isValid()) { @@ -255,22 +290,22 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_latency = -1; - for (size_t i = 0; i < muons->size(); ++i) { - edm::RefToBase muRef = muons->refAt(i); - const reco::Muon* mu = muRef.get(); - - const reco::Track* muonTrack = 0; - if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - if (muonTrack) { - b_pt = muonTrack->pt(); - b_eta = muonTrack->eta(); - b_phi = muonTrack->phi(); - if (b_eta < -2.15 or b_eta > -1.6) continue; - t_muon->Fill(); - b_nMuons++; - } - } + //for (size_t i = 0; i < muons->size(); ++i) { + // edm::RefToBase muRef = muons->refAt(i); + // const reco::Muon* mu = muRef.get(); + + // const reco::Track* muonTrack = 0; + // if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + // else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + // if (muonTrack) { + // b_pt = muonTrack->pt(); + // b_eta = muonTrack->eta(); + // b_phi = muonTrack->phi(); + // if (b_eta < -2.15 or b_eta > -1.6) continue; + // t_muon->Fill(); + // b_nMuons++; + // } + //} for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { @@ -284,29 +319,31 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); - h_clusterSize->Fill(hit->clusterSize()); - h_bxtotal->Fill(hit->BunchX()); + h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); + h_clusterSize->Fill(hit->clusterSize()); + h_bxtotal->Fill(hit->BunchX()); - for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { - totalStrips++; - h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); - } + for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { + totalStrips++; + h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); + } - b_firstStrip = hit->firstClusterStrip(); - b_nStrips = hit->clusterSize(); + b_firstStrip = hit->firstClusterStrip(); + b_nStrips = hit->clusterSize(); int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); float vfatNu = b_chamber+(b_layer-1)/2.+vfat/48.; h_activeLumi->Fill(b_lumi, vfatNu); - auto globalPosition = roll->toGlobal(hit->localPosition()); - b_x = globalPosition.x(); - b_y = globalPosition.y(); - b_z = globalPosition.z(); + auto globalPosition = roll->toGlobal(hit->localPosition()); + b_x = globalPosition.x(); + b_y = globalPosition.y(); + b_z = globalPosition.z(); + b_eta = globalPosition.eta(); + b_mag = globalPosition.mag(); - t_hit->Fill(); - b_nGEMHits++; + t_hit->Fill(); + b_nGEMHits++; } //auto gemVfatRange = gemDigisvfat->get(rId); @@ -319,9 +356,85 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i // if (!flag) h_activeLumi_->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); //} } - } + for (size_t i = 0; i < muons->size(); ++i) { + + edm::RefToBase muRef = muons->refAt(i); + const reco::Muon* mu = muRef.get(); + + // muon id + int muonId = 0; + if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; + else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; + + // tight and pt > 20 muon only + //if (muonId != 2) continue; + //if (mu->pt() < 20) continue; + + const reco::Track* muonTrack = 0; + if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + if (!muonTrack) continue; + else { + b_id = muonId; + b_pt = muonTrack->pt(); + b_eta = muonTrack->eta(); + b_phi = muonTrack->phi(); + } + + reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); + for (auto chamber : GEMGeometry_->chambers()) { + b_isValid = false; + if (chamber->id().chamber() == 1) continue; // ignore chammber 1 + if (mu->eta() * chamber->id().region() < 0 ) continue; + + TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),chamber->surface()); + if (!tsos.isValid()) continue; + + GlobalPoint tsosGP = tsos.globalPosition(); + auto etaPart = findEtaPartition(chamber, tsosGP); + if (!etaPart) continue; + + auto gemid = etaPart->id(); + auto locPos = etaPart->toLocal(tsosGP); + auto strip = (int) etaPart->strip(locPos); + + b_chamber = gemid.chamber(); + b_layer = gemid.layer(); + b_etaPartition = gemid.roll(); + + //Find hit + b_resX = 999; + GEMRecHit closestHit; + auto recHitsRange = gemRecHits->get(gemid); + for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { + LocalPoint hitLocPos = hit->localPosition(); + if ( fabs(hitLocPos.x() - locPos.x()) < fabs(b_resX) ) { + b_resX = hitLocPos.x() - locPos.x(); + closestHit = (*hit); + } + } + if (b_resX != 999) { //We could not find hit associated with muon + auto hitLocPos = closestHit.localPosition(); + auto hitGlobPos = etaPart->toGlobal(hitLocPos); + b_firstStrip = closestHit.firstClusterStrip(); + b_nStrips = closestHit.clusterSize(); + b_resY = hitLocPos.y() - locPos.y(); + b_resPhi = hitGlobPos.phi() - tsosGP.phi(); + + LocalError && locErr = tsos.localError().positionError(); + LocalError && hitLocErr = closestHit.localPositionError(); + b_pullX = b_resX / std::sqrt(hitLocErr.xx() + locErr.xx()); + b_pullY = b_resY / std::sqrt(hitLocErr.yy() + locErr.yy()); + + b_isValid = true; + } + + t_muon->Fill(); + b_nMuons++; + } + } for (auto ch : CSCGeometry_->chambers()) { CSCDetId cId = ch->id(); // Selection for CSC chambers are in same regime with GEMINI @@ -345,6 +458,17 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i t_event->Fill(); } +const GEMEtaPartition* SliceTestBkgAnalysis::findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP){ + for (auto etaPart : chamber->etaPartitions()) { + const LocalPoint locPos = etaPart->toLocal(tsosGP); + const LocalPoint locPos2D(locPos.x(), locPos.y(), 0); + const BoundPlane& bps(etaPart->surface()); + if (!bps.bounds().inside(locPos2D)) continue; + return etaPart; + } + return nullptr; +} + void SliceTestBkgAnalysis::beginJob(){} void SliceTestBkgAnalysis::endJob(){} diff --git a/MuonAnalyser/test/runSliceTestBkgAnalysis.py b/MuonAnalyser/test/runSliceTestBkgAnalysis.py index 16e23f2f4da..ced429533ea 100644 --- a/MuonAnalyser/test/runSliceTestBkgAnalysis.py +++ b/MuonAnalyser/test/runSliceTestBkgAnalysis.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('SliceTestAnalaysisBkg',eras.Run2_2017,eras.run3_GEM) +process = cms.Process('SliceTestBkgAnalysis',eras.Run2_2017,eras.run3_GEM) process.load("FWCore.MessageService.MessageLogger_cfi") process.load('Configuration.StandardSequences.GeometryRecoDB_cff') @@ -37,7 +37,7 @@ process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) -process.SliceTestAnalaysisBkg = cms.EDAnalyzer('SliceTestBkgAnalysis', +process.SliceTestBkgAnalysis = cms.EDAnalyzer('SliceTestBkgAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), #cscRecHits = cms.InputTag("csc2DRecHits"), From d2cf249632af5dd762ac8910ae7624c04730073f Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 11 Oct 2018 14:53:48 +0900 Subject: [PATCH 21/50] Add GEMDebug and STASliceTestAnalysis - GEMDebug : for printing basic GEM hit info - STASliceTestAnalysis : Run analysis on StandAloneMuon tracks instead of reco muons --- MuonAnalyser/plugins/GEMDebug.cc | 259 +++++++++ MuonAnalyser/plugins/STASliceTestAnalysis.cc | 521 +++++++++++++++++++ MuonAnalyser/python/RAW2STA_SliceTest.py | 125 +++++ 3 files changed, 905 insertions(+) create mode 100644 MuonAnalyser/plugins/GEMDebug.cc create mode 100644 MuonAnalyser/plugins/STASliceTestAnalysis.cc create mode 100644 MuonAnalyser/python/RAW2STA_SliceTest.py diff --git a/MuonAnalyser/plugins/GEMDebug.cc b/MuonAnalyser/plugins/GEMDebug.cc new file mode 100644 index 00000000000..6e869292072 --- /dev/null +++ b/MuonAnalyser/plugins/GEMDebug.cc @@ -0,0 +1,259 @@ +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 + +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +#include "DataFormats/Scalers/interface/LumiScalers.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" +#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigi.h" +#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" + +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +#include "TVector2.h" + + +using namespace std; +using namespace edm; + +class GEMDebug : public edm::EDAnalyzer { +public: + explicit GEMDebug(const edm::ParameterSet&); + ~GEMDebug(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + // ----------member data --------------------------- + edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT > muons_; + edm::EDGetTokenT vertexCollection_; + edm::Service fs; + + MuonServiceProxy* theService_; + edm::ESHandle propagator_; + edm::ESHandle ttrackBuilder_; + edm::ESHandle bField_; + edm::EDGetTokenT lumiScalers_; + // edm::EDGetTokenT> gemDigis_; + // // edm::EDGetTokenT> vfatStatus_; + // edm::EDGetTokenT> gebStatus_; + + ULong64_t b_event; + int b_run, b_lumi; + float b_instLumi; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality, b_bx; + int b_latency; + vector b_strips; + float b_x, b_y, b_z; + float b_mu_eta, b_mu_phi, b_mu_pt; + float b_pull_x, b_pull_y, b_res_x, b_res_y; + + int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon, nGEMTotal; + int b_nMuons, b_nMuonsWithGEMHit, b_nMuonsInMuonTree, b_nHitsInHitTree; + int b_valid; + + int b_nGEMHits; + + // muon branches + int m_nhits, m_nvalidhits; + int m_nbounds; + int m_quality, m_charge; + float m_pt, m_eta, m_phi; + // GEMHits included in Muon + vector m_roll, m_chamber, m_layer; // hit info + vector m_resx, m_resy, m_pullx, m_pully; + // Propagation only information + vector m_in_vfat; + vector m_in_roll, m_in_chamber, m_in_layer; // propagation bound info + vector m_in_globalPhi, m_in_globalEta, m_in_nearGemPhi, m_in_nearGemEta; // global info + vector m_in_x, m_in_y, m_in_local_x, m_in_local_y, m_in_gemx, m_in_gemy, m_in_local_gemx, m_in_local_gemy, m_in_pullx, m_in_pully, m_in_resx, m_in_resy, m_in_trkextdx, m_in_gem_dx; + vector m_in_local_x_closetsos, m_in_local_y_closetsos, m_in_trkextdx_closetsos, m_in_trkextdx_inner; + vector m_in_local_x_inner, m_in_local_y_inner; + vector m_in_gemNStrips, m_in_gemFirstStrip, m_in_strip; + vector m_in_matchingGem; + + vector m_rec_roll, m_rec_chamber, m_rec_layer; + + vector> m_in_resx_tests; + + TTree *t_hit; + TTree *t_run; + TTree *t_muon; + TTree *t_event; +}; + +GEMDebug::GEMDebug(const edm::ParameterSet& iConfig) : + nEvents(0), + nMuonTotal(0), + nGEMFiducialMuon(0), + nGEMTrackWithMuon(0), + nGEMTotal(0) +{ + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + muons_ = consumes >(iConfig.getParameter("muons")); + edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); + theService_ = new MuonServiceProxy(serviceParameters); + lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); +} + +GEMDebug::~GEMDebug() +{ + std::cout << "::: GEM Slice Test Results :::" << std::endl; + std::cout << ": From " << nEvents << " events" << std::endl; + std::cout << std::endl; + std::cout << " # GEMHits " << nGEMTotal << std::endl; + std::cout << " # Muons " << nMuonTotal << std::endl; + std::cout << " # FidMu " << nGEMFiducialMuon << std::endl; + std::cout << " # GEMMu " << nGEMTrackWithMuon << std::endl; + std::cout << std::endl; +} + +#include + +void +GEMDebug::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::Handle lumiScalers; + iEvent.getByToken(lumiScalers_, lumiScalers); + + edm::ESHandle GEMGeometry_; + iSetup.get().get(GEMGeometry_); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + Handle > muons; + iEvent.getByToken(muons_, muons); + + iSetup.get().get("TransientTrackBuilder", ttrackBuilder_); + theService_->update(iSetup); + auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + bool output = false; + std::stringstream ss; + + ss << "\n\n ---------- \n\n" << "\n"; + ss << "nEvent: " << nEvents++ << " : " << iEvent.id().event() << "\n\n"; + ss << "GEM REC HITS" << "\n"; + for (auto & gem : *gemRecHits) { + auto detId = gem.gemId(); + + auto roll = GEMGeometry_->etaPartition(detId); + auto globalPosition = roll->toGlobal(gem.localPosition()); + b_x = globalPosition.x(); + b_y = globalPosition.y(); + b_z = globalPosition.z(); + + ss << " --- eta: " << globalPosition.eta() << " phi: " << globalPosition.phi() << " xyz: " << b_x << " " << b_y << " " << b_z << " ch:" << detId.chamber() << " l:" << detId.layer() << " p:" << detId.roll() << " s:" << gem.firstClusterStrip() << " [" << gem.clusterSize() << "]" << "\n"; + } + + ss << "\n\nMUONS" << "\n"; + for (auto & mu : *muons) { + ss << " -- Mu e:" << mu.eta() << " p:" << mu.phi() << " pt:" << mu.pt() << "\n"; + // only consider muons going in the right direction (toward the gem slice test) + if (mu.eta() > 0) continue; + + if (mu.passed(reco::Muon::Selector::CutBasedIdTight)) m_quality = 2; + else if (mu.passed(reco::Muon::Selector::CutBasedIdLoose)) m_quality = 1; + else m_quality = 0; + + + const reco::Track* muonTrack = 0; + if (mu.globalTrack().isNonnull()) muonTrack = mu.globalTrack().get(); + else if (mu.outerTrack().isNonnull()) muonTrack = mu.outerTrack().get(); + if (muonTrack) { + reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); + for (auto ch : GEMGeometry_->etaPartitions()) { + + TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), + ch->surface()); + if (!tsos.isValid()) continue; + auto gemid = ch->id(); + if (gemid.chamber() == 1) continue; + + GlobalPoint tsosGP = tsos.globalPosition(); + const LocalPoint pos = ch->toLocal(tsosGP); + const LocalPoint pos2D(pos.x(), pos.y(), 0); + const BoundPlane& bps(ch->surface()); + + if (bps.bounds().inside(pos2D)) { + output = true; + ss << " ONgem: " << gemid.chamber() << " " << gemid.layer() << " " << gemid.roll() << " " << ch->strip(pos2D) << " - xyz: " << tsosGP.x() << " " << tsosGP.y() << " " << tsosGP.z() << "\n"; + } + } + + for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { + if ((*hit)->geographicalId().det() == DetId::Muon && + (*hit)->geographicalId().subdetId() == MuonSubdetId::GEM) { + output = true; + GEMDetId gemid((*hit)->geographicalId()); + + ss << " found hit " << gemid.chamber() << " " << gemid.layer() << " " << gemid.roll() << "\n"; + } + } + } + } + + ss << " ---------- " << "\n"; + if (output) { cout << ss.str() << endl; } +} + +void GEMDebug::beginJob(){} +void GEMDebug::endJob(){} + +void GEMDebug::beginRun(Run const& run, EventSetup const&){ +} +void GEMDebug::endRun(Run const&, EventSetup const&){} + +//define this as a plug-in +DEFINE_FWK_MODULE(GEMDebug); diff --git a/MuonAnalyser/plugins/STASliceTestAnalysis.cc b/MuonAnalyser/plugins/STASliceTestAnalysis.cc new file mode 100644 index 00000000000..e2e5836650c --- /dev/null +++ b/MuonAnalyser/plugins/STASliceTestAnalysis.cc @@ -0,0 +1,521 @@ +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 + +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +#include "DataFormats/Scalers/interface/LumiScalers.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" +#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigi.h" +#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" + +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +#include "TVector2.h" + + +using namespace std; +using namespace edm; + +class STASliceTestAnalysis : public edm::EDAnalyzer { +public: + explicit STASliceTestAnalysis(const edm::ParameterSet&); + ~STASliceTestAnalysis(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + // ----------member data --------------------------- + edm::EDGetTokenT gemRecHits_; + // edm::EDGetTokenT > muons_; + edm::EDGetTokenT vertexCollection_; + edm::Service fs; + edm::EDGetTokenT staTracks_; + + MuonServiceProxy* theService_; + edm::ESHandle propagator_; + edm::ESHandle ttrackBuilder_; + edm::ESHandle bField_; + edm::EDGetTokenT lumiScalers_; + edm::EDGetTokenT> gemDigis_; + // // edm::EDGetTokenT> vfatStatus_; + // edm::EDGetTokenT> gebStatus_; + + ULong64_t b_event; + int b_run, b_lumi; + float b_instLumi; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality, b_bx; + int b_latency; + vector b_strips; + float b_x, b_y, b_z; + float b_mu_eta, b_mu_phi, b_mu_pt; + float b_pull_x, b_pull_y, b_res_x, b_res_y; + + int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon, nGEMTotal; + int b_nMuons, b_nMuonsWithGEMHit, b_nMuonsInMuonTree, b_nHitsInHitTree; + int b_valid; + + int b_nGEMHits; + + // muon branches + int m_nGEMhits, m_nCSChits, m_nhits, m_nvalidhits; + int m_nbounds; + int m_quality, m_charge; + float m_pt, m_eta, m_phi; + // GEMHits included in Muon + vector m_roll, m_chamber, m_layer; // hit info + vector m_resx, m_resy, m_pullx, m_pully; + // Propagation only information + vector m_in_vfat; + vector m_in_roll, m_in_chamber, m_in_layer; // propagation bound info + vector m_in_globalPhi, m_in_globalEta, m_in_nearGemPhi, m_in_nearGemEta; // global info + vector m_in_x, m_in_y, m_in_local_x, m_in_local_y, m_in_gemx, m_in_gemy, m_in_local_gemx, m_in_local_gemy, m_in_pullx, m_in_pully, m_in_resx, m_in_resy, m_in_trkextdx, m_in_gem_dx; + vector m_in_local_x_closetsos, m_in_local_y_closetsos, m_in_trkextdx_closetsos, m_in_trkextdx_inner; + vector m_in_local_x_inner, m_in_local_y_inner; + vector m_in_gemNStrips, m_in_gemFirstStrip, m_in_strip; + vector m_in_matchingGem; + + vector m_rec_roll, m_rec_chamber, m_rec_layer; + + vector> m_in_resx_tests; + + TTree *t_hit; + TTree *t_run; + TTree *t_muon; + TTree *t_event; +}; + +STASliceTestAnalysis::STASliceTestAnalysis(const edm::ParameterSet& iConfig) : + nEvents(0), + nMuonTotal(0), + nGEMFiducialMuon(0), + nGEMTrackWithMuon(0), + nGEMTotal(0) +{ + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + staTracks_ = consumes(iConfig.getParameter("muons")); + edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); + theService_ = new MuonServiceProxy(serviceParameters); + lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); + gemDigis_ = consumes>(iConfig.getParameter("gemDigis")); + // // vfatStatus_ = consumes>(iConfig.getParameter("vfatStatus")); + // gebStatus_ = consumes>(iConfig.getParameter("gebStatus")); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); + t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); + t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); + t_event->Branch("nMuonsInMuonTree", &b_nMuonsInMuonTree, "nMuonsInMuonTree/I"); + t_event->Branch("nHitsInHitTree", &b_nHitsInHitTree, "nHitsInHitTree/I"); + t_event->Branch("event", &b_event, "event/l"); + t_event->Branch("run", &b_run, "run/I"); + t_event->Branch("lumi", &b_lumi, "lumi/I"); + t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); + t_event->Branch("latency", &b_latency, "latency/I"); + + t_muon = fs->make("Muon", "Muon"); + t_muon->Branch("event", &b_event, "event/l"); + t_muon->Branch("run", &b_run, "run/I"); + t_muon->Branch("lumi", &b_lumi, "lumi/I"); + t_muon->Branch("instLumi", &b_instLumi, "instLumi/F"); + t_muon->Branch("latency", &b_latency, "latency/I"); + t_muon->Branch("nhits", &m_nhits, "nhits/I"); + t_muon->Branch("nCSChits", &m_nCSChits, "nCSChits/I"); + t_muon->Branch("nGEMhits", &m_nGEMhits, "nGEMhits/I")->SetTitle("n GEM hits associated to muon"); + t_muon->Branch("nvalidhits", &m_nvalidhits, "nvalidhits/I")->SetTitle("n GEM hits associated to muon, and muon can propagate to eta partition of hit"); + t_muon->Branch("nbounds", &m_nbounds, "nbounds/I")->SetTitle("times muon is in GEM eta partition bounds"); + t_muon->Branch("pt", &m_pt, "pt/F"); + t_muon->Branch("eta", &m_eta, "eta/F"); + t_muon->Branch("phi", &m_phi, "phi/F"); + t_muon->Branch("charge", &m_charge, "charge/I"); + t_muon->Branch("quality", &m_quality, "quality/I")->SetTitle("muon quality :: 0:noid 1:looseID 2:tightID"); + t_muon->Branch("in_strip", &m_in_strip); + t_muon->Branch("in_vfat", &m_in_vfat); + t_muon->Branch("in_roll", &m_in_roll); + t_muon->Branch("in_chamber", &m_in_chamber); + t_muon->Branch("in_layer", &m_in_layer); + t_muon->Branch("in_resx", &m_in_resx); + t_muon->Branch("in_resx_tests", &m_in_resx_tests); + t_muon->Branch("in_resy", &m_in_resy); + t_muon->Branch("in_trkextdx", &m_in_trkextdx); + t_muon->Branch("in_pullx", &m_in_pullx); + t_muon->Branch("in_pully", &m_in_pully); + t_muon->Branch("in_phi", &m_in_globalPhi); + t_muon->Branch("in_eta", &m_in_globalEta); + t_muon->Branch("in_nearGemPhi", &m_in_nearGemPhi); + t_muon->Branch("in_nearGemEta", &m_in_nearGemEta); + t_muon->Branch("in_x", &m_in_x); + t_muon->Branch("in_y", &m_in_y); + + t_muon->Branch("in_local_x_inner", &m_in_local_x_inner); + t_muon->Branch("in_local_y_inner", &m_in_local_y_inner); + t_muon->Branch("in_local_x_closetsos", &m_in_local_x_closetsos); + t_muon->Branch("in_local_y_closetsos", &m_in_local_y_closetsos); + t_muon->Branch("in_trkextdx_closetsos", &m_in_trkextdx_closetsos); + t_muon->Branch("in_trkextdx_inner", &m_in_trkextdx_inner); + + t_muon->Branch("in_local_x", &m_in_local_x); + t_muon->Branch("in_local_y", &m_in_local_y); + t_muon->Branch("in_gemx", &m_in_gemx); + t_muon->Branch("in_gem_dx", &m_in_gem_dx); + t_muon->Branch("in_gemy", &m_in_gemy); + t_muon->Branch("in_local_gemx", &m_in_local_gemx); + t_muon->Branch("in_local_gemy", &m_in_local_gemy); + t_muon->Branch("in_gemFirstStrip", &m_in_gemFirstStrip); + t_muon->Branch("in_gemNStrips", &m_in_gemNStrips); + t_muon->Branch("in_matchingGem", &m_in_matchingGem); + + t_muon->Branch("rec_roll", &m_rec_roll); + t_muon->Branch("rec_chamber", &m_rec_chamber); + t_muon->Branch("rec_layer", &m_rec_layer); + + t_hit = fs->make("Hit", "Hit"); + t_hit->Branch("event", &b_event, "event/l"); + t_hit->Branch("run", &b_run, "run/I"); + t_hit->Branch("lumi", &b_lumi, "lumi/I"); + t_hit->Branch("instLumi", &b_instLumi, "instLumi/F"); + t_hit->Branch("latency", &b_latency, "latency/I"); + t_hit->Branch("bx", &b_bx, "bx/I"); + t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); + t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); + t_hit->Branch("strips", &b_strips); + t_hit->Branch("chamber", &b_chamber, "chamber/I"); + t_hit->Branch("layer", &b_layer, "layer/I"); + t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); + t_hit->Branch("x", &b_x, "x/F"); + t_hit->Branch("y", &b_y, "y/F"); + t_hit->Branch("z", &b_z, "z/F"); +} + +STASliceTestAnalysis::~STASliceTestAnalysis() +{ + std::cout << "::: GEM Slice Test Results :::" << std::endl; + std::cout << ": From " << nEvents << " events" << std::endl; + std::cout << std::endl; + std::cout << " # GEMHits " << nGEMTotal << std::endl; + std::cout << " # Muons " << nMuonTotal << std::endl; + std::cout << " # FidMu " << nGEMFiducialMuon << std::endl; + std::cout << " # GEMMu " << nGEMTrackWithMuon << std::endl; + std::cout << std::endl; +} + +void +STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::Handle lumiScalers; + iEvent.getByToken(lumiScalers_, lumiScalers); + + edm::ESHandle GEMGeometry_; + iSetup.get().get(GEMGeometry_); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + edm::Handle muons; + iEvent.getByToken(staTracks_, muons); + + edm::Handle> gemDigis; + iEvent.getByToken(gemDigis_, gemDigis); + + iSetup.get().get("TransientTrackBuilder", ttrackBuilder_); + theService_->update(iSetup); + auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + + b_latency = -1; + + for (auto g : *gemDigis) { + for (auto a = g.second.first; a != g.second.second; ++a) { + if (b_latency != -1 && b_latency != a->param1()) + std::cout << "CHANGING LATENCY - old: " << b_latency << " new: " << a->param1() << std::endl; + b_latency = a->param1(); + if (b_latency == -1) std::cout << "-1 LATENCY VALUE - " << iEvent.id().event() << " " << iEvent.id().run() << std::endl; + } + } + + nEvents++; + + b_nMuons = 0; + b_nMuonsWithGEMHit = 0; + b_nGEMHits = 0; + b_nMuonsInMuonTree = 0; + b_nHitsInHitTree = 0; + + b_run = iEvent.run(); + b_lumi = iEvent.luminosityBlock(); + if (lumiScalers->size() > 0) + b_instLumi = (lumiScalers->at(0)).instantLumi(); + else + b_instLumi = -1; + b_event = iEvent.id().event(); // = event number + + + // cout << "---- MUONS --- " << endl; + for (auto & mu : *muons) { + b_nMuons++; + // only consider muons going in the right direction (toward the gem slice test) + if (mu.eta() > 0) continue; + + m_nGEMhits = 0; + m_nbounds = 0; + m_in_strip.clear(); m_in_vfat.clear(); m_in_roll.clear(); m_in_chamber.clear(); m_in_layer.clear(); + m_in_x.clear(); m_in_y.clear(); m_in_gemx.clear(); m_in_gem_dx.clear(); m_in_gemy.clear(); + m_in_local_x_closetsos.clear(); m_in_local_y_closetsos.clear(); + m_in_local_x_inner.clear(); m_in_local_y_inner.clear(); + m_in_trkextdx_closetsos.clear(); m_in_trkextdx_inner.clear(); + m_in_local_gemx.clear(); m_in_local_gemy.clear(); + m_in_local_x.clear(); m_in_local_y.clear(); + m_in_resx.clear(); m_in_trkextdx.clear(); m_in_resy.clear(); m_in_pullx.clear(); m_in_pully.clear(); + m_in_resx_tests.clear(); + m_in_matchingGem.clear(); + m_in_gemFirstStrip.clear(); m_in_gemNStrips.clear(); + m_in_nearGemPhi.clear(); m_in_nearGemEta.clear(); + m_in_globalPhi.clear(); m_in_globalEta.clear(); + + m_rec_layer.clear(); m_rec_roll.clear(); m_rec_chamber.clear(); + m_quality = 0; + + // if (mu.passed(reco::Muon::Selector::CutBasedIdTight)) m_quality = 2; + // else if (mu.passed(reco::Muon::Selector::CutBasedIdLoose)) m_quality = 1; + // else m_quality = 0; + + m_charge = mu.charge(); + + const reco::Track* muonTrack = μ + // if (mu.globalTrack().isNonnull()) muonTrack = mu.globalTrack().get(); + // else if (mu.outerTrack().isNonnull()) muonTrack = mu.outerTrack().get(); + if (muonTrack) { + bool fidMu = false; + reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); + for (auto ch : GEMGeometry_->etaPartitions()) { + + TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), + ch->surface()); + if (!tsos.isValid()) continue; + + GlobalPoint tsosGP = tsos.globalPosition(); + + const LocalPoint pos = ch->toLocal(tsosGP); + const LocalPoint pos2D(pos.x(), pos.y(), 0); + const BoundPlane& bps(ch->surface()); + + if (bps.bounds().inside(pos2D)) { + fidMu = true; + m_nbounds++; + + auto gemid = ch->id(); + + m_in_strip.push_back(ch->strip(pos2D)); + m_in_vfat.push_back(ch->strip(pos2D)/128.); + m_in_roll.push_back(gemid.roll()); + m_in_chamber.push_back(gemid.chamber()); + m_in_layer.push_back(gemid.layer()); + float in_x, in_y; + in_x = tsosGP.x(); in_y = tsosGP.y(); + m_in_x.push_back(in_x); m_in_y.push_back(in_y); + m_in_globalPhi.push_back(tsosGP.phi()); + m_in_globalEta.push_back(tsosGP.eta()); + + // propagate from the "closest" tsos + float in_local_x_closetsos = -9999, in_local_y_closetsos = -9999, in_trkextdx_closetsos = -99; + GlobalPoint gemtagp1 = ch->position(); + TrajectoryStateOnSurface tsos1 = ttTrack.stateOnSurface(gemtagp1); + if (!tsos1.isValid()) goto out1; + tsos1 = propagator->propagate(tsos1, ch->surface()); + if (!tsos1.isValid()) goto out1; + in_local_x_closetsos = tsos1.localPosition().x(); in_local_y_closetsos = tsos1.localPosition().y(); + in_trkextdx_closetsos = std::sqrt(tsos1.localError().positionError().xx()); + out1: + m_in_local_x_closetsos.push_back(in_local_x_closetsos); m_in_local_y_closetsos.push_back(in_local_y_closetsos); + m_in_trkextdx_closetsos.push_back(in_trkextdx_closetsos); + + // Propagate from the innermost state + float in_local_x_inner = -9999, in_local_y_inner = -9999, in_trkextdx_inner = -99; + TrajectoryStateOnSurface tsos2 = propagator->propagate(ttTrack.innermostMeasurementState(), + ch->surface()); + if (!tsos2.isValid()) goto out2; + in_local_x_inner = tsos2.localPosition().x(); in_local_y_inner = tsos2.localPosition().y(); + in_trkextdx_inner = std::sqrt(tsos2.localError().positionError().xx()); + out2: + m_in_local_x_inner.push_back(in_local_x_inner); m_in_local_y_inner.push_back(in_local_y_inner); + m_in_trkextdx_inner.push_back(in_trkextdx_inner); + + + bool matchingGem = false; + int nstrips = -1, firststrip = -1; + float in_resx = -99, in_trkextdx, in_resy = -99, in_pullx = -99, in_pully = -99, in_gem_dx = -99; + float gemEta = +99.0, gemPhi = +99.0, in_gemx=-999, in_gemy=-999, in_local_gemx=-999, in_local_gemy=-999, in_local_x=-999, in_local_y=-999; + auto recHitsRange = gemRecHits->get(gemid); + auto gemRecHit = recHitsRange.first; + vector in_resx_tests; + + in_local_x = pos.x(); + in_local_y = pos.y(); + + LocalPoint loc; + + for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { + auto gemGlob = ch->toGlobal(hit->localPosition()); + if (fabs(gemGlob.phi() - tsosGP.phi()) < gemPhi) { + in_gemx = gemGlob.x(); + in_gemy = gemGlob.y(); + + in_local_gemx = hit->localPosition().x(); + in_local_gemy = hit->localPosition().y(); + + matchingGem = true; + firststrip = hit->firstClusterStrip(); + nstrips = hit->clusterSize(); + gemPhi = gemGlob.phi(); gemEta = gemGlob.eta(); + + LocalPoint && tsos_localpos = tsos.localPosition(); + loc = hit->localPosition(); + LocalError && tsos_localerr = tsos.localError().positionError(); + LocalPoint && dethit_localpos = hit->localPosition(); + LocalError && dethit_localerr = hit->localPositionError(); + in_gem_dx = dethit_localerr.xx(); + in_resx = (dethit_localpos.x() - tsos_localpos.x()); + in_trkextdx = std::sqrt(tsos.localError().positionError().xx()); + in_resy = (dethit_localpos.y() - tsos_localpos.y()); + in_pullx = (dethit_localpos.x() - tsos_localpos.x()) / + std::sqrt(dethit_localerr.xx() + tsos_localerr.xx()); + in_pully = (dethit_localpos.y() - tsos_localpos.y()) / + std::sqrt(dethit_localerr.yy() + tsos_localerr.yy()); + } + } + + m_in_resx_tests.push_back(in_resx_tests); + m_in_gemx.push_back(in_gemx); m_in_gemy.push_back(in_gemy); + m_in_gem_dx.push_back(in_gem_dx); + m_in_local_x.push_back(in_local_x); m_in_local_y.push_back(in_local_y); + m_in_local_gemx.push_back(in_local_gemx); m_in_local_gemy.push_back(in_local_gemy); + m_in_resx.push_back(in_resx); m_in_trkextdx.push_back(in_trkextdx); m_in_resy.push_back(in_resy); + m_in_pullx.push_back(in_pullx); m_in_pully.push_back(in_pully); + m_in_gemNStrips.push_back(nstrips); m_in_gemFirstStrip.push_back(firststrip); + m_in_matchingGem.push_back(matchingGem); + m_in_nearGemPhi.push_back(gemPhi); m_in_nearGemEta.push_back(gemEta); + // cout << " --- eta: " << tsosGP.eta() << " phi: " << tsosGP.phi() << " xyz: " << in_x << " " << in_y << " GEMxyz: " << in_gemx << " " << in_gemy << " qual:" << m_quality << " eta:" << mu.eta() << " phi:" << mu.phi() << " pt:" << mu.pt() << " ch:" << gemid.chamber() << " l:" << gemid.layer() << " p:" << gemid.roll() << endl; + } + } + + m_nhits = 0; m_nCSChits = 0; + for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { + m_nhits++; + if ((*hit)->geographicalId().det() == DetId::Muon && + (*hit)->geographicalId().subdetId() == MuonSubdetId::CSC) m_nCSChits++; + + if ((*hit)->geographicalId().det() == DetId::Muon && + (*hit)->geographicalId().subdetId() == MuonSubdetId::GEM) { + GEMDetId gemid((*hit)->geographicalId()); + + m_rec_chamber.push_back(gemid.chamber()); + m_rec_layer.push_back(gemid.layer()); + m_rec_roll.push_back(gemid.roll()); + } + } + + if (fidMu) ++nGEMFiducialMuon; + } + + if (m_nGEMhits > 0 or m_nbounds > 0) { + m_pt = mu.pt(); + m_eta = mu.eta(); + m_phi = mu.phi(); + t_muon->Fill(); + b_nMuonsInMuonTree++; + } + } // Muon Loop + + // cout << "--- GEM HITS ---" << endl; + for (auto & gem : *gemRecHits) { + ++b_nGEMHits; + auto detId = gem.gemId(); + + b_strips.clear(); + b_chamber = detId.chamber(); + b_layer = detId.layer(); + b_etaPartition = detId.roll(); + b_firstStrip = gem.firstClusterStrip(); + b_bx = gem.BunchX(); + b_nStrips = gem.clusterSize(); + for (int nstrip = gem.firstClusterStrip(); nstrip < (gem.firstClusterStrip() + gem.clusterSize()); ++nstrip) { + b_strips.push_back(nstrip); + } + + auto roll = GEMGeometry_->etaPartition(detId); + auto globalPosition = roll->toGlobal(gem.localPosition()); + b_x = globalPosition.x(); + b_y = globalPosition.y(); + b_z = globalPosition.z(); + + t_hit->Fill(); + b_nHitsInHitTree++; + // cout << " --- eta: " << globalPosition.eta() << " phi: " << globalPosition.phi() << " xyz: " << b_x << " " << b_y << " " << b_z << " ch:" << detId.chamber() << " l:" << detId.layer() << " p:" << detId.roll() << endl; + } // GEM Loop + // cout << endl << endl; + + nMuonTotal += b_nMuons; + nGEMTotal += b_nGEMHits; + + t_event->Fill(); +} + +void STASliceTestAnalysis::beginJob(){} +void STASliceTestAnalysis::endJob(){} + +void STASliceTestAnalysis::beginRun(Run const& run, EventSetup const&){ +} +void STASliceTestAnalysis::endRun(Run const&, EventSetup const&){} + +//define this as a plug-in +DEFINE_FWK_MODULE(STASliceTestAnalysis); diff --git a/MuonAnalyser/python/RAW2STA_SliceTest.py b/MuonAnalyser/python/RAW2STA_SliceTest.py new file mode 100644 index 00000000000..709da45cd36 --- /dev/null +++ b/MuonAnalyser/python/RAW2STA_SliceTest.py @@ -0,0 +1,125 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = 100 +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" + #"file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" + ), + secondaryFileNames = cms.untracked.vstring() +) + +#import FWCore.PythonUtilities.LumiList as LumiList +#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() +#print process.source.lumisToProcess + +process.options = cms.untracked.PSet() +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018 Data +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +# process.reconstruction_step = cms.Path(process.reconstruction) + +# Seed generator +from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * + +# Stand alone muon track producer +from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * + +# Beam Spot +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * + +process.dump=cms.EDAnalyzer('EventContentAnalyzer') + +process.reconstruction_step = cms.Path( + (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * + offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump +) + +process.endjob_step = cms.EndPath(process.endOfProcess) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) + +process.SliceTestAnalysis = cms.EDAnalyzer('STASliceTestAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits"), + muons = cms.InputTag("standAloneMuons"), + vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), + gemDigis = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + # vfatStatus = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), + # gebStatus = cms.InputTag("muonGEMDigis", "GEBStatus", "reRECO"), +) +process.sliceTest = cms.Path(process.SliceTestAnalysis) + +process.muonGEMDigis.unPackStatusDigis = cms.bool(True) +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.sliceTest, + process.endjob_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +# customisation of the process. + +# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 + +#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR +process = customisePostEra_Run2_2017(process) + +# End of customisation functions +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion From 5354987d7cca25ff6ed3ad1814e0949ddc3d04a9 Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 11 Oct 2018 15:45:03 +0900 Subject: [PATCH 22/50] Add scripts to run Gem Simulation, add output to STASliceTest --- MuonAnalyser/plugins/STASliceTestAnalysis.cc | 7 +++++-- MuonAnalyser/test/gemsim_on_condor.jds | 10 ++++++++++ MuonAnalyser/test/gemsim_on_condor.sh | 9 +++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 MuonAnalyser/test/gemsim_on_condor.jds create mode 100755 MuonAnalyser/test/gemsim_on_condor.sh diff --git a/MuonAnalyser/plugins/STASliceTestAnalysis.cc b/MuonAnalyser/plugins/STASliceTestAnalysis.cc index e2e5836650c..b436ddd8833 100644 --- a/MuonAnalyser/plugins/STASliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/STASliceTestAnalysis.cc @@ -111,7 +111,7 @@ class STASliceTestAnalysis : public edm::EDAnalyzer { int m_nGEMhits, m_nCSChits, m_nhits, m_nvalidhits; int m_nbounds; int m_quality, m_charge; - float m_pt, m_eta, m_phi; + float m_pt, m_eta, m_phi, m_chi2; // GEMHits included in Muon vector m_roll, m_chamber, m_layer; // hit info vector m_resx, m_resy, m_pullx, m_pully; @@ -169,6 +169,7 @@ STASliceTestAnalysis::STASliceTestAnalysis(const edm::ParameterSet& iConfig) : t_muon->Branch("lumi", &b_lumi, "lumi/I"); t_muon->Branch("instLumi", &b_instLumi, "instLumi/F"); t_muon->Branch("latency", &b_latency, "latency/I"); + t_muon->Branch("chi2", &m_chi2, "chi2/F"); t_muon->Branch("nhits", &m_nhits, "nhits/I"); t_muon->Branch("nCSChits", &m_nCSChits, "nCSChits/I"); t_muon->Branch("nGEMhits", &m_nGEMhits, "nGEMhits/I")->SetTitle("n GEM hits associated to muon"); @@ -323,7 +324,7 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i m_in_globalPhi.clear(); m_in_globalEta.clear(); m_rec_layer.clear(); m_rec_roll.clear(); m_rec_chamber.clear(); - m_quality = 0; + m_quality = mu.qualityMask(); // if (mu.passed(reco::Muon::Selector::CutBasedIdTight)) m_quality = 2; // else if (mu.passed(reco::Muon::Selector::CutBasedIdLoose)) m_quality = 1; @@ -471,6 +472,8 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i m_pt = mu.pt(); m_eta = mu.eta(); m_phi = mu.phi(); + m_pt = mu.normalizedChi2(); + t_muon->Fill(); b_nMuonsInMuonTree++; } diff --git a/MuonAnalyser/test/gemsim_on_condor.jds b/MuonAnalyser/test/gemsim_on_condor.jds new file mode 100644 index 00000000000..82ae5d39027 --- /dev/null +++ b/MuonAnalyser/test/gemsim_on_condor.jds @@ -0,0 +1,10 @@ +# Job description file for condor job 2018Cv6v2 +executable = step1_on_condor.sh +universe = vanilla +arguments = $(Process) + +log = condor.log + +getenv = True +should_transfer_files = NO +queue 2 diff --git a/MuonAnalyser/test/gemsim_on_condor.sh b/MuonAnalyser/test/gemsim_on_condor.sh new file mode 100755 index 00000000000..3cc2ad637b2 --- /dev/null +++ b/MuonAnalyser/test/gemsim_on_condor.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +cd /cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation +eval `scramv1 runtime -sh` + +cmsDriver.py TenMuExtendedE_0_200_pythia8_cfi --python_filename=python/step1_$1.py --conditions auto:phase1_2018_realistic -n 500 --era Run2_2018 --eventcontent FEVTDEBUG --relval 10000,100 -s GEN,SIM --datatier GEN-SIM --beamspot Realistic25ns13TeVEarly2018Collision --geometry DB:Extended --fileout root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step1/$1.root > log/step1_$1.log 2>&1 + +cmsDriver.py step2 --python_filename=python/step2_$1.py --conditions auto:phase1_2018_realistic -s DIGI:pdigi_valid,L1,DIGI2RAW,HLT:@relval2018 --datatier GEN-SIM-DIGI-RAW -n -1 --geometry DB:Extended --era Run2_2018 --eventcontent FEVTDEBUGHLT --filein root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step1/$1.root --fileout root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step2/$1.root > log/step2_$1.log 2>&1 + From f7954909feabc5f36774915da17c6150d998829b Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 11 Oct 2018 15:48:04 +0900 Subject: [PATCH 23/50] Fix GemSim scripts --- MuonAnalyser/test/gemsim_on_condor.jds | 4 ++-- MuonAnalyser/test/gemsim_on_condor.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MuonAnalyser/test/gemsim_on_condor.jds b/MuonAnalyser/test/gemsim_on_condor.jds index 82ae5d39027..72a25ce8012 100644 --- a/MuonAnalyser/test/gemsim_on_condor.jds +++ b/MuonAnalyser/test/gemsim_on_condor.jds @@ -1,5 +1,5 @@ -# Job description file for condor job 2018Cv6v2 -executable = step1_on_condor.sh +# Job description file for condor job +executable = gemsim_on_condor.sh universe = vanilla arguments = $(Process) diff --git a/MuonAnalyser/test/gemsim_on_condor.sh b/MuonAnalyser/test/gemsim_on_condor.sh index 3cc2ad637b2..c3f3d44401d 100755 --- a/MuonAnalyser/test/gemsim_on_condor.sh +++ b/MuonAnalyser/test/gemsim_on_condor.sh @@ -1,5 +1,7 @@ #!/bin/sh +# Steps from "runTheMatrix.py -w upgrade -l 10811.0" + cd /cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation eval `scramv1 runtime -sh` From bf430e31fa107335d84bff620cabc256e17d49db Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 11 Oct 2018 21:19:44 +0900 Subject: [PATCH 24/50] Update STASliceTest for Jasons branch, add runners --- MuonAnalyser/RAW2STA_SliceTest_2018C.py | 128 ++++++++++++++++++ MuonAnalyser/RAW2STA_SliceTest_2018D.py | 129 +++++++++++++++++++ MuonAnalyser/RAW2STA_SliceTest_MC.py | 128 ++++++++++++++++++ MuonAnalyser/plugins/STASliceTestAnalysis.cc | 72 +++++++++-- 4 files changed, 445 insertions(+), 12 deletions(-) create mode 100644 MuonAnalyser/RAW2STA_SliceTest_2018C.py create mode 100644 MuonAnalyser/RAW2STA_SliceTest_2018D.py create mode 100644 MuonAnalyser/RAW2STA_SliceTest_MC.py diff --git a/MuonAnalyser/RAW2STA_SliceTest_2018C.py b/MuonAnalyser/RAW2STA_SliceTest_2018C.py new file mode 100644 index 00000000000..9169cdcd084 --- /dev/null +++ b/MuonAnalyser/RAW2STA_SliceTest_2018C.py @@ -0,0 +1,128 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = 100 +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" +# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" + ), + secondaryFileNames = cms.untracked.vstring() +) + +#import FWCore.PythonUtilities.LumiList as LumiList +#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() +#print process.source.lumisToProcess + +process.options = cms.untracked.PSet() +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data +process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +# process.reconstruction_step = cms.Path(process.reconstruction) + +# Seed generator +from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * + +# Stand alone muon track producer +from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * + +# Beam Spot +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * + +process.dump=cms.EDAnalyzer('EventContentAnalyzer') + +process.reconstruction_step = cms.Path( + (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * + offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump +) + +process.endjob_step = cms.EndPath(process.endOfProcess) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) + +process.SliceTestAnalysis = cms.EDAnalyzer( + 'STASliceTestAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits", "", "reRECO"), + muons = cms.InputTag("standAloneMuons", "", "reRECO"), + vertexCollection = cms.InputTag("offlinePrimaryVertices", "", "reRECO"), + lumiScalers = cms.InputTag("scalersRawToDigi", "", "reRECO"), + amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), + amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), + vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), +) +process.sliceTest = cms.Path(process.SliceTestAnalysis) + +process.muonGEMDigis.unPackStatusDigis = cms.bool(True) +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.sliceTest, + process.endjob_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +# customisation of the process. + +# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 + +#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR +process = customisePostEra_Run2_2017(process) + +# End of customisation functions +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/MuonAnalyser/RAW2STA_SliceTest_2018D.py b/MuonAnalyser/RAW2STA_SliceTest_2018D.py new file mode 100644 index 00000000000..d26771c38e9 --- /dev/null +++ b/MuonAnalyser/RAW2STA_SliceTest_2018D.py @@ -0,0 +1,129 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = 100 +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + #"file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" +# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" + "file:/xrootd/store/data/Run2018D/SingleMuon/RAW/v1/000/322/430/00000/78621B29-2AB3-E811-BCC7-02163E010FA1.root" + ), + secondaryFileNames = cms.untracked.vstring() +) + +#import FWCore.PythonUtilities.LumiList as LumiList +#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() +#print process.source.lumisToProcess + +process.options = cms.untracked.PSet() +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +# process.reconstruction_step = cms.Path(process.reconstruction) + +# Seed generator +from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * + +# Stand alone muon track producer +from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * + +# Beam Spot +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * + +process.dump=cms.EDAnalyzer('EventContentAnalyzer') + +process.reconstruction_step = cms.Path( + (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * + offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump +) + +process.endjob_step = cms.EndPath(process.endOfProcess) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) + +process.SliceTestAnalysis = cms.EDAnalyzer( + 'STASliceTestAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits", "", "reRECO"), + muons = cms.InputTag("standAloneMuons", "", "reRECO"), + vertexCollection = cms.InputTag("offlinePrimaryVertices", "", "reRECO"), + lumiScalers = cms.InputTag("scalersRawToDigi", "", "reRECO"), + amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), + amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), + vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), +) +process.sliceTest = cms.Path(process.SliceTestAnalysis) + +process.muonGEMDigis.unPackStatusDigis = cms.bool(True) +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.sliceTest, + process.endjob_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +# customisation of the process. + +# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 + +#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR +process = customisePostEra_Run2_2017(process) + +# End of customisation functions +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/MuonAnalyser/RAW2STA_SliceTest_MC.py b/MuonAnalyser/RAW2STA_SliceTest_MC.py new file mode 100644 index 00000000000..03043b14dfc --- /dev/null +++ b/MuonAnalyser/RAW2STA_SliceTest_MC.py @@ -0,0 +1,128 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = 100 +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + # "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" + "/store/user/iawatson/GemSimulation/step2/step2_000.root" + ), + secondaryFileNames = cms.untracked.vstring() +) + +#import FWCore.PythonUtilities.LumiList as LumiList +#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() +#print process.source.lumisToProcess + +process.options = cms.untracked.PSet() +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018 Data +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +# process.reconstruction_step = cms.Path(process.reconstruction) + +# Seed generator +from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * + +# Stand alone muon track producer +from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * + +# Beam Spot +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * + +process.dump=cms.EDAnalyzer('EventContentAnalyzer') + +process.reconstruction_step = cms.Path( + (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * + offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump +) + +process.endjob_step = cms.EndPath(process.endOfProcess) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) + +process.SliceTestAnalysis = cms.EDAnalyzer( + 'STASliceTestAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits"), + muons = cms.InputTag("standAloneMuons"), + vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), + gemDigis = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), + amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), + vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), +) +process.sliceTest = cms.Path(process.SliceTestAnalysis) + +process.muonGEMDigis.unPackStatusDigis = cms.bool(True) +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.sliceTest, + process.endjob_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +# customisation of the process. + +# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 + +#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR +#process = customisePostEra_Run2_2017(process) + +# End of customisation functions +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +# from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +# process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/MuonAnalyser/plugins/STASliceTestAnalysis.cc b/MuonAnalyser/plugins/STASliceTestAnalysis.cc index b436ddd8833..b0efc23616d 100644 --- a/MuonAnalyser/plugins/STASliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/STASliceTestAnalysis.cc @@ -32,6 +32,12 @@ #include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" #include "EventFilter/GEMRawToDigi/interface/AMCdata.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMC13EventCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMCdataCollection.h" +#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" + #include "DataFormats/PatCandidates/interface/Muon.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -87,9 +93,18 @@ class STASliceTestAnalysis : public edm::EDAnalyzer { edm::ESHandle ttrackBuilder_; edm::ESHandle bField_; edm::EDGetTokenT lumiScalers_; - edm::EDGetTokenT> gemDigis_; - // // edm::EDGetTokenT> vfatStatus_; - // edm::EDGetTokenT> gebStatus_; + + edm::EDGetTokenT amc13Event_; + edm::EDGetTokenT amcData_; + edm::EDGetTokenT gebStatusCol_; + edm::EDGetTokenT vfatStatusCol_; + + bool checkEtaPartitionGood(const GEMEtaPartition* part); + + edm::Handle amc13Event; + edm::Handle amcData; + edm::Handle gebStatusCol; + edm::Handle vfatStatusCol; ULong64_t b_event; int b_run, b_lumi; @@ -117,7 +132,7 @@ class STASliceTestAnalysis : public edm::EDAnalyzer { vector m_resx, m_resy, m_pullx, m_pully; // Propagation only information vector m_in_vfat; - vector m_in_roll, m_in_chamber, m_in_layer; // propagation bound info + vector m_in_roll, m_in_chamber, m_in_layer, m_in_goodEta; // propagation bound info vector m_in_globalPhi, m_in_globalEta, m_in_nearGemPhi, m_in_nearGemEta; // global info vector m_in_x, m_in_y, m_in_local_x, m_in_local_y, m_in_gemx, m_in_gemy, m_in_local_gemx, m_in_local_gemy, m_in_pullx, m_in_pully, m_in_resx, m_in_resy, m_in_trkextdx, m_in_gem_dx; vector m_in_local_x_closetsos, m_in_local_y_closetsos, m_in_trkextdx_closetsos, m_in_trkextdx_inner; @@ -147,10 +162,11 @@ STASliceTestAnalysis::STASliceTestAnalysis(const edm::ParameterSet& iConfig) : edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); theService_ = new MuonServiceProxy(serviceParameters); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); - gemDigis_ = consumes>(iConfig.getParameter("gemDigis")); - // // vfatStatus_ = consumes>(iConfig.getParameter("vfatStatus")); - // gebStatus_ = consumes>(iConfig.getParameter("gebStatus")); - + amc13Event_ = consumes(iConfig.getParameter("amc13Event")); + amcData_ = consumes(iConfig.getParameter("amcData")); + gebStatusCol_ = consumes(iConfig.getParameter("gebStatusCol")); + vfatStatusCol_ = consumes(iConfig.getParameter("vfatStatusCol")); + t_event = fs->make("Event", "Event"); t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); @@ -185,6 +201,7 @@ STASliceTestAnalysis::STASliceTestAnalysis(const edm::ParameterSet& iConfig) : t_muon->Branch("in_roll", &m_in_roll); t_muon->Branch("in_chamber", &m_in_chamber); t_muon->Branch("in_layer", &m_in_layer); + t_muon->Branch("in_goodEta", &m_in_goodEta); t_muon->Branch("in_resx", &m_in_resx); t_muon->Branch("in_resx_tests", &m_in_resx_tests); t_muon->Branch("in_resy", &m_in_resy); @@ -266,8 +283,10 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i edm::Handle muons; iEvent.getByToken(staTracks_, muons); - edm::Handle> gemDigis; - iEvent.getByToken(gemDigis_, gemDigis); + iEvent.getByToken(amc13Event_, amc13Event); + iEvent.getByToken(amcData_, amcData); + iEvent.getByToken(gebStatusCol_, gebStatusCol); + iEvent.getByToken(vfatStatusCol_, vfatStatusCol); iSetup.get().get("TransientTrackBuilder", ttrackBuilder_); theService_->update(iSetup); @@ -275,7 +294,7 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_latency = -1; - for (auto g : *gemDigis) { + for (auto g : *amcData) { for (auto a = g.second.first; a != g.second.second; ++a) { if (b_latency != -1 && b_latency != a->param1()) std::cout << "CHANGING LATENCY - old: " << b_latency << " new: " << a->param1() << std::endl; @@ -309,7 +328,7 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i m_nGEMhits = 0; m_nbounds = 0; - m_in_strip.clear(); m_in_vfat.clear(); m_in_roll.clear(); m_in_chamber.clear(); m_in_layer.clear(); + m_in_strip.clear(); m_in_vfat.clear(); m_in_roll.clear(); m_in_chamber.clear(); m_in_layer.clear(); m_in_goodEta.clear(); m_in_x.clear(); m_in_y.clear(); m_in_gemx.clear(); m_in_gem_dx.clear(); m_in_gemy.clear(); m_in_local_x_closetsos.clear(); m_in_local_y_closetsos.clear(); m_in_local_x_inner.clear(); m_in_local_y_inner.clear(); @@ -361,6 +380,9 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i m_in_roll.push_back(gemid.roll()); m_in_chamber.push_back(gemid.chamber()); m_in_layer.push_back(gemid.layer()); + + m_in_goodEta.push_back(checkEtaPartitionGood(ch)); + float in_x, in_y; in_x = tsosGP.x(); in_y = tsosGP.y(); m_in_x.push_back(in_x); m_in_y.push_back(in_y); @@ -513,6 +535,32 @@ STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i t_event->Fill(); } +bool STASliceTestAnalysis::checkEtaPartitionGood(const GEMEtaPartition* part) +{ + GEMDetId rId = part->id(); + int amcBx = -1; + + for (GEMAMCdataCollection::DigiRangeIterator amcsIt = amcData->begin(); amcsIt != amcData->end(); ++amcsIt){ + auto amcs = (*amcsIt).second; + for (auto amc = amcs.first; amc != amcs.second; ++amc) { + amcBx = amc->bx(); + } + } + + auto gebs = gebStatusCol->get(rId.chamberId()); + for (auto geb = gebs.first; geb != gebs.second; ++geb) { + if (int(geb->getInFu()) != 0 ) return false; + } + + auto vfats = vfatStatusCol->get(rId); + for (auto vfat = vfats.first; vfat != vfats.second; ++vfat) { + if (vfat->bc() != amcBx ) return false; + if (int(vfat->quality()) != 0 ) return false; + if (int(vfat->flag()) != 0 ) return false; + } + return true; +} + void STASliceTestAnalysis::beginJob(){} void STASliceTestAnalysis::endJob(){} From aa14c2b6c7e1c98425917ef3cb6e65241f8224c7 Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 11 Oct 2018 21:21:13 +0900 Subject: [PATCH 25/50] Put runners in correct location --- MuonAnalyser/{ => test}/RAW2STA_SliceTest_2018C.py | 0 MuonAnalyser/{ => test}/RAW2STA_SliceTest_2018D.py | 0 MuonAnalyser/{ => test}/RAW2STA_SliceTest_MC.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename MuonAnalyser/{ => test}/RAW2STA_SliceTest_2018C.py (100%) rename MuonAnalyser/{ => test}/RAW2STA_SliceTest_2018D.py (100%) rename MuonAnalyser/{ => test}/RAW2STA_SliceTest_MC.py (100%) diff --git a/MuonAnalyser/RAW2STA_SliceTest_2018C.py b/MuonAnalyser/test/RAW2STA_SliceTest_2018C.py similarity index 100% rename from MuonAnalyser/RAW2STA_SliceTest_2018C.py rename to MuonAnalyser/test/RAW2STA_SliceTest_2018C.py diff --git a/MuonAnalyser/RAW2STA_SliceTest_2018D.py b/MuonAnalyser/test/RAW2STA_SliceTest_2018D.py similarity index 100% rename from MuonAnalyser/RAW2STA_SliceTest_2018D.py rename to MuonAnalyser/test/RAW2STA_SliceTest_2018D.py diff --git a/MuonAnalyser/RAW2STA_SliceTest_MC.py b/MuonAnalyser/test/RAW2STA_SliceTest_MC.py similarity index 100% rename from MuonAnalyser/RAW2STA_SliceTest_MC.py rename to MuonAnalyser/test/RAW2STA_SliceTest_MC.py From 28b17b253b344b32ce52aacf0623f39068ad6d83 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Fri, 12 Oct 2018 13:36:16 +0900 Subject: [PATCH 26/50] fix name --- MuonAnalyser/test/runSliceTestBkgAnalysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MuonAnalyser/test/runSliceTestBkgAnalysis.py b/MuonAnalyser/test/runSliceTestBkgAnalysis.py index ced429533ea..5289efada4b 100644 --- a/MuonAnalyser/test/runSliceTestBkgAnalysis.py +++ b/MuonAnalyser/test/runSliceTestBkgAnalysis.py @@ -49,4 +49,4 @@ vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), ) -process.p = cms.Path(process.SliceTestAnalaysisBkg) +process.p = cms.Path(process.SliceTestBkgAnalysis) From 120676f445fe8a3e693d971a8dba18574f5c58ee Mon Sep 17 00:00:00 2001 From: yechanKang Date: Mon, 10 Dec 2018 00:28:04 +0900 Subject: [PATCH 27/50] update bkg hit rate alnalyse --- MuonAnalyser/plugins/SliceTestBkgAnalysis.cc | 394 ++++++++++--------- MuonAnalyser/test/CrabSlice.py | 28 ++ MuonAnalyser/test/CrabSlice_EGamma.py | 28 ++ MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py | 128 ++++++ MuonAnalyser/test/runSliceTestBkgAnalysis.py | 9 +- MuonAnalyser/test/sliceCrab.py | 28 ++ 6 files changed, 430 insertions(+), 185 deletions(-) create mode 100644 MuonAnalyser/test/CrabSlice.py create mode 100644 MuonAnalyser/test/CrabSlice_EGamma.py create mode 100644 MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py create mode 100644 MuonAnalyser/test/sliceCrab.py diff --git a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc index e4bc8525d9c..ea224e75cc4 100644 --- a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc @@ -22,11 +22,11 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" -#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" -#include "DataFormats/MuonData/interface/MuonDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" +//#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +//#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +//#include "DataFormats/GEMDigi/interface/GEMAMCdataCollection.h" +//#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" +//#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" //Libraries for Geometry #include "Geometry/Records/interface/MuonGeometryRecord.h" @@ -87,11 +87,14 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { // ----------member data --------------------------- edm::EDGetTokenT gemRecHits_; - edm::EDGetTokenT cscSegments_; - edm::EDGetTokenT gemDigis_; - edm::EDGetTokenT > muons_; - edm::EDGetTokenT vertexCollection_; + //edm::EDGetTokenT cscSegments_; + //edm::EDGetTokenT gemDigis_; + //edm::EDGetTokenT > muons_; + //edm::EDGetTokenT vertexCollection_; edm::EDGetTokenT lumiScalers_; + //edm::EDGetTokenT amcData_; + //edm::EDGetTokenT gebStatusCol_; + //edm::EDGetTokenT vfatStatusCol_; edm::Service fs; //edm::EDGetTokenT cscRecHits_; //edm::EDGetTokenT gemDigisvfat_; @@ -99,25 +102,26 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { MuonServiceProxy* theService_; edm::ESHandle ttrackBuilder_; edm::ESHandle bField_; + //edm::Handle amcData; + //edm::Handle gebStatusCol; + //edm::Handle vfatStatusCol; - TH2D* h_firstStrip[36][2]; TH2D* h_allStrips[36][2]; + TH2D* h_allStrips_[36][2]; TH2D* h_activeLumi; TH2D* h_activeLumi_; TH1D* h_lumiStatus; TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; - TH1D* h_inEta[36][2]; - TH1D* h_hitEta[36][2]; - TH1D* h_trkEta[36][2]; TH1D* h_res_x, *h_res_y, *h_pull_x, *h_pull_y; TTree *t_setup; float b_stripLength[2][8]; float b_stripPitch[2][8]; - float b_cscArea; + float b_etaPosR[2][8]; + //float b_cscArea; TTree *t_run; @@ -126,6 +130,7 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { int b_nGEMHits, b_nCSCHits, b_nMuons; float b_instLumi, b_pileup; unsigned int b_timeLow, b_timeHigh; + int b_vfatQuality[36][2][24]; TTree *t_hit; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; @@ -145,11 +150,11 @@ class SliceTestBkgAnalysis : public edm::EDAnalyzer { SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) { gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - //cscRecHits_ = consumes(iConfig.getParameter("cscRecHits")); - cscSegments_ = consumes(iConfig.getParameter("cscSegments")); - muons_ = consumes >(iConfig.getParameter("muons")); //gemDigisvfat_ = consumes(iConfig.getParameter("gemDigisvfat")); - vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); + //vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); + //amcData_ = consumes(iConfig.getParameter("amcData")); + //gebStatusCol_ = consumes(iConfig.getParameter("gebStatusCol")); + //vfatStatusCol_ = consumes(iConfig.getParameter("vfatStatusCol")); lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); theService_ = new MuonServiceProxy(serviceParameters); @@ -165,7 +170,8 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) t_setup = fs->make("Setup", "Setup"); t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); - t_setup->Branch("cscArea", &b_cscArea, "cscArea/F"); + t_setup->Branch("etaPosR", &b_etaPosR, "etaPosR[2][8]/F"); + //t_setup->Branch("cscArea", &b_cscArea, "cscArea/F"); t_event = fs->make("Event", "Event"); t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); @@ -177,6 +183,7 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); t_event->Branch("timeLow", &b_timeLow, "timeLow/i"); t_event->Branch("timeHigh", &b_timeHigh, "timeHigh/i"); + t_event->Branch("vfatQuality", b_vfatQuality, "vfatQuality[36][2][24]/I"); t_hit = fs->make("Hit", "Hit"); t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); @@ -190,41 +197,24 @@ SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) t_hit->Branch("eta", &b_eta, "eta/F"); t_hit->Branch("mag", &b_mag, "mag/F"); - t_csc = fs->make("CSC", "CSC"); - t_csc->Branch("chamber", &b_chamber, "chamber/I"); - t_csc->Branch("layer", &b_layer, "layer/I"); - - t_muon = fs->make("muon", "muon"); - t_muon->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - t_muon->Branch("nStrips", &b_nStrips, "nStrips/I"); - t_muon->Branch("chamber", &b_chamber, "chamber/I"); - t_muon->Branch("layer", &b_layer, "layer/I"); - t_muon->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_muon->Branch("id", &b_id, "id/I"); - t_muon->Branch("pt", &b_pt, "pt/F"); - t_muon->Branch("eta", &b_eta, "eta/F"); - t_muon->Branch("phi", &b_phi, "phi/F"); - t_muon->Branch("resX", &b_resX, "resX/F"); - t_muon->Branch("resY", &b_resY, "resY/F"); - t_muon->Branch("resPhi", &b_resPhi, "resPhi/F"); - t_muon->Branch("isValid", &b_isValid, "isValid/O"); - - for (int ichamber=26; ichamber<30;++ichamber) { - // for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=0; ilayer<2;++ilayer) { - h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber+1, ilayer+1),"firstStrip",384,1,385,8,0.5,8.5); - h_firstStrip[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_firstStrip[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - - h_allStrips[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i",ichamber+1, ilayer+1),"allStrips",384,1,385,8,0.5,8.5); - h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - - h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber+1, ilayer+1),"inEta",8,0.5,8.5); - h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber+1, ilayer+1),"hitEta",8,0.5,8.5); - h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber+1, ilayer+1),"trkEta",8,0.5,8.5); - } - } + //t_csc = fs->make("CSC", "CSC"); + //t_csc->Branch("chamber", &b_chamber, "chamber/I"); + //t_csc->Branch("layer", &b_layer, "layer/I"); + + //t_muon = fs->make("muon", "muon"); + //t_muon->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); + //t_muon->Branch("nStrips", &b_nStrips, "nStrips/I"); + //t_muon->Branch("chamber", &b_chamber, "chamber/I"); + //t_muon->Branch("layer", &b_layer, "layer/I"); + //t_muon->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + //t_muon->Branch("id", &b_id, "id/I"); + //t_muon->Branch("pt", &b_pt, "pt/F"); + //t_muon->Branch("eta", &b_eta, "eta/F"); + //t_muon->Branch("phi", &b_phi, "phi/F"); + //t_muon->Branch("resX", &b_resX, "resX/F"); + //t_muon->Branch("resY", &b_resY, "resY/F"); + //t_muon->Branch("resPhi", &b_resPhi, "resPhi/F"); + //t_muon->Branch("isValid", &b_isValid, "isValid/O"); } @@ -244,41 +234,52 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_nCSCHits = 0; b_nMuons = 0; + for (int ch = 0; ch < 36; ch++) { + for (int ly = 0; ly < 2; ly++) { + for (int vfat = 0; vfat < 24; vfat++) { + b_vfatQuality[ch][ly][vfat] = -1; + } + } + } + edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - edm::ESHandle hCSCGeom; - iSetup.get().get(hCSCGeom); - const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + //edm::ESHandle hCSCGeom; + //iSetup.get().get(hCSCGeom); + //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); - edm::Handle cscSegments; - iEvent.getByToken(cscSegments_, cscSegments); + //edm::Handle cscSegments; + //iEvent.getByToken(cscSegments_, cscSegments); - iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - theService_->update(iSetup); - auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + //iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); + //theService_->update(iSetup); + //auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - edm::Handle vertexCollection; - iEvent.getByToken( vertexCollection_, vertexCollection ); - if(vertexCollection.isValid()) { - vertexCollection->size(); - } + //edm::Handle vertexCollection; + //iEvent.getByToken( vertexCollection_, vertexCollection ); + //if(vertexCollection.isValid()) { + // vertexCollection->size(); + //} edm::Handle lumiScalers; iEvent.getByToken( lumiScalers_, lumiScalers ); - Handle > muons; - iEvent.getByToken(muons_, muons); + //Handle > muons; + //iEvent.getByToken(muons_, muons); //edm::Handle gemDigisvfat; //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); //edm::Handle cscRecHits; //iEvent.getByToken(cscRecHits_, cscRecHits); + //iEvent.getByToken(amcData_, amcData); + //iEvent.getByToken(gebStatusCol_, gebStatusCol); + //iEvent.getByToken(vfatStatusCol_, vfatStatusCol); int totalStrips = 0; auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; @@ -290,6 +291,15 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_latency = -1; + //for (auto g : *amcData) { + // for (auto a = g.second.first; a != g.second.second; ++a) { + // if (b_latency != -1 && b_latency != a->param1()) + // std::cout << "CHANGING LATENCY - old: " << b_latency << " new: " << a->param1() << std::endl; + // b_latency = a->param1(); + // if (b_latency == -1) std::cout << "-1 LATENCY VALUE - " << iEvent.id().event() << " " << iEvent.id().run() << std::endl; + // } + //} + //for (size_t i = 0; i < muons->size(); ++i) { // edm::RefToBase muRef = muons->refAt(i); // const reco::Muon* mu = muRef.get(); @@ -317,15 +327,23 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i b_layer = rId.layer(); b_etaPartition = rId.roll(); + //auto vfats = vfatStatusCol->get(rId); + //int index = 0; + //for (auto vfat = vfats.first; vfat != vfats.second; ++vfat) { + // int vfatNu = (8-b_etaPartition)+8*(index); + // b_vfatQuality[b_chamber-1][b_layer-1][vfatNu] = vfat->quality(); + // index++; + //} + for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - h_firstStrip[rId.chamber()-1][rId.layer()-1]->Fill(hit->firstClusterStrip(), rId.roll()); h_clusterSize->Fill(hit->clusterSize()); h_bxtotal->Fill(hit->BunchX()); for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { totalStrips++; h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); + h_allStrips_[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); } b_firstStrip = hit->firstClusterStrip(); @@ -358,100 +376,100 @@ SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& i } } - for (size_t i = 0; i < muons->size(); ++i) { - - edm::RefToBase muRef = muons->refAt(i); - const reco::Muon* mu = muRef.get(); - - // muon id - int muonId = 0; - if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; - else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; - - // tight and pt > 20 muon only - //if (muonId != 2) continue; - //if (mu->pt() < 20) continue; - - const reco::Track* muonTrack = 0; - if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - if (!muonTrack) continue; - else { - b_id = muonId; - b_pt = muonTrack->pt(); - b_eta = muonTrack->eta(); - b_phi = muonTrack->phi(); - } + //for (size_t i = 0; i < muons->size(); ++i) { - reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - for (auto chamber : GEMGeometry_->chambers()) { - b_isValid = false; - if (chamber->id().chamber() == 1) continue; // ignore chammber 1 - if (mu->eta() * chamber->id().region() < 0 ) continue; + // edm::RefToBase muRef = muons->refAt(i); + // const reco::Muon* mu = muRef.get(); - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),chamber->surface()); - if (!tsos.isValid()) continue; + // // muon id + // int muonId = 0; + // if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; + // else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; - GlobalPoint tsosGP = tsos.globalPosition(); - auto etaPart = findEtaPartition(chamber, tsosGP); - if (!etaPart) continue; + // // tight and pt > 20 muon only + // //if (muonId != 2) continue; + // //if (mu->pt() < 20) continue; + // + // const reco::Track* muonTrack = 0; + // if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + // else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + // if (!muonTrack) continue; + // else { + // b_id = muonId; + // b_pt = muonTrack->pt(); + // b_eta = muonTrack->eta(); + // b_phi = muonTrack->phi(); + // } - auto gemid = etaPart->id(); - auto locPos = etaPart->toLocal(tsosGP); - auto strip = (int) etaPart->strip(locPos); - - b_chamber = gemid.chamber(); - b_layer = gemid.layer(); - b_etaPartition = gemid.roll(); - - //Find hit - b_resX = 999; - GEMRecHit closestHit; - auto recHitsRange = gemRecHits->get(gemid); - for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { - LocalPoint hitLocPos = hit->localPosition(); - if ( fabs(hitLocPos.x() - locPos.x()) < fabs(b_resX) ) { - b_resX = hitLocPos.x() - locPos.x(); - closestHit = (*hit); - } - } - if (b_resX != 999) { //We could not find hit associated with muon - auto hitLocPos = closestHit.localPosition(); - auto hitGlobPos = etaPart->toGlobal(hitLocPos); - b_firstStrip = closestHit.firstClusterStrip(); - b_nStrips = closestHit.clusterSize(); - b_resY = hitLocPos.y() - locPos.y(); - b_resPhi = hitGlobPos.phi() - tsosGP.phi(); - - LocalError && locErr = tsos.localError().positionError(); - LocalError && hitLocErr = closestHit.localPositionError(); - b_pullX = b_resX / std::sqrt(hitLocErr.xx() + locErr.xx()); - b_pullY = b_resY / std::sqrt(hitLocErr.yy() + locErr.yy()); - - b_isValid = true; - } - - t_muon->Fill(); - b_nMuons++; - } - } - for (auto ch : CSCGeometry_->chambers()) { - CSCDetId cId = ch->id(); - // Selection for CSC chambers are in same regime with GEMINI - if (cId.station() != 1) continue; - if (cId.endcap() != 2) continue; - if (cId.chamber() < 27 or cId.chamber() > 30) continue; - - auto segmentsRange = cscSegments->get(cId); - auto cscSegment = segmentsRange.first; - - for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { - b_chamber = cId.chamber(); - - t_csc->Fill(); - b_nCSCHits++; - } - } + // reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); + // for (auto chamber : GEMGeometry_->chambers()) { + // b_isValid = false; + // if (chamber->id().chamber() == 1) continue; // ignore chammber 1 + // if (mu->eta() * chamber->id().region() < 0 ) continue; + + // TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),chamber->surface()); + // if (!tsos.isValid()) continue; + + // GlobalPoint tsosGP = tsos.globalPosition(); + // auto etaPart = findEtaPartition(chamber, tsosGP); + // if (!etaPart) continue; + + // auto gemid = etaPart->id(); + // auto locPos = etaPart->toLocal(tsosGP); + // auto strip = (int) etaPart->strip(locPos); + // + // b_chamber = gemid.chamber(); + // b_layer = gemid.layer(); + // b_etaPartition = gemid.roll(); + + // //Find hit + // b_resX = 999; + // GEMRecHit closestHit; + // auto recHitsRange = gemRecHits->get(gemid); + // for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { + // LocalPoint hitLocPos = hit->localPosition(); + // if ( fabs(hitLocPos.x() - locPos.x()) < fabs(b_resX) ) { + // b_resX = hitLocPos.x() - locPos.x(); + // closestHit = (*hit); + // } + // } + // if (b_resX != 999) { //We could not find hit associated with muon + // auto hitLocPos = closestHit.localPosition(); + // auto hitGlobPos = etaPart->toGlobal(hitLocPos); + // b_firstStrip = closestHit.firstClusterStrip(); + // b_nStrips = closestHit.clusterSize(); + // b_resY = hitLocPos.y() - locPos.y(); + // b_resPhi = hitGlobPos.phi() - tsosGP.phi(); + + // LocalError && locErr = tsos.localError().positionError(); + // LocalError && hitLocErr = closestHit.localPositionError(); + // b_pullX = b_resX / std::sqrt(hitLocErr.xx() + locErr.xx()); + // b_pullY = b_resY / std::sqrt(hitLocErr.yy() + locErr.yy()); + + // b_isValid = true; + // } + // + // t_muon->Fill(); + // b_nMuons++; + // } + //} + //for (auto ch : CSCGeometry_->chambers()) { + // CSCDetId cId = ch->id(); + // // Selection for CSC chambers are in same regime with GEMINI + // if (cId.station() != 1) continue; + // if (cId.endcap() != 2) continue; + // if (cId.chamber() < 27 or cId.chamber() > 30) continue; + + // auto segmentsRange = cscSegments->get(cId); + // auto cscSegment = segmentsRange.first; + // + // for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { + // b_chamber = cId.chamber(); + + // t_csc->Fill(); + // b_nCSCHits++; + // } + //} h_totalStrips->Fill(totalStrips); @@ -473,17 +491,26 @@ void SliceTestBkgAnalysis::beginJob(){} void SliceTestBkgAnalysis::endJob(){} void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ + for (int ichamber=26; ichamber<30;++ichamber) { + // for (int ichamber=27; ichamber<=30;++ichamber) { + for (int ilayer=0; ilayer<2;++ilayer) { + h_allStrips_[ichamber][ilayer] = fs->make(Form("%i ch %i lay %i", run.run(), ichamber+1, ilayer+1),"",384,0.5,384.5,8,0.5,8.5); + h_allStrips_[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); + h_allStrips_[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + } + } + edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - edm::ESHandle hCSCGeom; - iSetup.get().get(hCSCGeom); - const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + //edm::ESHandle hCSCGeom; + //iSetup.get().get(hCSCGeom); + //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; - h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); - h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),1000, 0, 5000, 400, 27, 31); + h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),3000, 0, 3000, 400, 27, 31); + h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),3000, 0, 3000, 400, 27, 31); for (auto ch : GEMGeometry_->chambers()) { for(auto roll : ch->etaPartitions()) { @@ -492,25 +519,27 @@ void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); const float striplength(top_->stripLength()); const float pitch(roll->pitch()); + auto centrePosition = roll->toGlobal(roll->centreOfStrip(192)); b_stripLength[rId.chamber()%2][rId.roll()-1] = striplength; b_stripPitch[rId.chamber()%2][rId.roll()-1] = pitch; + b_etaPosR[rId.chamber()%2][rId.roll()-1] = sqrt(pow(centrePosition.x(), 2) + pow(centrePosition.y(), 2)); } } - for (auto ch : CSCGeometry_->chambers()) { - for (auto layer : ch->layers()) { - CSCDetId lId = layer->id(); - if (lId.station() != 1) continue; - if (lId.endcap() != 2) continue; - if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); - const float striplength(top_->stripLength()); - const float pitch(layer->geometry()->stripPitch()); - b_cscArea = striplength * pitch * top_->nstrips(); - } - } + //for (auto ch : CSCGeometry_->chambers()) { + // for (auto layer : ch->layers()) { + // CSCDetId lId = layer->id(); + // if (lId.station() != 1) continue; + // if (lId.endcap() != 2) continue; + // if (lId.chamber() < 27 or lId.chamber() > 30) continue; + + // const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + // const float striplength(top_->stripLength()); + // const float pitch(layer->geometry()->stripPitch()); + // b_cscArea = striplength * pitch * top_->nstrips(); + // } + //} b_run = run.run(); t_run->Fill(); @@ -518,6 +547,15 @@ void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ void SliceTestBkgAnalysis::endRun(Run const&, EventSetup const&){} void SliceTestBkgAnalysis::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ + for (int ichamber=26; ichamber<30;++ichamber) { + // for (int ichamber=27; ichamber<=30;++ichamber) { + for (int ilayer=0; ilayer<2;++ilayer) { + h_allStrips[ichamber][ilayer] = fs->make(Form("%i %i ch %i lay %i",lumiBlock.run(), lumiBlock.luminosityBlock(), ichamber+1, ilayer+1),"",384,0.5,384.5,8,0.5,8.5); + h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); + h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); + } + } + h_lumiStatus = fs->make(Form("%i %i status", lumiBlock.run(), lumiBlock.luminosityBlock()), "", 1000, 0, 2); } void SliceTestBkgAnalysis::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} diff --git a/MuonAnalyser/test/CrabSlice.py b/MuonAnalyser/test/CrabSlice.py new file mode 100644 index 00000000000..87971b38c4f --- /dev/null +++ b/MuonAnalyser/test/CrabSlice.py @@ -0,0 +1,28 @@ +from CRABClient.UserUtilities import config +config = config() + +config.General.requestName = 'GEM-SliceTestBkg-2018D' +config.General.transferLogs = True + +config.JobType.pluginName = 'Analysis' +# Name of the CMSSW configuration file +config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' + +#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' +config.Data.inputDataset = '/ZeroBias/Run2018D-v1/RAW' +config.Data.splitting = 'LumiBased' +config.Data.unitsPerJob = 10 +config.Data.publication = True +# This string is used to construct the output dataset name +config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018D' + +# These values only make sense for processing data +# Select input data based on a lumi mask +#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' +# Select input data based on run-ranges +#config.Data.runRange = '321067-321069' # v1 +config.Data.runRange = '324420,324418,324315,324314,324313,324293,324245,324237,324209,324206,324205,324202,324201,324078,324077,324021,323997,323980,323978,323976,323940,323857,323841,323794,323790,323778,323775,323755,323727,323726,323725,323702,323701,323700,323696,323693,323526,323525,323524,323523,323488,323487,323475,323474,323473,323472,323471,323470,323422,323421,323420,323419,323418,323417,323416,323415,323414,323413,323399,323398,323397,323396,323395,323394,323393,323391,323388,323367,323365,323364,323363,322633,322625,322617,322616,322605,322603,322602,322599,322492,322487,322480,322430,322407,322381,322356,322348,322332,322324,322322,322319,322317,322252,322222,322204,322201,322022,321990,321988,321975,321973,321961,321960,321917,321909,321908,321887,321880,321879,321834,321833,321832,321831,321820,321818,321817,321815,321813,321796,321795,321794,321781,321780,321778,321777,321776,321775,321774,321773,321759,321758,321755,321735,321732,321731,321730,321710,321709,321475,321461,321457,321434,321432,321431,321415,321414,321397,321396,321393,321390,321313,321312,321311,321310,321305,321218,321178,321177,321167,321166,321165,321164,321162,321149,321140,321138,321134,321126,321123,321122,321121,321119,321069,321068,321067,321055,321051' +#config.Data.runRange = '319347,319348,319349' # v2 + +# Where the output files will be transmitted to +config.Site.storageSite = 'T3_KR_KISTI' diff --git a/MuonAnalyser/test/CrabSlice_EGamma.py b/MuonAnalyser/test/CrabSlice_EGamma.py new file mode 100644 index 00000000000..f060ddc4603 --- /dev/null +++ b/MuonAnalyser/test/CrabSlice_EGamma.py @@ -0,0 +1,28 @@ +from CRABClient.UserUtilities import config +config = config() + +config.General.requestName = 'GEM-SliceTestBkg-2018C' +config.General.transferLogs = True + +config.JobType.pluginName = 'Analysis' +# Name of the CMSSW configuration file +config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' + +#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' +config.Data.inputDataset = '/EGamma/Run2018C-v1/RAW' +config.Data.splitting = 'LumiBased' +config.Data.unitsPerJob = 10 +config.Data.publication = True +# This string is used to construct the output dataset name +config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018C' + +# These values only make sense for processing data +# Select input data based on a lumi mask +#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' +# Select input data based on run-ranges +#config.Data.runRange = '321067-321069' # v1 +config.Data.runRange = '319337' +#config.Data.runRange = '319347,319348,319349' # v2 + +# Where the output files will be transmitted to +config.Site.storageSite = 'T3_KR_KISTI' diff --git a/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py b/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py new file mode 100644 index 00000000000..75c510eb622 --- /dev/null +++ b/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py @@ -0,0 +1,128 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_Data_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.MessageLogger.cerr.FwkReport.reportEvery = 100 +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), + "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" +# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" + ), + secondaryFileNames = cms.untracked.vstring() +) + +#import FWCore.PythonUtilities.LumiList as LumiList +#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() +#print process.source.lumisToProcess + +process.options = cms.untracked.PSet() +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step3 nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data +process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +# process.reconstruction_step = cms.Path(process.reconstruction) + +# Seed generator +from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * + +# Stand alone muon track producer +from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * + +# Beam Spot +from RecoVertex.BeamSpotProducer.BeamSpot_cff import * + +process.dump=cms.EDAnalyzer('EventContentAnalyzer') + +process.reconstruction_step = cms.Path( + (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * + offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump + #(process.gemRecHits + process.gemSegments) +) + +process.endjob_step = cms.EndPath(process.endOfProcess) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) + +process.SliceTestBkgAnalysis = cms.EDAnalyzer('SliceTestBkgAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits"), + #muons = cms.InputTag("muons"), + #vertexCollection = cms.InputTag("offlinePrimaryVertices"), + lumiScalers = cms.InputTag("scalersRawToDigi"), + #amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), + #amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), + #gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), + #vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), +) +process.sliceTest = cms.Path(process.SliceTestBkgAnalysis) + +process.muonGEMDigis.unPackStatusDigis = cms.bool(True) +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.sliceTest, + process.endjob_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +# customisation of the process. + +# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR +from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 + +#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR +process = customisePostEra_Run2_2017(process) + +# End of customisation functions +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/MuonAnalyser/test/runSliceTestBkgAnalysis.py b/MuonAnalyser/test/runSliceTestBkgAnalysis.py index 5289efada4b..573ef8670f9 100644 --- a/MuonAnalyser/test/runSliceTestBkgAnalysis.py +++ b/MuonAnalyser/test/runSliceTestBkgAnalysis.py @@ -22,8 +22,8 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv5/AOD_606.root') -#process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') +#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv5/AOD_606.root') +process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') #from glob import glob #process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) #process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') @@ -40,12 +40,7 @@ process.SliceTestBkgAnalysis = cms.EDAnalyzer('SliceTestBkgAnalysis', process.MuonServiceProxy, gemRecHits = cms.InputTag("gemRecHits"), - #cscRecHits = cms.InputTag("csc2DRecHits"), - cscSegments = cms.InputTag("cscSegments"), muons = cms.InputTag("muons"), - #gemDigisAMC = cms.InputTag("muonGEMDigis","AMCStatus"), - #gemDigisGEB = cms.InputTag("muonGEMDigis","GEBStatus"), - #gemDigisvfat = cms.InputTag("muonGEMDigis","vfatStatus"), vertexCollection = cms.InputTag("offlinePrimaryVertices"), lumiScalers = cms.InputTag("scalersRawToDigi"), ) diff --git a/MuonAnalyser/test/sliceCrab.py b/MuonAnalyser/test/sliceCrab.py new file mode 100644 index 00000000000..474462f156a --- /dev/null +++ b/MuonAnalyser/test/sliceCrab.py @@ -0,0 +1,28 @@ +from CRABClient.UserUtilities import config +config = config() + +config.General.requestName = 'GEM-SliceTestBkg-2018D-RAW-7036' +config.General.transferLogs = True + +config.JobType.pluginName = 'Analysis' +# Name of the CMSSW configuration file +config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' + +#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' +config.Data.inputDataset = '/ZeroBias/Run2018D-v1/RAW' +config.Data.splitting = 'LumiBased' +config.Data.unitsPerJob = 10 +config.Data.publication = True +# This string is used to construct the output dataset name +config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018D-7036' + +# These values only make sense for processing data +# Select input data based on a lumi mask +#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' +# Select input data based on run-ranges +#config.Data.runRange = '321067-321069' # v1 +config.Data.runRange = '321908,321909' +#config.Data.runRange = '319347,319348,319349' # v2 + +# Where the output files will be transmitted to +config.Site.storageSite = 'T3_KR_KISTI' From 6743c6a48ef4d6543ae386802e82bd4812bb9188 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Tue, 22 Jan 2019 13:19:45 +0900 Subject: [PATCH 28/50] add scripts for changing of HGCal geometry --- MuonAnalyser/plugins/HGCalSimTest.cc | 137 +++++++++++++++++++++++++++ MuonAnalyser/test/runHGCalSimTest.py | 42 ++++++++ 2 files changed, 179 insertions(+) create mode 100644 MuonAnalyser/plugins/HGCalSimTest.cc create mode 100644 MuonAnalyser/test/runHGCalSimTest.py diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc new file mode 100644 index 00000000000..31caa4ae863 --- /dev/null +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -0,0 +1,137 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "DataFormats/GEMDigi/interface/ME0DigiCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class HGCalSimTest : public edm::EDAnalyzer { +public: + explicit HGCalSimTest(const edm::ParameterSet&); + ~HGCalSimTest(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + // ----------member data --------------------------- + edm::EDGetTokenT me0Digis_; + edm::EDGetTokenT me0Segments_; + edm::Service fs; + + + TTree *t_event; + int b_run, b_lumi, b_latency; + int b_nME0Digis; + + TTree *t_digi; + int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; +}; + +HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) +{ + me0Digis_ = consumes(iConfig.getParameter("me0Digis")); + me0Segments_ = consumes(iConfig.getParameter("me0Segments")); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); + + t_digi = fs->make("Hit", "Hit"); + t_digi->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); + t_digi->Branch("nStrips", &b_nStrips, "nStrips/I"); + t_digi->Branch("chamber", &b_chamber, "chamber/I"); + t_digi->Branch("layer", &b_layer, "layer/I"); + t_digi->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); +} + +HGCalSimTest::~HGCalSimTest() +{ +} + +void +HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle hGeom; + iSetup.get().get(hGeom); + const ME0Geometry* ME0Geometry_ = &*hGeom; + + edm::Handle me0Digis; + iEvent.getByToken(me0Digis_, me0Digis); + + edm::Handle me0Segments; + iEvent.getByToken(me0Segments_, me0Segments); + + b_nME0Digis = 0; + + for (auto ch : ME0Geometry_->chambers()) { + for (auto ly : ch->layers()) { + for (auto roll : ly->etaPartitions()) { + ME0DetId rId = roll->id(); + + auto digisRange = me0Digis->get(rId); + auto me0Digi = digisRange.first; + int roll_ = rId.roll(); + int chamber = rId.chamber(); + int layer = rId.layer(); + for (auto hit = me0Digi; hit != digisRange.second; ++hit) { + int strip = hit->strip(); + t_digi->Fill(); + b_nME0Digis++; + } + } + } + } + t_event->Fill(); +} + +void HGCalSimTest::beginJob(){} +void HGCalSimTest::endJob(){} + +void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ +} +void HGCalSimTest::endRun(Run const&, EventSetup const&){} + +//define this as a plug-in +DEFINE_FWK_MODULE(HGCalSimTest); diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py new file mode 100644 index 00000000000..2bc6fbec5b3 --- /dev/null +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -0,0 +1,42 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('HGCalSimTest',eras.Run2_2017,eras.run3_GEM) + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load('Configuration.Geometry.GeometryExtended2023D23Reco_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('RecoLocalMuon.GEMRecHit.gemLocalReco_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') +process.MessageLogger.cerr.FwkReport.reportEvery = 5000 + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +#process.maxEvents.input = cms.untracked.int32(10) +# Input source +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) +process.source.skipEvents = cms.untracked.uint32(0) + +process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') +#from glob import glob +#process.source.fileNames.append('file:/cms/ldap_home/yckang/me0/CMSSW_10_4_0/src/MuonPerformance/MuonAnalyser/test/tenMu_GEN-SIM-DIGI.root') + +#fname = 'singleMuon.txt' +#f = open(fname) +#for line in f: +# process.source.fileNames.append(line) + +process.options = cms.untracked.PSet( +) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) + +process.HGCalSimTest = cms.EDAnalyzer('HGCalSimTest', + me0Digis = cms.InputTag("simMuonME0Digis"), + me0Segments = cms.InputTag("me0Segments"), +) +process.p = cms.Path(process.HGCalSimTest) + +process.schedule = cms.Schedule(process.p) From e0d88b345ab6b206d8625704422216c26f1ff2d6 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 22 Jan 2019 23:45:01 +0900 Subject: [PATCH 29/50] Save b_etaPartition --- MuonAnalyser/plugins/HGCalSimTest.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 31caa4ae863..7606d570bbb 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -68,6 +68,10 @@ class HGCalSimTest : public edm::EDAnalyzer { TTree *t_digi; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; + + TTree *t_seg; + int b_nSegments; + float b_eta; }; HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) @@ -84,6 +88,10 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_digi->Branch("chamber", &b_chamber, "chamber/I"); t_digi->Branch("layer", &b_layer, "layer/I"); t_digi->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + + t_seg = fs->make("Segment", "Segment"); + t_seg->Branch("nSegments", &b_nSegments, "nSegments/I"); + t_seg->Branch("eta", &b_eta, "eta/F"); } HGCalSimTest::~HGCalSimTest() @@ -96,11 +104,11 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) edm::ESHandle hGeom; iSetup.get().get(hGeom); const ME0Geometry* ME0Geometry_ = &*hGeom; - - edm::Handle me0Digis; + + edm::Handle me0Digis; iEvent.getByToken(me0Digis_, me0Digis); - - edm::Handle me0Segments; + + edm::Handle me0Segments; iEvent.getByToken(me0Segments_, me0Segments); b_nME0Digis = 0; @@ -110,13 +118,16 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto roll : ly->etaPartitions()) { ME0DetId rId = roll->id(); - auto digisRange = me0Digis->get(rId); + auto digisRange = me0Digis->get(rId); auto me0Digi = digisRange.first; int roll_ = rId.roll(); int chamber = rId.chamber(); int layer = rId.layer(); + b_chamber = chamber; + b_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { int strip = hit->strip(); + b_etaPartition = roll_; t_digi->Fill(); b_nME0Digis++; } From 566f94c3aead572824903964071decb0a045144c Mon Sep 17 00:00:00 2001 From: jang00777 Date: Wed, 23 Jan 2019 02:32:10 +0900 Subject: [PATCH 30/50] Get me0Segment (not complete) --- MuonAnalyser/plugins/HGCalSimTest.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 7606d570bbb..3417524ac97 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -70,7 +70,7 @@ class HGCalSimTest : public edm::EDAnalyzer { int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; TTree *t_seg; - int b_nSegments; + int b_nSegments, b_chamber_seg, b_layer_seg; float b_eta; }; @@ -92,6 +92,9 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_seg = fs->make("Segment", "Segment"); t_seg->Branch("nSegments", &b_nSegments, "nSegments/I"); t_seg->Branch("eta", &b_eta, "eta/F"); + t_seg->Branch("chamber_seg", &b_chamber_seg, "chamber_seg/I"); + t_seg->Branch("layer_seg", &b_layer_seg, "layer_seg/I"); + } HGCalSimTest::~HGCalSimTest() @@ -127,6 +130,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { int strip = hit->strip(); + b_firstStrip = strip; b_etaPartition = roll_; t_digi->Fill(); b_nME0Digis++; @@ -134,6 +138,28 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } } } + for (auto ch : ME0Geometry_->chambers()) { + std::cout << "err chk 1 " << std::endl; + ME0DetId cId = ch->id(); + std::cout << "err chk 2 " << std::endl; + auto segsRange = me0Segments->get(cId); + std::cout << "err chk 3 " << std::endl; + auto me0Seg = segsRange.first; + std::cout << "err chk 4 " << std::endl; + auto segLd = me0Seg->localPosition(); + std::cout << "err chk 5 " << std::endl; + auto chamber = cId.chamber(); + std::cout << "err chk 6 " << std::endl; + b_eta = segLd.eta(); + std::cout << "err chk 7 " << std::endl; + b_chamber_seg = chamber; + std::cout << "err chk 8 " << std::endl; + b_nSegments++; + std::cout << "err chk 9 " << std::endl; + t_seg->Fill(); + std::cout << "err chk 10 " << std::endl; + std::cout << b_chamber_seg << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << segLd.eta() << std::endl; + } t_event->Fill(); } From 75da58d4c5f3361c8f73422c30328cea9382181c Mon Sep 17 00:00:00 2001 From: yechanKang Date: Wed, 23 Jan 2019 15:07:13 +0900 Subject: [PATCH 31/50] fix bug in segment loop --- MuonAnalyser/plugins/HGCalSimTest.cc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 3417524ac97..1bdc6e0cb10 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -139,26 +139,18 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } } for (auto ch : ME0Geometry_->chambers()) { - std::cout << "err chk 1 " << std::endl; ME0DetId cId = ch->id(); - std::cout << "err chk 2 " << std::endl; auto segsRange = me0Segments->get(cId); - std::cout << "err chk 3 " << std::endl; + auto b_chamber_seg = cId.chamber(); auto me0Seg = segsRange.first; - std::cout << "err chk 4 " << std::endl; - auto segLd = me0Seg->localPosition(); - std::cout << "err chk 5 " << std::endl; - auto chamber = cId.chamber(); - std::cout << "err chk 6 " << std::endl; - b_eta = segLd.eta(); - std::cout << "err chk 7 " << std::endl; - b_chamber_seg = chamber; - std::cout << "err chk 8 " << std::endl; - b_nSegments++; - std::cout << "err chk 9 " << std::endl; - t_seg->Fill(); - std::cout << "err chk 10 " << std::endl; - std::cout << b_chamber_seg << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << segLd.eta() << std::endl; + for (auto seg = me0Seg; seg != segsRange.second; ++seg) { + auto segLd = me0Seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_eta = gp.eta(); + std::cout << b_chamber_seg << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << segLd.eta() << std::endl; + b_nSegments++; + t_seg->Fill(); + } } t_event->Fill(); } From 1c1bafa24a406faf6004d1cc89396e28d1dfcbc4 Mon Sep 17 00:00:00 2001 From: yechanKang Date: Wed, 23 Jan 2019 16:28:16 +0900 Subject: [PATCH 32/50] add script for tenMu_modified samples --- MuonAnalyser/test/runHGCalSimTest_modified.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 MuonAnalyser/test/runHGCalSimTest_modified.py diff --git a/MuonAnalyser/test/runHGCalSimTest_modified.py b/MuonAnalyser/test/runHGCalSimTest_modified.py new file mode 100644 index 00000000000..14e385b42fc --- /dev/null +++ b/MuonAnalyser/test/runHGCalSimTest_modified.py @@ -0,0 +1,43 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('HGCalSimTest',eras.Run2_2017,eras.run3_GEM) + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load('Configuration.Geometry.GeometryExtended2023D23Reco_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('RecoLocalMuon.GEMRecHit.me0LocalReco_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') +process.MessageLogger.cerr.FwkReport.reportEvery = 5000 + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +#process.maxEvents.input = cms.untracked.int32(10) +# Input source +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) +process.source.skipEvents = cms.untracked.uint32(0) + +process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_060.root') +#from glob import glob +#process.source.fileNames.append('file:/cms/ldap_home/yckang/me0/CMSSW_10_4_0/src/MuonPerformance/MuonAnalyser/test/tenMu_GEN-SIM-DIGI.root') + +#fname = 'singleMuon.txt' +#f = open(fname) +#for line in f: +# process.source.fileNames.append(line) + +process.options = cms.untracked.PSet( +) + +process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) + +process.reconstruction_step = cms.Path(process.me0LocalReco) +process.HGCalSimTest = cms.EDAnalyzer('HGCalSimTest', + me0Digis = cms.InputTag("simMuonME0Digis"), + me0Segments = cms.InputTag("me0Segments"), +) +process.p = cms.Path(process.HGCalSimTest) + +process.schedule = cms.Schedule(process.reconstruction_step, process.p) From 6085e340ba3d4bf083df20487a63d434f7d8dda5 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Thu, 31 Jan 2019 14:46:41 +0900 Subject: [PATCH 33/50] Add CSC and GEM --- MuonAnalyser/plugins/HGCalSimTest.cc | 366 +++++++++++++++++++++++---- MuonAnalyser/test/runHGCalSimTest.py | 13 +- 2 files changed, 334 insertions(+), 45 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 1bdc6e0cb10..547dc1191e9 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -25,6 +25,23 @@ #include "Geometry/GEMGeometry/interface/ME0Geometry.h" #include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" #include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" + +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" + +//#include "DataFormats/CSCRecHit/interface/CSCDigiCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +//#include "Geometry/CSCGeometry/interface/CSCEtaPartition.h" +//#include "Geometry/CSCGeometry/interface/CSCEtaPartitionSpecs.h" + #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -56,44 +73,148 @@ class HGCalSimTest : public edm::EDAnalyzer { virtual void beginRun(Run const&, EventSetup const&) override; virtual void endRun(Run const&, EventSetup const&) override; + void initValue(); + // ----------member data --------------------------- - edm::EDGetTokenT me0Digis_; + edm::EDGetTokenT me0Digis_; edm::EDGetTokenT me0Segments_; + edm::EDGetTokenT me0RecHits_; + + edm::EDGetTokenT cscSegments_; + edm::EDGetTokenT cscRecHits_; + + edm::EDGetTokenT gemDigis_; + edm::EDGetTokenT gemSegments_; + edm::EDGetTokenT gemRecHits_; + edm::Service fs; TTree *t_event; int b_run, b_lumi, b_latency; - int b_nME0Digis; + int b_nME0Digis, b_nME0Segments, b_nME0RecHits, b_nCSCSegments, b_nCSCRecHits, b_nGEMDigis, b_nGEMSegments, b_nGEMRecHits; + + /* me0 */ + TTree *t_me0_digi; + int b_me0_Digi_firstStrip, b_me0_Digi_nStrips, b_me0_Digi_chamber, b_me0_Digi_layer, b_me0_Digi_etaPartition; + + TTree *t_me0_seg; + int b_me0_Seg_chamber, b_me0_Seg_layer, b_me0_Seg_nRecHits; + float b_me0_Seg_eta; - TTree *t_digi; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; + TTree *t_me0_rec; + int b_me0_RecHit_chamber, b_me0_RecHit_layer, b_me0_RecHit_etaPartition; + float b_me0_RecHit_eta; - TTree *t_seg; - int b_nSegments, b_chamber_seg, b_layer_seg; - float b_eta; + /* me11 */ + TTree *t_me11_digi; + int b_me11_Digi_firstStrip, b_me11_Digi_nStrips, b_me11_Digi_chamber, b_me11_Digi_layer, b_me11_Digi_etaPartition; + + TTree *t_me11_seg; + int b_me11_Seg_chamber, b_me11_Seg_layer, b_me11_Seg_nRecHits; + float b_me11_Seg_eta; + + TTree *t_me11_rec; + int b_me11_RecHit_chamber, b_me11_RecHit_layer, b_me11_RecHit_etaPartition; + float b_me11_RecHit_eta; + + /* ge11 */ + TTree *t_ge11_digi; + int b_ge11_Digi_firstStrip, b_ge11_Digi_nStrips, b_ge11_Digi_chamber, b_ge11_Digi_layer, b_ge11_Digi_etaPartition; + + TTree *t_ge11_seg; + int b_ge11_Seg_chamber, b_ge11_Seg_layer, b_ge11_Seg_nRecHits; + float b_ge11_Seg_eta; + + TTree *t_ge11_rec; + int b_ge11_RecHit_chamber, b_ge11_RecHit_layer, b_ge11_RecHit_etaPartition; + float b_ge11_RecHit_eta; }; HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) { - me0Digis_ = consumes(iConfig.getParameter("me0Digis")); + me0Digis_ = consumes(iConfig.getParameter("me0Digis")); me0Segments_ = consumes(iConfig.getParameter("me0Segments")); + me0RecHits_ = consumes(iConfig.getParameter("me0RecHits")); + + cscSegments_ = consumes(iConfig.getParameter("cscSegments")); + cscRecHits_ = consumes(iConfig.getParameter("csc2DRecHits")); + + gemDigis_ = consumes(iConfig.getParameter("gemDigis")); + gemSegments_ = consumes(iConfig.getParameter("gemSegments")); + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + t_event = fs->make("Event", "Event"); - t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); + t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); + t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); + t_event->Branch("nME0RecHits", &b_nME0RecHits, "nME0RecHits/I"); + t_event->Branch("nCSCSegments", &b_nCSCSegments, "nCSCSegments/I"); + t_event->Branch("nCSCRecHits", &b_nCSCRecHits, "nCSCRecHits/I"); + t_event->Branch("nGEMDigis", &b_nGEMDigis, "nGEMDigis/I"); + t_event->Branch("nGEMSegments", &b_nGEMSegments, "nGEMSegments/I"); + t_event->Branch("nGEMRecHits", &b_nGEMRecHits, "nGEMRecHits/I"); - t_digi = fs->make("Hit", "Hit"); - t_digi->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - t_digi->Branch("nStrips", &b_nStrips, "nStrips/I"); - t_digi->Branch("chamber", &b_chamber, "chamber/I"); - t_digi->Branch("layer", &b_layer, "layer/I"); - t_digi->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); + /*me0*/ + t_me0_digi = fs->make("ME0_Hit", "ME0_Hit"); + t_me0_digi->Branch("Digi_firstStrip", &b_me0_Digi_firstStrip, "Digi_firstStrip/I"); + t_me0_digi->Branch("Digi_nStrips", &b_me0_Digi_nStrips, "Digi_nStrips/I"); + t_me0_digi->Branch("Digi_chamber", &b_me0_Digi_chamber, "Digi_chamber/I"); + t_me0_digi->Branch("Digi_layer", &b_me0_Digi_layer, "Digi_layer/I"); + t_me0_digi->Branch("Digi_etaPartition", &b_me0_Digi_etaPartition, "Digi_etaPartition/I"); + + t_me0_seg = fs->make("ME0_Segment", "ME0_Segment"); + t_me0_seg->Branch("Seg_eta", &b_me0_Seg_eta, "Seg_eta/F"); + t_me0_seg->Branch("Seg_chamber", &b_me0_Seg_chamber, "Seg_chamber/I"); + t_me0_seg->Branch("Seg_layer", &b_me0_Seg_layer, "Seg_layer/I"); + t_me0_seg->Branch("Seg_nRecHits", &b_me0_Seg_nRecHits, "Seg_nRecHits/I"); + + t_me0_rec = fs->make("ME0_RecHit", "ME0_RecHit"); + t_me0_rec->Branch("RecHit_chamber", &b_me0_RecHit_chamber, "RecHit_chaber/I"); + t_me0_rec->Branch("RecHit_layer", &b_me0_RecHit_layer, "RecHit_layer/I"); + t_me0_rec->Branch("RecHit_etaPartition", &b_me0_RecHit_etaPartition, "RecHit_etaParition/I"); + t_me0_rec->Branch("RecHit_eta", &b_me0_RecHit_eta, "RecHit_eta/F"); + + /*me11*/ + t_me11_digi = fs->make("ME11_Hit", "ME11_Hit"); + t_me11_digi->Branch("Digi_firstStrip", &b_me11_Digi_firstStrip, "Digi_firstStrip/I"); + t_me11_digi->Branch("Digi_nStrips", &b_me11_Digi_nStrips, "Digi_nStrips/I"); + t_me11_digi->Branch("Digi_chamber", &b_me11_Digi_chamber, "Digi_chamber/I"); + t_me11_digi->Branch("Digi_layer", &b_me11_Digi_layer, "Digi_layer/I"); + t_me11_digi->Branch("Digi_etaPartition", &b_me11_Digi_etaPartition, "Digi_etaPartition/I"); + + t_me11_seg = fs->make("ME11_Segment", "ME11_Segment"); + t_me11_seg->Branch("Seg_eta", &b_me11_Seg_eta, "Seg_eta/F"); + t_me11_seg->Branch("Seg_chamber", &b_me11_Seg_chamber, "Seg_chamber/I"); + t_me11_seg->Branch("Seg_layer", &b_me11_Seg_layer, "Seg_layer/I"); + t_me11_seg->Branch("Seg_nRecHits", &b_me11_Seg_nRecHits, "Seg_nRecHits/I"); + + t_me11_rec = fs->make("ME11_RecHit", "ME11_RecHit"); + t_me11_rec->Branch("RecHit_chamber", &b_me11_RecHit_chamber, "RecHit_chaber/I"); + t_me11_rec->Branch("RecHit_layer", &b_me11_RecHit_layer, "RecHit_layer/I"); + t_me11_rec->Branch("RecHit_etaPartition", &b_me11_RecHit_etaPartition, "RecHit_etaParition/I"); + t_me11_rec->Branch("RecHit_eta", &b_me11_RecHit_eta, "RecHit_eta/F"); + + /*ge11*/ + t_ge11_digi = fs->make("GE11_Hit", "GE11_Hit"); + t_ge11_digi->Branch("Digi_firstStrip", &b_ge11_Digi_firstStrip, "Digi_firstStrip/I"); + t_ge11_digi->Branch("Digi_nStrips", &b_ge11_Digi_nStrips, "Digi_nStrips/I"); + t_ge11_digi->Branch("Digi_chamber", &b_ge11_Digi_chamber, "Digi_chamber/I"); + t_ge11_digi->Branch("Digi_layer", &b_ge11_Digi_layer, "Digi_layer/I"); + t_ge11_digi->Branch("Digi_etaPartition", &b_ge11_Digi_etaPartition, "Digi_etaPartition/I"); + + t_ge11_seg = fs->make("GE11_Segment", "GE11_Segment"); + t_ge11_seg->Branch("Seg_eta", &b_ge11_Seg_eta, "Seg_eta/F"); + t_ge11_seg->Branch("Seg_chamber", &b_ge11_Seg_chamber, "Seg_chamber/I"); + t_ge11_seg->Branch("Seg_layer", &b_ge11_Seg_layer, "Seg_layer/I"); + t_ge11_seg->Branch("Seg_nRecHits", &b_ge11_Seg_nRecHits, "Seg_nRecHits/I"); + + t_ge11_rec = fs->make("GE11_RecHit", "GE11_RecHit"); + t_ge11_rec->Branch("RecHit_chamber", &b_ge11_RecHit_chamber, "RecHit_chaber/I"); + t_ge11_rec->Branch("RecHit_layer", &b_ge11_RecHit_layer, "RecHit_layer/I"); + t_ge11_rec->Branch("RecHit_etaPartition", &b_ge11_RecHit_etaPartition, "RecHit_etaParition/I"); + t_ge11_rec->Branch("RecHit_eta", &b_ge11_RecHit_eta, "RecHit_eta/F"); - t_seg = fs->make("Segment", "Segment"); - t_seg->Branch("nSegments", &b_nSegments, "nSegments/I"); - t_seg->Branch("eta", &b_eta, "eta/F"); - t_seg->Branch("chamber_seg", &b_chamber_seg, "chamber_seg/I"); - t_seg->Branch("layer_seg", &b_layer_seg, "layer_seg/I"); } @@ -104,52 +225,178 @@ HGCalSimTest::~HGCalSimTest() void HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const ME0Geometry* ME0Geometry_ = &*hGeom; + edm::ESHandle hME0Geom; + iSetup.get().get(hME0Geom); + const ME0Geometry* ME0Geometry_ = &*hME0Geom; + /* ME0 Geometry */ edm::Handle me0Digis; iEvent.getByToken(me0Digis_, me0Digis); edm::Handle me0Segments; iEvent.getByToken(me0Segments_, me0Segments); - b_nME0Digis = 0; + edm::Handle me0RecHits; + iEvent.getByToken(me0RecHits_, me0RecHits); + + /* CSC Geometry */ + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + edm::Handle cscSegments; + iEvent.getByToken(cscSegments_, cscSegments); + + edm::Handle cscRecHits; + iEvent.getByToken(cscRecHits_, cscRecHits); + + /* Gem Geometry */ + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::Handle gemDigis; + iEvent.getByToken(gemDigis_, gemDigis); + + edm::Handle gemSegments; + iEvent.getByToken(gemSegments_, gemSegments); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + initValue(); for (auto ch : ME0Geometry_->chambers()) { + /* me0 seg */ + ME0DetId cId = ch->id(); + auto segsRange = me0Segments->get(cId); + b_me0_Seg_chamber = cId.chamber(); + auto me0Seg = segsRange.first; + for (auto seg = me0Seg; seg != segsRange.second; ++seg) { + auto segLd = me0Seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_me0_Seg_eta = gp.eta(); + b_me0_Seg_nRecHits = me0Seg->nRecHits(); + std::cout << b_me0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_me0_Seg_nRecHits << std::endl; + b_nME0Segments++; + t_me0_seg->Fill(); + } for (auto ly : ch->layers()) { for (auto roll : ly->etaPartitions()) { ME0DetId rId = roll->id(); - - auto digisRange = me0Digis->get(rId); - auto me0Digi = digisRange.first; int roll_ = rId.roll(); int chamber = rId.chamber(); int layer = rId.layer(); - b_chamber = chamber; - b_layer = layer; + /* me0 digi */ + auto digisRange = me0Digis->get(rId); + auto me0Digi = digisRange.first; + b_me0_Digi_chamber = chamber; + b_me0_Digi_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { int strip = hit->strip(); - b_firstStrip = strip; - b_etaPartition = roll_; - t_digi->Fill(); + b_me0_Digi_firstStrip = strip; + b_me0_Digi_etaPartition = roll_; + t_me0_digi->Fill(); b_nME0Digis++; } + /* me0 RecHit */ + auto recRange = me0RecHits->get(rId); + auto me0Rec = recRange.first; + b_me0_RecHit_chamber = chamber; + b_me0_RecHit_layer = layer; + for (auto rec = me0Rec; rec != recRange.second; ++rec) { + auto recLd = me0Rec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_me0_RecHit_eta = gp.eta(); + b_me0_RecHit_etaPartition = roll_; + std::cout << b_me0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; + b_nME0RecHits++; + t_me0_rec->Fill(); + } } } } - for (auto ch : ME0Geometry_->chambers()) { - ME0DetId cId = ch->id(); - auto segsRange = me0Segments->get(cId); - auto b_chamber_seg = cId.chamber(); - auto me0Seg = segsRange.first; - for (auto seg = me0Seg; seg != segsRange.second; ++seg) { - auto segLd = me0Seg->localPosition(); + + for (auto ch : CSCGeometry_->chambers()) { + /* me11 seg */ + CSCDetId cId = ch->id(); + if (cId.ring() != 1 || cId.station() != 1) continue; // choose me11 + auto segsRange = cscSegments->get(cId); + b_me11_Seg_chamber = cId.chamber(); + auto cscSeg = segsRange.first; + for (auto seg = cscSeg; seg != segsRange.second; ++seg) { + auto segLd = cscSeg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_me11_Seg_eta = gp.eta(); + b_me11_Seg_nRecHits = cscSeg->nRecHits(); + b_nCSCSegments++; + t_me11_seg->Fill(); + } + for (auto ly : ch->layers()) { + CSCDetId lId = ly->id(); + int chamber = lId.chamber(); + int layer = lId.layer(); + /* me11 digi */ + /* me11 rechit */ + auto recRange = cscRecHits->get(lId); + auto cscRec = recRange.first; + b_me11_RecHit_chamber = chamber; + b_me11_RecHit_layer = layer; + for (auto rec = cscRec; rec != recRange.second; ++rec) { + auto recLd = cscRec->localPosition(); + auto gp = ly->toGlobal(recLd); + b_me11_RecHit_eta = gp.eta(); + b_nCSCRecHits++; + t_me11_rec->Fill(); + } + } + } + + for (auto ch : GEMGeometry_->chambers()) { + /* ge11 seg */ + GEMDetId cId = ch->id(); + if (cId.station() != 1 || (cId.ring() != 1 && cId.ring() != 2)) continue; // choose ge11 + auto segsRange = gemSegments->get(cId); + b_ge11_Seg_chamber = cId.chamber(); + auto gemSeg = segsRange.first; + for (auto seg = gemSeg; seg != segsRange.second; ++seg) { + auto segLd = gemSeg->localPosition(); auto gp = ch->toGlobal(segLd); - b_eta = gp.eta(); - std::cout << b_chamber_seg << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << segLd.eta() << std::endl; - b_nSegments++; - t_seg->Fill(); + b_ge11_Seg_eta = gp.eta(); + b_ge11_Seg_nRecHits = gemSeg->nRecHits(); + b_nGEMSegments++; + t_ge11_seg->Fill(); + } + for (auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + int roll_ = rId.roll(); + int chamber = rId.chamber(); + int layer = rId.layer(); + /* ge11 digi */ + auto digisRange = gemDigis->get(rId); + auto gemDigi = digisRange.first; + b_ge11_Digi_chamber = chamber; + b_ge11_Digi_layer = layer; + for (auto hit = gemDigi; hit != digisRange.second; ++hit) { + int strip = hit->strip(); + b_ge11_Digi_firstStrip = strip; + b_ge11_Digi_etaPartition = roll_; + t_ge11_digi->Fill(); + b_nGEMDigis++; + } + /* ge11 rechit */ + auto recRange = gemRecHits->get(rId); + auto gemRec = recRange.first; + b_ge11_RecHit_chamber = chamber; + b_ge11_RecHit_layer = layer; + for (auto rec = gemRec; rec != recRange.second; ++rec) { + auto recLd = gemRec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_ge11_RecHit_eta = gp.eta(); + b_ge11_RecHit_etaPartition = roll_; + b_nGEMRecHits++; + t_ge11_rec->Fill(); + } } } t_event->Fill(); @@ -162,5 +409,38 @@ void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ } void HGCalSimTest::endRun(Run const&, EventSetup const&){} +void HGCalSimTest::initValue() { + b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; + b_nCSCSegments = 0; b_nCSCRecHits = 0; + b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; + + /* me0 digi*/ + b_me0_Digi_firstStrip = -1; b_me0_Digi_nStrips = -1; b_me0_Digi_chamber = -1; b_me0_Digi_layer = -1; b_me0_Digi_etaPartition = -1; + /* me0 seg*/ + b_me0_Seg_chamber = -1, b_me0_Seg_layer = -1, b_me0_Seg_nRecHits = -1; + b_me0_Seg_eta = -9; + /*me0 rechit*/ + b_me0_RecHit_etaPartition = -1; + b_me0_RecHit_eta = -9; + + /* me11 digi*/ + b_me11_Digi_firstStrip = -1; b_me11_Digi_nStrips = -1; b_me11_Digi_chamber = -1; b_me11_Digi_layer = -1; b_me11_Digi_etaPartition = -1; + /* me11 seg*/ + b_me11_Seg_chamber = -1, b_me11_Seg_layer = -1, b_me11_Seg_nRecHits = -1; + b_me11_Seg_eta = -9; + /*me11 rechit*/ + b_me11_RecHit_etaPartition = -1; + b_me11_RecHit_eta = -9; + + /* ge11 digi*/ + b_ge11_Digi_firstStrip = -1; b_ge11_Digi_nStrips = -1; b_ge11_Digi_chamber = -1; b_ge11_Digi_layer = -1; b_ge11_Digi_etaPartition = -1; + /* ge11 seg*/ + b_ge11_Seg_chamber = -1, b_ge11_Seg_layer = -1, b_ge11_Seg_nRecHits = -1; + b_ge11_Seg_eta = -9; + /*ge11 rechit*/ + b_ge11_RecHit_etaPartition = -1; + b_ge11_RecHit_eta = -9; + +} //define this as a plug-in DEFINE_FWK_MODULE(HGCalSimTest); diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index 2bc6fbec5b3..f35a3875cda 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -19,7 +19,9 @@ process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) process.source.skipEvents = cms.untracked.uint32(0) -process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') +process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') +#process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_050.root') +#process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') #from glob import glob #process.source.fileNames.append('file:/cms/ldap_home/yckang/me0/CMSSW_10_4_0/src/MuonPerformance/MuonAnalyser/test/tenMu_GEN-SIM-DIGI.root') @@ -32,10 +34,17 @@ ) process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) - process.HGCalSimTest = cms.EDAnalyzer('HGCalSimTest', me0Digis = cms.InputTag("simMuonME0Digis"), me0Segments = cms.InputTag("me0Segments"), + me0RecHits = cms.InputTag("me0RecHits"), + cscSegments = cms.InputTag("cscSegments"), + csc2DRecHits = cms.InputTag("csc2DRecHits"), + gemDigis = cms.InputTag("simMuonGEMDigis"), + gemSegments = cms.InputTag("gemSegments"), + gemRecHits = cms.InputTag("gemRecHits"), + + ) process.p = cms.Path(process.HGCalSimTest) From 3eaa7e3f29694ba76fc481b9483c7b7f7241ea8a Mon Sep 17 00:00:00 2001 From: jang00777 Date: Mon, 4 Feb 2019 02:14:51 +0900 Subject: [PATCH 34/50] Save all stations and rings and add DT and RPC (cleaning up the code will be started later...) --- MuonAnalyser/plugins/HGCalSimTest.cc | 666 ++++++++++++------ MuonAnalyser/test/runHGCalSimTest.py | 6 +- MuonAnalyser/test/runHGCalSimTest_modified.py | 12 + 3 files changed, 465 insertions(+), 219 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 547dc1191e9..f9b2b64b41d 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -17,7 +17,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" - +// ME0 #include "DataFormats/GEMDigi/interface/ME0DigiCollection.h" #include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" #include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" @@ -25,7 +25,7 @@ #include "Geometry/GEMGeometry/interface/ME0Geometry.h" #include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" #include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" - +// GEM #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" #include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" @@ -33,14 +33,29 @@ #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" - -//#include "DataFormats/CSCRecHit/interface/CSCDigiCollection.h" +// CSC #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" -//#include "Geometry/CSCGeometry/interface/CSCEtaPartition.h" -//#include "Geometry/CSCGeometry/interface/CSCEtaPartitionSpecs.h" +// DT +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +//#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/MuonDetId/interface/DTBtiId.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "DataFormats/MuonDetId/interface/DTLayerId.h" +#include "DataFormats/MuonDetId/interface/DTSectCollId.h" +#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "DataFormats/MuonDetId/interface/DTTracoId.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +// RPC +#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -76,145 +91,223 @@ class HGCalSimTest : public edm::EDAnalyzer { void initValue(); // ----------member data --------------------------- - edm::EDGetTokenT me0Digis_; - edm::EDGetTokenT me0Segments_; - edm::EDGetTokenT me0RecHits_; + edm::EDGetTokenT me0Digis_; + edm::EDGetTokenT me0Segments_; + edm::EDGetTokenT me0RecHits_; - edm::EDGetTokenT cscSegments_; - edm::EDGetTokenT cscRecHits_; + edm::EDGetTokenT cscSegments_; + edm::EDGetTokenT csc2DRecHits_; - edm::EDGetTokenT gemDigis_; - edm::EDGetTokenT gemSegments_; - edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT gemDigis_; + edm::EDGetTokenT gemSegments_; + edm::EDGetTokenT gemRecHits_; - edm::Service fs; + edm::EDGetTokenT dtDigis_; + edm::EDGetTokenT dt4DSegments_; + edm::EDGetTokenT dtRecHits_; + + edm::EDGetTokenT rpcDigis_; + edm::EDGetTokenT rpcRecHits_; + edm::Service fs; TTree *t_event; int b_run, b_lumi, b_latency; - int b_nME0Digis, b_nME0Segments, b_nME0RecHits, b_nCSCSegments, b_nCSCRecHits, b_nGEMDigis, b_nGEMSegments, b_nGEMRecHits; - - /* me0 */ - TTree *t_me0_digi; - int b_me0_Digi_firstStrip, b_me0_Digi_nStrips, b_me0_Digi_chamber, b_me0_Digi_layer, b_me0_Digi_etaPartition; - - TTree *t_me0_seg; - int b_me0_Seg_chamber, b_me0_Seg_layer, b_me0_Seg_nRecHits; - float b_me0_Seg_eta; - - TTree *t_me0_rec; - int b_me0_RecHit_chamber, b_me0_RecHit_layer, b_me0_RecHit_etaPartition; - float b_me0_RecHit_eta; - - /* me11 */ - TTree *t_me11_digi; - int b_me11_Digi_firstStrip, b_me11_Digi_nStrips, b_me11_Digi_chamber, b_me11_Digi_layer, b_me11_Digi_etaPartition; - - TTree *t_me11_seg; - int b_me11_Seg_chamber, b_me11_Seg_layer, b_me11_Seg_nRecHits; - float b_me11_Seg_eta; + int b_nME0Digis, b_nME0Segments, b_nME0RecHits, b_nCSCSegments, b_nCSC2DRecHits, b_nGEMDigis, b_nGEMSegments, b_nGEMRecHits, b_nDTDigis, b_nDT4DSegments, b_nDTRecHits, b_nRPCDigis, b_nRPCRecHits; + + /* ME0 */ + TTree *t_ME0_digi; + int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition; + TTree *t_ME0_seg; + int b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; + float b_ME0_Seg_eta; + TTree *t_ME0_rec; + int b_ME0_RecHit_chamber, b_ME0_RecHit_layer, b_ME0_RecHit_etaPartition; + float b_ME0_RecHit_eta; + + /* CSC */ + TTree *t_CSC_seg; + int b_CSC_Seg_chamber, b_CSC_Seg_layer, b_CSC_Seg_station, b_CSC_Seg_ring, b_CSC_Seg_nRecHits; + float b_CSC_Seg_eta; + TTree *t_CSC_rec; + int b_CSC_2DRecHit_chamber, b_CSC_2DRecHit_layer, b_CSC_2DRecHit_station, b_CSC_2DRecHit_ring, b_CSC_2DRecHit_etaPartition; + float b_CSC_2DRecHit_eta; + + /* GEM */ + TTree *t_GEM_digi; + int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition; + TTree *t_GEM_seg; + int b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_nRecHits; + float b_GEM_Seg_eta; + TTree *t_GEM_rec; + int b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_etaPartition; + float b_GEM_RecHit_eta; + + /* DT */ + TTree *t_DT_digi; + int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station; + TTree *t_DT_seg; + int b_DT_4DSeg_chamber, b_DT_4DSeg_layer, b_DT_4DSeg_superLayer, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits; + float b_DT_4DSeg_eta; + TTree *t_DT_rec; + int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station; + float b_DT_RecHit_eta; + + /* RPC */ + TTree *t_RPC_digi; + int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector; + int b_RPC_Digi_isIRPC; + TTree *t_RPC_rec; + int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector; + int b_RPC_RecHit_isIRPC; + float b_RPC_RecHit_eta; - TTree *t_me11_rec; - int b_me11_RecHit_chamber, b_me11_RecHit_layer, b_me11_RecHit_etaPartition; - float b_me11_RecHit_eta; - - /* ge11 */ - TTree *t_ge11_digi; - int b_ge11_Digi_firstStrip, b_ge11_Digi_nStrips, b_ge11_Digi_chamber, b_ge11_Digi_layer, b_ge11_Digi_etaPartition; - - TTree *t_ge11_seg; - int b_ge11_Seg_chamber, b_ge11_Seg_layer, b_ge11_Seg_nRecHits; - float b_ge11_Seg_eta; - - TTree *t_ge11_rec; - int b_ge11_RecHit_chamber, b_ge11_RecHit_layer, b_ge11_RecHit_etaPartition; - float b_ge11_RecHit_eta; }; HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) { - me0Digis_ = consumes(iConfig.getParameter("me0Digis")); - me0Segments_ = consumes(iConfig.getParameter("me0Segments")); - me0RecHits_ = consumes(iConfig.getParameter("me0RecHits")); + me0Digis_ = consumes(iConfig.getParameter("me0Digis")); + me0Segments_ = consumes(iConfig.getParameter("me0Segments")); + me0RecHits_ = consumes(iConfig.getParameter("me0RecHits")); - cscSegments_ = consumes(iConfig.getParameter("cscSegments")); - cscRecHits_ = consumes(iConfig.getParameter("csc2DRecHits")); + cscSegments_ = consumes(iConfig.getParameter("cscSegments")); + csc2DRecHits_ = consumes(iConfig.getParameter("csc2DRecHits")); - gemDigis_ = consumes(iConfig.getParameter("gemDigis")); - gemSegments_ = consumes(iConfig.getParameter("gemSegments")); - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + gemDigis_ = consumes(iConfig.getParameter("gemDigis")); + gemSegments_ = consumes(iConfig.getParameter("gemSegments")); + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + dtDigis_ = consumes(iConfig.getParameter("dtDigis")); + dt4DSegments_ = consumes(iConfig.getParameter("dt4DSegments")); + dtRecHits_ = consumes(iConfig.getParameter("dtRecHits")); + + rpcDigis_ = consumes(iConfig.getParameter("rpcDigis")); + rpcRecHits_ = consumes(iConfig.getParameter("rpcRecHits")); - t_event = fs->make("Event", "Event"); - t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); - t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); - t_event->Branch("nME0RecHits", &b_nME0RecHits, "nME0RecHits/I"); - t_event->Branch("nCSCSegments", &b_nCSCSegments, "nCSCSegments/I"); - t_event->Branch("nCSCRecHits", &b_nCSCRecHits, "nCSCRecHits/I"); - t_event->Branch("nGEMDigis", &b_nGEMDigis, "nGEMDigis/I"); - t_event->Branch("nGEMSegments", &b_nGEMSegments, "nGEMSegments/I"); - t_event->Branch("nGEMRecHits", &b_nGEMRecHits, "nGEMRecHits/I"); - - /*me0*/ - t_me0_digi = fs->make("ME0_Hit", "ME0_Hit"); - t_me0_digi->Branch("Digi_firstStrip", &b_me0_Digi_firstStrip, "Digi_firstStrip/I"); - t_me0_digi->Branch("Digi_nStrips", &b_me0_Digi_nStrips, "Digi_nStrips/I"); - t_me0_digi->Branch("Digi_chamber", &b_me0_Digi_chamber, "Digi_chamber/I"); - t_me0_digi->Branch("Digi_layer", &b_me0_Digi_layer, "Digi_layer/I"); - t_me0_digi->Branch("Digi_etaPartition", &b_me0_Digi_etaPartition, "Digi_etaPartition/I"); - - t_me0_seg = fs->make("ME0_Segment", "ME0_Segment"); - t_me0_seg->Branch("Seg_eta", &b_me0_Seg_eta, "Seg_eta/F"); - t_me0_seg->Branch("Seg_chamber", &b_me0_Seg_chamber, "Seg_chamber/I"); - t_me0_seg->Branch("Seg_layer", &b_me0_Seg_layer, "Seg_layer/I"); - t_me0_seg->Branch("Seg_nRecHits", &b_me0_Seg_nRecHits, "Seg_nRecHits/I"); - - t_me0_rec = fs->make("ME0_RecHit", "ME0_RecHit"); - t_me0_rec->Branch("RecHit_chamber", &b_me0_RecHit_chamber, "RecHit_chaber/I"); - t_me0_rec->Branch("RecHit_layer", &b_me0_RecHit_layer, "RecHit_layer/I"); - t_me0_rec->Branch("RecHit_etaPartition", &b_me0_RecHit_etaPartition, "RecHit_etaParition/I"); - t_me0_rec->Branch("RecHit_eta", &b_me0_RecHit_eta, "RecHit_eta/F"); - - /*me11*/ - t_me11_digi = fs->make("ME11_Hit", "ME11_Hit"); - t_me11_digi->Branch("Digi_firstStrip", &b_me11_Digi_firstStrip, "Digi_firstStrip/I"); - t_me11_digi->Branch("Digi_nStrips", &b_me11_Digi_nStrips, "Digi_nStrips/I"); - t_me11_digi->Branch("Digi_chamber", &b_me11_Digi_chamber, "Digi_chamber/I"); - t_me11_digi->Branch("Digi_layer", &b_me11_Digi_layer, "Digi_layer/I"); - t_me11_digi->Branch("Digi_etaPartition", &b_me11_Digi_etaPartition, "Digi_etaPartition/I"); - - t_me11_seg = fs->make("ME11_Segment", "ME11_Segment"); - t_me11_seg->Branch("Seg_eta", &b_me11_Seg_eta, "Seg_eta/F"); - t_me11_seg->Branch("Seg_chamber", &b_me11_Seg_chamber, "Seg_chamber/I"); - t_me11_seg->Branch("Seg_layer", &b_me11_Seg_layer, "Seg_layer/I"); - t_me11_seg->Branch("Seg_nRecHits", &b_me11_Seg_nRecHits, "Seg_nRecHits/I"); - - t_me11_rec = fs->make("ME11_RecHit", "ME11_RecHit"); - t_me11_rec->Branch("RecHit_chamber", &b_me11_RecHit_chamber, "RecHit_chaber/I"); - t_me11_rec->Branch("RecHit_layer", &b_me11_RecHit_layer, "RecHit_layer/I"); - t_me11_rec->Branch("RecHit_etaPartition", &b_me11_RecHit_etaPartition, "RecHit_etaParition/I"); - t_me11_rec->Branch("RecHit_eta", &b_me11_RecHit_eta, "RecHit_eta/F"); - - /*ge11*/ - t_ge11_digi = fs->make("GE11_Hit", "GE11_Hit"); - t_ge11_digi->Branch("Digi_firstStrip", &b_ge11_Digi_firstStrip, "Digi_firstStrip/I"); - t_ge11_digi->Branch("Digi_nStrips", &b_ge11_Digi_nStrips, "Digi_nStrips/I"); - t_ge11_digi->Branch("Digi_chamber", &b_ge11_Digi_chamber, "Digi_chamber/I"); - t_ge11_digi->Branch("Digi_layer", &b_ge11_Digi_layer, "Digi_layer/I"); - t_ge11_digi->Branch("Digi_etaPartition", &b_ge11_Digi_etaPartition, "Digi_etaPartition/I"); - - t_ge11_seg = fs->make("GE11_Segment", "GE11_Segment"); - t_ge11_seg->Branch("Seg_eta", &b_ge11_Seg_eta, "Seg_eta/F"); - t_ge11_seg->Branch("Seg_chamber", &b_ge11_Seg_chamber, "Seg_chamber/I"); - t_ge11_seg->Branch("Seg_layer", &b_ge11_Seg_layer, "Seg_layer/I"); - t_ge11_seg->Branch("Seg_nRecHits", &b_ge11_Seg_nRecHits, "Seg_nRecHits/I"); - - t_ge11_rec = fs->make("GE11_RecHit", "GE11_RecHit"); - t_ge11_rec->Branch("RecHit_chamber", &b_ge11_RecHit_chamber, "RecHit_chaber/I"); - t_ge11_rec->Branch("RecHit_layer", &b_ge11_RecHit_layer, "RecHit_layer/I"); - t_ge11_rec->Branch("RecHit_etaPartition", &b_ge11_RecHit_etaPartition, "RecHit_etaParition/I"); - t_ge11_rec->Branch("RecHit_eta", &b_ge11_RecHit_eta, "RecHit_eta/F"); + t_event = fs->make("Event", "Event"); + t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); + t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); + t_event->Branch("nME0RecHits", &b_nME0RecHits, "nME0RecHits/I"); + t_event->Branch("nCSCSegments", &b_nCSCSegments, "nCSCSegments/I"); + t_event->Branch("nCSC2DRecHits", &b_nCSC2DRecHits, "nCSC2DRecHits/I"); + t_event->Branch("nGEMDigis", &b_nGEMDigis, "nGEMDigis/I"); + t_event->Branch("nGEMSegments", &b_nGEMSegments, "nGEMSegments/I"); + t_event->Branch("nGEMRecHits", &b_nGEMRecHits, "nGEMRecHits/I"); + t_event->Branch("nDTDigis", &b_nDTDigis, "nDTDigis/I"); + t_event->Branch("nDT4DSegments", &b_nDT4DSegments, "nDT4DSegments/I"); + t_event->Branch("nDTRecHits", &b_nDTRecHits, "nDTRecHits/I"); + t_event->Branch("nRPCDigis", &b_nRPCDigis, "nRPCDigis/I"); + t_event->Branch("nRPCRecHits", &b_nRPCRecHits, "nRPCRecHits/I"); + + /*ME0*/ + t_ME0_digi = fs->make("ME0_Hit", "ME0_Hit"); + t_ME0_digi->Branch("Digi_chamber", &b_ME0_Digi_chamber, "Digi_chamber/I"); + t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); + t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); + + t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); + t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); + t_ME0_seg->Branch("Seg_chamber", &b_ME0_Seg_chamber, "Seg_chamber/I"); + t_ME0_seg->Branch("Seg_layer", &b_ME0_Seg_layer, "Seg_layer/I"); + t_ME0_seg->Branch("Seg_nRecHits", &b_ME0_Seg_nRecHits, "Seg_nRecHits/I"); + + t_ME0_rec = fs->make("ME0_RecHit", "ME0_RecHit"); + t_ME0_rec->Branch("RecHit_chamber", &b_ME0_RecHit_chamber, "RecHit_chaber/I"); + t_ME0_rec->Branch("RecHit_layer", &b_ME0_RecHit_layer, "RecHit_layer/I"); + t_ME0_rec->Branch("RecHit_etaPartition", &b_ME0_RecHit_etaPartition, "RecHit_etaParition/I"); + t_ME0_rec->Branch("RecHit_eta", &b_ME0_RecHit_eta, "RecHit_eta/F"); + + /*CSC*/ + t_CSC_seg = fs->make("CSC_Segment", "CSC_Segment"); + t_CSC_seg->Branch("Seg_eta", &b_CSC_Seg_eta, "Seg_eta/F"); + t_CSC_seg->Branch("Seg_chamber", &b_CSC_Seg_chamber, "Seg_chamber/I"); + t_CSC_seg->Branch("Seg_layer", &b_CSC_Seg_layer, "Seg_layer/I"); + t_CSC_seg->Branch("Seg_nRecHits", &b_CSC_Seg_nRecHits, "Seg_nRecHits/I"); + t_CSC_seg->Branch("Seg_station", &b_CSC_Seg_station, "Seg_station/I"); + t_CSC_seg->Branch("Seg_ring", &b_CSC_Seg_ring, "Seg_ring/I"); + + t_CSC_rec = fs->make("CSC_2DRecHit", "CSC_2DRecHit"); + t_CSC_rec->Branch("RecHit_chamber", &b_CSC_2DRecHit_chamber, "RecHit_chaber/I"); + t_CSC_rec->Branch("RecHit_layer", &b_CSC_2DRecHit_layer, "RecHit_layer/I"); + t_CSC_rec->Branch("RecHit_etaPartition", &b_CSC_2DRecHit_etaPartition, "RecHit_etaParition/I"); + t_CSC_rec->Branch("RecHit_eta", &b_CSC_2DRecHit_eta, "RecHit_eta/F"); + t_CSC_rec->Branch("RecHit_station", &b_CSC_2DRecHit_station, "RecHit_station/I"); + t_CSC_rec->Branch("RecHit_ring", &b_CSC_2DRecHit_ring, "RecHit_ring/I"); + + /*GEM*/ + t_GEM_digi = fs->make("GEM_Hit", "GEM_Hit"); + t_GEM_digi->Branch("Digi_chamber", &b_GEM_Digi_chamber, "Digi_chamber/I"); + t_GEM_digi->Branch("Digi_layer", &b_GEM_Digi_layer, "Digi_layer/I"); + t_GEM_digi->Branch("Digi_etaPartition", &b_GEM_Digi_etaPartition, "Digi_etaPartition/I"); + t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); + t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); + + t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); + t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); + t_GEM_seg->Branch("Seg_chamber", &b_GEM_Seg_chamber, "Seg_chamber/I"); + t_GEM_seg->Branch("Seg_layer", &b_GEM_Seg_layer, "Seg_layer/I"); + t_GEM_seg->Branch("Seg_nRecHits", &b_GEM_Seg_nRecHits, "Seg_nRecHits/I"); + t_GEM_seg->Branch("Seg_station", &b_GEM_Seg_station, "Seg_station/I"); + t_GEM_seg->Branch("Seg_ring", &b_GEM_Seg_ring, "Seg_ring/I"); + + t_GEM_rec = fs->make("GEM_RecHit", "GEM_RecHit"); + t_GEM_rec->Branch("RecHit_chamber", &b_GEM_RecHit_chamber, "RecHit_chaber/I"); + t_GEM_rec->Branch("RecHit_layer", &b_GEM_RecHit_layer, "RecHit_layer/I"); + t_GEM_rec->Branch("RecHit_etaPartition", &b_GEM_RecHit_etaPartition, "RecHit_etaParition/I"); + t_GEM_rec->Branch("RecHit_eta", &b_GEM_RecHit_eta, "RecHit_eta/F"); + t_GEM_rec->Branch("RecHit_station", &b_GEM_RecHit_station, "RecHit_station/I"); + t_GEM_rec->Branch("RecHit_ring", &b_GEM_RecHit_ring, "RecHit_ring/I"); + + /*DT*/ + t_DT_digi = fs->make("DT_Hit", "DT_Hit"); + t_DT_digi->Branch("Digi_chamber", &b_DT_Digi_chamber, "Digi_chamber/I"); + t_DT_digi->Branch("Digi_layer", &b_DT_Digi_layer, "Digi_layer/I"); + t_DT_digi->Branch("Digi_superLayer", &b_DT_Digi_superLayer, "Digi_superLayer/I"); + t_DT_digi->Branch("Digi_wheel", &b_DT_Digi_wheel, "Digi_wheel/I"); + t_DT_digi->Branch("Digi_sector", &b_DT_Digi_sector, "Digi_sector/I"); + t_DT_digi->Branch("Digi_station", &b_DT_Digi_station, "Digi_station/I"); + + t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); + t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); + t_DT_seg->Branch("Seg_chamber", &b_DT_4DSeg_chamber, "Seg_chamber/I"); + t_DT_seg->Branch("Seg_layer", &b_DT_4DSeg_layer, "Seg_layer/I"); + t_DT_seg->Branch("Seg_superLayer", &b_DT_4DSeg_superLayer, "Seg_superLayer/I"); + t_DT_seg->Branch("Seg_nRecHits", &b_DT_4DSeg_nRecHits, "Seg_nRecHits/I"); + t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); + t_DT_seg->Branch("Seg_sector", &b_DT_4DSeg_sector, "Seg_sector/I"); + t_DT_seg->Branch("Seg_station", &b_DT_4DSeg_station, "Seg_station/I"); + + t_DT_rec = fs->make("DT_RecHit", "DT_RecHit"); + t_DT_rec->Branch("RecHit_chamber", &b_DT_RecHit_chamber, "RecHit_chaber/I"); + t_DT_rec->Branch("RecHit_layer", &b_DT_RecHit_layer, "RecHit_layer/I"); + t_DT_rec->Branch("RecHit_superLayer", &b_DT_RecHit_superLayer, "RecHit_superLayer/I"); + t_DT_rec->Branch("RecHit_eta", &b_DT_RecHit_eta, "RecHit_eta/F"); + t_DT_rec->Branch("RecHit_wheel", &b_DT_RecHit_wheel, "RecHit_wheel/I"); + t_DT_rec->Branch("RecHit_sector", &b_DT_RecHit_sector, "RecHit_sector/I"); + t_DT_rec->Branch("RecHit_station", &b_DT_RecHit_station, "RecHit_station/I"); + + /*RPC*/ + t_RPC_digi = fs->make("RPC_Hit", "RPC_Hit"); + t_RPC_digi->Branch("Digi_chamber", &b_RPC_Digi_chamber, "Digi_chamber/I"); + t_RPC_digi->Branch("Digi_layer", &b_RPC_Digi_layer, "Digi_layer/I"); + t_RPC_digi->Branch("Digi_station", &b_RPC_Digi_station, "Digi_station/I"); + t_RPC_digi->Branch("Digi_ring", &b_RPC_Digi_ring, "Digi_ring/I"); + t_RPC_digi->Branch("Digi_roll", &b_RPC_Digi_roll, "Digi_roll/I"); + t_RPC_digi->Branch("Digi_sector", &b_RPC_Digi_sector, "Digi_sector/I"); + t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); + t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); + + t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); + t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); + t_RPC_rec->Branch("RecHit_layer", &b_RPC_RecHit_layer, "RecHit_layer/I"); + t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); + t_RPC_rec->Branch("RecHit_station", &b_RPC_RecHit_station, "RecHit_station/I"); + t_RPC_rec->Branch("RecHit_ring", &b_RPC_RecHit_ring, "RecHit_ring/I"); + t_RPC_rec->Branch("RecHit_roll", &b_RPC_RecHit_roll, "RecHit_roll/I"); + t_RPC_rec->Branch("RecHit_sector", &b_RPC_RecHit_sector, "RecHit_sector/I"); + t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); + t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); } @@ -247,10 +340,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) edm::Handle cscSegments; iEvent.getByToken(cscSegments_, cscSegments); - edm::Handle cscRecHits; - iEvent.getByToken(cscRecHits_, cscRecHits); + edm::Handle csc2DRecHits; + iEvent.getByToken(csc2DRecHits_, csc2DRecHits); - /* Gem Geometry */ + /* GEM Geometry */ edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); const GEMGeometry* GEMGeometry_ = &*hGEMGeom; @@ -264,22 +357,47 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) edm::Handle gemRecHits; iEvent.getByToken(gemRecHits_, gemRecHits); + /* DT Geometry */ + edm::ESHandle hDTGeom; + iSetup.get().get(hDTGeom); + const DTGeometry* DTGeometry_ = &*hDTGeom; + + edm::Handle dtDigis; + iEvent.getByToken(dtDigis_, dtDigis); + + edm::Handle dt4DSegments; + iEvent.getByToken(dt4DSegments_, dt4DSegments); + + edm::Handle dtRecHits; + iEvent.getByToken(dtRecHits_, dtRecHits); + + /* RPC Geometry */ + edm::ESHandle hRPCGeom; + iSetup.get().get(hRPCGeom); + const RPCGeometry* RPCGeometry_ = &*hRPCGeom; + + edm::Handle rpcDigis; + iEvent.getByToken(rpcDigis_, rpcDigis); + + edm::Handle rpcRecHits; + iEvent.getByToken(rpcRecHits_, rpcRecHits); + initValue(); for (auto ch : ME0Geometry_->chambers()) { - /* me0 seg */ + /* ME0 seg */ ME0DetId cId = ch->id(); auto segsRange = me0Segments->get(cId); - b_me0_Seg_chamber = cId.chamber(); + b_ME0_Seg_chamber = cId.chamber(); auto me0Seg = segsRange.first; for (auto seg = me0Seg; seg != segsRange.second; ++seg) { auto segLd = me0Seg->localPosition(); auto gp = ch->toGlobal(segLd); - b_me0_Seg_eta = gp.eta(); - b_me0_Seg_nRecHits = me0Seg->nRecHits(); - std::cout << b_me0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_me0_Seg_nRecHits << std::endl; + b_ME0_Seg_eta = gp.eta(); + b_ME0_Seg_nRecHits = me0Seg->nRecHits(); + std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; b_nME0Segments++; - t_me0_seg->Fill(); + t_ME0_seg->Fill(); } for (auto ly : ch->layers()) { for (auto roll : ly->etaPartitions()) { @@ -287,115 +405,209 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) int roll_ = rId.roll(); int chamber = rId.chamber(); int layer = rId.layer(); - /* me0 digi */ + /* ME0 digi */ auto digisRange = me0Digis->get(rId); auto me0Digi = digisRange.first; - b_me0_Digi_chamber = chamber; - b_me0_Digi_layer = layer; + b_ME0_Digi_chamber = chamber; + b_ME0_Digi_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { - int strip = hit->strip(); - b_me0_Digi_firstStrip = strip; - b_me0_Digi_etaPartition = roll_; - t_me0_digi->Fill(); + b_ME0_Digi_etaPartition = roll_; + t_ME0_digi->Fill(); b_nME0Digis++; } - /* me0 RecHit */ + /* ME0 RecHit */ auto recRange = me0RecHits->get(rId); auto me0Rec = recRange.first; - b_me0_RecHit_chamber = chamber; - b_me0_RecHit_layer = layer; + b_ME0_RecHit_chamber = chamber; + b_ME0_RecHit_layer = layer; for (auto rec = me0Rec; rec != recRange.second; ++rec) { auto recLd = me0Rec->localPosition(); auto gp = roll->toGlobal(recLd); - b_me0_RecHit_eta = gp.eta(); - b_me0_RecHit_etaPartition = roll_; - std::cout << b_me0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; + b_ME0_RecHit_eta = gp.eta(); + b_ME0_RecHit_etaPartition = roll_; + std::cout << b_ME0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; b_nME0RecHits++; - t_me0_rec->Fill(); + t_ME0_rec->Fill(); } } } } for (auto ch : CSCGeometry_->chambers()) { - /* me11 seg */ + /* CSC seg */ CSCDetId cId = ch->id(); - if (cId.ring() != 1 || cId.station() != 1) continue; // choose me11 + b_CSC_Seg_station = cId.station(); + b_CSC_2DRecHit_station = cId.station(); + b_CSC_Seg_ring = cId.ring(); + b_CSC_2DRecHit_ring = cId.ring(); + b_CSC_Seg_chamber = cId.chamber(); + b_CSC_2DRecHit_chamber = cId.chamber(); + b_CSC_Seg_layer = cId.layer(); + b_CSC_2DRecHit_layer = cId.layer(); + auto segsRange = cscSegments->get(cId); - b_me11_Seg_chamber = cId.chamber(); auto cscSeg = segsRange.first; for (auto seg = cscSeg; seg != segsRange.second; ++seg) { auto segLd = cscSeg->localPosition(); auto gp = ch->toGlobal(segLd); - b_me11_Seg_eta = gp.eta(); - b_me11_Seg_nRecHits = cscSeg->nRecHits(); + b_CSC_Seg_eta = gp.eta(); + b_CSC_Seg_nRecHits = cscSeg->nRecHits(); b_nCSCSegments++; - t_me11_seg->Fill(); + t_CSC_seg->Fill(); } for (auto ly : ch->layers()) { CSCDetId lId = ly->id(); - int chamber = lId.chamber(); - int layer = lId.layer(); - /* me11 digi */ - /* me11 rechit */ - auto recRange = cscRecHits->get(lId); + /* CSC rechit */ + auto recRange = csc2DRecHits->get(lId); auto cscRec = recRange.first; - b_me11_RecHit_chamber = chamber; - b_me11_RecHit_layer = layer; for (auto rec = cscRec; rec != recRange.second; ++rec) { auto recLd = cscRec->localPosition(); auto gp = ly->toGlobal(recLd); - b_me11_RecHit_eta = gp.eta(); - b_nCSCRecHits++; - t_me11_rec->Fill(); + b_CSC_2DRecHit_eta = gp.eta(); + b_nCSC2DRecHits++; + t_CSC_rec->Fill(); } } } for (auto ch : GEMGeometry_->chambers()) { - /* ge11 seg */ + /* GEM seg */ GEMDetId cId = ch->id(); - if (cId.station() != 1 || (cId.ring() != 1 && cId.ring() != 2)) continue; // choose ge11 + b_GEM_Digi_station = cId.station(); + b_GEM_Seg_station = cId.station(); + b_GEM_RecHit_station = cId.station(); + b_GEM_Digi_ring = cId.ring(); + b_GEM_Seg_ring = cId.ring(); + b_GEM_RecHit_ring = cId.ring(); + b_GEM_Digi_chamber = cId.chamber(); + b_GEM_Seg_chamber = cId.chamber(); + b_GEM_RecHit_chamber = cId.chamber(); + b_GEM_Digi_layer = cId.layer(); + b_GEM_Seg_layer = cId.layer(); + b_GEM_RecHit_layer = cId.layer(); + auto segsRange = gemSegments->get(cId); - b_ge11_Seg_chamber = cId.chamber(); auto gemSeg = segsRange.first; for (auto seg = gemSeg; seg != segsRange.second; ++seg) { auto segLd = gemSeg->localPosition(); auto gp = ch->toGlobal(segLd); - b_ge11_Seg_eta = gp.eta(); - b_ge11_Seg_nRecHits = gemSeg->nRecHits(); + b_GEM_Seg_eta = gp.eta(); + b_GEM_Seg_nRecHits = gemSeg->nRecHits(); b_nGEMSegments++; - t_ge11_seg->Fill(); + t_GEM_seg->Fill(); } for (auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); int roll_ = rId.roll(); - int chamber = rId.chamber(); - int layer = rId.layer(); - /* ge11 digi */ + /* GEM digi */ auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; - b_ge11_Digi_chamber = chamber; - b_ge11_Digi_layer = layer; for (auto hit = gemDigi; hit != digisRange.second; ++hit) { - int strip = hit->strip(); - b_ge11_Digi_firstStrip = strip; - b_ge11_Digi_etaPartition = roll_; - t_ge11_digi->Fill(); + b_GEM_Digi_etaPartition = roll_; + t_GEM_digi->Fill(); b_nGEMDigis++; } - /* ge11 rechit */ + /* GEM rechit */ auto recRange = gemRecHits->get(rId); auto gemRec = recRange.first; - b_ge11_RecHit_chamber = chamber; - b_ge11_RecHit_layer = layer; for (auto rec = gemRec; rec != recRange.second; ++rec) { auto recLd = gemRec->localPosition(); auto gp = roll->toGlobal(recLd); - b_ge11_RecHit_eta = gp.eta(); - b_ge11_RecHit_etaPartition = roll_; + b_GEM_RecHit_eta = gp.eta(); + b_GEM_RecHit_etaPartition = roll_; b_nGEMRecHits++; - t_ge11_rec->Fill(); + t_GEM_rec->Fill(); + } + } + } + + for (auto ch : DTGeometry_->chambers()) { + /* DT seg */ + DTChamberId cId = ch->id(); + b_DT_4DSeg_station = cId.station(); + b_DT_4DSeg_sector = cId.sector(); + b_DT_4DSeg_wheel = cId.wheel(); + //b_DT_4DSeg_chamber = ch->id(); + auto segsRange = dt4DSegments->get(cId); + auto dt4DSeg = segsRange.first; + for (auto seg = dt4DSeg; seg != segsRange.second; ++seg) { + auto segLd = dt4DSeg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_DT_4DSeg_eta = gp.eta(); + b_DT_4DSeg_nRecHits = dt4DSeg->recHits().size(); + b_nDT4DSegments++; + t_DT_seg->Fill(); + } + } + for (auto ly : DTGeometry_->layers()) { + DTLayerId lId = ly->id(); + b_DT_Digi_station = lId.station(); + b_DT_RecHit_station = lId.station(); + b_DT_Digi_sector = lId.sector(); + b_DT_RecHit_sector = lId.sector(); + b_DT_Digi_wheel = lId.wheel(); + b_DT_RecHit_wheel = lId.wheel(); + b_DT_Digi_layer = lId.layer(); + b_DT_RecHit_layer = lId.layer(); + b_DT_Digi_superLayer = lId.superLayer(); + b_DT_RecHit_superLayer = lId.superLayer(); + /* DT digi */ + auto digisRange = dtDigis->get(lId); + auto dtDigi = digisRange.first; + for (auto hit = dtDigi; hit != digisRange.second; ++hit) { + t_DT_digi->Fill(); + b_nDTDigis++; + } + /* DT rechit */ + auto recRange = dtRecHits->get(lId); + auto dtRec = recRange.first; + for (auto rec = dtRec; rec != recRange.second; ++rec) { + auto recLd = dtRec->localPosition(); + auto gp = ly->toGlobal(recLd); + b_DT_RecHit_eta = gp.eta(); + b_nDTRecHits++; + t_DT_rec->Fill(); + } + } + + for (auto ch : RPCGeometry_->chambers()) { + RPCDetId cId = ch->id(); + b_RPC_Digi_station = cId.station(); + b_RPC_RecHit_station = cId.station(); + b_RPC_Digi_ring = cId.ring(); + b_RPC_RecHit_ring = cId.ring(); + //b_RPC_Digi_chamber = cId.chamber(); + //b_RPC_RecHit_chamber = cId.chamber(); + b_RPC_Digi_layer = cId.layer(); + b_RPC_RecHit_layer = cId.layer(); + b_RPC_Digi_sector = cId.sector(); + b_RPC_RecHit_sector = cId.sector(); + b_RPC_Digi_subSector = cId.subsector(); + b_RPC_RecHit_subSector = cId.subsector(); + + for (auto roll : ch->rolls()) { + b_RPC_Digi_isIRPC = (int)roll->isIRPC(); + b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); + RPCDetId rId = roll->id(); + int roll_ = rId.roll(); + /* RPC digi */ + auto digisRange = rpcDigis->get(rId); + auto rpcDigi = digisRange.first; + for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { + b_RPC_Digi_roll = roll_; + t_RPC_digi->Fill(); + b_nRPCDigis++; + } + /* RPC rechit */ + auto recRange = rpcRecHits->get(rId); + auto rpcRec = recRange.first; + for (auto rec = rpcRec; rec != recRange.second; ++rec) { + auto recLd = rpcRec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_RPC_RecHit_eta = gp.eta(); + b_RPC_RecHit_roll = roll_; + b_nRPCRecHits++; + t_RPC_rec->Fill(); } } } @@ -410,37 +622,55 @@ void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ void HGCalSimTest::endRun(Run const&, EventSetup const&){} void HGCalSimTest::initValue() { - b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; - b_nCSCSegments = 0; b_nCSCRecHits = 0; - b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; - - /* me0 digi*/ - b_me0_Digi_firstStrip = -1; b_me0_Digi_nStrips = -1; b_me0_Digi_chamber = -1; b_me0_Digi_layer = -1; b_me0_Digi_etaPartition = -1; - /* me0 seg*/ - b_me0_Seg_chamber = -1, b_me0_Seg_layer = -1, b_me0_Seg_nRecHits = -1; - b_me0_Seg_eta = -9; - /*me0 rechit*/ - b_me0_RecHit_etaPartition = -1; - b_me0_RecHit_eta = -9; - - /* me11 digi*/ - b_me11_Digi_firstStrip = -1; b_me11_Digi_nStrips = -1; b_me11_Digi_chamber = -1; b_me11_Digi_layer = -1; b_me11_Digi_etaPartition = -1; - /* me11 seg*/ - b_me11_Seg_chamber = -1, b_me11_Seg_layer = -1, b_me11_Seg_nRecHits = -1; - b_me11_Seg_eta = -9; - /*me11 rechit*/ - b_me11_RecHit_etaPartition = -1; - b_me11_RecHit_eta = -9; - - /* ge11 digi*/ - b_ge11_Digi_firstStrip = -1; b_ge11_Digi_nStrips = -1; b_ge11_Digi_chamber = -1; b_ge11_Digi_layer = -1; b_ge11_Digi_etaPartition = -1; - /* ge11 seg*/ - b_ge11_Seg_chamber = -1, b_ge11_Seg_layer = -1, b_ge11_Seg_nRecHits = -1; - b_ge11_Seg_eta = -9; - /*ge11 rechit*/ - b_ge11_RecHit_etaPartition = -1; - b_ge11_RecHit_eta = -9; + b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; + b_nCSCSegments = 0; b_nCSC2DRecHits = 0; + b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; + b_nDTDigis = 0; b_nDT4DSegments = 0; b_nDTRecHits = 0; + b_nRPCDigis = 0; b_nRPCRecHits = 0; + + /*ME0 digi*/ + b_ME0_Digi_chamber = -1; b_ME0_Digi_layer = -1; b_ME0_Digi_etaPartition = -1; + /*ME0 seg*/ + b_ME0_Seg_chamber = -1; b_ME0_Seg_layer = -1; b_ME0_Seg_nRecHits = -1; + b_ME0_Seg_eta = -9; + /*ME0 rechit*/ + b_ME0_RecHit_etaPartition = -1; + b_ME0_RecHit_eta = -9; + + /*CSC seg*/ + b_CSC_Seg_chamber = -1; b_CSC_Seg_layer = -1; b_CSC_Seg_station = -1; b_CSC_Seg_ring = -1; b_CSC_Seg_nRecHits = -1; + b_CSC_Seg_eta = -9; + /*CSC rechit*/ + b_CSC_2DRecHit_chamber = -1; b_CSC_2DRecHit_layer = -1; b_CSC_2DRecHit_station = -1; b_CSC_2DRecHit_ring = -1; b_CSC_2DRecHit_etaPartition = -1; + b_CSC_2DRecHit_eta = -9; + + /*GEM digi*/ + b_GEM_Digi_chamber = -1; b_GEM_Digi_layer = -1; b_GEM_Digi_station = -1; b_GEM_Digi_ring = -1; b_GEM_Digi_etaPartition = -1; + /*GEM seg*/ + b_GEM_Seg_chamber = -1; b_GEM_Seg_layer = -1; b_GEM_Seg_station = -1; b_GEM_Seg_ring = -1; b_GEM_Seg_nRecHits = -1; + b_GEM_Seg_eta = -9; + /*GEM rechit*/ + b_GEM_RecHit_chamber = -1; b_GEM_RecHit_layer = -1; b_GEM_RecHit_station = -1; b_GEM_RecHit_ring = -1; b_GEM_RecHit_etaPartition = -1; + b_GEM_RecHit_eta = -9; + + /* DT digi*/ + b_DT_Digi_chamber = -1; b_DT_Digi_layer = -1; b_DT_Digi_superLayer = -1; b_DT_Digi_wheel = -1; b_DT_Digi_sector = -1; b_DT_Digi_station = -1; + /* DT seg*/ + b_DT_4DSeg_chamber = -1; b_DT_4DSeg_layer = -1; b_DT_4DSeg_superLayer = -1; b_DT_4DSeg_wheel = -1; b_DT_4DSeg_sector = -1; b_DT_4DSeg_station = -1; b_DT_4DSeg_nRecHits = -1; + b_DT_4DSeg_eta = -9; + /* DT rechit*/ + b_DT_RecHit_chamber = -1; b_DT_RecHit_layer = -1; b_DT_RecHit_superLayer = -1; b_DT_RecHit_wheel = -1; b_DT_RecHit_sector = -1; b_DT_RecHit_station = -1; + b_DT_RecHit_eta = -9; + + /*RPC digi*/ + b_RPC_Digi_chamber = -1; b_RPC_Digi_layer = -1; b_RPC_Digi_station = -1; b_RPC_Digi_ring = -1; b_RPC_Digi_roll = -1; b_RPC_Digi_sector = -1; b_RPC_Digi_subSector = -1; + b_RPC_Digi_isIRPC = -1; + /*RPC rechit*/ + b_RPC_RecHit_chamber = -1; b_RPC_RecHit_layer = -1; b_RPC_RecHit_station = -1; b_RPC_RecHit_ring = -1; b_RPC_RecHit_roll = -1; b_RPC_RecHit_sector = -1; b_RPC_RecHit_subSector = -1; + b_RPC_RecHit_eta = -9; + b_RPC_RecHit_isIRPC = -1; } + //define this as a plug-in DEFINE_FWK_MODULE(HGCalSimTest); diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index f35a3875cda..c4f006eae66 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -43,7 +43,11 @@ gemDigis = cms.InputTag("simMuonGEMDigis"), gemSegments = cms.InputTag("gemSegments"), gemRecHits = cms.InputTag("gemRecHits"), - + dtDigis = cms.InputTag("simMuonDTDigis"), + dt4DSegments = cms.InputTag("dt4DSegments"), + dtRecHits = cms.InputTag("dt1DRecHits"), + rpcDigis = cms.InputTag("simMuonRPCDigis"), + rpcRecHits = cms.InputTag("rpcRecHits"), ) process.p = cms.Path(process.HGCalSimTest) diff --git a/MuonAnalyser/test/runHGCalSimTest_modified.py b/MuonAnalyser/test/runHGCalSimTest_modified.py index 14e385b42fc..737a35db220 100644 --- a/MuonAnalyser/test/runHGCalSimTest_modified.py +++ b/MuonAnalyser/test/runHGCalSimTest_modified.py @@ -37,6 +37,18 @@ process.HGCalSimTest = cms.EDAnalyzer('HGCalSimTest', me0Digis = cms.InputTag("simMuonME0Digis"), me0Segments = cms.InputTag("me0Segments"), + me0RecHits = cms.InputTag("me0RecHits"), + cscSegments = cms.InputTag("cscSegments"), + csc2DRecHits = cms.InputTag("csc2DRecHits"), + gemDigis = cms.InputTag("simMuonGEMDigis"), + gemSegments = cms.InputTag("gemSegments"), + gemRecHits = cms.InputTag("gemRecHits"), + dtDigis = cms.InputTag("simMuonDTDigis"), + dt4DSegments = cms.InputTag("dt4DSegments"), + dtRecHits = cms.InputTag("dt1DRecHits"), + rpcDigis = cms.InputTag("simMuonRPCDigis"), + rpcRecHits = cms.InputTag("rpcRecHits"), + ) process.p = cms.Path(process.HGCalSimTest) From 21bf3c47089ab979ced1066f6c4a84b3b54d4d5c Mon Sep 17 00:00:00 2001 From: jang00777 Date: Mon, 4 Feb 2019 02:51:47 +0900 Subject: [PATCH 35/50] Save all of rings and stations and add DT and RPC --- MuonAnalyser/plugins/HGCalSimTest.cc | 56 +++++++++++++--------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index f9b2b64b41d..76199808033 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -147,7 +147,7 @@ class HGCalSimTest : public edm::EDAnalyzer { TTree *t_DT_digi; int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station; TTree *t_DT_seg; - int b_DT_4DSeg_chamber, b_DT_4DSeg_layer, b_DT_4DSeg_superLayer, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits; + int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits; float b_DT_4DSeg_eta; TTree *t_DT_rec; int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station; @@ -230,7 +230,6 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_CSC_rec = fs->make("CSC_2DRecHit", "CSC_2DRecHit"); t_CSC_rec->Branch("RecHit_chamber", &b_CSC_2DRecHit_chamber, "RecHit_chaber/I"); t_CSC_rec->Branch("RecHit_layer", &b_CSC_2DRecHit_layer, "RecHit_layer/I"); - t_CSC_rec->Branch("RecHit_etaPartition", &b_CSC_2DRecHit_etaPartition, "RecHit_etaParition/I"); t_CSC_rec->Branch("RecHit_eta", &b_CSC_2DRecHit_eta, "RecHit_eta/F"); t_CSC_rec->Branch("RecHit_station", &b_CSC_2DRecHit_station, "RecHit_station/I"); t_CSC_rec->Branch("RecHit_ring", &b_CSC_2DRecHit_ring, "RecHit_ring/I"); @@ -271,8 +270,6 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); t_DT_seg->Branch("Seg_chamber", &b_DT_4DSeg_chamber, "Seg_chamber/I"); - t_DT_seg->Branch("Seg_layer", &b_DT_4DSeg_layer, "Seg_layer/I"); - t_DT_seg->Branch("Seg_superLayer", &b_DT_4DSeg_superLayer, "Seg_superLayer/I"); t_DT_seg->Branch("Seg_nRecHits", &b_DT_4DSeg_nRecHits, "Seg_nRecHits/I"); t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); t_DT_seg->Branch("Seg_sector", &b_DT_4DSeg_sector, "Seg_sector/I"); @@ -389,6 +386,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) ME0DetId cId = ch->id(); auto segsRange = me0Segments->get(cId); b_ME0_Seg_chamber = cId.chamber(); + b_ME0_Seg_layer = cId.layer(); auto me0Seg = segsRange.first; for (auto seg = me0Seg; seg != segsRange.second; ++seg) { auto segLd = me0Seg->localPosition(); @@ -441,10 +439,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_CSC_Seg_ring = cId.ring(); b_CSC_2DRecHit_ring = cId.ring(); b_CSC_Seg_chamber = cId.chamber(); - b_CSC_2DRecHit_chamber = cId.chamber(); b_CSC_Seg_layer = cId.layer(); - b_CSC_2DRecHit_layer = cId.layer(); - auto segsRange = cscSegments->get(cId); auto cscSeg = segsRange.first; for (auto seg = cscSeg; seg != segsRange.second; ++seg) { @@ -458,6 +453,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto ly : ch->layers()) { CSCDetId lId = ly->id(); /* CSC rechit */ + b_CSC_2DRecHit_chamber = lId.chamber(); + b_CSC_2DRecHit_layer = lId.layer(); auto recRange = csc2DRecHits->get(lId); auto cscRec = recRange.first; for (auto rec = cscRec; rec != recRange.second; ++rec) { @@ -479,13 +476,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_GEM_Digi_ring = cId.ring(); b_GEM_Seg_ring = cId.ring(); b_GEM_RecHit_ring = cId.ring(); - b_GEM_Digi_chamber = cId.chamber(); b_GEM_Seg_chamber = cId.chamber(); - b_GEM_RecHit_chamber = cId.chamber(); - b_GEM_Digi_layer = cId.layer(); b_GEM_Seg_layer = cId.layer(); - b_GEM_RecHit_layer = cId.layer(); - auto segsRange = gemSegments->get(cId); auto gemSeg = segsRange.first; for (auto seg = gemSeg; seg != segsRange.second; ++seg) { @@ -499,6 +491,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); int roll_ = rId.roll(); + b_GEM_Digi_chamber = rId.chamber(); + b_GEM_RecHit_chamber = rId.chamber(); + b_GEM_Digi_layer = rId.layer(); + b_GEM_RecHit_layer = rId.layer(); /* GEM digi */ auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; @@ -578,8 +574,6 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_RPC_RecHit_ring = cId.ring(); //b_RPC_Digi_chamber = cId.chamber(); //b_RPC_RecHit_chamber = cId.chamber(); - b_RPC_Digi_layer = cId.layer(); - b_RPC_RecHit_layer = cId.layer(); b_RPC_Digi_sector = cId.sector(); b_RPC_RecHit_sector = cId.sector(); b_RPC_Digi_subSector = cId.subsector(); @@ -590,6 +584,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); RPCDetId rId = roll->id(); int roll_ = rId.roll(); + b_RPC_Digi_layer = rId.layer(); + b_RPC_RecHit_layer = rId.layer(); /* RPC digi */ auto digisRange = rpcDigis->get(rId); auto rpcDigi = digisRange.first; @@ -622,51 +618,51 @@ void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ void HGCalSimTest::endRun(Run const&, EventSetup const&){} void HGCalSimTest::initValue() { - b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; - b_nCSCSegments = 0; b_nCSC2DRecHits = 0; - b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; + b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; + b_nCSCSegments = 0; b_nCSC2DRecHits = 0; + b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; b_nDTDigis = 0; b_nDT4DSegments = 0; b_nDTRecHits = 0; b_nRPCDigis = 0; b_nRPCRecHits = 0; /*ME0 digi*/ - b_ME0_Digi_chamber = -1; b_ME0_Digi_layer = -1; b_ME0_Digi_etaPartition = -1; + b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; /*ME0 seg*/ - b_ME0_Seg_chamber = -1; b_ME0_Seg_layer = -1; b_ME0_Seg_nRecHits = -1; + b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; b_ME0_Seg_eta = -9; /*ME0 rechit*/ - b_ME0_RecHit_etaPartition = -1; + b_ME0_RecHit_etaPartition = -9; b_ME0_RecHit_eta = -9; /*CSC seg*/ - b_CSC_Seg_chamber = -1; b_CSC_Seg_layer = -1; b_CSC_Seg_station = -1; b_CSC_Seg_ring = -1; b_CSC_Seg_nRecHits = -1; + b_CSC_Seg_chamber = -9; b_CSC_Seg_layer = -9; b_CSC_Seg_station = -9; b_CSC_Seg_ring = -9; b_CSC_Seg_nRecHits = -9; b_CSC_Seg_eta = -9; /*CSC rechit*/ - b_CSC_2DRecHit_chamber = -1; b_CSC_2DRecHit_layer = -1; b_CSC_2DRecHit_station = -1; b_CSC_2DRecHit_ring = -1; b_CSC_2DRecHit_etaPartition = -1; + b_CSC_2DRecHit_chamber = -9; b_CSC_2DRecHit_layer = -9; b_CSC_2DRecHit_station = -9; b_CSC_2DRecHit_ring = -9; b_CSC_2DRecHit_etaPartition = -9; b_CSC_2DRecHit_eta = -9; /*GEM digi*/ - b_GEM_Digi_chamber = -1; b_GEM_Digi_layer = -1; b_GEM_Digi_station = -1; b_GEM_Digi_ring = -1; b_GEM_Digi_etaPartition = -1; + b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; /*GEM seg*/ - b_GEM_Seg_chamber = -1; b_GEM_Seg_layer = -1; b_GEM_Seg_station = -1; b_GEM_Seg_ring = -1; b_GEM_Seg_nRecHits = -1; + b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_nRecHits = -9; b_GEM_Seg_eta = -9; /*GEM rechit*/ - b_GEM_RecHit_chamber = -1; b_GEM_RecHit_layer = -1; b_GEM_RecHit_station = -1; b_GEM_RecHit_ring = -1; b_GEM_RecHit_etaPartition = -1; + b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_etaPartition = -9; b_GEM_RecHit_eta = -9; /* DT digi*/ - b_DT_Digi_chamber = -1; b_DT_Digi_layer = -1; b_DT_Digi_superLayer = -1; b_DT_Digi_wheel = -1; b_DT_Digi_sector = -1; b_DT_Digi_station = -1; + b_DT_Digi_chamber = -9; b_DT_Digi_layer = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_wheel = -9; b_DT_Digi_sector = -9; b_DT_Digi_station = -9; /* DT seg*/ - b_DT_4DSeg_chamber = -1; b_DT_4DSeg_layer = -1; b_DT_4DSeg_superLayer = -1; b_DT_4DSeg_wheel = -1; b_DT_4DSeg_sector = -1; b_DT_4DSeg_station = -1; b_DT_4DSeg_nRecHits = -1; + b_DT_4DSeg_chamber = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_nRecHits = -9; b_DT_4DSeg_eta = -9; /* DT rechit*/ - b_DT_RecHit_chamber = -1; b_DT_RecHit_layer = -1; b_DT_RecHit_superLayer = -1; b_DT_RecHit_wheel = -1; b_DT_RecHit_sector = -1; b_DT_RecHit_station = -1; + b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_eta = -9; /*RPC digi*/ - b_RPC_Digi_chamber = -1; b_RPC_Digi_layer = -1; b_RPC_Digi_station = -1; b_RPC_Digi_ring = -1; b_RPC_Digi_roll = -1; b_RPC_Digi_sector = -1; b_RPC_Digi_subSector = -1; + b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; b_RPC_Digi_isIRPC = -1; /*RPC rechit*/ - b_RPC_RecHit_chamber = -1; b_RPC_RecHit_layer = -1; b_RPC_RecHit_station = -1; b_RPC_RecHit_ring = -1; b_RPC_RecHit_roll = -1; b_RPC_RecHit_sector = -1; b_RPC_RecHit_subSector = -1; + b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; b_RPC_RecHit_eta = -9; b_RPC_RecHit_isIRPC = -1; From a9e28b0b0f4411ea026231ed5b061341c6060fe0 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 5 Feb 2019 20:32:22 +0900 Subject: [PATCH 36/50] Add eta for digi and wire for DT --- MuonAnalyser/plugins/HGCalSimTest.cc | 42 ++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 76199808033..6e2c18876cd 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -118,6 +118,7 @@ class HGCalSimTest : public edm::EDAnalyzer { /* ME0 */ TTree *t_ME0_digi; int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition; + float b_ME0_Digi_eta; TTree *t_ME0_seg; int b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; float b_ME0_Seg_eta; @@ -136,6 +137,7 @@ class HGCalSimTest : public edm::EDAnalyzer { /* GEM */ TTree *t_GEM_digi; int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition; + float b_GEM_Digi_eta; TTree *t_GEM_seg; int b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_nRecHits; float b_GEM_Seg_eta; @@ -145,18 +147,20 @@ class HGCalSimTest : public edm::EDAnalyzer { /* DT */ TTree *t_DT_digi; - int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station; + int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station, b_DT_Digi_wire; + float b_DT_Digi_eta; TTree *t_DT_seg; int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits; float b_DT_4DSeg_eta; TTree *t_DT_rec; - int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station; + int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station, b_DT_RecHit_wire; float b_DT_RecHit_eta; /* RPC */ TTree *t_RPC_digi; int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector; int b_RPC_Digi_isIRPC; + float b_RPC_Digi_eta; TTree *t_RPC_rec; int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector; int b_RPC_RecHit_isIRPC; @@ -205,6 +209,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_ME0_digi->Branch("Digi_chamber", &b_ME0_Digi_chamber, "Digi_chamber/I"); t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); + t_ME0_digi->Branch("Digi_eta", &b_ME0_Digi_eta, "Digi_eta/F"); t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); @@ -241,6 +246,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_GEM_digi->Branch("Digi_etaPartition", &b_GEM_Digi_etaPartition, "Digi_etaPartition/I"); t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); + t_GEM_digi->Branch("Digi_eta", &b_GEM_Digi_eta, "Digi_eta/F"); t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); @@ -266,6 +272,8 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_digi->Branch("Digi_wheel", &b_DT_Digi_wheel, "Digi_wheel/I"); t_DT_digi->Branch("Digi_sector", &b_DT_Digi_sector, "Digi_sector/I"); t_DT_digi->Branch("Digi_station", &b_DT_Digi_station, "Digi_station/I"); + t_DT_digi->Branch("Digi_wrie", &b_DT_Digi_wire, "Digi_wire/I"); + t_DT_digi->Branch("Digi_eta", &b_DT_Digi_eta, "Digi_eta/F"); t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); @@ -283,6 +291,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_rec->Branch("RecHit_wheel", &b_DT_RecHit_wheel, "RecHit_wheel/I"); t_DT_rec->Branch("RecHit_sector", &b_DT_RecHit_sector, "RecHit_sector/I"); t_DT_rec->Branch("RecHit_station", &b_DT_RecHit_station, "RecHit_station/I"); + t_DT_rec->Branch("RecHit_wrie", &b_DT_RecHit_wire, "RecHit_wire/I"); /*RPC*/ t_RPC_digi = fs->make("RPC_Hit", "RPC_Hit"); @@ -294,17 +303,18 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_digi->Branch("Digi_sector", &b_RPC_Digi_sector, "Digi_sector/I"); t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); + t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); t_RPC_rec->Branch("RecHit_layer", &b_RPC_RecHit_layer, "RecHit_layer/I"); - t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); t_RPC_rec->Branch("RecHit_station", &b_RPC_RecHit_station, "RecHit_station/I"); t_RPC_rec->Branch("RecHit_ring", &b_RPC_RecHit_ring, "RecHit_ring/I"); t_RPC_rec->Branch("RecHit_roll", &b_RPC_RecHit_roll, "RecHit_roll/I"); t_RPC_rec->Branch("RecHit_sector", &b_RPC_RecHit_sector, "RecHit_sector/I"); t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); + t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); } @@ -409,6 +419,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_ME0_Digi_chamber = chamber; b_ME0_Digi_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { + auto strip = me0Digi->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_ME0_Digi_eta = gp.eta(); b_ME0_Digi_etaPartition = roll_; t_ME0_digi->Fill(); b_nME0Digis++; @@ -499,6 +513,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; for (auto hit = gemDigi; hit != digisRange.second; ++hit) { + auto strip = gemDigi->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_GEM_Digi_eta = gp.eta(); b_GEM_Digi_etaPartition = roll_; t_GEM_digi->Fill(); b_nGEMDigis++; @@ -547,10 +565,12 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_DT_RecHit_layer = lId.layer(); b_DT_Digi_superLayer = lId.superLayer(); b_DT_RecHit_superLayer = lId.superLayer(); + /* DT digi */ auto digisRange = dtDigis->get(lId); auto dtDigi = digisRange.first; - for (auto hit = dtDigi; hit != digisRange.second; ++hit) { + for (auto hit = dtDigi; hit != digisRange.second; ++hit) { + b_DT_Digi_wire = dtDigi->wire(); t_DT_digi->Fill(); b_nDTDigis++; } @@ -560,6 +580,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto rec = dtRec; rec != recRange.second; ++rec) { auto recLd = dtRec->localPosition(); auto gp = ly->toGlobal(recLd); + auto wireId = dtRec->wireId(); + b_DT_RecHit_wire = wireId.wire(); b_DT_RecHit_eta = gp.eta(); b_nDTRecHits++; t_DT_rec->Fill(); @@ -590,6 +612,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto digisRange = rpcDigis->get(rId); auto rpcDigi = digisRange.first; for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { + auto strip = rpcDigi->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_RPC_Digi_eta = gp.eta(); b_RPC_Digi_roll = roll_; t_RPC_digi->Fill(); b_nRPCDigis++; @@ -626,6 +652,7 @@ void HGCalSimTest::initValue() { /*ME0 digi*/ b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; + b_ME0_Digi_eta = -9; /*ME0 seg*/ b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; b_ME0_Seg_eta = -9; @@ -642,6 +669,7 @@ void HGCalSimTest::initValue() { /*GEM digi*/ b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; + b_GEM_Digi_eta = -9; /*GEM seg*/ b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_nRecHits = -9; b_GEM_Seg_eta = -9; @@ -650,16 +678,18 @@ void HGCalSimTest::initValue() { b_GEM_RecHit_eta = -9; /* DT digi*/ - b_DT_Digi_chamber = -9; b_DT_Digi_layer = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_wheel = -9; b_DT_Digi_sector = -9; b_DT_Digi_station = -9; + b_DT_Digi_chamber = -9; b_DT_Digi_layer = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_wheel = -9; b_DT_Digi_sector = -9; b_DT_Digi_station = -9; b_DT_Digi_wire = -9; + b_DT_Digi_eta = -9; /* DT seg*/ b_DT_4DSeg_chamber = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_nRecHits = -9; b_DT_4DSeg_eta = -9; /* DT rechit*/ - b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; + b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_wire = -9; b_DT_RecHit_eta = -9; /*RPC digi*/ b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; + b_RPC_Digi_eta = -9; b_RPC_Digi_isIRPC = -1; /*RPC rechit*/ b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; From 5ccc3b2371daf6880d47dbf8b2fc3dc533eead27 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Thu, 7 Feb 2019 17:35:05 +0900 Subject: [PATCH 37/50] Fix bug about variables(eta, wire) in seg, digi, rechit loop --- MuonAnalyser/plugins/HGCalSimTest.cc | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 6e2c18876cd..a985ee317a1 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -399,10 +399,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_ME0_Seg_layer = cId.layer(); auto me0Seg = segsRange.first; for (auto seg = me0Seg; seg != segsRange.second; ++seg) { - auto segLd = me0Seg->localPosition(); + auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); b_ME0_Seg_eta = gp.eta(); - b_ME0_Seg_nRecHits = me0Seg->nRecHits(); + b_ME0_Seg_nRecHits = seg->nRecHits(); std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; b_nME0Segments++; t_ME0_seg->Fill(); @@ -419,7 +419,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_ME0_Digi_chamber = chamber; b_ME0_Digi_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { - auto strip = me0Digi->strip(); + auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); b_ME0_Digi_eta = gp.eta(); @@ -433,7 +433,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_ME0_RecHit_chamber = chamber; b_ME0_RecHit_layer = layer; for (auto rec = me0Rec; rec != recRange.second; ++rec) { - auto recLd = me0Rec->localPosition(); + auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); b_ME0_RecHit_eta = gp.eta(); b_ME0_RecHit_etaPartition = roll_; @@ -457,10 +457,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto segsRange = cscSegments->get(cId); auto cscSeg = segsRange.first; for (auto seg = cscSeg; seg != segsRange.second; ++seg) { - auto segLd = cscSeg->localPosition(); + auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); b_CSC_Seg_eta = gp.eta(); - b_CSC_Seg_nRecHits = cscSeg->nRecHits(); + b_CSC_Seg_nRecHits = seg->nRecHits(); b_nCSCSegments++; t_CSC_seg->Fill(); } @@ -472,7 +472,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto recRange = csc2DRecHits->get(lId); auto cscRec = recRange.first; for (auto rec = cscRec; rec != recRange.second; ++rec) { - auto recLd = cscRec->localPosition(); + auto recLd = rec->localPosition(); auto gp = ly->toGlobal(recLd); b_CSC_2DRecHit_eta = gp.eta(); b_nCSC2DRecHits++; @@ -495,10 +495,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto segsRange = gemSegments->get(cId); auto gemSeg = segsRange.first; for (auto seg = gemSeg; seg != segsRange.second; ++seg) { - auto segLd = gemSeg->localPosition(); + auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); b_GEM_Seg_eta = gp.eta(); - b_GEM_Seg_nRecHits = gemSeg->nRecHits(); + b_GEM_Seg_nRecHits = seg->nRecHits(); b_nGEMSegments++; t_GEM_seg->Fill(); } @@ -513,7 +513,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; for (auto hit = gemDigi; hit != digisRange.second; ++hit) { - auto strip = gemDigi->strip(); + auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); b_GEM_Digi_eta = gp.eta(); @@ -525,7 +525,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto recRange = gemRecHits->get(rId); auto gemRec = recRange.first; for (auto rec = gemRec; rec != recRange.second; ++rec) { - auto recLd = gemRec->localPosition(); + auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); b_GEM_RecHit_eta = gp.eta(); b_GEM_RecHit_etaPartition = roll_; @@ -545,10 +545,10 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto segsRange = dt4DSegments->get(cId); auto dt4DSeg = segsRange.first; for (auto seg = dt4DSeg; seg != segsRange.second; ++seg) { - auto segLd = dt4DSeg->localPosition(); + auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); b_DT_4DSeg_eta = gp.eta(); - b_DT_4DSeg_nRecHits = dt4DSeg->recHits().size(); + b_DT_4DSeg_nRecHits = seg->recHits().size(); b_nDT4DSegments++; t_DT_seg->Fill(); } @@ -570,7 +570,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto digisRange = dtDigis->get(lId); auto dtDigi = digisRange.first; for (auto hit = dtDigi; hit != digisRange.second; ++hit) { - b_DT_Digi_wire = dtDigi->wire(); + b_DT_Digi_wire = hit->wire(); t_DT_digi->Fill(); b_nDTDigis++; } @@ -578,9 +578,9 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto recRange = dtRecHits->get(lId); auto dtRec = recRange.first; for (auto rec = dtRec; rec != recRange.second; ++rec) { - auto recLd = dtRec->localPosition(); + auto recLd = rec->localPosition(); auto gp = ly->toGlobal(recLd); - auto wireId = dtRec->wireId(); + auto wireId = rec->wireId(); b_DT_RecHit_wire = wireId.wire(); b_DT_RecHit_eta = gp.eta(); b_nDTRecHits++; @@ -612,7 +612,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto digisRange = rpcDigis->get(rId); auto rpcDigi = digisRange.first; for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { - auto strip = rpcDigi->strip(); + auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); b_RPC_Digi_eta = gp.eta(); @@ -624,7 +624,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto recRange = rpcRecHits->get(rId); auto rpcRec = recRange.first; for (auto rec = rpcRec; rec != recRange.second; ++rec) { - auto recLd = rpcRec->localPosition(); + auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); b_RPC_RecHit_eta = gp.eta(); b_RPC_RecHit_roll = roll_; From 18184081e520ebd6e7f010b4938d4340ceb36193 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Fri, 8 Feb 2019 18:17:00 +0900 Subject: [PATCH 38/50] Add reco muons --- MuonAnalyser/plugins/HGCalSimTest.cc | 74 ++++++++++++++++++- MuonAnalyser/test/runHGCalSimTest.py | 2 + MuonAnalyser/test/runHGCalSimTest_modified.py | 2 + 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index a985ee317a1..3d61e9cc9c5 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -56,6 +56,13 @@ #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" +// Muon +#include "DataFormats/PatCandidates/interface/Muon.h" +// L1 +#include "DataFormats/L1TMuon/interface/L1MuBMTrack.h" + +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -88,6 +95,7 @@ class HGCalSimTest : public edm::EDAnalyzer { virtual void beginRun(Run const&, EventSetup const&) override; virtual void endRun(Run const&, EventSetup const&) override; + void initMuonValue(); void initValue(); // ----------member data --------------------------- @@ -109,6 +117,13 @@ class HGCalSimTest : public edm::EDAnalyzer { edm::EDGetTokenT rpcDigis_; edm::EDGetTokenT rpcRecHits_; + edm::EDGetTokenT > muonToken_; + +// edm::EDGetTokenT > muonL1Token_; + + const reco::VertexCollection* vertexes_; + edm::EDGetTokenT > vtxToken_; + edm::Service fs; TTree *t_event; @@ -150,7 +165,7 @@ class HGCalSimTest : public edm::EDAnalyzer { int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station, b_DT_Digi_wire; float b_DT_Digi_eta; TTree *t_DT_seg; - int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits; + int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits, b_DT_4DSeg_hasZed; float b_DT_4DSeg_eta; TTree *t_DT_rec; int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station, b_DT_RecHit_wire; @@ -166,6 +181,10 @@ class HGCalSimTest : public edm::EDAnalyzer { int b_RPC_RecHit_isIRPC; float b_RPC_RecHit_eta; + + TTree *t_Muon; + float b_muon_pt, b_muon_eta; + int b_muon_isTight, b_muon_isMedium, b_muon_isLoose; }; HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) @@ -188,7 +207,13 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) rpcDigis_ = consumes(iConfig.getParameter("rpcDigis")); rpcRecHits_ = consumes(iConfig.getParameter("rpcRecHits")); + muonToken_ = consumes >(iConfig.getParameter("muonLabel")); + +// muonL1Token_ = consumes >(iConfig.getParameter("muonL1Label")); + vtxToken_ = consumes >(iConfig.getParameter("primaryVertex")); + + t_event = fs->make("Event", "Event"); t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); @@ -282,6 +307,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); t_DT_seg->Branch("Seg_sector", &b_DT_4DSeg_sector, "Seg_sector/I"); t_DT_seg->Branch("Seg_station", &b_DT_4DSeg_station, "Seg_station/I"); + t_DT_seg->Branch("Seg_hasZed", &b_DT_4DSeg_hasZed, "Seg_hasZed/I"); t_DT_rec = fs->make("DT_RecHit", "DT_RecHit"); t_DT_rec->Branch("RecHit_chamber", &b_DT_RecHit_chamber, "RecHit_chaber/I"); @@ -316,6 +342,14 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); + /*Muon*/ + t_Muon = fs->make("Muon", "Muon"); + t_Muon->Branch("pt", &b_muon_pt, "pt/F"); + t_Muon->Branch("eta", &b_muon_eta, "eta/F"); + t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); + t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); + t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); + } HGCalSimTest::~HGCalSimTest() @@ -389,6 +423,19 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) edm::Handle rpcRecHits; iEvent.getByToken(rpcRecHits_, rpcRecHits); + /* Muon */ + edm::Handle > muonHandle; + iEvent.getByToken(muonToken_, muonHandle); + +// edm::Handle > muonL1Handle; +// iEvent.getByToken(muonL1Token_, muonL1Handle); + + edm::Handle vertices; + iEvent.getByToken(vtxToken_, vertices); + + vertexes_ = vertices.product(); + reco::Vertex pv0 = vertexes_->at(0); + initValue(); for (auto ch : ME0Geometry_->chambers()) { @@ -549,6 +596,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = ch->toGlobal(segLd); b_DT_4DSeg_eta = gp.eta(); b_DT_4DSeg_nRecHits = seg->recHits().size(); + b_DT_4DSeg_hasZed = seg->hasZed(); b_nDT4DSegments++; t_DT_seg->Fill(); } @@ -633,6 +681,24 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } } } + + + /* reco Muon */ + for(size_t i = 0; i < muonHandle->size(); ++i) { + initMuonValue(); + edm::RefToBase muRef = muonHandle->refAt(i); + const reco::Muon* mu = muRef.get(); + b_muon_isTight = muon::isTightMuon(*mu, pv0); + b_muon_isMedium = muon::isMediumMuon(*mu); + b_muon_isLoose = muon::isLooseMuon(*mu); + b_muon_pt = mu->pt(); + b_muon_eta = mu->eta(); + t_Muon->Fill(); + } + + + /*L1 trigger*/ + t_event->Fill(); } @@ -643,6 +709,11 @@ void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ } void HGCalSimTest::endRun(Run const&, EventSetup const&){} +void HGCalSimTest::initMuonValue() { + b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; + b_muon_pt = -9; b_muon_eta = -9; + +} void HGCalSimTest::initValue() { b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; b_nCSCSegments = 0; b_nCSC2DRecHits = 0; @@ -683,6 +754,7 @@ void HGCalSimTest::initValue() { /* DT seg*/ b_DT_4DSeg_chamber = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_nRecHits = -9; b_DT_4DSeg_eta = -9; + b_DT_4DSeg_hasZed = -1; /* DT rechit*/ b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_wire = -9; b_DT_RecHit_eta = -9; diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index c4f006eae66..59aa193ab3c 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -48,6 +48,8 @@ dtRecHits = cms.InputTag("dt1DRecHits"), rpcDigis = cms.InputTag("simMuonRPCDigis"), rpcRecHits = cms.InputTag("rpcRecHits"), + muonLabel = cms.InputTag("muons"), + primaryVertex = cms.InputTag('offlinePrimaryVertices'), ) process.p = cms.Path(process.HGCalSimTest) diff --git a/MuonAnalyser/test/runHGCalSimTest_modified.py b/MuonAnalyser/test/runHGCalSimTest_modified.py index 737a35db220..914c7c9494e 100644 --- a/MuonAnalyser/test/runHGCalSimTest_modified.py +++ b/MuonAnalyser/test/runHGCalSimTest_modified.py @@ -48,6 +48,8 @@ dtRecHits = cms.InputTag("dt1DRecHits"), rpcDigis = cms.InputTag("simMuonRPCDigis"), rpcRecHits = cms.InputTag("rpcRecHits"), + muonLabel = cms.InputTag("muons"), + primaryVertex = cms.InputTag('offlinePrimaryVertices'), ) process.p = cms.Path(process.HGCalSimTest) From a241d3c2d9d73a360854d181a24293a46374d133 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 12 Feb 2019 00:07:59 +0900 Subject: [PATCH 39/50] Add RPC region (I forgot that ... ) --- MuonAnalyser/plugins/HGCalSimTest.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 3d61e9cc9c5..664ace03aab 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -173,11 +173,11 @@ class HGCalSimTest : public edm::EDAnalyzer { /* RPC */ TTree *t_RPC_digi; - int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector; + int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector, b_RPC_Digi_region; int b_RPC_Digi_isIRPC; float b_RPC_Digi_eta; TTree *t_RPC_rec; - int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector; + int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector, b_RPC_RecHit_region; int b_RPC_RecHit_isIRPC; float b_RPC_RecHit_eta; @@ -330,6 +330,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); + t_RPC_digi->Branch("Digi_region", &b_RPC_Digi_region, "Digi_region/F"); t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); @@ -341,6 +342,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); + t_RPC_rec->Branch("RecHit_region", &b_RPC_RecHit_region, "RecHit_region/F"); /*Muon*/ t_Muon = fs->make("Muon", "Muon"); @@ -648,6 +650,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) b_RPC_RecHit_sector = cId.sector(); b_RPC_Digi_subSector = cId.subsector(); b_RPC_RecHit_subSector = cId.subsector(); + b_RPC_Digi_region = cId.region(); // region : 0 for barrel +/-1 for +/- endcap + b_RPC_RecHit_region = cId.region(); for (auto roll : ch->rolls()) { b_RPC_Digi_isIRPC = (int)roll->isIRPC(); @@ -760,11 +764,11 @@ void HGCalSimTest::initValue() { b_DT_RecHit_eta = -9; /*RPC digi*/ - b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; + b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; b_RPC_Digi_region = -9; b_RPC_Digi_eta = -9; b_RPC_Digi_isIRPC = -1; /*RPC rechit*/ - b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; + b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; b_RPC_RecHit_region = -9; b_RPC_RecHit_eta = -9; b_RPC_RecHit_isIRPC = -1; From e2998b43e9444593ec8f7994c1f0457153f81615 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 12 Feb 2019 17:52:22 +0900 Subject: [PATCH 40/50] Save hit counts and detector areas for ME0/GEM/CSC/RPC --- MuonAnalyser/plugins/HGCalSimTest.cc | 220 +++++++++++++++++++++++++-- 1 file changed, 210 insertions(+), 10 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 664ace03aab..2e09137ee6f 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -56,6 +56,7 @@ #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" // Muon #include "DataFormats/PatCandidates/interface/Muon.h" // L1 @@ -67,6 +68,10 @@ #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -74,6 +79,7 @@ #include "TH1D.h" #include "TH2D.h" +#include "TProfile.h" #include "TString.h" #include "TGraphAsymmErrors.h" #include "TLorentzVector.h" @@ -98,6 +104,20 @@ class HGCalSimTest : public edm::EDAnalyzer { void initMuonValue(); void initValue(); + TProfile* hME0Area_; + TH1D* hME0Counts_; + + TProfile* hGEMArea_; + TH1D* hGEMCounts_; + + TProfile* hCSCArea_; + TH1D* hCSCCounts_; + + TProfile* hRPCArea_; + TH1D* hRPCCounts_; + + TH1D* hEvents_; + // ----------member data --------------------------- edm::EDGetTokenT me0Digis_; edm::EDGetTokenT me0Segments_; @@ -132,7 +152,7 @@ class HGCalSimTest : public edm::EDAnalyzer { /* ME0 */ TTree *t_ME0_digi; - int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition; + int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition, b_ME0_Digi_bx; float b_ME0_Digi_eta; TTree *t_ME0_seg; int b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; @@ -151,13 +171,13 @@ class HGCalSimTest : public edm::EDAnalyzer { /* GEM */ TTree *t_GEM_digi; - int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition; + int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition, b_GEM_Digi_bx; float b_GEM_Digi_eta; TTree *t_GEM_seg; int b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_nRecHits; float b_GEM_Seg_eta; TTree *t_GEM_rec; - int b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_etaPartition; + int b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_etaPartition, b_GEM_RecHit_bx; float b_GEM_RecHit_eta; /* DT */ @@ -235,6 +255,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); t_ME0_digi->Branch("Digi_eta", &b_ME0_Digi_eta, "Digi_eta/F"); + t_ME0_digi->Branch("Digi_bx", &b_ME0_Digi_bx, "Digi_bx/I"); t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); @@ -272,6 +293,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); t_GEM_digi->Branch("Digi_eta", &b_GEM_Digi_eta, "Digi_eta/F"); + t_GEM_digi->Branch("Digi_bx", &b_GEM_Digi_bx, "Digi_bx/I"); t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); @@ -288,6 +310,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_GEM_rec->Branch("RecHit_eta", &b_GEM_RecHit_eta, "RecHit_eta/F"); t_GEM_rec->Branch("RecHit_station", &b_GEM_RecHit_station, "RecHit_station/I"); t_GEM_rec->Branch("RecHit_ring", &b_GEM_RecHit_ring, "RecHit_ring/I"); + t_GEM_rec->Branch("RecHit_bx", &b_GEM_RecHit_bx, "RecHit_bx/I"); /*DT*/ t_DT_digi = fs->make("DT_Hit", "DT_Hit"); @@ -440,6 +463,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) initValue(); + hEvents_->Fill(1); + for (auto ch : ME0Geometry_->chambers()) { /* ME0 seg */ ME0DetId cId = ch->id(); @@ -452,7 +477,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = ch->toGlobal(segLd); b_ME0_Seg_eta = gp.eta(); b_ME0_Seg_nRecHits = seg->nRecHits(); - std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; + //std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; b_nME0Segments++; t_ME0_seg->Fill(); } @@ -473,6 +498,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = roll->toGlobal(digiLp); b_ME0_Digi_eta = gp.eta(); b_ME0_Digi_etaPartition = roll_; + b_ME0_Digi_bx = hit->bx(); t_ME0_digi->Fill(); b_nME0Digis++; } @@ -486,13 +512,28 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = roll->toGlobal(recLd); b_ME0_RecHit_eta = gp.eta(); b_ME0_RecHit_etaPartition = roll_; - std::cout << b_ME0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; + //std::cout << b_ME0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; b_nME0RecHits++; t_ME0_rec->Fill(); } } } } + for ( auto me0Hit : *me0RecHits ) { + const auto detId = me0Hit.me0Id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(0);//std::to_string(detId.ring()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + + const int idx = hME0Area_->GetXaxis()->FindBin(rollName.c_str()); + hME0Counts_->Fill(idx); + } + + + for (auto ch : CSCGeometry_->chambers()) { /* CSC seg */ @@ -529,6 +570,18 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } } } + for ( auto cscHit : *csc2DRecHits ) { + const auto detId = cscHit.cscDetId(); + auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward + auto ch = std::to_string(detId.chamber()); + auto ring = std::to_string(detId.ring()); + auto station = std::to_string(detId.station()); + const string name = "Endcap_"+endcap+"_Station_"+station+"_ring_"+ring+"_CH_"+ch; + const int idx = hCSCArea_->GetXaxis()->FindBin(name.c_str()); + hCSCCounts_->Fill(idx); + } + + for (auto ch : GEMGeometry_->chambers()) { /* GEM seg */ @@ -567,6 +620,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = roll->toGlobal(digiLp); b_GEM_Digi_eta = gp.eta(); b_GEM_Digi_etaPartition = roll_; + b_GEM_Digi_bx = hit->bx(); t_GEM_digi->Fill(); b_nGEMDigis++; } @@ -578,11 +632,26 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto gp = roll->toGlobal(recLd); b_GEM_RecHit_eta = gp.eta(); b_GEM_RecHit_etaPartition = roll_; + b_GEM_RecHit_bx = rec->BunchX(); b_nGEMRecHits++; t_GEM_rec->Fill(); } } } + for ( auto gemHit : *gemRecHits ) { + const auto detId = gemHit.gemId(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(detId.ring()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + + const int idx = hGEMArea_->GetXaxis()->FindBin(rollName.c_str()); + hGEMCounts_->Fill(idx); + } + + for (auto ch : DTGeometry_->chambers()) { /* DT seg */ @@ -637,7 +706,7 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) t_DT_rec->Fill(); } } - + for (auto ch : RPCGeometry_->chambers()) { RPCDetId cId = ch->id(); b_RPC_Digi_station = cId.station(); @@ -685,6 +754,13 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } } } + for ( auto rpcHit : *rpcRecHits ) { + const auto detId = rpcHit.rawId(); + const string rollName = RPCGeomServ(detId).name(); + + const int idx = hRPCArea_->GetXaxis()->FindBin(rollName.c_str()); + hRPCCounts_->Fill(idx); + } /* reco Muon */ @@ -709,7 +785,131 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) void HGCalSimTest::beginJob(){} void HGCalSimTest::endJob(){} -void HGCalSimTest::beginRun(Run const& run, EventSetup const&){ +void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){//(Run const& run, EventSetup const&){ + + hEvents_ = fs->make("hEvents", "hEvents;Types;Number of Events", 1, 1, 2); + + hME0Area_ = fs->make("hME0Area", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hME0Counts_ = fs->make("hME0Counts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hGEMArea_ = fs->make("hGEMArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hGEMCounts_ = fs->make("hGEMCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hCSCArea_ = fs->make("hCSCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hCSCCounts_ = fs->make("hCSCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hRPCArea_ = fs->make("hRPCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hRPCCounts_ = fs->make("hRPCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + + edm::ESHandle me0Geom; + iSetup.get().get(me0Geom); + + edm::ESHandle gemGeom; + iSetup.get().get(gemGeom); + + edm::ESHandle cscGeom; + iSetup.get().get(cscGeom); + + edm::ESHandle rpcGeom; + iSetup.get().get(rpcGeom); + +/* + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + GEMDetId rId = roll->id(); + + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + + } + } + + for (auto ch : CSCGeometry_->chambers()) { + for (auto layer : ch->layers()) { + CSCDetId lId = layer->id(); + const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); + const float striplength(top_->stripLength()); + const float pitch(layer->geometry()->stripPitch()); + b_cscArea = striplength * pitch * top_->nstrips(); + } + } +*/ + + /* ME0 */ + int iME0 = 0; + for ( auto roll : me0Geom->etaPartitions() ) { + ++iME0; + const auto detId = roll->id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); // for now, always 1 + auto ring = std::to_string(0);//std::to_string(detId.ring()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + auto nstrip = top_->nstrips(); +// std::cout << " ME0 : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; + hME0Area_->GetXaxis()->SetBinLabel(iME0, rollName.c_str()); + hME0Area_->Fill(iME0, striplength*pitch*nstrip); + } + + /* GEM */ + int iGEM = 0; + for ( auto roll : gemGeom->etaPartitions() ) { + ++iGEM; + const auto detId = roll->id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(detId.ring()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + auto nstrip = top_->nstrips(); +// std::cout << " GEM : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; + hGEMArea_->GetXaxis()->SetBinLabel(iGEM, rollName.c_str()); + hGEMArea_->Fill(iGEM, striplength*pitch*nstrip); + } + + /* CSC */ + int iCSC = 0; + for (auto ly : cscGeom->layers()) { + ++iCSC; + auto detId = ly->id(); + auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward + auto ch = std::to_string(detId.chamber()); + auto ring = std::to_string(detId.ring()); + auto station = std::to_string(detId.station()); + const string name = "Endcap_"+endcap+"_Station_"+station+"_ring_"+ring+"_CH_"+ch; + const RadialStripTopology* top_(dynamic_cast(&(ly->topology()))); + const float striplength(top_->stripLength()); + const float pitch(ly->geometry()->stripPitch()); + const float nstrip = top_->nstrips(); + //std::cout << " CSC : " << name << " / area : " << striplength*pitch*nstrip << std::endl; + hCSCArea_->GetXaxis()->SetBinLabel(iCSC, name.c_str()); + hCSCArea_->Fill(iCSC, striplength*pitch*nstrip); + } + + /* RPC */ + int iRPC = 0; + for ( const RPCRoll* roll : rpcGeom->rolls() ) { + ++iRPC; + const auto detId = roll->id(); + const string rollName = RPCGeomServ(detId).name(); + const double width = roll->surface().bounds().width(); + const double height = roll->surface().bounds().length(); + //std::cout << " RPC : " << rollName.c_str() << " / area : " << width*height << std::endl; + hRPCArea_->GetXaxis()->SetBinLabel(iRPC, rollName.c_str()); + hRPCArea_->Fill(iRPC, width*height); + } + + } void HGCalSimTest::endRun(Run const&, EventSetup const&){} @@ -726,7 +926,7 @@ void HGCalSimTest::initValue() { b_nRPCDigis = 0; b_nRPCRecHits = 0; /*ME0 digi*/ - b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; + b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; b_ME0_Digi_bx = -999; b_ME0_Digi_eta = -9; /*ME0 seg*/ b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; @@ -743,13 +943,13 @@ void HGCalSimTest::initValue() { b_CSC_2DRecHit_eta = -9; /*GEM digi*/ - b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; + b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; b_GEM_Digi_bx = -999; b_GEM_Digi_eta = -9; /*GEM seg*/ b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_nRecHits = -9; b_GEM_Seg_eta = -9; /*GEM rechit*/ - b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_etaPartition = -9; + b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_etaPartition = -9; b_GEM_RecHit_bx = -999; b_GEM_RecHit_eta = -9; /* DT digi*/ From b2916cb0127e2715e0ccfdd1d56e522da70a0790 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 19 Feb 2019 20:37:13 +0900 Subject: [PATCH 41/50] Add additional variables (phi for dets and isGlobal, isTracker and no. station layer for reco muon) and gen muon (temp) --- MuonAnalyser/plugins/HGCalSimTest.cc | 378 +++++++++++++++++---------- MuonAnalyser/test/runHGCalSimTest.py | 4 +- 2 files changed, 239 insertions(+), 143 deletions(-) diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc index 2e09137ee6f..02c7778bf3b 100644 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ b/MuonAnalyser/plugins/HGCalSimTest.cc @@ -65,6 +65,15 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/Associations/interface/MuonToTrackingParticleAssociator.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" +#include "SimMuon/MCTruth/interface/MuonToSimAssociatorByHits.h" +#include "SimTracker/Common/interface/TrackingParticleSelector.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" + #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" @@ -119,25 +128,26 @@ class HGCalSimTest : public edm::EDAnalyzer { TH1D* hEvents_; // ----------member data --------------------------- - edm::EDGetTokenT me0Digis_; - edm::EDGetTokenT me0Segments_; - edm::EDGetTokenT me0RecHits_; + edm::EDGetTokenT me0Digis_; + edm::EDGetTokenT me0Segments_; + edm::EDGetTokenT me0RecHits_; - edm::EDGetTokenT cscSegments_; - edm::EDGetTokenT csc2DRecHits_; + edm::EDGetTokenT cscSegments_; + edm::EDGetTokenT csc2DRecHits_; - edm::EDGetTokenT gemDigis_; - edm::EDGetTokenT gemSegments_; - edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT gemDigis_; + edm::EDGetTokenT gemSegments_; + edm::EDGetTokenT gemRecHits_; - edm::EDGetTokenT dtDigis_; - edm::EDGetTokenT dt4DSegments_; - edm::EDGetTokenT dtRecHits_; + edm::EDGetTokenT dtDigis_; + edm::EDGetTokenT dt4DSegments_; + edm::EDGetTokenT dtRecHits_; - edm::EDGetTokenT rpcDigis_; - edm::EDGetTokenT rpcRecHits_; + edm::EDGetTokenT rpcDigis_; + edm::EDGetTokenT rpcRecHits_; - edm::EDGetTokenT > muonToken_; + edm::EDGetTokenT simToken_; + edm::EDGetTokenT > muonToken_; // edm::EDGetTokenT > muonL1Token_; @@ -153,58 +163,63 @@ class HGCalSimTest : public edm::EDAnalyzer { /* ME0 */ TTree *t_ME0_digi; int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition, b_ME0_Digi_bx; - float b_ME0_Digi_eta; + float b_ME0_Digi_eta, b_ME0_Digi_phi; TTree *t_ME0_seg; int b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; - float b_ME0_Seg_eta; + float b_ME0_Seg_eta, b_ME0_Seg_phi; TTree *t_ME0_rec; int b_ME0_RecHit_chamber, b_ME0_RecHit_layer, b_ME0_RecHit_etaPartition; - float b_ME0_RecHit_eta; + float b_ME0_RecHit_eta, b_ME0_RecHit_phi; /* CSC */ TTree *t_CSC_seg; int b_CSC_Seg_chamber, b_CSC_Seg_layer, b_CSC_Seg_station, b_CSC_Seg_ring, b_CSC_Seg_nRecHits; - float b_CSC_Seg_eta; + float b_CSC_Seg_eta, b_CSC_Seg_phi; TTree *t_CSC_rec; int b_CSC_2DRecHit_chamber, b_CSC_2DRecHit_layer, b_CSC_2DRecHit_station, b_CSC_2DRecHit_ring, b_CSC_2DRecHit_etaPartition; - float b_CSC_2DRecHit_eta; + float b_CSC_2DRecHit_eta, b_CSC_2DRecHit_phi; /* GEM */ TTree *t_GEM_digi; int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition, b_GEM_Digi_bx; - float b_GEM_Digi_eta; + float b_GEM_Digi_eta, b_GEM_Digi_phi; TTree *t_GEM_seg; int b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_nRecHits; - float b_GEM_Seg_eta; + float b_GEM_Seg_eta, b_GEM_Seg_phi; TTree *t_GEM_rec; int b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_etaPartition, b_GEM_RecHit_bx; - float b_GEM_RecHit_eta; + float b_GEM_RecHit_eta, b_GEM_RecHit_phi; /* DT */ TTree *t_DT_digi; int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station, b_DT_Digi_wire; - float b_DT_Digi_eta; + float b_DT_Digi_eta, b_DT_Digi_phi; TTree *t_DT_seg; int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits, b_DT_4DSeg_hasZed; - float b_DT_4DSeg_eta; + float b_DT_4DSeg_eta, b_DT_4DSeg_phi; TTree *t_DT_rec; int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station, b_DT_RecHit_wire; - float b_DT_RecHit_eta; + float b_DT_RecHit_eta, b_DT_RecHit_phi; /* RPC */ TTree *t_RPC_digi; int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector, b_RPC_Digi_region; int b_RPC_Digi_isIRPC; - float b_RPC_Digi_eta; + float b_RPC_Digi_eta, b_RPC_Digi_phi; TTree *t_RPC_rec; int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector, b_RPC_RecHit_region; int b_RPC_RecHit_isIRPC; - float b_RPC_RecHit_eta; + float b_RPC_RecHit_eta, b_RPC_RecHit_phi; + + /* Muon */ + TTree *t_genMuon; + float b_genMuon_pt, b_genMuon_eta, b_genMuon_phi; + int b_genMuon_isTight, b_genMuon_isMedium, b_genMuon_isLoose, b_genMuon_isTrackerMuon, b_genMuon_isGlobalMuon, b_genMuon_isME0Muon, b_genMuon_nMatchedStationLayer; TTree *t_Muon; - float b_muon_pt, b_muon_eta; - int b_muon_isTight, b_muon_isMedium, b_muon_isLoose; + float b_muon_pt, b_muon_eta, b_muon_phi; + int b_muon_isTight, b_muon_isMedium, b_muon_isLoose, b_muon_isTrackerMuon, b_muon_isGlobalMuon, b_muon_isME0Muon, b_muon_nMatchedStationLayer; }; HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) @@ -227,6 +242,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) rpcDigis_ = consumes(iConfig.getParameter("rpcDigis")); rpcRecHits_ = consumes(iConfig.getParameter("rpcRecHits")); + simToken_ = consumes(iConfig.getParameter("simLabel")); muonToken_ = consumes >(iConfig.getParameter("muonLabel")); // muonL1Token_ = consumes >(iConfig.getParameter("muonL1Label")); @@ -255,10 +271,12 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); t_ME0_digi->Branch("Digi_eta", &b_ME0_Digi_eta, "Digi_eta/F"); + t_ME0_digi->Branch("Digi_phi", &b_ME0_Digi_phi, "Digi_phi/F"); t_ME0_digi->Branch("Digi_bx", &b_ME0_Digi_bx, "Digi_bx/I"); t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); + t_ME0_seg->Branch("Seg_phi", &b_ME0_Seg_phi, "Seg_phi/F"); t_ME0_seg->Branch("Seg_chamber", &b_ME0_Seg_chamber, "Seg_chamber/I"); t_ME0_seg->Branch("Seg_layer", &b_ME0_Seg_layer, "Seg_layer/I"); t_ME0_seg->Branch("Seg_nRecHits", &b_ME0_Seg_nRecHits, "Seg_nRecHits/I"); @@ -268,10 +286,12 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_ME0_rec->Branch("RecHit_layer", &b_ME0_RecHit_layer, "RecHit_layer/I"); t_ME0_rec->Branch("RecHit_etaPartition", &b_ME0_RecHit_etaPartition, "RecHit_etaParition/I"); t_ME0_rec->Branch("RecHit_eta", &b_ME0_RecHit_eta, "RecHit_eta/F"); + t_ME0_rec->Branch("RecHit_phi", &b_ME0_RecHit_phi, "RecHit_phi/F"); /*CSC*/ t_CSC_seg = fs->make("CSC_Segment", "CSC_Segment"); t_CSC_seg->Branch("Seg_eta", &b_CSC_Seg_eta, "Seg_eta/F"); + t_CSC_seg->Branch("Seg_phi", &b_CSC_Seg_phi, "Seg_phi/F"); t_CSC_seg->Branch("Seg_chamber", &b_CSC_Seg_chamber, "Seg_chamber/I"); t_CSC_seg->Branch("Seg_layer", &b_CSC_Seg_layer, "Seg_layer/I"); t_CSC_seg->Branch("Seg_nRecHits", &b_CSC_Seg_nRecHits, "Seg_nRecHits/I"); @@ -282,6 +302,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_CSC_rec->Branch("RecHit_chamber", &b_CSC_2DRecHit_chamber, "RecHit_chaber/I"); t_CSC_rec->Branch("RecHit_layer", &b_CSC_2DRecHit_layer, "RecHit_layer/I"); t_CSC_rec->Branch("RecHit_eta", &b_CSC_2DRecHit_eta, "RecHit_eta/F"); + t_CSC_rec->Branch("RecHit_phi", &b_CSC_2DRecHit_phi, "RecHit_phi/F"); t_CSC_rec->Branch("RecHit_station", &b_CSC_2DRecHit_station, "RecHit_station/I"); t_CSC_rec->Branch("RecHit_ring", &b_CSC_2DRecHit_ring, "RecHit_ring/I"); @@ -293,10 +314,12 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); t_GEM_digi->Branch("Digi_eta", &b_GEM_Digi_eta, "Digi_eta/F"); + t_GEM_digi->Branch("Digi_phi", &b_GEM_Digi_phi, "Digi_phi/F"); t_GEM_digi->Branch("Digi_bx", &b_GEM_Digi_bx, "Digi_bx/I"); t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); + t_GEM_seg->Branch("Seg_phi", &b_GEM_Seg_phi, "Seg_phi/F"); t_GEM_seg->Branch("Seg_chamber", &b_GEM_Seg_chamber, "Seg_chamber/I"); t_GEM_seg->Branch("Seg_layer", &b_GEM_Seg_layer, "Seg_layer/I"); t_GEM_seg->Branch("Seg_nRecHits", &b_GEM_Seg_nRecHits, "Seg_nRecHits/I"); @@ -308,6 +331,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_GEM_rec->Branch("RecHit_layer", &b_GEM_RecHit_layer, "RecHit_layer/I"); t_GEM_rec->Branch("RecHit_etaPartition", &b_GEM_RecHit_etaPartition, "RecHit_etaParition/I"); t_GEM_rec->Branch("RecHit_eta", &b_GEM_RecHit_eta, "RecHit_eta/F"); + t_GEM_rec->Branch("RecHit_phi", &b_GEM_RecHit_phi, "RecHit_phi/F"); t_GEM_rec->Branch("RecHit_station", &b_GEM_RecHit_station, "RecHit_station/I"); t_GEM_rec->Branch("RecHit_ring", &b_GEM_RecHit_ring, "RecHit_ring/I"); t_GEM_rec->Branch("RecHit_bx", &b_GEM_RecHit_bx, "RecHit_bx/I"); @@ -322,9 +346,11 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_digi->Branch("Digi_station", &b_DT_Digi_station, "Digi_station/I"); t_DT_digi->Branch("Digi_wrie", &b_DT_Digi_wire, "Digi_wire/I"); t_DT_digi->Branch("Digi_eta", &b_DT_Digi_eta, "Digi_eta/F"); + t_DT_digi->Branch("Digi_phi", &b_DT_Digi_phi, "Digi_phi/F"); t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); + t_DT_seg->Branch("Seg_phi", &b_DT_4DSeg_phi, "Seg_phi/F"); t_DT_seg->Branch("Seg_chamber", &b_DT_4DSeg_chamber, "Seg_chamber/I"); t_DT_seg->Branch("Seg_nRecHits", &b_DT_4DSeg_nRecHits, "Seg_nRecHits/I"); t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); @@ -337,6 +363,7 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_DT_rec->Branch("RecHit_layer", &b_DT_RecHit_layer, "RecHit_layer/I"); t_DT_rec->Branch("RecHit_superLayer", &b_DT_RecHit_superLayer, "RecHit_superLayer/I"); t_DT_rec->Branch("RecHit_eta", &b_DT_RecHit_eta, "RecHit_eta/F"); + t_DT_rec->Branch("RecHit_phi", &b_DT_RecHit_phi, "RecHit_phi/F"); t_DT_rec->Branch("RecHit_wheel", &b_DT_RecHit_wheel, "RecHit_wheel/I"); t_DT_rec->Branch("RecHit_sector", &b_DT_RecHit_sector, "RecHit_sector/I"); t_DT_rec->Branch("RecHit_station", &b_DT_RecHit_station, "RecHit_station/I"); @@ -353,7 +380,8 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); - t_RPC_digi->Branch("Digi_region", &b_RPC_Digi_region, "Digi_region/F"); + t_RPC_digi->Branch("Digi_phi", &b_RPC_Digi_phi, "Digi_phi/F"); + t_RPC_digi->Branch("Digi_region", &b_RPC_Digi_region, "Digi_region/I"); t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); @@ -365,15 +393,33 @@ HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); - t_RPC_rec->Branch("RecHit_region", &b_RPC_RecHit_region, "RecHit_region/F"); + t_RPC_rec->Branch("RecHit_phi", &b_RPC_RecHit_phi, "RecHit_phi/F"); + t_RPC_rec->Branch("RecHit_region", &b_RPC_RecHit_region, "RecHit_region/I"); /*Muon*/ + t_genMuon = fs->make("gen_Muon", "gen_Muon"); + t_genMuon->Branch("pt", &b_genMuon_pt, "pt/F"); + t_genMuon->Branch("eta", &b_genMuon_eta, "eta/F"); + t_genMuon->Branch("phi", &b_genMuon_phi, "phi/F"); + t_genMuon->Branch("nMatchedStationLayer" , &b_genMuon_nMatchedStationLayer, "nMatchedStationLayer/I"); + t_genMuon->Branch("isTrackerMuon", &b_genMuon_isTrackerMuon, "isTrackerMuon/I"); + t_genMuon->Branch("isGlobalMuon", &b_genMuon_isGlobalMuon, "isGlobalMuon/I"); + t_genMuon->Branch("isME0Muon", &b_genMuon_isME0Muon, "isME0Muon/I"); + t_genMuon->Branch("isTight", &b_genMuon_isTight, "isTight/I"); + t_genMuon->Branch("isMedium", &b_genMuon_isMedium, "isMedium/I"); + t_genMuon->Branch("isLoose", &b_genMuon_isLoose, "isLoose/I"); + t_Muon = fs->make("Muon", "Muon"); - t_Muon->Branch("pt", &b_muon_pt, "pt/F"); - t_Muon->Branch("eta", &b_muon_eta, "eta/F"); - t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); - t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); - t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); + t_Muon->Branch("pt", &b_muon_pt, "pt/F"); + t_Muon->Branch("eta", &b_muon_eta, "eta/F"); + t_Muon->Branch("phi", &b_muon_phi, "phi/F"); + t_Muon->Branch("nMatchedStationLayer" , &b_muon_nMatchedStationLayer, "nMatchedStationLayer/I"); + t_Muon->Branch("isTrackerMuon", &b_muon_isTrackerMuon, "isTrackerMuon/I"); + t_Muon->Branch("isGlobalMuon", &b_muon_isGlobalMuon, "isGlobalMuon/I"); + t_Muon->Branch("isME0Muon", &b_muon_isME0Muon, "isME0Muon/I"); + t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); + t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); + t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); } @@ -449,6 +495,9 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) iEvent.getByToken(rpcRecHits_, rpcRecHits); /* Muon */ + Handle simHandle; + iEvent.getByToken(simToken_, simHandle); + edm::Handle > muonHandle; iEvent.getByToken(muonToken_, muonHandle); @@ -469,14 +518,16 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) /* ME0 seg */ ME0DetId cId = ch->id(); auto segsRange = me0Segments->get(cId); - b_ME0_Seg_chamber = cId.chamber(); - b_ME0_Seg_layer = cId.layer(); auto me0Seg = segsRange.first; for (auto seg = me0Seg; seg != segsRange.second; ++seg) { auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); - b_ME0_Seg_eta = gp.eta(); + b_ME0_Seg_eta = gp.eta(); + b_ME0_Seg_phi = gp.phi(); b_ME0_Seg_nRecHits = seg->nRecHits(); + b_ME0_Seg_chamber = cId.chamber(); + b_ME0_Seg_layer = cId.layer(); + //std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; b_nME0Segments++; t_ME0_seg->Fill(); @@ -490,28 +541,32 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) /* ME0 digi */ auto digisRange = me0Digis->get(rId); auto me0Digi = digisRange.first; - b_ME0_Digi_chamber = chamber; - b_ME0_Digi_layer = layer; for (auto hit = me0Digi; hit != digisRange.second; ++hit) { auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); - b_ME0_Digi_eta = gp.eta(); + b_ME0_Digi_eta = gp.eta(); + b_ME0_Digi_phi = gp.phi(); b_ME0_Digi_etaPartition = roll_; - b_ME0_Digi_bx = hit->bx(); + b_ME0_Digi_bx = hit->bx(); + b_ME0_Digi_chamber = chamber; + b_ME0_Digi_layer = layer; + t_ME0_digi->Fill(); b_nME0Digis++; } /* ME0 RecHit */ auto recRange = me0RecHits->get(rId); auto me0Rec = recRange.first; - b_ME0_RecHit_chamber = chamber; - b_ME0_RecHit_layer = layer; for (auto rec = me0Rec; rec != recRange.second; ++rec) { auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); - b_ME0_RecHit_eta = gp.eta(); + b_ME0_RecHit_eta = gp.eta(); + b_ME0_RecHit_phi = gp.phi(); b_ME0_RecHit_etaPartition = roll_; + b_ME0_RecHit_chamber = chamber; + b_ME0_RecHit_layer = layer; + //std::cout << b_ME0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; b_nME0RecHits++; t_ME0_rec->Fill(); @@ -526,45 +581,47 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto iEta = std::to_string(detId.roll()); auto station = std::to_string(detId.station()); auto ring = std::to_string(0);//std::to_string(detId.ring()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; - + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; const int idx = hME0Area_->GetXaxis()->FindBin(rollName.c_str()); hME0Counts_->Fill(idx); } - - for (auto ch : CSCGeometry_->chambers()) { /* CSC seg */ CSCDetId cId = ch->id(); - b_CSC_Seg_station = cId.station(); - b_CSC_2DRecHit_station = cId.station(); - b_CSC_Seg_ring = cId.ring(); - b_CSC_2DRecHit_ring = cId.ring(); - b_CSC_Seg_chamber = cId.chamber(); - b_CSC_Seg_layer = cId.layer(); auto segsRange = cscSegments->get(cId); auto cscSeg = segsRange.first; for (auto seg = cscSeg; seg != segsRange.second; ++seg) { auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); - b_CSC_Seg_eta = gp.eta(); + b_CSC_Seg_eta = gp.eta(); + b_CSC_Seg_phi = gp.phi(); b_CSC_Seg_nRecHits = seg->nRecHits(); + b_CSC_Seg_station = cId.station(); + b_CSC_Seg_ring = cId.ring(); + b_CSC_Seg_chamber = cId.chamber(); + b_CSC_Seg_layer = cId.layer(); + b_nCSCSegments++; t_CSC_seg->Fill(); } for (auto ly : ch->layers()) { CSCDetId lId = ly->id(); /* CSC rechit */ - b_CSC_2DRecHit_chamber = lId.chamber(); - b_CSC_2DRecHit_layer = lId.layer(); auto recRange = csc2DRecHits->get(lId); auto cscRec = recRange.first; for (auto rec = cscRec; rec != recRange.second; ++rec) { auto recLd = rec->localPosition(); auto gp = ly->toGlobal(recLd); - b_CSC_2DRecHit_eta = gp.eta(); + b_CSC_2DRecHit_eta = gp.eta(); + b_CSC_2DRecHit_phi = gp.phi(); + b_CSC_2DRecHit_station = lId.station(); + b_CSC_2DRecHit_ring = lId.ring(); + b_CSC_2DRecHit_chamber = lId.chamber(); + b_CSC_2DRecHit_layer = lId.layer(); + b_nCSC2DRecHits++; t_CSC_rec->Fill(); } @@ -576,7 +633,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto ch = std::to_string(detId.chamber()); auto ring = std::to_string(detId.ring()); auto station = std::to_string(detId.station()); - const string name = "Endcap_"+endcap+"_Station_"+station+"_ring_"+ring+"_CH_"+ch; + auto layer = std::to_string(detId.layer()); + const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; const int idx = hCSCArea_->GetXaxis()->FindBin(name.c_str()); hCSCCounts_->Fill(idx); } @@ -586,31 +644,25 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto ch : GEMGeometry_->chambers()) { /* GEM seg */ GEMDetId cId = ch->id(); - b_GEM_Digi_station = cId.station(); - b_GEM_Seg_station = cId.station(); - b_GEM_RecHit_station = cId.station(); - b_GEM_Digi_ring = cId.ring(); - b_GEM_Seg_ring = cId.ring(); - b_GEM_RecHit_ring = cId.ring(); - b_GEM_Seg_chamber = cId.chamber(); - b_GEM_Seg_layer = cId.layer(); auto segsRange = gemSegments->get(cId); auto gemSeg = segsRange.first; for (auto seg = gemSeg; seg != segsRange.second; ++seg) { auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); - b_GEM_Seg_eta = gp.eta(); - b_GEM_Seg_nRecHits = seg->nRecHits(); + b_GEM_Seg_eta = gp.eta(); + b_GEM_Seg_phi = gp.phi(); + b_GEM_Seg_nRecHits = seg->nRecHits(); + b_GEM_Seg_station = cId.station(); + b_GEM_Seg_ring = cId.ring(); + b_GEM_Seg_chamber = cId.chamber(); + b_GEM_Seg_layer = cId.layer(); + b_nGEMSegments++; t_GEM_seg->Fill(); } for (auto roll : ch->etaPartitions()) { GEMDetId rId = roll->id(); int roll_ = rId.roll(); - b_GEM_Digi_chamber = rId.chamber(); - b_GEM_RecHit_chamber = rId.chamber(); - b_GEM_Digi_layer = rId.layer(); - b_GEM_RecHit_layer = rId.layer(); /* GEM digi */ auto digisRange = gemDigis->get(rId); auto gemDigi = digisRange.first; @@ -618,9 +670,15 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); - b_GEM_Digi_eta = gp.eta(); + b_GEM_Digi_eta = gp.eta(); + b_GEM_Digi_phi = gp.phi(); b_GEM_Digi_etaPartition = roll_; - b_GEM_Digi_bx = hit->bx(); + b_GEM_Digi_bx = hit->bx(); + b_GEM_Digi_chamber = rId.chamber(); + b_GEM_Digi_layer = rId.layer(); + b_GEM_Digi_station = rId.station(); + b_GEM_Digi_ring = rId.ring(); + t_GEM_digi->Fill(); b_nGEMDigis++; } @@ -630,9 +688,15 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto rec = gemRec; rec != recRange.second; ++rec) { auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); - b_GEM_RecHit_eta = gp.eta(); + b_GEM_RecHit_eta = gp.eta(); + b_GEM_RecHit_phi = gp.phi(); b_GEM_RecHit_etaPartition = roll_; - b_GEM_RecHit_bx = rec->BunchX(); + b_GEM_RecHit_bx = rec->BunchX(); + b_GEM_RecHit_chamber = rId.chamber(); + b_GEM_RecHit_layer = rId.layer(); + b_GEM_RecHit_station = rId.station(); + b_GEM_RecHit_ring = rId.ring(); + b_nGEMRecHits++; t_GEM_rec->Fill(); } @@ -645,7 +709,8 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto iEta = std::to_string(detId.roll()); auto station = std::to_string(detId.station()); auto ring = std::to_string(detId.ring()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; const int idx = hGEMArea_->GetXaxis()->FindBin(rollName.c_str()); hGEMCounts_->Fill(idx); @@ -656,40 +721,37 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto ch : DTGeometry_->chambers()) { /* DT seg */ DTChamberId cId = ch->id(); - b_DT_4DSeg_station = cId.station(); - b_DT_4DSeg_sector = cId.sector(); - b_DT_4DSeg_wheel = cId.wheel(); //b_DT_4DSeg_chamber = ch->id(); auto segsRange = dt4DSegments->get(cId); auto dt4DSeg = segsRange.first; for (auto seg = dt4DSeg; seg != segsRange.second; ++seg) { auto segLd = seg->localPosition(); auto gp = ch->toGlobal(segLd); - b_DT_4DSeg_eta = gp.eta(); + b_DT_4DSeg_eta = gp.eta(); + b_DT_4DSeg_phi = gp.phi(); b_DT_4DSeg_nRecHits = seg->recHits().size(); - b_DT_4DSeg_hasZed = seg->hasZed(); + b_DT_4DSeg_hasZed = seg->hasZed(); + b_DT_4DSeg_station = cId.station(); + b_DT_4DSeg_sector = cId.sector(); + b_DT_4DSeg_wheel = cId.wheel(); + b_nDT4DSegments++; t_DT_seg->Fill(); } } for (auto ly : DTGeometry_->layers()) { DTLayerId lId = ly->id(); - b_DT_Digi_station = lId.station(); - b_DT_RecHit_station = lId.station(); - b_DT_Digi_sector = lId.sector(); - b_DT_RecHit_sector = lId.sector(); - b_DT_Digi_wheel = lId.wheel(); - b_DT_RecHit_wheel = lId.wheel(); - b_DT_Digi_layer = lId.layer(); - b_DT_RecHit_layer = lId.layer(); - b_DT_Digi_superLayer = lId.superLayer(); - b_DT_RecHit_superLayer = lId.superLayer(); - /* DT digi */ auto digisRange = dtDigis->get(lId); auto dtDigi = digisRange.first; for (auto hit = dtDigi; hit != digisRange.second; ++hit) { - b_DT_Digi_wire = hit->wire(); + b_DT_Digi_wire = hit->wire(); + b_DT_Digi_station = lId.station(); + b_DT_Digi_sector = lId.sector(); + b_DT_Digi_wheel = lId.wheel(); + b_DT_Digi_layer = lId.layer(); + b_DT_Digi_superLayer = lId.superLayer(); + t_DT_digi->Fill(); b_nDTDigis++; } @@ -700,44 +762,46 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) auto recLd = rec->localPosition(); auto gp = ly->toGlobal(recLd); auto wireId = rec->wireId(); - b_DT_RecHit_wire = wireId.wire(); - b_DT_RecHit_eta = gp.eta(); + b_DT_RecHit_wire = wireId.wire(); + b_DT_RecHit_eta = gp.eta(); + b_DT_RecHit_phi = gp.phi(); + b_DT_RecHit_station = lId.station(); + b_DT_RecHit_sector = lId.sector(); + b_DT_RecHit_wheel = lId.wheel(); + b_DT_RecHit_layer = lId.layer(); + b_DT_RecHit_superLayer = lId.superLayer(); + b_nDTRecHits++; t_DT_rec->Fill(); } } for (auto ch : RPCGeometry_->chambers()) { - RPCDetId cId = ch->id(); - b_RPC_Digi_station = cId.station(); - b_RPC_RecHit_station = cId.station(); - b_RPC_Digi_ring = cId.ring(); - b_RPC_RecHit_ring = cId.ring(); + //RPCDetId cId = ch->id(); //b_RPC_Digi_chamber = cId.chamber(); //b_RPC_RecHit_chamber = cId.chamber(); - b_RPC_Digi_sector = cId.sector(); - b_RPC_RecHit_sector = cId.sector(); - b_RPC_Digi_subSector = cId.subsector(); - b_RPC_RecHit_subSector = cId.subsector(); - b_RPC_Digi_region = cId.region(); // region : 0 for barrel +/-1 for +/- endcap - b_RPC_RecHit_region = cId.region(); - for (auto roll : ch->rolls()) { - b_RPC_Digi_isIRPC = (int)roll->isIRPC(); - b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); RPCDetId rId = roll->id(); int roll_ = rId.roll(); - b_RPC_Digi_layer = rId.layer(); - b_RPC_RecHit_layer = rId.layer(); /* RPC digi */ auto digisRange = rpcDigis->get(rId); auto rpcDigi = digisRange.first; + cout << rId.region() << endl; for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { auto strip = hit->strip(); auto digiLp = roll->centreOfStrip(strip); auto gp = roll->toGlobal(digiLp); - b_RPC_Digi_eta = gp.eta(); - b_RPC_Digi_roll = roll_; + b_RPC_Digi_eta = gp.eta(); + b_RPC_Digi_phi = gp.phi(); + b_RPC_Digi_roll = roll_; // Roll id (also known as eta partition): each chamber is divided along the strip direction in - two or three parts (rolls) for Barrel and two, three or four parts for endcap + b_RPC_Digi_station = rId.station(); // Station id : For Barrel: the four groups of chambers at same r (distance from beam axis) and increasing phi / For Endcap: the three groups of chambers at same z (distance from interaction point), i.e. the disk + b_RPC_Digi_ring = rId.ring(); // Ring id: Wheel number in Barrel (from -2 to +2) Ring Number in Endcap (from 1 to 3) Ring has a different meaning in Barrel and Endcap! In Barrel it is wheel, in Endcap Ring has a different meaning in + b_RPC_Digi_sector = rId.sector(); // Sector id: the group of chambers at same phi (and increasing r) + b_RPC_Digi_subSector = rId.subsector(); // subSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel, from 1 to 6 in Endcap) + b_RPC_Digi_layer = rId.layer(); // Layer id: each station can have two layers of chambers: layer 1 is the inner chamber and layer 2 is the outer chamber (when present) // Only in Barrel: RB1 and RB2 + b_RPC_Digi_region = rId.region(); // region : 0 for barrel +/-1 for +/- endcap + b_RPC_Digi_isIRPC = (int)roll->isIRPC(); + //cout << b_RPC_Digi_region << " " << rId.region() << endl; t_RPC_digi->Fill(); b_nRPCDigis++; } @@ -747,8 +811,17 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) for (auto rec = rpcRec; rec != recRange.second; ++rec) { auto recLd = rec->localPosition(); auto gp = roll->toGlobal(recLd); - b_RPC_RecHit_eta = gp.eta(); - b_RPC_RecHit_roll = roll_; + b_RPC_RecHit_eta = gp.eta(); + b_RPC_RecHit_phi = gp.phi(); + b_RPC_RecHit_roll = roll_; + b_RPC_RecHit_station = rId.station(); + b_RPC_RecHit_ring = rId.ring(); + b_RPC_RecHit_sector = rId.sector(); + b_RPC_RecHit_subSector = rId.subsector(); + b_RPC_RecHit_layer = rId.layer(); + b_RPC_RecHit_region = rId.region(); + b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); + b_nRPCRecHits++; t_RPC_rec->Fill(); } @@ -763,16 +836,32 @@ HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) } + /* gen Muon */ + for (TrackingParticleCollection::size_type i=0; isize(); i++) { + TrackingParticleRef simRef(simHandle, i); + const TrackingParticle* simTP = simRef.get(); + b_genMuon_pt = simTP->pt(); + b_genMuon_eta = simTP->eta(); + b_genMuon_phi = simTP->phi(); + bool isSignalMuon = abs(simTP->pdgId())==13 && !simTP->genParticles().empty() && (simTP->eventId().event() == 0) && (simTP->eventId().bunchCrossing() == 0); + if (!isSignalMuon) continue; + t_genMuon->Fill(); + } /* reco Muon */ for(size_t i = 0; i < muonHandle->size(); ++i) { initMuonValue(); edm::RefToBase muRef = muonHandle->refAt(i); const reco::Muon* mu = muRef.get(); - b_muon_isTight = muon::isTightMuon(*mu, pv0); - b_muon_isMedium = muon::isMediumMuon(*mu); - b_muon_isLoose = muon::isLooseMuon(*mu); - b_muon_pt = mu->pt(); - b_muon_eta = mu->eta(); + b_muon_isTight = muon::isTightMuon(*mu, pv0); + b_muon_isMedium = muon::isMediumMuon(*mu); + b_muon_isLoose = muon::isLooseMuon(*mu); + b_muon_pt = mu->pt(); + b_muon_eta = mu->eta(); + b_muon_phi = mu->phi(); + b_muon_isGlobalMuon = mu->isGlobalMuon(); + b_muon_isTrackerMuon = mu->isTrackerMuon(); + b_muon_isME0Muon = mu->isME0Muon(); + b_muon_nMatchedStationLayer = mu->numberOfMatchedStations(); t_Muon->Fill(); } @@ -847,7 +936,8 @@ void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){ auto iEta = std::to_string(detId.roll()); auto station = std::to_string(detId.station()); // for now, always 1 auto ring = std::to_string(0);//std::to_string(detId.ring()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); const float striplength(top_->stripLength()); const float pitch(roll->pitch()); @@ -867,7 +957,8 @@ void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){ auto iEta = std::to_string(detId.roll()); auto station = std::to_string(detId.station()); auto ring = std::to_string(detId.ring()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_iEta_"+iEta; + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); const float striplength(top_->stripLength()); const float pitch(roll->pitch()); @@ -886,7 +977,8 @@ void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){ auto ch = std::to_string(detId.chamber()); auto ring = std::to_string(detId.ring()); auto station = std::to_string(detId.station()); - const string name = "Endcap_"+endcap+"_Station_"+station+"_ring_"+ring+"_CH_"+ch; + auto layer = std::to_string(detId.layer()); + const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; const RadialStripTopology* top_(dynamic_cast(&(ly->topology()))); const float striplength(top_->stripLength()); const float pitch(ly->geometry()->stripPitch()); @@ -909,13 +1001,15 @@ void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){ hRPCArea_->Fill(iRPC, width*height); } - } void HGCalSimTest::endRun(Run const&, EventSetup const&){} void HGCalSimTest::initMuonValue() { - b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; - b_muon_pt = -9; b_muon_eta = -9; + b_genMuon_pt = -9; b_genMuon_eta = -9; b_genMuon_phi = -9; + + b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; b_muon_isTrackerMuon = -1; b_muon_isGlobalMuon = -1; b_muon_isME0Muon = -1; + b_muon_pt = -9; b_muon_eta = -9; b_muon_phi = -9; + b_muon_nMatchedStationLayer = -9; } void HGCalSimTest::initValue() { @@ -927,37 +1021,37 @@ void HGCalSimTest::initValue() { /*ME0 digi*/ b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; b_ME0_Digi_bx = -999; - b_ME0_Digi_eta = -9; + b_ME0_Digi_eta = -9; b_ME0_Digi_phi = -9; /*ME0 seg*/ b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; - b_ME0_Seg_eta = -9; + b_ME0_Seg_eta = -9; b_ME0_Seg_phi = -9; /*ME0 rechit*/ b_ME0_RecHit_etaPartition = -9; - b_ME0_RecHit_eta = -9; + b_ME0_RecHit_eta = -9; b_ME0_RecHit_phi = -9; /*CSC seg*/ b_CSC_Seg_chamber = -9; b_CSC_Seg_layer = -9; b_CSC_Seg_station = -9; b_CSC_Seg_ring = -9; b_CSC_Seg_nRecHits = -9; - b_CSC_Seg_eta = -9; + b_CSC_Seg_eta = -9; b_CSC_Seg_phi = -9; /*CSC rechit*/ b_CSC_2DRecHit_chamber = -9; b_CSC_2DRecHit_layer = -9; b_CSC_2DRecHit_station = -9; b_CSC_2DRecHit_ring = -9; b_CSC_2DRecHit_etaPartition = -9; - b_CSC_2DRecHit_eta = -9; + b_CSC_2DRecHit_eta = -9; b_CSC_2DRecHit_phi = -9; /*GEM digi*/ b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; b_GEM_Digi_bx = -999; - b_GEM_Digi_eta = -9; + b_GEM_Digi_eta = -9; b_GEM_Digi_phi = -9; /*GEM seg*/ b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_nRecHits = -9; - b_GEM_Seg_eta = -9; + b_GEM_Seg_eta = -9; b_GEM_Seg_phi = -9; /*GEM rechit*/ b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_etaPartition = -9; b_GEM_RecHit_bx = -999; - b_GEM_RecHit_eta = -9; + b_GEM_RecHit_eta = -9; b_GEM_RecHit_phi = -9;; /* DT digi*/ b_DT_Digi_chamber = -9; b_DT_Digi_layer = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_wheel = -9; b_DT_Digi_sector = -9; b_DT_Digi_station = -9; b_DT_Digi_wire = -9; - b_DT_Digi_eta = -9; + b_DT_Digi_eta = -9; //b_DT_Digi_phi = -9; /* DT seg*/ b_DT_4DSeg_chamber = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_nRecHits = -9; - b_DT_4DSeg_eta = -9; + b_DT_4DSeg_eta = -9; b_DT_4DSeg_phi = -9; b_DT_4DSeg_hasZed = -1; /* DT rechit*/ b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_wire = -9; @@ -965,11 +1059,11 @@ void HGCalSimTest::initValue() { /*RPC digi*/ b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; b_RPC_Digi_region = -9; - b_RPC_Digi_eta = -9; + b_RPC_Digi_eta = -9; b_RPC_Digi_phi = -9; b_RPC_Digi_isIRPC = -1; /*RPC rechit*/ b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; b_RPC_RecHit_region = -9; - b_RPC_RecHit_eta = -9; + b_RPC_RecHit_eta = -9; b_RPC_RecHit_phi = -9; b_RPC_RecHit_isIRPC = -1; } diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index 59aa193ab3c..ceb791d2d46 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -19,7 +19,8 @@ process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) process.source.skipEvents = cms.untracked.uint32(0) -process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') +#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') +process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singlePion_RECO_v2/190213_061518/0000/singlePion_GEN-SIM-DIGI_10.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_050.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') #from glob import glob @@ -48,6 +49,7 @@ dtRecHits = cms.InputTag("dt1DRecHits"), rpcDigis = cms.InputTag("simMuonRPCDigis"), rpcRecHits = cms.InputTag("rpcRecHits"), + simLabel = cms.InputTag("mix","MergedTrackTruth"), muonLabel = cms.InputTag("muons"), primaryVertex = cms.InputTag('offlinePrimaryVertices'), From c98e514d9ce1bd4121e111547459c28547b8cbff Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 26 Feb 2019 03:29:47 +0900 Subject: [PATCH 42/50] Except slice test things and split HGCalSimTest into MuonDetHitAnalyser and MuonTrackAnalyser --- MuonAnalyser/plugins/HGCalSimTest.cc | 1072 ----------------- MuonAnalyser/plugins/MuonDetHitAnalyser.cc | 769 ++++++++++++ MuonAnalyser/plugins/MuonTrackAnalyser.cc | 478 ++++++++ MuonAnalyser/plugins/STASliceTestAnalysis.cc | 572 --------- MuonAnalyser/plugins/SliceTestAnalysis.cc | 545 --------- MuonAnalyser/plugins/SliceTestBkgAnalysis.cc | 564 --------- .../plugins/SliceTestEfficiencyAnalysis.cc | 388 ------ MuonAnalyser/python/RAW2STA_SliceTest.py | 125 -- MuonAnalyser/test/CrabSlice.py | 28 - MuonAnalyser/test/CrabSlice_EGamma.py | 28 - MuonAnalyser/test/RAW2STA_SliceTest_2018C.py | 128 -- MuonAnalyser/test/RAW2STA_SliceTest_2018D.py | 129 -- MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py | 128 -- MuonAnalyser/test/RAW2STA_SliceTest_MC.py | 128 -- MuonAnalyser/test/gemsim_on_condor.jds | 10 - MuonAnalyser/test/gemsim_on_condor.sh | 11 - MuonAnalyser/test/runHGCalSimTest.py | 19 +- MuonAnalyser/test/runSliceTestAnalysis.py | 44 - MuonAnalyser/test/runSliceTestAnalysis2018.py | 62 - MuonAnalyser/test/runSliceTestBkgAnalysis.py | 47 - .../runSliceTestEfficiencyAnalysis2018.py | 63 - MuonAnalyser/test/sliceCrab.py | 28 - 22 files changed, 1259 insertions(+), 4107 deletions(-) delete mode 100644 MuonAnalyser/plugins/HGCalSimTest.cc create mode 100644 MuonAnalyser/plugins/MuonDetHitAnalyser.cc create mode 100644 MuonAnalyser/plugins/MuonTrackAnalyser.cc delete mode 100644 MuonAnalyser/plugins/STASliceTestAnalysis.cc delete mode 100644 MuonAnalyser/plugins/SliceTestAnalysis.cc delete mode 100644 MuonAnalyser/plugins/SliceTestBkgAnalysis.cc delete mode 100644 MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc delete mode 100644 MuonAnalyser/python/RAW2STA_SliceTest.py delete mode 100644 MuonAnalyser/test/CrabSlice.py delete mode 100644 MuonAnalyser/test/CrabSlice_EGamma.py delete mode 100644 MuonAnalyser/test/RAW2STA_SliceTest_2018C.py delete mode 100644 MuonAnalyser/test/RAW2STA_SliceTest_2018D.py delete mode 100644 MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py delete mode 100644 MuonAnalyser/test/RAW2STA_SliceTest_MC.py delete mode 100644 MuonAnalyser/test/gemsim_on_condor.jds delete mode 100755 MuonAnalyser/test/gemsim_on_condor.sh delete mode 100644 MuonAnalyser/test/runSliceTestAnalysis.py delete mode 100644 MuonAnalyser/test/runSliceTestAnalysis2018.py delete mode 100644 MuonAnalyser/test/runSliceTestBkgAnalysis.py delete mode 100644 MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py delete mode 100644 MuonAnalyser/test/sliceCrab.py diff --git a/MuonAnalyser/plugins/HGCalSimTest.cc b/MuonAnalyser/plugins/HGCalSimTest.cc deleted file mode 100644 index 02c7778bf3b..00000000000 --- a/MuonAnalyser/plugins/HGCalSimTest.cc +++ /dev/null @@ -1,1072 +0,0 @@ -// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// system include files -#include -#include -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" -// ME0 -#include "DataFormats/GEMDigi/interface/ME0DigiCollection.h" -#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" -#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" -#include "DataFormats/MuonDetId/interface/ME0DetId.h" -#include "Geometry/GEMGeometry/interface/ME0Geometry.h" -#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" -#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" -// GEM -#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -// CSC -#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" -#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -// DT -#include "DataFormats/DTDigi/interface/DTDigiCollection.h" -#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" -//#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h" -#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" -#include "DataFormats/MuonDetId/interface/DTBtiId.h" -#include "DataFormats/MuonDetId/interface/DTChamberId.h" -#include "DataFormats/MuonDetId/interface/DTLayerId.h" -#include "DataFormats/MuonDetId/interface/DTSectCollId.h" -#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" -#include "DataFormats/MuonDetId/interface/DTTracoId.h" -#include "DataFormats/MuonDetId/interface/DTWireId.h" -#include "Geometry/DTGeometry/interface/DTGeometry.h" -// RPC -#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" -#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" -#include "DataFormats/MuonDetId/interface/RPCDetId.h" -#include "Geometry/RPCGeometry/interface/RPCGeometry.h" -#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" -// Muon -#include "DataFormats/PatCandidates/interface/Muon.h" -// L1 -#include "DataFormats/L1TMuon/interface/L1MuBMTrack.h" - -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" - -#include "SimDataFormats/TrackingHit/interface/PSimHit.h" -#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" -#include "SimDataFormats/Associations/interface/MuonToTrackingParticleAssociator.h" -#include "SimDataFormats/Vertex/interface/SimVertex.h" -#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" -#include "SimMuon/MCTruth/interface/MuonToSimAssociatorByHits.h" -#include "SimTracker/Common/interface/TrackingParticleSelector.h" -#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" - -#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" -#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" -#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TProfile.h" -#include "TString.h" -#include "TGraphAsymmErrors.h" -#include "TLorentzVector.h" -#include "TTree.h" - -using namespace std; -using namespace edm; - -class HGCalSimTest : public edm::EDAnalyzer { -public: - explicit HGCalSimTest(const edm::ParameterSet&); - ~HGCalSimTest(); - -private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() override; - virtual void endJob() override; - - virtual void beginRun(Run const&, EventSetup const&) override; - virtual void endRun(Run const&, EventSetup const&) override; - - void initMuonValue(); - void initValue(); - - TProfile* hME0Area_; - TH1D* hME0Counts_; - - TProfile* hGEMArea_; - TH1D* hGEMCounts_; - - TProfile* hCSCArea_; - TH1D* hCSCCounts_; - - TProfile* hRPCArea_; - TH1D* hRPCCounts_; - - TH1D* hEvents_; - - // ----------member data --------------------------- - edm::EDGetTokenT me0Digis_; - edm::EDGetTokenT me0Segments_; - edm::EDGetTokenT me0RecHits_; - - edm::EDGetTokenT cscSegments_; - edm::EDGetTokenT csc2DRecHits_; - - edm::EDGetTokenT gemDigis_; - edm::EDGetTokenT gemSegments_; - edm::EDGetTokenT gemRecHits_; - - edm::EDGetTokenT dtDigis_; - edm::EDGetTokenT dt4DSegments_; - edm::EDGetTokenT dtRecHits_; - - edm::EDGetTokenT rpcDigis_; - edm::EDGetTokenT rpcRecHits_; - - edm::EDGetTokenT simToken_; - edm::EDGetTokenT > muonToken_; - -// edm::EDGetTokenT > muonL1Token_; - - const reco::VertexCollection* vertexes_; - edm::EDGetTokenT > vtxToken_; - - edm::Service fs; - - TTree *t_event; - int b_run, b_lumi, b_latency; - int b_nME0Digis, b_nME0Segments, b_nME0RecHits, b_nCSCSegments, b_nCSC2DRecHits, b_nGEMDigis, b_nGEMSegments, b_nGEMRecHits, b_nDTDigis, b_nDT4DSegments, b_nDTRecHits, b_nRPCDigis, b_nRPCRecHits; - - /* ME0 */ - TTree *t_ME0_digi; - int b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition, b_ME0_Digi_bx; - float b_ME0_Digi_eta, b_ME0_Digi_phi; - TTree *t_ME0_seg; - int b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; - float b_ME0_Seg_eta, b_ME0_Seg_phi; - TTree *t_ME0_rec; - int b_ME0_RecHit_chamber, b_ME0_RecHit_layer, b_ME0_RecHit_etaPartition; - float b_ME0_RecHit_eta, b_ME0_RecHit_phi; - - /* CSC */ - TTree *t_CSC_seg; - int b_CSC_Seg_chamber, b_CSC_Seg_layer, b_CSC_Seg_station, b_CSC_Seg_ring, b_CSC_Seg_nRecHits; - float b_CSC_Seg_eta, b_CSC_Seg_phi; - TTree *t_CSC_rec; - int b_CSC_2DRecHit_chamber, b_CSC_2DRecHit_layer, b_CSC_2DRecHit_station, b_CSC_2DRecHit_ring, b_CSC_2DRecHit_etaPartition; - float b_CSC_2DRecHit_eta, b_CSC_2DRecHit_phi; - - /* GEM */ - TTree *t_GEM_digi; - int b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_etaPartition, b_GEM_Digi_bx; - float b_GEM_Digi_eta, b_GEM_Digi_phi; - TTree *t_GEM_seg; - int b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_nRecHits; - float b_GEM_Seg_eta, b_GEM_Seg_phi; - TTree *t_GEM_rec; - int b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_etaPartition, b_GEM_RecHit_bx; - float b_GEM_RecHit_eta, b_GEM_RecHit_phi; - - /* DT */ - TTree *t_DT_digi; - int b_DT_Digi_chamber, b_DT_Digi_layer, b_DT_Digi_superLayer, b_DT_Digi_wheel, b_DT_Digi_sector, b_DT_Digi_station, b_DT_Digi_wire; - float b_DT_Digi_eta, b_DT_Digi_phi; - TTree *t_DT_seg; - int b_DT_4DSeg_chamber, b_DT_4DSeg_wheel, b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_nRecHits, b_DT_4DSeg_hasZed; - float b_DT_4DSeg_eta, b_DT_4DSeg_phi; - TTree *t_DT_rec; - int b_DT_RecHit_chamber, b_DT_RecHit_layer, b_DT_RecHit_superLayer, b_DT_RecHit_wheel, b_DT_RecHit_sector, b_DT_RecHit_station, b_DT_RecHit_wire; - float b_DT_RecHit_eta, b_DT_RecHit_phi; - - /* RPC */ - TTree *t_RPC_digi; - int b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_roll, b_RPC_Digi_sector, b_RPC_Digi_subSector, b_RPC_Digi_region; - int b_RPC_Digi_isIRPC; - float b_RPC_Digi_eta, b_RPC_Digi_phi; - TTree *t_RPC_rec; - int b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_roll, b_RPC_RecHit_sector, b_RPC_RecHit_subSector, b_RPC_RecHit_region; - int b_RPC_RecHit_isIRPC; - float b_RPC_RecHit_eta, b_RPC_RecHit_phi; - - /* Muon */ - TTree *t_genMuon; - float b_genMuon_pt, b_genMuon_eta, b_genMuon_phi; - int b_genMuon_isTight, b_genMuon_isMedium, b_genMuon_isLoose, b_genMuon_isTrackerMuon, b_genMuon_isGlobalMuon, b_genMuon_isME0Muon, b_genMuon_nMatchedStationLayer; - - - TTree *t_Muon; - float b_muon_pt, b_muon_eta, b_muon_phi; - int b_muon_isTight, b_muon_isMedium, b_muon_isLoose, b_muon_isTrackerMuon, b_muon_isGlobalMuon, b_muon_isME0Muon, b_muon_nMatchedStationLayer; -}; - -HGCalSimTest::HGCalSimTest(const edm::ParameterSet& iConfig) -{ - me0Digis_ = consumes(iConfig.getParameter("me0Digis")); - me0Segments_ = consumes(iConfig.getParameter("me0Segments")); - me0RecHits_ = consumes(iConfig.getParameter("me0RecHits")); - - cscSegments_ = consumes(iConfig.getParameter("cscSegments")); - csc2DRecHits_ = consumes(iConfig.getParameter("csc2DRecHits")); - - gemDigis_ = consumes(iConfig.getParameter("gemDigis")); - gemSegments_ = consumes(iConfig.getParameter("gemSegments")); - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - - dtDigis_ = consumes(iConfig.getParameter("dtDigis")); - dt4DSegments_ = consumes(iConfig.getParameter("dt4DSegments")); - dtRecHits_ = consumes(iConfig.getParameter("dtRecHits")); - - rpcDigis_ = consumes(iConfig.getParameter("rpcDigis")); - rpcRecHits_ = consumes(iConfig.getParameter("rpcRecHits")); - - simToken_ = consumes(iConfig.getParameter("simLabel")); - muonToken_ = consumes >(iConfig.getParameter("muonLabel")); - -// muonL1Token_ = consumes >(iConfig.getParameter("muonL1Label")); - - vtxToken_ = consumes >(iConfig.getParameter("primaryVertex")); - - - t_event = fs->make("Event", "Event"); - t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); - t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); - t_event->Branch("nME0RecHits", &b_nME0RecHits, "nME0RecHits/I"); - t_event->Branch("nCSCSegments", &b_nCSCSegments, "nCSCSegments/I"); - t_event->Branch("nCSC2DRecHits", &b_nCSC2DRecHits, "nCSC2DRecHits/I"); - t_event->Branch("nGEMDigis", &b_nGEMDigis, "nGEMDigis/I"); - t_event->Branch("nGEMSegments", &b_nGEMSegments, "nGEMSegments/I"); - t_event->Branch("nGEMRecHits", &b_nGEMRecHits, "nGEMRecHits/I"); - t_event->Branch("nDTDigis", &b_nDTDigis, "nDTDigis/I"); - t_event->Branch("nDT4DSegments", &b_nDT4DSegments, "nDT4DSegments/I"); - t_event->Branch("nDTRecHits", &b_nDTRecHits, "nDTRecHits/I"); - t_event->Branch("nRPCDigis", &b_nRPCDigis, "nRPCDigis/I"); - t_event->Branch("nRPCRecHits", &b_nRPCRecHits, "nRPCRecHits/I"); - - /*ME0*/ - t_ME0_digi = fs->make("ME0_Hit", "ME0_Hit"); - t_ME0_digi->Branch("Digi_chamber", &b_ME0_Digi_chamber, "Digi_chamber/I"); - t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); - t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); - t_ME0_digi->Branch("Digi_eta", &b_ME0_Digi_eta, "Digi_eta/F"); - t_ME0_digi->Branch("Digi_phi", &b_ME0_Digi_phi, "Digi_phi/F"); - t_ME0_digi->Branch("Digi_bx", &b_ME0_Digi_bx, "Digi_bx/I"); - - t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); - t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); - t_ME0_seg->Branch("Seg_phi", &b_ME0_Seg_phi, "Seg_phi/F"); - t_ME0_seg->Branch("Seg_chamber", &b_ME0_Seg_chamber, "Seg_chamber/I"); - t_ME0_seg->Branch("Seg_layer", &b_ME0_Seg_layer, "Seg_layer/I"); - t_ME0_seg->Branch("Seg_nRecHits", &b_ME0_Seg_nRecHits, "Seg_nRecHits/I"); - - t_ME0_rec = fs->make("ME0_RecHit", "ME0_RecHit"); - t_ME0_rec->Branch("RecHit_chamber", &b_ME0_RecHit_chamber, "RecHit_chaber/I"); - t_ME0_rec->Branch("RecHit_layer", &b_ME0_RecHit_layer, "RecHit_layer/I"); - t_ME0_rec->Branch("RecHit_etaPartition", &b_ME0_RecHit_etaPartition, "RecHit_etaParition/I"); - t_ME0_rec->Branch("RecHit_eta", &b_ME0_RecHit_eta, "RecHit_eta/F"); - t_ME0_rec->Branch("RecHit_phi", &b_ME0_RecHit_phi, "RecHit_phi/F"); - - /*CSC*/ - t_CSC_seg = fs->make("CSC_Segment", "CSC_Segment"); - t_CSC_seg->Branch("Seg_eta", &b_CSC_Seg_eta, "Seg_eta/F"); - t_CSC_seg->Branch("Seg_phi", &b_CSC_Seg_phi, "Seg_phi/F"); - t_CSC_seg->Branch("Seg_chamber", &b_CSC_Seg_chamber, "Seg_chamber/I"); - t_CSC_seg->Branch("Seg_layer", &b_CSC_Seg_layer, "Seg_layer/I"); - t_CSC_seg->Branch("Seg_nRecHits", &b_CSC_Seg_nRecHits, "Seg_nRecHits/I"); - t_CSC_seg->Branch("Seg_station", &b_CSC_Seg_station, "Seg_station/I"); - t_CSC_seg->Branch("Seg_ring", &b_CSC_Seg_ring, "Seg_ring/I"); - - t_CSC_rec = fs->make("CSC_2DRecHit", "CSC_2DRecHit"); - t_CSC_rec->Branch("RecHit_chamber", &b_CSC_2DRecHit_chamber, "RecHit_chaber/I"); - t_CSC_rec->Branch("RecHit_layer", &b_CSC_2DRecHit_layer, "RecHit_layer/I"); - t_CSC_rec->Branch("RecHit_eta", &b_CSC_2DRecHit_eta, "RecHit_eta/F"); - t_CSC_rec->Branch("RecHit_phi", &b_CSC_2DRecHit_phi, "RecHit_phi/F"); - t_CSC_rec->Branch("RecHit_station", &b_CSC_2DRecHit_station, "RecHit_station/I"); - t_CSC_rec->Branch("RecHit_ring", &b_CSC_2DRecHit_ring, "RecHit_ring/I"); - - /*GEM*/ - t_GEM_digi = fs->make("GEM_Hit", "GEM_Hit"); - t_GEM_digi->Branch("Digi_chamber", &b_GEM_Digi_chamber, "Digi_chamber/I"); - t_GEM_digi->Branch("Digi_layer", &b_GEM_Digi_layer, "Digi_layer/I"); - t_GEM_digi->Branch("Digi_etaPartition", &b_GEM_Digi_etaPartition, "Digi_etaPartition/I"); - t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); - t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); - t_GEM_digi->Branch("Digi_eta", &b_GEM_Digi_eta, "Digi_eta/F"); - t_GEM_digi->Branch("Digi_phi", &b_GEM_Digi_phi, "Digi_phi/F"); - t_GEM_digi->Branch("Digi_bx", &b_GEM_Digi_bx, "Digi_bx/I"); - - t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); - t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); - t_GEM_seg->Branch("Seg_phi", &b_GEM_Seg_phi, "Seg_phi/F"); - t_GEM_seg->Branch("Seg_chamber", &b_GEM_Seg_chamber, "Seg_chamber/I"); - t_GEM_seg->Branch("Seg_layer", &b_GEM_Seg_layer, "Seg_layer/I"); - t_GEM_seg->Branch("Seg_nRecHits", &b_GEM_Seg_nRecHits, "Seg_nRecHits/I"); - t_GEM_seg->Branch("Seg_station", &b_GEM_Seg_station, "Seg_station/I"); - t_GEM_seg->Branch("Seg_ring", &b_GEM_Seg_ring, "Seg_ring/I"); - - t_GEM_rec = fs->make("GEM_RecHit", "GEM_RecHit"); - t_GEM_rec->Branch("RecHit_chamber", &b_GEM_RecHit_chamber, "RecHit_chaber/I"); - t_GEM_rec->Branch("RecHit_layer", &b_GEM_RecHit_layer, "RecHit_layer/I"); - t_GEM_rec->Branch("RecHit_etaPartition", &b_GEM_RecHit_etaPartition, "RecHit_etaParition/I"); - t_GEM_rec->Branch("RecHit_eta", &b_GEM_RecHit_eta, "RecHit_eta/F"); - t_GEM_rec->Branch("RecHit_phi", &b_GEM_RecHit_phi, "RecHit_phi/F"); - t_GEM_rec->Branch("RecHit_station", &b_GEM_RecHit_station, "RecHit_station/I"); - t_GEM_rec->Branch("RecHit_ring", &b_GEM_RecHit_ring, "RecHit_ring/I"); - t_GEM_rec->Branch("RecHit_bx", &b_GEM_RecHit_bx, "RecHit_bx/I"); - - /*DT*/ - t_DT_digi = fs->make("DT_Hit", "DT_Hit"); - t_DT_digi->Branch("Digi_chamber", &b_DT_Digi_chamber, "Digi_chamber/I"); - t_DT_digi->Branch("Digi_layer", &b_DT_Digi_layer, "Digi_layer/I"); - t_DT_digi->Branch("Digi_superLayer", &b_DT_Digi_superLayer, "Digi_superLayer/I"); - t_DT_digi->Branch("Digi_wheel", &b_DT_Digi_wheel, "Digi_wheel/I"); - t_DT_digi->Branch("Digi_sector", &b_DT_Digi_sector, "Digi_sector/I"); - t_DT_digi->Branch("Digi_station", &b_DT_Digi_station, "Digi_station/I"); - t_DT_digi->Branch("Digi_wrie", &b_DT_Digi_wire, "Digi_wire/I"); - t_DT_digi->Branch("Digi_eta", &b_DT_Digi_eta, "Digi_eta/F"); - t_DT_digi->Branch("Digi_phi", &b_DT_Digi_phi, "Digi_phi/F"); - - t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); - t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); - t_DT_seg->Branch("Seg_phi", &b_DT_4DSeg_phi, "Seg_phi/F"); - t_DT_seg->Branch("Seg_chamber", &b_DT_4DSeg_chamber, "Seg_chamber/I"); - t_DT_seg->Branch("Seg_nRecHits", &b_DT_4DSeg_nRecHits, "Seg_nRecHits/I"); - t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); - t_DT_seg->Branch("Seg_sector", &b_DT_4DSeg_sector, "Seg_sector/I"); - t_DT_seg->Branch("Seg_station", &b_DT_4DSeg_station, "Seg_station/I"); - t_DT_seg->Branch("Seg_hasZed", &b_DT_4DSeg_hasZed, "Seg_hasZed/I"); - - t_DT_rec = fs->make("DT_RecHit", "DT_RecHit"); - t_DT_rec->Branch("RecHit_chamber", &b_DT_RecHit_chamber, "RecHit_chaber/I"); - t_DT_rec->Branch("RecHit_layer", &b_DT_RecHit_layer, "RecHit_layer/I"); - t_DT_rec->Branch("RecHit_superLayer", &b_DT_RecHit_superLayer, "RecHit_superLayer/I"); - t_DT_rec->Branch("RecHit_eta", &b_DT_RecHit_eta, "RecHit_eta/F"); - t_DT_rec->Branch("RecHit_phi", &b_DT_RecHit_phi, "RecHit_phi/F"); - t_DT_rec->Branch("RecHit_wheel", &b_DT_RecHit_wheel, "RecHit_wheel/I"); - t_DT_rec->Branch("RecHit_sector", &b_DT_RecHit_sector, "RecHit_sector/I"); - t_DT_rec->Branch("RecHit_station", &b_DT_RecHit_station, "RecHit_station/I"); - t_DT_rec->Branch("RecHit_wrie", &b_DT_RecHit_wire, "RecHit_wire/I"); - - /*RPC*/ - t_RPC_digi = fs->make("RPC_Hit", "RPC_Hit"); - t_RPC_digi->Branch("Digi_chamber", &b_RPC_Digi_chamber, "Digi_chamber/I"); - t_RPC_digi->Branch("Digi_layer", &b_RPC_Digi_layer, "Digi_layer/I"); - t_RPC_digi->Branch("Digi_station", &b_RPC_Digi_station, "Digi_station/I"); - t_RPC_digi->Branch("Digi_ring", &b_RPC_Digi_ring, "Digi_ring/I"); - t_RPC_digi->Branch("Digi_roll", &b_RPC_Digi_roll, "Digi_roll/I"); - t_RPC_digi->Branch("Digi_sector", &b_RPC_Digi_sector, "Digi_sector/I"); - t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); - t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); - t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); - t_RPC_digi->Branch("Digi_phi", &b_RPC_Digi_phi, "Digi_phi/F"); - t_RPC_digi->Branch("Digi_region", &b_RPC_Digi_region, "Digi_region/I"); - - t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); - t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); - t_RPC_rec->Branch("RecHit_layer", &b_RPC_RecHit_layer, "RecHit_layer/I"); - t_RPC_rec->Branch("RecHit_station", &b_RPC_RecHit_station, "RecHit_station/I"); - t_RPC_rec->Branch("RecHit_ring", &b_RPC_RecHit_ring, "RecHit_ring/I"); - t_RPC_rec->Branch("RecHit_roll", &b_RPC_RecHit_roll, "RecHit_roll/I"); - t_RPC_rec->Branch("RecHit_sector", &b_RPC_RecHit_sector, "RecHit_sector/I"); - t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); - t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); - t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); - t_RPC_rec->Branch("RecHit_phi", &b_RPC_RecHit_phi, "RecHit_phi/F"); - t_RPC_rec->Branch("RecHit_region", &b_RPC_RecHit_region, "RecHit_region/I"); - - /*Muon*/ - t_genMuon = fs->make("gen_Muon", "gen_Muon"); - t_genMuon->Branch("pt", &b_genMuon_pt, "pt/F"); - t_genMuon->Branch("eta", &b_genMuon_eta, "eta/F"); - t_genMuon->Branch("phi", &b_genMuon_phi, "phi/F"); - t_genMuon->Branch("nMatchedStationLayer" , &b_genMuon_nMatchedStationLayer, "nMatchedStationLayer/I"); - t_genMuon->Branch("isTrackerMuon", &b_genMuon_isTrackerMuon, "isTrackerMuon/I"); - t_genMuon->Branch("isGlobalMuon", &b_genMuon_isGlobalMuon, "isGlobalMuon/I"); - t_genMuon->Branch("isME0Muon", &b_genMuon_isME0Muon, "isME0Muon/I"); - t_genMuon->Branch("isTight", &b_genMuon_isTight, "isTight/I"); - t_genMuon->Branch("isMedium", &b_genMuon_isMedium, "isMedium/I"); - t_genMuon->Branch("isLoose", &b_genMuon_isLoose, "isLoose/I"); - - t_Muon = fs->make("Muon", "Muon"); - t_Muon->Branch("pt", &b_muon_pt, "pt/F"); - t_Muon->Branch("eta", &b_muon_eta, "eta/F"); - t_Muon->Branch("phi", &b_muon_phi, "phi/F"); - t_Muon->Branch("nMatchedStationLayer" , &b_muon_nMatchedStationLayer, "nMatchedStationLayer/I"); - t_Muon->Branch("isTrackerMuon", &b_muon_isTrackerMuon, "isTrackerMuon/I"); - t_Muon->Branch("isGlobalMuon", &b_muon_isGlobalMuon, "isGlobalMuon/I"); - t_Muon->Branch("isME0Muon", &b_muon_isME0Muon, "isME0Muon/I"); - t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); - t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); - t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); - -} - -HGCalSimTest::~HGCalSimTest() -{ -} - -void -HGCalSimTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - edm::ESHandle hME0Geom; - iSetup.get().get(hME0Geom); - const ME0Geometry* ME0Geometry_ = &*hME0Geom; - - /* ME0 Geometry */ - edm::Handle me0Digis; - iEvent.getByToken(me0Digis_, me0Digis); - - edm::Handle me0Segments; - iEvent.getByToken(me0Segments_, me0Segments); - - edm::Handle me0RecHits; - iEvent.getByToken(me0RecHits_, me0RecHits); - - /* CSC Geometry */ - edm::ESHandle hCSCGeom; - iSetup.get().get(hCSCGeom); - const CSCGeometry* CSCGeometry_ = &*hCSCGeom; - - edm::Handle cscSegments; - iEvent.getByToken(cscSegments_, cscSegments); - - edm::Handle csc2DRecHits; - iEvent.getByToken(csc2DRecHits_, csc2DRecHits); - - /* GEM Geometry */ - edm::ESHandle hGEMGeom; - iSetup.get().get(hGEMGeom); - const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - - edm::Handle gemDigis; - iEvent.getByToken(gemDigis_, gemDigis); - - edm::Handle gemSegments; - iEvent.getByToken(gemSegments_, gemSegments); - - edm::Handle gemRecHits; - iEvent.getByToken(gemRecHits_, gemRecHits); - - /* DT Geometry */ - edm::ESHandle hDTGeom; - iSetup.get().get(hDTGeom); - const DTGeometry* DTGeometry_ = &*hDTGeom; - - edm::Handle dtDigis; - iEvent.getByToken(dtDigis_, dtDigis); - - edm::Handle dt4DSegments; - iEvent.getByToken(dt4DSegments_, dt4DSegments); - - edm::Handle dtRecHits; - iEvent.getByToken(dtRecHits_, dtRecHits); - - /* RPC Geometry */ - edm::ESHandle hRPCGeom; - iSetup.get().get(hRPCGeom); - const RPCGeometry* RPCGeometry_ = &*hRPCGeom; - - edm::Handle rpcDigis; - iEvent.getByToken(rpcDigis_, rpcDigis); - - edm::Handle rpcRecHits; - iEvent.getByToken(rpcRecHits_, rpcRecHits); - - /* Muon */ - Handle simHandle; - iEvent.getByToken(simToken_, simHandle); - - edm::Handle > muonHandle; - iEvent.getByToken(muonToken_, muonHandle); - -// edm::Handle > muonL1Handle; -// iEvent.getByToken(muonL1Token_, muonL1Handle); - - edm::Handle vertices; - iEvent.getByToken(vtxToken_, vertices); - - vertexes_ = vertices.product(); - reco::Vertex pv0 = vertexes_->at(0); - - initValue(); - - hEvents_->Fill(1); - - for (auto ch : ME0Geometry_->chambers()) { - /* ME0 seg */ - ME0DetId cId = ch->id(); - auto segsRange = me0Segments->get(cId); - auto me0Seg = segsRange.first; - for (auto seg = me0Seg; seg != segsRange.second; ++seg) { - auto segLd = seg->localPosition(); - auto gp = ch->toGlobal(segLd); - b_ME0_Seg_eta = gp.eta(); - b_ME0_Seg_phi = gp.phi(); - b_ME0_Seg_nRecHits = seg->nRecHits(); - b_ME0_Seg_chamber = cId.chamber(); - b_ME0_Seg_layer = cId.layer(); - - //std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; - b_nME0Segments++; - t_ME0_seg->Fill(); - } - for (auto ly : ch->layers()) { - for (auto roll : ly->etaPartitions()) { - ME0DetId rId = roll->id(); - int roll_ = rId.roll(); - int chamber = rId.chamber(); - int layer = rId.layer(); - /* ME0 digi */ - auto digisRange = me0Digis->get(rId); - auto me0Digi = digisRange.first; - for (auto hit = me0Digi; hit != digisRange.second; ++hit) { - auto strip = hit->strip(); - auto digiLp = roll->centreOfStrip(strip); - auto gp = roll->toGlobal(digiLp); - b_ME0_Digi_eta = gp.eta(); - b_ME0_Digi_phi = gp.phi(); - b_ME0_Digi_etaPartition = roll_; - b_ME0_Digi_bx = hit->bx(); - b_ME0_Digi_chamber = chamber; - b_ME0_Digi_layer = layer; - - t_ME0_digi->Fill(); - b_nME0Digis++; - } - /* ME0 RecHit */ - auto recRange = me0RecHits->get(rId); - auto me0Rec = recRange.first; - for (auto rec = me0Rec; rec != recRange.second; ++rec) { - auto recLd = rec->localPosition(); - auto gp = roll->toGlobal(recLd); - b_ME0_RecHit_eta = gp.eta(); - b_ME0_RecHit_phi = gp.phi(); - b_ME0_RecHit_etaPartition = roll_; - b_ME0_RecHit_chamber = chamber; - b_ME0_RecHit_layer = layer; - - //std::cout << b_ME0_RecHit_chamber << " ==> seg x : " << recLd.x() << " seg y : " << recLd.y() << " seg eta : " << gp.eta() << " nME0RecHits : " << b_nME0RecHits << std::endl; - b_nME0RecHits++; - t_ME0_rec->Fill(); - } - } - } - } - for ( auto me0Hit : *me0RecHits ) { - const auto detId = me0Hit.me0Id(); - auto region = std::to_string(detId.region()); - auto ch = std::to_string(detId.chamber()); - auto iEta = std::to_string(detId.roll()); - auto station = std::to_string(detId.station()); - auto ring = std::to_string(0);//std::to_string(detId.ring()); - auto layer = std::to_string(detId.layer()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; - const int idx = hME0Area_->GetXaxis()->FindBin(rollName.c_str()); - hME0Counts_->Fill(idx); - } - - - for (auto ch : CSCGeometry_->chambers()) { - /* CSC seg */ - CSCDetId cId = ch->id(); - auto segsRange = cscSegments->get(cId); - auto cscSeg = segsRange.first; - for (auto seg = cscSeg; seg != segsRange.second; ++seg) { - auto segLd = seg->localPosition(); - auto gp = ch->toGlobal(segLd); - b_CSC_Seg_eta = gp.eta(); - b_CSC_Seg_phi = gp.phi(); - b_CSC_Seg_nRecHits = seg->nRecHits(); - b_CSC_Seg_station = cId.station(); - b_CSC_Seg_ring = cId.ring(); - b_CSC_Seg_chamber = cId.chamber(); - b_CSC_Seg_layer = cId.layer(); - - b_nCSCSegments++; - t_CSC_seg->Fill(); - } - for (auto ly : ch->layers()) { - CSCDetId lId = ly->id(); - /* CSC rechit */ - auto recRange = csc2DRecHits->get(lId); - auto cscRec = recRange.first; - for (auto rec = cscRec; rec != recRange.second; ++rec) { - auto recLd = rec->localPosition(); - auto gp = ly->toGlobal(recLd); - b_CSC_2DRecHit_eta = gp.eta(); - b_CSC_2DRecHit_phi = gp.phi(); - b_CSC_2DRecHit_station = lId.station(); - b_CSC_2DRecHit_ring = lId.ring(); - b_CSC_2DRecHit_chamber = lId.chamber(); - b_CSC_2DRecHit_layer = lId.layer(); - - b_nCSC2DRecHits++; - t_CSC_rec->Fill(); - } - } - } - for ( auto cscHit : *csc2DRecHits ) { - const auto detId = cscHit.cscDetId(); - auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward - auto ch = std::to_string(detId.chamber()); - auto ring = std::to_string(detId.ring()); - auto station = std::to_string(detId.station()); - auto layer = std::to_string(detId.layer()); - const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; - const int idx = hCSCArea_->GetXaxis()->FindBin(name.c_str()); - hCSCCounts_->Fill(idx); - } - - - - for (auto ch : GEMGeometry_->chambers()) { - /* GEM seg */ - GEMDetId cId = ch->id(); - auto segsRange = gemSegments->get(cId); - auto gemSeg = segsRange.first; - for (auto seg = gemSeg; seg != segsRange.second; ++seg) { - auto segLd = seg->localPosition(); - auto gp = ch->toGlobal(segLd); - b_GEM_Seg_eta = gp.eta(); - b_GEM_Seg_phi = gp.phi(); - b_GEM_Seg_nRecHits = seg->nRecHits(); - b_GEM_Seg_station = cId.station(); - b_GEM_Seg_ring = cId.ring(); - b_GEM_Seg_chamber = cId.chamber(); - b_GEM_Seg_layer = cId.layer(); - - b_nGEMSegments++; - t_GEM_seg->Fill(); - } - for (auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - int roll_ = rId.roll(); - /* GEM digi */ - auto digisRange = gemDigis->get(rId); - auto gemDigi = digisRange.first; - for (auto hit = gemDigi; hit != digisRange.second; ++hit) { - auto strip = hit->strip(); - auto digiLp = roll->centreOfStrip(strip); - auto gp = roll->toGlobal(digiLp); - b_GEM_Digi_eta = gp.eta(); - b_GEM_Digi_phi = gp.phi(); - b_GEM_Digi_etaPartition = roll_; - b_GEM_Digi_bx = hit->bx(); - b_GEM_Digi_chamber = rId.chamber(); - b_GEM_Digi_layer = rId.layer(); - b_GEM_Digi_station = rId.station(); - b_GEM_Digi_ring = rId.ring(); - - t_GEM_digi->Fill(); - b_nGEMDigis++; - } - /* GEM rechit */ - auto recRange = gemRecHits->get(rId); - auto gemRec = recRange.first; - for (auto rec = gemRec; rec != recRange.second; ++rec) { - auto recLd = rec->localPosition(); - auto gp = roll->toGlobal(recLd); - b_GEM_RecHit_eta = gp.eta(); - b_GEM_RecHit_phi = gp.phi(); - b_GEM_RecHit_etaPartition = roll_; - b_GEM_RecHit_bx = rec->BunchX(); - b_GEM_RecHit_chamber = rId.chamber(); - b_GEM_RecHit_layer = rId.layer(); - b_GEM_RecHit_station = rId.station(); - b_GEM_RecHit_ring = rId.ring(); - - b_nGEMRecHits++; - t_GEM_rec->Fill(); - } - } - } - for ( auto gemHit : *gemRecHits ) { - const auto detId = gemHit.gemId(); - auto region = std::to_string(detId.region()); - auto ch = std::to_string(detId.chamber()); - auto iEta = std::to_string(detId.roll()); - auto station = std::to_string(detId.station()); - auto ring = std::to_string(detId.ring()); - auto layer = std::to_string(detId.layer()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; - - const int idx = hGEMArea_->GetXaxis()->FindBin(rollName.c_str()); - hGEMCounts_->Fill(idx); - } - - - - for (auto ch : DTGeometry_->chambers()) { - /* DT seg */ - DTChamberId cId = ch->id(); - //b_DT_4DSeg_chamber = ch->id(); - auto segsRange = dt4DSegments->get(cId); - auto dt4DSeg = segsRange.first; - for (auto seg = dt4DSeg; seg != segsRange.second; ++seg) { - auto segLd = seg->localPosition(); - auto gp = ch->toGlobal(segLd); - b_DT_4DSeg_eta = gp.eta(); - b_DT_4DSeg_phi = gp.phi(); - b_DT_4DSeg_nRecHits = seg->recHits().size(); - b_DT_4DSeg_hasZed = seg->hasZed(); - b_DT_4DSeg_station = cId.station(); - b_DT_4DSeg_sector = cId.sector(); - b_DT_4DSeg_wheel = cId.wheel(); - - b_nDT4DSegments++; - t_DT_seg->Fill(); - } - } - for (auto ly : DTGeometry_->layers()) { - DTLayerId lId = ly->id(); - /* DT digi */ - auto digisRange = dtDigis->get(lId); - auto dtDigi = digisRange.first; - for (auto hit = dtDigi; hit != digisRange.second; ++hit) { - b_DT_Digi_wire = hit->wire(); - b_DT_Digi_station = lId.station(); - b_DT_Digi_sector = lId.sector(); - b_DT_Digi_wheel = lId.wheel(); - b_DT_Digi_layer = lId.layer(); - b_DT_Digi_superLayer = lId.superLayer(); - - t_DT_digi->Fill(); - b_nDTDigis++; - } - /* DT rechit */ - auto recRange = dtRecHits->get(lId); - auto dtRec = recRange.first; - for (auto rec = dtRec; rec != recRange.second; ++rec) { - auto recLd = rec->localPosition(); - auto gp = ly->toGlobal(recLd); - auto wireId = rec->wireId(); - b_DT_RecHit_wire = wireId.wire(); - b_DT_RecHit_eta = gp.eta(); - b_DT_RecHit_phi = gp.phi(); - b_DT_RecHit_station = lId.station(); - b_DT_RecHit_sector = lId.sector(); - b_DT_RecHit_wheel = lId.wheel(); - b_DT_RecHit_layer = lId.layer(); - b_DT_RecHit_superLayer = lId.superLayer(); - - b_nDTRecHits++; - t_DT_rec->Fill(); - } - } - - for (auto ch : RPCGeometry_->chambers()) { - //RPCDetId cId = ch->id(); - //b_RPC_Digi_chamber = cId.chamber(); - //b_RPC_RecHit_chamber = cId.chamber(); - for (auto roll : ch->rolls()) { - RPCDetId rId = roll->id(); - int roll_ = rId.roll(); - /* RPC digi */ - auto digisRange = rpcDigis->get(rId); - auto rpcDigi = digisRange.first; - cout << rId.region() << endl; - for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { - auto strip = hit->strip(); - auto digiLp = roll->centreOfStrip(strip); - auto gp = roll->toGlobal(digiLp); - b_RPC_Digi_eta = gp.eta(); - b_RPC_Digi_phi = gp.phi(); - b_RPC_Digi_roll = roll_; // Roll id (also known as eta partition): each chamber is divided along the strip direction in - two or three parts (rolls) for Barrel and two, three or four parts for endcap - b_RPC_Digi_station = rId.station(); // Station id : For Barrel: the four groups of chambers at same r (distance from beam axis) and increasing phi / For Endcap: the three groups of chambers at same z (distance from interaction point), i.e. the disk - b_RPC_Digi_ring = rId.ring(); // Ring id: Wheel number in Barrel (from -2 to +2) Ring Number in Endcap (from 1 to 3) Ring has a different meaning in Barrel and Endcap! In Barrel it is wheel, in Endcap Ring has a different meaning in - b_RPC_Digi_sector = rId.sector(); // Sector id: the group of chambers at same phi (and increasing r) - b_RPC_Digi_subSector = rId.subsector(); // subSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel, from 1 to 6 in Endcap) - b_RPC_Digi_layer = rId.layer(); // Layer id: each station can have two layers of chambers: layer 1 is the inner chamber and layer 2 is the outer chamber (when present) // Only in Barrel: RB1 and RB2 - b_RPC_Digi_region = rId.region(); // region : 0 for barrel +/-1 for +/- endcap - b_RPC_Digi_isIRPC = (int)roll->isIRPC(); - //cout << b_RPC_Digi_region << " " << rId.region() << endl; - t_RPC_digi->Fill(); - b_nRPCDigis++; - } - /* RPC rechit */ - auto recRange = rpcRecHits->get(rId); - auto rpcRec = recRange.first; - for (auto rec = rpcRec; rec != recRange.second; ++rec) { - auto recLd = rec->localPosition(); - auto gp = roll->toGlobal(recLd); - b_RPC_RecHit_eta = gp.eta(); - b_RPC_RecHit_phi = gp.phi(); - b_RPC_RecHit_roll = roll_; - b_RPC_RecHit_station = rId.station(); - b_RPC_RecHit_ring = rId.ring(); - b_RPC_RecHit_sector = rId.sector(); - b_RPC_RecHit_subSector = rId.subsector(); - b_RPC_RecHit_layer = rId.layer(); - b_RPC_RecHit_region = rId.region(); - b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); - - b_nRPCRecHits++; - t_RPC_rec->Fill(); - } - } - } - for ( auto rpcHit : *rpcRecHits ) { - const auto detId = rpcHit.rawId(); - const string rollName = RPCGeomServ(detId).name(); - - const int idx = hRPCArea_->GetXaxis()->FindBin(rollName.c_str()); - hRPCCounts_->Fill(idx); - } - - - /* gen Muon */ - for (TrackingParticleCollection::size_type i=0; isize(); i++) { - TrackingParticleRef simRef(simHandle, i); - const TrackingParticle* simTP = simRef.get(); - b_genMuon_pt = simTP->pt(); - b_genMuon_eta = simTP->eta(); - b_genMuon_phi = simTP->phi(); - bool isSignalMuon = abs(simTP->pdgId())==13 && !simTP->genParticles().empty() && (simTP->eventId().event() == 0) && (simTP->eventId().bunchCrossing() == 0); - if (!isSignalMuon) continue; - t_genMuon->Fill(); - } - /* reco Muon */ - for(size_t i = 0; i < muonHandle->size(); ++i) { - initMuonValue(); - edm::RefToBase muRef = muonHandle->refAt(i); - const reco::Muon* mu = muRef.get(); - b_muon_isTight = muon::isTightMuon(*mu, pv0); - b_muon_isMedium = muon::isMediumMuon(*mu); - b_muon_isLoose = muon::isLooseMuon(*mu); - b_muon_pt = mu->pt(); - b_muon_eta = mu->eta(); - b_muon_phi = mu->phi(); - b_muon_isGlobalMuon = mu->isGlobalMuon(); - b_muon_isTrackerMuon = mu->isTrackerMuon(); - b_muon_isME0Muon = mu->isME0Muon(); - b_muon_nMatchedStationLayer = mu->numberOfMatchedStations(); - t_Muon->Fill(); - } - - - /*L1 trigger*/ - - t_event->Fill(); -} - -void HGCalSimTest::beginJob(){} -void HGCalSimTest::endJob(){} - -void HGCalSimTest::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){//(Run const& run, EventSetup const&){ - - hEvents_ = fs->make("hEvents", "hEvents;Types;Number of Events", 1, 1, 2); - - hME0Area_ = fs->make("hME0Area", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); - hME0Counts_ = fs->make("hME0Counts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); - - hGEMArea_ = fs->make("hGEMArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); - hGEMCounts_ = fs->make("hGEMCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); - - hCSCArea_ = fs->make("hCSCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); - hCSCCounts_ = fs->make("hCSCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); - - hRPCArea_ = fs->make("hRPCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); - hRPCCounts_ = fs->make("hRPCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); - - - edm::ESHandle me0Geom; - iSetup.get().get(me0Geom); - - edm::ESHandle gemGeom; - iSetup.get().get(gemGeom); - - edm::ESHandle cscGeom; - iSetup.get().get(cscGeom); - - edm::ESHandle rpcGeom; - iSetup.get().get(rpcGeom); - -/* - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - const float pitch(roll->pitch()); - - } - } - - for (auto ch : CSCGeometry_->chambers()) { - for (auto layer : ch->layers()) { - CSCDetId lId = layer->id(); - const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); - const float striplength(top_->stripLength()); - const float pitch(layer->geometry()->stripPitch()); - b_cscArea = striplength * pitch * top_->nstrips(); - } - } -*/ - - /* ME0 */ - int iME0 = 0; - for ( auto roll : me0Geom->etaPartitions() ) { - ++iME0; - const auto detId = roll->id(); - auto region = std::to_string(detId.region()); - auto ch = std::to_string(detId.chamber()); - auto iEta = std::to_string(detId.roll()); - auto station = std::to_string(detId.station()); // for now, always 1 - auto ring = std::to_string(0);//std::to_string(detId.ring()); - auto layer = std::to_string(detId.layer()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - const float pitch(roll->pitch()); - auto nstrip = top_->nstrips(); -// std::cout << " ME0 : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; - hME0Area_->GetXaxis()->SetBinLabel(iME0, rollName.c_str()); - hME0Area_->Fill(iME0, striplength*pitch*nstrip); - } - - /* GEM */ - int iGEM = 0; - for ( auto roll : gemGeom->etaPartitions() ) { - ++iGEM; - const auto detId = roll->id(); - auto region = std::to_string(detId.region()); - auto ch = std::to_string(detId.chamber()); - auto iEta = std::to_string(detId.roll()); - auto station = std::to_string(detId.station()); - auto ring = std::to_string(detId.ring()); - auto layer = std::to_string(detId.layer()); - const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - const float pitch(roll->pitch()); - auto nstrip = top_->nstrips(); -// std::cout << " GEM : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; - hGEMArea_->GetXaxis()->SetBinLabel(iGEM, rollName.c_str()); - hGEMArea_->Fill(iGEM, striplength*pitch*nstrip); - } - - /* CSC */ - int iCSC = 0; - for (auto ly : cscGeom->layers()) { - ++iCSC; - auto detId = ly->id(); - auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward - auto ch = std::to_string(detId.chamber()); - auto ring = std::to_string(detId.ring()); - auto station = std::to_string(detId.station()); - auto layer = std::to_string(detId.layer()); - const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; - const RadialStripTopology* top_(dynamic_cast(&(ly->topology()))); - const float striplength(top_->stripLength()); - const float pitch(ly->geometry()->stripPitch()); - const float nstrip = top_->nstrips(); - //std::cout << " CSC : " << name << " / area : " << striplength*pitch*nstrip << std::endl; - hCSCArea_->GetXaxis()->SetBinLabel(iCSC, name.c_str()); - hCSCArea_->Fill(iCSC, striplength*pitch*nstrip); - } - - /* RPC */ - int iRPC = 0; - for ( const RPCRoll* roll : rpcGeom->rolls() ) { - ++iRPC; - const auto detId = roll->id(); - const string rollName = RPCGeomServ(detId).name(); - const double width = roll->surface().bounds().width(); - const double height = roll->surface().bounds().length(); - //std::cout << " RPC : " << rollName.c_str() << " / area : " << width*height << std::endl; - hRPCArea_->GetXaxis()->SetBinLabel(iRPC, rollName.c_str()); - hRPCArea_->Fill(iRPC, width*height); - } - -} -void HGCalSimTest::endRun(Run const&, EventSetup const&){} - -void HGCalSimTest::initMuonValue() { - b_genMuon_pt = -9; b_genMuon_eta = -9; b_genMuon_phi = -9; - - b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; b_muon_isTrackerMuon = -1; b_muon_isGlobalMuon = -1; b_muon_isME0Muon = -1; - b_muon_pt = -9; b_muon_eta = -9; b_muon_phi = -9; - b_muon_nMatchedStationLayer = -9; - -} -void HGCalSimTest::initValue() { - b_nME0Digis = 0; b_nME0Segments = 0; b_nME0RecHits = 0; - b_nCSCSegments = 0; b_nCSC2DRecHits = 0; - b_nGEMDigis = 0; b_nGEMSegments = 0; b_nGEMRecHits = 0; - b_nDTDigis = 0; b_nDT4DSegments = 0; b_nDTRecHits = 0; - b_nRPCDigis = 0; b_nRPCRecHits = 0; - - /*ME0 digi*/ - b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; b_ME0_Digi_bx = -999; - b_ME0_Digi_eta = -9; b_ME0_Digi_phi = -9; - /*ME0 seg*/ - b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; - b_ME0_Seg_eta = -9; b_ME0_Seg_phi = -9; - /*ME0 rechit*/ - b_ME0_RecHit_etaPartition = -9; - b_ME0_RecHit_eta = -9; b_ME0_RecHit_phi = -9; - - /*CSC seg*/ - b_CSC_Seg_chamber = -9; b_CSC_Seg_layer = -9; b_CSC_Seg_station = -9; b_CSC_Seg_ring = -9; b_CSC_Seg_nRecHits = -9; - b_CSC_Seg_eta = -9; b_CSC_Seg_phi = -9; - /*CSC rechit*/ - b_CSC_2DRecHit_chamber = -9; b_CSC_2DRecHit_layer = -9; b_CSC_2DRecHit_station = -9; b_CSC_2DRecHit_ring = -9; b_CSC_2DRecHit_etaPartition = -9; - b_CSC_2DRecHit_eta = -9; b_CSC_2DRecHit_phi = -9; - - /*GEM digi*/ - b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_etaPartition = -9; b_GEM_Digi_bx = -999; - b_GEM_Digi_eta = -9; b_GEM_Digi_phi = -9; - /*GEM seg*/ - b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_nRecHits = -9; - b_GEM_Seg_eta = -9; b_GEM_Seg_phi = -9; - /*GEM rechit*/ - b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_etaPartition = -9; b_GEM_RecHit_bx = -999; - b_GEM_RecHit_eta = -9; b_GEM_RecHit_phi = -9;; - - /* DT digi*/ - b_DT_Digi_chamber = -9; b_DT_Digi_layer = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_wheel = -9; b_DT_Digi_sector = -9; b_DT_Digi_station = -9; b_DT_Digi_wire = -9; - b_DT_Digi_eta = -9; //b_DT_Digi_phi = -9; - /* DT seg*/ - b_DT_4DSeg_chamber = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_nRecHits = -9; - b_DT_4DSeg_eta = -9; b_DT_4DSeg_phi = -9; - b_DT_4DSeg_hasZed = -1; - /* DT rechit*/ - b_DT_RecHit_chamber = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_wire = -9; - b_DT_RecHit_eta = -9; - - /*RPC digi*/ - b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_roll = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; b_RPC_Digi_region = -9; - b_RPC_Digi_eta = -9; b_RPC_Digi_phi = -9; - b_RPC_Digi_isIRPC = -1; - /*RPC rechit*/ - b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_roll = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; b_RPC_RecHit_region = -9; - b_RPC_RecHit_eta = -9; b_RPC_RecHit_phi = -9; - b_RPC_RecHit_isIRPC = -1; - -} - -//define this as a plug-in -DEFINE_FWK_MODULE(HGCalSimTest); diff --git a/MuonAnalyser/plugins/MuonDetHitAnalyser.cc b/MuonAnalyser/plugins/MuonDetHitAnalyser.cc new file mode 100644 index 00000000000..b6dfae3c1fb --- /dev/null +++ b/MuonAnalyser/plugins/MuonDetHitAnalyser.cc @@ -0,0 +1,769 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +// ME0 +#include "DataFormats/GEMDigi/interface/ME0DigiCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" +// GEM +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +// CSC +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +// DT +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +//#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/MuonDetId/interface/DTBtiId.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "DataFormats/MuonDetId/interface/DTLayerId.h" +#include "DataFormats/MuonDetId/interface/DTSectCollId.h" +#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "DataFormats/MuonDetId/interface/DTTracoId.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +// RPC +#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +// Muon +#include "DataFormats/PatCandidates/interface/Muon.h" +// L1 +#include "DataFormats/L1TMuon/interface/L1MuBMTrack.h" + +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" + +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/Associations/interface/MuonToTrackingParticleAssociator.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" +#include "SimMuon/MCTruth/interface/MuonToSimAssociatorByHits.h" +#include "SimTracker/Common/interface/TrackingParticleSelector.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" + +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class MuonDetHitAnalyser : public edm::EDAnalyzer { +public: + explicit MuonDetHitAnalyser(const edm::ParameterSet&); + ~MuonDetHitAnalyser(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + void initValue(); + + TProfile* hME0Area_; + TH1D* hME0Counts_; + + TProfile* hGEMArea_; + TH1D* hGEMCounts_; + + TProfile* hCSCArea_; + TH1D* hCSCCounts_; + + TProfile* hRPCArea_; + TH1D* hRPCCounts_; + + TH1D* hEvents_; + + // ----------member data --------------------------- + edm::EDGetTokenT me0Digis_; + edm::EDGetTokenT me0RecHits_; + + edm::EDGetTokenT csc2DRecHits_; + + edm::EDGetTokenT gemDigis_; + edm::EDGetTokenT gemRecHits_; + + edm::EDGetTokenT dtDigis_; + edm::EDGetTokenT dtRecHits_; + + edm::EDGetTokenT rpcDigis_; + edm::EDGetTokenT rpcRecHits_; + + edm::Service fs; + + TTree *t_event; + int b_run, b_lumi, b_latency; + int b_nME0Digis, b_nME0Segments, b_nME0RecHits, b_nCSCSegments, b_nCSC2DRecHits, b_nGEMDigis, b_nGEMSegments, b_nGEMRecHits, b_nDTDigis, b_nDT4DSegments, b_nDTRecHits, b_nRPCDigis, b_nRPCRecHits; + + /* ME0 */ + TTree *t_ME0_digi; + int b_ME0_Digi_region, b_ME0_Digi_chamber, b_ME0_Digi_layer, b_ME0_Digi_etaPartition, b_ME0_Digi_bx; + float b_ME0_Digi_eta, b_ME0_Digi_phi; + TTree *t_ME0_rec; + int b_ME0_RecHit_region, b_ME0_RecHit_chamber, b_ME0_RecHit_layer, b_ME0_RecHit_etaPartition; + float b_ME0_RecHit_eta, b_ME0_RecHit_phi; + + /* CSC */ + TTree *t_CSC_rec; + int b_CSC_2DRecHit_region, b_CSC_2DRecHit_station, b_CSC_2DRecHit_ring, b_CSC_2DRecHit_chamber, b_CSC_2DRecHit_layer; + float b_CSC_2DRecHit_eta, b_CSC_2DRecHit_phi; + + /* GEM */ + TTree *t_GEM_digi; + int b_GEM_Digi_region, b_GEM_Digi_station, b_GEM_Digi_ring, b_GEM_Digi_chamber, b_GEM_Digi_layer, b_GEM_Digi_etaPartition, b_GEM_Digi_bx; + float b_GEM_Digi_eta, b_GEM_Digi_phi; + TTree *t_GEM_rec; + int b_GEM_RecHit_region, b_GEM_RecHit_station, b_GEM_RecHit_ring, b_GEM_RecHit_chamber, b_GEM_RecHit_layer, b_GEM_RecHit_etaPartition, b_GEM_RecHit_bx; + float b_GEM_RecHit_eta, b_GEM_RecHit_phi; + + /* DT */ + TTree *t_DT_digi; + int b_DT_Digi_sector, b_DT_Digi_station, b_DT_Digi_wheel, b_DT_Digi_chamber, b_DT_Digi_superLayer, b_DT_Digi_layer, b_DT_Digi_wire; + float b_DT_Digi_eta, b_DT_Digi_phi; + TTree *t_DT_rec; + int b_DT_RecHit_sector, b_DT_RecHit_station, b_DT_RecHit_wheel, b_DT_RecHit_chamber, b_DT_RecHit_superLayer, b_DT_RecHit_layer, b_DT_RecHit_wire; + float b_DT_RecHit_eta, b_DT_RecHit_phi; + + /* RPC */ + TTree *t_RPC_digi; + int b_RPC_Digi_region, b_RPC_Digi_sector, b_RPC_Digi_subSector, b_RPC_Digi_station, b_RPC_Digi_ring, b_RPC_Digi_chamber, b_RPC_Digi_layer, b_RPC_Digi_roll, b_RPC_Digi_isIRPC; + float b_RPC_Digi_eta, b_RPC_Digi_phi; + TTree *t_RPC_rec; + int b_RPC_RecHit_region, b_RPC_RecHit_sector, b_RPC_RecHit_subSector, b_RPC_RecHit_station, b_RPC_RecHit_ring, b_RPC_RecHit_chamber, b_RPC_RecHit_layer, b_RPC_RecHit_roll, b_RPC_RecHit_isIRPC; + float b_RPC_RecHit_eta, b_RPC_RecHit_phi; +}; + +MuonDetHitAnalyser::MuonDetHitAnalyser(const edm::ParameterSet& iConfig) +{ + me0Digis_ = consumes(iConfig.getParameter("me0Digis")); + me0RecHits_ = consumes(iConfig.getParameter("me0RecHits")); + + csc2DRecHits_ = consumes(iConfig.getParameter("csc2DRecHits")); + + gemDigis_ = consumes(iConfig.getParameter("gemDigis")); + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + + dtDigis_ = consumes(iConfig.getParameter("dtDigis")); + dtRecHits_ = consumes(iConfig.getParameter("dtRecHits")); + + rpcDigis_ = consumes(iConfig.getParameter("rpcDigis")); + rpcRecHits_ = consumes(iConfig.getParameter("rpcRecHits")); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nME0Digis", &b_nME0Digis, "nME0Digis/I"); + t_event->Branch("nME0RecHits", &b_nME0RecHits, "nME0RecHits/I"); + t_event->Branch("nCSC2DRecHits", &b_nCSC2DRecHits, "nCSC2DRecHits/I"); + t_event->Branch("nGEMDigis", &b_nGEMDigis, "nGEMDigis/I"); + t_event->Branch("nGEMRecHits", &b_nGEMRecHits, "nGEMRecHits/I"); + t_event->Branch("nDTDigis", &b_nDTDigis, "nDTDigis/I"); + t_event->Branch("nDTRecHits", &b_nDTRecHits, "nDTRecHits/I"); + t_event->Branch("nRPCDigis", &b_nRPCDigis, "nRPCDigis/I"); + t_event->Branch("nRPCRecHits", &b_nRPCRecHits, "nRPCRecHits/I"); + + /*ME0*/ + t_ME0_digi = fs->make("ME0_Hit", "ME0_Hit"); + t_ME0_digi->Branch("Digi_eta", &b_ME0_Digi_eta, "Digi_eta/F"); + t_ME0_digi->Branch("Digi_phi", &b_ME0_Digi_phi, "Digi_phi/F"); + t_ME0_digi->Branch("Digi_bx", &b_ME0_Digi_bx, "Digi_bx/I"); + t_ME0_digi->Branch("Digi_region", &b_ME0_Digi_region, "Digi_region/I"); + t_ME0_digi->Branch("Digi_chamber", &b_ME0_Digi_chamber, "Digi_chamber/I"); + t_ME0_digi->Branch("Digi_layer", &b_ME0_Digi_layer, "Digi_layer/I"); + t_ME0_digi->Branch("Digi_etaPartition", &b_ME0_Digi_etaPartition, "Digi_etaPartition/I"); + + t_ME0_rec = fs->make("ME0_RecHit", "ME0_RecHit"); + t_ME0_rec->Branch("RecHit_eta", &b_ME0_RecHit_eta, "RecHit_eta/F"); + t_ME0_rec->Branch("RecHit_phi", &b_ME0_RecHit_phi, "RecHit_phi/F"); + t_ME0_rec->Branch("RecHit_region", &b_ME0_RecHit_region, "RecHit_region/I"); + t_ME0_rec->Branch("RecHit_chamber", &b_ME0_RecHit_chamber, "RecHit_chaber/I"); + t_ME0_rec->Branch("RecHit_layer", &b_ME0_RecHit_layer, "RecHit_layer/I"); + t_ME0_rec->Branch("RecHit_etaPartition", &b_ME0_RecHit_etaPartition, "RecHit_etaParition/I"); + + /*CSC*/ + t_CSC_rec = fs->make("CSC_2DRecHit", "CSC_2DRecHit"); + t_CSC_rec->Branch("RecHit_eta", &b_CSC_2DRecHit_eta, "RecHit_eta/F"); + t_CSC_rec->Branch("RecHit_phi", &b_CSC_2DRecHit_phi, "RecHit_phi/F"); + t_CSC_rec->Branch("RecHit_region", &b_CSC_2DRecHit_region, "RecHit_region/I"); + t_CSC_rec->Branch("RecHit_station", &b_CSC_2DRecHit_station, "RecHit_station/I"); + t_CSC_rec->Branch("RecHit_ring", &b_CSC_2DRecHit_ring, "RecHit_ring/I"); + t_CSC_rec->Branch("RecHit_chamber", &b_CSC_2DRecHit_chamber, "RecHit_chaber/I"); + t_CSC_rec->Branch("RecHit_layer", &b_CSC_2DRecHit_layer, "RecHit_layer/I"); + + /*GEM*/ + t_GEM_digi = fs->make("GEM_Hit", "GEM_Hit"); + t_GEM_digi->Branch("Digi_eta", &b_GEM_Digi_eta, "Digi_eta/F"); + t_GEM_digi->Branch("Digi_phi", &b_GEM_Digi_phi, "Digi_phi/F"); + t_GEM_digi->Branch("Digi_bx", &b_GEM_Digi_bx, "Digi_bx/I"); + t_GEM_digi->Branch("Digi_region", &b_GEM_Digi_region, "Digi_region/I"); + t_GEM_digi->Branch("Digi_station", &b_GEM_Digi_station, "Digi_station/I"); + t_GEM_digi->Branch("Digi_ring", &b_GEM_Digi_ring, "Digi_ring/I"); + t_GEM_digi->Branch("Digi_chamber", &b_GEM_Digi_chamber, "Digi_chamber/I"); + t_GEM_digi->Branch("Digi_layer", &b_GEM_Digi_layer, "Digi_layer/I"); + t_GEM_digi->Branch("Digi_etaPartition", &b_GEM_Digi_etaPartition, "Digi_etaPartition/I"); + + t_GEM_rec = fs->make("GEM_RecHit", "GEM_RecHit"); + t_GEM_rec->Branch("RecHit_eta", &b_GEM_RecHit_eta, "RecHit_eta/F"); + t_GEM_rec->Branch("RecHit_phi", &b_GEM_RecHit_phi, "RecHit_phi/F"); + t_GEM_rec->Branch("RecHit_bx", &b_GEM_RecHit_bx, "RecHit_bx/I"); + t_GEM_rec->Branch("RecHit_region", &b_GEM_RecHit_region, "RecHit_region/I"); + t_GEM_rec->Branch("RecHit_station", &b_GEM_RecHit_station, "RecHit_station/I"); + t_GEM_rec->Branch("RecHit_ring", &b_GEM_RecHit_ring, "RecHit_ring/I"); + t_GEM_rec->Branch("RecHit_chamber", &b_GEM_RecHit_chamber, "RecHit_chaber/I"); + t_GEM_rec->Branch("RecHit_layer", &b_GEM_RecHit_layer, "RecHit_layer/I"); + t_GEM_rec->Branch("RecHit_etaPartition", &b_GEM_RecHit_etaPartition, "RecHit_etaParition/I"); + + /*DT*/ + t_DT_digi = fs->make("DT_Hit", "DT_Hit"); + t_DT_digi->Branch("Digi_eta", &b_DT_Digi_eta, "Digi_eta/F"); + t_DT_digi->Branch("Digi_phi", &b_DT_Digi_phi, "Digi_phi/F"); + t_DT_digi->Branch("Digi_sector", &b_DT_Digi_sector, "Digi_sector/I"); + t_DT_digi->Branch("Digi_station", &b_DT_Digi_station, "Digi_station/I"); + t_DT_digi->Branch("Digi_wheel", &b_DT_Digi_wheel, "Digi_wheel/I"); + t_DT_digi->Branch("Digi_chamber", &b_DT_Digi_chamber, "Digi_chamber/I"); + t_DT_digi->Branch("Digi_superLayer", &b_DT_Digi_superLayer, "Digi_superLayer/I"); + t_DT_digi->Branch("Digi_layer", &b_DT_Digi_layer, "Digi_layer/I"); + t_DT_digi->Branch("Digi_wire", &b_DT_Digi_wire, "Digi_wire/I"); + + t_DT_rec = fs->make("DT_RecHit", "DT_RecHit"); + t_DT_rec->Branch("RecHit_eta", &b_DT_RecHit_eta, "RecHit_eta/F"); + t_DT_rec->Branch("RecHit_phi", &b_DT_RecHit_phi, "RecHit_phi/F"); + t_DT_rec->Branch("RecHit_sector", &b_DT_RecHit_sector, "RecHit_sector/I"); + t_DT_rec->Branch("RecHit_station", &b_DT_RecHit_station, "RecHit_station/I"); + t_DT_rec->Branch("RecHit_wheel", &b_DT_RecHit_wheel, "RecHit_wheel/I"); + t_DT_rec->Branch("RecHit_chamber", &b_DT_RecHit_chamber, "RecHit_chaber/I"); + t_DT_rec->Branch("RecHit_superLayer", &b_DT_RecHit_superLayer, "RecHit_superLayer/I"); + t_DT_rec->Branch("RecHit_layer", &b_DT_RecHit_layer, "RecHit_layer/I"); + t_DT_rec->Branch("RecHit_wire", &b_DT_RecHit_wire, "RecHit_wire/I"); + + /*RPC*/ + t_RPC_digi = fs->make("RPC_Hit", "RPC_Hit"); + t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); + t_RPC_digi->Branch("Digi_phi", &b_RPC_Digi_phi, "Digi_phi/F"); + t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); + t_RPC_digi->Branch("Digi_region", &b_RPC_Digi_region, "Digi_region/I"); + t_RPC_digi->Branch("Digi_sector", &b_RPC_Digi_sector, "Digi_sector/I"); + t_RPC_digi->Branch("Digi_subSector", &b_RPC_Digi_subSector, "Digi_subSector/I"); + t_RPC_digi->Branch("Digi_station", &b_RPC_Digi_station, "Digi_station/I"); + t_RPC_digi->Branch("Digi_ring", &b_RPC_Digi_ring, "Digi_ring/I"); + t_RPC_digi->Branch("Digi_chamber", &b_RPC_Digi_chamber, "Digi_chamber/I"); + t_RPC_digi->Branch("Digi_layer", &b_RPC_Digi_layer, "Digi_layer/I"); + t_RPC_digi->Branch("Digi_roll", &b_RPC_Digi_roll, "Digi_roll/I"); + t_RPC_digi->Branch("Digi_isIRPC", &b_RPC_Digi_isIRPC, "Digi_isIRPC/I"); + t_RPC_digi->Branch("Digi_eta", &b_RPC_Digi_eta, "Digi_eta/F"); + t_RPC_digi->Branch("Digi_phi", &b_RPC_Digi_phi, "Digi_phi/F"); + + t_RPC_rec = fs->make("RPC_RecHit", "RPC_RecHit"); + t_RPC_rec->Branch("RecHit_eta", &b_RPC_RecHit_eta, "RecHit_eta/F"); + t_RPC_rec->Branch("RecHit_phi", &b_RPC_RecHit_phi, "RecHit_phi/F"); + t_RPC_rec->Branch("RecHit_isIRPC", &b_RPC_RecHit_isIRPC, "RecHit_isIRPC/I"); + t_RPC_rec->Branch("RecHit_region", &b_RPC_RecHit_region, "RecHit_region/I"); + t_RPC_rec->Branch("RecHit_sector", &b_RPC_RecHit_sector, "RecHit_sector/I"); + t_RPC_rec->Branch("RecHit_subSector", &b_RPC_RecHit_subSector, "RecHit_subSector/I"); + t_RPC_rec->Branch("RecHit_station", &b_RPC_RecHit_station, "RecHit_station/I"); + t_RPC_rec->Branch("RecHit_ring", &b_RPC_RecHit_ring, "RecHit_ring/I"); + t_RPC_rec->Branch("RecHit_chamber", &b_RPC_RecHit_chamber, "RecHit_chaber/I"); + t_RPC_rec->Branch("RecHit_layer", &b_RPC_RecHit_layer, "RecHit_layer/I"); + t_RPC_rec->Branch("RecHit_roll", &b_RPC_RecHit_roll, "RecHit_roll/I"); +} + +MuonDetHitAnalyser::~MuonDetHitAnalyser() +{ +} + +void +MuonDetHitAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle hME0Geom; + iSetup.get().get(hME0Geom); + const ME0Geometry* ME0Geometry_ = &*hME0Geom; + + /* ME0 Geometry */ + edm::Handle me0Digis; + iEvent.getByToken(me0Digis_, me0Digis); + + edm::Handle me0RecHits; + iEvent.getByToken(me0RecHits_, me0RecHits); + + /* CSC Geometry */ + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + edm::Handle csc2DRecHits; + iEvent.getByToken(csc2DRecHits_, csc2DRecHits); + + /* GEM Geometry */ + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::Handle gemDigis; + iEvent.getByToken(gemDigis_, gemDigis); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + /* DT Geometry */ + edm::ESHandle hDTGeom; + iSetup.get().get(hDTGeom); + const DTGeometry* DTGeometry_ = &*hDTGeom; + + edm::Handle dtDigis; + iEvent.getByToken(dtDigis_, dtDigis); + + edm::Handle dtRecHits; + iEvent.getByToken(dtRecHits_, dtRecHits); + + /* RPC Geometry */ + edm::ESHandle hRPCGeom; + iSetup.get().get(hRPCGeom); + const RPCGeometry* RPCGeometry_ = &*hRPCGeom; + + edm::Handle rpcDigis; + iEvent.getByToken(rpcDigis_, rpcDigis); + + edm::Handle rpcRecHits; + iEvent.getByToken(rpcRecHits_, rpcRecHits); + + initValue(); + + hEvents_->Fill(1); + + /* ME0 */ + for (auto roll : ME0Geometry_->etaPartitions()) { + ME0DetId rId = roll->id(); + // ME0 digi + auto digisRange = me0Digis->get(rId); + auto me0Digi = digisRange.first; + for (auto hit = me0Digi; hit != digisRange.second; ++hit) { + auto strip = hit->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_ME0_Digi_eta = gp.eta(); + b_ME0_Digi_phi = gp.phi(); + b_ME0_Digi_bx = hit->bx(); + b_ME0_Digi_region = rId.region(); // Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap + b_ME0_Digi_chamber = rId.chamber(); + b_ME0_Digi_layer = rId.layer(); + b_ME0_Digi_etaPartition = rId.roll(); + t_ME0_digi->Fill(); + b_nME0Digis++; + } + // ME0 RecHit + auto recRange = me0RecHits->get(rId); + auto me0Rec = recRange.first; + for (auto rec = me0Rec; rec != recRange.second; ++rec) { + auto recLd = rec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_ME0_RecHit_eta = gp.eta(); + b_ME0_RecHit_phi = gp.phi(); + b_ME0_RecHit_region = rId.region(); + b_ME0_RecHit_chamber = rId.chamber(); + b_ME0_RecHit_layer = rId.layer(); + b_ME0_RecHit_etaPartition = rId.roll(); + b_nME0RecHits++; + t_ME0_rec->Fill(); + } + } + for ( auto me0Hit : *me0RecHits ) { + const auto detId = me0Hit.me0Id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(0);//std::to_string(detId.ring()); + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; + const int idx = hME0Area_->GetXaxis()->FindBin(rollName.c_str()); + hME0Counts_->Fill(idx); + } + + /* CSC */ + for (auto ly : CSCGeometry_->layers()) { + CSCDetId lId = ly->id(); + // CSC rechit + auto recRange = csc2DRecHits->get(lId); + auto cscRec = recRange.first; + for (auto rec = cscRec; rec != recRange.second; ++rec) { + auto recLd = rec->localPosition(); + auto gp = ly->toGlobal(recLd); + b_CSC_2DRecHit_eta = gp.eta(); + b_CSC_2DRecHit_phi = gp.phi(); + b_CSC_2DRecHit_region = lId.endcap(); + b_CSC_2DRecHit_station = lId.station(); + b_CSC_2DRecHit_ring = lId.ring(); + b_CSC_2DRecHit_chamber = lId.chamber(); + b_CSC_2DRecHit_layer = lId.layer(); + b_nCSC2DRecHits++; + t_CSC_rec->Fill(); + } + } + for ( auto cscHit : *csc2DRecHits ) { + const auto detId = cscHit.cscDetId(); + auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward + auto ch = std::to_string(detId.chamber()); + auto ring = std::to_string(detId.ring()); + auto station = std::to_string(detId.station()); + auto layer = std::to_string(detId.layer()); + const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; + const int idx = hCSCArea_->GetXaxis()->FindBin(name.c_str()); + hCSCCounts_->Fill(idx); + } + + + /* GEM */ + for (auto roll : GEMGeometry_->etaPartitions()) { + GEMDetId rId = roll->id(); + // GEM digi + auto digisRange = gemDigis->get(rId); + auto gemDigi = digisRange.first; + for (auto hit = gemDigi; hit != digisRange.second; ++hit) { + auto strip = hit->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_GEM_Digi_eta = gp.eta(); + b_GEM_Digi_phi = gp.phi(); + b_GEM_Digi_bx = hit->bx(); + b_GEM_Digi_region = rId.region(); + b_GEM_Digi_station = rId.station(); + b_GEM_Digi_ring = rId.ring(); + b_GEM_Digi_chamber = rId.chamber(); + b_GEM_Digi_layer = rId.layer(); + b_GEM_Digi_etaPartition = rId.roll(); + t_GEM_digi->Fill(); + b_nGEMDigis++; + } + // GEM rechit + auto recRange = gemRecHits->get(rId); + auto gemRec = recRange.first; + for (auto rec = gemRec; rec != recRange.second; ++rec) { + auto recLd = rec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_GEM_RecHit_eta = gp.eta(); + b_GEM_RecHit_phi = gp.phi(); + b_GEM_RecHit_bx = rec->BunchX(); + b_GEM_RecHit_region = rId.region(); + b_GEM_RecHit_station = rId.station(); + b_GEM_RecHit_ring = rId.ring(); + b_GEM_RecHit_chamber = rId.chamber(); + b_GEM_RecHit_layer = rId.layer(); + b_GEM_RecHit_etaPartition = rId.roll(); + b_nGEMRecHits++; + t_GEM_rec->Fill(); + } + } + for ( auto gemHit : *gemRecHits ) { + const auto detId = gemHit.gemId(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(detId.ring()); + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; + + const int idx = hGEMArea_->GetXaxis()->FindBin(rollName.c_str()); + hGEMCounts_->Fill(idx); + } + + /* DT */ + for (auto ly : DTGeometry_->layers()) { + DTLayerId lId = ly->id(); + //auto ch = ly->chamber(); + //DTChamberId cId = ch->id(); + // DT digi + auto digisRange = dtDigis->get(lId); + auto dtDigi = digisRange.first; + for (auto hit = dtDigi; hit != digisRange.second; ++hit) { + b_DT_Digi_sector = lId.sector(); + b_DT_Digi_station = lId.station(); + b_DT_Digi_wheel = lId.wheel(); + //b_DT_Digi_chamber = cId.chamber(); + b_DT_Digi_superLayer = lId.superLayer(); /// Superlayers are numbered 1 (phi), 2 (Z), 3 (phi) + b_DT_Digi_layer = lId.layer(); + b_DT_Digi_wire = hit->wire(); + t_DT_digi->Fill(); + b_nDTDigis++; + } + // DT rechit + auto recRange = dtRecHits->get(lId); + auto dtRec = recRange.first; + for (auto rec = dtRec; rec != recRange.second; ++rec) { + auto recLd = rec->localPosition(); + auto gp = ly->toGlobal(recLd); + auto wireId = rec->wireId(); + b_DT_RecHit_eta = gp.eta(); + b_DT_RecHit_phi = gp.phi(); + b_DT_RecHit_sector = lId.sector(); + b_DT_RecHit_station = lId.station(); + b_DT_RecHit_wheel = lId.wheel(); + //b_DT_RecHit_chamber = cId.chamber() + b_DT_RecHit_superLayer = lId.superLayer(); + b_DT_RecHit_layer = lId.layer(); + b_DT_RecHit_wire = wireId.wire(); + b_nDTRecHits++; + t_DT_rec->Fill(); + } + } + + /* RPC */ + for (auto roll : RPCGeometry_->rolls()) { + RPCDetId rId = roll->id(); + //auto ch = roll->chamber(); + //auto cId = ch->id(); + // RPC digi + auto digisRange = rpcDigis->get(rId); + auto rpcDigi = digisRange.first; + for (auto hit = rpcDigi; hit != digisRange.second; ++hit) { + auto strip = hit->strip(); + auto digiLp = roll->centreOfStrip(strip); + auto gp = roll->toGlobal(digiLp); + b_RPC_Digi_eta = gp.eta(); + b_RPC_Digi_phi = gp.phi(); + b_RPC_Digi_isIRPC = (int)roll->isIRPC(); + b_RPC_Digi_region = rId.region(); // region : 0 for barrel +/-1 for +/- endcap + b_RPC_Digi_sector = rId.sector(); // Sector id: the group of chambers at same phi (and increasing r) + b_RPC_Digi_subSector = rId.subsector(); // subSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel, from 1 to 6 in Endcap) + b_RPC_Digi_station = rId.station(); // Station id : For Barrel: the four groups of chambers at same r (distance from beam axis) and increasing phi / For Endcap: the three groups of chambers at same z (distance from interaction point), i.e. the disk + b_RPC_Digi_ring = rId.ring(); // Ring id: Wheel number in Barrel (from -2 to +2) Ring Number in Endcap (from 1 to 3) Ring has a different meaning in Barrel and Endcap! In Barrel it is wheel, in Endcap Ring has a different meaning in + //b_RPC_Digi_chamber = cId.chamber(); + b_RPC_Digi_layer = rId.layer(); // Layer id: each station can have two layers of chambers: layer 1 is the inner chamber and layer 2 is the outer chamber (when present) // Only in Barrel: RB1 and RB + b_RPC_Digi_roll = rId.roll(); // Roll id (also known as eta partition): each chamber is divided along the strip direction in - two or three parts (rolls) for Barrel and two, three or four parts for endcap + t_RPC_digi->Fill(); + b_nRPCDigis++; + } + // RPC rechit + auto recRange = rpcRecHits->get(rId); + auto rpcRec = recRange.first; + for (auto rec = rpcRec; rec != recRange.second; ++rec) { + auto recLd = rec->localPosition(); + auto gp = roll->toGlobal(recLd); + b_RPC_RecHit_eta = gp.eta(); + b_RPC_RecHit_phi = gp.phi(); + b_RPC_RecHit_isIRPC = (int)roll->isIRPC(); + b_RPC_RecHit_region = rId.region(); + b_RPC_RecHit_sector = rId.sector(); + b_RPC_RecHit_subSector = rId.subsector(); + b_RPC_RecHit_station = rId.station(); + b_RPC_RecHit_ring = rId.ring(); + //b_RPC_RecHit_chamber = cId.chamber(); + b_RPC_RecHit_layer = rId.layer(); + b_RPC_RecHit_roll = rId.roll(); + b_nRPCRecHits++; + t_RPC_rec->Fill(); + } + } + for ( auto rpcHit : *rpcRecHits ) { + const auto detId = rpcHit.rawId(); + const string rollName = RPCGeomServ(detId).name(); + const int idx = hRPCArea_->GetXaxis()->FindBin(rollName.c_str()); + hRPCCounts_->Fill(idx); + } + t_event->Fill(); +} + +void MuonDetHitAnalyser::beginJob(){} +void MuonDetHitAnalyser::endJob(){} + +void MuonDetHitAnalyser::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){//(Run const& run, EventSetup const&){ + + hEvents_ = fs->make("hEvents", "hEvents;Types;Number of Events", 1, 1, 2); + + hME0Area_ = fs->make("hME0Area", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hME0Counts_ = fs->make("hME0Counts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hGEMArea_ = fs->make("hGEMArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hGEMCounts_ = fs->make("hGEMCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hCSCArea_ = fs->make("hCSCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hCSCCounts_ = fs->make("hCSCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + hRPCArea_ = fs->make("hRPCArea", "Roll area;Roll Name;Area [cm^{2}]", 5000, 1, 5001, 0, 100000); + hRPCCounts_ = fs->make("hRPCCounts", "Counts;Roll Index;Number of RecHits", 5000, 1, 5001); + + + edm::ESHandle me0Geom; + iSetup.get().get(me0Geom); + + edm::ESHandle gemGeom; + iSetup.get().get(gemGeom); + + edm::ESHandle cscGeom; + iSetup.get().get(cscGeom); + + edm::ESHandle rpcGeom; + iSetup.get().get(rpcGeom); + + /* ME0 */ + int iME0 = 0; + for ( auto roll : me0Geom->etaPartitions() ) { + ++iME0; + const auto detId = roll->id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); // for now, always 1 + auto ring = std::to_string(0);//std::to_string(detId.ring()); + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + auto nstrip = top_->nstrips(); +// std::cout << " ME0 : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; + hME0Area_->GetXaxis()->SetBinLabel(iME0, rollName.c_str()); + hME0Area_->Fill(iME0, striplength*pitch*nstrip); + } + + /* GEM */ + int iGEM = 0; + for ( auto roll : gemGeom->etaPartitions() ) { + ++iGEM; + const auto detId = roll->id(); + auto region = std::to_string(detId.region()); + auto ch = std::to_string(detId.chamber()); + auto iEta = std::to_string(detId.roll()); + auto station = std::to_string(detId.station()); + auto ring = std::to_string(detId.ring()); + auto layer = std::to_string(detId.layer()); + const string rollName = "Region_"+region+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer+"_iEta_"+iEta; + const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); + const float striplength(top_->stripLength()); + const float pitch(roll->pitch()); + auto nstrip = top_->nstrips(); +// std::cout << " GEM : " << rollName.c_str() << " / area : " << striplength*pitch*nstrip << std::endl; + hGEMArea_->GetXaxis()->SetBinLabel(iGEM, rollName.c_str()); + hGEMArea_->Fill(iGEM, striplength*pitch*nstrip); + } + + /* CSC */ + int iCSC = 0; + for (auto ly : cscGeom->layers()) { + ++iCSC; + auto detId = ly->id(); + auto endcap = std::to_string(detId.endcap()); // +1 : forward , -1 : backward + auto ch = std::to_string(detId.chamber()); + auto ring = std::to_string(detId.ring()); + auto station = std::to_string(detId.station()); + auto layer = std::to_string(detId.layer()); + const string name = "Endcap_"+endcap+"_station_"+station+"_ring_"+ring+"_CH_"+ch+"_layer_"+layer; + const RadialStripTopology* top_(dynamic_cast(&(ly->topology()))); + const float striplength(top_->stripLength()); + const float pitch(ly->geometry()->stripPitch()); + const float nstrip = top_->nstrips(); + //std::cout << " CSC : " << name << " / area : " << striplength*pitch*nstrip << std::endl; + hCSCArea_->GetXaxis()->SetBinLabel(iCSC, name.c_str()); + hCSCArea_->Fill(iCSC, striplength*pitch*nstrip); + } + + /* RPC */ + int iRPC = 0; + for ( const RPCRoll* roll : rpcGeom->rolls() ) { + ++iRPC; + const auto detId = roll->id(); + const string rollName = RPCGeomServ(detId).name(); + const double width = roll->surface().bounds().width(); + const double height = roll->surface().bounds().length(); + //std::cout << " RPC : " << rollName.c_str() << " / area : " << width*height << std::endl; + hRPCArea_->GetXaxis()->SetBinLabel(iRPC, rollName.c_str()); + hRPCArea_->Fill(iRPC, width*height); + } + +} +void MuonDetHitAnalyser::endRun(Run const&, EventSetup const&){} + +void MuonDetHitAnalyser::initValue() { + b_nME0Digis = 0; b_nME0RecHits = 0; + b_nCSC2DRecHits = 0; + b_nGEMDigis = 0; b_nGEMRecHits = 0; + b_nDTDigis = 0; b_nDTRecHits = 0; + b_nRPCDigis = 0; b_nRPCRecHits = 0; + + /*ME0 digi*/ + b_ME0_Digi_region = -9; b_ME0_Digi_chamber = -9; b_ME0_Digi_layer = -9; b_ME0_Digi_etaPartition = -9; b_ME0_Digi_bx = -999; + b_ME0_Digi_eta = -9; b_ME0_Digi_phi = -9; + /*ME0 rechit*/ + b_ME0_RecHit_region = -9; b_ME0_RecHit_chamber = -9; b_ME0_RecHit_layer = -9; b_ME0_RecHit_etaPartition = -9; + b_ME0_RecHit_eta = -9; b_ME0_RecHit_phi = -9; + + /*CSC rechit*/ + b_CSC_2DRecHit_region = -9; b_CSC_2DRecHit_station = -9; b_CSC_2DRecHit_ring = -9; b_CSC_2DRecHit_chamber = -9; b_CSC_2DRecHit_layer = -9; + b_CSC_2DRecHit_eta = -9; b_CSC_2DRecHit_phi = -9; + + /*GEM digi*/ + b_GEM_Digi_region = -9; b_GEM_Digi_station = -9; b_GEM_Digi_ring = -9; b_GEM_Digi_chamber = -9; b_GEM_Digi_layer = -9; b_GEM_Digi_etaPartition = -9; b_GEM_Digi_bx = -999; + b_GEM_Digi_eta = -9; b_GEM_Digi_phi = -9; + /*GEM rechit*/ + b_GEM_RecHit_region = -9; b_GEM_RecHit_station = -9; b_GEM_RecHit_ring = -9; b_GEM_RecHit_chamber = -9; b_GEM_RecHit_layer = -9; b_GEM_RecHit_etaPartition = -9; b_GEM_RecHit_bx = -999; + b_GEM_RecHit_eta = -9; b_GEM_RecHit_phi = -9;; + + /* DT digi*/ + b_DT_Digi_sector = -9; b_DT_Digi_station = -9; b_DT_Digi_wheel = -9; b_DT_Digi_chamber = -9; b_DT_Digi_superLayer = -9; b_DT_Digi_layer = -9; b_DT_Digi_wire = -9; + b_DT_Digi_eta = -9; b_DT_Digi_phi = -9; + /* DT rechit*/ + b_DT_RecHit_sector = -9; b_DT_RecHit_station = -9; b_DT_RecHit_wheel = -9; b_DT_RecHit_chamber = -9; b_DT_RecHit_superLayer = -9; b_DT_RecHit_layer = -9; b_DT_RecHit_wire = -9; + b_DT_RecHit_eta = -9; b_DT_RecHit_phi = -9; + + /*RPC digi*/ + b_RPC_Digi_region = -9; b_RPC_Digi_sector = -9; b_RPC_Digi_subSector = -9; b_RPC_Digi_station = -9; b_RPC_Digi_ring = -9; b_RPC_Digi_chamber = -9; b_RPC_Digi_layer = -9; b_RPC_Digi_roll = -9; + b_RPC_Digi_eta = -9; b_RPC_Digi_phi = -9; + b_RPC_Digi_isIRPC = -1; + /*RPC rechit*/ + b_RPC_RecHit_region = -9; b_RPC_RecHit_sector = -9; b_RPC_RecHit_subSector = -9; b_RPC_RecHit_station = -9; b_RPC_RecHit_ring = -9; b_RPC_RecHit_chamber = -9; b_RPC_RecHit_layer = -9; b_RPC_RecHit_roll = -9; + b_RPC_RecHit_eta = -9; b_RPC_RecHit_phi = -9; + b_RPC_RecHit_isIRPC = -1; +} + +//define this as a plug-in +DEFINE_FWK_MODULE(MuonDetHitAnalyser); diff --git a/MuonAnalyser/plugins/MuonTrackAnalyser.cc b/MuonAnalyser/plugins/MuonTrackAnalyser.cc new file mode 100644 index 00000000000..a3bc90aaefc --- /dev/null +++ b/MuonAnalyser/plugins/MuonTrackAnalyser.cc @@ -0,0 +1,478 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +// ME0 +#include "DataFormats/GEMDigi/interface/ME0DigiCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" +// GEM +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +// CSC +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +// DT +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +//#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/MuonDetId/interface/DTBtiId.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "DataFormats/MuonDetId/interface/DTLayerId.h" +#include "DataFormats/MuonDetId/interface/DTSectCollId.h" +#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "DataFormats/MuonDetId/interface/DTTracoId.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +// RPC +#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/RPCGeometry/interface/RPCGeomServ.h" +// Muon +#include "DataFormats/PatCandidates/interface/Muon.h" +// L1 +#include "DataFormats/L1TMuon/interface/L1MuBMTrack.h" + +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" + +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/Associations/interface/MuonToTrackingParticleAssociator.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" +#include "SimMuon/MCTruth/interface/MuonToSimAssociatorByHits.h" +#include "SimTracker/Common/interface/TrackingParticleSelector.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" + +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class MuonTrackAnalyser : public edm::EDAnalyzer { +public: + explicit MuonTrackAnalyser(const edm::ParameterSet&); + ~MuonTrackAnalyser(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + void initMuonValue(); + void initValue(); + + // ----------member data --------------------------- + edm::EDGetTokenT me0Segments_; + + edm::EDGetTokenT cscSegments_; + + edm::EDGetTokenT gemSegments_; + + edm::EDGetTokenT dt4DSegments_; + + edm::EDGetTokenT simToken_; + edm::EDGetTokenT > muonToken_; + +// edm::EDGetTokenT > muonL1Token_; + + const reco::VertexCollection* vertexes_; + edm::EDGetTokenT > vtxToken_; + + edm::Service fs; + + TTree *t_event; + int b_run, b_lumi, b_latency; + int b_nME0Segments, b_nCSCSegments, b_nGEMSegments, b_nDT4DSegments; + + /* ME0 */ + TTree *t_ME0_seg; + int b_ME0_Seg_region, b_ME0_Seg_chamber, b_ME0_Seg_layer, b_ME0_Seg_nRecHits; + float b_ME0_Seg_eta, b_ME0_Seg_phi; + + /* CSC */ + TTree *t_CSC_seg; + int b_CSC_Seg_region, b_CSC_Seg_station, b_CSC_Seg_ring, b_CSC_Seg_chamber, b_CSC_Seg_layer, b_CSC_Seg_nRecHits; + float b_CSC_Seg_eta, b_CSC_Seg_phi; + + /* GEM */ + TTree *t_GEM_seg; + int b_GEM_Seg_region, b_GEM_Seg_station, b_GEM_Seg_ring, b_GEM_Seg_chamber, b_GEM_Seg_layer, b_GEM_Seg_nRecHits; + float b_GEM_Seg_eta, b_GEM_Seg_phi; + + /* DT */ + TTree *t_DT_seg; + int b_DT_4DSeg_sector, b_DT_4DSeg_station, b_DT_4DSeg_wheel, b_DT_4DSeg_chamber, b_DT_4DSeg_nRecHits, b_DT_4DSeg_hasZed; + float b_DT_4DSeg_eta, b_DT_4DSeg_phi; + + /* Muon */ + TTree *t_genMuon; + float b_genMuon_pt, b_genMuon_eta, b_genMuon_phi; + int b_genMuon_isTight, b_genMuon_isMedium, b_genMuon_isLoose, b_genMuon_isTracker, b_genMuon_isGlobal, b_genMuon_isME0, b_genMuon_nMatchedStationLayer; + + TTree *t_Muon; + float b_muon_pt, b_muon_eta, b_muon_phi; + int b_muon_isTight, b_muon_isMedium, b_muon_isLoose, b_muon_isTracker, b_muon_isGlobal, b_muon_isME0, b_muon_nMatchedStationLayer; +}; + +MuonTrackAnalyser::MuonTrackAnalyser(const edm::ParameterSet& iConfig) +{ + me0Segments_ = consumes(iConfig.getParameter("me0Segments")); + + cscSegments_ = consumes(iConfig.getParameter("cscSegments")); + + gemSegments_ = consumes(iConfig.getParameter("gemSegments")); + + dt4DSegments_ = consumes(iConfig.getParameter("dt4DSegments")); + + simToken_ = consumes(iConfig.getParameter("simLabel")); + muonToken_ = consumes >(iConfig.getParameter("muonLabel")); + +// muonL1Token_ = consumes >(iConfig.getParameter("muonL1Label")); + + vtxToken_ = consumes >(iConfig.getParameter("primaryVertex")); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nME0Segments", &b_nME0Segments, "nME0Segments/I"); + t_event->Branch("nCSCSegments", &b_nCSCSegments, "nCSCSegments/I"); + t_event->Branch("nGEMSegments", &b_nGEMSegments, "nGEMSegments/I"); + t_event->Branch("nDT4DSegments", &b_nDT4DSegments, "nDT4DSegments/I"); + + /*ME0*/ + t_ME0_seg = fs->make("ME0_Segment", "ME0_Segment"); + t_ME0_seg->Branch("Seg_eta", &b_ME0_Seg_eta, "Seg_eta/F"); + t_ME0_seg->Branch("Seg_phi", &b_ME0_Seg_phi, "Seg_phi/F"); + t_ME0_seg->Branch("Seg_nRecHits", &b_ME0_Seg_nRecHits, "Seg_nRecHits/I"); + t_ME0_seg->Branch("Seg_region", &b_ME0_Seg_region, "Seg_region/I"); + t_ME0_seg->Branch("Seg_chamber", &b_ME0_Seg_chamber, "Seg_chamber/I"); + t_ME0_seg->Branch("Seg_layer", &b_ME0_Seg_layer, "Seg_layer/I"); + + /*CSC*/ + t_CSC_seg = fs->make("CSC_Segment", "CSC_Segment"); + t_CSC_seg->Branch("Seg_eta", &b_CSC_Seg_eta, "Seg_eta/F"); + t_CSC_seg->Branch("Seg_phi", &b_CSC_Seg_phi, "Seg_phi/F"); + t_CSC_seg->Branch("Seg_nRecHits", &b_CSC_Seg_nRecHits, "Seg_nRecHits/I"); + t_CSC_seg->Branch("Seg_region", &b_CSC_Seg_region, "Seg_region/I"); + t_CSC_seg->Branch("Seg_station", &b_CSC_Seg_station, "Seg_station/I"); + t_CSC_seg->Branch("Seg_ring", &b_CSC_Seg_ring, "Seg_ring/I"); + t_CSC_seg->Branch("Seg_chamber", &b_CSC_Seg_chamber, "Seg_chamber/I"); + t_CSC_seg->Branch("Seg_layer", &b_CSC_Seg_layer, "Seg_layer/I"); + + /*GEM*/ + t_GEM_seg = fs->make("GEM_Segment", "GEM_Segment"); + t_GEM_seg->Branch("Seg_eta", &b_GEM_Seg_eta, "Seg_eta/F"); + t_GEM_seg->Branch("Seg_phi", &b_GEM_Seg_phi, "Seg_phi/F"); + t_GEM_seg->Branch("Seg_nRecHits", &b_GEM_Seg_nRecHits, "Seg_nRecHits/I"); + t_GEM_seg->Branch("Seg_region", &b_GEM_Seg_region, "Seg_region/I"); + t_GEM_seg->Branch("Seg_station", &b_GEM_Seg_station, "Seg_station/I"); + t_GEM_seg->Branch("Seg_ring", &b_GEM_Seg_ring, "Seg_ring/I"); + t_GEM_seg->Branch("Seg_chamber", &b_GEM_Seg_chamber, "Seg_chamber/I"); + t_GEM_seg->Branch("Seg_layer", &b_GEM_Seg_layer, "Seg_layer/I"); + + /*DT*/ + t_DT_seg = fs->make("DT_4DSegment", "DT_4DSegment"); + t_DT_seg->Branch("Seg_eta", &b_DT_4DSeg_eta, "Seg_eta/F"); + t_DT_seg->Branch("Seg_phi", &b_DT_4DSeg_phi, "Seg_phi/F"); + t_DT_seg->Branch("Seg_nRecHits", &b_DT_4DSeg_nRecHits, "Seg_nRecHits/I"); + t_DT_seg->Branch("Seg_sector", &b_DT_4DSeg_sector, "Seg_sector/I"); + t_DT_seg->Branch("Seg_station", &b_DT_4DSeg_station, "Seg_station/I"); + t_DT_seg->Branch("Seg_wheel", &b_DT_4DSeg_wheel, "Seg_wheel/I"); + t_DT_seg->Branch("Seg_chamber", &b_DT_4DSeg_chamber, "Seg_chamber/I"); + t_DT_seg->Branch("Seg_hasZed", &b_DT_4DSeg_hasZed, "Seg_hasZed/I"); + + /*Muon*/ + t_genMuon = fs->make("gen_Muon", "gen_Muon"); + t_genMuon->Branch("pt", &b_genMuon_pt, "pt/F"); + t_genMuon->Branch("eta", &b_genMuon_eta, "eta/F"); + t_genMuon->Branch("phi", &b_genMuon_phi, "phi/F"); + t_genMuon->Branch("nMatchedStationLayer", &b_genMuon_nMatchedStationLayer, "nMatchedStationLayer/I"); + t_genMuon->Branch("isTracker", &b_genMuon_isTracker, "isTracker/I"); + t_genMuon->Branch("isGlobal", &b_genMuon_isGlobal, "isGlobal/I"); + t_genMuon->Branch("isME0", &b_genMuon_isME0, "isME0/I"); + t_genMuon->Branch("isTight", &b_genMuon_isTight, "isTight/I"); + t_genMuon->Branch("isMedium", &b_genMuon_isMedium, "isMedium/I"); + t_genMuon->Branch("isLoose", &b_genMuon_isLoose, "isLoose/I"); + + t_Muon = fs->make("Muon", "Muon"); + t_Muon->Branch("pt", &b_muon_pt, "pt/F"); + t_Muon->Branch("eta", &b_muon_eta, "eta/F"); + t_Muon->Branch("phi", &b_muon_phi, "phi/F"); + t_Muon->Branch("nMatchedStationLayer", &b_muon_nMatchedStationLayer, "nMatchedStationLayer/I"); + t_Muon->Branch("isTracker", &b_muon_isTracker, "isTracker/I"); + t_Muon->Branch("isGlobal", &b_muon_isGlobal, "isGlobal/I"); + t_Muon->Branch("isME0", &b_muon_isME0, "isME0/I"); + t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); + t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); + t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); + +} + +MuonTrackAnalyser::~MuonTrackAnalyser() +{ +} + +void +MuonTrackAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle hME0Geom; + iSetup.get().get(hME0Geom); + const ME0Geometry* ME0Geometry_ = &*hME0Geom; + + /* ME0 Geometry */ + edm::Handle me0Segments; + iEvent.getByToken(me0Segments_, me0Segments); + + /* CSC Geometry */ + edm::ESHandle hCSCGeom; + iSetup.get().get(hCSCGeom); + const CSCGeometry* CSCGeometry_ = &*hCSCGeom; + + edm::Handle cscSegments; + iEvent.getByToken(cscSegments_, cscSegments); + + /* GEM Geometry */ + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::Handle gemSegments; + iEvent.getByToken(gemSegments_, gemSegments); + + /* DT Geometry */ + edm::ESHandle hDTGeom; + iSetup.get().get(hDTGeom); + const DTGeometry* DTGeometry_ = &*hDTGeom; + + edm::Handle dt4DSegments; + iEvent.getByToken(dt4DSegments_, dt4DSegments); + + /* Muon */ + Handle simHandle; + iEvent.getByToken(simToken_, simHandle); + + edm::Handle > muonHandle; + iEvent.getByToken(muonToken_, muonHandle); + +// edm::Handle > muonL1Handle; +// iEvent.getByToken(muonL1Token_, muonL1Handle); + + edm::Handle vertices; + iEvent.getByToken(vtxToken_, vertices); + + vertexes_ = vertices.product(); + reco::Vertex pv0 = vertexes_->at(0); + + initValue(); + + for (auto ch : ME0Geometry_->chambers()) { + /* ME0 seg */ + ME0DetId cId = ch->id(); + auto segsRange = me0Segments->get(cId); + auto me0Seg = segsRange.first; + for (auto seg = me0Seg; seg != segsRange.second; ++seg) { + auto segLd = seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_ME0_Seg_eta = gp.eta(); + b_ME0_Seg_phi = gp.phi(); + b_ME0_Seg_nRecHits = seg->nRecHits(); + b_ME0_Seg_region = cId.region(); + b_ME0_Seg_chamber = cId.chamber(); + b_ME0_Seg_layer = cId.layer(); + //std::cout << b_ME0_Seg_chamber << " ==> seg x : " << segLd.x() << " seg y : " << segLd.y() << " seg eta : " << gp.eta() << " nRecHits : " << b_ME0_Seg_nRecHits << std::endl; + b_nME0Segments++; + t_ME0_seg->Fill(); + } + } + + /* CSC */ + for (auto ch : CSCGeometry_->chambers()) { + // CSC seg + CSCDetId cId = ch->id(); + auto segsRange = cscSegments->get(cId); + auto cscSeg = segsRange.first; + for (auto seg = cscSeg; seg != segsRange.second; ++seg) { + auto segLd = seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_CSC_Seg_eta = gp.eta(); + b_CSC_Seg_phi = gp.phi(); + b_CSC_Seg_nRecHits = seg->nRecHits(); + b_CSC_Seg_region = cId.endcap(); + b_CSC_Seg_station = cId.station(); + b_CSC_Seg_ring = cId.ring(); + b_CSC_Seg_chamber = cId.chamber(); + b_CSC_Seg_layer = cId.layer(); + b_nCSCSegments++; + t_CSC_seg->Fill(); + } + } + + /* GEM */ + for (auto ch : GEMGeometry_->chambers()) { + // GEM + GEMDetId cId = ch->id(); + auto segsRange = gemSegments->get(cId); + auto gemSeg = segsRange.first; + for (auto seg = gemSeg; seg != segsRange.second; ++seg) { + auto segLd = seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_GEM_Seg_eta = gp.eta(); + b_GEM_Seg_phi = gp.phi(); + b_GEM_Seg_nRecHits = seg->nRecHits(); + b_GEM_Seg_region = cId.region(); + b_GEM_Seg_station = cId.station(); + b_GEM_Seg_ring = cId.ring(); + b_GEM_Seg_chamber = cId.chamber(); + b_GEM_Seg_layer = cId.layer(); + b_nGEMSegments++; + t_GEM_seg->Fill(); + } + } + + /* DT */ + for (auto ch : DTGeometry_->chambers()) { + // DT seg + DTChamberId cId = ch->id(); + //b_DT_4DSeg_chamber = ch->id(); + auto segsRange = dt4DSegments->get(cId); + auto dt4DSeg = segsRange.first; + for (auto seg = dt4DSeg; seg != segsRange.second; ++seg) { + auto segLd = seg->localPosition(); + auto gp = ch->toGlobal(segLd); + b_DT_4DSeg_eta = gp.eta(); + b_DT_4DSeg_phi = gp.phi(); + b_DT_4DSeg_nRecHits = seg->recHits().size(); + b_DT_4DSeg_sector = cId.sector(); + b_DT_4DSeg_station = cId.station(); + b_DT_4DSeg_wheel = cId.wheel(); + //b_DT_4DSeg_chamber = cId.chamber(); + b_DT_4DSeg_hasZed = seg->hasZed(); + b_nDT4DSegments++; + t_DT_seg->Fill(); + } + } + + /* gen Muon */ + for (TrackingParticleCollection::size_type i=0; isize(); i++) { + TrackingParticleRef simRef(simHandle, i); + const TrackingParticle* simTP = simRef.get(); + b_genMuon_pt = simTP->pt(); + b_genMuon_eta = simTP->eta(); + b_genMuon_phi = simTP->phi(); + bool isSignalMuon = abs(simTP->pdgId())==13 && !simTP->genParticles().empty() && (simTP->eventId().event() == 0) && (simTP->eventId().bunchCrossing() == 0); + if (!isSignalMuon) continue; + t_genMuon->Fill(); + } + /* reco Muon */ + for(size_t i = 0; i < muonHandle->size(); ++i) { + initMuonValue(); + edm::RefToBase muRef = muonHandle->refAt(i); + const reco::Muon* mu = muRef.get(); + b_muon_isTight = muon::isTightMuon(*mu, pv0); + b_muon_isMedium = muon::isMediumMuon(*mu); + b_muon_isLoose = muon::isLooseMuon(*mu); + b_muon_pt = mu->pt(); + b_muon_eta = mu->eta(); + b_muon_phi = mu->phi(); + b_muon_isGlobal = mu->isGlobalMuon(); + b_muon_isTracker = mu->isTrackerMuon(); + b_muon_isME0 = mu->isME0Muon(); + b_muon_nMatchedStationLayer = mu->numberOfMatchedStations(); + t_Muon->Fill(); + } + /*L1 trigger*/ + + t_event->Fill(); +} + +void MuonTrackAnalyser::beginJob(){} +void MuonTrackAnalyser::endJob(){} + +void MuonTrackAnalyser::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){//(Run const& run, EventSetup const&){ +} +void MuonTrackAnalyser::endRun(Run const&, EventSetup const&){} + +void MuonTrackAnalyser::initMuonValue() { + b_genMuon_pt = -9; b_genMuon_eta = -9; b_genMuon_phi = -9; + + b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; b_muon_isTracker = -1; b_muon_isGlobal = -1; b_muon_isME0 = -1; + b_muon_pt = -9; b_muon_eta = -9; b_muon_phi = -9; + b_muon_nMatchedStationLayer = -9; + +} +void MuonTrackAnalyser::initValue() { + b_nME0Segments = 0; + b_nCSCSegments = 0; + b_nGEMSegments = 0; + b_nDT4DSegments = 0; + + /*ME0 seg*/ + b_ME0_Seg_region = -9; b_ME0_Seg_chamber = -9; b_ME0_Seg_layer = -9; b_ME0_Seg_nRecHits = -9; + b_ME0_Seg_eta = -9; b_ME0_Seg_phi = -9; + + /*CSC seg*/ + b_CSC_Seg_region = -9; b_CSC_Seg_station = -9; b_CSC_Seg_ring = -9; b_CSC_Seg_chamber = -9; b_CSC_Seg_layer = -9; b_CSC_Seg_nRecHits = -9; + b_CSC_Seg_eta = -9; b_CSC_Seg_phi = -9; + + /*GEM seg*/ + b_GEM_Seg_region = -9; b_GEM_Seg_station = -9; b_GEM_Seg_ring = -9; b_GEM_Seg_chamber = -9; b_GEM_Seg_layer = -9; b_GEM_Seg_nRecHits = -9; + b_GEM_Seg_eta = -9; b_GEM_Seg_phi = -9; + + /* DT seg*/ + b_DT_4DSeg_sector = -9; b_DT_4DSeg_station = -9; b_DT_4DSeg_wheel = -9; b_DT_4DSeg_chamber = -9; b_DT_4DSeg_nRecHits = -9; + b_DT_4DSeg_eta = -9; b_DT_4DSeg_phi = -9; + b_DT_4DSeg_hasZed = -1; +} + +//define this as a plug-in +DEFINE_FWK_MODULE(MuonTrackAnalyser); diff --git a/MuonAnalyser/plugins/STASliceTestAnalysis.cc b/MuonAnalyser/plugins/STASliceTestAnalysis.cc deleted file mode 100644 index b0efc23616d..00000000000 --- a/MuonAnalyser/plugins/STASliceTestAnalysis.cc +++ /dev/null @@ -1,572 +0,0 @@ -// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 - -// system include files -#include -#include -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -#include "DataFormats/Scalers/interface/LumiScalers.h" -#include "DataFormats/MuonData/interface/MuonDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" -#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" - -#include "DataFormats/MuonData/interface/MuonDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMC13EventCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCdataCollection.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" - -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonTopologies/interface/StripTopology.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TString.h" -#include "TGraphAsymmErrors.h" -#include "TLorentzVector.h" -#include "TTree.h" - -#include "TVector2.h" - - -using namespace std; -using namespace edm; - -class STASliceTestAnalysis : public edm::EDAnalyzer { -public: - explicit STASliceTestAnalysis(const edm::ParameterSet&); - ~STASliceTestAnalysis(); - -private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() override; - virtual void endJob() override; - - virtual void beginRun(Run const&, EventSetup const&) override; - virtual void endRun(Run const&, EventSetup const&) override; - - // ----------member data --------------------------- - edm::EDGetTokenT gemRecHits_; - // edm::EDGetTokenT > muons_; - edm::EDGetTokenT vertexCollection_; - edm::Service fs; - edm::EDGetTokenT staTracks_; - - MuonServiceProxy* theService_; - edm::ESHandle propagator_; - edm::ESHandle ttrackBuilder_; - edm::ESHandle bField_; - edm::EDGetTokenT lumiScalers_; - - edm::EDGetTokenT amc13Event_; - edm::EDGetTokenT amcData_; - edm::EDGetTokenT gebStatusCol_; - edm::EDGetTokenT vfatStatusCol_; - - bool checkEtaPartitionGood(const GEMEtaPartition* part); - - edm::Handle amc13Event; - edm::Handle amcData; - edm::Handle gebStatusCol; - edm::Handle vfatStatusCol; - - ULong64_t b_event; - int b_run, b_lumi; - float b_instLumi; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality, b_bx; - int b_latency; - vector b_strips; - float b_x, b_y, b_z; - float b_mu_eta, b_mu_phi, b_mu_pt; - float b_pull_x, b_pull_y, b_res_x, b_res_y; - - int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon, nGEMTotal; - int b_nMuons, b_nMuonsWithGEMHit, b_nMuonsInMuonTree, b_nHitsInHitTree; - int b_valid; - - int b_nGEMHits; - - // muon branches - int m_nGEMhits, m_nCSChits, m_nhits, m_nvalidhits; - int m_nbounds; - int m_quality, m_charge; - float m_pt, m_eta, m_phi, m_chi2; - // GEMHits included in Muon - vector m_roll, m_chamber, m_layer; // hit info - vector m_resx, m_resy, m_pullx, m_pully; - // Propagation only information - vector m_in_vfat; - vector m_in_roll, m_in_chamber, m_in_layer, m_in_goodEta; // propagation bound info - vector m_in_globalPhi, m_in_globalEta, m_in_nearGemPhi, m_in_nearGemEta; // global info - vector m_in_x, m_in_y, m_in_local_x, m_in_local_y, m_in_gemx, m_in_gemy, m_in_local_gemx, m_in_local_gemy, m_in_pullx, m_in_pully, m_in_resx, m_in_resy, m_in_trkextdx, m_in_gem_dx; - vector m_in_local_x_closetsos, m_in_local_y_closetsos, m_in_trkextdx_closetsos, m_in_trkextdx_inner; - vector m_in_local_x_inner, m_in_local_y_inner; - vector m_in_gemNStrips, m_in_gemFirstStrip, m_in_strip; - vector m_in_matchingGem; - - vector m_rec_roll, m_rec_chamber, m_rec_layer; - - vector> m_in_resx_tests; - - TTree *t_hit; - TTree *t_run; - TTree *t_muon; - TTree *t_event; -}; - -STASliceTestAnalysis::STASliceTestAnalysis(const edm::ParameterSet& iConfig) : - nEvents(0), - nMuonTotal(0), - nGEMFiducialMuon(0), - nGEMTrackWithMuon(0), - nGEMTotal(0) -{ - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - staTracks_ = consumes(iConfig.getParameter("muons")); - edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - theService_ = new MuonServiceProxy(serviceParameters); - lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); - amc13Event_ = consumes(iConfig.getParameter("amc13Event")); - amcData_ = consumes(iConfig.getParameter("amcData")); - gebStatusCol_ = consumes(iConfig.getParameter("gebStatusCol")); - vfatStatusCol_ = consumes(iConfig.getParameter("vfatStatusCol")); - - t_event = fs->make("Event", "Event"); - t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); - t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); - t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); - t_event->Branch("nMuonsInMuonTree", &b_nMuonsInMuonTree, "nMuonsInMuonTree/I"); - t_event->Branch("nHitsInHitTree", &b_nHitsInHitTree, "nHitsInHitTree/I"); - t_event->Branch("event", &b_event, "event/l"); - t_event->Branch("run", &b_run, "run/I"); - t_event->Branch("lumi", &b_lumi, "lumi/I"); - t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); - t_event->Branch("latency", &b_latency, "latency/I"); - - t_muon = fs->make("Muon", "Muon"); - t_muon->Branch("event", &b_event, "event/l"); - t_muon->Branch("run", &b_run, "run/I"); - t_muon->Branch("lumi", &b_lumi, "lumi/I"); - t_muon->Branch("instLumi", &b_instLumi, "instLumi/F"); - t_muon->Branch("latency", &b_latency, "latency/I"); - t_muon->Branch("chi2", &m_chi2, "chi2/F"); - t_muon->Branch("nhits", &m_nhits, "nhits/I"); - t_muon->Branch("nCSChits", &m_nCSChits, "nCSChits/I"); - t_muon->Branch("nGEMhits", &m_nGEMhits, "nGEMhits/I")->SetTitle("n GEM hits associated to muon"); - t_muon->Branch("nvalidhits", &m_nvalidhits, "nvalidhits/I")->SetTitle("n GEM hits associated to muon, and muon can propagate to eta partition of hit"); - t_muon->Branch("nbounds", &m_nbounds, "nbounds/I")->SetTitle("times muon is in GEM eta partition bounds"); - t_muon->Branch("pt", &m_pt, "pt/F"); - t_muon->Branch("eta", &m_eta, "eta/F"); - t_muon->Branch("phi", &m_phi, "phi/F"); - t_muon->Branch("charge", &m_charge, "charge/I"); - t_muon->Branch("quality", &m_quality, "quality/I")->SetTitle("muon quality :: 0:noid 1:looseID 2:tightID"); - t_muon->Branch("in_strip", &m_in_strip); - t_muon->Branch("in_vfat", &m_in_vfat); - t_muon->Branch("in_roll", &m_in_roll); - t_muon->Branch("in_chamber", &m_in_chamber); - t_muon->Branch("in_layer", &m_in_layer); - t_muon->Branch("in_goodEta", &m_in_goodEta); - t_muon->Branch("in_resx", &m_in_resx); - t_muon->Branch("in_resx_tests", &m_in_resx_tests); - t_muon->Branch("in_resy", &m_in_resy); - t_muon->Branch("in_trkextdx", &m_in_trkextdx); - t_muon->Branch("in_pullx", &m_in_pullx); - t_muon->Branch("in_pully", &m_in_pully); - t_muon->Branch("in_phi", &m_in_globalPhi); - t_muon->Branch("in_eta", &m_in_globalEta); - t_muon->Branch("in_nearGemPhi", &m_in_nearGemPhi); - t_muon->Branch("in_nearGemEta", &m_in_nearGemEta); - t_muon->Branch("in_x", &m_in_x); - t_muon->Branch("in_y", &m_in_y); - - t_muon->Branch("in_local_x_inner", &m_in_local_x_inner); - t_muon->Branch("in_local_y_inner", &m_in_local_y_inner); - t_muon->Branch("in_local_x_closetsos", &m_in_local_x_closetsos); - t_muon->Branch("in_local_y_closetsos", &m_in_local_y_closetsos); - t_muon->Branch("in_trkextdx_closetsos", &m_in_trkextdx_closetsos); - t_muon->Branch("in_trkextdx_inner", &m_in_trkextdx_inner); - - t_muon->Branch("in_local_x", &m_in_local_x); - t_muon->Branch("in_local_y", &m_in_local_y); - t_muon->Branch("in_gemx", &m_in_gemx); - t_muon->Branch("in_gem_dx", &m_in_gem_dx); - t_muon->Branch("in_gemy", &m_in_gemy); - t_muon->Branch("in_local_gemx", &m_in_local_gemx); - t_muon->Branch("in_local_gemy", &m_in_local_gemy); - t_muon->Branch("in_gemFirstStrip", &m_in_gemFirstStrip); - t_muon->Branch("in_gemNStrips", &m_in_gemNStrips); - t_muon->Branch("in_matchingGem", &m_in_matchingGem); - - t_muon->Branch("rec_roll", &m_rec_roll); - t_muon->Branch("rec_chamber", &m_rec_chamber); - t_muon->Branch("rec_layer", &m_rec_layer); - - t_hit = fs->make("Hit", "Hit"); - t_hit->Branch("event", &b_event, "event/l"); - t_hit->Branch("run", &b_run, "run/I"); - t_hit->Branch("lumi", &b_lumi, "lumi/I"); - t_hit->Branch("instLumi", &b_instLumi, "instLumi/F"); - t_hit->Branch("latency", &b_latency, "latency/I"); - t_hit->Branch("bx", &b_bx, "bx/I"); - t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); - t_hit->Branch("strips", &b_strips); - t_hit->Branch("chamber", &b_chamber, "chamber/I"); - t_hit->Branch("layer", &b_layer, "layer/I"); - t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); - t_hit->Branch("x", &b_x, "x/F"); - t_hit->Branch("y", &b_y, "y/F"); - t_hit->Branch("z", &b_z, "z/F"); -} - -STASliceTestAnalysis::~STASliceTestAnalysis() -{ - std::cout << "::: GEM Slice Test Results :::" << std::endl; - std::cout << ": From " << nEvents << " events" << std::endl; - std::cout << std::endl; - std::cout << " # GEMHits " << nGEMTotal << std::endl; - std::cout << " # Muons " << nMuonTotal << std::endl; - std::cout << " # FidMu " << nGEMFiducialMuon << std::endl; - std::cout << " # GEMMu " << nGEMTrackWithMuon << std::endl; - std::cout << std::endl; -} - -void -STASliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - edm::Handle lumiScalers; - iEvent.getByToken(lumiScalers_, lumiScalers); - - edm::ESHandle GEMGeometry_; - iSetup.get().get(GEMGeometry_); - - edm::Handle gemRecHits; - iEvent.getByToken(gemRecHits_, gemRecHits); - - edm::Handle muons; - iEvent.getByToken(staTracks_, muons); - - iEvent.getByToken(amc13Event_, amc13Event); - iEvent.getByToken(amcData_, amcData); - iEvent.getByToken(gebStatusCol_, gebStatusCol); - iEvent.getByToken(vfatStatusCol_, vfatStatusCol); - - iSetup.get().get("TransientTrackBuilder", ttrackBuilder_); - theService_->update(iSetup); - auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - - b_latency = -1; - - for (auto g : *amcData) { - for (auto a = g.second.first; a != g.second.second; ++a) { - if (b_latency != -1 && b_latency != a->param1()) - std::cout << "CHANGING LATENCY - old: " << b_latency << " new: " << a->param1() << std::endl; - b_latency = a->param1(); - if (b_latency == -1) std::cout << "-1 LATENCY VALUE - " << iEvent.id().event() << " " << iEvent.id().run() << std::endl; - } - } - - nEvents++; - - b_nMuons = 0; - b_nMuonsWithGEMHit = 0; - b_nGEMHits = 0; - b_nMuonsInMuonTree = 0; - b_nHitsInHitTree = 0; - - b_run = iEvent.run(); - b_lumi = iEvent.luminosityBlock(); - if (lumiScalers->size() > 0) - b_instLumi = (lumiScalers->at(0)).instantLumi(); - else - b_instLumi = -1; - b_event = iEvent.id().event(); // = event number - - - // cout << "---- MUONS --- " << endl; - for (auto & mu : *muons) { - b_nMuons++; - // only consider muons going in the right direction (toward the gem slice test) - if (mu.eta() > 0) continue; - - m_nGEMhits = 0; - m_nbounds = 0; - m_in_strip.clear(); m_in_vfat.clear(); m_in_roll.clear(); m_in_chamber.clear(); m_in_layer.clear(); m_in_goodEta.clear(); - m_in_x.clear(); m_in_y.clear(); m_in_gemx.clear(); m_in_gem_dx.clear(); m_in_gemy.clear(); - m_in_local_x_closetsos.clear(); m_in_local_y_closetsos.clear(); - m_in_local_x_inner.clear(); m_in_local_y_inner.clear(); - m_in_trkextdx_closetsos.clear(); m_in_trkextdx_inner.clear(); - m_in_local_gemx.clear(); m_in_local_gemy.clear(); - m_in_local_x.clear(); m_in_local_y.clear(); - m_in_resx.clear(); m_in_trkextdx.clear(); m_in_resy.clear(); m_in_pullx.clear(); m_in_pully.clear(); - m_in_resx_tests.clear(); - m_in_matchingGem.clear(); - m_in_gemFirstStrip.clear(); m_in_gemNStrips.clear(); - m_in_nearGemPhi.clear(); m_in_nearGemEta.clear(); - m_in_globalPhi.clear(); m_in_globalEta.clear(); - - m_rec_layer.clear(); m_rec_roll.clear(); m_rec_chamber.clear(); - m_quality = mu.qualityMask(); - - // if (mu.passed(reco::Muon::Selector::CutBasedIdTight)) m_quality = 2; - // else if (mu.passed(reco::Muon::Selector::CutBasedIdLoose)) m_quality = 1; - // else m_quality = 0; - - m_charge = mu.charge(); - - const reco::Track* muonTrack = μ - // if (mu.globalTrack().isNonnull()) muonTrack = mu.globalTrack().get(); - // else if (mu.outerTrack().isNonnull()) muonTrack = mu.outerTrack().get(); - if (muonTrack) { - bool fidMu = false; - reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - for (auto ch : GEMGeometry_->etaPartitions()) { - - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), - ch->surface()); - if (!tsos.isValid()) continue; - - GlobalPoint tsosGP = tsos.globalPosition(); - - const LocalPoint pos = ch->toLocal(tsosGP); - const LocalPoint pos2D(pos.x(), pos.y(), 0); - const BoundPlane& bps(ch->surface()); - - if (bps.bounds().inside(pos2D)) { - fidMu = true; - m_nbounds++; - - auto gemid = ch->id(); - - m_in_strip.push_back(ch->strip(pos2D)); - m_in_vfat.push_back(ch->strip(pos2D)/128.); - m_in_roll.push_back(gemid.roll()); - m_in_chamber.push_back(gemid.chamber()); - m_in_layer.push_back(gemid.layer()); - - m_in_goodEta.push_back(checkEtaPartitionGood(ch)); - - float in_x, in_y; - in_x = tsosGP.x(); in_y = tsosGP.y(); - m_in_x.push_back(in_x); m_in_y.push_back(in_y); - m_in_globalPhi.push_back(tsosGP.phi()); - m_in_globalEta.push_back(tsosGP.eta()); - - // propagate from the "closest" tsos - float in_local_x_closetsos = -9999, in_local_y_closetsos = -9999, in_trkextdx_closetsos = -99; - GlobalPoint gemtagp1 = ch->position(); - TrajectoryStateOnSurface tsos1 = ttTrack.stateOnSurface(gemtagp1); - if (!tsos1.isValid()) goto out1; - tsos1 = propagator->propagate(tsos1, ch->surface()); - if (!tsos1.isValid()) goto out1; - in_local_x_closetsos = tsos1.localPosition().x(); in_local_y_closetsos = tsos1.localPosition().y(); - in_trkextdx_closetsos = std::sqrt(tsos1.localError().positionError().xx()); - out1: - m_in_local_x_closetsos.push_back(in_local_x_closetsos); m_in_local_y_closetsos.push_back(in_local_y_closetsos); - m_in_trkextdx_closetsos.push_back(in_trkextdx_closetsos); - - // Propagate from the innermost state - float in_local_x_inner = -9999, in_local_y_inner = -9999, in_trkextdx_inner = -99; - TrajectoryStateOnSurface tsos2 = propagator->propagate(ttTrack.innermostMeasurementState(), - ch->surface()); - if (!tsos2.isValid()) goto out2; - in_local_x_inner = tsos2.localPosition().x(); in_local_y_inner = tsos2.localPosition().y(); - in_trkextdx_inner = std::sqrt(tsos2.localError().positionError().xx()); - out2: - m_in_local_x_inner.push_back(in_local_x_inner); m_in_local_y_inner.push_back(in_local_y_inner); - m_in_trkextdx_inner.push_back(in_trkextdx_inner); - - - bool matchingGem = false; - int nstrips = -1, firststrip = -1; - float in_resx = -99, in_trkextdx, in_resy = -99, in_pullx = -99, in_pully = -99, in_gem_dx = -99; - float gemEta = +99.0, gemPhi = +99.0, in_gemx=-999, in_gemy=-999, in_local_gemx=-999, in_local_gemy=-999, in_local_x=-999, in_local_y=-999; - auto recHitsRange = gemRecHits->get(gemid); - auto gemRecHit = recHitsRange.first; - vector in_resx_tests; - - in_local_x = pos.x(); - in_local_y = pos.y(); - - LocalPoint loc; - - for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - auto gemGlob = ch->toGlobal(hit->localPosition()); - if (fabs(gemGlob.phi() - tsosGP.phi()) < gemPhi) { - in_gemx = gemGlob.x(); - in_gemy = gemGlob.y(); - - in_local_gemx = hit->localPosition().x(); - in_local_gemy = hit->localPosition().y(); - - matchingGem = true; - firststrip = hit->firstClusterStrip(); - nstrips = hit->clusterSize(); - gemPhi = gemGlob.phi(); gemEta = gemGlob.eta(); - - LocalPoint && tsos_localpos = tsos.localPosition(); - loc = hit->localPosition(); - LocalError && tsos_localerr = tsos.localError().positionError(); - LocalPoint && dethit_localpos = hit->localPosition(); - LocalError && dethit_localerr = hit->localPositionError(); - in_gem_dx = dethit_localerr.xx(); - in_resx = (dethit_localpos.x() - tsos_localpos.x()); - in_trkextdx = std::sqrt(tsos.localError().positionError().xx()); - in_resy = (dethit_localpos.y() - tsos_localpos.y()); - in_pullx = (dethit_localpos.x() - tsos_localpos.x()) / - std::sqrt(dethit_localerr.xx() + tsos_localerr.xx()); - in_pully = (dethit_localpos.y() - tsos_localpos.y()) / - std::sqrt(dethit_localerr.yy() + tsos_localerr.yy()); - } - } - - m_in_resx_tests.push_back(in_resx_tests); - m_in_gemx.push_back(in_gemx); m_in_gemy.push_back(in_gemy); - m_in_gem_dx.push_back(in_gem_dx); - m_in_local_x.push_back(in_local_x); m_in_local_y.push_back(in_local_y); - m_in_local_gemx.push_back(in_local_gemx); m_in_local_gemy.push_back(in_local_gemy); - m_in_resx.push_back(in_resx); m_in_trkextdx.push_back(in_trkextdx); m_in_resy.push_back(in_resy); - m_in_pullx.push_back(in_pullx); m_in_pully.push_back(in_pully); - m_in_gemNStrips.push_back(nstrips); m_in_gemFirstStrip.push_back(firststrip); - m_in_matchingGem.push_back(matchingGem); - m_in_nearGemPhi.push_back(gemPhi); m_in_nearGemEta.push_back(gemEta); - // cout << " --- eta: " << tsosGP.eta() << " phi: " << tsosGP.phi() << " xyz: " << in_x << " " << in_y << " GEMxyz: " << in_gemx << " " << in_gemy << " qual:" << m_quality << " eta:" << mu.eta() << " phi:" << mu.phi() << " pt:" << mu.pt() << " ch:" << gemid.chamber() << " l:" << gemid.layer() << " p:" << gemid.roll() << endl; - } - } - - m_nhits = 0; m_nCSChits = 0; - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - m_nhits++; - if ((*hit)->geographicalId().det() == DetId::Muon && - (*hit)->geographicalId().subdetId() == MuonSubdetId::CSC) m_nCSChits++; - - if ((*hit)->geographicalId().det() == DetId::Muon && - (*hit)->geographicalId().subdetId() == MuonSubdetId::GEM) { - GEMDetId gemid((*hit)->geographicalId()); - - m_rec_chamber.push_back(gemid.chamber()); - m_rec_layer.push_back(gemid.layer()); - m_rec_roll.push_back(gemid.roll()); - } - } - - if (fidMu) ++nGEMFiducialMuon; - } - - if (m_nGEMhits > 0 or m_nbounds > 0) { - m_pt = mu.pt(); - m_eta = mu.eta(); - m_phi = mu.phi(); - m_pt = mu.normalizedChi2(); - - t_muon->Fill(); - b_nMuonsInMuonTree++; - } - } // Muon Loop - - // cout << "--- GEM HITS ---" << endl; - for (auto & gem : *gemRecHits) { - ++b_nGEMHits; - auto detId = gem.gemId(); - - b_strips.clear(); - b_chamber = detId.chamber(); - b_layer = detId.layer(); - b_etaPartition = detId.roll(); - b_firstStrip = gem.firstClusterStrip(); - b_bx = gem.BunchX(); - b_nStrips = gem.clusterSize(); - for (int nstrip = gem.firstClusterStrip(); nstrip < (gem.firstClusterStrip() + gem.clusterSize()); ++nstrip) { - b_strips.push_back(nstrip); - } - - auto roll = GEMGeometry_->etaPartition(detId); - auto globalPosition = roll->toGlobal(gem.localPosition()); - b_x = globalPosition.x(); - b_y = globalPosition.y(); - b_z = globalPosition.z(); - - t_hit->Fill(); - b_nHitsInHitTree++; - // cout << " --- eta: " << globalPosition.eta() << " phi: " << globalPosition.phi() << " xyz: " << b_x << " " << b_y << " " << b_z << " ch:" << detId.chamber() << " l:" << detId.layer() << " p:" << detId.roll() << endl; - } // GEM Loop - // cout << endl << endl; - - nMuonTotal += b_nMuons; - nGEMTotal += b_nGEMHits; - - t_event->Fill(); -} - -bool STASliceTestAnalysis::checkEtaPartitionGood(const GEMEtaPartition* part) -{ - GEMDetId rId = part->id(); - int amcBx = -1; - - for (GEMAMCdataCollection::DigiRangeIterator amcsIt = amcData->begin(); amcsIt != amcData->end(); ++amcsIt){ - auto amcs = (*amcsIt).second; - for (auto amc = amcs.first; amc != amcs.second; ++amc) { - amcBx = amc->bx(); - } - } - - auto gebs = gebStatusCol->get(rId.chamberId()); - for (auto geb = gebs.first; geb != gebs.second; ++geb) { - if (int(geb->getInFu()) != 0 ) return false; - } - - auto vfats = vfatStatusCol->get(rId); - for (auto vfat = vfats.first; vfat != vfats.second; ++vfat) { - if (vfat->bc() != amcBx ) return false; - if (int(vfat->quality()) != 0 ) return false; - if (int(vfat->flag()) != 0 ) return false; - } - return true; -} - -void STASliceTestAnalysis::beginJob(){} -void STASliceTestAnalysis::endJob(){} - -void STASliceTestAnalysis::beginRun(Run const& run, EventSetup const&){ -} -void STASliceTestAnalysis::endRun(Run const&, EventSetup const&){} - -//define this as a plug-in -DEFINE_FWK_MODULE(STASliceTestAnalysis); diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc deleted file mode 100644 index fa3dc613349..00000000000 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ /dev/null @@ -1,545 +0,0 @@ -// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// system include files -#include -#include -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonTopologies/interface/StripTopology.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TString.h" -#include "TGraphAsymmErrors.h" -#include "TLorentzVector.h" -#include "TTree.h" - -using namespace std; -using namespace edm; - -class SliceTestAnalysis : public edm::EDAnalyzer { -public: - explicit SliceTestAnalysis(const edm::ParameterSet&); - ~SliceTestAnalysis(); - -private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() override; - virtual void endJob() override; - - virtual void beginRun(Run const&, EventSetup const&) override; - virtual void endRun(Run const&, EventSetup const&) override; - - // ----------member data --------------------------- - edm::EDGetTokenT gemRecHits_; - edm::EDGetTokenT > muons_; - edm::EDGetTokenT vertexCollection_; - edm::Service fs; - - MuonServiceProxy* theService_; - edm::ESHandle propagator_; - edm::ESHandle ttrackBuilder_; - edm::ESHandle bField_; - - TH2D* h_firstStrip[36][3]; - TH2D* h_allStrips[36][3]; - TH2D* h_globalPosOnGem; - TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; - TH1D* h_inEta[36][3]; - TH1D* h_hitEta[36][3]; - TH1D* h_trkEta[36][3]; - - TH1D* h_res_x, *h_res_y, *h_pull_x, *h_pull_y; - - TTree *t_hit; - int b_run, b_lumi, b_event; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality, b_bx; - float b_x, b_y, b_z; - float b_mu_eta, b_mu_phi, b_mu_pt; - float b_pull_x, b_pull_y, b_res_x, b_res_y; - - int nEvents, nMuonTotal, nGEMFiducialMuon, nGEMTrackWithMuon; - int b_nMuons, b_nMuonsWithGEMHit; - int b_valid; - - int b_nGEMHits; - - // muon branches - int m_nhits, m_nvalidhits; - int m_nbounds; - int m_quality; - float m_pt, m_eta, m_phi; - vector m_roll, m_chamber, m_layer, m_strip; // hit info - vector m_resx, m_resy, m_pullx, m_pully; - vector m_in_roll, m_in_chamber, m_in_layer, m_in_strip; // propagation bound info - vector m_in_globalPhi, m_in_globalEta, m_in_nearGemPhi, m_in_nearGemEta, m_in_nearGemRoll, m_in_nearGemFirstStrip, m_in_nearGemClusterSize; // global info - - TTree *t_run; - TTree *t_muon; - TTree *t_event; -}; - -struct GEMMuonAssociation { - int muonQuality; - float mu_phi; - float mu_eta; - float mu_pt; - - float pull_x; - float pull_y; - float res_x; - float res_y; - - int valid; -}; - -SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : - nEvents(0), - nMuonTotal(0), - nGEMFiducialMuon(0), - nGEMTrackWithMuon(0) -{ - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - muons_ = consumes >(iConfig.getParameter("muons")); - vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); - edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - theService_ = new MuonServiceProxy(serviceParameters); - - h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); - h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_bxtotal=fs->make(Form("bx"),"bx",31,-15,15); - - h_globalPosOnGem = fs->make(Form("onGEM"), "onGEM", 100, -100, 100, 100, -100, 100); - - t_run = fs->make("Run", "Run"); - t_run->Branch("run", &b_run, "run/I"); - - t_event = fs->make("Event", "Event"); - t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); - t_event->Branch("nMuonsWithGEMHit", &b_nMuonsWithGEMHit, "nMuonsWithGEMHit/I"); - t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); - t_event->Branch("run", &b_run, "run/I"); - t_event->Branch("lumi", &b_lumi, "lumi/I"); - - h_res_x=fs->make(Form("res_x"),"res_x",100,-50,50); - h_res_y=fs->make(Form("res_y"),"res_y",100,-50,50); - h_pull_x=fs->make(Form("pull_x"),"pull_x",100,-50,50); - h_pull_y=fs->make(Form("pull_y"),"pull_y",100,-50,50); - - t_muon = fs->make("Muon", "Muon"); - t_muon->Branch("run", &b_run, "run/I"); - t_muon->Branch("lumi", &b_lumi, "lumi/I"); - t_muon->Branch("nhits", &m_nhits, "nhits/I")->SetTitle("n GEM hits associated to muon"); - t_muon->Branch("nvalidhits", &m_nvalidhits, "nvalidhits/I")->SetTitle("n GEM hits associated to muon, and muon can propagate to eta partition of hit"); - t_muon->Branch("nbounds", &m_nbounds, "nbounds/I")->SetTitle("times muon is in GEM eta partition bounds"); - t_muon->Branch("pt", &m_pt, "pt/F"); - t_muon->Branch("eta", &m_eta, "eta/F"); - t_muon->Branch("phi", &m_phi, "phi/F"); - t_muon->Branch("quality", &m_quality, "quality/I")->SetTitle("muon quality :: 0:noid 1:looseID 2:tightID"); - t_muon->Branch("roll", &m_roll); - t_muon->Branch("chamber", &m_chamber); - t_muon->Branch("layer", &m_layer); - t_muon->Branch("strip", &m_strip); - t_muon->Branch("resx", &m_resx); - t_muon->Branch("resy", &m_resy); - t_muon->Branch("pullx", &m_pullx); - t_muon->Branch("pully", &m_pully); - t_muon->Branch("in_roll", &m_in_roll); - t_muon->Branch("in_chamber", &m_in_chamber); - t_muon->Branch("in_layer", &m_in_layer); - t_muon->Branch("in_strip", &m_in_strip); - t_muon->Branch("in_globalPhi", &m_in_globalPhi); - t_muon->Branch("in_globalEta", &m_in_globalEta); - t_muon->Branch("in_nearGemPhi", &m_in_nearGemPhi); - t_muon->Branch("in_nearGemEta", &m_in_nearGemEta); - t_muon->Branch("in_nearGemRoll", &m_in_nearGemRoll); - t_muon->Branch("in_nearGemFirstStrip", &m_in_nearGemFirstStrip); - t_muon->Branch("in_nearGemClusterSize", &m_in_nearGemClusterSize); - - t_hit = fs->make("Hit", "Hit"); - t_hit->Branch("run", &b_run, "run/I"); - t_hit->Branch("lumi", &b_lumi, "lumi/I"); - - t_hit->Branch("bx", &b_bx, "bx/I"); - t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); - t_hit->Branch("chamber", &b_chamber, "chamber/I"); - t_hit->Branch("layer", &b_layer, "layer/I"); - t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_hit->Branch("muonQuality", &b_muonQuality, "muonQuality/I")->SetTitle("muonQuality -1:none 0:noid 1:looseID 2:tightID"); - t_hit->Branch("x", &b_x, "x/F"); - t_hit->Branch("y", &b_y, "y/F"); - t_hit->Branch("z", &b_z, "z/F"); - t_hit->Branch("pull_x", &b_pull_x, "pull_x/F"); - t_hit->Branch("pull_y", &b_pull_y, "pull_y/F"); - t_hit->Branch("res_x", &b_res_x, "res_x/F"); - t_hit->Branch("res_y", &b_res_y, "res_y/F"); - t_hit->Branch("valid", &b_valid, "valid/I"); - t_hit->Branch("mu_phi", &b_mu_phi, "mu_phi/F"); - t_hit->Branch("mu_eta", &b_mu_eta, "mu_eta/F"); - t_hit->Branch("mu_pt", &b_mu_pt, "mu_pt/F"); - - for (int ichamber=0; ichamber<36;++ichamber) { - // for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=1; ilayer<3;++ilayer) { - h_firstStrip[ichamber][ilayer] = fs->make(Form("firstStrip ch %i lay %i",ichamber, ilayer),"firstStrip",384,1,385,8,0.5,8.5); - h_firstStrip[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_firstStrip[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - - h_allStrips[ichamber][ilayer] = fs->make(Form("allStrips ch %i lay %i",ichamber, ilayer),"allStrips",384,1,385,8,0.5,8.5); - h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - - h_inEta[ichamber][ilayer] = fs->make(Form("inEta ch %i lay %i",ichamber, ilayer),"inEta",8,0.5,8.5); - h_hitEta[ichamber][ilayer] = fs->make(Form("hitEta ch %i lay %i",ichamber, ilayer),"hitEta",8,0.5,8.5); - h_trkEta[ichamber][ilayer] = fs->make(Form("trkEta ch %i lay %i",ichamber, ilayer),"trkEta",8,0.5,8.5); - } - } -} - -SliceTestAnalysis::~SliceTestAnalysis() -{ - std::cout << "::: GEM Slice Test Results :::" << std::endl; - std::cout << ": From " << nEvents << " events" << std::endl; - std::cout << std::endl; - std::cout << " # Muons " << nMuonTotal << std::endl; - std::cout << " # FidMu " << nGEMFiducialMuon << std::endl; - std::cout << " # GEMMu " << nGEMTrackWithMuon << std::endl; - std::cout << std::endl; -} - -void -SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - nEvents++; - - b_nMuons = 0; - b_nMuonsWithGEMHit = 0; - b_nGEMHits = 0; - - b_run = iEvent.run(); - b_lumi = iEvent.luminosityBlock(); - - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const GEMGeometry* GEMGeometry_ = &*hGeom; - - iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - // iSetup.get().get("SteppingHelixPropagatorAny",propagator_); - // iSetup.get().get(bField_); - theService_->update(iSetup); - auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - - edm::Handle gemRecHits; - iEvent.getByToken(gemRecHits_, gemRecHits); - - edm::Handle vertexCollection; - iEvent.getByToken( vertexCollection_, vertexCollection ); - if(vertexCollection.isValid()) { - vertexCollection->size(); - // std::cout << "vertex->size() " << vertexCollection->size() < > muons; - iEvent.getByToken(muons_, muons); - - std::map muHits; - - for (size_t i = 0; i < muons->size(); ++i) { - b_nMuons++; - nMuonTotal++; - - m_nhits = 0; - m_nvalidhits = 0; - m_nbounds = 0; - m_roll.clear(); m_chamber.clear(); m_layer.clear(); m_strip.clear(); - m_resx.clear(); m_resy.clear(); m_pullx.clear(); m_pully.clear(); - m_in_roll.clear(); m_in_chamber.clear(); m_in_layer.clear(); m_in_strip.clear(); - m_in_globalPhi.clear(); m_in_globalEta.clear(); m_in_nearGemPhi.clear(); m_in_nearGemEta.clear(); m_in_nearGemFirstStrip.clear(); - - edm::RefToBase muRef = muons->refAt(i); - const reco::Muon* mu = muRef.get(); - - if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) - m_quality = 2; - else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) - m_quality = 1; - else - m_quality = 0; - - const reco::Track* muonTrack = 0; - if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - if (muonTrack) { - - std::set detLists; - - reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - bool onDet = false; - - // prepropagate to near the GEM region, to speedup per/etapart prop. w/o loss of generatlity - // TrajectoryStateOnSurface tsos_ = propagator->propagate(ttTrack.outermostMeasurementState(), - // GEMGeometry_->etaPartitions()[0]->surface()); - // if (!tsos_.isValid()) continue; - - // GlobalPoint tsosGP = tsos.globalPosition(); - - for (auto ch : GEMGeometry_->etaPartitions()) { - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), - ch->surface()); - if (!tsos.isValid()) continue; - - GlobalPoint tsosGP = tsos.globalPosition(); - const LocalPoint pos = ch->toLocal(tsosGP); - const LocalPoint pos2D(pos.x(), pos.y(), 0); - const BoundPlane& bps(ch->surface()); - h_globalPosOnGem->Fill(tsosGP.x(), tsosGP.y()); - - if (bps.bounds().inside(pos2D)) { - m_nbounds++; - onDet = true; - auto gemid = ch->id(); - h_inEta[gemid.chamber()][gemid.layer()]->Fill(gemid.roll()); - m_in_roll.push_back(gemid.roll()); - m_in_chamber.push_back(gemid.chamber()); - m_in_layer.push_back(gemid.layer()); - m_in_strip.push_back((int)(ch->strip(pos))); - - m_in_globalPhi.push_back(tsosGP.phi()); - m_in_globalEta.push_back(tsosGP.eta()); - - float gemEta = +99.0, gemPhi = +99.0; - int gemRoll = -9, gemFirstStrip = -9, gemClusterSize = -9; - - - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - if (rId != gemid) continue; - - auto recHitsRange = gemRecHits->get(rId); - auto gemRecHit = recHitsRange.first; - for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - auto gemGlob = ch->toGlobal(hit->localPosition()); - - // pick closest hit - if (fabs(gemGlob.phi() - tsosGP.phi()) < gemPhi) { - gemPhi = gemGlob.phi(); - gemEta = gemGlob.eta(); - gemRoll = rId.roll(); - gemFirstStrip = hit->firstClusterStrip(); - gemClusterSize = hit->clusterSize(); - } - - // h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); - // h_firstStrip[rId.chamber()][rId.layer()]->Fill(hit->firstClusterStrip(), rId.roll()); - // h_clusterSize->Fill(hit->clusterSize()); - // h_bxtotal->Fill(hit->BunchX()); - } - } - } - m_in_nearGemPhi.push_back(gemPhi); - m_in_nearGemEta.push_back(gemEta); - m_in_nearGemRoll.push_back(gemRoll); - m_in_nearGemFirstStrip.push_back(gemFirstStrip); - m_in_nearGemClusterSize.push_back(gemClusterSize); - if (gemFirstStrip != -9) { - cout << " strip: " << gemFirstStrip << " VFAT: " << int(gemFirstStrip/128) << " X: " << ch->centreOfStrip(gemFirstStrip).x() << " phi: " << ch->toGlobal(ch->centreOfStrip(gemFirstStrip)).phi()<< endl; - cout << gemPhi << " " << tsosGP.phi() << endl; - } - - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ((*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - if ((*hit)->rawId() == ch->id().rawId() ) { - GEMDetId gemid((*hit)->geographicalId()); - auto etaPart = GEMGeometry_->etaPartition(gemid); - // cout << "found it "<< gemid - // << " lp " << (*hit)->localPosition() - // << " gp " << etaPart->toGlobal((*hit)->localPosition()) - // << endl; - } - } - } - } - } - - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - GEMDetId gemid((*hit)->geographicalId()); - h_trkEta[gemid.chamber()][gemid.layer()]->Fill(gemid.roll()); - } - } - - if (onDet) ++nGEMFiducialMuon; - - if (muonTrack->hitPattern().numberOfValidMuonGEMHits()) { - ++b_nMuonsWithGEMHit; - ++nGEMTrackWithMuon; - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - GEMDetId gemid((*hit)->geographicalId()); - auto etaPart = GEMGeometry_->etaPartition(gemid); - - m_nhits++; - - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),etaPart->surface()); - if (!tsos.isValid()) continue; - // GlobalPoint tsosGP = tsos.globalPosition(); - - m_nvalidhits++; - - LocalPoint && tsos_localpos = tsos.localPosition(); - LocalError && tsos_localerr = tsos.localError().positionError(); - LocalPoint && dethit_localpos = (*hit)->localPosition(); - LocalError && dethit_localerr = (*hit)->localPositionError(); - auto res_x = (dethit_localpos.x() - tsos_localpos.x()); - auto res_y = (dethit_localpos.y() - tsos_localpos.y()); - auto pull_x = (dethit_localpos.x() - tsos_localpos.x()) / - std::sqrt(dethit_localerr.xx() + tsos_localerr.xx()); - auto pull_y = (dethit_localpos.y() - tsos_localpos.y()) / - std::sqrt(dethit_localerr.yy() + tsos_localerr.yy()); - - h_res_x->Fill(res_x); - h_res_y->Fill(res_y); - h_pull_x->Fill(pull_x); - h_pull_y->Fill(pull_y); - - m_roll.push_back(gemid.roll()); - m_chamber.push_back(gemid.chamber()); - m_layer.push_back(gemid.layer()); - auto gemhit = static_cast(*hit); - m_strip.push_back((int) (etaPart->strip(dethit_localpos))); - - m_resx.push_back(res_x); - m_resy.push_back(res_y); - m_pullx.push_back(pull_x); - m_pully.push_back(pull_y); - - int isvalid = (*hit)->isValid(); - auto mup = tsos.globalMomentum(); - muHits[static_cast(*hit)] = {muonQuality: m_quality, - mu_phi: mup.phi(), mu_eta: mup.eta(), mu_pt: mup.perp(), - pull_x: pull_x, pull_y: pull_y, - res_x: res_x, res_y: res_y, valid: isvalid}; - } - } - } - } - - if (m_nhits > 0 or m_nbounds > 0) { - m_pt = mu->pt(); - m_eta = mu->eta(); - m_phi = mu->phi(); - t_muon->Fill(); - } - } // Muon Loop - - int totalStrips = 0; - - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - - auto recHitsRange = gemRecHits->get(rId); - auto gemRecHit = recHitsRange.first; - for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - - h_hitEta[rId.chamber()][rId.layer()]->Fill(rId.roll()); - h_firstStrip[rId.chamber()][rId.layer()]->Fill(hit->firstClusterStrip(), rId.roll()); - h_clusterSize->Fill(hit->clusterSize()); - h_bxtotal->Fill(hit->BunchX()); - for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { - totalStrips++; - h_allStrips[rId.chamber()][rId.layer()]->Fill(nstrip, rId.roll()); - } - - b_firstStrip = hit->firstClusterStrip(); - b_bx = hit->BunchX(); - b_nStrips = hit->clusterSize(); - b_chamber = rId.chamber(); - b_layer = rId.layer(); - b_etaPartition = rId.roll(); - b_muonQuality = -1; - b_pull_x = -99; - b_pull_y = -99; - b_res_x = -99; - b_res_y = -99; - b_valid = -1; - b_mu_phi = b_mu_eta = b_mu_pt = -99; - for (const auto & kv : muHits) { - auto muHit = kv.first; - if (*hit == *muHit) { - auto assoc = kv.second; - b_muonQuality = assoc.muonQuality; - b_pull_x = assoc.pull_x; - b_pull_y = assoc.pull_y; - b_res_x = assoc.res_x; - b_res_y = assoc.res_y; - b_valid = assoc.valid; - b_mu_eta = assoc.mu_eta; - b_mu_phi = assoc.mu_phi; - b_mu_pt = assoc.mu_pt; - } - } - - auto globalPosition = roll->toGlobal(hit->localPosition()); - b_x = globalPosition.x(); - b_y = globalPosition.y(); - b_z = globalPosition.z(); - - t_hit->Fill(); - b_nGEMHits++; - } - } - } - h_totalStrips->Fill(totalStrips); - - t_event->Fill(); -} - -void SliceTestAnalysis::beginJob(){} -void SliceTestAnalysis::endJob(){} - -void SliceTestAnalysis::beginRun(Run const& run, EventSetup const&){ - b_run = run.run(); - t_run->Fill(); -} -void SliceTestAnalysis::endRun(Run const&, EventSetup const&){} - -//define this as a plug-in -DEFINE_FWK_MODULE(SliceTestAnalysis); diff --git a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc b/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc deleted file mode 100644 index ea224e75cc4..00000000000 --- a/MuonAnalyser/plugins/SliceTestBkgAnalysis.cc +++ /dev/null @@ -1,564 +0,0 @@ -// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// cd ../../.. && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// system include files -#include -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -#include "DataFormats/Scalers/interface/LumiScalers.h" -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -//#include "DataFormats/MuonData/interface/MuonDigiCollection.h" -//#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -//#include "DataFormats/GEMDigi/interface/GEMAMCdataCollection.h" -//#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -//#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" - -//Libraries for Geometry -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonTopologies/interface/StripTopology.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" - -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" - -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/CSCGeometry/interface/CSCLayer.h" -#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" -#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" - -//Libraries for tracking -#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" -#include "FWCore/Framework/interface/LuminosityBlock.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TString.h" -#include "TGraphAsymmErrors.h" -#include "TLorentzVector.h" -#include "TTree.h" - -using namespace std; -using namespace edm; - -class SliceTestBkgAnalysis : public edm::EDAnalyzer { -public: - explicit SliceTestBkgAnalysis(const edm::ParameterSet&); - ~SliceTestBkgAnalysis(); - -private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() override; - virtual void endJob() override; - - virtual void beginRun(Run const&, EventSetup const&) override; - virtual void endRun(Run const&, EventSetup const&) override; - - virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; - virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) override; - - const GEMEtaPartition* findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP); - - // ----------member data --------------------------- - edm::EDGetTokenT gemRecHits_; - //edm::EDGetTokenT cscSegments_; - //edm::EDGetTokenT gemDigis_; - //edm::EDGetTokenT > muons_; - //edm::EDGetTokenT vertexCollection_; - edm::EDGetTokenT lumiScalers_; - //edm::EDGetTokenT amcData_; - //edm::EDGetTokenT gebStatusCol_; - //edm::EDGetTokenT vfatStatusCol_; - edm::Service fs; - //edm::EDGetTokenT cscRecHits_; - //edm::EDGetTokenT gemDigisvfat_; - - MuonServiceProxy* theService_; - edm::ESHandle ttrackBuilder_; - edm::ESHandle bField_; - //edm::Handle amcData; - //edm::Handle gebStatusCol; - //edm::Handle vfatStatusCol; - - TH2D* h_allStrips[36][2]; - TH2D* h_allStrips_[36][2]; - - TH2D* h_activeLumi; - TH2D* h_activeLumi_; - TH1D* h_lumiStatus; - - TH1D* h_clusterSize, *h_totalStrips, *h_bxtotal; - - TH1D* h_res_x, *h_res_y, *h_pull_x, *h_pull_y; - - TTree *t_setup; - float b_stripLength[2][8]; - float b_stripPitch[2][8]; - float b_etaPosR[2][8]; - //float b_cscArea; - - TTree *t_run; - - TTree *t_event; - int b_run, b_lumi, b_latency; - int b_nGEMHits, b_nCSCHits, b_nMuons; - float b_instLumi, b_pileup; - unsigned int b_timeLow, b_timeHigh; - int b_vfatQuality[36][2][24]; - - TTree *t_hit; - int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition; - float b_x, b_y, b_z, b_eta, b_mag; - - TTree *t_muon; - bool b_isValid; - int b_id; - float b_pt, b_phi; - float b_resX, b_resY, b_resPhi; - float b_pullX, b_pullY; - - TTree *t_csc; - -}; - -SliceTestBkgAnalysis::SliceTestBkgAnalysis(const edm::ParameterSet& iConfig) -{ - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - //gemDigisvfat_ = consumes(iConfig.getParameter("gemDigisvfat")); - //vertexCollection_ = consumes(iConfig.getParameter("vertexCollection")); - //amcData_ = consumes(iConfig.getParameter("amcData")); - //gebStatusCol_ = consumes(iConfig.getParameter("gebStatusCol")); - //vfatStatusCol_ = consumes(iConfig.getParameter("vfatStatusCol")); - lumiScalers_ = consumes(iConfig.getParameter("lumiScalers")); - edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - theService_ = new MuonServiceProxy(serviceParameters); - - h_clusterSize=fs->make(Form("clusterSize"),"clusterSize",100,0,100); - h_totalStrips=fs->make(Form("totalStrips"),"totalStrips",200,0,200); - h_bxtotal=fs->make(Form("bx"),"bx",1000,0,1000); - - - t_run = fs->make("Run", "Run"); - t_run->Branch("run", &b_run, "run/I"); - - t_setup = fs->make("Setup", "Setup"); - t_setup->Branch("stripLength", &b_stripLength, "stripLength[2][8]/F"); - t_setup->Branch("stripPitch", &b_stripPitch, "stripPitch[2][8]/F"); - t_setup->Branch("etaPosR", &b_etaPosR, "etaPosR[2][8]/F"); - //t_setup->Branch("cscArea", &b_cscArea, "cscArea/F"); - - t_event = fs->make("Event", "Event"); - t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); - t_event->Branch("nCSCHits", &b_nCSCHits, "nCSCHits/I"); - t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); - t_event->Branch("run", &b_run, "run/I"); - t_event->Branch("lumi", &b_lumi, "lumi/I"); - t_event->Branch("latency", &b_latency, "latency/I"); - t_event->Branch("instLumi", &b_instLumi, "instLumi/F"); - t_event->Branch("timeLow", &b_timeLow, "timeLow/i"); - t_event->Branch("timeHigh", &b_timeHigh, "timeHigh/i"); - t_event->Branch("vfatQuality", b_vfatQuality, "vfatQuality[36][2][24]/I"); - - t_hit = fs->make("Hit", "Hit"); - t_hit->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - t_hit->Branch("nStrips", &b_nStrips, "nStrips/I"); - t_hit->Branch("chamber", &b_chamber, "chamber/I"); - t_hit->Branch("layer", &b_layer, "layer/I"); - t_hit->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - t_hit->Branch("x", &b_x, "x/F"); - t_hit->Branch("y", &b_y, "y/F"); - t_hit->Branch("z", &b_z, "z/F"); - t_hit->Branch("eta", &b_eta, "eta/F"); - t_hit->Branch("mag", &b_mag, "mag/F"); - - //t_csc = fs->make("CSC", "CSC"); - //t_csc->Branch("chamber", &b_chamber, "chamber/I"); - //t_csc->Branch("layer", &b_layer, "layer/I"); - - //t_muon = fs->make("muon", "muon"); - //t_muon->Branch("firstStrip", &b_firstStrip, "firstStrip/I"); - //t_muon->Branch("nStrips", &b_nStrips, "nStrips/I"); - //t_muon->Branch("chamber", &b_chamber, "chamber/I"); - //t_muon->Branch("layer", &b_layer, "layer/I"); - //t_muon->Branch("etaPartition", &b_etaPartition, "etaPartition/I"); - //t_muon->Branch("id", &b_id, "id/I"); - //t_muon->Branch("pt", &b_pt, "pt/F"); - //t_muon->Branch("eta", &b_eta, "eta/F"); - //t_muon->Branch("phi", &b_phi, "phi/F"); - //t_muon->Branch("resX", &b_resX, "resX/F"); - //t_muon->Branch("resY", &b_resY, "resY/F"); - //t_muon->Branch("resPhi", &b_resPhi, "resPhi/F"); - //t_muon->Branch("isValid", &b_isValid, "isValid/O"); - - -} - -SliceTestBkgAnalysis::~SliceTestBkgAnalysis() -{ - t_setup->Fill(); -} - -void -SliceTestBkgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - b_run = iEvent.run(); - b_lumi = iEvent.luminosityBlock(); - - b_nGEMHits = 0; - b_nCSCHits = 0; - b_nMuons = 0; - - for (int ch = 0; ch < 36; ch++) { - for (int ly = 0; ly < 2; ly++) { - for (int vfat = 0; vfat < 24; vfat++) { - b_vfatQuality[ch][ly][vfat] = -1; - } - } - } - - edm::ESHandle hGEMGeom; - iSetup.get().get(hGEMGeom); - const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - - //edm::ESHandle hCSCGeom; - //iSetup.get().get(hCSCGeom); - //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; - - edm::Handle gemRecHits; - iEvent.getByToken(gemRecHits_, gemRecHits); - - //edm::Handle cscSegments; - //iEvent.getByToken(cscSegments_, cscSegments); - - //iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - //theService_->update(iSetup); - //auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - - //edm::Handle vertexCollection; - //iEvent.getByToken( vertexCollection_, vertexCollection ); - //if(vertexCollection.isValid()) { - // vertexCollection->size(); - //} - - edm::Handle lumiScalers; - iEvent.getByToken( lumiScalers_, lumiScalers ); - - //Handle > muons; - //iEvent.getByToken(muons_, muons); - - //edm::Handle gemDigisvfat; - //iEvent.getByToken(gemDigisvfat_, gemDigisvfat); - - //edm::Handle cscRecHits; - //iEvent.getByToken(cscRecHits_, cscRecHits); - //iEvent.getByToken(amcData_, amcData); - //iEvent.getByToken(gebStatusCol_, gebStatusCol); - //iEvent.getByToken(vfatStatusCol_, vfatStatusCol); - - int totalStrips = 0; - auto instLumi = (lumiScalers->at(0)).instantLumi()/10000; - h_lumiStatus->Fill(instLumi); - b_instLumi = instLumi; - b_pileup = (lumiScalers->at(0)).pileup(); - b_timeHigh = iEvent.time().unixTime(); - b_timeLow = iEvent.time().microsecondOffset(); - - b_latency = -1; - - //for (auto g : *amcData) { - // for (auto a = g.second.first; a != g.second.second; ++a) { - // if (b_latency != -1 && b_latency != a->param1()) - // std::cout << "CHANGING LATENCY - old: " << b_latency << " new: " << a->param1() << std::endl; - // b_latency = a->param1(); - // if (b_latency == -1) std::cout << "-1 LATENCY VALUE - " << iEvent.id().event() << " " << iEvent.id().run() << std::endl; - // } - //} - - //for (size_t i = 0; i < muons->size(); ++i) { - // edm::RefToBase muRef = muons->refAt(i); - // const reco::Muon* mu = muRef.get(); - - // const reco::Track* muonTrack = 0; - // if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - // else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - // if (muonTrack) { - // b_pt = muonTrack->pt(); - // b_eta = muonTrack->eta(); - // b_phi = muonTrack->phi(); - // if (b_eta < -2.15 or b_eta > -1.6) continue; - // t_muon->Fill(); - // b_nMuons++; - // } - //} - - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - - auto recHitsRange = gemRecHits->get(rId); - auto gemRecHit = recHitsRange.first; - b_chamber = rId.chamber(); - b_layer = rId.layer(); - b_etaPartition = rId.roll(); - - //auto vfats = vfatStatusCol->get(rId); - //int index = 0; - //for (auto vfat = vfats.first; vfat != vfats.second; ++vfat) { - // int vfatNu = (8-b_etaPartition)+8*(index); - // b_vfatQuality[b_chamber-1][b_layer-1][vfatNu] = vfat->quality(); - // index++; - //} - - for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) { - - h_clusterSize->Fill(hit->clusterSize()); - h_bxtotal->Fill(hit->BunchX()); - - for (int nstrip = hit->firstClusterStrip(); nstrip < hit->firstClusterStrip()+hit->clusterSize(); ++nstrip) { - totalStrips++; - h_allStrips[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); - h_allStrips_[rId.chamber()-1][rId.layer()-1]->Fill(nstrip, rId.roll()); - } - - b_firstStrip = hit->firstClusterStrip(); - b_nStrips = hit->clusterSize(); - - int vfat = (8-b_etaPartition)+8*((b_firstStrip-1)/128); - float vfatNu = b_chamber+(b_layer-1)/2.+vfat/48.; - h_activeLumi->Fill(b_lumi, vfatNu); - - auto globalPosition = roll->toGlobal(hit->localPosition()); - b_x = globalPosition.x(); - b_y = globalPosition.y(); - b_z = globalPosition.z(); - b_eta = globalPosition.eta(); - b_mag = globalPosition.mag(); - - t_hit->Fill(); - b_nGEMHits++; - } - - //auto gemVfatRange = gemDigisvfat->get(rId); - // - //for (auto vfatStatus = gemVfatRange.first; vfatStatus != gemVfatRange.second; vfatStatus++) { - // auto ix = vfatStatus->position(); - // int vfat = 8-b_etaPartition+8*ix; - // bool flag = int(vfatStatus->flag()) != 0; - // flag = int(vfatStatus->quality()) != 0; - // if (!flag) h_activeLumi_->Fill(b_lumi, b_chamber+(b_layer-1)/2.+vfat/48.); - //} - } - } - - //for (size_t i = 0; i < muons->size(); ++i) { - - // edm::RefToBase muRef = muons->refAt(i); - // const reco::Muon* mu = muRef.get(); - - // // muon id - // int muonId = 0; - // if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; - // else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; - - // // tight and pt > 20 muon only - // //if (muonId != 2) continue; - // //if (mu->pt() < 20) continue; - // - // const reco::Track* muonTrack = 0; - // if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - // else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - // if (!muonTrack) continue; - // else { - // b_id = muonId; - // b_pt = muonTrack->pt(); - // b_eta = muonTrack->eta(); - // b_phi = muonTrack->phi(); - // } - - // reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - // for (auto chamber : GEMGeometry_->chambers()) { - // b_isValid = false; - // if (chamber->id().chamber() == 1) continue; // ignore chammber 1 - // if (mu->eta() * chamber->id().region() < 0 ) continue; - - // TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(),chamber->surface()); - // if (!tsos.isValid()) continue; - - // GlobalPoint tsosGP = tsos.globalPosition(); - // auto etaPart = findEtaPartition(chamber, tsosGP); - // if (!etaPart) continue; - - // auto gemid = etaPart->id(); - // auto locPos = etaPart->toLocal(tsosGP); - // auto strip = (int) etaPart->strip(locPos); - // - // b_chamber = gemid.chamber(); - // b_layer = gemid.layer(); - // b_etaPartition = gemid.roll(); - - // //Find hit - // b_resX = 999; - // GEMRecHit closestHit; - // auto recHitsRange = gemRecHits->get(gemid); - // for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { - // LocalPoint hitLocPos = hit->localPosition(); - // if ( fabs(hitLocPos.x() - locPos.x()) < fabs(b_resX) ) { - // b_resX = hitLocPos.x() - locPos.x(); - // closestHit = (*hit); - // } - // } - // if (b_resX != 999) { //We could not find hit associated with muon - // auto hitLocPos = closestHit.localPosition(); - // auto hitGlobPos = etaPart->toGlobal(hitLocPos); - // b_firstStrip = closestHit.firstClusterStrip(); - // b_nStrips = closestHit.clusterSize(); - // b_resY = hitLocPos.y() - locPos.y(); - // b_resPhi = hitGlobPos.phi() - tsosGP.phi(); - - // LocalError && locErr = tsos.localError().positionError(); - // LocalError && hitLocErr = closestHit.localPositionError(); - // b_pullX = b_resX / std::sqrt(hitLocErr.xx() + locErr.xx()); - // b_pullY = b_resY / std::sqrt(hitLocErr.yy() + locErr.yy()); - - // b_isValid = true; - // } - // - // t_muon->Fill(); - // b_nMuons++; - // } - //} - //for (auto ch : CSCGeometry_->chambers()) { - // CSCDetId cId = ch->id(); - // // Selection for CSC chambers are in same regime with GEMINI - // if (cId.station() != 1) continue; - // if (cId.endcap() != 2) continue; - // if (cId.chamber() < 27 or cId.chamber() > 30) continue; - - // auto segmentsRange = cscSegments->get(cId); - // auto cscSegment = segmentsRange.first; - // - // for (auto hit = cscSegment; hit != segmentsRange.second; ++hit) { - // b_chamber = cId.chamber(); - - // t_csc->Fill(); - // b_nCSCHits++; - // } - //} - - h_totalStrips->Fill(totalStrips); - - t_event->Fill(); -} - -const GEMEtaPartition* SliceTestBkgAnalysis::findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP){ - for (auto etaPart : chamber->etaPartitions()) { - const LocalPoint locPos = etaPart->toLocal(tsosGP); - const LocalPoint locPos2D(locPos.x(), locPos.y(), 0); - const BoundPlane& bps(etaPart->surface()); - if (!bps.bounds().inside(locPos2D)) continue; - return etaPart; - } - return nullptr; -} - -void SliceTestBkgAnalysis::beginJob(){} -void SliceTestBkgAnalysis::endJob(){} - -void SliceTestBkgAnalysis::beginRun(Run const& run, EventSetup const& iSetup){ - for (int ichamber=26; ichamber<30;++ichamber) { - // for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=0; ilayer<2;++ilayer) { - h_allStrips_[ichamber][ilayer] = fs->make(Form("%i ch %i lay %i", run.run(), ichamber+1, ilayer+1),"",384,0.5,384.5,8,0.5,8.5); - h_allStrips_[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_allStrips_[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - } - } - - - edm::ESHandle hGEMGeom; - iSetup.get().get(hGEMGeom); - const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - - //edm::ESHandle hCSCGeom; - //iSetup.get().get(hCSCGeom); - //const CSCGeometry* CSCGeometry_ = &*hCSCGeom; - - h_activeLumi = fs->make(Form("%i active lumi", run.run()),Form("Run number %i", run.run()),3000, 0, 3000, 400, 27, 31); - h_activeLumi_ = fs->make(Form("%i active lumi_", run.run()),Form("Run number %i", run.run()),3000, 0, 3000, 400, 27, 31); - - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - GEMDetId rId = roll->id(); - - const TrapezoidalStripTopology* top_(dynamic_cast(&(roll->topology()))); - const float striplength(top_->stripLength()); - const float pitch(roll->pitch()); - auto centrePosition = roll->toGlobal(roll->centreOfStrip(192)); - - b_stripLength[rId.chamber()%2][rId.roll()-1] = striplength; - b_stripPitch[rId.chamber()%2][rId.roll()-1] = pitch; - b_etaPosR[rId.chamber()%2][rId.roll()-1] = sqrt(pow(centrePosition.x(), 2) + pow(centrePosition.y(), 2)); - } - } - - //for (auto ch : CSCGeometry_->chambers()) { - // for (auto layer : ch->layers()) { - // CSCDetId lId = layer->id(); - // if (lId.station() != 1) continue; - // if (lId.endcap() != 2) continue; - // if (lId.chamber() < 27 or lId.chamber() > 30) continue; - - // const RadialStripTopology* top_(dynamic_cast(&(layer->topology()))); - // const float striplength(top_->stripLength()); - // const float pitch(layer->geometry()->stripPitch()); - // b_cscArea = striplength * pitch * top_->nstrips(); - // } - //} - - b_run = run.run(); - t_run->Fill(); -} -void SliceTestBkgAnalysis::endRun(Run const&, EventSetup const&){} - -void SliceTestBkgAnalysis::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){ - for (int ichamber=26; ichamber<30;++ichamber) { - // for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=0; ilayer<2;++ilayer) { - h_allStrips[ichamber][ilayer] = fs->make(Form("%i %i ch %i lay %i",lumiBlock.run(), lumiBlock.luminosityBlock(), ichamber+1, ilayer+1),"",384,0.5,384.5,8,0.5,8.5); - h_allStrips[ichamber][ilayer]->GetXaxis()->SetTitle("strip"); - h_allStrips[ichamber][ilayer]->GetYaxis()->SetTitle("iEta"); - } - } - - h_lumiStatus = fs->make(Form("%i %i status", lumiBlock.run(), lumiBlock.luminosityBlock()), "", 1000, 0, 2); -} -void SliceTestBkgAnalysis::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& iSetup){} - -//define this as a plug-in -DEFINE_FWK_MODULE(SliceTestBkgAnalysis); diff --git a/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc b/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc deleted file mode 100644 index 9521d90cddd..00000000000 --- a/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc +++ /dev/null @@ -1,388 +0,0 @@ -// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 -// system include files -#include -#include -#include -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Geometry/CommonTopologies/interface/StripTopology.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "DataFormats/Math/interface/deltaPhi.h" -#include "DataFormats/MuonData/interface/MuonDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Run.h" - -#include "EventFilter/Utilities/interface/json.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TString.h" -#include "TGraphAsymmErrors.h" -#include "TLorentzVector.h" -#include "TTree.h" - -using namespace std; -using namespace edm; - -class SliceTestEfficiencyAnalysis : public edm::EDAnalyzer { -public: - explicit SliceTestEfficiencyAnalysis(const edm::ParameterSet&); - ~SliceTestEfficiencyAnalysis(); - -private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() override; - virtual void endJob() override; - - virtual void beginRun(Run const&, EventSetup const&) override; - virtual void endRun(Run const&, EventSetup const&) override; - - const GEMEtaPartition* findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP); - - // ----------member data --------------------------- - edm::EDGetTokenT gemRecHits_; - edm::EDGetTokenT > muons_; - edm::EDGetTokenT vertexCollection_; - //edm::EDGetTokenT> gemDigis_; - edm::Service fs; - - double Latency_; - - MuonServiceProxy* theService_; - edm::ESHandle propagator_; - edm::ESHandle ttrackBuilder_; - edm::ESHandle bField_; - - static const int MAXCHAMBERS = 36; - static const int MAXLAYERS = 2; - static const int MAXROLL = 8; - - int nGEMHitInMuontrack; - - TH1D* h_nGEMHitInMuontrack; - TH2D* h_inMap; - TH2D* h_hitMap; - - TH2D* h_hitLumiMap[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_stripLumiMap[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_inRoll[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_inStrip[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inVfat[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inPos[MAXCHAMBERS][MAXLAYERS]; - - TH1D* h_hitRoll[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_hitStrip[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_hitVfat[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_hitPos[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_hitNstrip[MAXCHAMBERS][MAXLAYERS][MAXROLL]; - TH1D* h_resX_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; - TH1D* h_resY_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; - TH1D* h_resPhi_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; - TH1D* h_resX_xPart[MAXCHAMBERS][MAXLAYERS][3]; - TH1D* h_resY_xPart[MAXCHAMBERS][MAXLAYERS][3]; - TH1D* h_resPhi_xPart[MAXCHAMBERS][MAXLAYERS][3]; - - TH1D* h_resX[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_resY[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_resPhi[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_resXvsNstrip[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_pullX[MAXCHAMBERS][MAXLAYERS]; - TH1D* h_pullY[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inPos_matched[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inPhiVsHitPhi[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inXVsHitX[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inStripVsHitStrip[MAXCHAMBERS][MAXLAYERS]; - TH2D* h_inPhiVsHitStrip[MAXCHAMBERS][MAXLAYERS]; - - int b_run, b_lumi; - int nEvents; - int b_nMuons, b_nMuonsInGEMRegion, b_nGEMHits; - int b_latency; - - TTree *t_event; -}; - -SliceTestEfficiencyAnalysis::SliceTestEfficiencyAnalysis(const edm::ParameterSet& iConfig) : - nEvents(0) -{ - gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); - muons_ = consumes >(iConfig.getParameter("muons")); - edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - //gemDigis_ = consumes>(iConfig.getParameter("gemDigis")); - theService_ = new MuonServiceProxy(serviceParameters); - Latency_ = iConfig.getParameter("latency"); - - t_event = fs->make("Event", "Event"); - t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); - t_event->Branch("nMuonsInGEMRegion", &b_nMuonsInGEMRegion, "nMuonsInGEMRegion/I"); - t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); - t_event->Branch("run", &b_run, "run/I"); - t_event->Branch("lumi", &b_lumi, "lumi/I"); - t_event->Branch("latency", &b_latency, "latency/I"); - - h_nGEMHitInMuontrack = fs->make(Form("nGEMHitInMuontrack"),"nGEMHitInMuontrack",4,0,4); - h_inMap = fs->make(Form("inMap"),"inMap",18,26.5,31,18,0,9); - h_hitMap = fs->make(Form("hitMap"),"hitMap",18,26.5,31,18,0,9); - for (int ichamber=27; ichamber<=30;++ichamber) { - for (int ilayer=0; ilayermake(Form("hitLumiMap ch %i lay %i",ichamber, ilayer+1),"hitLumiMap",700,0,700,32,1,9); - h_stripLumiMap[ichamber][ilayer] = fs->make(Form("stripLumiMap ch %i lay %i",ichamber, ilayer+1),"stripLumiMap",700,0,700,400,0,400); - h_inRoll[ichamber][ilayer] = fs->make(Form("inRoll ch %i lay %i",ichamber, ilayer+1),"inRoll",8,0.5,8.5); - h_inStrip[ichamber][ilayer] = fs->make(Form("inStrip ch %i lay %i",ichamber, ilayer+1),"inStrip",384,0,384); - h_inVfat[ichamber][ilayer] = fs->make(Form("inVfat ch %i lay %i",ichamber, ilayer+1),"inVfat",3,0.5,3.5,8,0.5,8.5); - h_inPos[ichamber][ilayer] = fs->make(Form("inPos ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-260,-110); - - h_hitRoll[ichamber][ilayer] = fs->make(Form("hitRoll ch %i lay %i",ichamber, ilayer+1),"hitRoll",8,0.5,8.5); - h_hitStrip[ichamber][ilayer] = fs->make(Form("hitStrip ch %i lay %i",ichamber, ilayer+1),"hitStrip",384,0,384); - h_hitVfat[ichamber][ilayer] = fs->make(Form("hitVfat ch %i lay %i",ichamber, ilayer+1),"hitVfat",3,0.5,3.5,8,0.5,8.5); - h_hitPos[ichamber][ilayer] = fs->make(Form("hitPos ch %i lay %i",ichamber, ilayer+1),"hitPos",100,-70,120,100,-260,-110); - for (int ieta=0; ietamake(Form("hitNstrip ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"hitNstrip",30,0,30); - h_resX_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resX_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resX",500,-3,3); - h_resY_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resY_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resY",500,-15,15); - h_resPhi_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resPhi_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resPhi",500,-0.03,0.03); - } - for (int xrange=0; xrange<3;++xrange) { - h_resX_xPart[ichamber][ilayer][xrange] = fs->make(Form("resX_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resX",500,-3,3); - h_resY_xPart[ichamber][ilayer][xrange] = fs->make(Form("resY_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resY",500,-15,15); - h_resPhi_xPart[ichamber][ilayer][xrange] = fs->make(Form("resPhi_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resPhi",500,-0.03,0.03); - } - - h_resX[ichamber][ilayer] = fs->make(Form("resX ch %i lay %i",ichamber, ilayer+1),"resX",500,-3,3); - h_resY[ichamber][ilayer] = fs->make(Form("resY ch %i lay %i",ichamber, ilayer+1),"resY",500,-15,15); - h_resPhi[ichamber][ilayer] = fs->make(Form("resPhi ch %i lay %i",ichamber, ilayer+1),"resPhi",500,-0.03,0.03); - h_resXvsNstrip[ichamber][ilayer] = fs->make(Form("resXvsNstrip ch %i lay %i",ichamber, ilayer+1),"resXvsNstrip",250,-3,3,15,0,15); - h_pullX[ichamber][ilayer] = fs->make(Form("pullX ch %i lay %i",ichamber, ilayer+1),"pullX",500,-3,3); - h_pullY[ichamber][ilayer] = fs->make(Form("pullY ch %i lay %i",ichamber, ilayer+1),"pullY",500,-3,3); - h_inPos_matched[ichamber][ilayer] = fs->make(Form("inPos_matched ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-260,-110); - h_inPhiVsHitPhi[ichamber][ilayer] = fs->make(Form("inPhiVsHitPhi ch %i lay %i",ichamber, ilayer+1),"inPos",100,-1.9,-1.1,100,-1.9,-1.1); - h_inXVsHitX[ichamber][ilayer] = fs->make(Form("inXVsHitX ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-70,120); - h_inStripVsHitStrip[ichamber][ilayer] = fs->make(Form("inStripVsHitStrip ch %i lay %i",ichamber, ilayer+1),"inPos",400,0,400,400,0,400); - h_inPhiVsHitStrip[ichamber][ilayer] = fs->make(Form("inPhiVsHitStrip ch %i lay %i",ichamber, ilayer+1),"inPos",100,-1.9,-1.1,400,0,400); - } - } -} - -SliceTestEfficiencyAnalysis::~SliceTestEfficiencyAnalysis(){} - -void -SliceTestEfficiencyAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - nEvents++; - - b_nMuons = 0; - b_nMuonsInGEMRegion = 0; - b_nGEMHits = 0; - - b_run = iEvent.run(); - b_lumi = iEvent.luminosityBlock(); - - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const GEMGeometry* GEMGeometry_ = &*hGeom; - - iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); - theService_->update(iSetup); - auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); - - edm::Handle gemRecHits; - iEvent.getByToken(gemRecHits_, gemRecHits); - - Handle > muons; - iEvent.getByToken(muons_, muons); - - /* - edm::Handle> gemDigis; - iEvent.getByToken(gemDigis_, gemDigis); - - b_latency = -1; - for (auto g : *gemDigis) { - for (auto a = g.second.first; a != g.second.second; ++a) { - b_latency = a->Param1(); - } - } - //if (b_latency != Latency_) return; - */ - - if (b_run != 319347) return; - if ( (b_lumi <50) - || (b_lumi>210 && b_lumi<240) - || (b_lumi>640) ) return; - - for (auto ch : GEMGeometry_->chambers()) { - for(auto roll : ch->etaPartitions()) { - auto rId = roll->id(); - auto recHitsRange = gemRecHits->get(rId); - b_nGEMHits += recHitsRange.second - recHitsRange.first; - for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { - int vfat = hit->firstClusterStrip()/128 +1; - h_hitLumiMap[rId.chamber()][rId.layer()-1]->Fill(b_lumi,rId.roll()+vfat/4.); - h_stripLumiMap[rId.chamber()][rId.layer()-1]->Fill(b_lumi,hit->firstClusterStrip()); - } - } - } - //if (b_nGEMHits == 0) continue; - - for (size_t i = 0; i < muons->size(); ++i) { - - edm::RefToBase muRef = muons->refAt(i); - const reco::Muon* mu = muRef.get(); - - // muon id - int muonId = 0; - if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; - else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; - - // tight and pt > 20 muon only - if (muonId != 2) continue; - if (mu->pt() < 20) continue; - - const reco::Track* muonTrack = 0; - if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); - else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); - if (!muonTrack) continue; - b_nMuons++; - - nGEMHitInMuontrack = 0; - for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { - if ((*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { - nGEMHitInMuontrack++; - } - } - h_nGEMHitInMuontrack->Fill(nGEMHitInMuontrack); - - reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); - for (auto chamber : GEMGeometry_->chambers()) { - if (chamber->id().chamber() == 1) continue; // ignore chammber 1 - if (mu->eta() * chamber->id().region() < 0 ) continue; - - TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), - chamber->surface()); - if (!tsos.isValid()) continue; - - GlobalPoint tsosGP = tsos.globalPosition(); - auto etaPart = findEtaPartition(chamber, tsosGP); - if (!etaPart) continue; - - auto gemid = etaPart->id(); - auto locPos = etaPart->toLocal(tsosGP); - auto strip = (int) etaPart->strip(locPos); - auto vfat = ((int) strip/128)+1; - - h_inRoll[gemid.chamber()][gemid.layer()-1]->Fill(gemid.roll()); - h_inStrip[gemid.chamber()][gemid.layer()-1]->Fill(strip); - h_inVfat[gemid.chamber()][gemid.layer()-1]->Fill(vfat, gemid.roll()); - h_inPos[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), tsosGP.y()); - h_inMap->Fill(gemid.chamber()+gemid.layer()/2., gemid.roll()); - - //Find hit - float resX = 999; - GEMRecHit closestHit; - auto recHitsRange = gemRecHits->get(gemid); - for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { - LocalPoint hitLocPos = hit->localPosition(); - if ( fabs(hitLocPos.x() - locPos.x()) < fabs(resX) ) { - resX = hitLocPos.x() - locPos.x(); - closestHit = (*hit); - } - } - if (resX == 999) continue; - auto hitLocPos = closestHit.localPosition(); - auto hitGlobPos = etaPart->toGlobal(hitLocPos); - auto hitStrip = closestHit.firstClusterStrip(); - auto resY = hitLocPos.y() - locPos.y(); - auto resPhi = hitGlobPos.phi() - tsosGP.phi(); - h_inPhiVsHitPhi[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.phi(), hitGlobPos.phi()); - h_inXVsHitX[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), hitGlobPos.x()); - h_inStripVsHitStrip[gemid.chamber()][gemid.layer()-1]->Fill(strip, hitStrip); - h_inPhiVsHitStrip[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.phi(), hitStrip); - - if (resX > 5.0) continue; - LocalError && locErr = tsos.localError().positionError(); - LocalError && hitLocErr = closestHit.localPositionError(); - auto pullX = resX / std::sqrt(hitLocErr.xx() + locErr.xx()); - auto pullY = resY / std::sqrt(hitLocErr.yy() + locErr.yy()); - - //Filling histograms - h_hitRoll[gemid.chamber()][gemid.layer()-1]->Fill(gemid.roll()); - h_hitStrip[gemid.chamber()][gemid.layer()-1]->Fill(hitStrip); - h_hitVfat[gemid.chamber()][gemid.layer()-1]->Fill(((int)hitStrip/128)+1, gemid.roll()); - h_hitPos[gemid.chamber()][gemid.layer()-1]->Fill(hitGlobPos.x(), hitGlobPos.y()); - h_hitNstrip[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(closestHit.clusterSize()); - h_hitMap->Fill(gemid.chamber()+gemid.layer()/2., gemid.roll()); - - int x = 1; - if (abs(locPos.x())<10) x = 0; - else if (abs(locPos.x())>20) x = 2; - h_resX_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resX); - h_resY_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resY); - h_resPhi_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resPhi); - h_resX_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resX); - h_resY_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resY); - h_resPhi_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resPhi); - h_resX[gemid.chamber()][gemid.layer()-1]->Fill(resX); - h_resY[gemid.chamber()][gemid.layer()-1]->Fill(resY); - h_resPhi[gemid.chamber()][gemid.layer()-1]->Fill(resPhi); - h_resXvsNstrip[gemid.chamber()][gemid.layer()-1]->Fill(resX,closestHit.clusterSize()); - h_pullX[gemid.chamber()][gemid.layer()-1]->Fill(pullX); - h_pullY[gemid.chamber()][gemid.layer()-1]->Fill(pullY); - h_inPos_matched[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), tsosGP.y()); - - } - } - t_event->Fill(); -} - -const GEMEtaPartition* SliceTestEfficiencyAnalysis::findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP){ - for (auto etaPart : chamber->etaPartitions()) { - const LocalPoint locPos = etaPart->toLocal(tsosGP); - const LocalPoint locPos2D(locPos.x(), locPos.y(), 0); - const BoundPlane& bps(etaPart->surface()); - if (!bps.bounds().inside(locPos2D)) continue; - return etaPart; - } - return nullptr; -} - -void SliceTestEfficiencyAnalysis::beginJob(){} -void SliceTestEfficiencyAnalysis::endJob(){} - -void SliceTestEfficiencyAnalysis::beginRun(Run const& run, EventSetup const&){} -void SliceTestEfficiencyAnalysis::endRun(Run const&, EventSetup const&){} - -//define this as a plug-in -DEFINE_FWK_MODULE(SliceTestEfficiencyAnalysis); diff --git a/MuonAnalyser/python/RAW2STA_SliceTest.py b/MuonAnalyser/python/RAW2STA_SliceTest.py deleted file mode 100644 index 709da45cd36..00000000000 --- a/MuonAnalyser/python/RAW2STA_SliceTest.py +++ /dev/null @@ -1,125 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_Data_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), - "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" - #"file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" - ), - secondaryFileNames = cms.untracked.vstring() -) - -#import FWCore.PythonUtilities.LumiList as LumiList -#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() -#print process.source.lumisToProcess - -process.options = cms.untracked.PSet() -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:-1'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Additional output definition - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018 Data -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -# process.reconstruction_step = cms.Path(process.reconstruction) - -# Seed generator -from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * - -# Stand alone muon track producer -from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * - -# Beam Spot -from RecoVertex.BeamSpotProducer.BeamSpot_cff import * - -process.dump=cms.EDAnalyzer('EventContentAnalyzer') - -process.reconstruction_step = cms.Path( - (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * - offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump -) - -process.endjob_step = cms.EndPath(process.endOfProcess) - -process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer('STASliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("standAloneMuons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), - lumiScalers = cms.InputTag("scalersRawToDigi"), - gemDigis = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - # vfatStatus = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), - # gebStatus = cms.InputTag("muonGEMDigis", "GEBStatus", "reRECO"), -) -process.sliceTest = cms.Path(process.SliceTestAnalysis) - -process.muonGEMDigis.unPackStatusDigis = cms.bool(True) -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step, - process.L1Reco_step, - process.reconstruction_step, - process.sliceTest, - process.endjob_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -# customisation of the process. - -# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 - -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -process = customisePostEra_Run2_2017(process) - -# End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - -# Customisation from command line - -#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule -from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands -process = customiseLogErrorHarvesterUsingOutputCommands(process) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/MuonAnalyser/test/CrabSlice.py b/MuonAnalyser/test/CrabSlice.py deleted file mode 100644 index 87971b38c4f..00000000000 --- a/MuonAnalyser/test/CrabSlice.py +++ /dev/null @@ -1,28 +0,0 @@ -from CRABClient.UserUtilities import config -config = config() - -config.General.requestName = 'GEM-SliceTestBkg-2018D' -config.General.transferLogs = True - -config.JobType.pluginName = 'Analysis' -# Name of the CMSSW configuration file -config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' - -#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' -config.Data.inputDataset = '/ZeroBias/Run2018D-v1/RAW' -config.Data.splitting = 'LumiBased' -config.Data.unitsPerJob = 10 -config.Data.publication = True -# This string is used to construct the output dataset name -config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018D' - -# These values only make sense for processing data -# Select input data based on a lumi mask -#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' -# Select input data based on run-ranges -#config.Data.runRange = '321067-321069' # v1 -config.Data.runRange = '324420,324418,324315,324314,324313,324293,324245,324237,324209,324206,324205,324202,324201,324078,324077,324021,323997,323980,323978,323976,323940,323857,323841,323794,323790,323778,323775,323755,323727,323726,323725,323702,323701,323700,323696,323693,323526,323525,323524,323523,323488,323487,323475,323474,323473,323472,323471,323470,323422,323421,323420,323419,323418,323417,323416,323415,323414,323413,323399,323398,323397,323396,323395,323394,323393,323391,323388,323367,323365,323364,323363,322633,322625,322617,322616,322605,322603,322602,322599,322492,322487,322480,322430,322407,322381,322356,322348,322332,322324,322322,322319,322317,322252,322222,322204,322201,322022,321990,321988,321975,321973,321961,321960,321917,321909,321908,321887,321880,321879,321834,321833,321832,321831,321820,321818,321817,321815,321813,321796,321795,321794,321781,321780,321778,321777,321776,321775,321774,321773,321759,321758,321755,321735,321732,321731,321730,321710,321709,321475,321461,321457,321434,321432,321431,321415,321414,321397,321396,321393,321390,321313,321312,321311,321310,321305,321218,321178,321177,321167,321166,321165,321164,321162,321149,321140,321138,321134,321126,321123,321122,321121,321119,321069,321068,321067,321055,321051' -#config.Data.runRange = '319347,319348,319349' # v2 - -# Where the output files will be transmitted to -config.Site.storageSite = 'T3_KR_KISTI' diff --git a/MuonAnalyser/test/CrabSlice_EGamma.py b/MuonAnalyser/test/CrabSlice_EGamma.py deleted file mode 100644 index f060ddc4603..00000000000 --- a/MuonAnalyser/test/CrabSlice_EGamma.py +++ /dev/null @@ -1,28 +0,0 @@ -from CRABClient.UserUtilities import config -config = config() - -config.General.requestName = 'GEM-SliceTestBkg-2018C' -config.General.transferLogs = True - -config.JobType.pluginName = 'Analysis' -# Name of the CMSSW configuration file -config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' - -#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' -config.Data.inputDataset = '/EGamma/Run2018C-v1/RAW' -config.Data.splitting = 'LumiBased' -config.Data.unitsPerJob = 10 -config.Data.publication = True -# This string is used to construct the output dataset name -config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018C' - -# These values only make sense for processing data -# Select input data based on a lumi mask -#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' -# Select input data based on run-ranges -#config.Data.runRange = '321067-321069' # v1 -config.Data.runRange = '319337' -#config.Data.runRange = '319347,319348,319349' # v2 - -# Where the output files will be transmitted to -config.Site.storageSite = 'T3_KR_KISTI' diff --git a/MuonAnalyser/test/RAW2STA_SliceTest_2018C.py b/MuonAnalyser/test/RAW2STA_SliceTest_2018C.py deleted file mode 100644 index 9169cdcd084..00000000000 --- a/MuonAnalyser/test/RAW2STA_SliceTest_2018C.py +++ /dev/null @@ -1,128 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_Data_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), - "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" -# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" - ), - secondaryFileNames = cms.untracked.vstring() -) - -#import FWCore.PythonUtilities.LumiList as LumiList -#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() -#print process.source.lumisToProcess - -process.options = cms.untracked.PSet() -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:-1'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Additional output definition - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data -process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -# process.reconstruction_step = cms.Path(process.reconstruction) - -# Seed generator -from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * - -# Stand alone muon track producer -from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * - -# Beam Spot -from RecoVertex.BeamSpotProducer.BeamSpot_cff import * - -process.dump=cms.EDAnalyzer('EventContentAnalyzer') - -process.reconstruction_step = cms.Path( - (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * - offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump -) - -process.endjob_step = cms.EndPath(process.endOfProcess) - -process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer( - 'STASliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits", "", "reRECO"), - muons = cms.InputTag("standAloneMuons", "", "reRECO"), - vertexCollection = cms.InputTag("offlinePrimaryVertices", "", "reRECO"), - lumiScalers = cms.InputTag("scalersRawToDigi", "", "reRECO"), - amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), - amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), - vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), -) -process.sliceTest = cms.Path(process.SliceTestAnalysis) - -process.muonGEMDigis.unPackStatusDigis = cms.bool(True) -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step, - process.L1Reco_step, - process.reconstruction_step, - process.sliceTest, - process.endjob_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -# customisation of the process. - -# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 - -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -process = customisePostEra_Run2_2017(process) - -# End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - -# Customisation from command line - -#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule -from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands -process = customiseLogErrorHarvesterUsingOutputCommands(process) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/MuonAnalyser/test/RAW2STA_SliceTest_2018D.py b/MuonAnalyser/test/RAW2STA_SliceTest_2018D.py deleted file mode 100644 index d26771c38e9..00000000000 --- a/MuonAnalyser/test/RAW2STA_SliceTest_2018D.py +++ /dev/null @@ -1,129 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_Data_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), - #"file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" -# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" - "file:/xrootd/store/data/Run2018D/SingleMuon/RAW/v1/000/322/430/00000/78621B29-2AB3-E811-BCC7-02163E010FA1.root" - ), - secondaryFileNames = cms.untracked.vstring() -) - -#import FWCore.PythonUtilities.LumiList as LumiList -#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() -#print process.source.lumisToProcess - -process.options = cms.untracked.PSet() -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:-1'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Additional output definition - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data -#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -# process.reconstruction_step = cms.Path(process.reconstruction) - -# Seed generator -from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * - -# Stand alone muon track producer -from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * - -# Beam Spot -from RecoVertex.BeamSpotProducer.BeamSpot_cff import * - -process.dump=cms.EDAnalyzer('EventContentAnalyzer') - -process.reconstruction_step = cms.Path( - (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * - offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump -) - -process.endjob_step = cms.EndPath(process.endOfProcess) - -process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer( - 'STASliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits", "", "reRECO"), - muons = cms.InputTag("standAloneMuons", "", "reRECO"), - vertexCollection = cms.InputTag("offlinePrimaryVertices", "", "reRECO"), - lumiScalers = cms.InputTag("scalersRawToDigi", "", "reRECO"), - amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), - amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), - vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), -) -process.sliceTest = cms.Path(process.SliceTestAnalysis) - -process.muonGEMDigis.unPackStatusDigis = cms.bool(True) -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step, - process.L1Reco_step, - process.reconstruction_step, - process.sliceTest, - process.endjob_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -# customisation of the process. - -# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 - -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -process = customisePostEra_Run2_2017(process) - -# End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - -# Customisation from command line - -#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule -from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands -process = customiseLogErrorHarvesterUsingOutputCommands(process) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py b/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py deleted file mode 100644 index 75c510eb622..00000000000 --- a/MuonAnalyser/test/RAW2STA_SliceTest_Bkg.py +++ /dev/null @@ -1,128 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_Data_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), - "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" -# "file:/cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation/step2.root" - ), - secondaryFileNames = cms.untracked.vstring() -) - -#import FWCore.PythonUtilities.LumiList as LumiList -#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() -#print process.source.lumisToProcess - -process.options = cms.untracked.PSet() -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:-1'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Additional output definition - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018D Data -process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v1', '') # Run on 2018C Data -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -# process.reconstruction_step = cms.Path(process.reconstruction) - -# Seed generator -from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * - -# Stand alone muon track producer -from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * - -# Beam Spot -from RecoVertex.BeamSpotProducer.BeamSpot_cff import * - -process.dump=cms.EDAnalyzer('EventContentAnalyzer') - -process.reconstruction_step = cms.Path( - (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * - offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump - #(process.gemRecHits + process.gemSegments) -) - -process.endjob_step = cms.EndPath(process.endOfProcess) - -process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) - -process.SliceTestBkgAnalysis = cms.EDAnalyzer('SliceTestBkgAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - #muons = cms.InputTag("muons"), - #vertexCollection = cms.InputTag("offlinePrimaryVertices"), - lumiScalers = cms.InputTag("scalersRawToDigi"), - #amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), - #amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - #gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), - #vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), -) -process.sliceTest = cms.Path(process.SliceTestBkgAnalysis) - -process.muonGEMDigis.unPackStatusDigis = cms.bool(True) -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step, - process.L1Reco_step, - process.reconstruction_step, - process.sliceTest, - process.endjob_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -# customisation of the process. - -# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 - -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -process = customisePostEra_Run2_2017(process) - -# End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - -# Customisation from command line - -#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule -from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands -process = customiseLogErrorHarvesterUsingOutputCommands(process) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/MuonAnalyser/test/RAW2STA_SliceTest_MC.py b/MuonAnalyser/test/RAW2STA_SliceTest_MC.py deleted file mode 100644 index 03043b14dfc..00000000000 --- a/MuonAnalyser/test/RAW2STA_SliceTest_MC.py +++ /dev/null @@ -1,128 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: step3 --conditions 101X_dataRun2_Prompt_v10 -s RAW2DIGI,L1Reco,RECO --runUnscheduled --process reRECO --data --era Run2_2017 --eventcontent RECO --hltProcess reHLT --scenario pp --datatier RECO --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2017 -n -1 --filein /store/data/Run2017G/SingleMuon/RAW/v1/000/306/801/00001/7ADC8664-3DCE-E711-ADEF-02163E019BF4.root --fileout file:step3.root -import FWCore.ParameterSet.Config as cms - -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('reRECO',eras.Run2_2018,eras.run3_GEM) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.RawToDigi_Data_cff') -process.load('Configuration.StandardSequences.L1Reco_cff') -process.load('Configuration.StandardSequences.Reconstruction_Data_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) - -# Input source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( #'file:/xrootd/store/data/Run2017G/SingleMuon/RAW/v1/000/306/826/00000/FE2B6447-A4CE-E711-8DD7-02163E019CD7.root'), - # "file:/xrootd/store/data/Run2018C/SingleMuon/RAW/v1/000/319/347/00000/041ED888-4683-E811-B79A-FA163EF19885.root" - "/store/user/iawatson/GemSimulation/step2/step2_000.root" - ), - secondaryFileNames = cms.untracked.vstring() -) - -#import FWCore.PythonUtilities.LumiList as LumiList -#process.source.lumisToProcess = LumiList.LumiList(filename = 'cert_306824-306826_5TeV.txt').getVLuminosityBlockRange() -#print process.source.lumisToProcess - -process.options = cms.untracked.PSet() -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('step3 nevts:-1'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Additional output definition - -# Other statements -from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_dataRun2_Prompt_v7', '') # Run on 2018 Data -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') # Run on 2018 Simulation - -# Path and EndPath definitions -process.raw2digi_step = cms.Path(process.RawToDigi) -process.L1Reco_step = cms.Path(process.L1Reco) -# process.reconstruction_step = cms.Path(process.reconstruction) - -# Seed generator -from RecoMuon.MuonSeedGenerator.standAloneMuonSeeds_cff import * - -# Stand alone muon track producer -from RecoMuon.StandAloneMuonProducer.standAloneMuons_cff import * - -# Beam Spot -from RecoVertex.BeamSpotProducer.BeamSpot_cff import * - -process.dump=cms.EDAnalyzer('EventContentAnalyzer') - -process.reconstruction_step = cms.Path( - (process.dt1DRecHits + process.dt4DSegments + process.dt1DCosmicRecHits + process.dt4DCosmicSegments + process.csc2DRecHits + process.cscSegments + process.rpcRecHits + process.gemRecHits + process.gemSegments) * - offlineBeamSpot*standAloneMuonSeeds*process.standAloneMuons # *process.dump -) - -process.endjob_step = cms.EndPath(process.endOfProcess) - -process.TFileService = cms.Service("TFileService",fileName = cms.string("gem_raw2aod.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer( - 'STASliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("standAloneMuons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), - lumiScalers = cms.InputTag("scalersRawToDigi"), - gemDigis = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - amc13Event = cms.InputTag("muonGEMDigis", "AMC13Event", "reRECO"), - amcData = cms.InputTag("muonGEMDigis", "AMCdata", "reRECO"), - gebStatusCol = cms.InputTag("muonGEMDigis", "gebStatus", "reRECO"), - vfatStatusCol = cms.InputTag("muonGEMDigis", "vfatStatus", "reRECO"), -) -process.sliceTest = cms.Path(process.SliceTestAnalysis) - -process.muonGEMDigis.unPackStatusDigis = cms.bool(True) -# Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step, - process.L1Reco_step, - process.reconstruction_step, - process.sliceTest, - process.endjob_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -# customisation of the process. - -# Automatic addition of the customisation function from Configuration.DataProcessing.RecoTLR -from Configuration.DataProcessing.RecoTLR import customisePostEra_Run2_2017 - -#call to customisation function customisePostEra_Run2_2017 imported from Configuration.DataProcessing.RecoTLR -#process = customisePostEra_Run2_2017(process) - -# End of customisation functions -#do not add changes to your config after this point (unless you know what you are doing) -from FWCore.ParameterSet.Utilities import convertToUnscheduled -process=convertToUnscheduled(process) - -# Customisation from command line - -#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule -# from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands -# process = customiseLogErrorHarvesterUsingOutputCommands(process) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/MuonAnalyser/test/gemsim_on_condor.jds b/MuonAnalyser/test/gemsim_on_condor.jds deleted file mode 100644 index 72a25ce8012..00000000000 --- a/MuonAnalyser/test/gemsim_on_condor.jds +++ /dev/null @@ -1,10 +0,0 @@ -# Job description file for condor job -executable = gemsim_on_condor.sh -universe = vanilla -arguments = $(Process) - -log = condor.log - -getenv = True -should_transfer_files = NO -queue 2 diff --git a/MuonAnalyser/test/gemsim_on_condor.sh b/MuonAnalyser/test/gemsim_on_condor.sh deleted file mode 100755 index c3f3d44401d..00000000000 --- a/MuonAnalyser/test/gemsim_on_condor.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Steps from "runTheMatrix.py -w upgrade -l 10811.0" - -cd /cms/scratch/iwatson/GEM/CMSSW_10_3_0_pre3_vanilla/src/GEMSimulation -eval `scramv1 runtime -sh` - -cmsDriver.py TenMuExtendedE_0_200_pythia8_cfi --python_filename=python/step1_$1.py --conditions auto:phase1_2018_realistic -n 500 --era Run2_2018 --eventcontent FEVTDEBUG --relval 10000,100 -s GEN,SIM --datatier GEN-SIM --beamspot Realistic25ns13TeVEarly2018Collision --geometry DB:Extended --fileout root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step1/$1.root > log/step1_$1.log 2>&1 - -cmsDriver.py step2 --python_filename=python/step2_$1.py --conditions auto:phase1_2018_realistic -s DIGI:pdigi_valid,L1,DIGI2RAW,HLT:@relval2018 --datatier GEN-SIM-DIGI-RAW -n -1 --geometry DB:Extended --era Run2_2018 --eventcontent FEVTDEBUGHLT --filein root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step1/$1.root --fileout root://cms-xrdr.sdfarm.kr:1094//xrd/store/user/iawatson/GemSimulation/step2/$1.root > log/step2_$1.log 2>&1 - diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index ceb791d2d46..3d0bcfbcc51 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -20,7 +20,8 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') -process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singlePion_RECO_v2/190213_061518/0000/singlePion_GEN-SIM-DIGI_10.root') +#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singlePion_RECO_v2/190213_061518/0000/singlePion_GEN-SIM-DIGI_10.root') +process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_050.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') #from glob import glob @@ -35,25 +36,29 @@ ) process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) -process.HGCalSimTest = cms.EDAnalyzer('HGCalSimTest', +process.MuonDetHitAnalyser = cms.EDAnalyzer('MuonDetHitAnalyser', me0Digis = cms.InputTag("simMuonME0Digis"), - me0Segments = cms.InputTag("me0Segments"), me0RecHits = cms.InputTag("me0RecHits"), - cscSegments = cms.InputTag("cscSegments"), csc2DRecHits = cms.InputTag("csc2DRecHits"), gemDigis = cms.InputTag("simMuonGEMDigis"), - gemSegments = cms.InputTag("gemSegments"), gemRecHits = cms.InputTag("gemRecHits"), dtDigis = cms.InputTag("simMuonDTDigis"), - dt4DSegments = cms.InputTag("dt4DSegments"), dtRecHits = cms.InputTag("dt1DRecHits"), rpcDigis = cms.InputTag("simMuonRPCDigis"), rpcRecHits = cms.InputTag("rpcRecHits"), +) + +process.MuonTrackAnalyser = cms.EDAnalyzer('MuonTrackAnalyser', + me0Segments = cms.InputTag("me0Segments"), + cscSegments = cms.InputTag("cscSegments"), + gemSegments = cms.InputTag("gemSegments"), + dt4DSegments = cms.InputTag("dt4DSegments"), simLabel = cms.InputTag("mix","MergedTrackTruth"), muonLabel = cms.InputTag("muons"), primaryVertex = cms.InputTag('offlinePrimaryVertices'), ) -process.p = cms.Path(process.HGCalSimTest) + +process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser) process.schedule = cms.Schedule(process.p) diff --git a/MuonAnalyser/test/runSliceTestAnalysis.py b/MuonAnalyser/test/runSliceTestAnalysis.py deleted file mode 100644 index 7c6c61668ef..00000000000 --- a/MuonAnalyser/test/runSliceTestAnalysis.py +++ /dev/null @@ -1,44 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('SliceTestAnalysis',eras.Run2_2017,eras.run3_GEM) - -process.load("FWCore.MessageService.MessageLogger_cfi") -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') -process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') -process.MessageLogger.cerr.FwkReport.reportEvery = 5000 - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) -#process.maxEvents.input = cms.untracked.int32(10) -# Input source -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) -process.source.skipEvents = cms.untracked.uint32(0) - -#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -from glob import glob -process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) -#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') - -#fname = 'singleMuon.txt' -#f = open(fname) -#for line in f: -# process.source.fileNames.append(line) - -process.options = cms.untracked.PSet() - -process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("muons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), -) -process.p = cms.Path(process.SliceTestAnalysis) diff --git a/MuonAnalyser/test/runSliceTestAnalysis2018.py b/MuonAnalyser/test/runSliceTestAnalysis2018.py deleted file mode 100644 index 0e21c13cde9..00000000000 --- a/MuonAnalyser/test/runSliceTestAnalysis2018.py +++ /dev/null @@ -1,62 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('SliceTestAnalysis',eras.Run2_2018,eras.run3_GEM) - -process.load("FWCore.MessageService.MessageLogger_cfi") -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') -process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v11', '') -process.MessageLogger.cerr.FwkReport.reportEvery = 5000 - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) -#process.maxEvents.input = cms.untracked.int32(10) -# Input source -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) -process.source.skipEvents = cms.untracked.uint32(0) - -### Files available as at 17.7.2018 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_000.root 319337 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_349.root 319347 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_975.root 319348 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_993.root 319349 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1140.root 319449 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1510.root 319450 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1518.root 319456 -# Error in : file /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root does not exist -# Skipping /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1857.root 319459 - - -#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -from glob import glob -process.source.fileNames.extend( - ['/store/user/jlee/SingleMuon/Run2018C-v1/RECOv2/step3_019.root'] - # ['file:/xrootd/store/user/iawatson/SingleMuon/Run2018C-v1/wGEM/RECOv1/step3_{0:03d}.root'.format(i) for i in range(682, 682+1)] - # ['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3*.root')][:] -) -#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') - -#fname = 'singleMuon.txt' -#f = open(fname) -#for line in f: -# process.source.fileNames.append(line) - -process.options = cms.untracked.PSet() - -process.TFileService = cms.Service("TFileService",fileName = cms.string("histo2018.root")) - -process.SliceTestAnalysis = cms.EDAnalyzer('SliceTestAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("muons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), - lumiScalers = cms.InputTag("scalersRawToDigi"), -) -process.p = cms.Path(process.SliceTestAnalysis) diff --git a/MuonAnalyser/test/runSliceTestBkgAnalysis.py b/MuonAnalyser/test/runSliceTestBkgAnalysis.py deleted file mode 100644 index 573ef8670f9..00000000000 --- a/MuonAnalyser/test/runSliceTestBkgAnalysis.py +++ /dev/null @@ -1,47 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('SliceTestBkgAnalysis',eras.Run2_2017,eras.run3_GEM) - -process.load("FWCore.MessageService.MessageLogger_cfi") -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') -process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v10', '') -process.MessageLogger.cerr.FwkReport.reportEvery = 5000 - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) -#process.maxEvents.input = cms.untracked.int32(10) -# Input source -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) -process.source.skipEvents = cms.untracked.uint32(0) - -#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2018C-v1/RECOv5/AOD_606.root') -process.source.fileNames.append('/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_38.root') -#from glob import glob -#process.source.fileNames.extend(['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2017G-v1/RECOv2/step3*.root')][:5]) -#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') - -#fname = 'singleMuon.txt' -#f = open(fname) -#for line in f: -# process.source.fileNames.append(line) - -process.options = cms.untracked.PSet() - -process.TFileService = cms.Service("TFileService",fileName = cms.string("histo.root")) - -process.SliceTestBkgAnalysis = cms.EDAnalyzer('SliceTestBkgAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("muons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), - lumiScalers = cms.InputTag("scalersRawToDigi"), -) -process.p = cms.Path(process.SliceTestBkgAnalysis) diff --git a/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py b/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py deleted file mode 100644 index 5fc0d3775ba..00000000000 --- a/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py +++ /dev/null @@ -1,63 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from Configuration.StandardSequences.Eras import eras - -process = cms.Process('SliceTestEfficiencyAnalysis',eras.Run2_2018,eras.run3_GEM) - -process.load("FWCore.MessageService.MessageLogger_cfi") -process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') -process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v11', '') -process.MessageLogger.cerr.FwkReport.reportEvery = 5000 - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) -#process.maxEvents.input = cms.untracked.int32(10) -# Input source -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) -process.source.skipEvents = cms.untracked.uint32(0) - -### Files available as at 17.7.2018 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_000.root 319337 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_349.root 319347 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_975.root 319348 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_993.root 319349 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1140.root 319449 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1510.root 319450 -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1518.root 319456 -# Error in : file /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root does not exist -# Skipping /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root -# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1857.root 319459 - - -#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') -from glob import glob -process.source.fileNames.extend( - ['file:root://cms-xrdr.sdfarm.kr:1094///xrd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv6newDigiStatus/AOD_623.root'] - #['file:/xrootd/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_{0:02d}.root'.format(i) for i in range(30, 30+10)] - # ['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3*.root')][:] -) -#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') - -#fname = 'singleMuon.txt' -#f = open(fname) -#for line in f: -# process.source.fileNames.append(line) - -process.options = cms.untracked.PSet() - -process.TFileService = cms.Service("TFileService",fileName = cms.string("histo2018.root")) - -process.SliceTestEfficiencyAnalysis = cms.EDAnalyzer('SliceTestEfficiencyAnalysis', - process.MuonServiceProxy, - gemRecHits = cms.InputTag("gemRecHits"), - muons = cms.InputTag("muons"), - vertexCollection = cms.InputTag("offlinePrimaryVertices"), - #gemDigis = cms.InputTag("muonGEMDigis","AMCStatus"), - latency = cms.double(181), -) -process.p = cms.Path(process.SliceTestEfficiencyAnalysis) diff --git a/MuonAnalyser/test/sliceCrab.py b/MuonAnalyser/test/sliceCrab.py deleted file mode 100644 index 474462f156a..00000000000 --- a/MuonAnalyser/test/sliceCrab.py +++ /dev/null @@ -1,28 +0,0 @@ -from CRABClient.UserUtilities import config -config = config() - -config.General.requestName = 'GEM-SliceTestBkg-2018D-RAW-7036' -config.General.transferLogs = True - -config.JobType.pluginName = 'Analysis' -# Name of the CMSSW configuration file -config.JobType.psetName = 'RAW2STA_SliceTest_Bkg.py' - -#config.Data.inputDataset = '/EGamma/Run2018C-PromptReco-v1/AOD' -config.Data.inputDataset = '/ZeroBias/Run2018D-v1/RAW' -config.Data.splitting = 'LumiBased' -config.Data.unitsPerJob = 10 -config.Data.publication = True -# This string is used to construct the output dataset name -config.Data.outputDatasetTag = 'CRAB3_GEMSliceTestBkgAnalysis_GEM_2018D-7036' - -# These values only make sense for processing data -# Select input data based on a lumi mask -#config.Data.lumiMask = '2018D_321069.txt' # 'Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt' -# Select input data based on run-ranges -#config.Data.runRange = '321067-321069' # v1 -config.Data.runRange = '321908,321909' -#config.Data.runRange = '319347,319348,319349' # v2 - -# Where the output files will be transmitted to -config.Site.storageSite = 'T3_KR_KISTI' From d0d6c9a8cb31e8f18e228ebc7505f49c66e1e7d2 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 26 Feb 2019 03:32:51 +0900 Subject: [PATCH 43/50] back --- .../plugins/SliceTestEfficiencyAnalysis.cc | 388 ++++++++++++++++++ .../runSliceTestEfficiencyAnalysis2018.py | 63 +++ 2 files changed, 451 insertions(+) create mode 100644 MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc create mode 100644 MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py diff --git a/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc b/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc new file mode 100644 index 00000000000..9521d90cddd --- /dev/null +++ b/MuonAnalyser/plugins/SliceTestEfficiencyAnalysis.cc @@ -0,0 +1,388 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "MagneticField/Engine/interface/MagneticField.h" + +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "DataFormats/Math/interface/deltaPhi.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "EventFilter/Utilities/interface/json.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class SliceTestEfficiencyAnalysis : public edm::EDAnalyzer { +public: + explicit SliceTestEfficiencyAnalysis(const edm::ParameterSet&); + ~SliceTestEfficiencyAnalysis(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + const GEMEtaPartition* findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP); + + // ----------member data --------------------------- + edm::EDGetTokenT gemRecHits_; + edm::EDGetTokenT > muons_; + edm::EDGetTokenT vertexCollection_; + //edm::EDGetTokenT> gemDigis_; + edm::Service fs; + + double Latency_; + + MuonServiceProxy* theService_; + edm::ESHandle propagator_; + edm::ESHandle ttrackBuilder_; + edm::ESHandle bField_; + + static const int MAXCHAMBERS = 36; + static const int MAXLAYERS = 2; + static const int MAXROLL = 8; + + int nGEMHitInMuontrack; + + TH1D* h_nGEMHitInMuontrack; + TH2D* h_inMap; + TH2D* h_hitMap; + + TH2D* h_hitLumiMap[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_stripLumiMap[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_inRoll[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_inStrip[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inVfat[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inPos[MAXCHAMBERS][MAXLAYERS]; + + TH1D* h_hitRoll[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_hitStrip[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_hitVfat[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_hitPos[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_hitNstrip[MAXCHAMBERS][MAXLAYERS][MAXROLL]; + TH1D* h_resX_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; + TH1D* h_resY_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; + TH1D* h_resPhi_etaPart[MAXCHAMBERS][MAXLAYERS][MAXROLL]; + TH1D* h_resX_xPart[MAXCHAMBERS][MAXLAYERS][3]; + TH1D* h_resY_xPart[MAXCHAMBERS][MAXLAYERS][3]; + TH1D* h_resPhi_xPart[MAXCHAMBERS][MAXLAYERS][3]; + + TH1D* h_resX[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_resY[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_resPhi[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_resXvsNstrip[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_pullX[MAXCHAMBERS][MAXLAYERS]; + TH1D* h_pullY[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inPos_matched[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inPhiVsHitPhi[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inXVsHitX[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inStripVsHitStrip[MAXCHAMBERS][MAXLAYERS]; + TH2D* h_inPhiVsHitStrip[MAXCHAMBERS][MAXLAYERS]; + + int b_run, b_lumi; + int nEvents; + int b_nMuons, b_nMuonsInGEMRegion, b_nGEMHits; + int b_latency; + + TTree *t_event; +}; + +SliceTestEfficiencyAnalysis::SliceTestEfficiencyAnalysis(const edm::ParameterSet& iConfig) : + nEvents(0) +{ + gemRecHits_ = consumes(iConfig.getParameter("gemRecHits")); + muons_ = consumes >(iConfig.getParameter("muons")); + edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); + //gemDigis_ = consumes>(iConfig.getParameter("gemDigis")); + theService_ = new MuonServiceProxy(serviceParameters); + Latency_ = iConfig.getParameter("latency"); + + t_event = fs->make("Event", "Event"); + t_event->Branch("nMuons", &b_nMuons, "nMuons/I"); + t_event->Branch("nMuonsInGEMRegion", &b_nMuonsInGEMRegion, "nMuonsInGEMRegion/I"); + t_event->Branch("nGEMHits", &b_nGEMHits, "nGEMHits/I"); + t_event->Branch("run", &b_run, "run/I"); + t_event->Branch("lumi", &b_lumi, "lumi/I"); + t_event->Branch("latency", &b_latency, "latency/I"); + + h_nGEMHitInMuontrack = fs->make(Form("nGEMHitInMuontrack"),"nGEMHitInMuontrack",4,0,4); + h_inMap = fs->make(Form("inMap"),"inMap",18,26.5,31,18,0,9); + h_hitMap = fs->make(Form("hitMap"),"hitMap",18,26.5,31,18,0,9); + for (int ichamber=27; ichamber<=30;++ichamber) { + for (int ilayer=0; ilayermake(Form("hitLumiMap ch %i lay %i",ichamber, ilayer+1),"hitLumiMap",700,0,700,32,1,9); + h_stripLumiMap[ichamber][ilayer] = fs->make(Form("stripLumiMap ch %i lay %i",ichamber, ilayer+1),"stripLumiMap",700,0,700,400,0,400); + h_inRoll[ichamber][ilayer] = fs->make(Form("inRoll ch %i lay %i",ichamber, ilayer+1),"inRoll",8,0.5,8.5); + h_inStrip[ichamber][ilayer] = fs->make(Form("inStrip ch %i lay %i",ichamber, ilayer+1),"inStrip",384,0,384); + h_inVfat[ichamber][ilayer] = fs->make(Form("inVfat ch %i lay %i",ichamber, ilayer+1),"inVfat",3,0.5,3.5,8,0.5,8.5); + h_inPos[ichamber][ilayer] = fs->make(Form("inPos ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-260,-110); + + h_hitRoll[ichamber][ilayer] = fs->make(Form("hitRoll ch %i lay %i",ichamber, ilayer+1),"hitRoll",8,0.5,8.5); + h_hitStrip[ichamber][ilayer] = fs->make(Form("hitStrip ch %i lay %i",ichamber, ilayer+1),"hitStrip",384,0,384); + h_hitVfat[ichamber][ilayer] = fs->make(Form("hitVfat ch %i lay %i",ichamber, ilayer+1),"hitVfat",3,0.5,3.5,8,0.5,8.5); + h_hitPos[ichamber][ilayer] = fs->make(Form("hitPos ch %i lay %i",ichamber, ilayer+1),"hitPos",100,-70,120,100,-260,-110); + for (int ieta=0; ietamake(Form("hitNstrip ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"hitNstrip",30,0,30); + h_resX_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resX_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resX",500,-3,3); + h_resY_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resY_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resY",500,-15,15); + h_resPhi_etaPart[ichamber][ilayer][ieta] = fs->make(Form("resPhi_etaPart ch %i lay %i ieta %i",ichamber, ilayer+1, ieta),"resPhi",500,-0.03,0.03); + } + for (int xrange=0; xrange<3;++xrange) { + h_resX_xPart[ichamber][ilayer][xrange] = fs->make(Form("resX_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resX",500,-3,3); + h_resY_xPart[ichamber][ilayer][xrange] = fs->make(Form("resY_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resY",500,-15,15); + h_resPhi_xPart[ichamber][ilayer][xrange] = fs->make(Form("resPhi_xPart ch %i lay %i xrange %i",ichamber, ilayer+1, xrange),"resPhi",500,-0.03,0.03); + } + + h_resX[ichamber][ilayer] = fs->make(Form("resX ch %i lay %i",ichamber, ilayer+1),"resX",500,-3,3); + h_resY[ichamber][ilayer] = fs->make(Form("resY ch %i lay %i",ichamber, ilayer+1),"resY",500,-15,15); + h_resPhi[ichamber][ilayer] = fs->make(Form("resPhi ch %i lay %i",ichamber, ilayer+1),"resPhi",500,-0.03,0.03); + h_resXvsNstrip[ichamber][ilayer] = fs->make(Form("resXvsNstrip ch %i lay %i",ichamber, ilayer+1),"resXvsNstrip",250,-3,3,15,0,15); + h_pullX[ichamber][ilayer] = fs->make(Form("pullX ch %i lay %i",ichamber, ilayer+1),"pullX",500,-3,3); + h_pullY[ichamber][ilayer] = fs->make(Form("pullY ch %i lay %i",ichamber, ilayer+1),"pullY",500,-3,3); + h_inPos_matched[ichamber][ilayer] = fs->make(Form("inPos_matched ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-260,-110); + h_inPhiVsHitPhi[ichamber][ilayer] = fs->make(Form("inPhiVsHitPhi ch %i lay %i",ichamber, ilayer+1),"inPos",100,-1.9,-1.1,100,-1.9,-1.1); + h_inXVsHitX[ichamber][ilayer] = fs->make(Form("inXVsHitX ch %i lay %i",ichamber, ilayer+1),"inPos",100,-70,120,100,-70,120); + h_inStripVsHitStrip[ichamber][ilayer] = fs->make(Form("inStripVsHitStrip ch %i lay %i",ichamber, ilayer+1),"inPos",400,0,400,400,0,400); + h_inPhiVsHitStrip[ichamber][ilayer] = fs->make(Form("inPhiVsHitStrip ch %i lay %i",ichamber, ilayer+1),"inPos",100,-1.9,-1.1,400,0,400); + } + } +} + +SliceTestEfficiencyAnalysis::~SliceTestEfficiencyAnalysis(){} + +void +SliceTestEfficiencyAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + nEvents++; + + b_nMuons = 0; + b_nMuonsInGEMRegion = 0; + b_nGEMHits = 0; + + b_run = iEvent.run(); + b_lumi = iEvent.luminosityBlock(); + + edm::ESHandle hGeom; + iSetup.get().get(hGeom); + const GEMGeometry* GEMGeometry_ = &*hGeom; + + iSetup.get().get("TransientTrackBuilder",ttrackBuilder_); + theService_->update(iSetup); + auto propagator = theService_->propagator("SteppingHelixPropagatorAny"); + + edm::Handle gemRecHits; + iEvent.getByToken(gemRecHits_, gemRecHits); + + Handle > muons; + iEvent.getByToken(muons_, muons); + + /* + edm::Handle> gemDigis; + iEvent.getByToken(gemDigis_, gemDigis); + + b_latency = -1; + for (auto g : *gemDigis) { + for (auto a = g.second.first; a != g.second.second; ++a) { + b_latency = a->Param1(); + } + } + //if (b_latency != Latency_) return; + */ + + if (b_run != 319347) return; + if ( (b_lumi <50) + || (b_lumi>210 && b_lumi<240) + || (b_lumi>640) ) return; + + for (auto ch : GEMGeometry_->chambers()) { + for(auto roll : ch->etaPartitions()) { + auto rId = roll->id(); + auto recHitsRange = gemRecHits->get(rId); + b_nGEMHits += recHitsRange.second - recHitsRange.first; + for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { + int vfat = hit->firstClusterStrip()/128 +1; + h_hitLumiMap[rId.chamber()][rId.layer()-1]->Fill(b_lumi,rId.roll()+vfat/4.); + h_stripLumiMap[rId.chamber()][rId.layer()-1]->Fill(b_lumi,hit->firstClusterStrip()); + } + } + } + //if (b_nGEMHits == 0) continue; + + for (size_t i = 0; i < muons->size(); ++i) { + + edm::RefToBase muRef = muons->refAt(i); + const reco::Muon* mu = muRef.get(); + + // muon id + int muonId = 0; + if (mu->passed(reco::Muon::Selector::CutBasedIdTight)) muonId = 2; + else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose)) muonId = 1; + + // tight and pt > 20 muon only + if (muonId != 2) continue; + if (mu->pt() < 20) continue; + + const reco::Track* muonTrack = 0; + if ( mu->globalTrack().isNonnull() ) muonTrack = mu->globalTrack().get(); + else if ( mu->outerTrack().isNonnull() ) muonTrack = mu->outerTrack().get(); + if (!muonTrack) continue; + b_nMuons++; + + nGEMHitInMuontrack = 0; + for (auto hit = muonTrack->recHitsBegin(); hit != muonTrack->recHitsEnd(); hit++) { + if ((*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { + nGEMHitInMuontrack++; + } + } + h_nGEMHitInMuontrack->Fill(nGEMHitInMuontrack); + + reco::TransientTrack ttTrack = ttrackBuilder_->build(muonTrack); + for (auto chamber : GEMGeometry_->chambers()) { + if (chamber->id().chamber() == 1) continue; // ignore chammber 1 + if (mu->eta() * chamber->id().region() < 0 ) continue; + + TrajectoryStateOnSurface tsos = propagator->propagate(ttTrack.outermostMeasurementState(), + chamber->surface()); + if (!tsos.isValid()) continue; + + GlobalPoint tsosGP = tsos.globalPosition(); + auto etaPart = findEtaPartition(chamber, tsosGP); + if (!etaPart) continue; + + auto gemid = etaPart->id(); + auto locPos = etaPart->toLocal(tsosGP); + auto strip = (int) etaPart->strip(locPos); + auto vfat = ((int) strip/128)+1; + + h_inRoll[gemid.chamber()][gemid.layer()-1]->Fill(gemid.roll()); + h_inStrip[gemid.chamber()][gemid.layer()-1]->Fill(strip); + h_inVfat[gemid.chamber()][gemid.layer()-1]->Fill(vfat, gemid.roll()); + h_inPos[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), tsosGP.y()); + h_inMap->Fill(gemid.chamber()+gemid.layer()/2., gemid.roll()); + + //Find hit + float resX = 999; + GEMRecHit closestHit; + auto recHitsRange = gemRecHits->get(gemid); + for (auto hit = recHitsRange.first; hit != recHitsRange.second; ++hit) { + LocalPoint hitLocPos = hit->localPosition(); + if ( fabs(hitLocPos.x() - locPos.x()) < fabs(resX) ) { + resX = hitLocPos.x() - locPos.x(); + closestHit = (*hit); + } + } + if (resX == 999) continue; + auto hitLocPos = closestHit.localPosition(); + auto hitGlobPos = etaPart->toGlobal(hitLocPos); + auto hitStrip = closestHit.firstClusterStrip(); + auto resY = hitLocPos.y() - locPos.y(); + auto resPhi = hitGlobPos.phi() - tsosGP.phi(); + h_inPhiVsHitPhi[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.phi(), hitGlobPos.phi()); + h_inXVsHitX[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), hitGlobPos.x()); + h_inStripVsHitStrip[gemid.chamber()][gemid.layer()-1]->Fill(strip, hitStrip); + h_inPhiVsHitStrip[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.phi(), hitStrip); + + if (resX > 5.0) continue; + LocalError && locErr = tsos.localError().positionError(); + LocalError && hitLocErr = closestHit.localPositionError(); + auto pullX = resX / std::sqrt(hitLocErr.xx() + locErr.xx()); + auto pullY = resY / std::sqrt(hitLocErr.yy() + locErr.yy()); + + //Filling histograms + h_hitRoll[gemid.chamber()][gemid.layer()-1]->Fill(gemid.roll()); + h_hitStrip[gemid.chamber()][gemid.layer()-1]->Fill(hitStrip); + h_hitVfat[gemid.chamber()][gemid.layer()-1]->Fill(((int)hitStrip/128)+1, gemid.roll()); + h_hitPos[gemid.chamber()][gemid.layer()-1]->Fill(hitGlobPos.x(), hitGlobPos.y()); + h_hitNstrip[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(closestHit.clusterSize()); + h_hitMap->Fill(gemid.chamber()+gemid.layer()/2., gemid.roll()); + + int x = 1; + if (abs(locPos.x())<10) x = 0; + else if (abs(locPos.x())>20) x = 2; + h_resX_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resX); + h_resY_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resY); + h_resPhi_etaPart[gemid.chamber()][gemid.layer()-1][gemid.roll()-1]->Fill(resPhi); + h_resX_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resX); + h_resY_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resY); + h_resPhi_xPart[gemid.chamber()][gemid.layer()-1][x]->Fill(resPhi); + h_resX[gemid.chamber()][gemid.layer()-1]->Fill(resX); + h_resY[gemid.chamber()][gemid.layer()-1]->Fill(resY); + h_resPhi[gemid.chamber()][gemid.layer()-1]->Fill(resPhi); + h_resXvsNstrip[gemid.chamber()][gemid.layer()-1]->Fill(resX,closestHit.clusterSize()); + h_pullX[gemid.chamber()][gemid.layer()-1]->Fill(pullX); + h_pullY[gemid.chamber()][gemid.layer()-1]->Fill(pullY); + h_inPos_matched[gemid.chamber()][gemid.layer()-1]->Fill(tsosGP.x(), tsosGP.y()); + + } + } + t_event->Fill(); +} + +const GEMEtaPartition* SliceTestEfficiencyAnalysis::findEtaPartition(const GEMChamber*& chamber, GlobalPoint& tsosGP){ + for (auto etaPart : chamber->etaPartitions()) { + const LocalPoint locPos = etaPart->toLocal(tsosGP); + const LocalPoint locPos2D(locPos.x(), locPos.y(), 0); + const BoundPlane& bps(etaPart->surface()); + if (!bps.bounds().inside(locPos2D)) continue; + return etaPart; + } + return nullptr; +} + +void SliceTestEfficiencyAnalysis::beginJob(){} +void SliceTestEfficiencyAnalysis::endJob(){} + +void SliceTestEfficiencyAnalysis::beginRun(Run const& run, EventSetup const&){} +void SliceTestEfficiencyAnalysis::endRun(Run const&, EventSetup const&){} + +//define this as a plug-in +DEFINE_FWK_MODULE(SliceTestEfficiencyAnalysis); diff --git a/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py b/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py new file mode 100644 index 00000000000..5fc0d3775ba --- /dev/null +++ b/MuonAnalyser/test/runSliceTestEfficiencyAnalysis2018.py @@ -0,0 +1,63 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('SliceTestEfficiencyAnalysis',eras.Run2_2018,eras.run3_GEM) + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('RecoMuon.TrackingTools.MuonServiceProxy_cff') +process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v11', '') +process.MessageLogger.cerr.FwkReport.reportEvery = 5000 + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +#process.maxEvents.input = cms.untracked.int32(10) +# Input source +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) +process.source.skipEvents = cms.untracked.uint32(0) + +### Files available as at 17.7.2018 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_000.root 319337 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_349.root 319347 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_975.root 319348 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_993.root 319349 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1140.root 319449 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1510.root 319450 +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1518.root 319456 +# Error in : file /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root does not exist +# Skipping /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1808.root +# /xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3_1857.root 319459 + + +#process.source.fileNames.append('/store/data/Run2018B/Cosmics/AOD/PromptReco-v1/000/317/428/00000/E4BC1D7B-3F6A-E811-9E05-FA163E57A064.root') +from glob import glob +process.source.fileNames.extend( + ['file:root://cms-xrdr.sdfarm.kr:1094///xrd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv6newDigiStatus/AOD_623.root'] + #['file:/xrootd/store/user/jlee/SingleMuon/2018DLatency321908-321909/180902_194730/0000/AOD_{0:02d}.root'.format(i) for i in range(30, 30+10)] + # ['file:'+f for f in glob('/xrootd/store/user/jlee/SingleMuon/Run2018C-v1/RECOv1/step3*.root')][:] +) +#process.source.fileNames.append('/store/user/jlee/SingleMuon/Run2017G-v1/FEVTEvent/step3_313.root') + +#fname = 'singleMuon.txt' +#f = open(fname) +#for line in f: +# process.source.fileNames.append(line) + +process.options = cms.untracked.PSet() + +process.TFileService = cms.Service("TFileService",fileName = cms.string("histo2018.root")) + +process.SliceTestEfficiencyAnalysis = cms.EDAnalyzer('SliceTestEfficiencyAnalysis', + process.MuonServiceProxy, + gemRecHits = cms.InputTag("gemRecHits"), + muons = cms.InputTag("muons"), + vertexCollection = cms.InputTag("offlinePrimaryVertices"), + #gemDigis = cms.InputTag("muonGEMDigis","AMCStatus"), + latency = cms.double(181), +) +process.p = cms.Path(process.SliceTestEfficiencyAnalysis) From a65d8eb610f8dd308fcca326a44f73bf0561cd2c Mon Sep 17 00:00:00 2001 From: jang00777 Date: Wed, 27 Feb 2019 00:03:31 +0900 Subject: [PATCH 44/50] Add MuonSimAnalyser --- MuonAnalyser/plugins/MuonSimAnalyser.cc | 195 ++++++++++++++++++++++++ MuonAnalyser/test/runHGCalSimTest.py | 11 +- 2 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 MuonAnalyser/plugins/MuonSimAnalyser.cc diff --git a/MuonAnalyser/plugins/MuonSimAnalyser.cc b/MuonAnalyser/plugins/MuonSimAnalyser.cc new file mode 100644 index 00000000000..71385228ce1 --- /dev/null +++ b/MuonAnalyser/plugins/MuonSimAnalyser.cc @@ -0,0 +1,195 @@ +// cd /cms/ldap_home/iawatson/scratch/GEM/CMSSW_10_1_5/src/ && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// cd ../../.. && source /cvmfs/cms.cern.ch/cmsset_default.sh && eval `scramv1 runtime -sh` && eval `scramv1 runtime -sh` && scram b -j 10 +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +//#include "DQMServices/Core/interface/DQMStore.h" +//#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +//#include "DQMServices/Core/interface/MonitorElement.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +// GEM +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" + +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" + +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimDataFormats/Associations/interface/MuonToTrackingParticleAssociator.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" +#include "SimMuon/MCTruth/interface/MuonToSimAssociatorByHits.h" +#include "SimTracker/Common/interface/TrackingParticleSelector.h" +#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GeomDet.h" + +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/CommonTopologies/interface/RadialStripTopology.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Run.h" + +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TString.h" +#include "TGraphAsymmErrors.h" +#include "TLorentzVector.h" +#include "TTree.h" + +using namespace std; +using namespace edm; + +class MuonSimAnalyser : public edm::EDAnalyzer { +public: + explicit MuonSimAnalyser(const edm::ParameterSet&); + ~MuonSimAnalyser(); + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginJob() override; + virtual void endJob() override; + + virtual void beginRun(Run const&, EventSetup const&) override; + virtual void endRun(Run const&, EventSetup const&) override; + + void initValue(); + + // ----------member data --------------------------- + edm::ParameterSet cfg_; + edm::EDGetToken simHitsToken_; + edm::EDGetToken simTracksToken_; + edm::EDGetToken simVerticesToken_; + + edm::Service fs; + + TTree *t_event; + int b_nGEMSimHits; + + /* GEM */ + TTree *t_GEM_simhit; + int b_GEM_SimHit_region, b_GEM_SimHit_station, b_GEM_SimHit_ring, b_GEM_SimHit_chamber, b_GEM_SimHit_layer, b_GEM_SimHit_etaPartition, b_GEM_SimHit_pdgId; + float b_GEM_SimHit_pt, b_GEM_SimHit_eta, b_GEM_SimHit_phi; +}; + +MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) +{ + + std::string simInputLabel_ = iConfig.getUntrackedParameter("simInputLabel"); + + simHitsToken_ = consumes(edm::InputTag(simInputLabel_,"MuonGEMHits")); + simTracksToken_ = consumes< edm::SimTrackContainer >(iConfig.getParameter("simTrackCollection")); + simVerticesToken_ = consumes< edm::SimVertexContainer >(iConfig.getParameter("simVertexCollection")); + cfg_ = iConfig; + + t_event = fs->make("Event", "Event"); + t_event->Branch("nGEMSimHits", &b_nGEMSimHits, "nGEMSimHits/I"); + + /*GEM*/ + t_GEM_simhit = fs->make("GEM_SimHit", "GEM_SimHit"); + t_GEM_simhit->Branch("SimHit_pdgId", &b_GEM_SimHit_pdgId, "SimHit_pdgId/I"); + t_GEM_simhit->Branch("SimHit_pt", &b_GEM_SimHit_pt, "SimHit_pt/F"); + t_GEM_simhit->Branch("SimHit_eta", &b_GEM_SimHit_eta, "SimHit_eta/F"); + t_GEM_simhit->Branch("SimHit_phi", &b_GEM_SimHit_phi, "SimHit_phi/F"); + t_GEM_simhit->Branch("SimHit_region", &b_GEM_SimHit_region, "SimHit_region/I"); + t_GEM_simhit->Branch("SimHit_station", &b_GEM_SimHit_station, "SimHit_station/I"); + t_GEM_simhit->Branch("SimHit_ring", &b_GEM_SimHit_ring, "SimHit_ring/I"); + t_GEM_simhit->Branch("SimHit_chamber", &b_GEM_SimHit_chamber, "SimHit_chaber/I"); + t_GEM_simhit->Branch("SimHit_layer", &b_GEM_SimHit_layer, "SimHit_layer/I"); + t_GEM_simhit->Branch("SimHit_etaPartition", &b_GEM_SimHit_etaPartition, "SimHit_etaParition/I"); + +} + +MuonSimAnalyser::~MuonSimAnalyser() +{ +} + +void +MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + /* GEM Geometry */ + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + + edm::Handle simHits; + edm::Handle simTracks; + edm::Handle simVertices; + iEvent.getByToken(simHitsToken_, simHits); + iEvent.getByToken(simTracksToken_, simTracks); + iEvent.getByToken(simVerticesToken_, simVertices); + //if ( !simHits.isValid() || !simTracks.isValid() || !simVertices.isValid()) return; + if (!simHits.isValid()) return; + + initValue(); + + const edm::PSimHitContainer & sim_hits = *simHits.product(); + + /* GEM */ + for (auto& sh : sim_hits){ + GEMDetId det_id = sh.detUnitId(); + auto vec = sh.momentumAtEntry(); + b_GEM_SimHit_pdgId = sh.particleType(); + b_GEM_SimHit_pt = vec.perp(); + b_GEM_SimHit_eta = vec.eta(); + b_GEM_SimHit_phi = sh.phiAtEntry(); + + b_GEM_SimHit_region = det_id.region(); + b_GEM_SimHit_station = det_id.station(); + b_GEM_SimHit_ring = det_id.ring(); + b_GEM_SimHit_chamber = det_id.chamber(); + b_GEM_SimHit_layer = det_id.layer(); + b_GEM_SimHit_etaPartition = det_id.roll(); + + ++b_nGEMSimHits; + t_GEM_simhit->Fill(); + } + t_event->Fill(); +} + +void MuonSimAnalyser::beginJob(){} +void MuonSimAnalyser::endJob(){} + +void MuonSimAnalyser::beginRun(const edm::Run& run, const edm::EventSetup& iSetup){//(Run const& run, EventSetup const&){ +} +void MuonSimAnalyser::endRun(Run const&, EventSetup const&){} + +void MuonSimAnalyser::initValue() { + b_nGEMSimHits = -1; + /*GEM */ + b_GEM_SimHit_region = -9; b_GEM_SimHit_station = -9; b_GEM_SimHit_ring = -9; b_GEM_SimHit_chamber = -9; b_GEM_SimHit_layer = -9; b_GEM_SimHit_etaPartition = -9; b_GEM_SimHit_pdgId = -99; + b_GEM_SimHit_pt = -9; b_GEM_SimHit_eta = -9; b_GEM_SimHit_phi = -9; + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(MuonSimAnalyser); diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index 3d0bcfbcc51..cdee782f6f9 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -56,9 +56,18 @@ simLabel = cms.InputTag("mix","MergedTrackTruth"), muonLabel = cms.InputTag("muons"), primaryVertex = cms.InputTag('offlinePrimaryVertices'), +) +process.MuonSimAnalyser = cms.EDAnalyzer('MuonSimAnalyser', + verboseSimHit = cms.untracked.int32(1), + simInputLabel = cms.untracked.string('g4SimHits'), + simMuOnlyGEM = cms.untracked.bool(True), + #verboseSimHit = cms.untracked.int32(1), + #simInputLabel = cms.InputTag('g4SimHits',"MuonGEMHits"), + simTrackCollection = cms.InputTag('g4SimHits'), + simVertexCollection = cms.InputTag('g4SimHits') ) -process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser) +process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser + process.MuonSimAnalyser) process.schedule = cms.Schedule(process.p) From 4069472da4b795057bcba2a91c9cda8c46b9a2c7 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Thu, 28 Feb 2019 16:07:39 +0900 Subject: [PATCH 45/50] Fix bug for running HGCalSimTest --- MuonAnalyser/plugins/MuonSimAnalyser.cc | 24 ++++++++++++++++++++---- MuonAnalyser/test/runHGCalSimTest.py | 13 +++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/MuonAnalyser/plugins/MuonSimAnalyser.cc b/MuonAnalyser/plugins/MuonSimAnalyser.cc index 71385228ce1..bef814e75ac 100644 --- a/MuonAnalyser/plugins/MuonSimAnalyser.cc +++ b/MuonAnalyser/plugins/MuonSimAnalyser.cc @@ -65,6 +65,7 @@ #include "TGraphAsymmErrors.h" #include "TLorentzVector.h" #include "TTree.h" +#include "TDatabasePDG.h" using namespace std; using namespace edm; @@ -99,18 +100,22 @@ class MuonSimAnalyser : public edm::EDAnalyzer { TTree *t_GEM_simhit; int b_GEM_SimHit_region, b_GEM_SimHit_station, b_GEM_SimHit_ring, b_GEM_SimHit_chamber, b_GEM_SimHit_layer, b_GEM_SimHit_etaPartition, b_GEM_SimHit_pdgId; float b_GEM_SimHit_pt, b_GEM_SimHit_eta, b_GEM_SimHit_phi; + }; MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) { - std::string simInputLabel_ = iConfig.getUntrackedParameter("simInputLabel"); + //std::string simInputLabel_ = iConfig.getUntrackedParameter("simInputLabel"); - simHitsToken_ = consumes(edm::InputTag(simInputLabel_,"MuonGEMHits")); + auto simInputLabel_ = iConfig.getParameter("simInputLabel"); + simHitsToken_ = consumes(simInputLabel_);//,"MuonGEMHits")); simTracksToken_ = consumes< edm::SimTrackContainer >(iConfig.getParameter("simTrackCollection")); simVerticesToken_ = consumes< edm::SimVertexContainer >(iConfig.getParameter("simVertexCollection")); cfg_ = iConfig; + + t_event = fs->make("Event", "Event"); t_event->Branch("nGEMSimHits", &b_nGEMSimHits, "nGEMSimHits/I"); @@ -139,7 +144,7 @@ MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup /* GEM Geometry */ edm::ESHandle hGEMGeom; iSetup.get().get(hGEMGeom); - const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + //const GEMGeometry* GEMGeometry_ = &*hGEMGeom; edm::Handle simHits; edm::Handle simTracks; @@ -151,14 +156,25 @@ MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup if (!simHits.isValid()) return; initValue(); - const edm::PSimHitContainer & sim_hits = *simHits.product(); /* GEM */ for (auto& sh : sim_hits){ GEMDetId det_id = sh.detUnitId(); auto vec = sh.momentumAtEntry(); + std::cout << "chk " << std::endl; + b_GEM_SimHit_pdgId = sh.particleType(); + + TDatabasePDG *pdg = TDatabasePDG::Instance(); + + if (auto particle_pdg = pdg->GetParticle(b_GEM_SimHit_pdgId)) { + std::cout << particle_pdg->GetName() << " " << b_GEM_SimHit_pdgId << std::endl; + } else { + std::cout << "Cannot understand!!! " << b_GEM_SimHit_pdgId << std::endl; + } + + b_GEM_SimHit_pt = vec.perp(); b_GEM_SimHit_eta = vec.eta(); b_GEM_SimHit_phi = sh.phiAtEntry(); diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index cdee782f6f9..0b5a44d368f 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -20,8 +20,8 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') -#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singlePion_RECO_v2/190213_061518/0000/singlePion_GEN-SIM-DIGI_10.root') -process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') +process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_MinBias/190213_140302/0000/step1_10.root') +#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_050.root') #process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') #from glob import glob @@ -59,15 +59,16 @@ ) process.MuonSimAnalyser = cms.EDAnalyzer('MuonSimAnalyser', - verboseSimHit = cms.untracked.int32(1), - simInputLabel = cms.untracked.string('g4SimHits'), - simMuOnlyGEM = cms.untracked.bool(True), +# verboseSimHit = cms.untracked.int32(1), + simInputLabel = cms.InputTag('g4SimHits', "MuonGEMHits"), +# simMuOnlyGEM = cms.untracked.bool(True), #verboseSimHit = cms.untracked.int32(1), #simInputLabel = cms.InputTag('g4SimHits',"MuonGEMHits"), simTrackCollection = cms.InputTag('g4SimHits'), simVertexCollection = cms.InputTag('g4SimHits') ) -process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser + process.MuonSimAnalyser) +#process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser + process.MuonSimAnalyser) +process.p = cms.Path(process.MuonSimAnalyser) process.schedule = cms.Schedule(process.p) From 7f8ac7a7340b7d45cf38d0ab0660b531c7ec1f98 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Thu, 28 Feb 2019 16:11:38 +0900 Subject: [PATCH 46/50] Fix bug for running HGCalSimTest (+1) --- MuonAnalyser/plugins/BuildFile.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/MuonAnalyser/plugins/BuildFile.xml b/MuonAnalyser/plugins/BuildFile.xml index b0c0f29738a..555883c5465 100644 --- a/MuonAnalyser/plugins/BuildFile.xml +++ b/MuonAnalyser/plugins/BuildFile.xml @@ -24,5 +24,6 @@ + From f7a72f8c3c01aafaddc21c849113dbd227e066e3 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Mon, 4 Mar 2019 15:24:25 +0900 Subject: [PATCH 47/50] Add ME0 simhit in MuonSimAnalyser --- MuonAnalyser/plugins/MuonSimAnalyser.cc | 138 ++++++++++++++++-------- MuonAnalyser/test/runHGCalSimTest.py | 14 +-- 2 files changed, 103 insertions(+), 49 deletions(-) diff --git a/MuonAnalyser/plugins/MuonSimAnalyser.cc b/MuonAnalyser/plugins/MuonSimAnalyser.cc index bef814e75ac..5e16ebeb870 100644 --- a/MuonAnalyser/plugins/MuonSimAnalyser.cc +++ b/MuonAnalyser/plugins/MuonSimAnalyser.cc @@ -23,6 +23,11 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" +// ME0 +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" // GEM #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" @@ -87,14 +92,20 @@ class MuonSimAnalyser : public edm::EDAnalyzer { // ----------member data --------------------------- edm::ParameterSet cfg_; - edm::EDGetToken simHitsToken_; + edm::EDGetToken ME0SimHitsToken_; + edm::EDGetToken GEMSimHitsToken_; edm::EDGetToken simTracksToken_; edm::EDGetToken simVerticesToken_; edm::Service fs; TTree *t_event; - int b_nGEMSimHits; + int b_nME0SimHits, b_nGEMSimHits; + + /* ME */ + TTree *t_ME0_simhit; + int b_ME0_SimHit_region, b_ME0_SimHit_chamber, b_ME0_SimHit_layer, b_ME0_SimHit_etaPartition, b_ME0_SimHit_pdgId; + float b_ME0_SimHit_pt, b_ME0_SimHit_eta, b_ME0_SimHit_phi; /* GEM */ TTree *t_GEM_simhit; @@ -106,10 +117,8 @@ class MuonSimAnalyser : public edm::EDAnalyzer { MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) { - //std::string simInputLabel_ = iConfig.getUntrackedParameter("simInputLabel"); - - auto simInputLabel_ = iConfig.getParameter("simInputLabel"); - simHitsToken_ = consumes(simInputLabel_);//,"MuonGEMHits")); + ME0SimHitsToken_ = consumes(iConfig.getParameter("ME0SimInputLabel")); + GEMSimHitsToken_ = consumes(iConfig.getParameter("GEMSimInputLabel")); simTracksToken_ = consumes< edm::SimTrackContainer >(iConfig.getParameter("simTrackCollection")); simVerticesToken_ = consumes< edm::SimVertexContainer >(iConfig.getParameter("simVertexCollection")); cfg_ = iConfig; @@ -117,8 +126,20 @@ MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) t_event = fs->make("Event", "Event"); + t_event->Branch("nME0SimHits", &b_nME0SimHits, "nME0SimHits/I"); t_event->Branch("nGEMSimHits", &b_nGEMSimHits, "nGEMSimHits/I"); + /*ME0*/ + t_ME0_simhit = fs->make("ME0_SimHit", "ME0_SimHit"); + t_ME0_simhit->Branch("SimHit_pdgId", &b_ME0_SimHit_pdgId, "SimHit_pdgId/I"); + t_ME0_simhit->Branch("SimHit_pt", &b_ME0_SimHit_pt, "SimHit_pt/F"); + t_ME0_simhit->Branch("SimHit_eta", &b_ME0_SimHit_eta, "SimHit_eta/F"); + t_ME0_simhit->Branch("SimHit_phi", &b_ME0_SimHit_phi, "SimHit_phi/F"); + t_ME0_simhit->Branch("SimHit_region", &b_ME0_SimHit_region, "SimHit_region/I"); + t_ME0_simhit->Branch("SimHit_chamber", &b_ME0_SimHit_chamber, "SimHit_chaber/I"); + t_ME0_simhit->Branch("SimHit_layer", &b_ME0_SimHit_layer, "SimHit_layer/I"); + t_ME0_simhit->Branch("SimHit_etaPartition", &b_ME0_SimHit_etaPartition, "SimHit_etaParition/I"); + /*GEM*/ t_GEM_simhit = fs->make("GEM_SimHit", "GEM_SimHit"); t_GEM_simhit->Branch("SimHit_pdgId", &b_GEM_SimHit_pdgId, "SimHit_pdgId/I"); @@ -142,53 +163,82 @@ void MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { /* GEM Geometry */ - edm::ESHandle hGEMGeom; - iSetup.get().get(hGEMGeom); + //edm::ESHandle hGEMGeom; + //iSetup.get().get(hGEMGeom); //const GEMGeometry* GEMGeometry_ = &*hGEMGeom; - edm::Handle simHits; + edm::Handle ME0SimHits; + edm::Handle GEMSimHits; edm::Handle simTracks; edm::Handle simVertices; - iEvent.getByToken(simHitsToken_, simHits); + iEvent.getByToken(ME0SimHitsToken_, ME0SimHits); + iEvent.getByToken(GEMSimHitsToken_, GEMSimHits); iEvent.getByToken(simTracksToken_, simTracks); iEvent.getByToken(simVerticesToken_, simVertices); //if ( !simHits.isValid() || !simTracks.isValid() || !simVertices.isValid()) return; - if (!simHits.isValid()) return; initValue(); - const edm::PSimHitContainer & sim_hits = *simHits.product(); - - /* GEM */ - for (auto& sh : sim_hits){ - GEMDetId det_id = sh.detUnitId(); - auto vec = sh.momentumAtEntry(); - std::cout << "chk " << std::endl; - b_GEM_SimHit_pdgId = sh.particleType(); - - TDatabasePDG *pdg = TDatabasePDG::Instance(); - - if (auto particle_pdg = pdg->GetParticle(b_GEM_SimHit_pdgId)) { - std::cout << particle_pdg->GetName() << " " << b_GEM_SimHit_pdgId << std::endl; - } else { - std::cout << "Cannot understand!!! " << b_GEM_SimHit_pdgId << std::endl; + /* ME0 */ + if (ME0SimHits.isValid()) { + const edm::PSimHitContainer & ME0_sim_hits = *ME0SimHits.product(); + for (auto& sh : ME0_sim_hits){ + ME0DetId det_id = sh.detUnitId(); + auto vec = sh.momentumAtEntry(); + b_ME0_SimHit_pdgId = sh.particleType(); + + TDatabasePDG *pdg = TDatabasePDG::Instance(); + if (auto particle_pdg = pdg->GetParticle(b_ME0_SimHit_pdgId)) { + std::cout << particle_pdg->GetName() << " " << b_ME0_SimHit_pdgId << std::endl; + } else { + std::cout << "Cannot understand!!! " << b_ME0_SimHit_pdgId << std::endl; + } + + b_ME0_SimHit_pt = vec.perp(); + b_ME0_SimHit_eta = vec.eta(); + b_ME0_SimHit_phi = sh.phiAtEntry(); + + b_ME0_SimHit_region = det_id.region(); + b_ME0_SimHit_chamber = det_id.chamber(); + b_ME0_SimHit_layer = det_id.layer(); + b_ME0_SimHit_etaPartition = det_id.roll(); + + ++b_nME0SimHits; + t_ME0_simhit->Fill(); } + } else return; - b_GEM_SimHit_pt = vec.perp(); - b_GEM_SimHit_eta = vec.eta(); - b_GEM_SimHit_phi = sh.phiAtEntry(); - - b_GEM_SimHit_region = det_id.region(); - b_GEM_SimHit_station = det_id.station(); - b_GEM_SimHit_ring = det_id.ring(); - b_GEM_SimHit_chamber = det_id.chamber(); - b_GEM_SimHit_layer = det_id.layer(); - b_GEM_SimHit_etaPartition = det_id.roll(); - - ++b_nGEMSimHits; - t_GEM_simhit->Fill(); - } + /* GEM */ + if (GEMSimHits.isValid()) { + const edm::PSimHitContainer & GEM_sim_hits = *GEMSimHits.product(); + for (auto& sh : GEM_sim_hits){ + GEMDetId det_id = sh.detUnitId(); + auto vec = sh.momentumAtEntry(); + b_GEM_SimHit_pdgId = sh.particleType(); + + TDatabasePDG *pdg = TDatabasePDG::Instance(); + if (auto particle_pdg = pdg->GetParticle(b_GEM_SimHit_pdgId)) { + std::cout << particle_pdg->GetName() << " " << b_GEM_SimHit_pdgId << std::endl; + } else { + std::cout << "Cannot understand!!! " << b_GEM_SimHit_pdgId << std::endl; + } + + b_GEM_SimHit_pt = vec.perp(); + b_GEM_SimHit_eta = vec.eta(); + b_GEM_SimHit_phi = sh.phiAtEntry(); + + b_GEM_SimHit_region = det_id.region(); + b_GEM_SimHit_station = det_id.station(); + b_GEM_SimHit_ring = det_id.ring(); + b_GEM_SimHit_chamber = det_id.chamber(); + b_GEM_SimHit_layer = det_id.layer(); + b_GEM_SimHit_etaPartition = det_id.roll(); + + ++b_nGEMSimHits; + t_GEM_simhit->Fill(); + } + } else return; t_event->Fill(); } @@ -200,11 +250,15 @@ void MuonSimAnalyser::beginRun(const edm::Run& run, const edm::EventSetup& iSetu void MuonSimAnalyser::endRun(Run const&, EventSetup const&){} void MuonSimAnalyser::initValue() { - b_nGEMSimHits = -1; + b_nME0SimHits = -1; b_nGEMSimHits = -1; + + /*ME0 */ + b_ME0_SimHit_region = -9; b_ME0_SimHit_chamber = -9; b_ME0_SimHit_layer = -9; b_ME0_SimHit_etaPartition = -9; b_ME0_SimHit_pdgId = -99; + b_ME0_SimHit_pt = -9; b_ME0_SimHit_eta = -9; b_ME0_SimHit_phi = -9; + /*GEM */ b_GEM_SimHit_region = -9; b_GEM_SimHit_station = -9; b_GEM_SimHit_ring = -9; b_GEM_SimHit_chamber = -9; b_GEM_SimHit_layer = -9; b_GEM_SimHit_etaPartition = -9; b_GEM_SimHit_pdgId = -99; b_GEM_SimHit_pt = -9; b_GEM_SimHit_eta = -9; b_GEM_SimHit_phi = -9; - } //define this as a plug-in diff --git a/MuonAnalyser/test/runHGCalSimTest.py b/MuonAnalyser/test/runHGCalSimTest.py index 0b5a44d368f..6230a238945 100644 --- a/MuonAnalyser/test/runHGCalSimTest.py +++ b/MuonAnalyser/test/runHGCalSimTest.py @@ -20,10 +20,9 @@ process.source.skipEvents = cms.untracked.uint32(0) #process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') -process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_MinBias/190213_140302/0000/step1_10.root') -#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_singleNu_RECO/190129_065738/0000/singleNu_GEN-SIM-DIGI_10.root') -#process.source.fileNames.append('/store/user/yekang/me0/tenMu_modified/tenMu_GEN-SIM-DIGI_050.root') -#process.source.fileNames.append('/store/user/yekang/me0/tenMu_default/tenMu_GEN-SIM-DIGI_060.root') +#process.source.fileNames.append('/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_MinBias/190213_140302/0000/step1_10.root') +#process.source.fileNames.append('root://uosaf0007.sscc.uos.ac.kr:1094//xrootd/store/user/yekang/CRAB_PrivateMC/HGCalStainless_default_me0_diMu_RECO/190225_172244/0000/diMu_GEN-SIM-DIGI_951.root') +process.source.fileNames.append('root://uosaf0007.sscc.uos.ac.kr:1094//xrootd/store/user/yekang/CRAB_PrivateMC/HGCalStainless_modified_me0_diMu_RECO/190225_172318/0000/diMu_GEN-SIM-DIGI_489.root') #from glob import glob #process.source.fileNames.append('file:/cms/ldap_home/yckang/me0/CMSSW_10_4_0/src/MuonPerformance/MuonAnalyser/test/tenMu_GEN-SIM-DIGI.root') @@ -60,7 +59,8 @@ process.MuonSimAnalyser = cms.EDAnalyzer('MuonSimAnalyser', # verboseSimHit = cms.untracked.int32(1), - simInputLabel = cms.InputTag('g4SimHits', "MuonGEMHits"), + ME0SimInputLabel = cms.InputTag('g4SimHits', "MuonME0Hits"), + GEMSimInputLabel = cms.InputTag('g4SimHits', "MuonGEMHits"), # simMuOnlyGEM = cms.untracked.bool(True), #verboseSimHit = cms.untracked.int32(1), #simInputLabel = cms.InputTag('g4SimHits',"MuonGEMHits"), @@ -68,7 +68,7 @@ simVertexCollection = cms.InputTag('g4SimHits') ) -#process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser + process.MuonSimAnalyser) -process.p = cms.Path(process.MuonSimAnalyser) +process.p = cms.Path(process.MuonDetHitAnalyser + process.MuonTrackAnalyser + process.MuonSimAnalyser) +#process.p = cms.Path(process.MuonSimAnalyser) process.schedule = cms.Schedule(process.p) From 58e0d25e9417d91689e63caeb6c82fe2c9d4d261 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Thu, 14 Mar 2019 02:39:13 +0900 Subject: [PATCH 48/50] Add isLooseME0 in MuonTrackAnalyser --- MuonAnalyser/plugins/MuonTrackAnalyser.cc | 69 +++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/MuonAnalyser/plugins/MuonTrackAnalyser.cc b/MuonAnalyser/plugins/MuonTrackAnalyser.cc index a3bc90aaefc..f390896434b 100644 --- a/MuonAnalyser/plugins/MuonTrackAnalyser.cc +++ b/MuonAnalyser/plugins/MuonTrackAnalyser.cc @@ -112,6 +112,7 @@ class MuonTrackAnalyser : public edm::EDAnalyzer { void initMuonValue(); void initValue(); + bool isME0MuonSelNew(reco::Muon muon, double dEtaCut, double dPhiCut, double dPhiBendCut); // ----------member data --------------------------- edm::EDGetTokenT me0Segments_; @@ -132,6 +133,8 @@ class MuonTrackAnalyser : public edm::EDAnalyzer { edm::Service fs; + const ME0Geometry* ME0Geometry_; + TTree *t_event; int b_run, b_lumi, b_latency; int b_nME0Segments, b_nCSCSegments, b_nGEMSegments, b_nDT4DSegments; @@ -159,11 +162,11 @@ class MuonTrackAnalyser : public edm::EDAnalyzer { /* Muon */ TTree *t_genMuon; float b_genMuon_pt, b_genMuon_eta, b_genMuon_phi; - int b_genMuon_isTight, b_genMuon_isMedium, b_genMuon_isLoose, b_genMuon_isTracker, b_genMuon_isGlobal, b_genMuon_isME0, b_genMuon_nMatchedStationLayer; + int b_genMuon_isTight, b_genMuon_isMedium, b_genMuon_isLoose, b_genMuon_isTracker, b_genMuon_isGlobal, b_genMuon_isME0, b_genMuon_isLooseME0, b_genMuon_nMatchedStationLayer; TTree *t_Muon; float b_muon_pt, b_muon_eta, b_muon_phi; - int b_muon_isTight, b_muon_isMedium, b_muon_isLoose, b_muon_isTracker, b_muon_isGlobal, b_muon_isME0, b_muon_nMatchedStationLayer; + int b_muon_isTight, b_muon_isMedium, b_muon_isLoose, b_muon_isTracker, b_muon_isGlobal, b_muon_isME0, b_muon_isLooseME0, b_muon_nMatchedStationLayer; }; MuonTrackAnalyser::MuonTrackAnalyser(const edm::ParameterSet& iConfig) @@ -240,6 +243,7 @@ MuonTrackAnalyser::MuonTrackAnalyser(const edm::ParameterSet& iConfig) t_genMuon->Branch("isTracker", &b_genMuon_isTracker, "isTracker/I"); t_genMuon->Branch("isGlobal", &b_genMuon_isGlobal, "isGlobal/I"); t_genMuon->Branch("isME0", &b_genMuon_isME0, "isME0/I"); + t_genMuon->Branch("isLooseME0", &b_genMuon_isLooseME0, "isLooseME0/I"); t_genMuon->Branch("isTight", &b_genMuon_isTight, "isTight/I"); t_genMuon->Branch("isMedium", &b_genMuon_isMedium, "isMedium/I"); t_genMuon->Branch("isLoose", &b_genMuon_isLoose, "isLoose/I"); @@ -252,6 +256,7 @@ MuonTrackAnalyser::MuonTrackAnalyser(const edm::ParameterSet& iConfig) t_Muon->Branch("isTracker", &b_muon_isTracker, "isTracker/I"); t_Muon->Branch("isGlobal", &b_muon_isGlobal, "isGlobal/I"); t_Muon->Branch("isME0", &b_muon_isME0, "isME0/I"); + t_Muon->Branch("isLooseME0", &b_muon_isLooseME0, "isLooseME0/I"); t_Muon->Branch("isTight", &b_muon_isTight, "isTight/I"); t_Muon->Branch("isMedium", &b_muon_isMedium, "isMedium/I"); t_Muon->Branch("isLoose", &b_muon_isLoose, "isLoose/I"); @@ -267,7 +272,7 @@ MuonTrackAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet { edm::ESHandle hME0Geom; iSetup.get().get(hME0Geom); - const ME0Geometry* ME0Geometry_ = &*hME0Geom; + ME0Geometry_ = &*hME0Geom; /* ME0 Geometry */ edm::Handle me0Segments; @@ -418,6 +423,12 @@ MuonTrackAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet initMuonValue(); edm::RefToBase muRef = muonHandle->refAt(i); const reco::Muon* mu = muRef.get(); + + double mom = mu->p(); + double dPhiCut_ = std::min(std::max(1.2/mom,1.2/100),0.056); + double dPhiBendCut_ = std::min(std::max(0.2/mom,0.2/100),0.0096); + b_muon_isLooseME0 = isME0MuonSelNew(*mu, 0.077, dPhiCut_, dPhiBendCut_); + b_muon_isTight = muon::isTightMuon(*mu, pv0); b_muon_isMedium = muon::isMediumMuon(*mu); b_muon_isLoose = muon::isLooseMuon(*mu); @@ -445,7 +456,7 @@ void MuonTrackAnalyser::endRun(Run const&, EventSetup const&){} void MuonTrackAnalyser::initMuonValue() { b_genMuon_pt = -9; b_genMuon_eta = -9; b_genMuon_phi = -9; - b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; b_muon_isTracker = -1; b_muon_isGlobal = -1; b_muon_isME0 = -1; + b_muon_isTight = -1; b_muon_isMedium = -1; b_muon_isLoose = -1; b_muon_isTracker = -1; b_muon_isGlobal = -1; b_muon_isME0 = -1; b_muon_isLooseME0 = -1; b_muon_pt = -9; b_muon_eta = -9; b_muon_phi = -9; b_muon_nMatchedStationLayer = -9; @@ -474,5 +485,55 @@ void MuonTrackAnalyser::initValue() { b_DT_4DSeg_hasZed = -1; } +bool MuonTrackAnalyser::isME0MuonSelNew(reco::Muon muon, double dEtaCut, double dPhiCut, double dPhiBendCut) +{ + bool result = false; + bool isME0 = muon.isME0Muon(); + + if(isME0){ + + double deltaEta = 999; + double deltaPhi = 999; + double deltaPhiBend = 999; + + const std::vector& chambers = muon.matches(); + for( std::vector::const_iterator chamber = chambers.begin(); chamber != chambers.end(); ++chamber ){ + + if (chamber->detector() == 5){ + + for ( std::vector::const_iterator segment = chamber->me0Matches.begin(); segment != chamber->me0Matches.end(); ++segment ){ + + LocalPoint trk_loc_coord(chamber->x, chamber->y, 0); + LocalPoint seg_loc_coord(segment->x, segment->y, 0); + LocalVector trk_loc_vec(chamber->dXdZ, chamber->dYdZ, 1); + LocalVector seg_loc_vec(segment->dXdZ, segment->dYdZ, 1); + + const ME0Chamber * me0chamber = ME0Geometry_->chamber(chamber->id); + + GlobalPoint trk_glb_coord = me0chamber->toGlobal(trk_loc_coord); + GlobalPoint seg_glb_coord = me0chamber->toGlobal(seg_loc_coord); + + //double segDPhi = segment->me0SegmentRef->deltaPhi(); + // need to check if this works + double segDPhi = me0chamber->computeDeltaPhi(seg_loc_coord, seg_loc_vec); + double trackDPhi = me0chamber->computeDeltaPhi(trk_loc_coord, trk_loc_vec); + + deltaEta = std::abs(trk_glb_coord.eta() - seg_glb_coord.eta() ); + deltaPhi = std::abs(trk_glb_coord.phi() - seg_glb_coord.phi() ); + deltaPhiBend = std::abs(segDPhi - trackDPhi); + + if (deltaEta < dEtaCut && deltaPhi < dPhiCut && deltaPhiBend < dPhiBendCut) result = true; + + } + } + } + + } + + return result; + +} + + //define this as a plug-in DEFINE_FWK_MODULE(MuonTrackAnalyser); From 9491f9042c5fd0b98a947b2c3854bee0257a6123 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Wed, 13 Mar 2019 17:48:03 +0900 Subject: [PATCH 49/50] Add analysis code for several detectors (#8) Add analysis code for several detectors --- MuonAnalyser/plugins/MuonTrackAnalyser.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/MuonAnalyser/plugins/MuonTrackAnalyser.cc b/MuonAnalyser/plugins/MuonTrackAnalyser.cc index f390896434b..d1db57911f7 100644 --- a/MuonAnalyser/plugins/MuonTrackAnalyser.cc +++ b/MuonAnalyser/plugins/MuonTrackAnalyser.cc @@ -533,7 +533,6 @@ bool MuonTrackAnalyser::isME0MuonSelNew(reco::Muon muon, double dEtaCut, double return result; } - //define this as a plug-in DEFINE_FWK_MODULE(MuonTrackAnalyser); From 4f5e8b304886dfca6a497581cb80ceab97de8535 Mon Sep 17 00:00:00 2001 From: jang00777 Date: Tue, 26 Mar 2019 17:10:38 +0900 Subject: [PATCH 50/50] Add function to extract track and vertex and get mom pdgId from simhit --- MuonAnalyser/plugins/MuonSimAnalyser.cc | 124 +++++++++++++++++++----- 1 file changed, 101 insertions(+), 23 deletions(-) diff --git a/MuonAnalyser/plugins/MuonSimAnalyser.cc b/MuonAnalyser/plugins/MuonSimAnalyser.cc index 5e16ebeb870..96639cb03c6 100644 --- a/MuonAnalyser/plugins/MuonSimAnalyser.cc +++ b/MuonAnalyser/plugins/MuonSimAnalyser.cc @@ -71,6 +71,7 @@ #include "TLorentzVector.h" #include "TTree.h" #include "TDatabasePDG.h" +#include using namespace std; using namespace edm; @@ -90,6 +91,12 @@ class MuonSimAnalyser : public edm::EDAnalyzer { void initValue(); + enum detType {DET_NONE = 0, DET_ME0, DET_GEM, DET_CSC, DET_DT, DET_RPC}; + + bool isSimTrackGood(const SimTrack & , int = -1, detType = DET_NONE); + std::tuple matchSimHitToSimTrack(const PSimHit & sh, const edm::SimTrackContainer & sim_track, int pdg=-1, detType = DET_NONE); + int getMotherPdgId(const SimTrack & trk, const edm::PSimHitContainer & sim_hit, const edm::SimVertexContainer & sim_vertex); + // ----------member data --------------------------- edm::ParameterSet cfg_; edm::EDGetToken ME0SimHitsToken_; @@ -99,18 +106,21 @@ class MuonSimAnalyser : public edm::EDAnalyzer { edm::Service fs; + float GEM_minEta_ = 1.5; float GEM_maxEta_ = 2.5; + float ME0_minEta_ = 1.9; float ME0_maxEta_ = 3.; + TTree *t_event; int b_nME0SimHits, b_nGEMSimHits; /* ME */ TTree *t_ME0_simhit; - int b_ME0_SimHit_region, b_ME0_SimHit_chamber, b_ME0_SimHit_layer, b_ME0_SimHit_etaPartition, b_ME0_SimHit_pdgId; - float b_ME0_SimHit_pt, b_ME0_SimHit_eta, b_ME0_SimHit_phi; + int b_ME0_SimHit_region, b_ME0_SimHit_chamber, b_ME0_SimHit_layer, b_ME0_SimHit_etaPartition, b_ME0_SimHit_pdgId, b_ME0_SimHit_momPdgId; + float b_ME0_SimHit_pt, b_ME0_SimHit_eta, b_ME0_SimHit_phi, b_ME0_SimHit_E; /* GEM */ TTree *t_GEM_simhit; - int b_GEM_SimHit_region, b_GEM_SimHit_station, b_GEM_SimHit_ring, b_GEM_SimHit_chamber, b_GEM_SimHit_layer, b_GEM_SimHit_etaPartition, b_GEM_SimHit_pdgId; - float b_GEM_SimHit_pt, b_GEM_SimHit_eta, b_GEM_SimHit_phi; + int b_GEM_SimHit_region, b_GEM_SimHit_station, b_GEM_SimHit_ring, b_GEM_SimHit_chamber, b_GEM_SimHit_layer, b_GEM_SimHit_etaPartition, b_GEM_SimHit_pdgId, b_GEM_SimHit_momPdgId; + float b_GEM_SimHit_pt, b_GEM_SimHit_eta, b_GEM_SimHit_phi, b_GEM_SimHit_E; }; @@ -132,9 +142,11 @@ MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) /*ME0*/ t_ME0_simhit = fs->make("ME0_SimHit", "ME0_SimHit"); t_ME0_simhit->Branch("SimHit_pdgId", &b_ME0_SimHit_pdgId, "SimHit_pdgId/I"); + t_ME0_simhit->Branch("SimHit_momPdgId", &b_ME0_SimHit_momPdgId, "SimHit_momPdgId/I"); t_ME0_simhit->Branch("SimHit_pt", &b_ME0_SimHit_pt, "SimHit_pt/F"); t_ME0_simhit->Branch("SimHit_eta", &b_ME0_SimHit_eta, "SimHit_eta/F"); t_ME0_simhit->Branch("SimHit_phi", &b_ME0_SimHit_phi, "SimHit_phi/F"); + t_ME0_simhit->Branch("SimHit_E", &b_ME0_SimHit_E, "SimHit_E/F"); t_ME0_simhit->Branch("SimHit_region", &b_ME0_SimHit_region, "SimHit_region/I"); t_ME0_simhit->Branch("SimHit_chamber", &b_ME0_SimHit_chamber, "SimHit_chaber/I"); t_ME0_simhit->Branch("SimHit_layer", &b_ME0_SimHit_layer, "SimHit_layer/I"); @@ -143,9 +155,11 @@ MuonSimAnalyser::MuonSimAnalyser(const edm::ParameterSet& iConfig) /*GEM*/ t_GEM_simhit = fs->make("GEM_SimHit", "GEM_SimHit"); t_GEM_simhit->Branch("SimHit_pdgId", &b_GEM_SimHit_pdgId, "SimHit_pdgId/I"); + t_GEM_simhit->Branch("SimHit_momPdgId", &b_GEM_SimHit_momPdgId, "SimHit_momPdgId/I"); t_GEM_simhit->Branch("SimHit_pt", &b_GEM_SimHit_pt, "SimHit_pt/F"); t_GEM_simhit->Branch("SimHit_eta", &b_GEM_SimHit_eta, "SimHit_eta/F"); t_GEM_simhit->Branch("SimHit_phi", &b_GEM_SimHit_phi, "SimHit_phi/F"); + t_GEM_simhit->Branch("SimHit_E", &b_GEM_SimHit_E, "SimHit_E/F"); t_GEM_simhit->Branch("SimHit_region", &b_GEM_SimHit_region, "SimHit_region/I"); t_GEM_simhit->Branch("SimHit_station", &b_GEM_SimHit_station, "SimHit_station/I"); t_GEM_simhit->Branch("SimHit_ring", &b_GEM_SimHit_ring, "SimHit_ring/I"); @@ -162,10 +176,15 @@ MuonSimAnalyser::~MuonSimAnalyser() void MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + /* ME0 Geometry */ + edm::ESHandle hME0Geom; + iSetup.get().get(hME0Geom); + const ME0Geometry* ME0Geometry_ = &*hME0Geom; + /* GEM Geometry */ - //edm::ESHandle hGEMGeom; - //iSetup.get().get(hGEMGeom); - //const GEMGeometry* GEMGeometry_ = &*hGEMGeom; + edm::ESHandle hGEMGeom; + iSetup.get().get(hGEMGeom); + const GEMGeometry* GEMGeometry_ = &*hGEMGeom; edm::Handle ME0SimHits; edm::Handle GEMSimHits; @@ -179,24 +198,36 @@ MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup initValue(); + const edm::SimTrackContainer & sim_tracks = *simTracks.product(); + const edm::SimVertexContainer & sim_vertices = *simVertices.product(); + + /* ME0 */ if (ME0SimHits.isValid()) { const edm::PSimHitContainer & ME0_sim_hits = *ME0SimHits.product(); for (auto& sh : ME0_sim_hits){ - ME0DetId det_id = sh.detUnitId(); - auto vec = sh.momentumAtEntry(); + ME0DetId det_id(sh.detUnitId()); + auto vec = sh.momentumAtEntry(); + auto shLp = sh.localPosition(); + const BoundPlane & surface = ME0Geometry_->idToDet(det_id)->surface(); + auto shGp = surface.toGlobal(shLp); + b_ME0_SimHit_pdgId = sh.particleType(); + auto sim_track_tuple = matchSimHitToSimTrack(sh, sim_tracks); + b_ME0_SimHit_momPdgId = getMotherPdgId(std::get<0>(sim_track_tuple), ME0_sim_hits, sim_vertices); + std::cout << " >>>>>>> TUPLE : [ " << std::get<0>(sim_track_tuple) << " ] / [ " << std::get<1>(sim_track_tuple) << " ] / [ " << std::get<2>(sim_track_tuple) << " ] / [ " << std::get<3>(sim_track_tuple) << " ] " << std::endl; TDatabasePDG *pdg = TDatabasePDG::Instance(); if (auto particle_pdg = pdg->GetParticle(b_ME0_SimHit_pdgId)) { - std::cout << particle_pdg->GetName() << " " << b_ME0_SimHit_pdgId << std::endl; + std::cout << particle_pdg->GetName() << " " << b_ME0_SimHit_pdgId << " mom pdg : " << b_ME0_SimHit_momPdgId << std::endl; } else { std::cout << "Cannot understand!!! " << b_ME0_SimHit_pdgId << std::endl; } b_ME0_SimHit_pt = vec.perp(); - b_ME0_SimHit_eta = vec.eta(); - b_ME0_SimHit_phi = sh.phiAtEntry(); + b_ME0_SimHit_eta = shGp.eta(); + b_ME0_SimHit_phi = shGp.phi(); + b_ME0_SimHit_E = sh.pabs(); b_ME0_SimHit_region = det_id.region(); b_ME0_SimHit_chamber = det_id.chamber(); @@ -213,21 +244,29 @@ MuonSimAnalyser::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup if (GEMSimHits.isValid()) { const edm::PSimHitContainer & GEM_sim_hits = *GEMSimHits.product(); for (auto& sh : GEM_sim_hits){ - GEMDetId det_id = sh.detUnitId(); - auto vec = sh.momentumAtEntry(); + GEMDetId det_id(sh.detUnitId()); + auto vec = sh.momentumAtEntry(); + auto shLp = sh.localPosition(); + const BoundPlane & surface = GEMGeometry_->idToDet(det_id)->surface(); + auto shGp = surface.toGlobal(shLp); + b_GEM_SimHit_pdgId = sh.particleType(); - + auto sim_track_tuple = matchSimHitToSimTrack(sh, sim_tracks); + b_GEM_SimHit_momPdgId = getMotherPdgId(std::get<0>(sim_track_tuple), GEM_sim_hits, sim_vertices); + std::cout << " >>>>>>> TUPLE : [ " << std::get<0>(sim_track_tuple) << " ] / [ " << std::get<1>(sim_track_tuple) << " ] / [ " << std::get<2>(sim_track_tuple) << " ] / [ " << std::get<3>(sim_track_tuple) << " ] " << std::endl; + TDatabasePDG *pdg = TDatabasePDG::Instance(); if (auto particle_pdg = pdg->GetParticle(b_GEM_SimHit_pdgId)) { - std::cout << particle_pdg->GetName() << " " << b_GEM_SimHit_pdgId << std::endl; + std::cout << particle_pdg->GetName() << " " << b_GEM_SimHit_pdgId << " mom pdg : " << b_GEM_SimHit_momPdgId << std::endl; } else { std::cout << "Cannot understand!!! " << b_GEM_SimHit_pdgId << std::endl; } b_GEM_SimHit_pt = vec.perp(); - b_GEM_SimHit_eta = vec.eta(); - b_GEM_SimHit_phi = sh.phiAtEntry(); - + b_GEM_SimHit_eta = shGp.eta(); + b_GEM_SimHit_phi = shGp.phi(); + b_GEM_SimHit_E = sh.pabs(); + b_GEM_SimHit_region = det_id.region(); b_GEM_SimHit_station = det_id.station(); b_GEM_SimHit_ring = det_id.ring(); @@ -253,12 +292,51 @@ void MuonSimAnalyser::initValue() { b_nME0SimHits = -1; b_nGEMSimHits = -1; /*ME0 */ - b_ME0_SimHit_region = -9; b_ME0_SimHit_chamber = -9; b_ME0_SimHit_layer = -9; b_ME0_SimHit_etaPartition = -9; b_ME0_SimHit_pdgId = -99; - b_ME0_SimHit_pt = -9; b_ME0_SimHit_eta = -9; b_ME0_SimHit_phi = -9; + b_ME0_SimHit_region = -9; b_ME0_SimHit_chamber = -9; b_ME0_SimHit_layer = -9; b_ME0_SimHit_etaPartition = -9; b_ME0_SimHit_pdgId = -99; b_ME0_SimHit_momPdgId = -99; + b_ME0_SimHit_pt = -9; b_ME0_SimHit_eta = -9; b_ME0_SimHit_phi = -9; b_ME0_SimHit_E = -9; /*GEM */ - b_GEM_SimHit_region = -9; b_GEM_SimHit_station = -9; b_GEM_SimHit_ring = -9; b_GEM_SimHit_chamber = -9; b_GEM_SimHit_layer = -9; b_GEM_SimHit_etaPartition = -9; b_GEM_SimHit_pdgId = -99; - b_GEM_SimHit_pt = -9; b_GEM_SimHit_eta = -9; b_GEM_SimHit_phi = -9; + b_GEM_SimHit_region = -9; b_GEM_SimHit_station = -9; b_GEM_SimHit_ring = -9; b_GEM_SimHit_chamber = -9; b_GEM_SimHit_layer = -9; b_GEM_SimHit_etaPartition = -9; b_GEM_SimHit_pdgId = -99; b_GEM_SimHit_momPdgId = -99; + b_GEM_SimHit_pt = -9; b_GEM_SimHit_eta = -9; b_GEM_SimHit_phi = -9; b_GEM_SimHit_E = -9; +} + +bool MuonSimAnalyser::isSimTrackGood(const SimTrack &t, int pdg, detType detName) { + // SimTrack selection + if (t.noVertex()) return false; + //if (t.noGenpart()) return false; + if (pdg != -1 ) { + if (t.type() != pdg) return false; // only interested in pdg matched particle + } + //if (t.momentum().pt() < minPt_ ) return false; + const float eta(std::abs(t.momentum().eta())); + if (detName == DET_GEM) { + if (eta > GEM_maxEta_ || eta < GEM_minEta_ ) return false; // no GEMs could be in such eta + } else if (detName == DET_ME0) { + if (eta > ME0_maxEta_ || eta < ME0_minEta_ ) return false; // no ME0 could be in such eta + } + return true; +} + +std::tuple MuonSimAnalyser::matchSimHitToSimTrack(const PSimHit & sh, const edm::SimTrackContainer & sim_track, int pdg, detType detName) { + int pdgId = sh.particleType(); + for (auto & trk : sim_track) { + if (!isSimTrackGood(trk, pdg, detName)) continue; + if (sh.trackId() != trk.trackId()) continue; + return std::make_tuple(trk, trk.vertIndex(), trk.genpartIndex(), pdgId); + } + return std::make_tuple(SimTrack(), -1, -1, pdgId); +} + +int MuonSimAnalyser::getMotherPdgId(const SimTrack & trk, const edm::PSimHitContainer & sim_hit, const edm::SimVertexContainer & sim_vertex){ + unsigned int p_vtx_id = 0; + for (auto & vtx : sim_vertex) { + if (vtx.noParent()) continue; + if((int)vtx.vertexId() == trk.vertIndex()) p_vtx_id = vtx.parentIndex(); + } + for (auto & sh : sim_hit) { + if (sh.trackId() == p_vtx_id) return sh.particleType(); + } + return -999; } //define this as a plug-in