CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
BTagPerformanceAnalyzerMC Class Reference

#include <BTagPerformanceAnalyzerMC.h>

Inheritance diagram for BTagPerformanceAnalyzerMC:
edm::EDAnalyzer

Classes

struct  JetRefCompare
 

Public Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 BTagPerformanceAnalyzerMC (const edm::ParameterSet &pSet)
 
virtual void endJob ()
 
 ~BTagPerformanceAnalyzerMC ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Types

typedef std::map
< edm::RefToBase< reco::Jet >
, unsigned int, JetRefCompare
FlavourMap
 
typedef std::pair< reco::Jet,
reco::JetFlavour
JetWithFlavour
 
typedef std::map
< edm::RefToBase< reco::Jet >
, reco::JetFlavour::Leptons,
JetRefCompare
LeptonMap
 

Private Member Functions

void bookHistos (const edm::ParameterSet &pSet)
 
EtaPtBin getEtaPtBin (const int &iEta, const int &iPt)
 
bool getJetWithFlavour (edm::RefToBase< reco::Jet > caloRef, FlavourMap flavours, JetWithFlavour &jetWithFlavour, const edm::EventSetup &es)
 

Private Attributes

bool allHisto
 
std::vector< std::vector
< JetTagPlotter * > > 
binJetTagPlotters
 
std::vector< std::vector
< TagCorrelationPlotter * > > 
binTagCorrelationPlotters
 
std::vector< std::vector
< BaseTagInfoPlotter * > > 
binTagInfoPlotters
 
std::map< BaseTagInfoPlotter
*, size_t > 
binTagInfoPlottersToModuleConfig
 
std::vector< std::vector
< BTagDifferentialPlot * > > 
differentialPlots
 
bool electronPlots
 
std::string epsBaseName
 
std::vector< double > etaRanges
 
bool eventInitialized
 
bool finalize
 
bool finalizeOnly
 
std::string inputFile
 
CorrectJet jetCorrector
 
MatchJet jetMatcher
 
edm::InputTag jetMCSrc
 
AcceptJet jetSelector
 
std::vector< edm::InputTagjetTagInputTags
 
bool makeDiffPlots_
 
bool mcPlots_
 
std::vector< edm::ParameterSetmoduleConfig
 
bool muonPlots
 
bool partonKinematics
 
bool produceEps
 
bool producePs
 
std::string psBaseName
 
double ptPartonMax
 
double ptPartonMin
 
std::vector< double > ptRanges
 
edm::InputTag slInfoTag
 
std::vector< std::pair
< edm::InputTag, edm::InputTag > > 
tagCorrelationInputTags
 
std::vector< std::vector
< edm::InputTag > > 
tagInfoInputTags
 
bool tauPlots
 
std::vector< std::string > tiDataFormatType
 
bool update
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Top level steering routine for b tag performance analysis.

Definition at line 45 of file BTagPerformanceAnalyzerMC.h.

Member Typedef Documentation

Definition at line 68 of file BTagPerformanceAnalyzerMC.h.

Definition at line 67 of file BTagPerformanceAnalyzerMC.h.

Definition at line 69 of file BTagPerformanceAnalyzerMC.h.

Constructor & Destructor Documentation

BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC ( const edm::ParameterSet pSet)
explicit

Definition at line 19 of file BTagPerformanceAnalyzerMC.cc.

References bookHistos(), electronPlots, edm::ParameterSet::getParameter(), jetMatcher, muonPlots, MatchJet::setThreshold(), and tauPlots.

