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 Member Functions | Private Attributes
BTagPerformanceAnalyzerOnData Class Reference

#include <BTagPerformanceAnalyzerOnData.h>

Inheritance diagram for BTagPerformanceAnalyzerOnData:
DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  JetRefCompare
 

Public Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 BTagPerformanceAnalyzerOnData (const edm::ParameterSet &pSet)
 
 ~BTagPerformanceAnalyzerOnData ()
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
EtaPtBin getEtaPtBin (const int &iEta, const int &iPt)
 

Private Attributes

std::vector< std::vector
< JetTagPlotter * > > 
binJetTagPlotters
 
std::vector< std::vector
< TagCorrelationPlotter * > > 
binTagCorrelationPlotters
 
std::vector< std::vector
< BaseTagInfoPlotter * > > 
binTagInfoPlotters
 
std::map< BaseTagInfoPlotter
*, size_t > 
binTagInfoPlottersToModuleConfig
 
bool doJEC
 
std::vector< double > etaRanges
 
edm::EDGetTokenT
< GenEventInfoProduct
genToken
 
edm::EDGetTokenT
< reco::JetCorrector
jecDataToken
 
edm::EDGetTokenT
< reco::JetCorrector
jecMCToken
 
AcceptJet jetSelector
 
std::vector< edm::InputTagjetTagInputTags
 
std::vector< edm::EDGetTokenT
< reco::JetTagCollection > > 
jetTagToken
 
std::vector< edm::ParameterSetmoduleConfig
 
std::vector< double > ptRanges
 
edm::InputTag slInfoTag
 
edm::EDGetTokenT
< reco::SoftLeptonTagInfoCollection
slInfoToken
 
std::vector< std::pair
< edm::InputTag, edm::InputTag > > 
tagCorrelationInputTags
 
std::vector< std::pair
< edm::EDGetTokenT
< reco::JetTagCollection >
, edm::EDGetTokenT
< reco::JetTagCollection > > > 
tagCorrelationToken
 
std::vector< std::vector
< edm::InputTag > > 
tagInfoInputTags
 
std::vector< std::vector
< edm::EDGetTokenT< edm::View
< reco::BaseTagInfo > > > > 
tagInfoToken
 
std::vector< std::string > tiDataFormatType
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Top level steering routine for b tag performance analysis.

Definition at line 20 of file BTagPerformanceAnalyzerOnData.h.

Constructor & Destructor Documentation

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

Definition at line 10 of file BTagPerformanceAnalyzerOnData.cc.

References binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, edm::EDConsumerBase::consumes(), genToken, edm::ParameterSet::getParameter(), HLT_25ns14e33_v1_cff::InputTag, jecDataToken, jecMCToken, jetTagInputTags, jetTagToken, moduleConfig, slInfoToken, tagCorrelationInputTags, tagCorrelationToken, tagInfoInputTags, tagInfoToken, and tiDataFormatType.

