File indexing completed on 2024-04-06 12:24:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/Candidate/interface/Candidate.h"
0010 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0011 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0012 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0013 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0014 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0015 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0016 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
0017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0018 #include "DataFormats/TrackReco/interface/Track.h"
0019 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0020 #include "FWCore/Framework/interface/ConsumesCollector.h"
0021 #include "FWCore/Framework/interface/ESHandle.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/Utilities/interface/InputTag.h"
0026 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0027 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0028 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0029 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0030 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractor.h"
0031 #include "RecoCaloTools/Selectors/interface/CaloDualConeSelector.h"
0032 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaRecHitIsolation.h"
0033
0034 #include <Math/VectorUtil.h>
0035
0036 #include <vector>
0037 #include <functional>
0038
0039 namespace egammaisolation {
0040
0041 class EgammaHcalExtractor : public reco::isodeposit::IsoDepositExtractor {
0042 public:
0043 EgammaHcalExtractor(const edm::ParameterSet& par, edm::ConsumesCollector&& iC) : EgammaHcalExtractor(par, iC) {}
0044 EgammaHcalExtractor(const edm::ParameterSet& par, edm::ConsumesCollector& iC);
0045
0046 ~EgammaHcalExtractor() override;
0047
0048 void fillVetos(const edm::Event& ev, const edm::EventSetup& evSetup, const reco::TrackCollection& tracks) override {
0049 }
0050 reco::IsoDeposit deposit(const edm::Event& ev,
0051 const edm::EventSetup& evSetup,
0052 const reco::Track& track) const override {
0053 throw cms::Exception("Configuration Error")
0054 << "This extractor " << (typeid(this).name()) << " is not made for tracks";
0055 }
0056 reco::IsoDeposit deposit(const edm::Event& ev,
0057 const edm::EventSetup& evSetup,
0058 const reco::Candidate& c) const override;
0059
0060 private:
0061 double extRadius_;
0062 double intRadius_;
0063 double etLow_;
0064
0065 edm::EDGetTokenT<HBHERecHitCollection> hcalRecHitProducerToken_;
0066 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometryToken_;
0067 };
0068 }
0069
0070 #include "FWCore/Framework/interface/MakerMacros.h"
0071 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractorFactory.h"
0072 DEFINE_EDM_PLUGIN(IsoDepositExtractorFactory, egammaisolation::EgammaHcalExtractor, "EgammaHcalExtractor");
0073
0074 using namespace std;
0075
0076 using namespace egammaisolation;
0077 using namespace reco::isodeposit;
0078
0079 EgammaHcalExtractor::EgammaHcalExtractor(const edm::ParameterSet& par, edm::ConsumesCollector& iC)
0080 : extRadius_(par.getParameter<double>("extRadius")),
0081 intRadius_(par.getParameter<double>("intRadius")),
0082 etLow_(par.getParameter<double>("etMin")),
0083 hcalRecHitProducerToken_(iC.consumes<HBHERecHitCollection>(par.getParameter<edm::InputTag>("hcalRecHits"))),
0084 geometryToken_(iC.esConsumes()) {}
0085
0086 EgammaHcalExtractor::~EgammaHcalExtractor() {}
0087
0088 reco::IsoDeposit EgammaHcalExtractor::deposit(const edm::Event& iEvent,
0089 const edm::EventSetup& iSetup,
0090 const reco::Candidate& emObject) const {
0091
0092 auto const& hcalRecHits = iEvent.get(hcalRecHitProducerToken_);
0093
0094
0095 const CaloGeometry* caloGeom = &iSetup.getData(geometryToken_);
0096 CaloDualConeSelector<HBHERecHit> coneSel(intRadius_, extRadius_, caloGeom, DetId::Hcal);
0097
0098
0099 reco::SuperClusterRef sc = emObject.get<reco::SuperClusterRef>();
0100 math::XYZPoint caloPosition = sc->position();
0101 GlobalPoint point(caloPosition.x(), caloPosition.y(), caloPosition.z());
0102
0103
0104 Direction candDir(caloPosition.eta(), caloPosition.phi());
0105 reco::IsoDeposit deposit(candDir);
0106 deposit.setVeto(reco::IsoDeposit::Veto(candDir, intRadius_));
0107 double sinTheta = sin(2 * atan(exp(-sc->eta())));
0108 deposit.addCandEnergy(sc->energy() * sinTheta);
0109
0110
0111 coneSel.selectCallback(point, hcalRecHits, [&](const HBHERecHit& i) {
0112 const GlobalPoint& hcalHit_position = caloGeom->getPosition(i.detid());
0113 double hcalHit_eta = hcalHit_position.eta();
0114 double hcalHit_Et = i.energy() * sin(2 * atan(exp(-hcalHit_eta)));
0115 if (hcalHit_Et > etLow_) {
0116 deposit.addDeposit(Direction(hcalHit_eta, hcalHit_position.phi()), hcalHit_Et);
0117 }
0118 });
0119
0120 return deposit;
0121 }