19  :
20  partonKinematics(pSet.getParameter< bool >("partonKinematics")),
21  ptPartonMin(pSet.getParameter<double>("ptPartonMin")),
22  ptPartonMax(pSet.getParameter<double>("ptPartonMax")),
24  pSet.getParameter<double>("etaMin"),
25  pSet.getParameter<double>("etaMax"),
26  pSet.getParameter<double>("ptRecJetMin"),
27  pSet.getParameter<double>("ptRecJetMax"),
28  0.0, 99999.0,
29  pSet.getParameter<double>("ratioMin"),
30  pSet.getParameter<double>("ratioMax")
31  ),
32  etaRanges(pSet.getParameter< vector<double> >("etaRanges")),
33  ptRanges(pSet.getParameter< vector<double> >("ptRanges")),
34  produceEps(pSet.getParameter< bool >("produceEps")),
35  producePs(pSet.getParameter< bool >("producePs")),
36  inputFile(pSet.getParameter<std::string>( "inputfile" )),
37  update(pSet.getParameter<bool>( "update" )),
38  allHisto(pSet.getParameter<bool>( "allHistograms" )),
39  finalize(pSet.getParameter< bool >("finalizePlots")),
40  finalizeOnly(pSet.getParameter< bool >("finalizeOnly")),
41  jetMCSrc(pSet.getParameter<edm::InputTag>("jetMCSrc")),
42  slInfoTag(pSet.getParameter<edm::InputTag>("softLeptonInfo")),
43  moduleConfig(pSet.getParameter< vector<edm::ParameterSet> >("tagConfig")),
44  mcPlots_(pSet.getParameter< bool >("mcPlots")),
45  makeDiffPlots_(pSet.getParameter< bool >("differentialPlots")),
46  jetCorrector(pSet.getParameter<std::string>("jetCorrection")),
47  jetMatcher(pSet.getParameter<edm::ParameterSet>("recJetMatching"))
48 {
49  double ptRecJetMin = pSet.getParameter<double>("ptRecJetMin");
50  jetMatcher.setThreshold(0.25 * ptRecJetMin);
51  switch(pSet.getParameter<unsigned int>("leptonPlots")) {
52  case 11: electronPlots = true; muonPlots = false; tauPlots = false; break;
53  case 13: muonPlots = true; electronPlots = false; tauPlots = false; break;
54  case 15: tauPlots = true; electronPlots = false; tauPlots = false; break;
55  default: electronPlots = false; muonPlots = false; tauPlots = false;
56  }
57  bookHistos(pSet);
58 }
T getParameter(std::string const &) const
void setThreshold(const double &energy)
Definition: MatchJet.h:25
std::vector< edm::ParameterSet > moduleConfig
void bookHistos(const edm::ParameterSet &pSet)
BTagPerformanceAnalyzerMC::~BTagPerformanceAnalyzerMC ( )

Definition at line 234 of file BTagPerformanceAnalyzerMC.cc.

References binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, differentialPlots, finalize, makeDiffPlots_, and mcPlots_.

