extern void printJets(const JetCollection jets) { for (unsigned short index = 0; index < jets.size(); ++index) { const JetPointer jet = jets.at(index); cout << "Jet " << index + 1 << endl; printJet(jet); } }
void JetAnalyser::analyse(const EventPtr event) { histMan_->setCurrentHistogramFolder(histogramFolder_); weight_ = event->weight() * prescale_ * scale_; const JetCollection jets = event->Jets(); unsigned int numberOfBJets(0); for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); histMan_->H1D_BJetBinned("all_jet_pT")->Fill(jet->pt(), weight_); histMan_->H1D_BJetBinned("all_jet_phi")->Fill(jet->phi(), weight_); histMan_->H1D_BJetBinned("all_jet_eta")->Fill(jet->eta(), weight_); if (jet->isBJet(BtagAlgorithm::CombinedSecondaryVertex, BtagAlgorithm::MEDIUM)) ++numberOfBJets; if (index < 7) { stringstream temp; temp << "jet" << (index + 1); string nthJet = temp.str(); histMan_->H1D_BJetBinned(nthJet + "_pT")->Fill(jet->pt(), weight_); histMan_->H1D_BJetBinned(nthJet + "_phi")->Fill(jet->phi(), weight_); histMan_->H1D_BJetBinned(nthJet + "_eta")->Fill(jet->eta(), weight_); } } histMan_->H1D_BJetBinned("N_Jets")->Fill(jets.size(), weight_); histMan_->H1D("N_BJets")->Fill(numberOfBJets, weight_); }
bool PseudoTopAnalyser::passesEventSelection( const MCParticlePointer pseudoLepton, const ParticlePointer pseudoNeutrino, const JetCollection pseudoJets, const MCParticleCollection pseudoBs, const ParticleCollection allPseudoLeptons, const ParticlePointer pseudoMET ) { // Event selection taken from here : https://twiki.cern.ch/twiki/bin/view/LHCPhysics/ParticleLevelTopDefinitions unsigned int numberGoodLeptons = 0; unsigned int numberVetoLeptons = 0; ParticlePointer leadingLepton; for ( unsigned int leptonIndex = 0; leptonIndex < allPseudoLeptons.size(); ++ leptonIndex ) { const ParticlePointer lepton = allPseudoLeptons.at(leptonIndex); // Check if this is a good signal type lepton if ( lepton->pt() > minLeptonPt_ && fabs(lepton->eta()) < maxLeptonAbsEta_ ) { ++numberGoodLeptons; if ( leadingLepton == 0 ) leadingLepton = lepton; } // Check if this is a veto lepton if ( lepton->pt() > minVetoLeptonPt_ && fabs(lepton->eta()) < maxVetoLeptonAbsEta_ ) { ++numberVetoLeptons; } } // Neutrino pt sum bool passesNeutrinoSumPt = false; if ( pseudoMET != 0 ) { if ( pseudoMET->pt() > minNeutrinoSumPt_ ) passesNeutrinoSumPt = true; } // W MT bool passesWMT = false; if ( leadingLepton != 0 && pseudoMET != 0 ) { double genMT = sqrt( 2 * leadingLepton->pt() * pseudoMET->pt() * ( 1 - cos(leadingLepton->phi() - pseudoMET->phi() ) ) ); if (genMT > minWMt_) passesWMT = true; } // Jets unsigned int numberGoodJets = 0; unsigned int numberGoodBJets = 0; for ( unsigned int jetIndex = 0; jetIndex < pseudoJets.size(); ++ jetIndex ) { const JetPointer jet = pseudoJets.at(jetIndex); // Check if this is a good jet if ( jet->pt() > minJetPt_ && fabs(jet->eta()) < maxJetAbsEta_ ) { ++numberGoodJets; // Check if this is also a good b jet if ( fabs( jet->partonFlavour() ) == 5 ) { ++numberGoodBJets; } } } if ( numberGoodLeptons == 1 && numberVetoLeptons <= 1 && passesNeutrinoSumPt && passesWMT && numberGoodJets >= minNJets_ && numberGoodBJets >= minNBJets_ ) { return true; } else return false; }
JetCollection BTagWeight::getBJets(const JetCollection jets) const { JetCollection bjets; for (unsigned int index = 0; index < jets.size(); ++index) { if (abs(jets.at(index)->partonFlavour()) == 5) //b-quark bjets.push_back(jets.at(index)); } return bjets; }
JetCollection BTagWeight::getCJets(const JetCollection& jets) const { JetCollection cjets; for (unsigned int index = 0; index < jets.size(); ++index) { if (abs(jets.at(index).partonFlavour()) == 4) //c-quark cjets.push_back(jets.at(index)); } return cjets; }
void TTbar_plus_X_analyser::fillCommonTreesNoBSelection(const EventPtr event, const unsigned int selectionCriteria, std::string folder ) { SelectionCriteria::selection selection = SelectionCriteria::selection(selectionCriteria); // Jets const JetCollection jets(event->CleanedJets()); // B Jets const JetCollection bJets(event->CleanedBJets()); // Lepton const LeptonPointer signalLepton = event->getSignalLepton( selection ); // MET const METPointer MET_original(event->MET((METAlgorithm::value) 0)); treeMan_->setCurrentFolder(folder); treeMan_->Fill("EventWeight", event->weight()); treeMan_->Fill("PUWeight", event->PileUpWeight()); treeMan_->Fill("PUWeight_up", event->PileUpWeight(1)); treeMan_->Fill("PUWeight_down", event->PileUpWeight(-1)); treeMan_->Fill("M3",Event::M3(jets)); if ( Event::NJets(bJets) > 0 ) { treeMan_->Fill("M_bl",Event::M_bl(bJets, signalLepton)); treeMan_->Fill("angle_bl",Event::angle_bl(bJets, signalLepton)); } treeMan_->Fill("HT",Event::HT(jets)); treeMan_->Fill("MET",MET_original->et()); treeMan_->Fill("MET_phi",MET_original->phi()); treeMan_->Fill("ST",Event::ST(jets, signalLepton, MET_original)); treeMan_->Fill("WPT",Event::WPT(signalLepton, MET_original)); treeMan_->Fill("MT",Event::MT(signalLepton, MET_original)); treeMan_->Fill("NJets",Event::NJets(jets)); treeMan_->Fill("NBJets",Event::NJets(bJets)); treeMan_->Fill("NVertices", event->Vertices().size()); treeMan_->Fill("BJetWeight",event->BJetWeight()); treeMan_->Fill("BJetEfficiencyCorrectionWeight",event->BJetEfficiencyCorrectionWeight()); treeMan_->Fill("BJetAlternativeWeight",event->BJetAlternativeWeight()); treeMan_->Fill("BJetUpWeight",event->BJetUpWeight()); treeMan_->Fill("BJetDownWeight",event->BJetDownWeight()); treeMan_->Fill("LightJetUpWeight",event->LightJetUpWeight()); treeMan_->Fill("LightJetDownWeight",event->LightJetDownWeight()); if (selection == SelectionCriteria::selection(SelectionCriteria::ElectronPlusJetsReference)){ treeMan_->Fill("lepton_isolation", signalLepton->PFRelIso03DeltaBeta()); } else if (selection == SelectionCriteria::selection(SelectionCriteria::MuonPlusJetsReference)){ treeMan_->Fill("lepton_isolation", signalLepton->PFRelIso04DeltaBeta()); } for (unsigned int index = 0; index < jets.size(); ++index) { treeMan_->Fill("jet_csv", jets.at(index)->getBTagDiscriminator(BtagAlgorithm::CombinedSecondaryVertexV2) ); } fillLeptonEfficiencyCorrectionBranches( event, selectionCriteria, signalLepton ); }
double Event::HT(const JetCollection jets) { double ht(0); //Take ALL the jets! for (unsigned int index = 0; index < jets.size(); ++index) { if(jets.at(index)->pt() > 20) ht += jets.at(index)->pt(); } return ht; }
bool TopPairEplusJetsRefAsymJetsSelection::passesAsymmetricJetCuts(const EventPtr event) const { const JetCollection goodElectronCleanedJets = cleanedJets(event); if (goodElectronCleanedJets.size() < 3) // good jets have a cut of 30 GeV! return false; JetPointer leadingJet = goodElectronCleanedJets.front(); JetPointer secondLeadingJet = goodElectronCleanedJets.at(1); JetPointer thirdLeadingJet = goodElectronCleanedJets.at(2); return leadingJet->pt() > 70 && secondLeadingJet->pt() > 50 && thirdLeadingJet->pt() > 50; }
double TtbarHypothesis::M3() const { JetCollection jets; jets.clear(); jets.push_back(jet1FromW); jets.push_back(jet2FromW); jets.push_back(leptonicBjet); jets.push_back(hadronicBJet); return M3(jets); }
JetCollection Event::GetBJetCollection(const JetCollection& jets, BtagAlgorithm::value btagAlgorithm, BtagAlgorithm::workingPoint WP) const { JetCollection bjets; for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet = jets.at(index); if (jet->isBJet(btagAlgorithm, WP)) bjets.push_back(jet); } return bjets; }
void TTbarDiLeptonAnalyser::eESignalAnalysis(const EventPtr event) { if (topEERefSelection_->passesSelectionUpToStep(event, TTbarEEReferenceSelection::MetCut)) { const JetCollection jets(topEERefSelection_->cleanedJets(event)); const JetCollection bJets(topEERefSelection_->cleanedBJets(event)); unsigned int numberOfBjets(bJets.size()); vector<double> bjetWeights; if (event->isRealData()) { for (unsigned int index = 0; index <= numberOfBjets; ++index) { if (index == numberOfBjets) bjetWeights.push_back(1.); else bjetWeights.push_back(0); } } else bjetWeights = BjetWeights(jets, numberOfBjets); histMan_->setCurrentJetBin(jets.size()); histMan_->setCurrentBJetBin(numberOfBjets); //this is for HT in the MET analyser but needs changing const LeptonPointer signalLepton = topEERefSelection_->signalLepton(event); const ElectronPointer signalElectron(boost::static_pointer_cast<Electron>(signalLepton)); const PhotonCollection photons = topEERefSelection_->signalPhotons(event); //get dilepton collection const ElectronCollection electrons = topEERefSelection_->signalElectrons(event); const MuonCollection muons = topEERefSelection_->signalMuons(event); for (unsigned int weightIndex = 0; weightIndex < bjetWeights.size(); ++weightIndex) { double bjetWeight = bjetWeights.at(weightIndex); histMan_->setCurrentBJetBin(weightIndex); histMan_->setCurrentHistogramFolder(histogramFolder_ + "/EE/Ref selection"); //MET metAnalyserEERefSelection_->setScale(bjetWeight); metAnalyserEERefSelection_->analyse(event, signalLepton); //jets jetAnalyserEERefSelection_->setScale(bjetWeight); jetAnalyserEERefSelection_->analyse(event); //DiElectron diElectronAnalyserEERefSelection_->setScale(bjetWeight); diElectronAnalyserEERefSelection_->analyse(event, electrons); //photons photonAnalyserEERefSelection_->setScale(bjetWeight); photonAnalyserEERefSelection_->analyse(event, photons, jets, electrons, muons); } } }
void MET::adjForUnc(const JetCollection &jets) { if (Jet::correctDirection == JetCorrDirection::NONE || jets.size() <= 0) return; FourVector new4vec = getFourVector(); for (unsigned int index = 0; index < jets.size(); ++index) new4vec += jets.at(index)->DiffVec; new4vec.SetPz(0.0); // Make sure no longitudinal component new4vec.SetE(new4vec.Pt()); // Make sure it stays massless setFourVector(new4vec); }
unsigned short Electron::getClosestJetIndex(const JetCollection& jets) const { unsigned short idOfClosest = 999; double closestDR = 999.; for (unsigned short index = 0; index < jets.size(); ++index) { double DR = deltaR(jets.at(index)); if (DR < closestDR) { closestDR = DR; idOfClosest = index; } } return idOfClosest; }
double BTagWeight::getAverageUDSGScaleFactor(const JetCollection& jets) const { std::vector<double> scaleFactors; for (unsigned int index = 0; index < jets.size(); ++index) { const Jet jet(jets.at(index)); scaleFactors.push_back(getUDSGScaleFactor(jet)); } double sumOfScaleFactors = std::accumulate(scaleFactors.begin(), scaleFactors.end(), 0.0); if (scaleFactors.size() == 0) return 1.; else return sumOfScaleFactors / scaleFactors.size(); }
const JetCollection TopPairEMuReferenceSelection::cleanedBJets(const EventPtr event) const { const JetCollection jets(cleanedJets(event)); JetCollection cleanedBJets; for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); if (isBJet(jet)) cleanedBJets.push_back(jet); } return cleanedBJets; }
StatusCode AlbersWrite::execute() { JetCollection* jets = new JetCollection(); LorentzVector lv1; lv1.Px = 20.; lv1.Py = 20. ; lv1.Mass = 125; lv1.Pz = 0.; JetHandle j1 = jets->create(); BareJet& core = j1.mod().Core; core.P4 = lv1; m_jethandle.put(jets); return StatusCode::SUCCESS; }
double BTagWeight::weight ( const JetCollection& jets, int BTagSystematic, std::string MCSampleTag) const { float bTaggedMCJet = 1.0; float nonBTaggedMCJet = 1.0; float bTaggedDataJet = 1.0; float nonBTaggedDataJet = 1.0; float err1 = 0.0; float err2 = 0.0; float err3 = 0.0; float err4 = 0.0; for (unsigned int index = 0; index < jets.size(); ++index) { // Info on this jet const pat::Jet& jet (jets.at(index)); const unsigned int partonFlavour = abs( jet.partonFlavour() ); const bool isBTagged = jet.bDiscriminator("combinedSecondaryVertexBJetTags") >= 0.679; // Get scale factor for this jet std::vector<double> sfAndError = getScaleFactor( partonFlavour, jet, MCSampleTag ); const double sf = sfAndError.at(0); const double sfError = sfAndError.at(1); // Get efficiency for this jet const double eff = getEfficiency( partonFlavour, jet, MCSampleTag ); if ( isBTagged ) { bTaggedMCJet *= eff; bTaggedDataJet *= eff*sf; if(partonFlavour==5 || partonFlavour ==4) err1 += sfError/sf; ///correlated for b/c else err3 += sfError/sf; //correlated for light } else { nonBTaggedMCJet *= ( 1 - eff ); nonBTaggedDataJet *= ( 1 - eff*sf ); if(partonFlavour==5 || partonFlavour ==4 ) err2 += (-eff*sfError)/(1-eff*sf); /// /correlated for b/c else err4 += (-eff*sfError)/(1-eff*sf); ////correlated for light } } double bTagWeight = (nonBTaggedDataJet * bTaggedDataJet) / (nonBTaggedMCJet * bTaggedMCJet); double error_BTagWeight = sqrt(pow(err1 + err2, 2) + pow(err3 + err4, 2)) * bTagWeight; ///un-correlated for b/c and light if (BTagSystematic == +1) { return bTagWeight + error_BTagWeight; } else if (BTagSystematic == -1) { return bTagWeight - error_BTagWeight; } else if (BTagSystematic == 0) { return bTagWeight; } return 0.; }
double BTagWeight::getAverageBScaleFactor(const JetCollection& jets, std::string MCSampleTag, double uncertaintyFactor) const { std::vector<double> scaleFactors; for (unsigned int index = 0; index < jets.size(); ++index) { const Jet jet(jets.at(index)); scaleFactors.push_back(getBScaleFactor(jet, MCSampleTag, uncertaintyFactor)); } double sumOfScaleFactors = std::accumulate(scaleFactors.begin(), scaleFactors.end(), 0.0); if (scaleFactors.size() == 0) { return 1.; } else { return sumOfScaleFactors / scaleFactors.size(); } }
void TauAnalysisSelector::setupBranches(BranchManager& branchManager) { fEventInfo.setupBranches(branchManager); if(fIsEmbedded) { branchManager.book("weightGenerator", &fGeneratorWeight); fMuons.setupBranches(branchManager, isMC()); //fElectrons.setupBranches(branchManager, isMC()); fJets.setupBranches(branchManager); fGenTausEmbedded.setupBranches(branchManager); } fTaus.setupBranches(branchManager, isMC() && !fIsEmbedded); if(isMC()) fGenTaus.setupBranches(branchManager); if(!fPuWeightName.empty()) branchManager.book(fPuWeightName, &fPuWeight); branchManager.book("selectedPrimaryVertex_count", &fSelectedVertexCount); branchManager.book("goodPrimaryVertex_count", &fVertexCount); if(fIsEmbedded) { branchManager.book("trigger_Mu40_eta2p1", &fMuTriggerPassed); } //branchManager.book("ElectronVetoPassed", &fElectronVetoPassed); }
void Analysis::analyse() { cout << "detected samples:" << endl; for (unsigned int sample = 0; sample < DataType::NUMBER_OF_DATA_TYPES; ++sample) { if (eventReader->getSeenDatatypes()[sample]) cout << DataType::names[sample] << endl; } createHistograms(); while (eventReader->hasNextEvent()) { initiateEvent(); printNumberOfProccessedEventsEvery(Globals::printEveryXEvents); inspectEvents(); const JetCollection jets(currentEvent->Jets()); unsigned int numberOfJets(jets.size()); unsigned int numberOfBJets(0); for (unsigned int index = 0; index < numberOfJets; ++index) { const JetPointer jet(currentEvent->Jets().at(index)); if (jet->isBJet(BtagAlgorithm::CombinedSecondaryVertexV2, BtagAlgorithm::MEDIUM)) ++numberOfBJets; } histMan->setCurrentBJetBin(numberOfBJets); histMan->setCurrentJetBin(numberOfJets); vector<double> bjetWeights; if (currentEvent->isRealData()) { for (unsigned int index = 0; index <= numberOfBJets; ++index) { if (index == numberOfBJets) bjetWeights.push_back(1.); else bjetWeights.push_back(0); } } else bjetWeights = BjetWeights(jets, numberOfBJets); ttbar_plus_X_analyser_->analyse(currentEvent); if ( ( currentEvent->getDataType() == DataType::TTJets_amcatnloFXFX || currentEvent->getDataType() == DataType::TTJets_madgraphMLM ) && Globals::treePrefix_ == "" ) { pseudoTopAnalyser_->analyse(currentEvent); unfoldingRecoAnalyser_->analyse(currentEvent); partonAnalyser_->analyse(currentEvent); // likelihoodInputAnalyser_->analyse(currentEvent); } treeMan->FillTrees(); } }
const JetCollection TopPairMuPlusJetsReferenceSelection2011::cleanedJets(const EventPtr event) const { const JetCollection jets(event->Jets()); JetCollection cleanedJets; if (!hasExactlyOneIsolatedLepton(event)) //if no signal lepton is found, can't clean jets, return them all! return jets; const LeptonPointer lepton(signalLepton(event)); for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); if (!jet->isWithinDeltaR(0.3, lepton)) cleanedJets.push_back(jet); } return cleanedJets; }
void BTagEff::analyse(const EventPtr event) { histMan_->setCurrentHistogramFolder(histogramFolder_); treeMan_->setCurrentFolder(histogramFolder_); int NJets = 0; const JetCollection allJets = event->Jets(); for (unsigned int jetIndex = 0; jetIndex < allJets.size(); ++jetIndex) { const JetPointer jet(allJets.at(jetIndex)); bool isLoose = false; bool isMedium = false; bool isTight = false; double jetPt = jet->pt(); double jetEta = jet->eta(); if (jetPt < 25 || abs(jetEta) > 2.4) continue; // double jetCSV = jet->getBTagDiscriminator(BtagAlgorithm::CombinedSecondaryVertexV2, BtagAlgorithm::MEDIUM); double jetCSV = jet->getBTagDiscriminator(BAT::BtagAlgorithm::value::CombinedSecondaryVertexV2); // https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagRecommendation74X50ns if (jetCSV > 0.605) isLoose = true; if (jetCSV > 0.890) isMedium = true; if (jetCSV > 0.970) isTight = true; unsigned int partonFlavour = abs(jet->partonFlavour()); // const bool isBTagged = jet->isBJet(BtagAlgorithm::CombinedSecondaryVertexV2, BtagAlgorithm::MEDIUM); // cout << jet->isBJet(BtagAlgorithm::CombinedSecondaryVertexV2, BtagAlgorithm::MEDIUM) << endl; treeMan_->Fill("pt", jetPt); treeMan_->Fill("eta", jetEta); treeMan_->Fill("CSV", jetCSV); treeMan_->Fill("partonFlavour", partonFlavour); treeMan_->Fill("isLoose", isLoose); treeMan_->Fill("isMedium", isMedium); treeMan_->Fill("isTight", isTight); ++NJets; } treeMan_->Fill("NJets", NJets); }
void Analysis::analyse() { createHistograms(); cout << "detected samples:" << endl; for (unsigned int sample = 0; sample < DataType::NUMBER_OF_DATA_TYPES; ++sample) { if (eventReader->getSeenDatatypes()[sample]) cout << DataType::names[sample] << endl; } while (eventReader->hasNextEvent()) { initiateEvent(); printNumberOfProccessedEventsEvery(Globals::printEveryXEvents); inspectEvents(); const JetCollection jets(currentEvent->Jets()); unsigned int numberOfJets(jets.size()); unsigned int numberOfBJets(0); for (unsigned int index = 0; index < numberOfJets; ++index) { const JetPointer jet(currentEvent->Jets().at(index)); if (jet->isBJet(BtagAlgorithm::CombinedSecondaryVertex, BtagAlgorithm::MEDIUM)) ++numberOfBJets; } histMan->setCurrentBJetBin(numberOfBJets); histMan->setCurrentJetBin(numberOfJets); vector<double> bjetWeights; if (currentEvent->isRealData()) { for (unsigned int index = 0; index <= numberOfBJets; ++index) { if (index == numberOfBJets) bjetWeights.push_back(1.); else bjetWeights.push_back(0); } } else bjetWeights = BjetWeights(jets, numberOfBJets); eventcountAnalyser->analyse(currentEvent); // mttbarAnalyser->analyse(currentEvent); ttbar_plus_X_analyser_->analyse(currentEvent); diffVariablesAnalyser->analyse(currentEvent); // binningAnalyser->analyse(currentEvent); } }
//this can be done shorter if you introduce a function which passes the btagWeight std::vector<double> BjetWeights(const JetCollection& jets, unsigned int numberOfBtags, int btagSystematicFactor, int lightJetSystematicFactor) { boost::scoped_ptr < BTagWeight > btagWeight(new BTagWeight(btagSystematicFactor, lightJetSystematicFactor)); //get b-jets const JetCollection bjets(btagWeight->getBJets(jets)); //get c-jets const JetCollection cjets(btagWeight->getCJets(jets)); //get udsg jets const JetCollection udsgjets(btagWeight->getUDSGJets(jets)); //get mean scale factors double SF_b = btagWeight->getAverageBScaleFactor(bjets); double SF_c = btagWeight->getAverageCScaleFactor(cjets); double SF_udsg = btagWeight->getAverageUDSGScaleFactor(udsgjets); //get mean efficiencies double mean_bJetEfficiency = btagWeight->getAverageBEfficiency(); double mean_cJetEfficiency = btagWeight->getAverageCEfficiency(); double mean_udsgJetEfficiency = btagWeight->getAverageUDSGEfficiency(udsgjets); std::vector<double> event_weights; for (unsigned int nTag = 0; nTag <= numberOfBtags; ++nTag) { // >= 4 is our last b-tag bin! btagWeight->setNumberOfBtags(nTag, 20); double event_weight = btagWeight->weight(bjets.size(), cjets.size(), udsgjets.size(), mean_bJetEfficiency, mean_cJetEfficiency, mean_udsgJetEfficiency, SF_b, SF_c, SF_udsg, numberOfBtags); event_weights.push_back(event_weight); } //all weights are inclusive. To get the weight for exclusive N b-tags ones has to subtract: for (unsigned int nTag = 0; nTag < numberOfBtags; ++nTag) { // w(N b-tags) = w(>= N) - w(>= N+1) event_weights.at(nTag) = event_weights.at(nTag) - event_weights.at(nTag + 1); //last weight, >= numberOfBjets jets, stays inclusive } return event_weights; }
const JetCollection TopPairEMuReferenceSelection::cleanedJets(const EventPtr event) const { const JetCollection jets(event->Jets()); JetCollection cleanedJets; //if no signal lepton is found, can't clean jets, return them all! if (!passesDiLeptonSelection(event)) return jets; const PhotonCollection photons(signalPhotons(event)); const ElectronCollection electrons(signalElectrons(event)); const MuonCollection muons(signalMuons(event)); double minDR = 999999999.; double minDR_pho = 999999999.; for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); for (unsigned int lep = 0; lep < electrons.size(); lep++){ const LeptonPointer lepton(electrons.at(lep)); if(jet->deltaR(lepton) < minDR) minDR = jet->deltaR(lepton); } for (unsigned int lep = 0; lep < muons.size(); lep++){ const LeptonPointer lepton(muons.at(lep)); if(jet->deltaR(lepton) < minDR) minDR = jet->deltaR(lepton); } for (unsigned int pho = 0; pho < photons.size(); pho++){ const PhotonPointer photon(photons.at(pho)); if(jet->deltaR(photon) < minDR_pho) minDR_pho = jet->deltaR(photon); } if (minDR > 0.5 && minDR_pho > 0.3 && isGoodJet(jet)) cleanedJets.push_back(jet); } return cleanedJets; }
JetCollection BTagWeight::getUDSGJets(const JetCollection& jets) const { JetCollection udsgjets; for (unsigned int index = 0; index < jets.size(); ++index) { if (abs(jets.at(index).partonFlavour()) != 4 && abs(jets.at(index).partonFlavour()) != 5) //not a c- or b-quark udsgjets.push_back(jets.at(index)); } return udsgjets; }
double BTagWeight::getAverageUDSGEfficiency(const JetCollection& jets) const { std::vector<double> efficiencies; for (unsigned int index = 0; index < jets.size(); ++index) { const Jet jet(jets.at(index)); double efficiency(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); if (pt < 20) { continue; } else if (pt > 800) { efficiency = getMeanUDSGEfficiency(800.); } else { efficiency = getMeanUDSGEfficiency(pt); } efficiencies.push_back(efficiency); } double sumOfEfficiencies = std::accumulate(efficiencies.begin(), efficiencies.end(), 0.0); if (efficiencies.size() == 0) return 1.; else return sumOfEfficiencies / efficiencies.size(); }
int HitFitAnalyser::positionOfLastTTBarJet(const JetCollection jets) { // Loop over jets and find position of last jet that comes from ttbar decay bool foundHadB = false; bool foundLepB = false; bool foundQ = false; bool foundQBar = false; for ( unsigned int jetIndex=0; jetIndex < jets.size(); ++jetIndex ) { JetPointer jet = jets[jetIndex]; if ( jet->ttbar_decay_parton() == 3 ) foundQ = true; else if ( jet->ttbar_decay_parton() == 4 ) foundQBar = true; else if ( jet->ttbar_decay_parton() == 5 ) foundLepB = true; else if ( jet->ttbar_decay_parton() == 6 ) foundHadB = true; if ( foundQ && foundQBar && foundLepB && foundHadB ) return jetIndex; } return -1; }
bool HLTriggerQCDAnalyser::passesTriggerAnalysisSelection(const EventPtr event) const { const ElectronCollection electrons(event->Electrons()); const JetCollection jets(event->Jets()); if (electrons.size() == 0 || jets.size() < 3) return false; unsigned int nElectrons(0); for (unsigned int index = 0; index < electrons.size(); ++index) { const ElectronPointer electron(electrons.at(index)); if (fabs(electron->eta()) < 2.5 && electron->pt() > 20) ++nElectrons; //if more than 2 electrons passing the selection of > 20GeV, reject event } const ElectronPointer mostEnergeticElectron(electrons.front()); //clean jets against electron JetCollection cleanedJets; for (unsigned int index = 0; index < jets.size(); ++index) { const JetPointer jet(jets.at(index)); if (!jet->isWithinDeltaR(0.3, mostEnergeticElectron)) cleanedJets.push_back(jet); } unsigned int nCleanedJetsAbove30GeV(0), nCleanedJetsAbove45GeV(0); for (unsigned int index = 0; index < cleanedJets.size(); ++index) { const JetPointer jet(cleanedJets.at(index)); if (jet->pt() > 45.) ++nCleanedJetsAbove45GeV; if (jet->pt() > 30.) ++nCleanedJetsAbove30GeV; } return nElectrons == 1 && (nCleanedJetsAbove45GeV >= 3 || (nCleanedJetsAbove45GeV >= 2 && nCleanedJetsAbove30GeV >= 3 && event->runnumber() >= 194270)); }
double TtbarHypothesis::M3(const JetCollection jets) { double m3(0), max_pt(0); if (jets.size() >= 3) { for (unsigned int index1 = 0; index1 < jets.size() - 2; ++index1) { for (unsigned int index2 = index1 + 1; index2 < jets.size() - 1; ++index2) { for (unsigned int index3 = index2 + 1; index3 < jets.size(); ++index3) { FourVector m3Vector( jets.at(index1)->getFourVector() + jets.at(index2)->getFourVector() + jets.at(index3)->getFourVector()); double currentPt = m3Vector.Pt(); if (currentPt > max_pt) { max_pt = currentPt; m3 = m3Vector.M(); } } } } } return m3; }