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")) {
38  nPhiBins_, ptMax_, highPtMax_, doRefAnalysis_, l1MatchDr_, dqmBaseFolder_));
39  }
40  if(ps.exists("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 
69 //--------------------------------------------------------
71  //Evaluate configuration for every new trigger menu
72  bool hltMenuChanged = false;
73  if(HLTCP_.init(iRun, iSetup, hltProcessName_, hltMenuChanged)) {
74  LogDebug("HLTTauDQMOffline") << "dqmBeginRun(), hltMenuChanged " << hltMenuChanged;
75  if(hltMenuChanged) {
76  // Find all paths to monitor
77  std::vector<std::string> foundPaths;
78  std::smatch what;
79  LogDebug("HLTTauDQMOffline") << "Looking for paths with regex " << pathRegex_;
80  for(const std::string& pathName: HLTCP_.triggerNames()) {
81  if(std::regex_search(pathName, what, pathRegex_)) {
82  LogDebug("HLTTauDQMOffline") << "Found path " << pathName;
83  foundPaths.emplace_back(pathName);
84  }
85  }
86  std::sort(foundPaths.begin(), foundPaths.end());
87 
88  if(!tagAndProbe_) {
89  // Construct path plotters
90  std::vector<const HLTTauDQMPath *> pathObjects;
91  pathPlotters_.reserve(foundPaths.size());
92  pathObjects.reserve(foundPaths.size());
93  for(const std::string& pathName: foundPaths) {
95  if(pathPlotters_.back().isValid()) {
96  pathObjects.push_back(pathPlotters_.back().getPathObject());
97  }
98  }
99 
100  // Update paths to the summary plotter
101  if(pathSummaryPlotter_) {
102  pathSummaryPlotter_->setPathObjects(pathObjects);
103  }
104  }
105  }
106  } else {
107  edm::LogWarning("HLTTauDQMOffline") << "HLT config extraction failure with process name '" << hltProcessName_ << "'";
108  }
109 }
110 
111 //--------------------------------------------------------
113  if(l1Plotter_) {
114  l1Plotter_->bookHistograms(iBooker);
115  }
116  for(auto& pathPlotter: pathPlotters_) {
117  pathPlotter.bookHistograms(iBooker);
118  }
119  for(auto& tpPlotter: tagandprobePlotters_) {
120  tpPlotter->bookHistograms(iBooker,iRun,iSetup);
121  }
122  if(pathSummaryPlotter_) {
123  pathSummaryPlotter_->bookHistograms(iBooker);
124  }
125 }
126 
127 // ----------------------------------------------------------
129  //Apply the prescaler
130  if (counterEvt_ > prescaleEvt_) {
131  //Do Analysis here
132  counterEvt_ = 0;
133 
134  edm::Handle<edm::TriggerResults> triggerResultsHandle;
135  iEvent.getByToken(triggerResultsToken_, triggerResultsHandle);
136  if(!triggerResultsHandle.isValid()) {
137  edm::LogWarning("HLTTauDQMOffline") << "Unable to read edm::TriggerResults with label " << triggerResultsSrc_;
138  return;
139  }
140 
141  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
142  iEvent.getByToken(triggerEventToken_, triggerEventHandle);
143  if(!triggerEventHandle.isValid()) {
144  edm::LogWarning("HLTTauDQMOffline") << "Unable to read trigger::TriggerEvent with label " << triggerEventSrc_;
145  return;
146  }
147 
148  //Create match collections
150  if (doRefAnalysis_) {
151  for(RefObject& refObj: refObjects_) {
152  edm::Handle<LVColl> collHandle;
153  iEvent.getByToken(refObj.token, collHandle);
154  if(!collHandle.isValid())
155  continue;
156 
157  if(refObj.objID == 11) {
158  refC.electrons.insert(refC.electrons.end(), collHandle->begin(), collHandle->end());
159  }
160  else if(refObj.objID == 13) {
161  refC.muons.insert(refC.muons.end(), collHandle->begin(), collHandle->end());
162  }
163  else if(refObj.objID == 15) {
164  refC.taus.insert(refC.taus.end(), collHandle->begin(), collHandle->end());
165  }
166  else if(refObj.objID == 0) {
167  refC.met.insert(refC.met.end(), collHandle->begin(), collHandle->end());
168  }
169  }
170  }
171 
172  //Path Plotters
173  for(auto& pathPlotter: pathPlotters_) {
174  if(pathPlotter.isValid())
175  pathPlotter.analyze(*triggerResultsHandle, *triggerEventHandle, refC);
176  }
177 
178  if(pathSummaryPlotter_ && pathSummaryPlotter_->isValid()) {
179  pathSummaryPlotter_->analyze(*triggerResultsHandle, *triggerEventHandle, refC);
180  }
181 
182  //L1 Plotter
183  if(l1Plotter_ && l1Plotter_->isValid()) {
184  l1Plotter_->analyze(iEvent, iSetup, refC);
185  }
186 
187  //Tag and probe plotters
188  for(auto& tpPlotter: tagandprobePlotters_) {
189  if(tpPlotter->isValid())
190  tpPlotter->analyze(iEvent,iSetup,refC);
191  }
192 
193  } else {
194  counterEvt_++;
195  }
196 }
#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:460
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(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:42
std::vector< LV > muons
std::unique_ptr< HLTTauDQML1Plotter > l1Plotter_
void analyze(const edm::Event &e, const edm::EventSetup &c) override