235 {
236  for (vector<vector<JetTagPlotter*> >::iterator iJetLabel = binJetTagPlotters.begin();
237  iJetLabel != binJetTagPlotters.end(); ++iJetLabel)
238  for (vector<JetTagPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
239  delete *iPlotter;
240 
241  if (finalize && mcPlots_ && makeDiffPlots_) {
242  for(vector<vector<BTagDifferentialPlot*> >::iterator iJetLabel = differentialPlots.begin();
243  iJetLabel != differentialPlots.end(); ++iJetLabel)
244  for (vector<BTagDifferentialPlot *>::iterator iPlotter = iJetLabel->begin();
245  iPlotter != iJetLabel->end(); ++ iPlotter)
246  delete *iPlotter;
247  }
248 
249  for (vector<vector<TagCorrelationPlotter*> >::iterator iJetLabel = binTagCorrelationPlotters.begin();
250  iJetLabel != binTagCorrelationPlotters.end(); ++iJetLabel)
251  for (vector<TagCorrelationPlotter* >::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
252  delete *iPlotter;
253 
254 
255  for (vector<vector<BaseTagInfoPlotter*> >::iterator iJetLabel = binTagInfoPlotters.begin();
256  iJetLabel != binTagInfoPlotters.end(); ++iJetLabel)
257  for (vector<BaseTagInfoPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
258  delete *iPlotter;
259 
260 }
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
std::vector< std::vector< BTagDifferentialPlot * > > differentialPlots
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters

Member Function Documentation

void BTagPerformanceAnalyzerMC::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

needed for lepton specific plots

needed for lepton specific plots

Implements edm::EDAnalyzer.

Definition at line 262 of file BTagPerformanceAnalyzerMC.cc.

References abs, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::begin(), binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, binTagInfoPlottersToModuleConfig, metsig::electron, electronPlots, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::end(), eventInitialized, edm::hlt::Exception, finalizeOnly, edm::Event::getByLabel(), getJetWithFlavour(), edm::ProductID::id(), reco::BaseTagInfo::jet(), jetMCSrc, jetSelector, jetTagInputTags, reco_calib_source_client_cfg::labels, EgammaValidation_Wenu_cff::leptons, LogDebug, moduleConfig, metsig::muon, muonPlots, partonKinematics, edm::Handle< T >::product(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size(), findQualityFiles::size, slInfoTag, tagCorrelationInputTags, tagInfoInputTags, BaseTagInfoPlotter::tagInfoRequirements(), metsig::tau, tauPlots, and tiDataFormatType.

263 {
264  eventInitialized = false;
265 
266  if (finalizeOnly) return;
267 
269  FlavourMap flavours;
271 
272  iEvent.getByLabel(jetMCSrc, jetMC);
273  for (JetFlavourMatchingCollection::const_iterator iter = jetMC->begin();
274  iter != jetMC->end(); ++iter) {
275  unsigned int fl = std::abs(iter->second.getFlavour());
276  flavours.insert(std::make_pair(iter->first, fl));
277  const reco::JetFlavour::Leptons &lep = iter->second.getLeptons();
278  leptons.insert(std::make_pair(iter->first, lep));
279  }
280 
282  iEvent.getByLabel(slInfoTag, infoHandle);
283 
284 // Look first at the jetTags
285 
286  for (unsigned int iJetLabel = 0; iJetLabel != jetTagInputTags.size(); ++iJetLabel) {
288  iEvent.getByLabel(jetTagInputTags[iJetLabel], tagHandle);
289  const reco::JetTagCollection & tagColl = *(tagHandle.product());
290  LogDebug("Info") << "Found " << tagColl.size() << " B candidates in collection " << jetTagInputTags[iJetLabel];
291 
292  int plotterSize = binJetTagPlotters[iJetLabel].size();
293  for (JetTagCollection::const_iterator tagI = tagColl.begin();
294  tagI != tagColl.end(); ++tagI) {
295  // Identify parton associated to jet.
296 
298  if (flavours[tagI->first] == 5 &&
299  ((electronPlots && !leptons[tagI->first].electron) ||
300  (muonPlots && !leptons[tagI->first].muon) ||
301  (tauPlots && !leptons[tagI->first].tau)))
302  continue;
303 
304  JetWithFlavour jetWithFlavour;
305  if (!getJetWithFlavour(tagI->first, flavours, jetWithFlavour, iSetup))
306  continue;
307  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getFlavour()), infoHandle))
308  continue;
309 
310  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
311  bool inBin = false;
312  if (partonKinematics)
313  inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.second.getLorentzVector().Eta(),
314  jetWithFlavour.second.getLorentzVector().Pt());
315  else
316  inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first);
317  // Fill histograms if in desired pt/rapidity bin.
318  if (inBin)
319  binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(jetWithFlavour.first, tagI->second, std::abs(jetWithFlavour.second.getFlavour()));
320  }
321  }
322  }
323 
324 // Now look at Tag Correlations
325  for (unsigned int iJetLabel = 0; iJetLabel != tagCorrelationInputTags.size(); ++iJetLabel) {
326  const std::pair<edm::InputTag, edm::InputTag>& inputTags = tagCorrelationInputTags[iJetLabel];
328  iEvent.getByLabel(inputTags.first, tagHandle1);
329  const reco::JetTagCollection& tagColl1 = *(tagHandle1.product());
330 
332  iEvent.getByLabel(inputTags.second, tagHandle2);
333  const reco::JetTagCollection& tagColl2 = *(tagHandle2.product());
334 
335  int plotterSize = binTagCorrelationPlotters[iJetLabel].size();
336  for (JetTagCollection::const_iterator tagI = tagColl1.begin(); tagI != tagColl1.end(); ++tagI) {
337 
338  if (flavours[tagI->first] == 5 &&
339  ((electronPlots && !leptons[tagI->first].electron) ||
340  (muonPlots && !leptons[tagI->first].muon) ||
341  (tauPlots && !leptons[tagI->first].tau)))
342  continue;
343 
344  JetWithFlavour jetWithFlavour;
345  if (!getJetWithFlavour(tagI->first, flavours, jetWithFlavour, iSetup))
346  continue;
347  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getFlavour()), infoHandle))
348  continue;
349 
350  for(int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
351  bool inBin = false;
352  if (partonKinematics)
353  inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.second.getLorentzVector().Eta(),
354  jetWithFlavour.second.getLorentzVector().Pt());
355 
356  else
357  inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first);
358 
359  if(inBin)
360  {
361  double discr2 = tagColl2[tagI->first];
362  binTagCorrelationPlotters[iJetLabel][iPlotter]->analyzeTags(tagI->second, discr2, std::abs(jetWithFlavour.second.getFlavour()));
363  }
364  }
365  }
366  }
367 
368 // Now look at the TagInfos
369 
370  for (unsigned int iJetLabel = 0; iJetLabel != tiDataFormatType.size(); ++iJetLabel) {
371  int plotterSize = binTagInfoPlotters[iJetLabel].size();
372  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
373  binTagInfoPlotters[iJetLabel][iPlotter]->setEventSetup(iSetup);
374 
375  vector<edm::InputTag> & inputTags = tagInfoInputTags[iJetLabel];
376  if (inputTags.empty()) {
377  // deferred retrieval of input tags
378  BaseTagInfoPlotter *firstPlotter = binTagInfoPlotters[iJetLabel][0];
379  int iModule = binTagInfoPlottersToModuleConfig[firstPlotter];
380  vector<string> labels = firstPlotter->tagInfoRequirements();
381  if (labels.empty())
382  labels.push_back("label");
383  for (vector<string>::const_iterator iLabels = labels.begin();
384  iLabels != labels.end(); ++iLabels) {
385  edm::InputTag inputTag =
386  moduleConfig[iModule].getParameter<InputTag>(*iLabels);
387  inputTags.push_back(inputTag);
388  }
389  }
390 
391  unsigned int nInputTags = inputTags.size();
392  vector< edm::Handle< View<BaseTagInfo> > > tagInfoHandles(nInputTags);
393  edm::ProductID jetProductID;
394  unsigned int nTagInfos = 0;
395  for (unsigned int iInputTags = 0; iInputTags < inputTags.size(); ++iInputTags) {
396  edm::Handle< View<BaseTagInfo> > & tagInfoHandle = tagInfoHandles[iInputTags];
397  iEvent.getByLabel(inputTags[iInputTags], tagInfoHandle);
398  unsigned int size = tagInfoHandle->size();
399  LogDebug("Info") << "Found " << size << " B candidates in collection " << inputTags[iInputTags];
400 
401  edm::ProductID thisProductID = (size > 0) ? (*tagInfoHandle)[0].jet().id() : edm::ProductID();
402  if (iInputTags == 0) {
403  jetProductID = thisProductID;
404  nTagInfos = size;
405  } else if (jetProductID != thisProductID)
406  throw cms::Exception("Configuration") << "TagInfos are referencing a different jet collection." << endl;
407  else if (nTagInfos != size)
408  throw cms::Exception("Configuration") << "TagInfo collections are having a different size." << endl;
409  }
410 
411  for (unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
412  vector<const BaseTagInfo*> baseTagInfos(nInputTags);
413  edm::RefToBase<Jet> jetRef;
414  for (unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
415  const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
416  if (iTagInfo == 0)
417  jetRef = baseTagInfo.jet();
418  else if (baseTagInfo.jet() != jetRef)
419  throw cms::Exception("Configuration") << "TagInfos pointing to different jets." << endl;
420  baseTagInfos[iTagInfo] = &baseTagInfo;
421  }
422 
423  // Identify parton associated to jet.
424 
426  if (flavours[jetRef] == 5 &&
427  ((electronPlots && !leptons[jetRef].electron) ||
428  (muonPlots && !leptons[jetRef].muon) ||
429  (tauPlots && !leptons[jetRef].tau)))
430  continue;
431 
432  JetWithFlavour jetWithFlavour;
433  if (!getJetWithFlavour(jetRef, flavours, jetWithFlavour, iSetup))
434  continue;
435  if (!jetSelector(jetWithFlavour.first, std::abs(jetWithFlavour.second.getFlavour()), infoHandle))
436  continue;
437 
438  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
439  bool inBin = false;
440  if (partonKinematics)
441  inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.second.getLorentzVector().Eta(),
442  jetWithFlavour.second.getLorentzVector().Pt());
443  else
444  inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef);
445  // Fill histograms if in desired pt/rapidity bin.
446  if (inBin)
447  binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, std::abs(jetWithFlavour.second.getFlavour()));
448  }
449  }
450  }
451 }
#define LogDebug(id)
std::vector< std::pair< edm::InputTag, edm::InputTag > > tagCorrelationInputTags
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
transient_vector_type::const_iterator const_iterator
std::map< edm::RefToBase< reco::Jet >, unsigned int, JetRefCompare > FlavourMap
std::map< edm::RefToBase< reco::Jet >, reco::JetFlavour::Leptons, JetRefCompare > LeptonMap
#define abs(x)
Definition: mlp_lapack.h:159
const_iterator end() const
std::pair< Jet, reco::JetFlavour > JetWithFlavour
bool getJetWithFlavour(edm::RefToBase< reco::Jet > caloRef, FlavourMap flavours, JetWithFlavour &jetWithFlavour, const edm::EventSetup &es)
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: BaseTagInfo.h:24
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
std::vector< edm::ParameterSet > moduleConfig
std::vector< std::vector< edm::InputTag > > tagInfoInputTags
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
lepton info struct
Definition: JetFlavour.h:25
virtual std::vector< std::string > tagInfoRequirements() const
std::vector< std::string > tiDataFormatType
T const * product() const
Definition: Handle.h:74
std::vector< edm::InputTag > jetTagInputTags
ProductIndex id() const
Definition: ProductID.h:38
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
const_iterator begin() const
std::map< BaseTagInfoPlotter *, size_t > binTagInfoPlottersToModuleConfig
tuple size
Write out results.
size_type size() const
void BTagPerformanceAnalyzerMC::bookHistos ( const edm::ParameterSet pSet)
private

