CMS 3D CMS Logo

FourVectorHLT.cc
Go to the documentation of this file.
9 
10 // see header file for information.
11 #include "FourVectorHLT.h"
12 
13 using namespace edm;
14 
16  LogDebug("FourVectorHLT") << "constructor....";
17 
18  dbe_ = Service<DQMStore>().operator->();
19  if (!dbe_) {
20  LogWarning("Status") << "unable to get DQMStore service?";
21  }
22 
23  dirname_ = "HLT/FourVectorHLT";
24 
25  if (dbe_ != nullptr) {
26  LogDebug("Status") << "Setting current directory to " << dirname_;
27  dbe_->setCurrentFolder(dirname_);
28  }
29 
30  // plotting paramters
31  ptMin_ = iConfig.getUntrackedParameter<double>("ptMin", 0.);
32  ptMax_ = iConfig.getUntrackedParameter<double>("ptMax", 200.);
33  nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins", 50);
34 
35  plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
36 
37  // this is the list of paths to look at.
38  std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters");
39  for (std::vector<edm::ParameterSet>::iterator filterconf = filters.begin(); filterconf != filters.end();
40  filterconf++) {
41  std::string me = filterconf->getParameter<std::string>("name");
42  int objectType = filterconf->getParameter<unsigned int>("type");
43  float ptMin = filterconf->getUntrackedParameter<double>("ptMin");
44  float ptMax = filterconf->getUntrackedParameter<double>("ptMax");
45  hltPaths_.push_back(PathInfo(me, objectType, ptMin, ptMax));
46  }
47  if (!hltPaths_.empty() && plotAll_) {
48  // these two ought to be mutually exclusive....
49  LogWarning("Configuration") << "Using both plotAll and a list. "
50  "list will be ignored.";
51  hltPaths_.clear();
52  }
53  triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
54 
55  //set Token(-s)
56  triggerSummaryToken_ = consumes<trigger::TriggerEvent>(iConfig.getParameter<edm::InputTag>("triggerSummaryLabel"));
57 }
58 
60  // do anything here that needs to be done at desctruction time
61  // (e.g. close files, deallocate resources etc.)
62 }
63 
64 //
65 // member functions
66 //
67 
68 // ------------ method called to for each event ------------
70  using namespace edm;
71  using namespace trigger;
72  ++nev_;
73  LogDebug("Status") << "analyze";
74 
75  edm::Handle<TriggerEvent> triggerObj;
76  iEvent.getByToken(triggerSummaryToken_, triggerObj);
77  if (!triggerObj.isValid()) {
78  edm::LogInfo("Status") << "Summary HLT object (TriggerEvent) not found, "
79  "skipping event";
80  return;
81  }
82 
83  const trigger::TriggerObjectCollection& toc(triggerObj->getObjects());
84 
85  if (plotAll_) {
86  for (size_t ia = 0; ia < triggerObj->sizeFilters(); ++ia) {
87  std::string fullname = triggerObj->filterTag(ia).encode();
88  // the name can have in it the module label as well as the process and
89  // other labels - strip 'em
91  size_t p = fullname.find_first_of(':');
92  if (p != std::string::npos) {
93  name = fullname.substr(0, p);
94  } else {
95  name = fullname;
96  }
97 
98  LogDebug("Parameter") << "filter " << ia << ", full name = " << fullname << ", p = " << p
99  << ", abbreviated = " << name;
100 
101  PathInfoCollection::iterator pic = hltPaths_.find(name);
102  if (pic == hltPaths_.end()) {
103  // doesn't exist - add it
104  MonitorElement *et(nullptr), *eta(nullptr), *phi(nullptr), *etavsphi(nullptr);
105 
106  std::string histoname(name + "_et");
107  LogDebug("Status") << "new histo with name " << histoname;
108  dbe_->setCurrentFolder(dirname_);
109  std::string title(name + " E_{T}");
110  et = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, 0, 100);
111 
112  histoname = name + "_eta";
113  title = name + " #eta";
114  eta = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7);
115 
116  histoname = name + "_phi";
117  title = name + " #phi";
118  phi = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, -3.14, 3.14);
119 
120  histoname = name + "_etaphi";
121  title = name + " #eta vs #phi";
122  etavsphi = dbe_->book2D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7, nBins_, -3.14, 3.14);
123 
124  // no idea how to get the bin boundries in this mode
125  PathInfo e(name, 0, et, eta, phi, etavsphi, ptMin_, ptMax_);
126  hltPaths_.push_back(e);
127  pic = hltPaths_.begin() + hltPaths_.size() - 1;
128  }
129  const trigger::Keys& k = triggerObj->filterKeys(ia);
130  for (trigger::Keys::const_iterator ki = k.begin(); ki != k.end(); ++ki) {
131  LogDebug("Parameters") << "pt, eta, phi = " << toc[*ki].pt() << ", " << toc[*ki].eta() << ", "
132  << toc[*ki].phi();
133  pic->getEtHisto()->Fill(toc[*ki].pt());
134  pic->getEtaHisto()->Fill(toc[*ki].eta());
135  pic->getPhiHisto()->Fill(toc[*ki].phi());
136  pic->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi());
137  }
138  }
139 
140  } else { // not plotAll_
141  for (PathInfoCollection::iterator v = hltPaths_.begin(); v != hltPaths_.end(); ++v) {
142  const int index = triggerObj->filterIndex(v->getName());
143  if (index >= triggerObj->sizeFilters()) {
144  continue; // not in this event
145  }
146  LogDebug("Status") << "filling ... ";
147  const trigger::Keys& k = triggerObj->filterKeys(index);
148  for (trigger::Keys::const_iterator ki = k.begin(); ki != k.end(); ++ki) {
149  v->getEtHisto()->Fill(toc[*ki].pt());
150  v->getEtaHisto()->Fill(toc[*ki].eta());
151  v->getPhiHisto()->Fill(toc[*ki].phi());
152  v->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi());
153  }
154  }
155  }
156 }
157 
158 // -- method called once each job just before starting event loop --------
160  nev_ = 0;
161  DQMStore* dbe = nullptr;
162  dbe = Service<DQMStore>().operator->();
163 
164  if (dbe) {
165  dbe->setCurrentFolder(dirname_);
166 
167  if (!plotAll_) {
168  for (PathInfoCollection::iterator v = hltPaths_.begin(); v != hltPaths_.end(); ++v) {
169  MonitorElement *et, *eta, *phi, *etavsphi = nullptr;
170  std::string histoname(v->getName() + "_et");
171  std::string title(v->getName() + " E_t");
172  et = dbe->book1D(histoname.c_str(), title.c_str(), nBins_, v->getPtMin(), v->getPtMax());
173 
174  histoname = v->getName() + "_eta";
175  title = v->getName() + " #eta";
176  eta = dbe->book1D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7);
177 
178  histoname = v->getName() + "_phi";
179  title = v->getName() + " #phi";
180  phi = dbe->book1D(histoname.c_str(), histoname.c_str(), nBins_, -3.14, 3.14);
181 
182  histoname = v->getName() + "_etaphi";
183  title = v->getName() + " #eta vs #phi";
184  etavsphi = dbe->book2D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7, nBins_, -3.14, 3.14);
185 
186  v->setHistos(et, eta, phi, etavsphi);
187  }
188  } // ! plotAll_ - for plotAll we discover it during the event
189  }
190 }
191 
192 // - method called once each job just after ending the event loop ------------
194  LogInfo("Status") << "endJob: analyzed " << nev_ << " events";
195  return;
196 }
197 
198 // BeginRun
200  LogDebug("Status") << "beginRun, run " << run.id();
201 }
202 
205  LogDebug("Status") << "endRun, run " << run.id();
206 }
Handle.h
trigger::TriggerEvent::sizeFilters
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
filters
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
FourVectorHLT::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
Definition: FourVectorHLT.cc:199
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::Run
Definition: Run.h:45
TriggerEvent.h
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
DQMStore.h
FourVectorHLT::endRun
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
Definition: FourVectorHLT.cc:204
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FourVectorHLT::endJob
void endJob() override
Definition: FourVectorHLT.cc:193
edm::Handle
Definition: AssociativeIterator.h:50
FourVectorHLT::FourVectorHLT
FourVectorHLT(const edm::ParameterSet &)
Definition: FourVectorHLT.cc:15
MakerMacros.h
FourVectorHLT::beginJob
void beginJob() override
Definition: FourVectorHLT.cc:159
trigger::TriggerEvent::filterTag
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:108
dqm::legacy::DQMStore
Definition: DQMStore.h:727
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
PVValHelper::eta
Definition: PVValidationHelpers.h:69
Run.h
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
FourVectorHLT::~FourVectorHLT
~FourVectorHLT() override
Definition: FourVectorHLT.cc:59
trigger::TriggerEvent::filterIndex
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:57
FourVectorHLT.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
TriggerObject.h
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
FourVectorHLT::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: FourVectorHLT.cc:69
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FourVectorHLT::PathInfo
Definition: FourVectorHLT.h:83
trigger
Definition: HLTPrescaleTableCond.h:8
ParameterSet.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37