Skip to content

Commit

Permalink
Fix HLT matching and writing of muon matches chamber info
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Battilana committed Apr 5, 2023
1 parent 6d97d9c commit ba2012e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 58 deletions.
47 changes: 19 additions & 28 deletions DPGAnalysis/MuonTools/plugins/MuNtupleCSCTnPFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,38 +532,29 @@ bool MuNtupleCSCTnPFiller::hasTrigger(std::vector<int>& trigIndices,
const trigger::TriggerObjectCollection& trigObjs,
edm::Handle<trigger::TriggerEvent>& trigEvent,
const reco::Muon& muon) {
double matchDeltaR = 999.;

for (const auto& trigIndex : trigIndices) {
const std::vector<std::string> moduleLabels(m_hltConfig.moduleLabels(trigIndex));

// find index of the last module:
const unsigned moduleIndex = m_hltConfig.size(trigIndex) - 2;

// find index of HLT trigger name:
const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(moduleLabels[moduleIndex], "", "HLT"));
float dRMatch = 999.;
for (int trigIdx : trigIndices) {
const std::vector<std::string> trigModuleLabels = m_hltConfig.moduleLabels(trigIdx);

const unsigned trigModuleIndex =
std::find(trigModuleLabels.begin(), trigModuleLabels.end(), "hltBoolEnd") - trigModuleLabels.begin() - 1;
const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(trigModuleLabels[trigModuleIndex], "", "HLT"));
if (hltFilterIndex < trigEvent->sizeFilters()) {
const trigger::Keys triggerKeys(trigEvent->filterKeys(hltFilterIndex));
const trigger::Vids triggerVids(trigEvent->filterIds(hltFilterIndex));

const size_t nTriggers = triggerVids.size();

for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
// loop over all trigger objects:
const trigger::TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];

double dR = deltaR(muon, trigObject);
if (dR < matchDeltaR)
matchDeltaR = dR;

} // loop over different trigger objects

} // if trigger is in event (should apply hltFilter with used trigger...)
const trigger::Keys keys = trigEvent->filterKeys(hltFilterIndex);
const trigger::Vids vids = trigEvent->filterIds(hltFilterIndex);
const unsigned nTriggers = vids.size();

for (unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
trigger::TriggerObject trigObj = trigObjs[keys[iTrig]];
float dR = deltaR(muon, trigObj);
if (dR < dRMatch)
dRMatch = dR;
}
}
}

} // loop over muon candidates
return dRMatch < 0.1; //CB should get it programmable

return matchDeltaR < 0.1; //CB should get it programmable
}

//bool MuNtupleCSCTnPFiller::muonTagSelection(const reco::Muon & muon,edm::Handle<std::vector<reco::Track>> tracks)
Expand Down
53 changes: 23 additions & 30 deletions DPGAnalysis/MuonTools/plugins/MuNtupleMuonFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ void MuNtupleMuonFiller::fill(edm::Event& ev) {
addColumn(tabMatches, "x", matches_x, "X position of the extrapolated track on the matched chamber");
addColumn(tabMatches, "y", matches_y, "Y position of the extrapolated track on the matched chamber");

addColumn(tabMatches, "wheel", matches_wheel, "Matched chamber wheel");
addColumn(tabMatches, "sector", matches_sector, "Matched chamber sector");
addColumn(tabMatches, "station", matches_station, "Matched chamber station");

addColumn(
tabMatches, "phi", matches_phi, "Phi of the (x,y) position on the matched chamber (global reference frame)");
addColumn(
Expand Down Expand Up @@ -453,39 +457,28 @@ bool MuNtupleMuonFiller::hasTrigger(std::vector<int>& trigIndices,
const trigger::TriggerObjectCollection& trigObjs,
edm::Handle<trigger::TriggerEvent>& trigEvent,
const reco::Muon& muon) {
double matchDeltaR = 999.;

for (const auto& trigIndex : trigIndices) {
const std::vector<std::string> moduleLabels(m_hltConfig.moduleLabels(trigIndex));

// find index of the last module:
const unsigned moduleIndex = m_hltConfig.size(trigIndex) - 2;

// find index of HLT trigger name:
const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(moduleLabels[moduleIndex], "", "HLT"));
float dRMatch = 999.;
for (int trigIdx : trigIndices) {
const std::vector<std::string> trigModuleLabels = m_hltConfig.moduleLabels(trigIdx);

const unsigned trigModuleIndex =
std::find(trigModuleLabels.begin(), trigModuleLabels.end(), "hltBoolEnd") - trigModuleLabels.begin() - 1;
const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(trigModuleLabels[trigModuleIndex], "", "HLT"));
if (hltFilterIndex < trigEvent->sizeFilters()) {
const trigger::Keys triggerKeys(trigEvent->filterKeys(hltFilterIndex));
const trigger::Vids triggerVids(trigEvent->filterIds(hltFilterIndex));

const size_t nTriggers = triggerVids.size();

for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
// loop over all trigger objects:
const trigger::TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];

double dR = deltaR(muon, trigObject);

if (dR < matchDeltaR)
matchDeltaR = dR;

} // loop over different trigger objects

} // if trigger is in event (should apply hltFilter with used trigger...)

} // loop over muon candidates
const trigger::Keys keys = trigEvent->filterKeys(hltFilterIndex);
const trigger::Vids vids = trigEvent->filterIds(hltFilterIndex);
const unsigned nTriggers = vids.size();

for (unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
trigger::TriggerObject trigObj = trigObjs[keys[iTrig]];
float dR = deltaR(muon, trigObj);
if (dR < dRMatch)
dRMatch = dR;
}
}
}

return matchDeltaR < 0.1; //CB should get it programmable
return dRMatch < 0.1; //CB should get it programmable
}

#include "FWCore/PluginManager/interface/ModuleDef.h"
Expand Down

0 comments on commit ba2012e

Please sign in to comment.