CMS 3D CMS Logo

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

#include <HLTVertexPerformanceAnalyzer.h>

Inheritance diagram for HLTVertexPerformanceAnalyzer:
thread_unsafe::DQMEDAnalyzer edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void dqmBeginRun (const edm::Run &iRun, const edm::EventSetup &iSetup)
 
 HLTVertexPerformanceAnalyzer (const edm::ParameterSet &)
 
 ~HLTVertexPerformanceAnalyzer ()
 
- Public Member Functions inherited from thread_unsafe::DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
 DQMEDAnalyzer (void)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 

Private Attributes

std::vector< bool > _isfoundHLTs
 
std::vector< std::string > folders
 
std::vector< std::map
< std::string, MonitorElement * > > 
H1_
 
HLTConfigProvider hltConfigProvider_
 
std::vector< int > hltPathIndexs_
 
std::vector< std::string > hltPathNames_
 
edm::EDGetTokenT< TriggerResultshlTriggerResults_
 
std::string hlTriggerResults_Label
 
edm::EDConsumerBase::Labels label
 
edm::EDGetTokenT< std::vector
< SimVertex > > 
simVertexCollection_
 
bool triggerConfChanged_
 
std::vector< edm::EDGetTokenT
< reco::VertexCollection > > 
VertexCollection_
 
std::vector< std::string > VertexCollection_Label
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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::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

Code used to produce DQM validation plots for b-tag at HLT. It plots the distribution of recoVertex.z() - simVertex.z() of the primary vertex.

Definition at line 35 of file HLTVertexPerformanceAnalyzer.h.

Constructor & Destructor Documentation

HLTVertexPerformanceAnalyzer::HLTVertexPerformanceAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 3 of file HLTVertexPerformanceAnalyzer.cc.

References edm::ParameterSet::getParameter(), hlTriggerResults_, GlobalPosition_Frontier_DevDB_cff::tag, edm::vector_transform(), and VertexCollection_.

4 {
5  hlTriggerResults_ = consumes<TriggerResults>(iConfig.getParameter<InputTag> ("TriggerResults"));
6  VertexCollection_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "Vertex" ), [this](edm::InputTag const & tag){return mayConsume< reco::VertexCollection>(tag);});
7  hltPathNames_ = iConfig.getParameter< std::vector<std::string> > ("HLTPathNames");
8  simVertexCollection_ = consumes<std::vector<SimVertex> >(edm::InputTag("g4SimHits"));
9 
10  EDConsumerBase::labelsForToken(hlTriggerResults_,label);
12 
13  for(unsigned int i=0; i<VertexCollection_.size() ; i++){
14  EDConsumerBase::labelsForToken(VertexCollection_[i],label);
16  }
17 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< std::vector< SimVertex > > simVertexCollection_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::EDGetTokenT< TriggerResults > hlTriggerResults_
std::vector< std::string > VertexCollection_Label
std::vector< std::string > hltPathNames_
std::vector< edm::EDGetTokenT< reco::VertexCollection > > VertexCollection_
HLTVertexPerformanceAnalyzer::~HLTVertexPerformanceAnalyzer ( )

Definition at line 20 of file HLTVertexPerformanceAnalyzer.cc.

21 {
22 }

Member Function Documentation

void HLTVertexPerformanceAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 59 of file HLTVertexPerformanceAnalyzer.cc.

References _isfoundHLTs, coll, HcalObjRepresent::Fill(), edm::Event::getByToken(), H1_, hltPathIndexs_, hltPathNames_, hlTriggerResults_, hlTriggerResults_Label, edm::errors::LogicError, CoreSimVertex::position(), cms::Exception::raise(), simVertexCollection_, triggerResults, relativeConstraints::value, VertexCollection_, and VertexCollection_Label.

