CMS 3D CMS Logo

BTagPerformanceAnalyzerMC.cc
Go to the documentation of this file.
5 
6 using namespace reco;
7 using namespace edm;
8 using namespace std;
9 using namespace RecoBTag;
10 
11 typedef std::pair<Jet, reco::JetFlavourInfo> JetWithFlavour;
12 
14  : jetSelector(pSet.getParameter<double>("etaMin"),
15  pSet.getParameter<double>("etaMax"),
16  pSet.getParameter<double>("ptRecJetMin"),
17  pSet.getParameter<double>("ptRecJetMax"),
18  0.0,
19  99999.0,
20  pSet.getParameter<double>("ratioMin"),
21  pSet.getParameter<double>("ratioMax"),
22  pSet.getParameter<bool>("doJetID")),
23  etaRanges(pSet.getParameter<vector<double>>("etaRanges")),
24  ptRanges(pSet.getParameter<vector<double>>("ptRanges")),
25  useOldFlavourTool(pSet.getParameter<bool>("useOldFlavourTool")),
26  doJEC(pSet.getParameter<bool>("doJEC")),
27  ptHatWeight(pSet.getParameter<bool>("applyPtHatWeight")),
28  moduleConfig(pSet.getParameter<vector<edm::ParameterSet>>("tagConfig")),
29  flavPlots_(pSet.getParameter<std::string>("flavPlots")),
30  jetMatcher(pSet.getParameter<edm::ParameterSet>("recJetMatching")),
31  doPUid(pSet.getParameter<bool>("doPUid")) {
32  // mcPlots_ : 1=b+c+l+ni; 2=all+1; 3=1+d+u+s+g; 4=3+all . Default is 2. Don't
33  // use 0.
34  if (flavPlots_.find("dusg") < 15) {
35  if (flavPlots_.find("all") < 15)
36  mcPlots_ = 4;
37  else
38  mcPlots_ = 3;
39  } else {
40  if (flavPlots_.find("all") < 15)
41  mcPlots_ = 2;
42  else
43  mcPlots_ = 1;
44  }
45  double ptRecJetMin = pSet.getParameter<double>("ptRecJetMin");
46  jetMatcher.setThreshold(0.25 * ptRecJetMin);
47  switch (pSet.getParameter<unsigned int>("leptonPlots")) {
48  case 11:
49  electronPlots = true;
50  muonPlots = false;
51  tauPlots = false;
52  break;
53  case 13:
54  muonPlots = true;
55  electronPlots = false;
56  tauPlots = false;
57  break;
58  case 15:
59  tauPlots = true;
60  electronPlots = false;
61  tauPlots = false;
62  break;
63  default:
64  electronPlots = false;
65  muonPlots = false;
66  tauPlots = false;
67  }
68 
69  if (etaRanges.size() <= 1)
70  etaRanges = {pSet.getParameter<double>("etaMin"), pSet.getParameter<double>("etaMax")};
71  if (ptRanges.size() <= 1)
72  ptRanges = {pSet.getParameter<double>("ptRecJetMin"), pSet.getParameter<double>("ptRecJetMax")};
73 
74  genToken = mayConsume<GenEventInfoProduct>(edm::InputTag("generator"));
76  mayConsume<edm::Association<reco::GenJetCollection>>(pSet.getParameter<InputTag>("genJetsMatched"));
77  jetToken = consumes<JetFlavourInfoMatchingCollection>(pSet.getParameter<InputTag>("jetMCSrc"));
78  caloJetToken = mayConsume<JetFlavourMatchingCollection>(pSet.getParameter<InputTag>("caloJetMCSrc"));
79  slInfoToken = consumes<SoftLeptonTagInfoCollection>(pSet.getParameter<InputTag>("softLeptonInfo"));
80  jecMCToken = consumes<JetCorrector>(pSet.getParameter<edm::InputTag>("JECsourceMC"));
81  jecDataToken = mayConsume<JetCorrector>(pSet.getParameter<edm::InputTag>("JECsourceData"));
82 
83  for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin(); iModule != moduleConfig.end();
84  ++iModule) {
85  const string &dataFormatType = iModule->exists("type") ? iModule->getParameter<string>("type") : "JetTag";
86  if (dataFormatType == "JetTag") {
87  const InputTag &moduleLabel = iModule->getParameter<InputTag>("label");
88  jetTagInputTags.push_back(moduleLabel);
89  binJetTagPlotters.push_back(vector<std::unique_ptr<JetTagPlotter>>());
90  jetTagToken.push_back(consumes<JetTagCollection>(moduleLabel));
91  } else if (dataFormatType == "TagCorrelation") {
92  const InputTag &label1 = iModule->getParameter<InputTag>("label1");
93  const InputTag &label2 = iModule->getParameter<InputTag>("label2");
94  tagCorrelationInputTags.push_back(std::pair<edm::InputTag, edm::InputTag>(label1, label2));
95  binTagCorrelationPlotters.push_back(vector<std::unique_ptr<TagCorrelationPlotter>>());
96  tagCorrelationToken.push_back(
98  consumes<JetTagCollection>(label1), consumes<JetTagCollection>(label2)));
99  } else {
100  vector<edm::InputTag> vIP;
101  tiDataFormatType.push_back(dataFormatType);
102  binTagInfoPlotters.push_back(vector<std::unique_ptr<BaseTagInfoPlotter>>());
103  std::vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>> tokens;
104  if (dataFormatType == "GenericMVA") {
105  const std::vector<InputTag> listInfo = iModule->getParameter<vector<InputTag>>("listTagInfos");
106  for (unsigned int ITi = 0; ITi < listInfo.size(); ITi++) {
107  tokens.push_back(consumes<View<BaseTagInfo>>(listInfo[ITi]));
108  vIP.push_back(listInfo[ITi]);
109  }
110  } else {
111  const InputTag &moduleLabel = iModule->getParameter<InputTag>("label");
112  tokens.push_back(consumes<View<BaseTagInfo>>(moduleLabel));
113  vIP.push_back(moduleLabel);
114  }
115  tagInfoToken.push_back(tokens);
116  tagInfoInputTags.push_back(vIP);
117  }
118  }
119 }
120 
122  edm::Run const &run,
123  edm::EventSetup const &es) {
124  //
125  // Book all histograms.
126  //
127 
128  // iterate over ranges:
129  const int iEtaStart = -1; // this will be the inactive one
130  const int iEtaEnd = etaRanges.size() > 2 ? etaRanges.size() - 1
131  : 0; // if there is only one bin defined, leave it as the inactive one
132  const int iPtStart = -1; // this will be the inactive one
133  const int iPtEnd =
134  ptRanges.size() > 2 ? ptRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
135 
136  setTDRStyle();
137 
138  TagInfoPlotterFactory theFactory;
139  int iTag = -1;
140  int iTagCorr = -1;
141  int iInfoTag = -1;
142  for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin(); iModule != moduleConfig.end();
143  ++iModule) {
144  const string &dataFormatType = iModule->exists("type") ? iModule->getParameter<string>("type") : "JetTag";
145  if (dataFormatType == "JetTag") {
146  iTag++;
147  const string &folderName = iModule->getParameter<string>("folder");
148 
149  bool doDifferentialPlots = false;
150  double discrCut = -999.;
151  if (iModule->exists("differentialPlots") && iModule->getParameter<bool>("differentialPlots") == true) {
152  doDifferentialPlots = true;
153  discrCut = iModule->getParameter<double>("discrCut");
154  }
155 
156  // eta loop
157  for (int iEta = iEtaStart; iEta < iEtaEnd; iEta++) {
158  // pt loop
159  for (int iPt = iPtStart; iPt < iPtEnd; iPt++) {
160  const EtaPtBin &etaPtBin = getEtaPtBin(iEta, iPt);
161 
162  // Instantiate the genertic b tag plotter
163  binJetTagPlotters.at(iTag).push_back(
164  std::make_unique<JetTagPlotter>(folderName,
165  etaPtBin,
166  iModule->getParameter<edm::ParameterSet>("parameters"),
167  mcPlots_,
168  false,
169  ibook,
170  false,
171  doDifferentialPlots,
172  discrCut));
173  }
174  }
175  } else if (dataFormatType == "TagCorrelation") {
176  iTagCorr++;
177  const InputTag &label1 = iModule->getParameter<InputTag>("label1");
178  const InputTag &label2 = iModule->getParameter<InputTag>("label2");
179 
180  // eta loop
181  for (int iEta = iEtaStart; iEta != iEtaEnd; ++iEta) {
182  // pt loop
183  for (int iPt = iPtStart; iPt != iPtEnd; ++iPt) {
184  const EtaPtBin &etaPtBin = getEtaPtBin(iEta, iPt);
185  // Instantiate the generic b tag correlation plotter
186  binTagCorrelationPlotters.at(iTagCorr).push_back(
187  std::make_unique<TagCorrelationPlotter>(label1.label(),
188  label2.label(),
189  etaPtBin,
190  iModule->getParameter<edm::ParameterSet>("parameters"),
191  mcPlots_,
192  false,
193  false,
194  ibook));
195  }
196  }
197  } else {
198  iInfoTag++;
199  // tag info retrievel is deferred (needs availability of EventSetup)
200  const InputTag &moduleLabel = iModule->getParameter<InputTag>("label");
201  const string &folderName = iModule->getParameter<string>("folder");
202  // eta loop
203  for (int iEta = iEtaStart; iEta < iEtaEnd; iEta++) {
204  // pt loop
205  for (int iPt = iPtStart; iPt < iPtEnd; iPt++) {
206  const EtaPtBin &etaPtBin = getEtaPtBin(iEta, iPt);
207 
208  // Instantiate the tagInfo plotter
209  binTagInfoPlotters.at(iInfoTag).push_back(
210  theFactory.buildPlotter(dataFormatType,
211  moduleLabel.label(),
212  etaPtBin,
213  iModule->getParameter<edm::ParameterSet>("parameters"),
214  folderName,
215  mcPlots_,
216  false,
217  ibook));
218  }
219  }
220  }
221  }
222 }
223 
224 EtaPtBin BTagPerformanceAnalyzerMC::getEtaPtBin(const int &iEta, const int &iPt) {
225  // DEFINE BTagBin:
226  bool etaActive_, ptActive_;
227  double etaMin_, etaMax_, ptMin_, ptMax_;
228 
229  if (iEta != -1) {
230  etaActive_ = true;
231  etaMin_ = etaRanges[iEta];
232  etaMax_ = etaRanges[iEta + 1];
233  } else {
234  etaActive_ = false;
235  etaMin_ = etaRanges[0];
236  etaMax_ = etaRanges[etaRanges.size() - 1];
237  }
238 
239  if (iPt != -1) {
240  ptActive_ = true;
241  ptMin_ = ptRanges[iPt];
242  ptMax_ = ptRanges[iPt + 1];
243  } else {
244  ptActive_ = false;
245  ptMin_ = ptRanges[0];
246  ptMax_ = ptRanges[ptRanges.size() - 1];
247  }
248  return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_, ptMax_);
249 }
250 
252 
254  eventInitialized = false;
255 
256  float weight = 1; // event weight
257 
258  if (ptHatWeight) {
259  /* APPLY PTHAT EVENT WEIGHT */
260 
261  edm::Handle<GenEventInfoProduct> genInfoHandle;
262  iEvent.getByToken(genToken, genInfoHandle);
263 
264  if (genInfoHandle.isValid()) {
265  weight = weight * static_cast<float>(genInfoHandle->weight());
266  }
267  }
268 
269  LogDebug("Info") << "Event weight is: " << weight;
270 
271  FlavourMap flavours;
273 
274  if (!useOldFlavourTool) {
276  iEvent.getByToken(jetToken, jetMC);
277  for (JetFlavourInfoMatchingCollection::const_iterator iter = jetMC->begin(); iter != jetMC->end(); ++iter) {
278  unsigned int fl = std::abs(iter->second.getPartonFlavour());
279  flavours.insert(std::make_pair(iter->first, fl));
280  const GenParticleRefVector &lep = iter->second.getLeptons();
281  reco::JetFlavour::Leptons lepCount;
282  for (unsigned int i = 0; i < lep.size(); i++) {
283  if (abs(lep[i]->pdgId()) == 11)
284  lepCount.electron++;
285  else if (abs(lep[i]->pdgId()) == 13)
286  lepCount.muon++;
287  else if (abs(lep[i]->pdgId()) == 15)
288  lepCount.tau++;
289  }
290  leptons.insert(std::make_pair(iter->first, lepCount));
291  }
292  } else {
294  iEvent.getByToken(caloJetToken, jetMC);
295  for (JetFlavourMatchingCollection::const_iterator iter = jetMC->begin(); iter != jetMC->end(); ++iter) {
296  unsigned int fl = std::abs(iter->second.getFlavour());
297  flavours.insert(std::make_pair(iter->first, fl));
298  const reco::JetFlavour::Leptons &lep = iter->second.getLeptons();
299  leptons.insert(std::make_pair(iter->first, lep));
300  }
301  }
302 
304  iEvent.getByToken(slInfoToken, infoHandle);
305 
307  if (doPUid) {
308  iEvent.getByToken(genJetsMatchedToken, genJetsMatched);
309  }
310 
311  // Get JEC
312  const JetCorrector *corrector = nullptr;
313  if (doJEC) {
314  edm::Handle<GenEventInfoProduct> genInfoHandle; // check if data or MC
315  iEvent.getByToken(genToken, genInfoHandle);
316  edm::Handle<JetCorrector> corrHandle;
317  if (!genInfoHandle.isValid())
318  iEvent.getByToken(jecDataToken, corrHandle);
319  else
320  iEvent.getByToken(jecMCToken, corrHandle);
321  corrector = corrHandle.product();
322  }
323  //
324 
325  // Look first at the jetTags
326  for (unsigned int iJetLabel = 0; iJetLabel != jetTagInputTags.size(); ++iJetLabel) {
328  iEvent.getByToken(jetTagToken[iJetLabel], tagHandle);
329  const reco::JetTagCollection &tagColl = *(tagHandle.product());
330  LogDebug("Info") << "Found " << tagColl.size() << " B candidates in collection " << jetTagInputTags[iJetLabel];
331 
332  int plotterSize = binJetTagPlotters[iJetLabel].size();
333  for (JetTagCollection::const_iterator tagI = tagColl.begin(); tagI != tagColl.end(); ++tagI) {
334  // Identify parton associated to jet.
335 
337  if (flavours[tagI->first] == 5 &&
338  ((electronPlots && !leptons[tagI->first].electron) || (muonPlots && !leptons[tagI->first].muon) ||
339  (tauPlots && !leptons[tagI->first].tau)))
340  continue;
341  // JEC
342  double jec = 1.0;
343  /*reco::Jet correctedJet = *(tagI->first);
344  if(doJEC && corrector) {
345  jec = corrector->correction(*(tagI->first));
346  }*/
347 
348  JetWithFlavour jetWithFlavour;
349  // also applies JEC to jet
350  if (!getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
351  continue;
352  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
353  continue;
354 
355  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
356  bool inBin = false;
357  inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec);
358  // Fill histograms if in desired pt/rapidity bin.
359  if (inBin)
360  binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(
361  jetWithFlavour.first, jec, tagI->second, std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
362  }
363  }
364  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
365  binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(weight);
366  }
367  }
368 
369  // Now look at Tag Correlations
370  for (unsigned int iJetLabel = 0; iJetLabel != tagCorrelationInputTags.size(); ++iJetLabel) {
371  const std::pair<edm::EDGetTokenT<reco::JetTagCollection>, edm::EDGetTokenT<reco::JetTagCollection>> &inputTokens =
372  tagCorrelationToken[iJetLabel];
374  iEvent.getByToken(inputTokens.first, tagHandle1);
375  const reco::JetTagCollection &tagColl1 = *(tagHandle1.product());
376 
378  iEvent.getByToken(inputTokens.second, tagHandle2);
379  const reco::JetTagCollection &tagColl2 = *(tagHandle2.product());
380 
381  int plotterSize = binTagCorrelationPlotters[iJetLabel].size();
382  for (JetTagCollection::const_iterator tagI = tagColl1.begin(); tagI != tagColl1.end(); ++tagI) {
383  if (flavours[tagI->first] == 5 &&
384  ((electronPlots && !leptons[tagI->first].electron) || (muonPlots && !leptons[tagI->first].muon) ||
385  (tauPlots && !leptons[tagI->first].tau)))
386  continue;
387 
388  // JEC
389  double jec = 1.0;
390  /*reco::Jet correctedJet = *(tagI->first);
391  if(doJEC && corrector) {
392  jec = corrector->correction(*(tagI->first));
393  }*/
394 
395  JetWithFlavour jetWithFlavour;
396  // also applies JEC to jet
397  if (!getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
398  continue;
399  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
400  continue;
401 
402  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
403  bool inBin = false;
404  inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec);
405 
406  if (inBin) {
407  double discr2 = tagColl2[tagI->first];
408  binTagCorrelationPlotters[iJetLabel][iPlotter]->analyzeTags(
409  tagI->second, discr2, std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
410  }
411  }
412  }
413  }
414 
415  // Now look at the TagInfos
416 
417  for (unsigned int iJetLabel = 0; iJetLabel != tiDataFormatType.size(); ++iJetLabel) {
418  int plotterSize = binTagInfoPlotters[iJetLabel].size();
419  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
420  binTagInfoPlotters[iJetLabel][iPlotter]->setEventSetup(iSetup);
421 
422  vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>> &tokens = tagInfoToken[iJetLabel];
423  // check number of tag infos = expected number of tag infos
424  vector<string> labels = binTagInfoPlotters[iJetLabel][0]->tagInfoRequirements();
425  if (labels.empty())
426  labels.push_back("label");
427  if (labels.size() != tokens.size())
428  throw cms::Exception("Configuration")
429  << "Different number of Tag Infos than expected" << labels.size() << tokens.size() << endl;
430 
431  unsigned int nInputTags = tokens.size();
432  vector<edm::Handle<View<BaseTagInfo>>> tagInfoHandles(nInputTags);
433  edm::ProductID jetProductID;
434  unsigned int nTagInfos = 0;
435  for (unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) {
436  edm::Handle<View<BaseTagInfo>> &tagInfoHandle = tagInfoHandles[iInputTags];
437  iEvent.getByToken(tokens[iInputTags], tagInfoHandle);
438  if (tagInfoHandle.isValid() == false) {
439  edm::LogWarning("BTagPerformanceAnalyzerMC")
440  << " Collection " << tagInfoInputTags[iJetLabel][iInputTags] << " not present. Skipping it for this event.";
441  continue;
442  }
443 
444  unsigned int size = tagInfoHandle->size();
445  LogDebug("Info") << "Found " << size << " B candidates in collection " << tagInfoInputTags[iJetLabel][iInputTags];
446  edm::ProductID thisProductID = (size > 0) ? (*tagInfoHandle)[0].jet().id() : edm::ProductID();
447  if (iInputTags == 0) {
448  jetProductID = thisProductID;
449  nTagInfos = size;
450  } else if (jetProductID != thisProductID)
451  throw cms::Exception("Configuration") << "TagInfos are referencing a different jet collection." << endl;
452  else if (nTagInfos != size)
453  throw cms::Exception("Configuration") << "TagInfo collections are having a different size." << endl;
454  }
455 
456  for (unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
457  vector<const BaseTagInfo *> baseTagInfos(nInputTags);
458  edm::RefToBase<Jet> jetRef;
459  for (unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
460  const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
461  if (iTagInfo == 0)
462  jetRef = baseTagInfo.jet();
463  else if (baseTagInfo.jet() != jetRef)
464  throw cms::Exception("Configuration") << "TagInfos pointing to different jets." << endl;
465  baseTagInfos[iTagInfo] = &baseTagInfo;
466  }
467 
468  // Identify parton associated to jet.
469 
471  if (flavours[jetRef] == 5 && ((electronPlots && !leptons[jetRef].electron) ||
472  (muonPlots && !leptons[jetRef].muon) || (tauPlots && !leptons[jetRef].tau)))
473  continue;
474 
475  // JEC
476  double jec = 1.0;
477  /*reco::Jet correctedJet = *(jetRef);
478  if(doJEC && corrector) {
479  jec = corrector->correction(*(jetRef));
480  }*/
481 
482  JetWithFlavour jetWithFlavour;
483  // also applies JEC to jet
484  if (!getJetWithFlavour(iEvent, jetRef, flavours, jetWithFlavour, corrector, genJetsMatched))
485  continue;
486  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
487  continue;
488 
489  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
490  bool inBin = false;
491  inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec);
492  // Fill histograms if in desired pt/rapidity bin.
493  if (inBin)
494  binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(
495  baseTagInfos, jec, std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
496  }
497  }
498  }
499 }
500 
503  if (!doPUid)
504  return true;
505  reco::GenJetRef genjet = (*genJetsMatched)[jetRef];
506  if (genjet.isNonnull() && genjet.isAvailable())
507  return true;
508  return false;
509 }
510 
512  edm::RefToBase<Jet> jetRef,
513  const FlavourMap &flavours,
514  JetWithFlavour &jetWithFlavour,
515  const JetCorrector *corrector,
517  edm::ProductID recProdId = jetRef.id();
518  edm::ProductID refProdId = (flavours.begin() == flavours.end()) ? recProdId : flavours.begin()->first.id();
519 
520  if (!eventInitialized) {
521  jetCorrector.setCorrector(corrector);
522  if (recProdId != refProdId) {
524  for (FlavourMap::const_iterator iter = flavours.begin(); iter != flavours.end(); ++iter)
525  refJets.push_back(iter->first);
526  const edm::RefToBaseProd<Jet> recJetsProd(edm::makeRefToBaseProdFrom(jetRef, iEvent));
528  for (unsigned int i = 0; i < recJetsProd->size(); i++)
529  recJets.push_back(edm::RefToBase<Jet>(recJetsProd, i));
530  jetMatcher.matchCollections(refJets, recJets, corrector);
531  }
532  eventInitialized = true;
533  }
534 
535  if (recProdId != refProdId) {
536  jetRef = jetMatcher(jetRef);
537  if (jetRef.isNull())
538  return false;
539  }
540 
541  // apply JEC
542  jetWithFlavour.first = jetCorrector(*jetRef);
543 
544  auto itFound = flavours.find(jetRef);
545  unsigned int flavour = itFound != flavours.end() ? itFound->second : 0;
546 
547  if (doPUid) {
548  bool isNotPU = getJetWithGenJet(jetRef, genJetsMatched);
549  if (!isNotPU)
550  flavour = 20;
551  }
552 
553  jetWithFlavour.second = reco::JetFlavourInfo(flavour, flavour);
554 
555  LogTrace("Info") << "Found jet with flavour " << jetWithFlavour.second.getPartonFlavour() << endl;
556  LogTrace("Info") << jetWithFlavour.first.p() << " , " << jetWithFlavour.first.pt() << " - " << endl;
557  //<< jetWithFlavour.second.getLorentzVector().P()<<" , "<<
558  // jetWithFlavour.second.getLorentzVector().Pt()<<endl;
559 
560  return true;
561 }
562 
563 // define this as a plug-in
#define LogDebug(id)
size
Write out results.
bool isAvailable() const
Definition: Ref.h:575
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
transient_vector_type::const_iterator const_iterator
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetsMatchedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::EDGetTokenT< reco::JetTagCollection > > jetTagToken
void setThreshold(const double &energy)
Definition: MatchJet.h:25
edm::EDGetTokenT< reco::JetCorrector > jecMCToken
std::map< edm::RefToBase< reco::Jet >, unsigned int, JetRefCompare > FlavourMap
std::map< edm::RefToBase< reco::Jet >, reco::JetFlavour::Leptons, JetRefCompare > LeptonMap
const_iterator end() const
std::vector< std::pair< edm::InputTag, edm::InputTag > > tagCorrelationInputTags
size_type size() const
std::vector< std::pair< edm::EDGetTokenT< reco::JetTagCollection >, edm::EDGetTokenT< reco::JetTagCollection > > > tagCorrelationToken
Definition: weight.py:1
double weight() const
ProductID id() const
Definition: RefToBase.h:242
std::pair< reco::Jet, reco::JetFlavourInfo > JetWithFlavour
edm::EDGetTokenT< GenEventInfoProduct > genToken
void matchCollections(const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const reco::JetCorrector *corrector)
match the collections
Definition: MatchJet.cc:28
std::pair< Jet, reco::JetFlavourInfo > JetWithFlavour
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: BaseTagInfo.h:24
bool getJetWithGenJet(edm::RefToBase< reco::Jet > jetRef, edm::Handle< edm::Association< reco::GenJetCollection >> genJetsMatched)
BTagPerformanceAnalyzerMC(const edm::ParameterSet &pSet)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::JetFlavourMatchingCollection > caloJetToken
std::vector< std::vector< std::unique_ptr< TagCorrelationPlotter > > > binTagCorrelationPlotters
std::vector< std::vector< std::unique_ptr< BaseTagInfoPlotter > > > binTagInfoPlotters
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetToken
def setTDRStyle()
Definition: plotscripts.py:89
Class storing the jet flavour information.
edm::EDGetTokenT< reco::JetCorrector > jecDataToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > > tagInfoToken
std::vector< edm::ParameterSet > moduleConfig
EtaPtBin getEtaPtBin(const int &iEta, const int &iPt)
bool isValid() const
Definition: HandleBase.h:74
#define LogTrace(id)
lepton info struct
Definition: JetFlavour.h:23
T const * product() const
Definition: Handle.h:74
Definition: Tools.h:23
std::vector< std::string > tiDataFormatType
edm::EDGetTokenT< reco::SoftLeptonTagInfoCollection > slInfoToken
bool isNull() const
Checks for null.
Definition: RefToBase.h:331
void setCorrector(const reco::JetCorrector *corrector)
Returns the corrected jet.
Definition: CorrectJet.h:22
std::vector< std::vector< edm::InputTag > > tagInfoInputTags
std::string const & label() const
Definition: InputTag.h:36
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
fixed size matrix
HLT enums.
std::vector< edm::InputTag > jetTagInputTags
void push_back(const RefToBase< T > &)
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
ProductIndex id() const
Definition: ProductID.h:38
std::vector< std::vector< std::unique_ptr< JetTagPlotter > > > binJetTagPlotters
std::unique_ptr< BaseTagInfoPlotter > buildPlotter(const std::string &dataFormatType, const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, unsigned int mc, bool wf, DQMStore::IBooker &ibook)
const_iterator begin() const
bool getJetWithFlavour(const edm::Event &iEvent, edm::RefToBase< reco::Jet > caloRef, const FlavourMap &_flavours, JetWithFlavour &jetWithFlavour, const reco::JetCorrector *corrector, edm::Handle< edm::Association< reco::GenJetCollection >> genJetsMatched)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:45
size_type size() const