CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

HLTMuonValidator Class Reference

#include <HLTMuonValidator.h>

Inheritance diagram for HLTMuonValidator:
edm::EDAnalyzer edm::EDAnalyzer edm::EDConsumerBase edm::EDConsumerBase

List of all members.

Classes

struct  matchesByDescendingPt
struct  MatchStruct

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 HLTMuonValidator (const edm::ParameterSet &)
 HLTMuonValidator (const edm::ParameterSet &)

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
void analyzePath (const edm::Event &, const std::string &, const std::string &, const std::vector< MatchStruct > &, edm::Handle< trigger::TriggerEventWithRefs >)
virtual void beginJob ()
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
void bookHist (std::string, std::string, std::string, std::string)
virtual void endJob ()
virtual void endRun (const edm::Run &, const edm::EventSetup &)
void findMatches (std::vector< MatchStruct > &, std::vector< l1extra::L1MuonParticleRef >, std::vector< std::vector< const reco::RecoChargedCandidate * > >)
void initializeHists ()
std::vector< std::string > moduleLabels (std::string)
std::vector< std::string > stepLabels (const std::vector< std::string > &)

Private Attributes

std::vector< HLTMuonPlotteranalyzers_
double cutMaxEta_
unsigned int cutMotherId_
std::vector< double > cutsDr_
std::map< std::string, double > cutsMinPt_
DQMStoredbe_
std::map< std::string,
MonitorElement * > 
elements_
std::map< std::string,
std::vector< std::string > > 
filterLabels_
std::string genMuonCut_
StringCutObjectSelector
< reco::GenParticle > * 
genMuonSelector_
std::string genParticleLabel_
HLTConfigProvider hltConfig_
std::set< std::string > hltPaths_
std::vector< std::string > hltPathsToCheck_
std::string hltProcessName_
std::string l1CandLabel_
L1MuonMatcherAlgo l1Matcher_
std::string l2CandLabel_
std::string l3CandLabel_
std::vector< double > parametersEta_
std::vector< double > parametersPhi_
std::vector< double > parametersTurnOn_
edm::ParameterSet pset_
std::string recMuonCut_
std::string recMuonLabel_
StringCutObjectSelector
< reco::Muon > * 
recMuonSelector_
std::map< std::string,
std::vector< std::string > > 
stepLabels_

Detailed Description

Generate histograms for muon trigger efficiencies Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance

Date:
2013/04/19 23:22:27
Revision:
1.13
Author:
J. Klukas, M. Vander Donckt, J. Alcaraz

Definition at line 60 of file HLTMuonValidator.h.


Constructor & Destructor Documentation

HLTMuonValidator::HLTMuonValidator ( const edm::ParameterSet pset)

Definition at line 91 of file HLTMuonValidator.cc.

                                                           :
  pset_(pset),
  hltProcessName_(pset.getParameter<string>("hltProcessName")),
  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
{
}
HLTMuonValidator::HLTMuonValidator ( const edm::ParameterSet ) [explicit]

Member Function Documentation

void HLTMuonValidator::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 190 of file HLTMuonValidator.cc.

References analyzers_.