10  :
12  pSet.getParameter<double>("etaMin"),
13  pSet.getParameter<double>("etaMax"),
14  pSet.getParameter<double>("ptRecJetMin"),
15  pSet.getParameter<double>("ptRecJetMax"),
16  0.0, 99999.0,
17  pSet.getParameter<double>("ratioMin"),
18  pSet.getParameter<double>("ratioMax"),
19  pSet.getParameter<bool>( "doJetID" )
20  ),
21  etaRanges(pSet.getParameter< vector<double> >("etaRanges")),
22  ptRanges(pSet.getParameter< vector<double> >("ptRanges")),
23  doJEC(pSet.getParameter<bool>( "doJEC" )),
24  moduleConfig(pSet.getParameter< vector<edm::ParameterSet> >("tagConfig"))
25 {
26  genToken = mayConsume<GenEventInfoProduct>(edm::InputTag("generator"));
27  slInfoToken = consumes<SoftLeptonTagInfoCollection>(pSet.getParameter<InputTag>("softLeptonInfo"));
28  jecMCToken = mayConsume<JetCorrector>(pSet.getParameter<edm::InputTag>( "JECsourceMC" ));
29  jecDataToken = consumes<JetCorrector>(pSet.getParameter<edm::InputTag>( "JECsourceData" ));
30  for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin();
31  iModule != moduleConfig.end(); ++iModule) {
32 
33  const string& dataFormatType = iModule->exists("type") ?
34  iModule->getParameter<string>("type") :
35  "JetTag";
36  if (dataFormatType == "JetTag") {
37  const InputTag& moduleLabel = iModule->getParameter<InputTag>("label");
38  jetTagInputTags.push_back(moduleLabel);
39  binJetTagPlotters.push_back(vector<JetTagPlotter*>()) ;
40  jetTagToken.push_back(consumes<JetTagCollection>(moduleLabel));
41  }
42  else if(dataFormatType == "TagCorrelation") {
43  const InputTag& label1 = iModule->getParameter<InputTag>("label1");
44  const InputTag& label2 = iModule->getParameter<InputTag>("label2");
45  tagCorrelationInputTags.push_back(std::pair<edm::InputTag, edm::InputTag>(label1, label2));
46  binTagCorrelationPlotters.push_back(vector<TagCorrelationPlotter*>());
47  tagCorrelationToken.push_back(std::pair< edm::EDGetTokenT<reco::JetTagCollection>, edm::EDGetTokenT<reco::JetTagCollection> >(consumes<JetTagCollection>(label1), consumes<JetTagCollection>(label2)));
48  }
49  else {
50  tagInfoInputTags.push_back(vector<edm::InputTag>());
51  tiDataFormatType.push_back(dataFormatType);
52  binTagInfoPlotters.push_back(vector<BaseTagInfoPlotter*>()) ;
53  std::vector< edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > tokens;
54  if(dataFormatType == "GenericMVA") {
55  const InputTag& ipinfo = iModule->getParameter<InputTag>("ipTagInfos");
56  const InputTag& svinfo = iModule->getParameter<InputTag>("svTagInfos");
57  tokens.push_back(consumes< View<BaseTagInfo> >(ipinfo));
58  tokens.push_back(consumes< View<BaseTagInfo> >(svinfo));
59  }
60  else {
61  const InputTag& moduleLabel = iModule->getParameter<InputTag>("label");
62  tokens.push_back(consumes< View<BaseTagInfo> >(moduleLabel));
63  }
64  tagInfoToken.push_back(tokens);
65  }
66  }
67 }
T getParameter(std::string const &) const
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
std::vector< edm::EDGetTokenT< reco::JetTagCollection > > jetTagToken
edm::EDGetTokenT< reco::JetCorrector > jecMCToken
std::vector< std::string > tiDataFormatType
std::vector< std::pair< edm::EDGetTokenT< reco::JetTagCollection >, edm::EDGetTokenT< reco::JetTagCollection > > > tagCorrelationToken
std::vector< std::pair< edm::InputTag, edm::InputTag > > tagCorrelationInputTags
std::vector< std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > > tagInfoToken
edm::EDGetTokenT< GenEventInfoProduct > genToken
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::SoftLeptonTagInfoCollection > slInfoToken
std::vector< std::vector< edm::InputTag > > tagInfoInputTags
std::vector< edm::ParameterSet > moduleConfig
std::vector< edm::InputTag > jetTagInputTags
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
edm::EDGetTokenT< reco::JetCorrector > jecDataToken
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
BTagPerformanceAnalyzerOnData::~BTagPerformanceAnalyzerOnData ( )

Definition at line 185 of file BTagPerformanceAnalyzerOnData.cc.

References binJetTagPlotters, binTagCorrelationPlotters, and binTagInfoPlotters.

