Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:41

0001 
0002 #include <memory>
0003 
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/stream/EDProducer.h"
0006 
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/Utilities/interface/StreamID.h"
0012 
0013 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0014 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0015 #include "DataFormats/HeavyIonEvent/interface/HFFilterInfo.h"
0016 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0017 
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFiller.h"
0021 
0022 #include "DataFormats/Common/interface/Wrapper.h"
0023 
0024 #include <cmath>
0025 
0026 class HiHFFilterProducer : public edm::stream::EDProducer<> {
0027 public:
0028   explicit HiHFFilterProducer(const edm::ParameterSet&);
0029   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0030 
0031 private:
0032   void produce(edm::Event&, const edm::EventSetup&) override;
0033   edm::EDGetTokenT<CaloTowerCollection> srcTowers_;
0034 };
0035 
0036 HiHFFilterProducer::HiHFFilterProducer(const edm::ParameterSet& iConfig)
0037     : srcTowers_(consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("srcTowers"))) {
0038   produces<reco::HFFilterInfo>("hiHFfilters");
0039 }
0040 
0041 void HiHFFilterProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0042   using namespace std;
0043   using namespace edm;
0044 
0045   auto const& towers = iEvent.get(srcTowers_);
0046 
0047   unsigned short int nTowersTh2HFplus = 0;
0048   unsigned short int nTowersTh2HFminus = 0;
0049   unsigned short int nTowersTh3HFplus = 0;
0050   unsigned short int nTowersTh3HFminus = 0;
0051   unsigned short int nTowersTh4HFplus = 0;
0052   unsigned short int nTowersTh4HFminus = 0;
0053   unsigned short int nTowersTh5HFplus = 0;
0054   unsigned short int nTowersTh5HFminus = 0;
0055 
0056   auto hiHFFilterResults = std::make_unique<reco::HFFilterInfo>();
0057   for (const auto& tower : towers) {
0058     const auto et = tower.et();
0059     const auto energy = tower.energy();
0060     const auto eta = tower.eta();
0061     const bool eta_plus = (eta > 3.0) && (eta < 6.0);
0062     const bool eta_minus = (eta < -3.0) && (eta > -6.0);
0063     if (et < 0.0)
0064       continue;
0065     if (eta_plus) {
0066       nTowersTh2HFplus += energy >= 2.0 ? 1 : 0;
0067       nTowersTh3HFplus += energy >= 3.0 ? 1 : 0;
0068       nTowersTh4HFplus += energy >= 4.0 ? 1 : 0;
0069       nTowersTh5HFplus += energy >= 5.0 ? 1 : 0;
0070     } else if (eta_minus) {
0071       nTowersTh2HFminus += energy >= 2.0 ? 1 : 0;
0072       nTowersTh3HFminus += energy >= 3.0 ? 1 : 0;
0073       nTowersTh4HFminus += energy >= 4.0 ? 1 : 0;
0074       nTowersTh5HFminus += energy >= 5.0 ? 1 : 0;
0075     }
0076   }
0077 
0078   hiHFFilterResults->numMinHFTowers2 = std::min(nTowersTh2HFplus, nTowersTh2HFminus);
0079   hiHFFilterResults->numMinHFTowers3 = std::min(nTowersTh3HFplus, nTowersTh3HFminus);
0080   hiHFFilterResults->numMinHFTowers4 = std::min(nTowersTh4HFplus, nTowersTh4HFminus);
0081   hiHFFilterResults->numMinHFTowers5 = std::min(nTowersTh5HFplus, nTowersTh5HFminus);
0082 
0083   iEvent.put(std::move(hiHFFilterResults), "hiHFfilters");
0084 }
0085 
0086 void HiHFFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0087   edm::ParameterSetDescription desc;
0088   desc.add<edm::InputTag>("srcTowers", {"towerMaker"});
0089   descriptions.addWithDefaultLabel(desc);
0090 }
0091 
0092 DEFINE_FWK_MODULE(HiHFFilterProducer);