Definition at line 60 of file BTagPerformanceAnalyzerMC.cc.

References binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, binTagInfoPlottersToModuleConfig, TagInfoPlotterFactory::buildPlotter(), BTagDifferentialPlot::constETA, BTagDifferentialPlot::constPT, differentialPlots, etaRanges, finalize, getEtaPtBin(), jetTagInputTags, edm::InputTag::label(), makeDiffPlots_, mcPlots_, moduleConfig, ptRanges, setTDRStyle(), tagCorrelationInputTags, tagInfoInputTags, tiDataFormatType, and update.

Referenced by BTagPerformanceAnalyzerMC().

61 {
62  //
63  // Book all histograms.
64  //
65 
66  //if (update) {
67  //
68  // append the DQM file ... we should consider this experimental
69  // edm::Service<DQMStore>().operator->()->open(std::string((const char *)(inputFile)),"/");
70  // removed; DQM framework will take care
71  //}
72 
73  // parton p
74 // double pPartonMin = 0.0 ;
75 // double pPartonMax = 99999.9 ;
76 
77 
78  // iterate over ranges:
79  const int iEtaStart = -1 ; // this will be the inactive one
80  const int iEtaEnd = etaRanges.size() - 1 ;
81  const int iPtStart = -1 ; // this will be the inactive one
82  const int iPtEnd = ptRanges.size() - 1 ;
83  setTDRStyle();
84 
85  TagInfoPlotterFactory theFactory;
86 
87  for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin();
88  iModule != moduleConfig.end(); ++iModule) {
89 
90  const string& dataFormatType = iModule->exists("type") ?
91  iModule->getParameter<string>("type") :
92  "JetTag";
93  if (dataFormatType == "JetTag") {
94  const InputTag& moduleLabel = iModule->getParameter<InputTag>("label");
95  const string& folderName = iModule->getParameter<string>("folder");
96 
97  jetTagInputTags.push_back(moduleLabel);
98  binJetTagPlotters.push_back(vector<JetTagPlotter*>()) ;
99  // Contains plots for each bin of rapidity and pt.
100  vector<BTagDifferentialPlot*> * differentialPlotsConstantEta = new vector<BTagDifferentialPlot*> () ;
101  vector<BTagDifferentialPlot*> * differentialPlotsConstantPt = new vector<BTagDifferentialPlot*> () ;
102  if (finalize && mcPlots_ && makeDiffPlots_){
103  differentialPlots.push_back(vector<BTagDifferentialPlot*>());
104 
105  // the constant b-efficiency for the differential plots versus pt and eta
106  const double& effBConst =
107  iModule->getParameter<edm::ParameterSet>("parameters").getParameter<double>("effBConst");
108 
109  // the objects for the differential plots vs. eta,pt for
110  for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) {
111  BTagDifferentialPlot * etaConstDifferentialPlot = new BTagDifferentialPlot
112  (effBConst, BTagDifferentialPlot::constETA, folderName);
113  differentialPlotsConstantEta->push_back ( etaConstDifferentialPlot );
114  }
115 
116  for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) {
117  // differentialPlots for this pt bin
118  BTagDifferentialPlot * ptConstDifferentialPlot = new BTagDifferentialPlot
119  (effBConst, BTagDifferentialPlot::constPT, folderName);
120  differentialPlotsConstantPt->push_back ( ptConstDifferentialPlot );
121  }
122  }
123  // eta loop
124  for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) {
125  // pt loop
126  for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) {
127 
128  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
129 
130  // Instantiate the genertic b tag plotter
131  JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin,
132  iModule->getParameter<edm::ParameterSet>("parameters"),mcPlots_,update,finalize);
133  binJetTagPlotters.back().push_back ( jetTagPlotter ) ;
134 
135  // Add to the corresponding differential plotters
136  if (finalize && mcPlots_ && makeDiffPlots_){
137  (*differentialPlotsConstantEta)[iEta+1]->addBinPlotter ( jetTagPlotter ) ;
138  (*differentialPlotsConstantPt )[iPt+1] ->addBinPlotter ( jetTagPlotter ) ;
139  }
140  }
141  }
142  // the objects for the differential plots vs. eta, pt: collect all from constant eta and constant pt
143  if (finalize && mcPlots_ && makeDiffPlots_){
144  differentialPlots.back().reserve(differentialPlotsConstantEta->size()+differentialPlotsConstantPt->size()) ;
145  differentialPlots.back().insert(differentialPlots.back().end(), differentialPlotsConstantEta->begin(), differentialPlotsConstantEta->end());
146  differentialPlots.back().insert(differentialPlots.back().end(), differentialPlotsConstantPt->begin(), differentialPlotsConstantPt->end());
147 
148  edm::LogInfo("Info")
149  << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size();
150 
151  // the intermediate ones are no longer needed
152  delete differentialPlotsConstantEta ;
153  delete differentialPlotsConstantPt ;
154  }
155  } else if(dataFormatType == "TagCorrelation") {
156  const InputTag& label1 = iModule->getParameter<InputTag>("label1");
157  const InputTag& label2 = iModule->getParameter<InputTag>("label2");
158  tagCorrelationInputTags.push_back(std::pair<edm::InputTag, edm::InputTag>(label1, label2));
159  binTagCorrelationPlotters.push_back(vector<TagCorrelationPlotter*>());
160 
161  // eta loop
162  for ( int iEta = iEtaStart ; iEta != iEtaEnd ; ++iEta) {
163  // pt loop
164  for( int iPt = iPtStart ; iPt != iPtEnd ; ++iPt) {
165  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
166  // Instantiate the generic b tag correlation plotter
167  TagCorrelationPlotter* tagCorrelationPlotter = new TagCorrelationPlotter(label1.label(), label2.label(), etaPtBin,
168  iModule->getParameter<edm::ParameterSet>("parameters"),
169  mcPlots_, update);
170  binTagCorrelationPlotters.back().push_back(tagCorrelationPlotter);
171  }
172  }
173  } else {
174  // tag info retrievel is deferred (needs availability of EventSetup)
175  const InputTag& moduleLabel = iModule->getParameter<InputTag>("label");
176  const string& folderName = iModule->getParameter<string>("folder");
177 
178  tagInfoInputTags.push_back(vector<edm::InputTag>());
179  tiDataFormatType.push_back(dataFormatType);
180  binTagInfoPlotters.push_back(vector<BaseTagInfoPlotter*>()) ;
181  // eta loop
182  for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) {
183  // pt loop
184  for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) {
185  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
186 
187  // Instantiate the tagInfo plotter
188 
189  BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(),
190  etaPtBin, iModule->getParameter<edm::ParameterSet>("parameters"), folderName,
192  binTagInfoPlotters.back().push_back ( jetTagPlotter ) ;
193  binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin()));
194  }
195  }
196 
197  edm::LogInfo("Info")
198  << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size();
199  }
200  }
201 }
std::vector< std::pair< edm::InputTag, edm::InputTag > > tagCorrelationInputTags
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
std::vector< std::vector< BTagDifferentialPlot * > > differentialPlots
BaseTagInfoPlotter * buildPlotter(const std::string &dataFormatType, const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, const bool &update, const bool &mc, const bool &wf)
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
std::vector< edm::ParameterSet > moduleConfig
std::vector< std::vector< edm::InputTag > > tagInfoInputTags
EtaPtBin getEtaPtBin(const int &iEta, const int &iPt)
std::vector< std::string > tiDataFormatType
std::string const & label() const
Definition: InputTag.h:25
void setTDRStyle()
Definition: plotscripts.py:87
std::vector< edm::InputTag > jetTagInputTags
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
std::map< BaseTagInfoPlotter *, size_t > binTagInfoPlottersToModuleConfig
void BTagPerformanceAnalyzerMC::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 495 of file BTagPerformanceAnalyzerMC.cc.