{

  vector<HLTMuonPlotter>::iterator iter;
  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
    iter->analyze(iEvent, iSetup);
  }

}
virtual void HLTMuonValidator::analyze ( const edm::Event ,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDAnalyzer.

void HLTMuonValidator::analyzePath ( const edm::Event ,
const std::string &  ,
const std::string &  ,
const std::vector< MatchStruct > &  ,
edm::Handle< trigger::TriggerEventWithRefs  
) [private]
virtual void HLTMuonValidator::beginJob ( ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

void HLTMuonValidator::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 204 of file HLTMuonValidator.cc.

{
}
virtual void HLTMuonValidator::beginRun ( const edm::Run ,
const edm::EventSetup  
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

void HLTMuonValidator::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 143 of file HLTMuonValidator.cc.

References analyzers_, hltConfig_, CreateSqliteForCondDB_cfg::hltPaths, hltPathsToCheck_, hltProcessName_, i, HLTConfigProvider::init(), j, reco_calib_source_client_cfg::labels, moduleLabels(), getHLTPrescaleColumns::path, listBenchmarks::pattern, pset_, stepLabels(), relval_steps::steps, and HLTConfigProvider::triggerNames().

                                                       {

  // Initialize hltConfig
  bool changedConfig;
  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
    LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!"; 
    return;
  }

  // Get the set of trigger paths we want to make plots for
  set<string> hltPaths;
  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
    TPRegexp pattern(hltPathsToCheck_[i]);
    for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
      if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
        hltPaths.insert(hltConfig_.triggerNames()[j]);
  }
  
  // Initialize the analyzers
  analyzers_.clear();
  set<string>::iterator iPath;
  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {

    string path = * iPath;
    string shortpath = path;
    if (path.rfind("_v") < path.length())
      shortpath = path.substr(0, path.rfind("_v"));

    vector<string> labels = moduleLabels(path);
    vector<string> steps = stepLabels(labels);

    if (labels.size() > 0 && steps.size() > 0) {
      HLTMuonPlotter analyzer(pset_, shortpath, labels, steps);
      analyzers_.push_back(analyzer);
    }
  }

  // Call the beginRun (which books all the histograms)
  vector<HLTMuonPlotter>::iterator iter;
  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
    iter->beginRun(iRun, iSetup);
  }

}
void HLTMuonPlotter::bookHist ( std::string  ,
std::string  ,
std::string  ,
std::string   
) [private]

Definition at line 373 of file HLTMuonPlotter.cc.

References DQMStore::book1D(), HLTMuonPlotter::dbe_, prof2calltree::edges, HLTMuonPlotter::elements_, h, i, diffTwoXMLs::label, max(), min, mergeVDriftHistosByStation::name, HLTMuonPlotter::parametersEta_, HLTMuonPlotter::parametersPhi_, HLTMuonPlotter::parametersTurnOn_, LaserTracksInput_cfi::source, and indexGen::title.

{

  string sourceUpper = source; 
  sourceUpper[0] = toupper(sourceUpper[0]);
  string name = source + "Pass" + type + "_" + label;
  TH1F * h;

  if (type.find("MaxPt") != string::npos) {
    string desc = (type == "MaxPt1") ? "Leading" : "Next-to-Leading";
    string title = "pT of " + desc + " " + sourceUpper + " Muon "+
                   "matched to " + label;
    const size_t nBins = parametersTurnOn_.size() - 1;
    float * edges = new float[nBins + 1];
    for (size_t i = 0; i < nBins + 1; i++) edges[i] = parametersTurnOn_[i];
    h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
  }

  else {
    string symbol = (type == "Eta") ? "#eta" : "#phi";
    string title  = symbol + " of " + sourceUpper + " Muons " +
                    "matched to " + label;
    vector<double> params = (type == "Eta") ? parametersEta_ : parametersPhi_; 
    int    nBins = (int)params[0];
    double min   = params[1];
    double max   = params[2];
    h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
  }

  h->Sumw2();
  elements_[name] = dbe_->book1D(name, h);
  delete h;

}
void HLTMuonValidator::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 225 of file HLTMuonValidator.cc.

{
}
void HLTMuonValidator::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 211 of file HLTMuonValidator.cc.

{

  // vector<HLTMuonPlotter>::iterator iter;
  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
  //   iter->endRun(iRun, iSetup);
  // }

}
void HLTMuonPlotter::findMatches ( std::vector< MatchStruct > &  ,
std::vector< l1extra::L1MuonParticleRef ,
std::vector< std::vector< const reco::RecoChargedCandidate * > >   
) [private]

Definition at line 288 of file HLTMuonPlotter.cc.