186 {
187  for (unsigned int iJetLabel = 0; iJetLabel != binJetTagPlotters.size(); ++iJetLabel) {
188  int plotterSize = binJetTagPlotters[iJetLabel].size();
189  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
190  delete binJetTagPlotters[iJetLabel][iPlotter];
191  }
192  }
193 
194  for (vector<vector<TagCorrelationPlotter*> >::iterator iJetLabel = binTagCorrelationPlotters.begin();
195  iJetLabel != binTagCorrelationPlotters.end(); ++iJetLabel)
196  for(vector<TagCorrelationPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
197  delete *iPlotter;
198 
199  for (unsigned int iJetLabel = 0; iJetLabel != binTagInfoPlotters.size(); ++iJetLabel) {
200  int plotterSize = binTagInfoPlotters[iJetLabel].size();
201  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
202  delete binTagInfoPlotters[iJetLabel][iPlotter];
203  }
204  }
205 }
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters

Member Function Documentation

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 207 of file BTagPerformanceAnalyzerOnData.cc.

References edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::begin(), binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, binTagInfoPlottersToModuleConfig, reco::JetCorrector::correction(), mvaPFMET_cff::corrector, doJEC, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::end(), Exception, genToken, edm::Event::getByToken(), edm::ProductID::id(), beam_dqm_sourceclient-live_cfg::inputTag, edm::HandleBase::isValid(), patTestJEC_cfi::jec, jecDataToken, jecMCToken, reco::BaseTagInfo::jet(), jetSelector, jetTagInputTags, jetTagToken, HLT_25ns14e33_v1_cff::labels, LogDebug, moduleConfig, edm::Handle< T >::product(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size(), findQualityFiles::size, slInfoToken, tagCorrelationInputTags, tagCorrelationToken, tagInfoInputTags, BaseTagInfoPlotter::tagInfoRequirements(), tagInfoToken, and tiDataFormatType.

208 {
209 
211  iEvent.getByToken(slInfoToken, infoHandle);
212 
213  //Get JEC
214  const JetCorrector* corrector = 0;
215  if(doJEC) {
216  edm::Handle<GenEventInfoProduct> genInfoHandle; //check if data or MC
217  iEvent.getByToken(genToken, genInfoHandle);
218  edm::Handle<JetCorrector> corrHandle;
219  if( !genInfoHandle.isValid() ) iEvent.getByToken( jecDataToken, corrHandle);
220  else iEvent.getByToken( jecMCToken, corrHandle);
221  corrector = corrHandle.product();
222  }
223  //
224 
225 // Look first at the jetTags
226 
227  for (unsigned int iJetLabel = 0; iJetLabel != jetTagInputTags.size(); ++iJetLabel) {
229  iEvent.getByToken(jetTagToken[iJetLabel], tagHandle);
230  //
231  // insert check on the presence of the collections
232  //
233 
234  if (!tagHandle.isValid()){
235  edm::LogWarning("BTagPerformanceAnalyzerOnData")<<" Collection "<<jetTagInputTags[iJetLabel]<<" not present. Skipping it for this event.";
236  continue;
237  }
238 
239  const reco::JetTagCollection & tagColl = *(tagHandle.product());
240  LogDebug("Info") << "Found " << tagColl.size() << " B candidates in collection " << jetTagInputTags[iJetLabel];
241 
242  int plotterSize = binJetTagPlotters[iJetLabel].size();
243  for (JetTagCollection::const_iterator tagI = tagColl.begin();
244  tagI != tagColl.end(); ++tagI) {
245 
246  //JEC
247  reco::Jet correctedJet = *(tagI->first);
248  double jec = 1.0;
249  if(doJEC && corrector) {
250  jec = corrector->correction(*(tagI->first));
251  }
252  //
253 
254  if (!jetSelector(*(tagI->first), -1, infoHandle, jec))
255  continue;
256 
257  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
258  bool inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*tagI->first, jec);
259  // Fill histograms if in desired pt/rapidity bin.
260  if (inBin)
261  binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(*tagI, jec, -1);
262  }
263  }
264  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
265  binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag();
266  }
267  }
268 
269 // Now look at Tag Correlations
270  for (unsigned int iJetLabel = 0; iJetLabel != tagCorrelationInputTags.size(); ++iJetLabel) {
271  const std::pair< edm::EDGetTokenT<reco::JetTagCollection>, edm::EDGetTokenT<reco::JetTagCollection> >& inputTokens = tagCorrelationToken[iJetLabel];
273  iEvent.getByToken(inputTokens.first, tagHandle1);
274  const reco::JetTagCollection& tagColl1 = *(tagHandle1.product());
275 
277  iEvent.getByToken(inputTokens.second, tagHandle2);
278  const reco::JetTagCollection& tagColl2 = *(tagHandle2.product());
279 
280  int plotterSize = binTagCorrelationPlotters[iJetLabel].size();
281  for (JetTagCollection::const_iterator tagI = tagColl1.begin(); tagI != tagColl1.end(); ++tagI) {
282  //JEC
283  reco::Jet correctedJet = *(tagI->first);
284  double jec = 1.0;
285  if(doJEC && corrector) {
286  jec = corrector->correction(*(tagI->first));
287  }
288  //
289 
290  if (!jetSelector(*(tagI->first), -1, infoHandle, jec))
291  continue;
292 
293  for(int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
294  bool inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*(tagI->first), jec);
295 
296  if(inBin)
297  {
298  double discr2 = tagColl2[tagI->first];
299  binTagCorrelationPlotters[iJetLabel][iPlotter]->analyzeTags(tagI->second, discr2, -1);
300  }
301  }
302  }
303  }
304 // Now look at the TagInfos
305 
306  for (unsigned int iJetLabel = 0; iJetLabel != tiDataFormatType.size(); ++iJetLabel) {
307  int plotterSize = binTagInfoPlotters[iJetLabel].size();
308  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
309  binTagInfoPlotters[iJetLabel][iPlotter]->setEventSetup(iSetup);
310 
311  vector<edm::InputTag> & inputTags = tagInfoInputTags[iJetLabel];
312  if (inputTags.empty()) {
313  // deferred retrieval of input tags
314  BaseTagInfoPlotter *firstPlotter = binTagInfoPlotters[iJetLabel][0];
315  int iModule = binTagInfoPlottersToModuleConfig[firstPlotter];
316  vector<string> labels = firstPlotter->tagInfoRequirements();
317  if (labels.empty())
318  labels.push_back("label");
319  for (vector<string>::const_iterator iLabels = labels.begin();
320  iLabels != labels.end(); ++iLabels) {
322  moduleConfig[iModule].getParameter<InputTag>(*iLabels);
323  inputTags.push_back(inputTag);
324  }
325  }
326 
327  unsigned int nInputTags = inputTags.size();
328  vector< edm::Handle< View<BaseTagInfo> > > tagInfoHandles(nInputTags);
329  edm::ProductID jetProductID;
330  unsigned int nTagInfos = 0;
331  vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > & tokens = tagInfoToken[iJetLabel];
332  if(nInputTags!=tokens.size()) throw cms::Exception("Configuration") << "Different number of Tag Infos than expected" << endl;
333  for (unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) {
334  edm::Handle< View<BaseTagInfo> > & tagInfoHandle = tagInfoHandles[iInputTags];
335  iEvent.getByToken(tokens[iInputTags], tagInfoHandle);
336  //
337  // protect against missing products
338  //
339  if (tagInfoHandle.isValid() == false){
340  edm::LogWarning("BTagPerformanceAnalyzerOnData")<<" Collection "<<inputTags[iInputTags]<<" not present. Skipping it for this event.";
341  continue;
342  }
343 
344 
345  unsigned int size = tagInfoHandle->size();
346  LogDebug("Info") << "Found " << size << " B candidates in collection " << inputTags[iInputTags];
347  edm::ProductID thisProductID = (size > 0) ? (*tagInfoHandle)[0].jet().id() : edm::ProductID();
348  if (iInputTags == 0) {
349  jetProductID = thisProductID;
350  nTagInfos = size;
351  } else if (jetProductID != thisProductID)
352  throw cms::Exception("Configuration") << "TagInfos are referencing a different jet collection." << endl;
353  else if (nTagInfos != size)
354  throw cms::Exception("Configuration") << "TagInfo collections are having a different size." << endl;
355  }
356 
357  for (unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
358  vector<const BaseTagInfo*> baseTagInfos(nInputTags);
359  edm::RefToBase<Jet> jetRef;
360  for (unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
361  const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
362  if (iTagInfo == 0)
363  jetRef = baseTagInfo.jet();
364  else if (baseTagInfo.jet() != jetRef)
365  throw cms::Exception("Configuration") << "TagInfos pointing to different jets." << endl;
366  baseTagInfos[iTagInfo] = &baseTagInfo;
367  }
368 
369  //JEC
370  reco::Jet correctedJet = *(jetRef);
371  double jec = 1.0;
372  if(doJEC && corrector) {
373  jec = corrector->correction(*(jetRef));
374  }
375  //
376 
377  if (!jetSelector(*jetRef, -1, infoHandle, jec))
378  continue;
379 
380  for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
381  bool inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec);
382  // Fill histograms if in desired pt/rapidity bin.
383  if (inBin)
384  binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec, -1);
385  }
386  }
387  }
388 }
#define LogDebug(id)
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
std::vector< edm::EDGetTokenT< reco::JetTagCollection > > jetTagToken
std::map< BaseTagInfoPlotter *, size_t > binTagInfoPlottersToModuleConfig
transient_vector_type::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< reco::JetCorrector > jecMCToken
Base class for all types of Jets.
Definition: Jet.h:20
std::vector< std::string > tiDataFormatType
std::vector< std::pair< edm::EDGetTokenT< reco::JetTagCollection >, edm::EDGetTokenT< reco::JetTagCollection > > > tagCorrelationToken
const_iterator end() const
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:47
std::vector< std::pair< edm::InputTag, edm::InputTag > > tagCorrelationInputTags
std::vector< std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > > tagInfoToken
edm::EDGetTokenT< GenEventInfoProduct > genToken
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: BaseTagInfo.h:24
tuple corrector
Definition: mvaPFMET_cff.py:86
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< reco::SoftLeptonTagInfoCollection > slInfoToken
std::vector< std::vector< edm::InputTag > > tagInfoInputTags
virtual std::vector< std::string > tagInfoRequirements() const
T const * product() const
Definition: Handle.h:81
std::vector< edm::ParameterSet > moduleConfig
std::vector< edm::InputTag > jetTagInputTags
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
edm::EDGetTokenT< reco::JetCorrector > jecDataToken
ProductIndex id() const
Definition: ProductID.h:38
const_iterator begin() const
tuple size
Write out results.
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
size_type size() const
void BTagPerformanceAnalyzerOnData::bookHistograms ( DQMStore::IBooker ibook,
edm::Run const &  run,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Implements DQMEDAnalyzer.

Definition at line 69 of file BTagPerformanceAnalyzerOnData.cc.

References binJetTagPlotters, binTagCorrelationPlotters, binTagInfoPlotters, binTagInfoPlottersToModuleConfig, TagInfoPlotterFactory::buildPlotter(), etaRanges, getEtaPtBin(), edm::InputTag::label(), moduleConfig, ptRanges, and setTDRStyle().

70 {
71  //
72  // Book all histograms.
73  //
74 
75  // iterate over ranges:
76  const int iEtaStart = -1 ; // this will be the inactive one
77  const int iEtaEnd = etaRanges.size() - 1 ;
78  const int iPtStart = -1 ; // this will be the inactive one
79  const int iPtEnd = ptRanges.size() - 1 ;
80  setTDRStyle();
81 
82  TagInfoPlotterFactory theFactory;
83  int iTag = -1; int iTagCorr = -1; int iInfoTag = -1;
84  for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin();
85  iModule != moduleConfig.end(); ++iModule) {
86 
87  const string& dataFormatType = iModule->exists("type") ?
88  iModule->getParameter<string>("type") :
89  "JetTag";
90  if (dataFormatType == "JetTag") {
91  iTag++;
92  const string& folderName = iModule->getParameter<string>("folder");
93 
94  // eta loop
95  for ( int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta ) {
96  // pt loop
97  for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) {
98 
99  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
100 
101  // Instantiate the genertic b tag plotter
102  JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin,
103  iModule->getParameter<edm::ParameterSet>("parameters"), 0, false, ibook);
104  binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ;
105 
106  }
107  }
108 
109  } else if(dataFormatType == "TagCorrelation") {
110  iTagCorr++;
111  const InputTag& label1 = iModule->getParameter<InputTag>("label1");
112  const InputTag& label2 = iModule->getParameter<InputTag>("label2");
113 
114  // eta loop
115  for ( int iEta = iEtaStart ; iEta != iEtaEnd ; ++iEta) {
116  // pt loop
117  for( int iPt = iPtStart ; iPt != iPtEnd ; ++iPt) {
118  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
119  // Instantiate the generic b tag correlation plotter
120  TagCorrelationPlotter* tagCorrelationPlotter = new TagCorrelationPlotter(label1.label(), label2.label(), etaPtBin,
121  iModule->getParameter<edm::ParameterSet>("parameters"),
122  0, ibook);
123  binTagCorrelationPlotters.at(iTagCorr).push_back(tagCorrelationPlotter);
124  }
125  }
126  } else {
127  iInfoTag++;
128  // tag info retrievel is deferred (needs availability of EventSetup)
129  const InputTag& moduleLabel = iModule->getParameter<InputTag>("label");
130  const string& folderName = iModule->getParameter<string>("folder");
131 
132  // eta loop
133  for ( int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta ) {
134  // pt loop
135  for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) {
136  const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt);
137 
138  // Instantiate the tagInfo plotter
139 
140  BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(),
141  etaPtBin, iModule->getParameter<edm::ParameterSet>("parameters"), folderName,
142  0, false, ibook);
143  binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ;
144  binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin()));
145  }
146  }
147 
148  }
149  }
150 
151 
152 }
BaseTagInfoPlotter * buildPlotter(const std::string &dataFormatType, const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, const unsigned int &mc, const bool &wf, DQMStore::IBooker &ibook)
std::vector< std::vector< JetTagPlotter * > > binJetTagPlotters
std::map< BaseTagInfoPlotter *, size_t > binTagInfoPlottersToModuleConfig
std::vector< edm::ParameterSet > moduleConfig
EtaPtBin getEtaPtBin(const int &iEta, const int &iPt)
std::string const & label() const
Definition: InputTag.h:43
std::vector< std::vector< TagCorrelationPlotter * > > binTagCorrelationPlotters
void setTDRStyle()
Definition: plotscripts.py:87
std::vector< std::vector< BaseTagInfoPlotter * > > binTagInfoPlotters
EtaPtBin BTagPerformanceAnalyzerOnData::getEtaPtBin ( const int &  iEta,
const int &  iPt 
)
private

