Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-19 10:28:41

0001 #ifndef GsfElectronAlgo_H
0002 #define GsfElectronAlgo_H
0003 
0004 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0005 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0006 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0007 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
0008 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0009 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0010 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0011 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0012 #include "DataFormats/Common/interface/ValueMap.h"
0013 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0014 #include "DataFormats/EgammaCandidates/interface/GsfElectronCoreFwd.h"
0015 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0016 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0017 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
0018 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0019 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
0020 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrackFwd.h"
0021 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0022 #include "DataFormats/TrackReco/interface/HitPattern.h"
0023 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0024 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0025 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0026 #include "FWCore/Framework/interface/ConsumesCollector.h"
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0031 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0032 #include "MagneticField/Engine/interface/MagneticField.h"
0033 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h"
0034 #include "RecoEgamma/EgammaElectronAlgos/interface/ElectronHcalHelper.h"
0035 #include "RecoEgamma/EgammaElectronAlgos/interface/RegressionHelper.h"
0036 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaRecHitIsolation.h"
0037 #include "RecoEgamma/EgammaIsolationAlgos/interface/EleTkIsolFromCands.h"
0038 #include "RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimator.h"
0039 #include "RecoEgamma/ElectronIdentification/interface/SoftElectronMVAEstimator.h"
0040 #include "RecoEgamma/ElectronIdentification/interface/ElectronDNNEstimator.h"
0041 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
0042 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
0043 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateMode.h"
0044 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateTransform.h"
0045 #include "TrackingTools/GsfTracking/interface/GsfConstraintAtVertex.h"
0046 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0047 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0048 #include "RecoEgamma/EgammaElectronAlgos/interface/ConversionFinder.h"
0049 #include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
0050 #include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
0051 #include "RecoEgamma/EgammaIsolationAlgos/interface/EcalPFClusterIsolation.h"
0052 #include "RecoEgamma/EgammaIsolationAlgos/interface/HcalPFClusterIsolation.h"
0053 
0054 class GsfElectronAlgo {
0055 public:
0056   class HeavyObjectCache {
0057   public:
0058     HeavyObjectCache(const edm::ParameterSet&);
0059     std::unique_ptr<const SoftElectronMVAEstimator> sElectronMVAEstimator;
0060     std::unique_ptr<const ElectronMVAEstimator> iElectronMVAEstimator;
0061     std::unique_ptr<const ElectronDNNEstimator> iElectronDNNEstimator;
0062   };
0063 
0064   struct Tokens {
0065     edm::EDGetTokenT<reco::GsfElectronCoreCollection> gsfElectronCores;
0066     edm::EDGetTokenT<HBHERecHitCollection> hbheRecHitsTag;
0067     edm::EDGetTokenT<reco::SuperClusterCollection> barrelSuperClusters;
0068     edm::EDGetTokenT<reco::SuperClusterCollection> endcapSuperClusters;
0069     edm::EDGetTokenT<EcalRecHitCollection> barrelRecHitCollection;
0070     edm::EDGetTokenT<EcalRecHitCollection> endcapRecHitCollection;
0071     edm::EDGetTokenT<reco::ElectronSeedCollection> seedsTag;
0072     edm::EDGetTokenT<reco::TrackCollection> ctfTracks;
0073     edm::EDGetTokenT<reco::BeamSpot> beamSpotTag;
0074     edm::EDGetTokenT<reco::VertexCollection> vtxCollectionTag;
0075     edm::EDGetTokenT<reco::ConversionCollection> conversions;
0076 
0077     edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducer;
0078     edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHCAL;
0079     edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHFEM;
0080     edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHFHAD;
0081   };
0082 
0083   struct StrategyConfiguration {
0084     // if true, electron preselection is applied
0085     bool applyPreselection;
0086     // if true, electron level escale corrections are
0087     // used on top of the cluster level corrections
0088     bool ecalDrivenEcalEnergyFromClassBasedParameterization;
0089     bool ecalDrivenEcalErrorFromClassBasedParameterization;
0090     bool pureTrackerDrivenEcalErrorFromSimpleParameterization;
0091     // ambiguity solving
0092     bool applyAmbResolution;  // if not true, ambiguity solving is not applied
0093     bool ignoreNotPreselected;
0094     unsigned ambSortingStrategy;          // 0:isBetter, 1:isInnermost
0095     unsigned ambClustersOverlapStrategy;  // 0:sc adresses, 1:bc shared energy
0096     // for backward compatibility
0097     bool ctfTracksCheck;
0098     float PreSelectMVA;
0099     float MaxElePtForOnlyMVA;
0100     bool useDefaultEnergyCorrection;
0101     // GED-Regression (ECAL and combination)
0102     bool useEcalRegression;
0103     bool useCombinationRegression;
0104     //heavy ion in 2015 has no conversions and so cant fill conv vtx fit prob so this bool
0105     //stops it from being filled
0106     bool fillConvVtxFitProb;
0107     // Compute PFcluster isolation for egamma PFID DNN
0108     bool computePfClusterIso;
0109   };
0110 
0111   struct CutsConfiguration {
0112     // minimum SC Et
0113     double minSCEtBarrel;
0114     double minSCEtEndcaps;
0115     // maximum E/p where E is the supercluster corrected energy and p the track momentum at innermost state
0116     double maxEOverPBarrel;
0117     double maxEOverPEndcaps;
0118     // minimum E/p where E is the supercluster corrected energy and p the track momentum at innermost state
0119     double minEOverPBarrel;
0120     double minEOverPEndcaps;
0121 
0122     // H/E
0123     double maxHOverEBarrelCone;
0124     double maxHOverEEndcapsCone;
0125     double maxHBarrelCone;
0126     double maxHEndcapsCone;
0127     double maxHOverEBarrelBc;
0128     double maxHOverEEndcapsBc;
0129     double maxHBarrelBc;
0130     double maxHEndcapsBc;
0131 
0132     // maximum eta difference between the supercluster position and the track position at the closest impact to the supercluster
0133     double maxDeltaEtaBarrel;
0134     double maxDeltaEtaEndcaps;
0135 
0136     // maximum phi difference between the supercluster position and the track position at the closest impact to the supercluster
0137     // position to the supercluster
0138     double maxDeltaPhiBarrel;
0139     double maxDeltaPhiEndcaps;
0140 
0141     // maximum sigma ieta ieta
0142     double maxSigmaIetaIetaBarrel;
0143     double maxSigmaIetaIetaEndcaps;
0144     // maximum fbrem
0145 
0146     double maxFbremBarrel;
0147     double maxFbremEndcaps;
0148 
0149     // fiducial regions
0150     bool isBarrel;
0151     bool isEndcaps;
0152     bool isFiducial;
0153 
0154     // transverse impact parameter wrt beam spot
0155     double maxTIP;
0156 
0157     // only make sense for ecal driven electrons
0158     bool seedFromTEC;
0159 
0160     // noise cleaning
0161     double multThresEB;
0162     double multThresEE;
0163   };
0164 
0165   // Ecal rec hits
0166   struct EcalRecHitsConfiguration {
0167     std::vector<int> recHitFlagsToBeExcludedBarrel;
0168     std::vector<int> recHitFlagsToBeExcludedEndcaps;
0169     std::vector<int> recHitSeverityToBeExcludedBarrel;
0170     std::vector<int> recHitSeverityToBeExcludedEndcaps;
0171     //int severityLevelCut ;
0172   };
0173 
0174   // isolation variables parameters
0175   struct IsolationConfiguration {
0176     double intRadiusHcal;
0177     double etMinHcal;
0178     double intRadiusEcalBarrel;
0179     double intRadiusEcalEndcaps;
0180     double jurassicWidth;
0181     double etMinBarrel;
0182     double eMinBarrel;
0183     double etMinEndcaps;
0184     double eMinEndcaps;
0185     bool vetoClustered;
0186     bool useNumCrystals;
0187   };
0188 
0189   struct PFClusterIsolationConfiguration {
0190     double ecaldrMax;
0191     double ecaldrVetoBarrel;
0192     double ecaldrVetoEndcap;
0193     double ecaletaStripBarrel;
0194     double ecaletaStripEndcap;
0195     double ecalenergyBarrel;
0196     double ecalenergyEndcap;
0197 
0198     bool useHF;
0199     double hcaldrMax;
0200     double hcaldrVetoBarrel;
0201     double hcaldrVetoEndcap;
0202     double hcaletaStripBarrel;
0203     double hcaletaStripEndcap;
0204     double hcalenergyBarrel;
0205     double hcalenergyEndcap;
0206     bool hcaluseEt;
0207   };
0208 
0209   GsfElectronAlgo(const Tokens&,
0210                   const StrategyConfiguration&,
0211                   const CutsConfiguration& cutsCfg,
0212                   const ElectronHcalHelper::Configuration& hcalCone,
0213                   const ElectronHcalHelper::Configuration& hcalBc,
0214                   const IsolationConfiguration&,
0215                   const PFClusterIsolationConfiguration&,
0216                   const EcalRecHitsConfiguration&,
0217                   std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
0218                   const RegressionHelper::Configuration& regCfg,
0219                   const edm::ParameterSet& tkIsol03Cfg,
0220                   const edm::ParameterSet& tkIsol04Cfg,
0221                   const edm::ParameterSet& tkIsolHEEP03Cfg,
0222                   const edm::ParameterSet& tkIsolHEEP04Cfg,
0223                   edm::ConsumesCollector&& cc);
0224 
0225   // main methods
0226   reco::GsfElectronCollection completeElectrons(edm::Event const& event,
0227                                                 edm::EventSetup const& eventSetup,
0228                                                 const HeavyObjectCache* hoc);
0229 
0230 private:
0231   // internal structures
0232 
0233   struct Configuration {
0234     // configurables
0235     const Tokens tokens;
0236     const StrategyConfiguration strategy;
0237     const CutsConfiguration cuts;
0238     const IsolationConfiguration iso;
0239     const PFClusterIsolationConfiguration pfiso;
0240     const EcalRecHitsConfiguration recHits;
0241   };
0242 
0243   struct EventData;
0244   struct ElectronData;
0245 
0246   void checkSetup(edm::EventSetup const& eventSetup);
0247   EventData beginEvent(edm::Event const& event,
0248                        CaloGeometry const& caloGeometry,
0249                        EcalSeverityLevelAlgo const& ecalSeveretyLevelAlgo);
0250 
0251   void createElectron(reco::GsfElectronCollection& electrons,
0252                       ElectronData& electronData,
0253                       EventData& eventData,
0254                       CaloTopology const& topology,
0255                       CaloGeometry const& geometry,
0256                       MultiTrajectoryStateTransform const& mtsTransform,
0257                       double magneticFieldInTesla,
0258                       const HeavyObjectCache*,
0259                       egamma::conv::TrackTableView ctfTable,
0260                       egamma::conv::TrackTableView gsfTable,
0261                       EcalPFRecHitThresholds const& thresholds);
0262 
0263   void setCutBasedPreselectionFlag(reco::GsfElectron& ele, const reco::BeamSpot&) const;
0264 
0265   template <bool full5x5>
0266   reco::GsfElectron::ShowerShape calculateShowerShape(const reco::SuperClusterRef&,
0267                                                       ElectronHcalHelper const& hcalHelperCone,
0268                                                       ElectronHcalHelper const& hcalHelperBc,
0269                                                       EventData const& eventData,
0270                                                       CaloTopology const& topology,
0271                                                       CaloGeometry const& geometry,
0272                                                       EcalPFRecHitThresholds const& thresholds) const;
0273   reco::GsfElectron::SaturationInfo calculateSaturationInfo(const reco::SuperClusterRef&,
0274                                                             EventData const& eventData) const;
0275 
0276   // Pixel match variables
0277   void setPixelMatchInfomation(reco::GsfElectron&) const;
0278 
0279   // constant class members
0280   const Configuration cfg_;
0281 
0282   const EleTkIsolFromCands::Configuration tkIsol03CalcCfg_;
0283   const EleTkIsolFromCands::Configuration tkIsol04CalcCfg_;
0284   const EleTkIsolFromCands::Configuration tkIsolHEEP03CalcCfg_;
0285   const EleTkIsolFromCands::Configuration tkIsolHEEP04CalcCfg_;
0286 
0287   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
0288   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
0289   const edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopologyToken_;
0290   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
0291   const edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> ecalSeveretyLevelAlgoToken_;
0292   const edm::ESGetToken<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd> ecalPFRechitThresholdsToken_;
0293 
0294   // additional configuration and helpers
0295   ElectronHcalHelper hcalHelperCone_;
0296   ElectronHcalHelper hcalHelperBc_;
0297   std::unique_ptr<EcalClusterFunctionBaseClass> crackCorrectionFunction_;
0298   RegressionHelper regHelper_;
0299 
0300   // Algos for PfCluster Isolation
0301   typedef EcalPFClusterIsolation<reco::GsfElectron> ElectronEcalPFClusterIsolation;
0302   std::unique_ptr<ElectronEcalPFClusterIsolation> ecalisoAlgo_;
0303   typedef HcalPFClusterIsolation<reco::GsfElectron> ElectronHcalPFClusterIsolation;
0304   std::unique_ptr<ElectronHcalPFClusterIsolation> hcalisoAlgo_;
0305 };
0306 
0307 #endif  // GsfElectronAlgo_H