88 virtual void endJob();
140 maxMuon_ = iConfig.
getParameter<
unsigned int>(
"maxMuon");
146 triggerSummaryLabelToken_ = consumes<trigger::TriggerEvent>(iConfig.
getUntrackedParameter(
"triggerSummaryLabelToken",
edm::InputTag(
"hltTriggerSummaryAOD",
"",
"HLT")));
152 muon_data = muon->getData();
154 tree_=fs_->make<TTree>(
"Muon2RecoTree",
"Muon2RecoTree");
155 tree_->Branch(
"Muon",
"L1Analysis::L1AnalysisRecoMuon2DataFormat", &muon_data, 32000, 3);
157 triggerMaxDeltaR_ = iConfig.
getParameter<
double>(
"triggerMaxDeltaR");
160 isoTriggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"isoTriggerNames");
161 triggerNames_ = iConfig.
getParameter<std::vector<std::string>>(
"triggerNames");
195 iEvent.
getByToken(TriggerResultsToken_, triggerResults);
198 iEvent.
getByToken(triggerSummaryLabelToken_, triggerSummaryLabel_);
201 muon->SetMuon(iEvent, iSetup, recoMuons, maxMuon_);
209 for(reco::MuonCollection::const_iterator imu = recoMuons->begin();
210 imu != recoMuons->end() && (unsigned) counter_mu < maxMuon_; imu++) {
216 if (triggerMatching_) {
217 double isoMatchDeltaR = 9999.;
218 double matchDeltaR = 9999.;
219 int hasIsoTriggered = 0;
220 int hasTriggered = 0;
224 if (triggerResults.
isValid()) {
226 if (triggerSummaryLabel_.
isValid()) {
230 matchDeltaR = match_trigger(triggerIndices_, triggerObjects, triggerSummaryLabel_, (*imu));
231 if (matchDeltaR < triggerMaxDeltaR_)
238 isoMatchDeltaR = match_trigger(isoTriggerIndices_, triggerObjects, triggerSummaryLabel_, (*imu));
239 if (isoMatchDeltaR < triggerMaxDeltaR_)
247 muon_data->hlt_isomu.push_back(hasIsoTriggered);
248 muon_data->hlt_mu.push_back(hasTriggered);
249 muon_data->hlt_isoDeltaR.push_back(isoMatchDeltaR);
250 muon_data->hlt_deltaR.push_back(matchDeltaR);
275 muon_data->hlt_isomu.push_back(-9999);
276 muon_data->hlt_mu.push_back(-9999);
277 muon_data->hlt_isoDeltaR.push_back(-9999);
278 muon_data->hlt_deltaR.push_back(-9999);
287 double matchDeltaR = 9999;
289 for(
size_t iTrigIndex = 0; iTrigIndex < trigIndices.size(); ++iTrigIndex) {
290 int triggerIndex = trigIndices[iTrigIndex];
291 const std::vector<std::string> moduleLabels(hltConfig_.moduleLabels(triggerIndex));
293 const unsigned moduleIndex = hltConfig_.size(triggerIndex)-2;
295 const unsigned hltFilterIndex = triggerEvent->filterIndex(
edm::InputTag ( moduleLabels[moduleIndex],
"", triggerProcessLabel_ ) );
297 if (hltFilterIndex < triggerEvent->sizeFilters()) {
298 const trigger::Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
299 const trigger::Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
301 const unsigned nTriggers = triggerVids.size();
302 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
306 double dRtmp =
deltaR( mu, trigObject );
308 if ( dRtmp < matchDeltaR ) {
322 if (triggerMatching_) {
324 if (!hltConfig_.init(run, eventSetup, triggerProcessLabel_, changed)) {
326 std::cout <<
"Error: didn't find process" << triggerProcessLabel_ << std::endl;
330 bool enableWildcard =
true;
331 for (
size_t iTrig = 0; iTrig < triggerNames_.size(); ++iTrig) {
333 TString tNameTmp = TString(triggerNames_[iTrig]);
334 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
337 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
339 TString tmpName = TString(hltConfig_.triggerName(ipath));
340 if (tmpName.Contains(tNamePattern)) {
342 triggerIndices_.push_back(tIndex);
346 std::cout <<
"Warning: Could not find trigger" << triggerNames_[iTrig] << std::endl;
350 for (
size_t iTrig = 0; iTrig < isoTriggerNames_.size(); ++iTrig) {
353 TString tNameTmp = TString(isoTriggerNames_[iTrig]);
354 TRegexp tNamePattern = TRegexp(tNameTmp, enableWildcard);
357 for (
unsigned ipath = 0; ipath < hltConfig_.size(); ++ipath) {
359 TString tmpName = TString(hltConfig_.triggerName(ipath));
360 if (tmpName.Contains(tNamePattern)) {
362 isoTriggerIndices_.push_back(tIndex);
366 std::cout <<
"Warning: Could not find trigger" << isoTriggerNames_[iTrig] << std::endl;
L1Analysis::L1AnalysisRecoMuon2DataFormat * muon_data
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
~L1Muon2RecoTreeProducer()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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)
edm::EDGetTokenT< reco::MuonCollection > MuonToken_
edm::Service< TFileService > fs_
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
static std::string const triggerResults
virtual void analyze(const edm::Event &, const edm::EventSetup &)
HLTConfigProvider hltConfig_
virtual void beginJob(void)
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
std::vector< size_type > Keys
L1Muon2RecoTreeProducer(const edm::ParameterSet &)
std::string triggerProcessLabel_
edm::EDGetTokenT< edm::TriggerResults > TriggerResultsToken_
L1Analysis::L1AnalysisRecoMuon2 * muon
std::vector< int > triggerIndices_
std::vector< int > isoTriggerIndices_
edm::EDGetTokenT< trigger::TriggerEvent > triggerSummaryLabelToken_
std::vector< std::string > triggerNames_
std::vector< std::string > isoTriggerNames_