Go to the documentation of this file.00001
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "HLTrigger/HLTfilters/interface/HLTSinglet.h"
00014
00015 #include "DataFormats/Common/interface/Handle.h"
00016
00017 #include "DataFormats/Common/interface/Ref.h"
00018 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00019
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021
00022
00023
00024
00025 template<typename T, int Tid>
00026 HLTSinglet<T,Tid>::HLTSinglet(const edm::ParameterSet& iConfig) :
00027 inputTag_ (iConfig.template getParameter<edm::InputTag>("inputTag")),
00028 saveTag_ (iConfig.template getUntrackedParameter<bool>("saveTag",false)),
00029 min_Pt_ (iConfig.template getParameter<double> ("MinPt" )),
00030 max_Eta_ (iConfig.template getParameter<double> ("MaxEta" )),
00031 min_N_ (iConfig.template getParameter<int> ("MinN" ))
00032 {
00033 LogDebug("") << "Input/ptcut/etacut/ncut : "
00034 << inputTag_.encode() << " "
00035 << min_Pt_ << " " << max_Eta_ << " " << min_N_ ;
00036
00037
00038 produces<trigger::TriggerFilterObjectWithRefs>();
00039 }
00040
00041 template<typename T, int Tid>
00042 HLTSinglet<T,Tid>::~HLTSinglet()
00043 {
00044 }
00045
00046
00047
00048
00049
00050
00051 template<typename T, int Tid>
00052 bool
00053 HLTSinglet<T,Tid>::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00054 {
00055 using namespace std;
00056 using namespace edm;
00057 using namespace reco;
00058 using namespace trigger;
00059
00060 typedef vector<T> TCollection;
00061 typedef Ref<TCollection> TRef;
00062
00063
00064
00065
00066
00067
00068 auto_ptr<TriggerFilterObjectWithRefs>
00069 filterobject (new TriggerFilterObjectWithRefs(path(),module()));
00070 if (saveTag_) filterobject->addCollectionTag(inputTag_);
00071
00072 TRef ref;
00073
00074
00075
00076 Handle<TCollection> objects;
00077 iEvent.getByLabel (inputTag_,objects);
00078
00079
00080 int n(0);
00081 typename TCollection::const_iterator i ( objects->begin() );
00082 for (; i!=objects->end(); i++) {
00083 if ( (i->pt() >= min_Pt_) &&
00084 ( (max_Eta_ < 0.0) || (std::abs(i->eta()) <= max_Eta_) ) ) {
00085 n++;
00086 ref=TRef(objects,distance(objects->begin(),i));
00087 filterobject->addObject(Tid,ref);
00088 }
00089 }
00090
00091
00092 bool accept(n>=min_N_);
00093
00094
00095 iEvent.put(filterobject);
00096
00097 return accept;
00098 }