CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HLTVertexPerformanceAnalyzer Class Reference

#include <HLTVertexPerformanceAnalyzer.h>

Inheritance diagram for HLTVertexPerformanceAnalyzer:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

void dqmBeginRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override
 
 HLTVertexPerformanceAnalyzer (const edm::ParameterSet &)
 
 ~HLTVertexPerformanceAnalyzer () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
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< edm::TriggerResultshlTriggerResults_
 
std::string hlTriggerResults_Label
 
edm::EDConsumerBase::Labels label
 
std::string mainFolder_
 
edm::EDGetTokenT< std::vector< SimVertex > > simVertexCollection_
 
bool triggerConfChanged_
 
std::vector< edm::EDGetTokenT< reco::VertexCollection > > VertexCollection_
 
std::vector< std::string > VertexCollection_Label
 

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 33 of file HLTVertexPerformanceAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file HLTVertexPerformanceAnalyzer.cc.

References edm::ParameterSet::getParameter(), mps_fire::i, diffTwoXMLs::label, edm::EDConsumerBase::labelsForToken(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

7 {
8  mainFolder_ = iConfig.getParameter<std::string>("mainFolder");
9  hlTriggerResults_ = consumes<TriggerResults>(iConfig.getParameter<InputTag> ("TriggerResults"));
10  VertexCollection_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "Vertex" ), [this](edm::InputTag const & tag){return mayConsume< reco::VertexCollection>(tag);});
11  hltPathNames_ = iConfig.getParameter< std::vector<std::string> > ("HLTPathNames");
12  simVertexCollection_ = consumes<std::vector<SimVertex> >(iConfig.getParameter<edm::InputTag> ("SimVertexCollection"));
13 
14  EDConsumerBase::labelsForToken(hlTriggerResults_,label);
16 
17  for(unsigned int i=0; i<VertexCollection_.size() ; i++){
18  EDConsumerBase::labelsForToken(VertexCollection_[i],label);
20  }
21 }
T getParameter(std::string const &) const
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< edm::TriggerResults > hlTriggerResults_
char const * module
Definition: ProductLabels.h:5
std::vector< std::string > VertexCollection_Label
std::vector< std::string > hltPathNames_
std::vector< edm::EDGetTokenT< reco::VertexCollection > > VertexCollection_
HLTVertexPerformanceAnalyzer::~HLTVertexPerformanceAnalyzer ( )
override

Definition at line 24 of file HLTVertexPerformanceAnalyzer.cc.

25 {
26 }

Member Function Documentation

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

Definition at line 63 of file HLTVertexPerformanceAnalyzer.cc.

References edm::HLTGlobalStatus::accept(), coll, HcalObjRepresent::Fill(), edm::Event::getByToken(), edm::HandleBase::isValid(), RecoTauDiscriminantConfiguration::maxValue, CoreSimVertex::position(), edm::Handle< T >::product(), caloTruthProducer_cfi::simVertexCollection, and edm::triggerResults().

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

Definition at line 120 of file HLTVertexPerformanceAnalyzer.cc.

References DQMStore::IBooker::book1D(), coll, DEFINE_FWK_MODULE, RecoTauDiscriminantConfiguration::maxValue, DQMStore::IBooker::setCurrentFolder(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 29 of file HLTVertexPerformanceAnalyzer.cc.

References runEdmFileComparison::found, createfilelist::int, diffTwoXMLs::label, and edm::EDConsumerBase::labelsForToken().

29  {
30  triggerConfChanged_ = true;
31  EDConsumerBase::labelsForToken(hlTriggerResults_,label);
32 
34  const std::vector< std::string > & allHltPathNames = hltConfigProvider_.triggerNames();
35 
36  //fill hltPathIndexs_ with the trigger number of each hltPathNames_
37  for ( size_t trgs=0; trgs<hltPathNames_.size(); trgs++) {
38  unsigned int found = 1;
39  int it_mem = -1;
40  for (size_t it=0 ; it < allHltPathNames.size() ; ++it )
41  {
42  found = allHltPathNames.at(it).find(hltPathNames_[trgs]);
43  if ( found == 0 )
44  {
45  it_mem= (int) it;
46  }
47  }//for allallHltPathNames
48  hltPathIndexs_.push_back(it_mem);
49  }//for hltPathNames_
50 
51  //fill _isfoundHLTs for each hltPathNames_
52  for ( size_t trgs=0; trgs<hltPathNames_.size(); trgs++) {
53  if ( hltPathIndexs_[trgs] < 0 ) {
54  _isfoundHLTs.push_back(false);
55  }
56  else {
57  _isfoundHLTs.push_back(true);
58  }
59  }
60 }
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::EDGetTokenT< edm::TriggerResults > hlTriggerResults_
char const * process
Definition: ProductLabels.h:7
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 55 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 56 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 57 of file HLTVertexPerformanceAnalyzer.h.

HLTConfigProvider HLTVertexPerformanceAnalyzer::hltConfigProvider_
private

Definition at line 48 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 52 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 47 of file HLTVertexPerformanceAnalyzer.h.

edm::EDGetTokenT<edm::TriggerResults> HLTVertexPerformanceAnalyzer::hlTriggerResults_
private

Definition at line 45 of file HLTVertexPerformanceAnalyzer.h.

std::string HLTVertexPerformanceAnalyzer::hlTriggerResults_Label
private

Definition at line 61 of file HLTVertexPerformanceAnalyzer.h.

edm::EDConsumerBase::Labels HLTVertexPerformanceAnalyzer::label
private
std::string HLTVertexPerformanceAnalyzer::mainFolder_
private

Definition at line 44 of file HLTVertexPerformanceAnalyzer.h.

edm::EDGetTokenT<std::vector<SimVertex> > HLTVertexPerformanceAnalyzer::simVertexCollection_
private

Definition at line 46 of file HLTVertexPerformanceAnalyzer.h.

bool HLTVertexPerformanceAnalyzer::triggerConfChanged_
private

Definition at line 49 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 51 of file HLTVertexPerformanceAnalyzer.h.

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

Definition at line 60 of file HLTVertexPerformanceAnalyzer.h.