CMS 3D CMS Logo

Classes | Functions
Utils.h File Reference
#include <map>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

class  G4toCMSLegacyProcTypeMap
 

Functions

template<typename Reference , typename Association >
std::pair< typename Association::data_type::first_type, double > match (Reference key, Association association, bool bestMatchByMaxValue)
 Generic matching function. More...
 

Function Documentation

template<typename Reference , typename Association >
std::pair<typename Association::data_type::first_type, double> match ( Reference  key,
Association  association,
bool  bestMatchByMaxValue 
)

Generic matching function.

Definition at line 10 of file Utils.h.

References mps_fire::i, patRefSel_triggerMatching_cfi::matches, lumiQueryAPI::q, edm::second(), and relativeConstraints::value.

Referenced by BeautifulSoup.UnicodeDammit::_detectEncoding(), optutl::CommandLineParser::_finishDefaultOptions(), ParticleLevelProducer::addGenJet(), DTTFFEDReader::analyse(), ZHistogrammer::analyze(), ZMCHistogrammer::analyze(), DebugZMCTruth::analyze(), RPCPointVsRecHit::analyze(), RPCRecHitValid::analyze(), CTPPSProtonReconstructionPlotter::analyze(), CTPPSProtonReconstructionEfficiencyEstimatorData::analyze(), TotemRPDQMSource::analyze(), SiPixelHitEfficiencySource::analyze(), SiPixelTrackResidualSource::analyze(), SiPixelRecHitSource::analyze(), TkConvValidator::analyze(), SiPixelTrackingRecHitsValid::analyze(), StudyHLT::analyze(), optutl::CommandLineParser::argVec(), VertexAssociatorByTracks::associateRecoToSim(), VertexAssociatorByTracks::associateSimToReco(), TtFullLepHypKinSolution::buildKey(), TtFullHadHypGenMatch::buildKey(), TtFullLepHypGenMatch::buildKey(), JetPartonMatching::calculate(), HGCalNumberingScheme::checkPosition(), MuonTrajectoryCleaner::clean(), TkGluedMeasurementDet::collectRecHits(), DEcompare< T >::CompareCollections(), L1Comparator::CompareCollections(), CaloTowersCreationAlgo::convert(), cond::persistency::convertoToOracleConnection(), gen::TauolappInterface::decay(), dumpLutDiff(), GtPsbTextToDigi::endJob(), L1GctLut< NAddressBits, NDataBits >::equalityCheck(), TrackHistory::evaluate(), VertexHistory::evaluate(), APVGain::FetchIndices(), APVGain::FetchMonitor(), cond::persistency::fetchOne(), L1TDTTF::fillMEs(), reco::tau::AssociationMatchRefSelector< InputType, MatchedType, OutputType, ClonePolicy >::filter(), StringMap::find(), pat::GenericOverlapFinder< Distance >::find(), muonid::findOppositeTrack(), l1t::MicroGMTCancelOutUnit::getCoordinateCancelBits(), pat::PATObject< ObjectType >::getKinResolution(), StripCompactDigiSimLinks::getLinks(), TrackDetectorAssociator::getTAMuonChamberMatches(), heppy::PdfWeightProducerTool::getWeights(), HcalHBHEMuonAnalyzer::goodCell(), DDLogicalPart::hasDDValue(), pat::PATObject< ObjectType >::hasKinResolution(), pat::PATObject< ObjectType >::hasOverlaps(), pat::TriggerObjectStandAlone::hasPathOrAlgorithm(), cond::persistency::import(), triggerExpression::L1uGTReader::init(), triggerExpression::PathReader::init(), HLTHighLevel::init(), gen::JetMatching::initAfterBeams(), ZCounting::initHLT(), HLTTauDQMPlotter::isValid(), TtFullLepHypothesis::isValid(), IsoDepositVetoFactory::make(), Multi5x5BremRecoveryClusterAlgo::makeIslandSuperClusters(), PFBenchmarkAlgo::matchByDeltaEt(), PFBenchmarkAlgo::matchByDeltaR(), FWHistSliceSelector::matchCell(), HcalHBHEMuonSimAnalyzer::matchId(), HcalRaddamMuon::matchId(), HcalHBHEMuonAnalyzer::matchId(), JetPartonMatching::matchingPtOrderedMinDist(), ConversionProducer::matchingSC(), JetPartonMatching::matchingTotalMinDist(), JetPartonMatching::matchingUnambiguousOnly(), AlignmentGlobalTrackSelector::matchTracks(), JetPartonMatching::minSumDist_recursion(), FWDetailViewManager::openDetailViewFor(), MatchJet::operator()(), StringMap::operator[](), MuonIdProducer::overlap(), pat::PATObject< ObjectType >::overlaps(), pat::TriggerObjectStandAlone::packFilterLabels(), reco::modules::TrackerTrackHitFilter::parseStoN(), pat::PATUserDataMerger< ObjectType, Operation >::PATUserDataMerger(), TtSemiLepJetCombMaxSumPtWMass::produce(), TtSemiLepJetCombGeom::produce(), TtSemiLepJetCombWMassMaxSumPt::produce(), MCTruthCompositeMatcher< C1, C2 >::produce(), TtSemiLepKinFitProducer< LeptonCollection >::produce(), TtSemiLepJetCombWMassDeltaTopMass::produce(), CandOneToManyDeltaRMatcher::produce(), MCTrackMatcher::produce(), GenTrackMatcher::produce(), reco::modulesNew::MCTruthCompositeMatcher::produce(), reco::modules::MatcherBase< C1, C2, M >::produce(), TtFullHadKinFitProducer::produce(), reco::modulesNew::Matcher< C1, C2, S, D >::produce(), pat::MatcherUsingTracks::produce(), ShiftedJetProducerByMatchedObjectT< T >::produce(), pat::L1MuonMatcher::produce(), pat::HLTL1MuonMatcher::produce(), TrackListMerger::produce(), TtFullHadHypothesis::produce(), pat::PATJetUpdater::produce(), TtSemiLepHypothesis::produce(), CosmicTrackSelector::produce(), ShiftedPFCandidateProducerForPFMVAMEt::produce(), TtFullLepHypothesis::produce(), TtJetPartonMatch< C >::produce(), pat::PATJetProducer::produce(), pat::PATTriggerMatchEmbedder< PATObjectType >::produce(), DeepDoubleXTagInfoProducer::produce(), reco::modules::TrackFullCloneSelectorBase< Selector >::produce(), reco::modules::HICaloCompatibleTrackSelector::produce(), SimPFProducer::produce(), MuonMCClassifier::produce(), reco::PhysObjectMatcher< C1, C2, S, D, Q >::produce(), DeepFlavourTagInfoProducer::produce(), MuonSimClassifier::produce(), CandMCMatchTableProducer::produce(), read_processor_model(), valtools.webpage::readCaption(), reco::modules::TrackerTrackHitFilter::Rule::Rule(), PixelCPEClusterRepair::Rule::Rule(), parsingRulesHelper::rulesParser(), AnalyticalTrackSelector::run(), l1t::GlobalBoard::runGTL(), ecaldqm::TrigPrimTask::runOnEmulTPs(), pf2pat::ElectronIDPFCandidateSelectorDefinition::select(), L1TDTTFClient::setGMTsummary(), pat::PATObject< ObjectType >::setKinResolution(), TtFullHadKinFitter::KinFit::setMatch(), pat::PATObject< ObjectType >::setOverlaps(), PFCandIsolatorFromDeposits::SingleDeposit::SingleDeposit(), DEcompare< T >::SortCollections(), optutl::CommandLineParser::split(), and TriggerSummaryProducerAOD::TriggerSummaryProducerAOD().

12  {
13  typename Association::data_type::first_type value;
14 
15  typename Association::const_iterator pos = association.find(key);
16 
17  if (pos == association.end())
18  return std::pair<typename Association::data_type::first_type, double>(value, 0);
19 
20  const std::vector<typename Association::data_type> &matches = pos->val;
21 
22  double q = bestMatchByMaxValue ? -1e30 : 1e30;
23 
24  for (std::size_t i = 0; i < matches.size(); ++i)
25  if (bestMatchByMaxValue ? (matches[i].second > q) : (matches[i].second < q)) {
26  value = matches[i].first;
27  q = matches[i].second;
28  }
29 
30  return std::pair<typename Association::data_type::first_type, double>(value, q);
31 }
U second(std::pair< T, U > const &p)