Definition at line 154 of file BTagPerformanceAnalyzerOnData.cc.

References histoStyle::EtaPtBin, etaRanges, edm::false, ptRanges, and funct::true.

Referenced by bookHistograms().

155 {
156  // DEFINE BTagBin:
157  bool etaActive_ , ptActive_;
158  double etaMin_, etaMax_, ptMin_, ptMax_ ;
159 
160  if ( iEta != -1 ) {
161  etaActive_ = true ;
162  etaMin_ = etaRanges[iEta] ;
163  etaMax_ = etaRanges[iEta+1] ;
164  }
165  else {
166  etaActive_ = false ;
167  etaMin_ = etaRanges[0] ;
168  etaMax_ = etaRanges[etaRanges.size() - 1] ;
169  }
170 
171  if ( iPt != -1 ) {
172  ptActive_ = true ;
173  ptMin_ = ptRanges[iPt] ;
174  ptMax_ = ptRanges[iPt+1] ;
175  }
176  else {
177  ptActive_ = false ;
178  ptMin_ = ptRanges[0] ;
179  ptMax_ = ptRanges[ptRanges.size() - 1] ;
180  }
181  return EtaPtBin(etaActive_ , etaMin_ , etaMax_ ,
182  ptActive_ , ptMin_ , ptMax_ );
183 }
list EtaPtBin
Definition: histoStyle.py:59
volatile std::atomic< bool > shutdown_flag false

