File indexing completed on 2022-06-20 22:43:38
0001 #ifndef RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgo_h
0002 #define RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgo_h
0003
0004 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0006 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
0007 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
0008 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
0009 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0010
0011 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0012 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0013 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0014 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0015
0016 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0017 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0018 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0019 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0020
0021 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0022 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0023 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0024 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0025 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0026
0027 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"
0028
0029 #include "RecoEcal/EgammaClusterAlgos/interface/SCEnergyCorrectorSemiParm.h"
0030 #include "RecoEcal/EgammaCoreTools/interface/EcalClustersGraph.h"
0031 #include "RecoEcal/EgammaCoreTools/interface/CalibratedPFCluster.h"
0032
0033 #include "FWCore/Framework/interface/Event.h"
0034 #include "FWCore/Framework/interface/ESHandle.h"
0035 #include "FWCore/Framework/interface/EventSetup.h"
0036
0037 #include "FWCore/Utilities/interface/InputTag.h"
0038 #include "FWCore/Framework/interface/ConsumesCollector.h"
0039 #include "FWCore/Utilities/interface/ESGetToken.h"
0040
0041 #include "CondFormats/ESObjects/interface/ESChannelStatus.h"
0042 #include "CondFormats/DataRecord/interface/ESEEIntercalibConstantsRcd.h"
0043 #include "CondFormats/DataRecord/interface/ESChannelStatusRcd.h"
0044 #include "CondFormats/ESObjects/interface/ESEEIntercalibConstants.h"
0045
0046 #include "CondFormats/EcalObjects/interface/EcalMustacheSCParameters.h"
0047 #include "CondFormats/DataRecord/interface/EcalMustacheSCParametersRcd.h"
0048 #include "CondFormats/EcalObjects/interface/EcalSCDynamicDPhiParameters.h"
0049 #include "CondFormats/DataRecord/interface/EcalSCDynamicDPhiParametersRcd.h"
0050
0051 #include "RecoEcal/EgammaCoreTools/interface/SCProducerCache.h"
0052
0053 #include <vector>
0054 #include <memory>
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 typedef std::shared_ptr<CalibratedPFCluster> CalibratedClusterPtr;
0065 typedef std::vector<CalibratedClusterPtr> CalibratedClusterPtrVector;
0066
0067 class PFECALSuperClusterAlgo {
0068 public:
0069 enum clustering_type { kBOX = 1, kMustache = 2, kDeepSC = 3 };
0070 enum energy_weight { kRaw, kCalibratedNoPS, kCalibratedTotal };
0071
0072
0073 PFECALSuperClusterAlgo(const reco::SCProducerCache* cache);
0074
0075 void setVerbosityLevel(bool verbose) { verbose_ = verbose; }
0076
0077 void setClusteringType(clustering_type thetype) { _clustype = thetype; }
0078
0079 void setEnergyWeighting(energy_weight thetype) { _eweight = thetype; }
0080
0081 void setUseETForSeeding(bool useET) { threshIsET_ = useET; }
0082
0083 void setUseDynamicDPhi(bool useit) { useDynamicDPhi_ = useit; }
0084
0085 void setUseRegression(bool useRegression) { useRegression_ = useRegression; }
0086
0087 void setThreshSuperClusterEt(double thresh) { threshSuperClusterEt_ = thresh; }
0088
0089 void setThreshPFClusterSeedBarrel(double thresh) { threshPFClusterSeedBarrel_ = thresh; }
0090 void setThreshPFClusterBarrel(double thresh) { threshPFClusterBarrel_ = thresh; }
0091 void setThreshPFClusterSeedEndcap(double thresh) { threshPFClusterSeedEndcap_ = thresh; }
0092 void setThreshPFClusterEndcap(double thresh) { threshPFClusterEndcap_ = thresh; }
0093
0094 void setPhiwidthSuperClusterBarrel(double phiwidth) { phiwidthSuperClusterBarrel_ = phiwidth; }
0095 void setEtawidthSuperClusterBarrel(double etawidth) { etawidthSuperClusterBarrel_ = etawidth; }
0096 void setPhiwidthSuperClusterEndcap(double phiwidth) { phiwidthSuperClusterEndcap_ = phiwidth; }
0097 void setEtawidthSuperClusterEndcap(double etawidth) { etawidthSuperClusterEndcap_ = etawidth; }
0098
0099 void setPFClusterCalibration(const std::shared_ptr<PFEnergyCalibration>&);
0100
0101 void setSatelliteMerging(const bool doit) { doSatelliteClusterMerge_ = doit; }
0102 void setSatelliteThreshold(const double t) { satelliteThreshold_ = t; }
0103 void setMajorityFraction(const double f) { fractionForMajority_ = f; }
0104 void setDropUnseedable(const bool d) { dropUnseedable_ = d; }
0105
0106 void setIsOOTCollection(bool isOOTCollection) { isOOTCollection_ = isOOTCollection; }
0107
0108 void setCrackCorrections(bool applyCrackCorrections) { applyCrackCorrections_ = applyCrackCorrections; }
0109
0110 void setTokens(const edm::ParameterSet&, edm::ConsumesCollector&&);
0111
0112 void update(const edm::EventSetup&);
0113 void updateSCParams(const edm::EventSetup&);
0114
0115 std::unique_ptr<reco::SuperClusterCollection>& getEBOutputSCCollection() { return superClustersEB_; }
0116 std::unique_ptr<reco::SuperClusterCollection>& getEEOutputSCCollection() { return superClustersEE_; }
0117
0118 void loadAndSortPFClusters(const edm::Event& evt);
0119
0120 void run();
0121
0122 private:
0123 edm::EDGetTokenT<edm::View<reco::PFCluster> > inputTagPFClusters_;
0124 edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> inputTagPFClustersES_;
0125 edm::EDGetTokenT<reco::BeamSpot> inputTagBeamSpot_;
0126
0127 edm::ESGetToken<ESEEIntercalibConstants, ESEEIntercalibConstantsRcd> esEEInterCalibToken_;
0128 edm::ESGetToken<ESChannelStatus, ESChannelStatusRcd> esChannelStatusToken_;
0129 edm::ESGetToken<EcalMustacheSCParameters, EcalMustacheSCParametersRcd> ecalMustacheSCParametersToken_;
0130 edm::ESGetToken<EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcd> ecalSCDynamicDPhiParametersToken_;
0131 edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopologyToken_;
0132 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
0133
0134 const reco::BeamSpot* beamSpot_;
0135 const ESChannelStatus* channelStatus_;
0136 const CaloGeometry* geometry_;
0137 const CaloSubdetectorGeometry* ebGeom_;
0138 const CaloSubdetectorGeometry* eeGeom_;
0139 const CaloSubdetectorGeometry* esGeom_;
0140 const CaloTopology* topology_;
0141
0142 const EcalMustacheSCParameters* mustacheSCParams_;
0143 const EcalSCDynamicDPhiParameters* scDynamicDPhiParams_;
0144
0145 CalibratedClusterPtrVector _clustersEB;
0146 CalibratedClusterPtrVector _clustersEE;
0147 std::unique_ptr<reco::SuperClusterCollection> superClustersEB_;
0148 std::unique_ptr<reco::SuperClusterCollection> superClustersEE_;
0149 const reco::PFCluster::EEtoPSAssociation* EEtoPS_;
0150 std::shared_ptr<PFEnergyCalibration> _pfEnergyCalibration;
0151 clustering_type _clustype;
0152 energy_weight _eweight;
0153 void buildAllSuperClusters(CalibratedClusterPtrVector&, double seedthresh);
0154 void buildAllSuperClustersMustacheOrBox(CalibratedClusterPtrVector&, double seedthresh);
0155 void buildAllSuperClustersDeepSC(CalibratedClusterPtrVector&, double seedthresh);
0156 void buildSuperClusterMustacheOrBox(CalibratedClusterPtr&, CalibratedClusterPtrVector&);
0157 void finalizeSuperCluster(CalibratedClusterPtr& seed, CalibratedClusterPtrVector& clustered, bool isEE);
0158
0159 bool verbose_;
0160
0161
0162 bool useRegression_;
0163 std::unique_ptr<SCEnergyCorrectorSemiParm> regr_;
0164
0165 double threshSuperClusterEt_;
0166
0167 double threshPFClusterSeedBarrel_;
0168 double threshPFClusterBarrel_;
0169 double threshPFClusterSeedEndcap_;
0170 double threshPFClusterEndcap_;
0171
0172 double phiwidthSuperClusterBarrel_;
0173 double etawidthSuperClusterBarrel_;
0174 double phiwidthSuperClusterEndcap_;
0175 double etawidthSuperClusterEndcap_;
0176
0177 bool doSatelliteClusterMerge_;
0178 double satelliteThreshold_, fractionForMajority_;
0179 bool dropUnseedable_;
0180
0181 bool useDynamicDPhi_;
0182
0183 bool applyCrackCorrections_;
0184 bool threshIsET_;
0185
0186 const reco::SCProducerCache* SCProducerCache_;
0187
0188
0189 bool isOOTCollection_;
0190 edm::EDGetTokenT<EcalRecHitCollection> inputTagBarrelRecHits_;
0191 edm::EDGetTokenT<EcalRecHitCollection> inputTagEndcapRecHits_;
0192 const EcalRecHitCollection* barrelRecHits_;
0193 const EcalRecHitCollection* endcapRecHits_;
0194 };
0195
0196 #endif