extern void printMuons(const MuonCollection muons) { for (unsigned short index = 0; index < muons.size(); ++index) { const MuonPointer muon = muons.at(index); cout << "Muon " << index + 1 << endl; printMuon(muon); } }
const MuonPointer Event::MostIsolatedMuon(const MuonCollection& muons, bool usePFIso) const { float bestIsolation = 999999999; unsigned int bestIsolatedLepton = 990; for (unsigned int index = 0; index < muons.size(); ++index) { float currentIsolation = 999999999; if (usePFIso) currentIsolation = muons.at(index)->pfRelativeIsolation(); else currentIsolation = muons.at(index)->relativeIsolation(); if (currentIsolation < bestIsolation) { bestIsolation = currentIsolation; bestIsolatedLepton = index; } } return muons.at(bestIsolatedLepton); }
bool TopPairMuPlusJetsReferenceSelection2011::hasExactlyOneIsolatedLepton(const EventPtr event) const { unsigned int nIsolatedGoodMuons(0); const MuonCollection allMuons(event->Muons()); for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isGoodMuon(muon) && isIsolated(muon)) ++nIsolatedGoodMuons; } return nIsolatedGoodMuons == 1; }
bool TopPairMuPlusJetsReferenceSelection2011::passesLooseMuonVeto(const EventPtr event) const { unsigned int nLooseMuons(0); const MuonCollection allMuons(event->Muons()); for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isLooseMuon(muon)) ++nLooseMuons; } return nLooseMuons < 2; }
const MuonCollection TopPairEMuReferenceSelection::goodMuons(const EventPtr event) const { const MuonCollection allMuons(event->Muons()); MuonCollection goodIsolatedMuons; for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isGoodMuon(muon)) { goodIsolatedMuons.push_back(muon); } } return goodIsolatedMuons; }
void MuonAnalyser::analyse(const EventPtr event) { if (singleMuonOnly_) return; histMan_->setCurrentHistogramFolder(histogramFolder_); weight_ = event->weight() * prescale_ * scale_; const MuonCollection muons = event->Muons(); histMan_->H1D("Number_Of_Muons")->Fill(muons.size(), weight_); for (unsigned int index = 0; index < muons.size(); ++index) { const MuonPointer muon(muons.at(index)); histMan_->H1D("All_Muon_Pt")->Fill(muon->pt(), weight_); histMan_->H1D("All_Muon_Eta")->Fill(muon->eta(), weight_); histMan_->H1D("All_Muon_AbsEta")->Fill(fabs(muon->eta()), weight_); histMan_->H1D("All_Muon_Phi")->Fill(muon->phi(), weight_); histMan_->H1D("All_Muon_pfIsolation_03")->Fill(muon->PFRelIso03(), weight_); histMan_->H1D("All_Muon_pfIsolation_04")->Fill(muon->PFRelIso04(), weight_); histMan_->H1D("All_Muon_dB")->Fill(muon->d0(), weight_); } }
const LeptonPointer TopPairMuPlusJetsReferenceSelection2011::signalLepton(const EventPtr event) const { if (!hasExactlyOneIsolatedLepton(event)) { cerr << "An error occurred in SignalSelection in event (no = " << event->eventnumber(); cerr << ", run = " << event->runnumber() << ", lumi = " << event->lumiblock() << "!" << endl; cerr << "File = " << event->file() << endl; cerr << "Access exception: No signal lepton could be found. Event doesn't pass 'hasExactlyOneIsolatedLepton' selection" << endl; throw "Access exception: No signal lepton could be found. Event doesn't pass 'hasExactlyOneIsolatedLepton' selection"; } const MuonCollection allMuons(event->Muons()); MuonCollection goodIsolatedMuons; for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isGoodMuon(muon) && isIsolated(muon)) goodIsolatedMuons.push_back(muon); } return goodIsolatedMuons.front(); }
void PhotonAnalyser::analyse(const EventPtr event){ histMan_->setCurrentHistogramFolder(histogramFolder_ + "/AllPhotons"); //const ElectronCollection electrons = topEERefSelection_->goodElectrons(event); //const MuonCollection muons = topMuMuRefSelection_->goodMuons(event); weight_ = event->weight() * prescale_ * scale_; const JetCollection jets = event->Jets(); const ElectronCollection electrons = event->Electrons(); const PhotonCollection photons = event->Photons(); const MuonCollection muons = event->Muons(); histMan_->H1D_BJetBinned("Number_Of_Photons")->Fill(photons.size(), weight_); for (unsigned int index = 0; index < photons.size(); ++index) { const PhotonPointer photon(photons.at(index)); histMan_->H1D_BJetBinned("Photon_Pt")->Fill(photon->pt(), weight_); histMan_->H1D_BJetBinned("Photon_Eta")->Fill(photon->eta(), weight_); histMan_->H1D_BJetBinned("Photon_AbsEta")->Fill(fabs(photon->eta()), weight_); histMan_->H1D_BJetBinned("Photon_Phi")->Fill(photon->phi(), weight_); histMan_->H1D_BJetBinned("Photon_ET")->Fill(photon->et(), weight_); if (photon->isInEndCapRegion()){ histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_endcap")->Fill(photon->sigmaIEtaIEta(), weight_); histMan_->H1D_BJetBinned("Photon_PFChargedHadronIso_endcap")->Fill(photon->PFChargedHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFNeutralHadronIso_endcap")->Fill(photon->PFNeutralHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFPhotonIso_endcap")->Fill(photon->PFPhotonIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFChargedHadronIso_endcap")->Fill(photon->RhoCorrectedPFChargedHadronIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFNeutralHadronIso_endcap")->Fill(photon->RhoCorrectedPFNeutralHadronIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFPhotonIso_endcap")->Fill(photon->RhoCorrectedPFPhotonIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_SCChIso_endcap")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCNuIso_endcap")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCPhIso_endcap")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso_endcap")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso_endcap")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso_endcap")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); histMan_->H2D_BJetBinned("RhoCorrectedSCFRChIso_v._Sigma_ietaieta_endcap")->Fill(photon->RhoCorrectedSCChIso(event->rho()), photon->sigmaIEtaIEta(), weight_); } else if (photon->isInBarrelRegion()) { histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_barrel")->Fill(photon->sigmaIEtaIEta(), weight_); histMan_->H1D_BJetBinned("Photon_PFChargedHadronIso_barrel")->Fill(photon->PFChargedHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFNeutralHadronIso_barrel")->Fill(photon->PFNeutralHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFPhotonIso_barrel")->Fill(photon->PFPhotonIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFChargedHadronIso_barrel")->Fill(photon->RhoCorrectedPFChargedHadronIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFNeutralHadronIso_barrel")->Fill(photon->RhoCorrectedPFNeutralHadronIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFPhotonIso_barrel")->Fill(photon->RhoCorrectedPFPhotonIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_SCChIso_barrel")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCNuIso_barrel")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCPhIso_barrel")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso_barrel")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso_barrel")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso_barrel")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RandConeChIso_barrel")->Fill(photon->phoRandConeChIso(), weight_); histMan_->H1D_BJetBinned("Photon_RandConeNuIso_barrel")->Fill(photon->phoRandConeNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_RandConePhIso_barrel")->Fill(photon->phoRandConePhIso(), weight_); histMan_->H2D_BJetBinned("RhoCorrectedSCFRChIso_v._Sigma_ietaieta_barrel")->Fill(photon->RhoCorrectedSCChIso(event->rho()), photon->sigmaIEtaIEta(), weight_); } histMan_->H1D_BJetBinned("Photon_HadOverEM")->Fill(photon->HadOverEm(), weight_); histMan_->H1D_BJetBinned("Photon_EcalIso")->Fill(photon->ecalIsolation(), weight_); histMan_->H1D_BJetBinned("Photon_HcalIso")->Fill(photon->hcalIsolation(), weight_); histMan_->H1D_BJetBinned("Photon_HcalIso2012")->Fill(photon->hcalIsolation2012(), weight_); histMan_->H1D_BJetBinned("Photon_TrckIso")->Fill(photon->trackerIsolation(), weight_); histMan_->H1D_BJetBinned("Photon_SCeta")->Fill(photon->superClusterEta(), weight_); histMan_->H1D_BJetBinned("Photon_SCphi")->Fill(photon->superClusterPhi(), weight_); histMan_->H1D_BJetBinned("Photon_SCenergy")->Fill(photon->superClusterEnergy(), weight_); histMan_->H1D_BJetBinned("Photon_SCSeedEnergy")->Fill(photon->superClusterSeedEnergy(), weight_); histMan_->H1D_BJetBinned("Photon_E3x3")->Fill(photon->Ecal3x3Cluster(), weight_); histMan_->H1D_BJetBinned("Photon_E5x5")->Fill(photon->Ecal5x5Cluster(), weight_); histMan_->H1D_BJetBinned("Photon_TrkVeto")->Fill(photon->TrackVeto(), weight_); histMan_->H1D_BJetBinned("Photon_ConvSEVeto")->Fill(photon->ConversionSafeElectronVeto(), weight_); histMan_->H1D_BJetBinned("Photon_HtowoE")->Fill(photon->SingleTowerHoE(), weight_); histMan_->H1D_BJetBinned("Photon_PFChargedHadronIso")->Fill(photon->PFChargedHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFNeutralHadronIso")->Fill(photon->PFNeutralHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_PFPhotonIso")->Fill(photon->PFPhotonIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCChIso")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCNuIso")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_SCPhIso")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RandConeChIso")->Fill(photon->phoRandConeChIso(), weight_); histMan_->H1D_BJetBinned("Photon_RandConeNuIso")->Fill(photon->phoRandConeNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_RandConePhIso")->Fill(photon->phoRandConePhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); histMan_->H2D_BJetBinned("RhoCorrectedSCFRChIso_v._Sigma_ietaieta")->Fill(photon->RhoCorrectedSCChIso(event->rho()), photon->sigmaIEtaIEta(), weight_); for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); histMan_->H1D_BJetBinned("Photon_deltaR_jets")->Fill(photon->deltaR(jet), weight_); } for (unsigned int index = 0; index < electrons.size(); ++index) { const ElectronPointer electron(electrons.at(index)); histMan_->H1D_BJetBinned("Photon_deltaR_electrons")->Fill(photon->deltaR(electron), weight_); } for (unsigned int index = 0; index < muons.size(); ++index) { const MuonPointer muon(muons.at(index)); histMan_->H1D_BJetBinned("Photon_deltaR_muons")->Fill(photon->deltaR(muon), weight_); } } }
void PhotonAnalyser::analyse_NminusOnePhotons(const EventPtr event, PhotonCollection nMinusOnePhotons, JetCollection jets, ElectronCollection electrons, MuonCollection muons, TString cut){ string folder = histogramFolder_ + "/NminusOnePhotons"; histMan_->setCurrentHistogramFolder(folder); //const ElectronCollection electrons = topMuMuRefSelection_->goodElectrons(event); //const MuonCollection muons = topMuMuRefSelection_->goodMuons(event); weight_ = event->weight() * prescale_ * scale_; // const JetCollection jets = event->Jets(); // const ElectronCollection electrons = event->Electrons(); // const MuonCollection muons = event->Muons(); // need to change to rhgo corrected? for (unsigned int index = 0; index < nMinusOnePhotons.size(); ++index) { const PhotonPointer photon(nMinusOnePhotons.at(index)); if(cut =="passesEtAndEta"){ histMan_->H1D_BJetBinned("Photon_Pt")->Fill(photon->pt(), weight_); histMan_->H1D_BJetBinned("Photon_Eta")->Fill(photon->eta(), weight_); histMan_->H1D_BJetBinned("Photon_AbsEta")->Fill(fabs(photon->eta()), weight_); histMan_->H1D_BJetBinned("Photon_ET")->Fill(photon->et(), weight_); } if(cut =="passesHOverE"){ histMan_->H1D_BJetBinned("Photon_HadOverEM")->Fill(photon->HadOverEm(), weight_); histMan_->H1D_BJetBinned("Photon_HtowoE")->Fill(photon->SingleTowerHoE(), weight_); } if (photon->isInEndCapRegion() && cut =="passesShowerShape"){ histMan_->H1D_BJetBinned("Photon_sigma_ietaieta")->Fill(photon->sigmaIEtaIEta(), weight_); histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_endcap")->Fill(photon->sigmaIEtaIEta(), weight_); } if (photon->isInBarrelRegion() && cut =="passesShowerShape"){ histMan_->H1D_BJetBinned("Photon_sigma_ietaieta")->Fill(photon->sigmaIEtaIEta(), weight_); histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_barrel")->Fill(photon->sigmaIEtaIEta(), weight_); } if (photon->isInEndCapRegion()){ histMan_->H1D_BJetBinned("Photon_PFChargedHadronIso_endcap")->Fill(photon->PFChargedHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFChargedHadronIso_endcap")->Fill(photon->RhoCorrectedPFChargedHadronIso(event->rho()), weight_); } if (photon->isInBarrelRegion()){ histMan_->H1D_BJetBinned("Photon_PFChargedHadronIso_barrel")->Fill(photon->PFChargedHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFChargedHadronIso_barrel")->Fill(photon->RhoCorrectedPFChargedHadronIso(event->rho()), weight_); } if (photon->isInEndCapRegion() && cut =="passesPFNeutralIso"){ histMan_->H1D_BJetBinned("Photon_PFNeutralHadronIso_endcap")->Fill(photon->PFNeutralHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFNeutralHadronIso_endcap")->Fill(photon->RhoCorrectedPFNeutralHadronIso(event->rho()), weight_); } if (photon->isInBarrelRegion() && cut =="passesPFNeutralIso"){ histMan_->H1D_BJetBinned("Photon_PFNeutralHadronIso_barrel")->Fill(photon->PFNeutralHadronIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFNeutralHadronIso_barrel")->Fill(photon->RhoCorrectedPFNeutralHadronIso(event->rho()), weight_); } if (photon->isInEndCapRegion() && cut =="passesPFPhotonIso"){ histMan_->H1D_BJetBinned("Photon_PFPhotonIso_endcap")->Fill(photon->PFPhotonIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFPhotonIso_endcap")->Fill(photon->RhoCorrectedPFPhotonIso(event->rho()), weight_); } if (photon->isInBarrelRegion() && cut =="passesPFPhotonIso"){ histMan_->H1D_BJetBinned("Photon_PFPhotonIso_barrel")->Fill(photon->PFPhotonIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedPFPhotonIso_barrel")->Fill(photon->RhoCorrectedPFPhotonIso(event->rho()), weight_); } if (photon->isInEndCapRegion() && cut =="passesphoSCChIso"){ histMan_->H1D_BJetBinned("Photon_SCChIso_endcap")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso_endcap")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); } if (photon->isInBarrelRegion() && cut =="passesSCChIso"){ histMan_->H1D_BJetBinned("Photon_SCChIso_barrel")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso_barrel")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); } if (photon->isInEndCapRegion() && cut =="passesphoSCNuIso"){ histMan_->H1D_BJetBinned("Photon_SCNuIso_endcap")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso_endcap")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); } if (photon->isInBarrelRegion() && cut =="passesSCNuIso"){ histMan_->H1D_BJetBinned("Photon_SCNuIso_barrel")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso_barrel")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); } if (photon->isInEndCapRegion() && cut =="passesphoSCPhIso"){ histMan_->H1D_BJetBinned("Photon_SCPhIso_endcap")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso_endcap")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); } if (photon->isInBarrelRegion() && cut =="passesSCPhIso"){ histMan_->H1D_BJetBinned("Photon_SCPhIso_barrel")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso_barrel")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); } if (cut =="passesphoSCChIso"){ histMan_->H1D_BJetBinned("Photon_SCChIso")->Fill(photon->phoSCChIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCChIso")->Fill(photon->RhoCorrectedSCChIso(event->rho()), weight_); } if (cut =="passesphoSCNuIso"){ histMan_->H1D_BJetBinned("Photon_SCNuIso")->Fill(photon->phoSCNuIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCNuIso")->Fill(photon->RhoCorrectedSCNuIso(event->rho()), weight_); } if (cut =="passesphoSCPhIso"){ histMan_->H1D_BJetBinned("Photon_SCPhIso")->Fill(photon->phoSCPhIso(), weight_); histMan_->H1D_BJetBinned("Photon_RhoCorrectedSCPhIso")->Fill(photon->RhoCorrectedSCPhIso(event->rho()), weight_); } if(cut =="passesDeltaRgammaMuons"){ for (unsigned int index = 0; index < muons.size(); ++index) { const MuonPointer muon(muons.at(index)); histMan_->H1D_BJetBinned("Photon_deltaR_muons")->Fill(photon->deltaR(muon), weight_); } } if(cut =="passesDeltaRgammaElectrons"){ for (unsigned int index = 0; index < electrons.size(); ++index) { const ElectronPointer electron(electrons.at(index)); histMan_->H1D_BJetBinned("Photon_deltaR_electrons")->Fill(photon->deltaR(electron), weight_); } } if(cut == "backgroundShape" && photon->isInBarrelRegion()){ histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_barrel_background")->Fill(photon->sigmaIEtaIEta(), weight_); } if(cut == "backgroundShape" && photon->isInEndCapRegion()){ histMan_->H1D_BJetBinned("Photon_sigma_ietaieta_endcap_background")->Fill(photon->sigmaIEtaIEta(), weight_); } } }