File indexing completed on 2024-04-06 12:26:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDProducer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0031
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/Utilities/interface/StreamID.h"
0034 #include <vector>
0035 #include <iostream>
0036 #include "DataFormats/Math/interface/Point3D.h"
0037 #include "DataFormats/TrackReco/interface/Track.h"
0038 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0039 #include "DataFormats/METReco/interface/GlobalHaloData.h"
0040 #include "RecoMET/METAlgorithms/interface/GlobalHaloAlgo.h"
0041 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0042 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0043 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0044 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0045
0046 using namespace reco;
0047
0048 class CaloRecHitsBeamHaloCleaned : public edm::stream::EDProducer<> {
0049 public:
0050 explicit CaloRecHitsBeamHaloCleaned(const edm::ParameterSet&);
0051 ~CaloRecHitsBeamHaloCleaned() override;
0052
0053 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0054
0055 private:
0056 void produce(edm::Event&, const edm::EventSetup&) override;
0057
0058 edm::EDGetTokenT<EcalRecHitCollection> ecalebhits_token;
0059 edm::EDGetTokenT<EcalRecHitCollection> ecaleehits_token;
0060 edm::EDGetTokenT<HBHERecHitCollection> hbhehits_token;
0061 edm::EDGetTokenT<GlobalHaloData> globalhalo_token;
0062
0063
0064 edm::InputTag it_EBRecHits;
0065 edm::InputTag it_EERecHits;
0066 edm::InputTag it_HBHERecHits;
0067 edm::InputTag it_GlobalHaloData;
0068
0069 bool ishlt;
0070 };
0071
0072
0073
0074
0075 CaloRecHitsBeamHaloCleaned::CaloRecHitsBeamHaloCleaned(const edm::ParameterSet& iConfig) {
0076 ishlt = iConfig.getParameter<bool>("IsHLT");
0077
0078 produces<EcalRecHitCollection>("EcalRecHitsEB");
0079 produces<EcalRecHitCollection>("EcalRecHitsEE");
0080 produces<HBHERecHitCollection>();
0081
0082 it_EBRecHits = iConfig.getParameter<edm::InputTag>("EBRecHitsLabel");
0083 it_EERecHits = iConfig.getParameter<edm::InputTag>("EERecHitsLabel");
0084 it_HBHERecHits = iConfig.getParameter<edm::InputTag>("HBHERecHitsLabel");
0085 it_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
0086
0087 ecalebhits_token = consumes<EcalRecHitCollection>(it_EBRecHits);
0088 ecaleehits_token = consumes<EcalRecHitCollection>(it_EERecHits);
0089 hbhehits_token = consumes<HBHERecHitCollection>(it_HBHERecHits);
0090
0091 globalhalo_token = consumes<GlobalHaloData>(it_GlobalHaloData);
0092 }
0093
0094 CaloRecHitsBeamHaloCleaned::~CaloRecHitsBeamHaloCleaned() {
0095
0096
0097 }
0098
0099
0100
0101
0102
0103
0104 void CaloRecHitsBeamHaloCleaned::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0105 using namespace edm;
0106 using namespace reco;
0107 using namespace std;
0108
0109 Handle<EcalRecHitCollection> ebrhitsuncleaned;
0110 iEvent.getByToken(ecalebhits_token, ebrhitsuncleaned);
0111
0112 Handle<EcalRecHitCollection> eerhitsuncleaned;
0113 iEvent.getByToken(ecaleehits_token, eerhitsuncleaned);
0114
0115 Handle<HBHERecHitCollection> hbherhitsuncleaned;
0116 iEvent.getByToken(hbhehits_token, hbherhitsuncleaned);
0117
0118
0119 edm::Handle<reco::GlobalHaloData> TheGlobalHaloData;
0120 iEvent.getByToken(globalhalo_token, TheGlobalHaloData);
0121
0122 const GlobalHaloData TheSummaryHalo = (*TheGlobalHaloData);
0123
0124
0125
0126
0127 auto ebrhitscleaned = std::make_unique<EcalRecHitCollection>();
0128 for (unsigned int i = 0; i < ebrhitsuncleaned->size(); i++) {
0129 const EcalRecHit& rhit = (*ebrhitsuncleaned)[i];
0130 bool isclean(true);
0131 const edm::RefVector<EcalRecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetEBRechits();
0132 for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
0133 const EcalRecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
0134 if (rhit.detid() == rhitbeamhalo.detid()) {
0135 isclean = false;
0136 break;
0137 }
0138 }
0139 if (isclean)
0140 ebrhitscleaned->push_back(rhit);
0141 }
0142
0143
0144 auto eerhitscleaned = std::make_unique<EcalRecHitCollection>();
0145 for (unsigned int i = 0; i < eerhitsuncleaned->size(); i++) {
0146 const EcalRecHit& rhit = (*eerhitsuncleaned)[i];
0147 bool isclean(true);
0148 const edm::RefVector<EcalRecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetEERechits();
0149 for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
0150 const EcalRecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
0151 if (rhit.detid() == rhitbeamhalo.detid()) {
0152 isclean = false;
0153 break;
0154 }
0155 }
0156 if (isclean)
0157 eerhitscleaned->push_back(rhit);
0158 }
0159
0160
0161 auto hbherhitscleaned = std::make_unique<HBHERecHitCollection>();
0162 for (unsigned int i = 0; i < hbherhitsuncleaned->size(); i++) {
0163 const HBHERecHit& rhit = (*hbherhitsuncleaned)[i];
0164 bool isclean(true);
0165 const edm::RefVector<HBHERecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetHBHERechits();
0166 for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
0167 const HBHERecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
0168 if (rhit.detid() == rhitbeamhalo.detid()) {
0169 isclean = false;
0170 break;
0171 }
0172 }
0173 if (isclean)
0174 hbherhitscleaned->push_back(rhit);
0175 }
0176
0177 iEvent.put(std::move(ebrhitscleaned), "EcalRecHitsEB");
0178 iEvent.put(std::move(eerhitscleaned), "EcalRecHitsEE");
0179 iEvent.put(std::move(hbherhitscleaned));
0180 }
0181
0182
0183 void CaloRecHitsBeamHaloCleaned::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0184 edm::ParameterSetDescription desc;
0185 desc.add<edm::InputTag>("EBRecHitsLabel", edm::InputTag("EcalRecHit", "EcalRecHitsEB"));
0186 desc.add<edm::InputTag>("EERecHitsLabel", edm::InputTag("EcalRecHit", "EcalRecHitsEE"));
0187 desc.add<edm::InputTag>("HBHERecHitsLabel", edm::InputTag("hbhereco"));
0188 desc.add<edm::InputTag>("GlobalHaloDataLabel", edm::InputTag("GlobalHaloData"));
0189 desc.add<bool>("IsHLT", false);
0190 descriptions.add("caloRecHitsBeamHaloCleaned", desc);
0191 }
0192
0193
0194 DEFINE_FWK_MODULE(CaloRecHitsBeamHaloCleaned);