97 virtual void endJob();
152 maxMuon_ = iConfig.
getParameter<
unsigned int>(
"maxMuon");
153 isoTriggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"isoTriggerNames");
160 triggerSummaryLabelToken_ = consumes<trigger::TriggerEvent>(iConfig.
getUntrackedParameter(
"triggerSummaryLabelToken",
edm::InputTag(
"hltTriggerSummaryAOD",
"",
"HLT")));
167 muon_data = muon->getData();
169 tree_=fs_->make<TTree>(
"Muon2RecoTree",
"Muon2RecoTree");
170 tree_->Branch(
"Muon",
"L1Analysis::L1AnalysisRecoMuon2DataFormat", &muon_data, 32000, 3);
172 triggerMaxDeltaR_ = iConfig.
getParameter<
double>(
"triggerMaxDeltaR");
175 isoTriggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"isoTriggerNames");
176 triggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"triggerNames");
213 iEvent.
getByToken(TriggerResultsToken_, triggerResults);
216 iEvent.
getByToken(triggerSummaryLabelToken_, triggerSummaryLabel_);
226 for(reco::PFMETCollection::const_iterator imet = metLabel_->begin();
227 imet != metLabel_->end() && (unsigned) counter_met < 1; imet++) {
235 muon->SetMuon(iEvent, iSetup, recoMuons, vertices, METx, METy, maxMuon_);
243 for(reco::MuonCollection::const_iterator imu = recoMuons->begin();
244 imu != recoMuons->end() && (unsigned) counter_mu < maxMuon_; imu++) {
250 if (triggerMatching_) {
251 double isoMatchDeltaR = 9999.;
252 double matchDeltaR = 9999.;
253 int hasIsoTriggered = 0;
254 int hasTriggered = 0;
256 int passesSingleMuonFlag = 0;
259 if (triggerResults.
isValid()) {
261 if (triggerSummaryLabel_.
isValid()) {
269 for(UInt_t iPath = 0 ; iPath < isoTriggerNames_.size() ; ++iPath)
271 if(passesSingleMuonFlag==1)
continue;
281 if(passTrig) passesSingleMuonFlag=1;
284 if (triggerSummaryLabel_.
isValid()) {
288 matchDeltaR = match_trigger(triggerIndices_, triggerObjects, triggerSummaryLabel_, (*imu));
289 if (matchDeltaR < triggerMaxDeltaR_)
296 isoMatchDeltaR = match_trigger(isoTriggerIndices_, triggerObjects, triggerSummaryLabel_, (*imu));
297 if (isoMatchDeltaR < triggerMaxDeltaR_)
307 muon_data->hlt_isomu.push_back(hasIsoTriggered);
308 muon_data->hlt_mu.push_back(hasTriggered);
309 muon_data->hlt_isoDeltaR.push_back(isoMatchDeltaR);
310 muon_data->hlt_deltaR.push_back(matchDeltaR);
311 muon_data->passesSingleMuon.push_back(passesSingleMuonFlag);
336 muon_data->hlt_isomu.push_back(-9999);
337 muon_data->hlt_mu.push_back(-9999);
338 muon_data->hlt_isoDeltaR.push_back(-9999);
339 muon_data->hlt_deltaR.push_back(-9999);
348 double matchDeltaR = 9999;
350 for(
size_t iTrigIndex = 0; iTrigIndex < trigIndices.size(); ++iTrigIndex) {
351 int triggerIndex = trigIndices[iTrigIndex];
352 const std::vector<std::string> moduleLabels(hltConfig_.moduleLabels(triggerIndex));
354 const unsigned moduleIndex = hltConfig_.size(triggerIndex)-2;
356 const unsigned hltFilterIndex = triggerEvent->
filterIndex(
edm::InputTag ( moduleLabels[moduleIndex],
"", triggerProcessLabel_ ) );
358 if (hltFilterIndex < triggerEvent->sizeFilters()) {
362 const unsigned nTriggers = triggerVids.size();
363 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
367 double dRtmp =
deltaR( mu, trigObject );
369 if ( dRtmp < matchDeltaR ) {
383 if (triggerMatching_) {
385 if (!hltConfig_.init(run, eventSetup, triggerProcessLabel_, changed)) {
387 std::cout <<
"Error: didn't find process" << triggerProcessLabel_ << std::endl;
391 bool enableWildcard =
true;
392 for (
size_t iTrig = 0; iTrig < triggerNames_.size(); ++iTrig) {
394 TString tNameTmp = TString(triggerNames_[iTrig]);
395 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
398 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
400 TString tmpName = TString(hltConfig_.triggerName(ipath));
401 if (tmpName.Contains(tNamePattern)) {
403 triggerIndices_.push_back(tIndex);
407 std::cout <<
"Warning: Could not find trigger" << triggerNames_[iTrig] << std::endl;
411 for (
size_t iTrig = 0; iTrig < isoTriggerNames_.size(); ++iTrig) {
414 TString tNameTmp = TString(isoTriggerNames_[iTrig]);
415 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
418 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
420 TString tmpName = TString(hltConfig_.triggerName(ipath));
421 if (tmpName.Contains(tNamePattern)) {
423 isoTriggerIndices_.push_back(tIndex);
427 std::cout <<
"Warning: Could not find trigger" << isoTriggerNames_[iTrig] << std::endl;
433 muon->init(eventSetup);
L1Analysis::L1AnalysisRecoMuon2DataFormat * muon_data
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
~L1Muon2RecoTreeProducer()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Strings::size_type size() const
Single trigger physics object (e.g., an isolated muon)
double match_trigger(std::vector< int > &trigIndices, const trigger::TriggerObjectCollection &trigObjs, edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon &mu)
const Vids & filterIds(trigger::size_type index) const
edm::EDGetTokenT< reco::MuonCollection > MuonToken_
edm::Service< TFileService > fs_
unsigned int triggerIndex(std::string const &name) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
const TriggerObjectCollection & getObjects() const
static std::string const triggerResults
virtual void analyze(const edm::Event &, const edm::EventSetup &)
HLTConfigProvider hltConfig_
virtual void beginJob(void)
edm::Handle< edm::TriggerResults > isoTriggerToken_
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
static const char *const trigNames[]
std::vector< size_type > Keys
L1Muon2RecoTreeProducer(const edm::ParameterSet &)
std::string triggerProcessLabel_
edm::EDGetTokenT< edm::TriggerResults > TriggerResultsToken_
edm::EDGetTokenT< reco::VertexCollection > VtxToken_
edm::Handle< std::vector< std::string > > isoTriggerNamesToken_
L1Analysis::L1AnalysisRecoMuon2 * muon
std::vector< int > triggerIndices_
std::vector< int > isoTriggerIndices_
edm::EDGetTokenT< trigger::TriggerEvent > triggerSummaryLabelToken_
std::vector< std::string > triggerNames_
edm::EDGetTokenT< reco::PFMETCollection > metToken_
std::vector< std::string > isoTriggerNames_