29 using namespace trigger;
30 using namespace l1extra;
40 const std::vector<string>& moduleLabels,
41 const std::vector<string>& stepLabels) :
89 if (
hltPath_.find(
"eta2p1") != string::npos)
94 TPRegexp ptRegexp(
"Mu([0-9]+)");
95 TObjArray * regexArray = ptRegexp.MatchS(
hltPath_);
96 if (regexArray->GetEntriesFast() == 2) {
97 threshold = atoi(((TObjString *)regexArray->At(1))->GetString());
103 cutMinPt_ = ceil(threshold * 1.1) - 0.01;
106 string baseDir =
"HLT/Muon/Distributions/";
109 vector<string> sources(2);
120 for (
size_t i = 0;
i < sources.size();
i++) {
139 static int eventNumber = 0;
141 LogTrace(
"HLTMuonVal") <<
"In HLTMuonPlotter::analyze, "
142 <<
"Event: " << eventNumber;
152 iEvent.
getByLabel(
"hltTriggerSummaryRAW", rawTriggerEvent);
154 {
LogError(
"HLTMuonVal") <<
"No trigger summary found";
return;}
158 vector<string> sources;
159 if (genParticles.
isValid()) sources.push_back(
"gen");
160 if ( recMuons.
isValid()) sources.push_back(
"rec");
162 for (
size_t sourceNo = 0; sourceNo < sources.size(); sourceNo++) {
164 string source = sources[sourceNo];
173 vector<MatchStruct> matches;
174 if (source ==
"gen" && genParticles.
isValid())
175 for (
size_t i = 0;
i < genParticles->size();
i++)
178 if (source ==
"rec" && recMuons.
isValid())
179 for (
size_t i = 0;
i < recMuons->size();
i++)
186 const bool isDoubleMuonPath = (
hltPath_.find(
"Double") != string::npos);
189 const size_t nStepsHlt = nSteps - 2;
190 const int nObjectsToPassPath = (isDoubleMuonPath) ? 2 : 1;
191 vector< L1MuonParticleRef > candsL1;
192 vector< vector< RecoChargedCandidateRef > > refsHlt(nStepsHlt);
193 vector< vector< const RecoChargedCandidate * > > candsHlt(nStepsHlt);
195 for (
size_t i = 0;
i < nFilters;
i++) {
196 const int hltStep =
i - 1;
198 size_t iFilter = rawTriggerEvent->filterIndex(tag);
199 if (iFilter < rawTriggerEvent->
size()) {
201 rawTriggerEvent->getObjects(iFilter,
TriggerL1Mu, candsL1);
206 else LogTrace(
"HLTMuonVal") <<
"No collection with label " <<
tag;
208 for (
size_t i = 0;
i < nStepsHlt;
i++)
209 for (
size_t j = 0;
j < refsHlt[
i].size();
j++)
210 if (refsHlt[
i][
j].isAvailable()) {
211 candsHlt[
i].push_back(& * refsHlt[
i][
j]);
214 <<
"Ref refsHlt[i][j]: product not available "
221 vector<size_t> matchesInEtaRange;
222 vector<bool> hasMatch(matches.size(),
true);
226 const size_t hltStep = (
step >= 2) ?
step - 2 : 0;
232 for (
size_t j = 0;
j < matches.size();
j++) {
235 matchesInEtaRange.push_back(
j);
237 else if (level == 1) {
238 if (matches[
j].candL1 == 0)
241 else if (level >= 2) {
242 if (matches[
j].candHlt[hltStep] == 0)
244 else if (!hasMatch[
j]) {
245 LogTrace(
"HLTMuonVal") <<
"Match found for HLT step " << hltStep
246 <<
" of " << nStepsHlt
247 <<
" without previous match!";
253 if (
std::count(hasMatch.begin(), hasMatch.end(),
true) <
257 string pre = source +
"Pass";
260 for (
size_t j = 0;
j < matches.size();
j++) {
261 float pt = matches[
j].candBase->pt();
262 float eta = matches[
j].candBase->eta();
263 float phi = matches[
j].candBase->phi();
265 if (matchesInEtaRange.size() >= 1 && j == matchesInEtaRange[0])
267 if (matchesInEtaRange.size() >= 2 && j == matchesInEtaRange[1])
270 elements_[pre +
"Eta" + post]->Fill(eta);
272 elements_[pre +
"Phi" + post]->Fill(phi);
289 vector<MatchStruct> & matches,
290 const std::vector<L1MuonParticleRef>& candsL1,
291 const std::vector< vector< const RecoChargedCandidate *> >& candsHlt)
294 set<size_t>::iterator it;
296 set<size_t> indicesL1;
297 for (
size_t i = 0;
i < candsL1.size();
i++)
300 vector< set<size_t> > indicesHlt(candsHlt.size());
301 for (
size_t i = 0;
i < candsHlt.size();
i++)
302 for (
size_t j = 0;
j < candsHlt[
i].size();
j++)
305 for (
size_t i = 0;
i < matches.size();
i++) {
309 double bestDeltaR =
cutsDr_[0];
310 size_t bestMatch =
kNull;
311 for (it = indicesL1.begin(); it != indicesL1.end(); it++) {
312 if (candsL1[*it].isAvailable()) {
314 candsL1[*it]->eta(), candsL1[*it]->phi());
315 if (dR < bestDeltaR) {
329 <<
"Ref candsL1[*it]: product not available "
333 if (bestMatch !=
kNull)
334 matches[
i].candL1 = & * candsL1[bestMatch];
335 indicesL1.erase(bestMatch);
337 matches[
i].candHlt.assign(candsHlt.size(), 0);
338 for (
size_t j = 0;
j < candsHlt.size();
j++) {
339 size_t level = (candsHlt.size() == 4) ? (
j < 2) ? 2 : 3 :
340 (candsHlt.size() == 2) ? (
j < 1) ? 2 : 3 :
342 bestDeltaR =
cutsDr_[level - 2];
344 for (it = indicesHlt[
j].
begin(); it != indicesHlt[
j].end(); it++) {
346 candsHlt[
j][*it]->eta(), candsHlt[
j][*it]->phi());
347 if (dR < bestDeltaR) {
352 if (bestMatch !=
kNull)
353 matches[
i].candHlt[
j] = candsHlt[
j][bestMatch];
354 indicesHlt[
j].erase(bestMatch);
377 string sourceUpper =
source;
378 sourceUpper[0] = toupper(sourceUpper[0]);
379 string name = source +
"Pass" + type +
"_" +
label;
382 if (type.find(
"MaxPt") != string::npos) {
383 string desc = (type ==
"MaxPt1") ?
"Leading" :
"Next-to-Leading";
384 string title =
"pT of " + desc +
" " + sourceUpper +
" Muon "+
385 "matched to " +
label;
387 float *
edges =
new float[nBins + 1];
389 h =
new TH1F(name.c_str(), title.c_str(), nBins,
edges);
393 string symbol = (type ==
"Eta") ?
"#eta" :
"#phi";
394 string title = symbol +
" of " + sourceUpper +
" Muons " +
395 "matched to " +
label;
397 int nBins = (int)params[0];
398 double min = params[1];
399 double max = params[2];
400 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
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.
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::string genParticleLabel_
std::vector< std::string > moduleLabels_
MonitorElement * bookFloat(const char *name)
Book float.
void beginRun(const edm::Run &, const edm::EventSetup &)
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)
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_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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::string recMuonLabel_
std::vector< double > parametersPhi_
HLTMuonPlotter(const edm::ParameterSet &, std::string, const std::vector< std::string > &, const std::vector< std::string > &)
std::map< std::string, MonitorElement * > elements_
std::string hltProcessName_
std::vector< double > parametersTurnOn_
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)