diff --git a/MuonAnalyser/plugins/SliceTestAnalysis.cc b/MuonAnalyser/plugins/SliceTestAnalysis.cc index 99abb2be707..8d16471d234 100644 --- a/MuonAnalyser/plugins/SliceTestAnalysis.cc +++ b/MuonAnalyser/plugins/SliceTestAnalysis.cc @@ -83,6 +83,8 @@ class SliceTestAnalysis : public edm::EDAnalyzer { 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_hit; int b_run, b_lumi, b_event; int b_firstStrip, b_nStrips, b_chamber, b_layer, b_etaPartition, b_muonQuality; @@ -117,28 +119,33 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) : t_run = fs->make("Run", "Run"); t_run->Branch("run", &b_run, "run/I"); - - 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("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_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"); 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:low 1:high"); + 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"); - + for (int ichamber=0; ichamber<36;++ichamber) { // for (int ichamber=27; ichamber<=30;++ichamber) { for (int ilayer=0; ilayer<2;++ilayer) { @@ -204,8 +211,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet iEvent.getByToken(muons_, muons); //std::cout << "muons->size() " << muons->size() < goodMuHits; - std::vector poorMuHits; + std::vector tightMuHits; + std::vector looseMuHits; + std::vector noidMuHits; for (size_t i = 0; i < muons->size(); ++i) { b_nMuons++; @@ -274,7 +282,12 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet if ( (*hit)->geographicalId().det() == 2 && (*hit)->geographicalId().subdetId() == 4) { GEMDetId gemid((*hit)->geographicalId()); h_trkEta[gemid.chamber()][gemid.layer()]->Fill(gemid.roll()); - poorMuHits.push_back(static_cast(*hit)); + 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)); } } @@ -297,16 +310,21 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet 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()); + 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; @@ -331,9 +349,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet } } - // if (poorMuHits.size() > 0) { + // if (looseMuHits.size() > 0) { // std::cout << "POOR MU "; - // for (auto & hit : poorMuHits) std::cout << hit << " "; + // for (auto & hit : looseMuHits) std::cout << hit << " "; // std::cout << std::endl; // } @@ -366,16 +384,21 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet b_layer = rId.layer(); b_etaPartition = rId.roll(); b_muonQuality = -1; - for (auto muHit : poorMuHits) { + for (auto muHit : noidMuHits) { if (*hit == *muHit) { b_muonQuality = 0; - // std::cout << " POOR HIT" << std::endl; } } - for (auto muHit : goodMuHits) { - if (*hit == *muHit) + 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());