References begin, binJetTagPlotters, binTagInfoPlotters, differentialPlots, epsBaseName, finalize, makeDiffPlots_, produceEps, producePs, psBaseName, and setTDRStyle().

496 {
497  if (!finalize) return;
498  setTDRStyle();
499  for (unsigned int iJetLabel = 0; iJetLabel != binJetTagPlotters.size(); ++iJetLabel) {
500  int plotterSize = binJetTagPlotters[iJetLabel].size();
501  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
502  binJetTagPlotters[iJetLabel][iPlotter]->finalize();
503  // binJetTagPlotters[iJetLabel][iPlotter]->write(allHisto);
504  if (producePs) (*binJetTagPlotters[iJetLabel][iPlotter]).psPlot(psBaseName);
505  if (produceEps) (*binJetTagPlotters[iJetLabel][iPlotter]).epsPlot(epsBaseName);
506  }
507 
508  if(makeDiffPlots_) {
509  for (vector<BTagDifferentialPlot *>::iterator iPlotter = differentialPlots[iJetLabel].begin();
510  iPlotter != differentialPlots[iJetLabel].end(); ++ iPlotter) {
511  (*iPlotter)->process();
512  if (producePs) (*iPlotter)->psPlot(psBaseName);
513  if (produceEps) (*iPlotter)->epsPlot(epsBaseName);
514  // (**iPlotter).write(allHisto);
515  }
516  }
517  }
518  for (vector<vector<BaseTagInfoPlotter*> >::iterator iJetLabel = binTagInfoPlotters.begin();
519  iJetLabel != binTagInfoPlotters.end(); ++iJetLabel) {
520  for (vector<BaseTagInfoPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter) {
521  (*iPlotter)->finalize();
522  // binTagInfoPlotters[iJetLabel][iPlotter]->write(allHisto);
523  if (producePs) (*iPlotter)->psPlot(psBaseName);
524  if (produceEps) (*iPlotter)->epsPlot(epsBaseName);
525  }
526  }
527 }
std::vector< std::vector< BTagDifferentialPlot * > > differentialPlots
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
void setTDRStyle()
Definition: plotscripts.py:87
#define begin
Definition: vmac.h:31
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
EtaPtBin BTagPerformanceAnalyzerMC::getEtaPtBin ( const int &  iEta,
const int &  iPt 
)
private

