Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24: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 /// \ Algorithm for box particle flow super clustering in the ECAL
0057 /*!
0058 
0059   Original Author: Nicolas Chanon
0060   Additional Authors (Mustache): Y. Gershtein, R. Patel, L. Gray
0061   \date July 2012
0062 */
0063 
0064 typedef std::vector<CalibratedPFCluster> CalibratedPFClusterVector;
0065 
0066 class PFECALSuperClusterAlgo {
0067 public:
0068   enum clustering_type { kBOX = 1, kMustache = 2, kDeepSC = 3 };
0069   enum energy_weight { kRaw, kCalibratedNoPS, kCalibratedTotal };
0070 
0071   /// constructor
0072   PFECALSuperClusterAlgo(const reco::SCProducerCache* cache);
0073 
0074   void setVerbosityLevel(bool verbose) { verbose_ = verbose; }
0075 
0076   void setClusteringType(clustering_type thetype) { _clustype = thetype; }
0077 
0078   void setEnergyWeighting(energy_weight thetype) { _eweight = thetype; }
0079 
0080   void setUseETForSeeding(bool useET) { threshIsET_ = useET; }
0081 
0082   void setUseDynamicDPhi(bool useit) { useDynamicDPhi_ = useit; }
0083 
0084   void setUseRegression(bool useRegression) { useRegression_ = useRegression; }
0085 
0086   void setThreshSuperClusterEt(double thresh) { threshSuperClusterEt_ = thresh; }
0087 
0088   void setThreshPFClusterSeedBarrel(double thresh) { threshPFClusterSeedBarrel_ = thresh; }
0089   void setThreshPFClusterBarrel(double thresh) { threshPFClusterBarrel_ = thresh; }
0090   void setThreshPFClusterSeedEndcap(double thresh) { threshPFClusterSeedEndcap_ = thresh; }
0091   void setThreshPFClusterEndcap(double thresh) { threshPFClusterEndcap_ = thresh; }
0092 
0093   void setPhiwidthSuperClusterBarrel(double phiwidth) { phiwidthSuperClusterBarrel_ = phiwidth; }
0094   void setEtawidthSuperClusterBarrel(double etawidth) { etawidthSuperClusterBarrel_ = etawidth; }
0095   void setPhiwidthSuperClusterEndcap(double phiwidth) { phiwidthSuperClusterEndcap_ = phiwidth; }
0096   void setEtawidthSuperClusterEndcap(double etawidth) { etawidthSuperClusterEndcap_ = etawidth; }
0097 
0098   void setPFClusterCalibration(const std::shared_ptr<PFEnergyCalibration>&);
0099 
0100   void setSatelliteMerging(const bool doit) { doSatelliteClusterMerge_ = doit; }
0101   void setSatelliteThreshold(const double t) { satelliteThreshold_ = t; }
0102   void setMajorityFraction(const double f) { fractionForMajority_ = f; }
0103   void setDropUnseedable(const bool d) { dropUnseedable_ = d; }
0104 
0105   void setIsOOTCollection(bool isOOTCollection) { isOOTCollection_ = isOOTCollection; }
0106 
0107   void setCrackCorrections(bool applyCrackCorrections) { applyCrackCorrections_ = applyCrackCorrections; }
0108 
0109   void setTokens(const edm::ParameterSet&, edm::ConsumesCollector&&);
0110 
0111   void update(const edm::EventSetup&);
0112   void updateSCParams(const edm::EventSetup&);
0113 
0114   std::unique_ptr<reco::SuperClusterCollection>& getEBOutputSCCollection() { return superClustersEB_; }
0115   std::unique_ptr<reco::SuperClusterCollection>& getEEOutputSCCollection() { return superClustersEE_; }
0116 
0117   void loadAndSortPFClusters(const edm::Event& evt);
0118 
0119   void run();
0120 
0121 private:
0122   edm::EDGetTokenT<edm::View<reco::PFCluster> > inputTagPFClusters_;
0123   edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> inputTagPFClustersES_;
0124   edm::EDGetTokenT<reco::BeamSpot> inputTagBeamSpot_;
0125 
0126   edm::ESGetToken<ESEEIntercalibConstants, ESEEIntercalibConstantsRcd> esEEInterCalibToken_;
0127   edm::ESGetToken<ESChannelStatus, ESChannelStatusRcd> esChannelStatusToken_;
0128   edm::ESGetToken<EcalMustacheSCParameters, EcalMustacheSCParametersRcd> ecalMustacheSCParametersToken_;
0129   edm::ESGetToken<EcalSCDynamicDPhiParameters, EcalSCDynamicDPhiParametersRcd> ecalSCDynamicDPhiParametersToken_;
0130   edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopologyToken_;
0131   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
0132 
0133   const reco::BeamSpot* beamSpot_;
0134   const ESChannelStatus* channelStatus_;
0135   const CaloGeometry* geometry_;
0136   const CaloSubdetectorGeometry* ebGeom_;
0137   const CaloSubdetectorGeometry* eeGeom_;
0138   const CaloSubdetectorGeometry* esGeom_;
0139   const CaloTopology* topology_;
0140 
0141   const EcalMustacheSCParameters* mustacheSCParams_;
0142   const EcalSCDynamicDPhiParameters* scDynamicDPhiParams_;
0143 
0144   CalibratedPFClusterVector _clustersEB;
0145   CalibratedPFClusterVector _clustersEE;
0146   std::unique_ptr<reco::SuperClusterCollection> superClustersEB_;
0147   std::unique_ptr<reco::SuperClusterCollection> superClustersEE_;
0148   const reco::PFCluster::EEtoPSAssociation* EEtoPS_;
0149   std::shared_ptr<PFEnergyCalibration> _pfEnergyCalibration;
0150   clustering_type _clustype;
0151   energy_weight _eweight;
0152   void buildAllSuperClusters(CalibratedPFClusterVector&, double seedthresh);
0153   void buildAllSuperClustersMustacheOrBox(CalibratedPFClusterVector&, double seedthresh);
0154   void buildAllSuperClustersDeepSC(CalibratedPFClusterVector&, double seedthresh);
0155   void buildSuperClusterMustacheOrBox(CalibratedPFCluster&, CalibratedPFClusterVector&);
0156   void finalizeSuperCluster(CalibratedPFCluster& seed, CalibratedPFClusterVector& clustered, bool isEE);
0157 
0158   bool verbose_;
0159 
0160   // regression
0161   bool useRegression_;
0162   std::unique_ptr<SCEnergyCorrectorSemiParm> regr_;
0163 
0164   double threshSuperClusterEt_;
0165 
0166   double threshPFClusterSeedBarrel_;
0167   double threshPFClusterBarrel_;
0168   double threshPFClusterSeedEndcap_;
0169   double threshPFClusterEndcap_;
0170 
0171   double phiwidthSuperClusterBarrel_;
0172   double etawidthSuperClusterBarrel_;
0173   double phiwidthSuperClusterEndcap_;
0174   double etawidthSuperClusterEndcap_;
0175 
0176   bool doSatelliteClusterMerge_;  //rock it
0177   double satelliteThreshold_, fractionForMajority_;
0178   bool dropUnseedable_;
0179 
0180   bool useDynamicDPhi_;
0181 
0182   bool applyCrackCorrections_;
0183   bool threshIsET_;
0184 
0185   const reco::SCProducerCache* SCProducerCache_;
0186 
0187   // OOT photons
0188   bool isOOTCollection_;
0189   edm::EDGetTokenT<EcalRecHitCollection> inputTagBarrelRecHits_;
0190   edm::EDGetTokenT<EcalRecHitCollection> inputTagEndcapRecHits_;
0191   const EcalRecHitCollection* barrelRecHits_;
0192   const EcalRecHitCollection* endcapRecHits_;
0193 };
0194 
0195 #endif