CMS 3D CMS Logo

HLTTauDQMOfflineSource.cc
Go to the documentation of this file.
2 
4 
6 
7 using namespace std;
8 using namespace edm;
9 using namespace reco;
10 using namespace trigger;
11 
12 //
13 // constructors and destructor
14 //
16  hltProcessName_(ps.getUntrackedParameter<std::string>("HLTProcessName","HLT")),
17  triggerResultsSrc_(ps.getUntrackedParameter<edm::InputTag>("TriggerResultsSrc")),
18  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsSrc_)),
19  triggerEventSrc_(ps.getUntrackedParameter<edm::InputTag>("TriggerEventSrc")),
20  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventSrc_)),
21  pathRegex_(ps.getUntrackedParameter<std::string>("Paths")),
22  nPtBins_(ps.getUntrackedParameter<int>("PtHistoBins", 20)),
23  nEtaBins_(ps.getUntrackedParameter<int>("EtaHistoBins",12)),
24  nPhiBins_(ps.getUntrackedParameter<int>("PhiHistoBins",18)),
25  ptMax_(ps.getUntrackedParameter<double>("PtHistoMax",200)),
26  highPtMax_(ps.getUntrackedParameter<double>("HighPtHistoMax",1000)),
27  l1MatchDr_(ps.getUntrackedParameter<double>("L1MatchDeltaR", 0.5)),
28  hltMatchDr_(ps.getUntrackedParameter<double>("HLTMatchDeltaR", 0.5)),
29  dqmBaseFolder_(ps.getUntrackedParameter<std::string>("DQMBaseFolder")),
30  counterEvt_(0),
31  prescaleEvt_(ps.getUntrackedParameter<int>("prescaleEvt", -1))
32 {
34  doRefAnalysis_ = matching.getUntrackedParameter<bool>("doMatching");
35 
36  if(ps.exists("L1Plotter") && !ps.exists("TagAndProbe")) {
37  l1Plotter_ = std::make_unique<HLTTauDQML1Plotter>(ps.getUntrackedParameter<edm::ParameterSet>("L1Plotter"), consumesCollector(),
39  }
40  if(ps.exists("PathSummaryPlotter")) {
41  pathSummaryPlotter_ = std::make_unique<HLTTauDQMPathSummaryPlotter>(ps.getUntrackedParameter<edm::ParameterSet>("PathSummaryPlotter"),
42  doRefAnalysis_, dqmBaseFolder_, hltMatchDr_);
43  }
44  tagAndProbe_ = false;
45  if(ps.exists("TagAndProbe")) {
46  std::vector<edm::ParameterSet> tagAndProbePaths = ps.getUntrackedParameter<std::vector<edm::ParameterSet> >("TagAndProbe");
47  tagAndProbe_ = true;
48  // tagandprobePlotters_.reserve(tagAndProbePaths.size());
49  for(const edm::ParameterSet& tpset: tagAndProbePaths) {
50  num_genTriggerEventFlag_.emplace_back(new GenericTriggerEventFlag(tpset.getParameter<edm::ParameterSet>("numerator"),consumesCollector(), *this));
51  den_genTriggerEventFlag_.emplace_back(new GenericTriggerEventFlag(tpset.getParameter<edm::ParameterSet>("denominator"),consumesCollector(), *this));
53  }
54  }
55 
56  if(doRefAnalysis_) {
57  using VPSet = std::vector<edm::ParameterSet>;
58  VPSet matchObjects = matching.getUntrackedParameter<VPSet>("matchFilters");
59  for(const edm::ParameterSet& pset: matchObjects) {
60  refObjects_.push_back(RefObject{pset.getUntrackedParameter<int>("matchObjectID"),
61  consumes<LVColl>(pset.getUntrackedParameter<edm::InputTag>("FilterName"))});
62  }
63  }
64 }
65 
67 
68 //--------------------------------------------------------
70  //Evaluate configuration for every new trigger menu
71  bool hltMenuChanged = false;
72  if(HLTCP_.init(iRun, iSetup, hltProcessName_, hltMenuChanged)) {
73  LogDebug("HLTTauDQMOffline") << "dqmBeginRun(), hltMenuChanged " << hltMenuChanged;
74  if(hltMenuChanged) {
75  // Find all paths to monitor
76  std::vector<std::string> foundPaths;
77  std::smatch what;
78  LogDebug("HLTTauDQMOffline") << "Looking for paths with regex " << pathRegex_;
79  for(const std::string& pathName: HLTCP_.triggerNames()) {
80  if(std::regex_search(pathName, what, pathRegex_)) {
81  LogDebug("HLTTauDQMOffline") << "Found path " << pathName;
82  foundPaths.emplace_back(pathName);
83  }
84  }
85  std::sort(foundPaths.begin(), foundPaths.end());
86 
87  if(!tagAndProbe_) {
88  // Construct path plotters
89  std::vector<const HLTTauDQMPath *> pathObjects;
90  pathPlotters_.reserve(foundPaths.size());
91  pathObjects.reserve(foundPaths.size());
92  for(const std::string& pathName: foundPaths) {
94  if(pathPlotters_.back().isValid()) {
95  pathObjects.push_back(pathPlotters_.back().getPathObject());
96  }
97  }
98 
99  // Update paths to the summary plotter
100  if(pathSummaryPlotter_) {
101  pathSummaryPlotter_->setPathObjects(pathObjects);
102  }
103  }
104  }
105  } else {
106  edm::LogWarning("HLTTauDQMOffline") << "HLT config extraction failure with process name '" << hltProcessName_ << "'";
107  }
108 }
109 
110 //--------------------------------------------------------
112  if(l1Plotter_) {
113  l1Plotter_->bookHistograms(iBooker);
114  }
115  for(auto& pathPlotter: pathPlotters_) {
116  pathPlotter.bookHistograms(iBooker);
117  }
118  for(auto& tpPlotter: tagandprobePlotters_) {
119  tpPlotter->bookHistograms(iBooker,iRun,iSetup);
120  }
121  if(pathSummaryPlotter_) {
122  pathSummaryPlotter_->bookHistograms(iBooker);
123  }
124 }
125 
126 // ----------------------------------------------------------
128  //Apply the prescaler
129  if (counterEvt_ > prescaleEvt_) {
130  //Do Analysis here
131  counterEvt_ = 0;
132 
133  edm::Handle<edm::TriggerResults> triggerResultsHandle;
134  iEvent.getByToken(triggerResultsToken_, triggerResultsHandle);
135  if(!triggerResultsHandle.isValid()) {
136  edm::LogWarning("HLTTauDQMOffline") << "Unable to read edm::TriggerResults with label " << triggerResultsSrc_;
137  return;
138  }
139 
140  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
141  iEvent.getByToken(triggerEventToken_, triggerEventHandle);
142  if(!triggerEventHandle.isValid()) {
143  edm::LogWarning("HLTTauDQMOffline") << "Unable to read trigger::TriggerEvent with label " << triggerEventSrc_;
144  return;
145  }
146 
147  //Create match collections
149  if (doRefAnalysis_) {
150  for(RefObject& refObj: refObjects_) {
151  edm::Handle<LVColl> collHandle;
152  iEvent.getByToken(refObj.token, collHandle);
153  if(!collHandle.isValid())
154  continue;
155 
156  if(refObj.objID == 11) {
157  refC.electrons.insert(refC.electrons.end(), collHandle->begin(), collHandle->end());
158  }
159  else if(refObj.objID == 13) {
160  refC.muons.insert(refC.muons.end(), collHandle->begin(), collHandle->end());
161  }
162  else if(refObj.objID == 15) {
163  refC.taus.insert(refC.taus.end(), collHandle->begin(), collHandle->end());
164  }
165  else if(refObj.objID == 0) {
166  refC.met.insert(refC.met.end(), collHandle->begin(), collHandle->end());
167  }
168  }
169  }
170 
171  //Path Plotters
172  for(auto& pathPlotter: pathPlotters_) {
173  if(pathPlotter.isValid())
174  pathPlotter.analyze(*triggerResultsHandle, *triggerEventHandle, refC);
175  }
176 
177  if(pathSummaryPlotter_ && pathSummaryPlotter_->isValid()) {
178  pathSummaryPlotter_->analyze(*triggerResultsHandle, *triggerEventHandle, refC);
179  }
180 
181  //L1 Plotter
182  if(l1Plotter_ && l1Plotter_->isValid()) {
183  l1Plotter_->analyze(iEvent, iSetup, refC);
184  }
185 
186  //Tag and probe plotters
187  for(auto& tpPlotter: tagandprobePlotters_) {
188  if(tpPlotter->isValid())
189  tpPlotter->analyze(iEvent,iSetup,refC);
190  }
191 
192  } else {
193  counterEvt_++;
194  }
195 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string dqmBaseFolder_
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
std::vector< LV > electrons
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
std::vector< LV > taus
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< RefObject > refObjects_
void bookHistograms(DQMStore::IBooker &iBooker, const edm::Run &r, const edm::EventSetup &c) override
const std::vector< std::string > & triggerNames() const
names of trigger paths
bool exists(std::string const &parameterName) const
checks if a parameter exists
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
std::vector< std::unique_ptr< GenericTriggerEventFlag > > den_genTriggerEventFlag_
int iEvent
Definition: GenABIO.cc:230
~HLTTauDQMOfflineSource() override
HLTTauDQMOfflineSource(const edm::ParameterSet &)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< std::unique_ptr< GenericTriggerEventFlag > > num_genTriggerEventFlag_
std::vector< HLTTauDQMPathPlotter > pathPlotters_
bool isValid() const
Definition: HandleBase.h:74
std::vector< std::unique_ptr< HLTTauDQMTagAndProbePlotter > > tagandprobePlotters_
std::unique_ptr< HLTTauDQMPathSummaryPlotter > pathSummaryPlotter_
std::vector< LV > met
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: Run.h:43
std::vector< LV > muons
std::unique_ptr< HLTTauDQML1Plotter > l1Plotter_
void analyze(const edm::Event &e, const edm::EventSetup &c) override