94 void endJob()
override;
101 double match_trigger(std::vector<int> &trigIndices,
145 maxMuon_ = iConfig.
getParameter<
unsigned int>(
"maxMuon");
146 isoTriggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"isoTriggerNames");
150 VtxToken_ = consumes<reco::VertexCollection>(
153 TriggerResultsToken_ = consumes<edm::TriggerResults>(
155 triggerSummaryLabelToken_ = consumes<trigger::TriggerEvent>(
163 muon_data =
muon->getData();
165 tree_ = fs_->make<TTree>(
"Muon2RecoTree",
"Muon2RecoTree");
166 tree_->Branch(
"Muon",
"L1Analysis::L1AnalysisRecoMuon2DataFormat", &muon_data, 32000, 3);
168 triggerMaxDeltaR_ = iConfig.
getParameter<
double>(
"triggerMaxDeltaR");
171 isoTriggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"isoTriggerNames");
172 triggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"triggerNames");
195 iEvent.getByToken(MuonToken_, recoMuons);
204 iEvent.getByToken(triggerSummaryLabelToken_, triggerSummaryLabel_);
207 iEvent.getByToken(metToken_, metLabel_);
214 for (reco::PFMETCollection::const_iterator imet = metLabel_->begin();
215 imet != metLabel_->end() && (unsigned)counter_met < 1;
227 for (reco::MuonCollection::const_iterator imu = recoMuons->begin();
228 imu != recoMuons->end() && (unsigned)counter_mu < maxMuon_;
234 if (triggerMatching_) {
235 double isoMatchDeltaR = 9999.;
236 double matchDeltaR = 9999.;
237 int hasIsoTriggered = 0;
238 int hasTriggered = 0;
240 int passesSingleMuonFlag = 0;
244 if (triggerSummaryLabel_.
isValid()) {
251 for (UInt_t iPath = 0; iPath < isoTriggerNames_.size(); ++iPath) {
252 if (passesSingleMuonFlag == 1)
265 passesSingleMuonFlag = 1;
268 if (triggerSummaryLabel_.
isValid()) {
272 matchDeltaR = match_trigger(triggerIndices_,
triggerObjects, triggerSummaryLabel_, (*imu));
273 if (matchDeltaR < triggerMaxDeltaR_)
280 isoMatchDeltaR = match_trigger(isoTriggerIndices_,
triggerObjects, triggerSummaryLabel_, (*imu));
281 if (isoMatchDeltaR < triggerMaxDeltaR_)
291 muon_data->hlt_isomu.push_back(hasIsoTriggered);
292 muon_data->hlt_mu.push_back(hasTriggered);
293 muon_data->hlt_isoDeltaR.push_back(isoMatchDeltaR);
294 muon_data->hlt_deltaR.push_back(matchDeltaR);
295 muon_data->passesSingleMuon.push_back(passesSingleMuonFlag);
312 muon_data->hlt_isomu.push_back(-9999);
313 muon_data->hlt_mu.push_back(-9999);
314 muon_data->hlt_isoDeltaR.push_back(-9999);
315 muon_data->hlt_deltaR.push_back(-9999);
322 double matchDeltaR = 9999;
324 for (
size_t iTrigIndex = 0; iTrigIndex < trigIndices.size(); ++iTrigIndex) {
325 int triggerIndex = trigIndices[iTrigIndex];
326 const std::vector<std::string> moduleLabels(hltConfig_.moduleLabels(triggerIndex));
328 const unsigned moduleIndex = hltConfig_.size(triggerIndex) - 2;
330 const unsigned hltFilterIndex =
333 if (hltFilterIndex < triggerEvent->sizeFilters()) {
337 const unsigned nTriggers = triggerVids.size();
338 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
342 double dRtmp =
deltaR(
mu, trigObject);
344 if (dRtmp < matchDeltaR) {
358 if (triggerMatching_) {
360 if (!hltConfig_.init(
run, eventSetup, triggerProcessLabel_, changed)) {
362 std::cout <<
"Error: didn't find process" << triggerProcessLabel_ << std::endl;
366 bool enableWildcard =
true;
367 for (
size_t iTrig = 0; iTrig < triggerNames_.size(); ++iTrig) {
369 TString tNameTmp = TString(triggerNames_[iTrig]);
370 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
373 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
375 TString tmpName = TString(hltConfig_.triggerName(ipath));
376 if (tmpName.Contains(tNamePattern)) {
378 triggerIndices_.push_back(tIndex);
382 std::cout <<
"Warning: Could not find trigger" << triggerNames_[iTrig] << std::endl;
386 for (
size_t iTrig = 0; iTrig < isoTriggerNames_.size(); ++iTrig) {
388 TString tNameTmp = TString(isoTriggerNames_[iTrig]);
389 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
392 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
394 TString tmpName = TString(hltConfig_.triggerName(ipath));
395 if (tmpName.Contains(tNamePattern)) {
397 isoTriggerIndices_.push_back(tIndex);
401 std::cout <<
"Warning: Could not find trigger" << isoTriggerNames_[iTrig] << std::endl;
407 muon->init(eventSetup);