Member Data Documentation

std::vector< std::vector<JetTagPlotter*> > BTagPerformanceAnalyzerOnData::binJetTagPlotters
private
std::vector< std::vector<TagCorrelationPlotter*> > BTagPerformanceAnalyzerOnData::binTagCorrelationPlotters
private
std::vector< std::vector<BaseTagInfoPlotter*> > BTagPerformanceAnalyzerOnData::binTagInfoPlotters
private
std::map<BaseTagInfoPlotter*, size_t> BTagPerformanceAnalyzerOnData::binTagInfoPlottersToModuleConfig
private

Definition at line 57 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and bookHistograms().

bool BTagPerformanceAnalyzerOnData::doJEC
private

Definition at line 46 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze().

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

Definition at line 45 of file BTagPerformanceAnalyzerOnData.h.

Referenced by bookHistograms(), and getEtaPtBin().

edm::EDGetTokenT<GenEventInfoProduct> BTagPerformanceAnalyzerOnData::genToken
private

Definition at line 62 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

edm::EDGetTokenT<reco::JetCorrector> BTagPerformanceAnalyzerOnData::jecDataToken
private

Definition at line 61 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

edm::EDGetTokenT<reco::JetCorrector> BTagPerformanceAnalyzerOnData::jecMCToken
private

