Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:41

0001 #include "HLTHcalPhiSymFilter.h"
0002 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 HLTHcalPhiSymFilter::HLTHcalPhiSymFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0006   HBHEHits_ = iConfig.getParameter<edm::InputTag>("HBHEHitCollection");
0007   HOHits_ = iConfig.getParameter<edm::InputTag>("HOHitCollection");
0008   HFHits_ = iConfig.getParameter<edm::InputTag>("HFHitCollection");
0009   phiSymHBHEHits_ = iConfig.getParameter<std::string>("phiSymHBHEHitCollection");
0010   phiSymHOHits_ = iConfig.getParameter<std::string>("phiSymHOHitCollection");
0011   phiSymHFHits_ = iConfig.getParameter<std::string>("phiSymHFHitCollection");
0012 
0013   eCut_HB_ = iConfig.getParameter<double>("eCut_HB");
0014   eCut_HE_ = iConfig.getParameter<double>("eCut_HE");
0015   eCut_HO_ = iConfig.getParameter<double>("eCut_HO");
0016   eCut_HF_ = iConfig.getParameter<double>("eCut_HF");
0017 
0018   HBHEHitsToken_ = consumes<HBHERecHitCollection>(HBHEHits_);
0019   HOHitsToken_ = consumes<HORecHitCollection>(HOHits_);
0020   HFHitsToken_ = consumes<HFRecHitCollection>(HFHits_);
0021 
0022   //register your products
0023   produces<HBHERecHitCollection>(phiSymHBHEHits_);
0024   produces<HORecHitCollection>(phiSymHOHits_);
0025   produces<HFRecHitCollection>(phiSymHFHits_);
0026 }
0027 
0028 HLTHcalPhiSymFilter::~HLTHcalPhiSymFilter() = default;
0029 
0030 void HLTHcalPhiSymFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0031   edm::ParameterSetDescription desc;
0032   makeHLTFilterDescription(desc);
0033   desc.add<edm::InputTag>("HBHEHitCollection", edm::InputTag("hbhereco"));
0034   desc.add<edm::InputTag>("HOHitCollection", edm::InputTag("horeco"));
0035   desc.add<edm::InputTag>("HFHitCollection", edm::InputTag("hfreco"));
0036   desc.add<double>("eCut_HE", -10.);
0037   desc.add<double>("eCut_HF", -10.);
0038   desc.add<double>("eCut_HB", -10.);
0039   desc.add<double>("eCut_HO", -10.);
0040   desc.add<std::string>("phiSymHOHitCollection", "phiSymHcalRecHitsHO");
0041   desc.add<std::string>("phiSymHBHEHitCollection", "phiSymHcalRecHitsHBHE");
0042   desc.add<std::string>("phiSymHFHitCollection", "phiSymHcalRecHitsHF");
0043   descriptions.add("alCaHcalPhiSymStream", desc);
0044 }
0045 
0046 // ------------ method called to produce the data  ------------
0047 bool HLTHcalPhiSymFilter::hltFilter(edm::Event& iEvent,
0048                                     const edm::EventSetup& iSetup,
0049                                     trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0050   edm::Handle<HBHERecHitCollection> HBHERecHitsH;
0051   edm::Handle<HORecHitCollection> HORecHitsH;
0052   edm::Handle<HFRecHitCollection> HFRecHitsH;
0053 
0054   iEvent.getByToken(HBHEHitsToken_, HBHERecHitsH);
0055   iEvent.getByToken(HOHitsToken_, HORecHitsH);
0056   iEvent.getByToken(HFHitsToken_, HFRecHitsH);
0057 
0058   //Create empty output collections
0059   std::unique_ptr<HBHERecHitCollection> phiSymHBHERecHitCollection(new HBHERecHitCollection);
0060   std::unique_ptr<HORecHitCollection> phiSymHORecHitCollection(new HORecHitCollection);
0061   std::unique_ptr<HFRecHitCollection> phiSymHFRecHitCollection(new HFRecHitCollection);
0062 
0063   //Select interesting HBHERecHits
0064   for (auto const& it : *HBHERecHitsH) {
0065     if (it.energy() > eCut_HB_ && it.id().subdet() == 1) {
0066       phiSymHBHERecHitCollection->push_back(it);
0067     }
0068     if (it.energy() > eCut_HE_ && it.id().subdet() == 2) {
0069       phiSymHBHERecHitCollection->push_back(it);
0070     }
0071   }
0072 
0073   //Select interesting HORecHits
0074   for (auto const& it : *HORecHitsH) {
0075     if (it.energy() > eCut_HO_ && it.id().subdet() == 3) {
0076       phiSymHORecHitCollection->push_back(it);
0077     }
0078   }
0079 
0080   //Select interesting HFRecHits
0081   for (auto const& it : *HFRecHitsH) {
0082     if (it.energy() > eCut_HF_ && it.id().subdet() == 4) {
0083       phiSymHFRecHitCollection->push_back(it);
0084     }
0085   }
0086 
0087   if ((phiSymHBHERecHitCollection->empty()) && (phiSymHORecHitCollection->empty()) &&
0088       (phiSymHFRecHitCollection->empty()))
0089     return false;
0090 
0091   //Put selected information in the event
0092   if (!phiSymHBHERecHitCollection->empty())
0093     iEvent.put(std::move(phiSymHBHERecHitCollection), phiSymHBHEHits_);
0094   if (!phiSymHORecHitCollection->empty())
0095     iEvent.put(std::move(phiSymHORecHitCollection), phiSymHOHits_);
0096   if (!phiSymHFRecHitCollection->empty())
0097     iEvent.put(std::move(phiSymHFRecHitCollection), phiSymHFHits_);
0098 
0099   return true;
0100 }
0101 
0102 // declare this class as a framework plugin
0103 #include "FWCore/Framework/interface/MakerMacros.h"
0104 DEFINE_FWK_MODULE(HLTHcalPhiSymFilter);