References begin, HLTMuonPlotter::cutsDr_, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::Candidate::eta(), i, edm::eventsetup::heterocontainer::insert(), j, kNull, testEve_cfg::level, and reco::Candidate::phi().

{

  set<size_t>::iterator it;

  set<size_t> indicesL1;
  for (size_t i = 0; i < candsL1.size(); i++) 
    indicesL1.insert(i);

  vector< set<size_t> > indicesHlt(candsHlt.size());
  for (size_t i = 0; i < candsHlt.size(); i++)
    for (size_t j = 0; j < candsHlt[i].size(); j++)
      indicesHlt[i].insert(j);

  for (size_t i = 0; i < matches.size(); i++) {

    const Candidate * cand = matches[i].candBase;

    double bestDeltaR = cutsDr_[0];
    size_t bestMatch = kNull;
    for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
     if (candsL1[*it].isAvailable()) {
      double dR = deltaR(cand->eta(), cand->phi(),
                         candsL1[*it]->eta(), candsL1[*it]->phi());
      if (dR < bestDeltaR) {
        bestMatch = *it;
        bestDeltaR = dR;
      }
      // TrajectoryStateOnSurface propagated;
      // float dR = 999., dPhi = 999.;
      // bool isValid = l1Matcher_.match(* cand, * candsL1[*it], 
      //                                 dR, dPhi, propagated);
      // if (isValid && dR < bestDeltaR) {
      //   bestMatch = *it;
      //   bestDeltaR = dR;
      // }
     } else {
       LogWarning("HLTMuonPlotter")
         << "Ref candsL1[*it]: product not available "
         << *it;
     }
    }
    if (bestMatch != kNull)
      matches[i].candL1 = & * candsL1[bestMatch];
    indicesL1.erase(bestMatch);

    matches[i].candHlt.assign(candsHlt.size(), 0);
    for (size_t j = 0; j < candsHlt.size(); j++) {
      size_t level = (candsHlt.size() == 4) ? (j < 2) ? 2 : 3 :
                     (candsHlt.size() == 2) ? (j < 1) ? 2 : 3 :
                     2;
      bestDeltaR = cutsDr_[level - 2];
      bestMatch = kNull;
      for (it = indicesHlt[j].begin(); it != indicesHlt[j].end(); it++) {
        double dR = deltaR(cand->eta(), cand->phi(),
                           candsHlt[j][*it]->eta(), candsHlt[j][*it]->phi());
        if (dR < bestDeltaR) {
          bestMatch = *it;
          bestDeltaR = dR;
        }
      }
      if (bestMatch != kNull)
        matches[i].candHlt[j] = candsHlt[j][bestMatch];
      indicesHlt[j].erase(bestMatch);
    }

//     cout << "    Muon: " << cand->eta() << ", ";
//     if (matches[i].candL1) cout << matches[i].candL1->eta() << ", ";
//     else cout << "none, ";
//     for (size_t j = 0; j < candsHlt.size(); j++) 
//       if (matches[i].candHlt[j]) cout << matches[i].candHlt[j]->eta() << ", ";
//       else cout << "none, ";
//     cout << endl;

  }

}
void HLTMuonValidator::initializeHists ( ) [private]
vector< string > HLTMuonValidator::moduleLabels ( std::string  ) [private]

Definition at line 111 of file HLTMuonOfflineAnalyzer.cc.

References HLTMuonOfflineAnalyzer::hltConfig_, and HLTConfigProvider::moduleLabels().

Referenced by beginRun().

                                                {

  vector<string> modules = hltConfig_.moduleLabels(path);
  vector<string>::iterator iter = modules.begin();

  while (iter != modules.end())
    if (iter->find("Filtered") == string::npos) 
      iter = modules.erase(iter);
    else
      ++iter;

  return modules;

}
vector< string > HLTMuonValidator::stepLabels ( const std::vector< std::string > &  ) [private]

Definition at line 117 of file HLTMuonValidator.cc.

References spr::find(), i, and relval_steps::steps.