Definition at line 60 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

AcceptJet BTagPerformanceAnalyzerOnData::jetSelector
private

Definition at line 44 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze().

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

Definition at line 52 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

std::vector< edm::EDGetTokenT<reco::JetTagCollection> > BTagPerformanceAnalyzerOnData::jetTagToken
private

Definition at line 64 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

std::vector<edm::ParameterSet> BTagPerformanceAnalyzerOnData::moduleConfig
private
std::vector<double> BTagPerformanceAnalyzerOnData::ptRanges
private

Definition at line 45 of file BTagPerformanceAnalyzerOnData.h.

Referenced by bookHistograms(), and getEtaPtBin().

edm::InputTag BTagPerformanceAnalyzerOnData::slInfoTag
private

Definition at line 47 of file BTagPerformanceAnalyzerOnData.h.

edm::EDGetTokenT<reco::SoftLeptonTagInfoCollection> BTagPerformanceAnalyzerOnData::slInfoToken
private

Definition at line 63 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

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

Definition at line 53 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

std::vector< std::pair<edm::EDGetTokenT<reco::JetTagCollection>, edm::EDGetTokenT<reco::JetTagCollection> > > BTagPerformanceAnalyzerOnData::tagCorrelationToken
private

Definition at line 65 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

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

Definition at line 54 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

std::vector<std::vector <edm::EDGetTokenT<edm::View<reco::BaseTagInfo> > > > BTagPerformanceAnalyzerOnData::tagInfoToken
private

Definition at line 66 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().

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

Definition at line 43 of file BTagPerformanceAnalyzerOnData.h.

Referenced by analyze(), and BTagPerformanceAnalyzerOnData().