Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:42

0001 /** \class HLTEgammaEtFilter
0002  *
0003  *
0004  *  \author Monica Vazquez Acosta (CERN)
0005  *
0006  */
0007 
0008 #include "HLTEgammaEtFilter.h"
0009 
0010 #include "DataFormats/Common/interface/Handle.h"
0011 
0012 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 
0016 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0017 
0018 //
0019 // constructors and destructor
0020 //
0021 HLTEgammaEtFilter::HLTEgammaEtFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0022   inputTag_ = iConfig.getParameter<edm::InputTag>("inputTag");
0023   etcutEB_ = iConfig.getParameter<double>("etcutEB");
0024   etcutEE_ = iConfig.getParameter<double>("etcutEE");
0025   ncandcut_ = iConfig.getParameter<int>("ncandcut");
0026   l1EGTag_ = iConfig.getParameter<edm::InputTag>("l1EGCand");
0027   inputToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(inputTag_);
0028 }
0029 
0030 void HLTEgammaEtFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0031   edm::ParameterSetDescription desc;
0032   makeHLTFilterDescription(desc);
0033   desc.add<edm::InputTag>("inputTag", edm::InputTag("HLTEgammaL1MatchFilter"));
0034   desc.add<edm::InputTag>("l1EGCand", edm::InputTag("hltL1IsoRecoEcalCandidate"));
0035   desc.add<double>("etcutEB", 1.0);
0036   desc.add<double>("etcutEE", 1.0);
0037   desc.add<int>("ncandcut", 1);
0038   descriptions.add("hltEgammaEtFilter", desc);
0039 }
0040 
0041 HLTEgammaEtFilter::~HLTEgammaEtFilter() = default;
0042 
0043 // ------------ method called to produce the data  ------------
0044 bool HLTEgammaEtFilter::hltFilter(edm::Event& iEvent,
0045                                   const edm::EventSetup& iSetup,
0046                                   trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0047   using namespace trigger;
0048 
0049   // The filter object
0050   if (saveTags()) {
0051     filterproduct.addCollectionTag(l1EGTag_);
0052     ;
0053   }
0054 
0055   // Ref to Candidate object to be recorded in filter object
0056   edm::Ref<reco::RecoEcalCandidateCollection> ref;
0057 
0058   // get hold of filtered candidates
0059   //edm::Handle<reco::HLTFilterObjectWithRefs> recoecalcands;
0060   edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput;
0061   iEvent.getByToken(inputToken_, PrevFilterOutput);
0062 
0063   std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > recoecalcands;  // vref with your specific C++ collection type
0064   PrevFilterOutput->getObjects(TriggerCluster, recoecalcands);
0065   if (recoecalcands.empty())
0066     PrevFilterOutput->getObjects(TriggerPhoton,
0067                                  recoecalcands);  //we dont know if its type trigger cluster or trigger photon
0068 
0069   // look at all candidates,  check cuts and add to filter object
0070   int n(0);
0071 
0072   for (auto& recoecalcand : recoecalcands) {
0073     ref = recoecalcand;
0074 
0075     if ((fabs(ref->eta()) < 1.479 && ref->et() >= etcutEB_) || (fabs(ref->eta()) >= 1.479 && ref->et() >= etcutEE_)) {
0076       n++;
0077       // std::cout << "Passed eta: " << ref->eta() << std::endl;
0078       filterproduct.addObject(TriggerCluster, ref);
0079     }
0080   }
0081 
0082   // filter decision
0083   bool accept(n >= ncandcut_);
0084 
0085   return accept;
0086 }
0087 
0088 // declare this class as a framework plugin
0089 #include "FWCore/Framework/interface/MakerMacros.h"
0090 DEFINE_FWK_MODULE(HLTEgammaEtFilter);