From 5b54be063822e65a5ab96f1640b9da5edf398eab Mon Sep 17 00:00:00 2001 From: aelwood Date: Wed, 29 Oct 2014 17:52:19 +0100 Subject: [PATCH] Added the new filter --- HLTrigger/JetMET/interface/HLTAlphaTFilter.h | 5 +- HLTrigger/JetMET/src/HLTAlphaTFilter.cc | 192 ++++++++++++++----- 2 files changed, 144 insertions(+), 53 deletions(-) diff --git a/HLTrigger/JetMET/interface/HLTAlphaTFilter.h b/HLTrigger/JetMET/interface/HLTAlphaTFilter.h index ef15f81b717cb..68e25fcd753ab 100644 --- a/HLTrigger/JetMET/interface/HLTAlphaTFilter.h +++ b/HLTrigger/JetMET/interface/HLTAlphaTFilter.h @@ -4,12 +4,14 @@ /** \class HLTAlphaTFilter * * \author Bryn Mathias - * + * \modified Adam Elwood */ #include "HLTrigger/HLTcore/interface/HLTFilter.h" #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" +#include "DataFormats/METReco/interface/MET.h" +#include "DataFormats/METReco/interface/METFwd.h" #include "DataFormats/JetReco/interface/CaloJetCollection.h" #include "DataFormats/JetReco/interface/PFJetCollection.h" @@ -43,6 +45,7 @@ class HLTAlphaTFilter : public HLTFilter { double minHt_; double minAlphaT_; int triggerType_; + bool dynamicAlphaT_; }; #endif // HLTrigger_JetMET_HLTAlphaTFilter_h diff --git a/HLTrigger/JetMET/src/HLTAlphaTFilter.cc b/HLTrigger/JetMET/src/HLTAlphaTFilter.cc index a6ec11e955f39..791e2ece7b9a6 100644 --- a/HLTrigger/JetMET/src/HLTAlphaTFilter.cc +++ b/HLTrigger/JetMET/src/HLTAlphaTFilter.cc @@ -2,6 +2,12 @@ * * * \author Bryn Mathias + * \modified Mark Baber, Adam Elwood + * + * Filter for the AlphaT SUSY analysis + * Makes a trigger decision based on the event HT + * and the AlphaT value. AlphaT cut is chosen + * to reject all the QCD background * */ @@ -35,6 +41,7 @@ HLTAlphaTFilter::HLTAlphaTFilter(const edm::ParameterSet& iConfig) : HLTFilte minHt_ = iConfig.getParameter ("minHt"); minAlphaT_ = iConfig.getParameter ("minAlphaT"); triggerType_ = iConfig.getParameter("triggerType"); + dynamicAlphaT_ = iConfig.getParameter("dynamicAlphaT"); // sanity checks if ( (minPtJet_.size() != etaJet_.size()) @@ -78,6 +85,7 @@ void HLTAlphaTFilter::fillDescriptions(edm::ConfigurationDescriptions& descri desc.add("minHt",0.0); desc.add("minAlphaT",0.0); desc.add("triggerType",trigger::TriggerJet); + desc.add("dynamicAlphaT",true); //Set to reproduce old behaviour descriptions.add(std::string("hlt")+std::string(typeid(HLTAlphaTFilter).name()),desc); } @@ -112,70 +120,150 @@ bool HLTAlphaTFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iS iEvent.getByToken(m_theFastJetToken,recojetsFastJet); + int n(0); + + //OLD - DYNAMIC ALPHAT BEHAVIOUR + //Produce AlphaT dynamically, first on two jets, then three etc until it does + //or doesn't pass + if (dynamicAlphaT_){ + // look at all candidates, check cuts and add to filter object + int flag(0); + double htFast = 0.; + double aT =0.; + unsigned int njets(0); + + if(recojets->size() > 1){ + // events with at least two jets, needed for alphaT + // Make a vector of Lorentz Jets for the AlphaT calcualtion + std::vector jets; + typename TCollection::const_iterator ijet = recojets->begin(); + typename TCollection::const_iterator ijetFast = recojetsFastJet->begin(); + typename TCollection::const_iterator jjet = recojets->end(); + + + + for( ; ijet != jjet; ijet++, ijetFast++ ) { + if( flag == 1) break; + // Do Some Jet selection! + if( std::abs(ijet->eta()) > etaJet_.at(0) ) continue; + if( ijet->et() < minPtJet_.at(0) ) continue; + njets++; + + if (njets > maxNJets_) //to keep timing reasonable - if too many jets passing pt / eta cuts, just accept the event + flag = 1; + + else { + + if( std::abs(ijetFast->eta()) < etaJet_.at(1) ){ + if( ijetFast->et() > minPtJet_.at(1) ) { + // Add to HT + htFast += ijetFast->et(); + } + } + + // Add to JetVector + LorentzV JetLVec(ijet->pt(),ijet->eta(),ijet->phi(),ijet->mass()); + jets.push_back( JetLVec ); + aT = AlphaT(jets).value(); + if(htFast > minHt_ && aT > minAlphaT_){ + // set flat to one so that we don't carry on looping though the jets + flag = 1; + } + } + } + + //If passed, add jets to the filter product for the DQM + if (flag==1) { + for (typename TCollection::const_iterator recojet = recojets->begin(); recojet!=jjet; recojet++) { + if (recojet->et() > minPtJet_.at(0)) { + ref = TRef(recojets,distance(recojets->begin(),recojet)); + filterproduct.addObject(triggerType_,ref); + n++; + } + } + } + }// events with at least two jet + // filter decision + bool accept(n>0); - // look at all candidates, check cuts and add to filter object - int n(0), flag(0); - double htFast = 0.; - unsigned int njets(0); - - if(recojets->size() > 1){ - // events with at least two jets, needed for alphaT - // Make a vector of Lorentz Jets for the AlphaT calcualtion - std::vector jets; + return accept; + } + // NEW - STATIC ALPHAT BEHAVIOUR + // just reproduce + else{ + // look at all candidates, check cuts and add to filter object + int flag(0); typename TCollection::const_iterator ijet = recojets->begin(); - typename TCollection::const_iterator ijetFast = recojetsFastJet->begin(); typename TCollection::const_iterator jjet = recojets->end(); + if( (recojets->size() > 1) && (recojetsFastJet->size() > 1) ){ - for( ; ijet != jjet; ijet++, ijetFast++ ) { - if( flag == 1) break; - // Do Some Jet selection! - if( std::abs(ijet->eta()) > etaJet_.at(0) ) continue; - if( ijet->et() < minPtJet_.at(0) ) continue; - njets++; - - if (njets > maxNJets_) //to keep timing reasonable - if too many jets passing pt / eta cuts, just accept the event - flag = 1; - - else { - - if( std::abs(ijetFast->eta()) < etaJet_.at(1) ){ - if( ijetFast->et() > minPtJet_.at(1) ) { - // Add to HT - htFast += ijetFast->et(); - } - } - - // Add to JetVector - LorentzV JetLVec(ijet->pt(),ijet->eta(),ijet->phi(),ijet->mass()); - jets.push_back( JetLVec ); - double aT = AlphaT(jets).value(); - if(htFast > minHt_ && aT > minAlphaT_){ - // set flat to one so that we don't carry on looping though the jets - flag = 1; - } + // events with at least two jets, needed for alphaT + double htFast = 0.; + typename TCollection::const_iterator ijetFast = recojetsFastJet->begin(); + typename TCollection::const_iterator jjetFast = recojetsFastJet->end(); + for( ; ijetFast != jjetFast; ijetFast++ ) { + if( std::abs(ijetFast->eta()) < etaJet_.at(1) ){ + if( ijetFast->et() > minPtJet_.at(1) ) { + // Add to HT + htFast += ijetFast->et(); + } + } } - } - - if (flag==1) { - for (typename TCollection::const_iterator recojet = recojets->begin(); recojet!=jjet; recojet++) { - if (recojet->et() > minPtJet_.at(0)) { - ref = TRef(recojets,distance(recojets->begin(),recojet)); - filterproduct.addObject(triggerType_,ref); - n++; - } + if(htFast > minHt_){ + + unsigned int njets(0); + // Make a vector of Lorentz Jets for the AlphaT calcualtion + std::vector jets; + for( ; ijet != jjet; ijet++ ) { + if( std::abs(ijet->eta()) > etaJet_.at(0) ) continue; + if( ijet->et() < minPtJet_.at(0) ) continue; + njets++; + + if (njets > maxNJets_) { //to keep timing reasonable - if too many jets passing pt / eta cuts, just accept the event + flag = 1; + break; //Added for efficiency + } + + // Add to JetVector + LorentzV JetLVec(ijet->pt(),ijet->eta(),ijet->phi(),ijet->mass()); + jets.push_back( JetLVec ); + + } + + if(flag!=1){ //Added for efficiency + //Calculate the value for alphaT + float aT = AlphaT(jets).value(); + + // Trigger decision! + if(aT > minAlphaT_){ + flag = 1; + } + } + + //If passed, add the jets to the filterproduct for DQM + if (flag==1) { + for (typename TCollection::const_iterator recojet = recojets->begin(); recojet!=jjet; recojet++) { + if (recojet->et() > minPtJet_.at(0)) { + ref = TRef(recojets,distance(recojets->begin(),recojet)); + filterproduct.addObject(triggerType_,ref); + n++; + } + } + } } - } - }// events with at least two jet - - // filter decision - bool accept(n>0); + }// events with at least two jet + // filter decision + bool accept(n>0); + return accept; + } - return accept; + // THIS WILL NEVER HAPPEN + return true; }