27 using namespace trigger;
28 using namespace l1extra;
38 const std::vector<string>& moduleLabels,
39 const std::vector<string>& stepLabels,
94 if (
hltPath_.find(
"eta2p1") != string::npos)
99 TPRegexp ptRegexp(
"Mu([0-9]+)");
100 TObjArray * regexArray = ptRegexp.MatchS(
hltPath_);
101 if (regexArray->GetEntriesFast() == 2) {
102 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
108 cutMinPt_ = ceil(threshold * 1.1) - 0.01;
111 string baseDir =
"HLT/Muon/Distributions/";
114 vector<string> sources(2);
125 for (
size_t i = 0;
i < sources.size();
i++) {
144 static int eventNumber = 0;
146 LogTrace(
"HLTMuonVal") <<
"In HLTMuonPlotter::analyze, "
147 <<
"Event: " << eventNumber;
159 {
LogError(
"HLTMuonVal") <<
"No trigger summary found";
return;}
163 vector<string> sources;
164 if (genParticles.
isValid()) sources.push_back(
"gen");
165 if ( recMuons.
isValid()) sources.push_back(
"rec");
167 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
169 string source = sources[sourceNo];
178 vector<MatchStruct> matches;
179 if (source ==
"gen" && genParticles.
isValid())
180 for (
size_t i = 0;
i < genParticles->size();
i++)
183 if (source ==
"rec" && recMuons.
isValid())
184 for (
size_t i = 0;
i < recMuons->size();
i++)
191 const bool isDoubleMuonPath = (
hltPath_.find(
"Double") != string::npos);
194 const size_t nStepsHlt = nSteps - 2;
195 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
196 vector< L1MuonParticleRef > candsL1;
197 vector< vector< RecoChargedCandidateRef > > refsHlt(nStepsHlt);
198 vector< vector< const RecoChargedCandidate * > > candsHlt(nStepsHlt);
200 for (
size_t i = 0;
i < nFilters;
i++) {
201 const int hltStep =
i - 1;
203 size_t iFilter = rawTriggerEvent->filterIndex(tag);
204 if (iFilter < rawTriggerEvent->
size()) {
206 rawTriggerEvent->getObjects(iFilter,
TriggerL1Mu, candsL1);
211 else LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
213 for (
size_t i = 0;
i < nStepsHlt;
i++)
214 for (
size_t j = 0;
j < refsHlt[
i].size();
j++)
215 if (refsHlt[
i][
j].isAvailable()) {
216 candsHlt[
i].push_back(& * refsHlt[
i][
j]);
219 <<
"Ref refsHlt[i][j]: product not available "
226 vector<size_t> matchesInEtaRange;
227 vector<bool> hasMatch(matches.size(),
true);
231 const size_t hltStep = (
step >= 2) ?
step - 2 : 0;
237 for (
size_t j = 0;
j < matches.size();
j++) {
240 matchesInEtaRange.push_back(
j);
242 else if (level == 1) {
243 if (matches[
j].candL1 == 0)
246 else if (level >= 2) {
247 if (matches[
j].candHlt[hltStep] == 0)
249 else if (!hasMatch[
j]) {
250 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep
251 <<
" of " << nStepsHlt
252 <<
" without previous match!";
258 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) <
262 string pre = source +
"Pass";
265 for (
size_t j = 0;
j < matches.size();
j++) {
266 float pt = matches[
j].candBase->pt();
267 float eta = matches[
j].candBase->eta();
268 float phi = matches[
j].candBase->phi();
270 if (matchesInEtaRange.size() >= 1 && j == matchesInEtaRange[0])
272 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
275 elements_[pre +
"Eta" + post]->Fill(eta);
277 elements_[pre +
"Phi" + post]->Fill(phi);
314 vector<MatchStruct> & matches,
315 const std::vector<L1MuonParticleRef>& candsL1,
316 const std::vector< vector< const RecoChargedCandidate *> >& candsHlt)
319 set<size_t>::iterator it;
321 set<size_t> indicesL1;
322 for (
size_t i = 0;
i < candsL1.size();
i++)
325 vector< set<size_t> > indicesHlt(candsHlt.size());
326 for (
size_t i = 0;
i < candsHlt.size();
i++)
327 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
330 for (
size_t i = 0;
i < matches.size();
i++) {
334 double bestDeltaR =
cutsDr_[0];
335 size_t bestMatch =
kNull;
336 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
337 if (candsL1[*it].isAvailable()) {
339 candsL1[*it]->eta(), candsL1[*it]->phi());
340 if (dR < bestDeltaR) {
354 <<
"Ref candsL1[*it]: product not available "
358 if (bestMatch !=
kNull)
359 matches[
i].candL1 = & * candsL1[bestMatch];
360 indicesL1.erase(bestMatch);
362 matches[
i].candHlt.assign(candsHlt.size(), 0);
363 for (
size_t j = 0;
j < candsHlt.size();
j++) {
364 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 :
365 (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 :
367 bestDeltaR =
cutsDr_[level - 2];
369 for (it = indicesHlt[
j].
begin(); it != indicesHlt[
j].end(); it++) {
371 candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
372 if (dR < bestDeltaR) {
377 if (bestMatch !=
kNull)
378 matches[
i].candHlt[
j] = candsHlt[
j][bestMatch];
379 indicesHlt[
j].erase(bestMatch);
402 string sourceUpper =
source;
403 sourceUpper[0] = toupper(sourceUpper[0]);
404 string name = source +
"Pass" + type +
"_" +
label;
407 if (type.find(
"MaxPt") != string::npos) {
408 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
409 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon "+
410 "matched to " +
label;
412 float *
edges =
new float[nBins + 1];
414 h =
new TH1F(name.c_str(), title.c_str(), nBins,
edges);
418 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
419 string title = symbol +
" of " + sourceUpper +
" Muons " +
420 "matched to " +
label;
422 int nBins = (int)params[0];
423 double min = params[1];
424 double max = params[2];
425 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
enum start value shifted to 81 so as to avoid clashes with PDG codes
virtual float eta() const =0
momentum pseudorapidity
std::vector< double > parametersEta_
virtual float phi() const =0
momentum azimuthal angle
L1MuonMatcherAlgo l1Matcher_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > moduleLabels_
std::vector< Muon > MuonCollection
collection of Muon objects
MonitorElement * bookFloat(const char *name)
Book float.
void beginRun(const edm::Run &, const edm::EventSetup &)
static boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > getTokens(const edm::ParameterSet &, edm::ConsumesCollector &&)
vector< ParameterSet > Parameters
StringCutObjectSelector< reco::Muon > * recMuonSelector_
const T & max(const T &a, const T &b)
std::vector< double > cutsDr_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void bookHist(std::string, std::string, std::string, std::string)
edm::EDGetTokenT< reco::MuonCollection > recMuonLabel_
void analyze(const edm::Event &, const edm::EventSetup &)
void setVerbose(unsigned level)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
StringCutObjectSelector< reco::GenParticle > * genMuonSelector_
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::vector< std::string > stepLabels_
void findMatches(std::vector< MatchStruct > &, const std::vector< l1extra::L1MuonParticleRef > &, const std::vector< std::vector< const reco::RecoChargedCandidate * > > &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< double > parametersPhi_
std::map< std::string, MonitorElement * > elements_
std::string hltProcessName_
edm::EDGetTokenT< reco::GenParticleCollection > genParticleLabel_
HLTMuonPlotter(const edm::ParameterSet &, std::string, const std::vector< std::string > &, const std::vector< std::string > &, const boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > &)
edm::EDGetTokenT< trigger::TriggerEventWithRefs > hltTriggerSummaryRAW_
std::vector< double > parametersTurnOn_
static std::string const source
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)