60 {
61  bool trigRes=false;
62  using namespace edm;
63 
64  //get triggerResults
65  Handle<TriggerResults> TriggerResulsHandler;
67  if ( hlTriggerResults_Label == "" || hlTriggerResults_Label == "NULL" ) {
68  excp << "TriggerResults ==> Empty";
69  excp.raise();
70  }
71  try {
72  iEvent.getByToken(hlTriggerResults_, TriggerResulsHandler);
73  if (TriggerResulsHandler.isValid()) trigRes=true;
74  } catch (...) { }
75  if ( !trigRes ) { excp << "TriggerResults ==> not readable"; excp.raise(); }
76  const TriggerResults & triggerResults = *(TriggerResulsHandler.product());
77 
78  //get simVertex
79  float simPV=0;
80 
81  Handle<std::vector<SimVertex> > simVertexCollection;
82 
83  try {
84  iEvent.getByToken(simVertexCollection_, simVertexCollection);
85  const SimVertex simPVh = *(simVertexCollection->begin());
86  simPV=simPVh.position().z();
87  }
88  catch (...) {}
89 
90  //fill the DQM plot
91  Handle<VertexCollection> VertexHandler;
92  for (unsigned int ind=0; ind<hltPathNames_.size();ind++) {
93  for (unsigned int coll=0; coll<VertexCollection_.size();coll++) {
94  bool VertexOK=false;
95  if ( !_isfoundHLTs[ind]) continue; //if the hltPath is not in the event, skip the event
96  if ( !triggerResults.accept(hltPathIndexs_[ind]) ) continue; //if the hltPath was not accepted skip the event
97 
98  //get the recoVertex
99  if (VertexCollection_Label.at(coll) != "" && VertexCollection_Label.at(coll) != "NULL" )
100  {
101  try {
102  iEvent.getByToken(VertexCollection_.at(coll), VertexHandler);
103  if (VertexHandler.isValid()) VertexOK=true;
104  } catch (...) { }
105  }
106 
107  //calculate the variable (RecoVertex - SimVertex)
108  float value=VertexHandler->begin()->z()-simPV;
109 
110  //if value is over/under flow, assign the extreme value
111  float maxValue=H1_.at(ind)["Vertex_"+VertexCollection_Label.at(coll)]->getTH1F()->GetXaxis()->GetXmax();
112  if(value>maxValue) value=maxValue-0.0001;
113  if(value<-maxValue) value=-maxValue+0.0001;
114 
115  //fill the histo
116  if (VertexOK) H1_.at(ind)["Vertex_"+VertexCollection_Label.at(coll)] -> Fill(value);
117  }// for on VertexCollection_
118  }//for on hltPathNames_
119 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
edm::EDGetTokenT< std::vector< SimVertex > > simVertexCollection_
edm::EDGetTokenT< TriggerResults > hlTriggerResults_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:26
static std::string const triggerResults
Definition: EdmProvDump.cc:41
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::vector< std::string > VertexCollection_Label
std::vector< std::string > hltPathNames_
std::vector< edm::EDGetTokenT< reco::VertexCollection > > VertexCollection_
std::vector< std::map< std::string, MonitorElement * > > H1_
void HLTVertexPerformanceAnalyzer::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements thread_unsafe::DQMEDAnalyzer.

Definition at line 122 of file HLTVertexPerformanceAnalyzer.cc.

References DQMStore::IBooker::book1D(), coll, H1_, hltPathNames_, DQMStore::IBooker::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, VertexCollection_, and VertexCollection_Label.

123 {
124  //book the DQM plots
125  using namespace std;
126  std::string dqmFolder;
127  for (unsigned int ind=0; ind<hltPathNames_.size();ind++) {
128  dqmFolder = Form("HLT/BTag/Vertex/%s",hltPathNames_[ind].c_str());
129  H1_.push_back(std::map<std::string, MonitorElement *>());
130  ibooker.setCurrentFolder(dqmFolder);
131  for (unsigned int coll=0; coll<VertexCollection_.size();coll++) {
132  float maxValue = 0.02;
133  if(VertexCollection_Label.at(coll)==("hltFastPrimaryVertex")) maxValue = 2.; //for the hltFastPrimaryVertex use a larger scale (res ~ 1 cm)
134  float vertexU = maxValue;
135  float vertexL = -maxValue;
136  int vertexBins = 100;
137  if ( VertexCollection_Label.at(coll) != "" && VertexCollection_Label.at(coll) != "NULL" ) {
138  H1_.back()["Vertex_"+VertexCollection_Label.at(coll)] = ibooker.book1D("Vertex_"+VertexCollection_Label.at(coll), VertexCollection_Label.at(coll).c_str(), vertexBins, vertexL, vertexU );
139  H1_.back()["Vertex_"+VertexCollection_Label.at(coll)] -> setAxisTitle("vertex error (cm)",1);
140  }
141  }
142  }
143 }
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
JetCorrectorParametersCollection coll
Definition: classes.h:10
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::vector< std::string > VertexCollection_Label
std::vector< std::string > hltPathNames_
std::vector< edm::EDGetTokenT< reco::VertexCollection > > VertexCollection_
std::vector< std::map< std::string, MonitorElement * > > H1_
void HLTVertexPerformanceAnalyzer::dqmBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from thread_unsafe::DQMEDAnalyzer.

Definition at line 25 of file HLTVertexPerformanceAnalyzer.cc.

References _isfoundHLTs, newFWLiteAna::found, hltConfigProvider_, hltPathIndexs_, hltPathNames_, hlTriggerResults_, HLTConfigProvider::init(), label, edm::EDConsumerBase::Labels::process, triggerConfChanged_, and HLTConfigProvider::triggerNames().

25  {
26  triggerConfChanged_ = true;
27  EDConsumerBase::labelsForToken(hlTriggerResults_,label);
28 
30  const std::vector< std::string > & allHltPathNames = hltConfigProvider_.triggerNames();
31 
32  //fill hltPathIndexs_ with the trigger number of each hltPathNames_
33  for ( size_t trgs=0; trgs<hltPathNames_.size(); trgs++) {
34  unsigned int found = 1;
35  int it_mem = -1;
36  for (size_t it=0 ; it < allHltPathNames.size() ; ++it )
37  {
38  found = allHltPathNames.at(it).find(hltPathNames_[trgs]);
39  if ( found == 0 )
40  {
41  it_mem= (int) it;
42  }
43  }//for allallHltPathNames
44  hltPathIndexs_.push_back(it_mem);
45  }//for hltPathNames_
46 
47  //fill _isfoundHLTs for each hltPathNames_
48  for ( size_t trgs=0; trgs<hltPathNames_.size(); trgs++) {
49  if ( hltPathIndexs_[trgs] < 0 ) {
50  _isfoundHLTs.push_back(false);
51  }
52  else {
53  _isfoundHLTs.push_back(true);
54  }
55  }
56 }
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::EDGetTokenT< TriggerResults > hlTriggerResults_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< std::string > hltPathNames_

Member Data Documentation

std::vector<bool> HLTVertexPerformanceAnalyzer::_isfoundHLTs
private

Definition at line 56 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze(), and dqmBeginRun().

std::vector<std::string> HLTVertexPerformanceAnalyzer::folders
private

Definition at line 57 of file HLTVertexPerformanceAnalyzer.h.

std::vector< std::map<std::string, MonitorElement *> > HLTVertexPerformanceAnalyzer::H1_
private

Definition at line 58 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze(), and bookHistograms().

HLTConfigProvider HLTVertexPerformanceAnalyzer::hltConfigProvider_
private

Definition at line 49 of file HLTVertexPerformanceAnalyzer.h.

Referenced by dqmBeginRun().

std::vector<int> HLTVertexPerformanceAnalyzer::hltPathIndexs_
private

Definition at line 53 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze(), and dqmBeginRun().

std::vector<std::string> HLTVertexPerformanceAnalyzer::hltPathNames_
private

Definition at line 48 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze(), bookHistograms(), and dqmBeginRun().

edm::EDGetTokenT<TriggerResults> HLTVertexPerformanceAnalyzer::hlTriggerResults_
private
std::string HLTVertexPerformanceAnalyzer::hlTriggerResults_Label
private

Definition at line 62 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze().

edm::EDConsumerBase::Labels HLTVertexPerformanceAnalyzer::label
private
edm::EDGetTokenT<std::vector<SimVertex> > HLTVertexPerformanceAnalyzer::simVertexCollection_
private

Definition at line 47 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze().

bool HLTVertexPerformanceAnalyzer::triggerConfChanged_
private

Definition at line 50 of file HLTVertexPerformanceAnalyzer.h.

Referenced by dqmBeginRun().

std::vector<edm::EDGetTokenT<reco::VertexCollection> > HLTVertexPerformanceAnalyzer::VertexCollection_
private
std::vector<std::string> HLTVertexPerformanceAnalyzer::VertexCollection_Label
private

Definition at line 61 of file HLTVertexPerformanceAnalyzer.h.

Referenced by analyze(), and bookHistograms().