Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 51 additions & 28 deletions MuonAnalyser/plugins/SliceTestAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,28 +119,33 @@ SliceTestAnalysis::SliceTestAnalysis(const edm::ParameterSet& iConfig) :

t_run = fs->make<TTree>("Run", "Run");
t_run->Branch("run", &b_run, "run/I");

t_hit = fs->make<TTree>("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<TTree>("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<TH1D>(Form("res_x"),"res_x",100,-50,50);
h_res_y=fs->make<TH1D>(Form("res_y"),"res_y",100,-50,50);
h_pull_x=fs->make<TH1D>(Form("pull_x"),"pull_x",100,-50,50);
h_pull_y=fs->make<TH1D>(Form("pull_y"),"pull_y",100,-50,50);

t_hit = fs->make<TTree>("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) {
Expand Down Expand Up @@ -204,8 +211,9 @@ SliceTestAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
iEvent.getByToken(muons_, muons);
//std::cout << "muons->size() " << muons->size() <<std::endl;

std::vector<GEMRecHit*> goodMuHits;
std::vector<GEMRecHit*> poorMuHits;
std::vector<GEMRecHit*> tightMuHits;
std::vector<GEMRecHit*> looseMuHits;
std::vector<GEMRecHit*> noidMuHits;

for (size_t i = 0; i < muons->size(); ++i) {
b_nMuons++;
Expand Down Expand Up @@ -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<GEMRecHit*>(*hit));
if (mu->passed(reco::Muon::Selector::CutBasedIdTight))
tightMuHits.push_back(static_cast<GEMRecHit*>(*hit));
else if (mu->passed(reco::Muon::Selector::CutBasedIdLoose))
looseMuHits.push_back(static_cast<GEMRecHit*>(*hit));
else
noidMuHits.push_back(static_cast<GEMRecHit*>(*hit));
}
}

Expand All @@ -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;
Expand All @@ -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;
// }

Expand Down Expand Up @@ -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());
Expand Down