CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/HLTrigger/HLTfilters/src/HLTSinglet.cc

Go to the documentation of this file.
00001 
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "DataFormats/Common/interface/Ref.h"
00017 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00018 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00019 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00020 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00021 
00022 #include "HLTrigger/HLTfilters/interface/HLTSinglet.h"
00023 
00024 #include <typeinfo>
00025 
00026 // extract the candidate type
00027 template<typename T>
00028 int getObjectType(const T &) {
00029   return 0;
00030 }
00031 
00032 // specialize for type l1extra::L1EmParticle
00033 template<typename T>
00034 int getObjectType(const l1extra::L1EmParticle & candidate) {
00035   switch (candidate.type()) {
00036     case l1extra::L1EmParticle::kIsolated:
00037       return trigger::TriggerL1IsoEG;
00038     case l1extra::L1EmParticle::kNonIsolated:
00039       return trigger::TriggerL1NoIsoEG;
00040     default:
00041       return 0;
00042   }
00043 }
00044 
00045 // specialize for type l1extra::L1EtMissParticle
00046 template<typename T>
00047 int getObjectType(const l1extra::L1EtMissParticle & candidate) {
00048   switch (candidate.type()) {
00049     case l1extra::L1EtMissParticle::kMET:
00050       return trigger::TriggerL1ETM;
00051     case l1extra::L1EtMissParticle::kMHT:
00052       return trigger::TriggerL1HTM;
00053     default:
00054       return 0;
00055   }
00056 }
00057 
00058 // specialize for type l1extra::L1JetParticle
00059 template<typename T>
00060 int getObjectType(const l1extra::L1JetParticle & candidate) {
00061   switch (candidate.type()) {
00062     case l1extra::L1JetParticle::kCentral:
00063       return trigger::TriggerL1CenJet;
00064     case l1extra::L1JetParticle::kForward:
00065       return trigger::TriggerL1ForJet;
00066     case l1extra::L1JetParticle::kTau:
00067       return trigger::TriggerL1TauJet;
00068     default:
00069       return 0;
00070   }
00071 }
00072 
00073 
00074 //
00075 // constructors and destructor
00076 //
00077 template<typename T>
00078 HLTSinglet<T>::HLTSinglet(const edm::ParameterSet& iConfig) : HLTFilter(iConfig), 
00079   inputTag_    (iConfig.template getParameter<edm::InputTag>("inputTag")),
00080   triggerType_ (iConfig.template getParameter<int>("triggerType")),
00081   min_E_    (iConfig.template getParameter<double>       ("MinE"    )),
00082   min_Pt_   (iConfig.template getParameter<double>       ("MinPt"   )),
00083   min_Mass_ (iConfig.template getParameter<double>       ("MinMass" )),
00084   max_Eta_  (iConfig.template getParameter<double>       ("MaxEta"  )),
00085   min_N_    (iConfig.template getParameter<int>          ("MinN"    )),
00086   tid_ (triggerType_)
00087 {
00088    LogDebug("") << "Input/ptcut/etacut/ncut : "
00089                 << inputTag_.encode() << " "
00090                 << min_E_ << " " << min_Pt_ << " " << min_Mass_ << " " 
00091                 << max_Eta_ << " " << min_N_ ;
00092 }
00093 
00094 template<typename T>
00095 HLTSinglet<T>::~HLTSinglet()
00096 {
00097 }
00098 
00099 template<typename T>
00100 void
00101 HLTSinglet<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00102   edm::ParameterSetDescription desc;
00103   makeHLTFilterDescription(desc);
00104   desc.add<edm::InputTag>("inputTag",edm::InputTag("hltCollection"));
00105   desc.add<int>("triggerType",0);
00106   desc.add<double>("MinE",-1.0);
00107   desc.add<double>("MinPt",-1.0);
00108   desc.add<double>("MinMass",-1.0);
00109   desc.add<double>("MaxEta",-1.0);
00110   desc.add<int>("MinN",1);
00111   descriptions.add(std::string("hlt")+std::string(typeid(HLTSinglet<T>).name()),desc);
00112 }
00113 
00114 //
00115 // member functions
00116 //
00117 
00118 // ------------ method called to produce the data  ------------
00119 template<typename T> 
00120 bool
00121 HLTSinglet<T>::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct)
00122 {
00123    using namespace std;
00124    using namespace edm;
00125    using namespace reco;
00126    using namespace trigger;
00127 
00128    typedef vector<T> TCollection;
00129    typedef Ref<TCollection> TRef;
00130 
00131    // All HLT filters must create and fill an HLT filter object,
00132    // recording any reconstructed physics objects satisfying (or not)
00133    // this HLT filter, and place it in the Event.
00134 
00135    // The filter object
00136    if (saveTags()) filterproduct.addCollectionTag(inputTag_);
00137 
00138    // Ref to Candidate object to be recorded in filter object
00139    TRef ref;
00140 
00141 
00142    // get hold of collection of objects
00143    Handle<TCollection> objects;
00144    iEvent.getByLabel (inputTag_,objects);
00145 
00146    // look at all objects, check cuts and add to filter object
00147    int n(0);
00148    typename TCollection::const_iterator i ( objects->begin() );
00149    for (; i!=objects->end(); i++) {
00150      if ( (i->energy() >= min_E_) &&
00151           (i->pt() >= min_Pt_) && 
00152           (i->mass() >= min_Mass_) && 
00153           ( (max_Eta_ < 0.0) || (std::abs(i->eta()) <= max_Eta_) ) ) {
00154        n++;
00155        ref=TRef(objects,distance(objects->begin(),i));
00156        tid_=getObjectType<T>(*i);
00157        if (tid_==0) tid_=triggerType_;
00158        filterproduct.addObject(tid_,ref);
00159      }
00160    }
00161 
00162    // filter decision
00163    bool accept(n>=min_N_);
00164 
00165    return accept;
00166 }