Definition at line 203 of file BTagPerformanceAnalyzerMC.cc.

References etaRanges, funct::false, ptRanges, and funct::true.

Referenced by bookHistos().

204 {
205  // DEFINE BTagBin:
206  bool etaActive_ , ptActive_;
207  double etaMin_, etaMax_, ptMin_, ptMax_ ;
208 
209  if ( iEta != -1 ) {
210  etaActive_ = true ;
211  etaMin_ = etaRanges[iEta] ;
212  etaMax_ = etaRanges[iEta+1] ;
213  }
214  else {
215  etaActive_ = false ;
216  etaMin_ = etaRanges[0] ;
217  etaMax_ = etaRanges[etaRanges.size() - 1] ;
218  }
219 
220  if ( iPt != -1 ) {
221  ptActive_ = true ;
222  ptMin_ = ptRanges[iPt] ;
223  ptMax_ = ptRanges[iPt+1] ;
224  }
225  else {
226  ptActive_ = false ;
227  ptMin_ = ptRanges[0] ;
228  ptMax_ = ptRanges[ptRanges.size() - 1] ;
229  }
230  return EtaPtBin(etaActive_ , etaMin_ , etaMax_ ,
231  ptActive_ , ptMin_ , ptMax_ );
232 }
bool BTagPerformanceAnalyzerMC::getJetWithFlavour ( edm::RefToBase< reco::Jet caloRef,
FlavourMap  flavours,
JetWithFlavour jetWithFlavour,
const edm::EventSetup es 
)
private