Referenced by beginRun().

                                                          {
  vector<string> steps(1, "All");
  for (size_t i = 0; i < modules.size(); i++) {
    if (modules[i].find("IsoFiltered") != string::npos) {
      if (modules[i].find("L3") != string::npos)
        steps.push_back("L3Iso");
      else
        steps.push_back("L2Iso");
    }
    else if (modules[i].find("L3") != string::npos)
      steps.push_back("L3");
    else if (modules[i].find("L2") != string::npos)
      steps.push_back("L2");
    else if (modules[i].find("L1") != string::npos)
      steps.push_back("L1");
    else
      return vector<string>();
  }
  if (steps.size() < 2 || steps[1] != "L1")
    return vector<string>();
  return steps;

}

Member Data Documentation

Definition at line 66 of file HLTMuonValidator.cc.

Referenced by analyze(), and beginRun().

double HLTMuonValidator::cutMaxEta_ [private]

Definition at line 125 of file HLTMuonValidator.h.

unsigned int HLTMuonValidator::cutMotherId_ [private]

Definition at line 126 of file HLTMuonValidator.h.

std::vector<double> HLTMuonValidator::cutsDr_ [private]

Definition at line 127 of file HLTMuonValidator.h.

std::map<std::string, double> HLTMuonValidator::cutsMinPt_ [private]

Definition at line 123 of file HLTMuonValidator.h.

Definition at line 138 of file HLTMuonValidator.h.

std::map<std::string, MonitorElement *> HLTMuonValidator::elements_ [private]

Definition at line 139 of file HLTMuonValidator.h.

std::map<std::string, std::vector<std::string> > HLTMuonValidator::filterLabels_ [private]

Definition at line 111 of file HLTMuonValidator.h.

std::string HLTMuonValidator::genMuonCut_ [private]

Definition at line 128 of file HLTMuonValidator.h.

Definition at line 131 of file HLTMuonValidator.h.

std::string HLTMuonValidator::genParticleLabel_ [private]

Definition at line 113 of file HLTMuonValidator.h.

Definition at line 134 of file HLTMuonValidator.h.

Referenced by beginRun().

std::set<std::string> HLTMuonValidator::hltPaths_ [private]

Definition at line 110 of file HLTMuonValidator.h.

std::vector< std::string > HLTMuonValidator::hltPathsToCheck_ [private]

Definition at line 109 of file HLTMuonValidator.h.

Referenced by beginRun().

std::string HLTMuonValidator::hltProcessName_ [private]

Definition at line 107 of file HLTMuonValidator.h.

Referenced by beginRun().

std::string HLTMuonValidator::l1CandLabel_ [private]

Definition at line 115 of file HLTMuonValidator.h.

Definition at line 136 of file HLTMuonValidator.h.

std::string HLTMuonValidator::l2CandLabel_ [private]

Definition at line 116 of file HLTMuonValidator.h.

std::string HLTMuonValidator::l3CandLabel_ [private]

Definition at line 117 of file HLTMuonValidator.h.

std::vector<double> HLTMuonValidator::parametersEta_ [private]

Definition at line 119 of file HLTMuonValidator.h.

std::vector<double> HLTMuonValidator::parametersPhi_ [private]

Definition at line 120 of file HLTMuonValidator.h.

std::vector<double> HLTMuonValidator::parametersTurnOn_ [private]

Definition at line 121 of file HLTMuonValidator.h.

Definition at line 61 of file HLTMuonValidator.cc.

Referenced by beginRun().

std::string HLTMuonValidator::recMuonCut_ [private]

Definition at line 129 of file HLTMuonValidator.h.

std::string HLTMuonValidator::recMuonLabel_ [private]

Definition at line 114 of file HLTMuonValidator.h.

Definition at line 132 of file HLTMuonValidator.h.

std::map<std::string, std::vector<std::string> > HLTMuonValidator::stepLabels_ [private]

Definition at line 140 of file HLTMuonValidator.h.