CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/HLTrigger/HLTfilters/src/HLT1CaloJetEnergy.cc

Go to the documentation of this file.
00001 
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "HLTrigger/HLTfilters/interface/HLT1CaloJetEnergy.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 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00020 
00021 #include "DataFormats/JetReco/interface/CaloJet.h"
00022 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00023 
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 
00026 //
00027 // constructors and destructor
00028 //
00029 HLT1CaloJetEnergy::HLT1CaloJetEnergy(const edm::ParameterSet& iConfig) :
00030   inputTag_ (iConfig.getParameter<edm::InputTag>("inputTag")),
00031   saveTag_  (iConfig.getUntrackedParameter<bool>("saveTag",false)),
00032   min_E_    (iConfig.getParameter<double>       ("MinE"   )),
00033   max_Eta_  (iConfig.getParameter<double>       ("MaxEta"   )),
00034   min_N_    (iConfig.getParameter<int>          ("MinN"   ))
00035 {
00036    LogDebug("") << "Input/ecut/etacut/ncut : "
00037                 << inputTag_.encode() << " "
00038                 << min_E_ << " "
00039                 << max_Eta_ << " "
00040                 << min_N_ ;
00041 
00042    //register your products
00043    produces<trigger::TriggerFilterObjectWithRefs>();
00044 }
00045 
00046 HLT1CaloJetEnergy::~HLT1CaloJetEnergy()
00047 {
00048 }
00049 
00050 //
00051 // member functions
00052 //
00053 
00054 // ------------ method called to produce the data  ------------
00055 bool 
00056 HLT1CaloJetEnergy::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00057 {
00058    using namespace std;
00059    using namespace edm;
00060    using namespace reco;
00061    using namespace trigger;
00062 
00063    // All HLT filters must create and fill an HLT filter object,
00064    // recording any reconstructed physics objects satisfying (or not)
00065    // this HLT filter, and place it in the Event.
00066 
00067    // The filter object
00068    auto_ptr<TriggerFilterObjectWithRefs>
00069      filterobject (new TriggerFilterObjectWithRefs(path(),module()));
00070    if (saveTag_) filterobject->addCollectionTag(inputTag_);
00071    // Ref to Candidate object to be recorded in filter object
00072    Ref<CaloJetCollection> ref;
00073 
00074 
00075    // get hold of collection of objects
00076    Handle<CaloJetCollection> jets;
00077    iEvent.getByLabel (inputTag_,jets);
00078 
00079    // look at all objects, check cuts and add to filter object
00080    int n(0);
00081    CaloJetCollection::const_iterator i ( jets->begin() );
00082    for (; i!=jets->end(); i++) {
00083      if ( i->energy() >= min_E_  &&
00084           fabs(i->eta()) <= max_Eta_   ) {
00085        n++;
00086        ref=Ref<CaloJetCollection>(jets,distance(jets->begin(),i));
00087        filterobject->addObject(TriggerJet,ref);
00088      }
00089    }
00090 
00091    // filter decision
00092    bool accept(n>=min_N_);
00093 
00094    // put filter object into the Event
00095    iEvent.put(filterobject);
00096 
00097    return accept;
00098 }
00099 
00100 
00101 #include "FWCore/Framework/interface/MakerMacros.h"