Definition at line 453 of file BTagPerformanceAnalyzerMC.cc.

References eventInitialized, i, edm::ProductID::id(), edm::RefToBase< T >::id(), edm::RefToBase< T >::isNull(), jetCorrector, jetMatcher, LogTrace, MatchJet::matchCollections(), edm::RefToBaseVector< T >::push_back(), CorrectJet::setEventSetup(), and edm::View< T >::size().

Referenced by analyze().

455 {
456 
457  edm::ProductID recProdId = jetRef.id();
458  edm::ProductID refProdId = (flavours.begin() == flavours.end())
459  ? recProdId
460  : flavours.begin()->first.id();
461 
462  if (!eventInitialized) {
464  if (recProdId != refProdId) {
466  for(FlavourMap::const_iterator iter = flavours.begin();
467  iter != flavours.end(); ++iter)
468  refJets.push_back(iter->first);
469  const edm::RefToBaseProd<Jet> recJetsProd(jetRef);
471  for(unsigned int i = 0; i < recJetsProd->size(); i++)
472  recJets.push_back(edm::RefToBase<Jet>(recJetsProd, i));
473  jetMatcher.matchCollections(refJets, recJets, es);
474  }
475  eventInitialized = true;
476  }
477 
478  if (recProdId != refProdId) {
479  jetRef = jetMatcher(jetRef);
480  if (jetRef.isNull())
481  return false;
482  }
483 
484  jetWithFlavour.first = jetCorrector(*jetRef);
485 
486  jetWithFlavour.second = reco::JetFlavour(jetWithFlavour.first.p4(), math::XYZPoint (0,0,0), flavours[jetRef]);
487 
488  LogTrace("Info") << "Found jet with flavour "<<jetWithFlavour.second.getFlavour()<<endl;
489  LogTrace("Info") << jetWithFlavour.first.p()<<" , "<< jetWithFlavour.first.pt()<<" - "
490  << jetWithFlavour.second.getLorentzVector().P()<<" , "<< jetWithFlavour.second.getLorentzVector().Pt()<<endl;
491 
492  return true;
493 }
int i
Definition: DBlmapReader.cc:9
void matchCollections(const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const edm::EventSetup &es)
match the collections
Definition: MatchJet.cc:53
void setEventSetup(const edm::EventSetup &es)
Definition: CorrectJet.h:23
#define LogTrace(id)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void push_back(const RefToBase< T > &)
ProductIndex id() const
Definition: ProductID.h:38

Member Data Documentation

bool BTagPerformanceAnalyzerMC::allHisto
private

Definition at line 83 of file BTagPerformanceAnalyzerMC.h.

std::vector< std::vector<JetTagPlotter*> > BTagPerformanceAnalyzerMC::binJetTagPlotters
private
std::vector< std::vector<TagCorrelationPlotter*> > BTagPerformanceAnalyzerMC::binTagCorrelationPlotters
private

Definition at line 90 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), bookHistos(), and ~BTagPerformanceAnalyzerMC().

std::vector< std::vector<BaseTagInfoPlotter*> > BTagPerformanceAnalyzerMC::binTagInfoPlotters
private
std::map<BaseTagInfoPlotter*, size_t> BTagPerformanceAnalyzerMC::binTagInfoPlottersToModuleConfig
private

Definition at line 99 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

std::vector< std::vector<BTagDifferentialPlot*> > BTagPerformanceAnalyzerMC::differentialPlots
private

Definition at line 96 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), endJob(), and ~BTagPerformanceAnalyzerMC().

bool BTagPerformanceAnalyzerMC::electronPlots
private

Definition at line 107 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and BTagPerformanceAnalyzerMC().

std::string BTagPerformanceAnalyzerMC::epsBaseName
private

Definition at line 82 of file BTagPerformanceAnalyzerMC.h.

Referenced by endJob().

std::vector<double> BTagPerformanceAnalyzerMC::etaRanges
private

Definition at line 80 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), and getEtaPtBin().

bool BTagPerformanceAnalyzerMC::eventInitialized
private

Definition at line 106 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and getJetWithFlavour().

bool BTagPerformanceAnalyzerMC::finalize
private

Definition at line 84 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), endJob(), and ~BTagPerformanceAnalyzerMC().

bool BTagPerformanceAnalyzerMC::finalizeOnly
private

Definition at line 85 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze().

std::string BTagPerformanceAnalyzerMC::inputFile
private

Definition at line 82 of file BTagPerformanceAnalyzerMC.h.

CorrectJet BTagPerformanceAnalyzerMC::jetCorrector
private

Definition at line 103 of file BTagPerformanceAnalyzerMC.h.

Referenced by getJetWithFlavour().

MatchJet BTagPerformanceAnalyzerMC::jetMatcher
private

Definition at line 104 of file BTagPerformanceAnalyzerMC.h.

Referenced by BTagPerformanceAnalyzerMC(), and getJetWithFlavour().

edm::InputTag BTagPerformanceAnalyzerMC::jetMCSrc
private

Definition at line 86 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze().

AcceptJet BTagPerformanceAnalyzerMC::jetSelector
private

Definition at line 79 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze().

std::vector<edm::InputTag> BTagPerformanceAnalyzerMC::jetTagInputTags
private

Definition at line 92 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

bool BTagPerformanceAnalyzerMC::makeDiffPlots_
private

Definition at line 101 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), endJob(), and ~BTagPerformanceAnalyzerMC().

bool BTagPerformanceAnalyzerMC::mcPlots_
private

Definition at line 101 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), and ~BTagPerformanceAnalyzerMC().

std::vector<edm::ParameterSet> BTagPerformanceAnalyzerMC::moduleConfig
private

Definition at line 98 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

bool BTagPerformanceAnalyzerMC::muonPlots
private

Definition at line 107 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and BTagPerformanceAnalyzerMC().

bool BTagPerformanceAnalyzerMC::partonKinematics
private

Definition at line 77 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze().

bool BTagPerformanceAnalyzerMC::produceEps
private

Definition at line 81 of file BTagPerformanceAnalyzerMC.h.

Referenced by endJob().

bool BTagPerformanceAnalyzerMC::producePs
private

Definition at line 81 of file BTagPerformanceAnalyzerMC.h.

Referenced by endJob().

std::string BTagPerformanceAnalyzerMC::psBaseName
private

Definition at line 82 of file BTagPerformanceAnalyzerMC.h.

Referenced by endJob().

double BTagPerformanceAnalyzerMC::ptPartonMax
private

Definition at line 78 of file BTagPerformanceAnalyzerMC.h.

double BTagPerformanceAnalyzerMC::ptPartonMin
private

Definition at line 78 of file BTagPerformanceAnalyzerMC.h.

std::vector<double> BTagPerformanceAnalyzerMC::ptRanges
private

Definition at line 80 of file BTagPerformanceAnalyzerMC.h.

Referenced by bookHistos(), and getEtaPtBin().

edm::InputTag BTagPerformanceAnalyzerMC::slInfoTag
private

Definition at line 87 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze().

std::vector< std::pair<edm::InputTag, edm::InputTag> > BTagPerformanceAnalyzerMC::tagCorrelationInputTags
private

Definition at line 93 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

std::vector< std::vector<edm::InputTag> > BTagPerformanceAnalyzerMC::tagInfoInputTags
private

Definition at line 94 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

bool BTagPerformanceAnalyzerMC::tauPlots
private

Definition at line 107 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and BTagPerformanceAnalyzerMC().

std::vector<std::string> BTagPerformanceAnalyzerMC::tiDataFormatType
private

Definition at line 76 of file BTagPerformanceAnalyzerMC.h.

Referenced by analyze(), and bookHistos().

bool BTagPerformanceAnalyzerMC::update
private

Definition at line 83 of file BTagPerformanceAnalyzerMC.h.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), python.seqvaluedict.seqdict::__setslice__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), bookHistos(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.seqvaluedict.seqdict::extend(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().