Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-05 00:08:06

0001 // -*- C++ -*-
0002 //
0003 // Package:    METAlgorithms
0004 // Class:      TCMETAlgo
0005 //
0006 //
0007 
0008 /** \class TCMETAlgo
0009 
0010    Calculates TCMET based on detector response to charged paricles
0011    using the tracker to correct for the non-linearity of the
0012    calorimeter and the displacement of charged particles by the
0013    B-field. Given a track pt, eta the expected energy deposited in the
0014    calorimeter is obtained from a lookup table, removed from the
0015    calorimeter, and replaced with the track at the vertex.
0016 
0017 */
0018 //
0019 // Original Author:  F. Golf
0020 //         Created:  March 24, 2009
0021 //
0022 //
0023 
0024 //____________________________________________________________________________||
0025 #ifndef TCMETAlgo_h
0026 #define TCMETAlgo_h
0027 
0028 //____________________________________________________________________________||
0029 #include <vector>
0030 #include <string>
0031 #include "FWCore/Framework/interface/Event.h"
0032 #include "DataFormats/Common/interface/Handle.h"
0033 #include "FWCore/Framework/interface/ESHandle.h"
0034 #include "FWCore/Framework/interface/EventSetup.h"
0035 #include "DataFormats/Common/interface/ValueMap.h"
0036 
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0039 #include "DataFormats/METReco/interface/CommonMETData.h"
0040 #include "DataFormats/METReco/interface/MET.h"
0041 
0042 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0043 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0044 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0045 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0046 
0047 #include "DataFormats/MuonReco/interface/Muon.h"
0048 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0049 #include "DataFormats/TrackReco/interface/TrackBase.h"
0050 #include "DataFormats/VertexReco/interface/Vertex.h"
0051 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0052 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0053 #include "DataFormats/METReco/interface/CaloMET.h"
0054 #include "DataFormats/METReco/interface/CaloMETCollection.h"
0055 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0056 #include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
0057 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0058 
0059 #include "MagneticField/Engine/interface/MagneticField.h"
0060 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0061 
0062 #include "FWCore/Framework/interface/ConsumesCollector.h"
0063 
0064 #include "TH2D.h"
0065 #include "TVector3.h"
0066 
0067 //____________________________________________________________________________||
0068 class TCMETAlgo {
0069 public:
0070   typedef std::vector<const reco::Candidate> InputCollection;
0071   TCMETAlgo();
0072   virtual ~TCMETAlgo();
0073   reco::MET CalculateTCMET(edm::Event& event, const edm::EventSetup& setup);
0074   TH2D* getResponseFunction_fit();
0075   TH2D* getResponseFunction_mode();
0076   TH2D* getResponseFunction_shower();
0077   TH2D* getResponseFunction_noshower();
0078   void configure(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iConsumesCollector);
0079 
0080 private:
0081   double met_x_;
0082   double met_y_;
0083   double sumEt_;
0084 
0085   void initialize_MET_with_PFClusters(edm::Event& event);
0086   void initialize_MET_with_CaloMET(edm::Event& event);
0087   void correct_MET_for_Muons();
0088   void correct_MET_for_Tracks();
0089 
0090   edm::Handle<reco::MuonCollection> muonHandle_;
0091   edm::Handle<reco::GsfElectronCollection> electronHandle_;
0092   edm::Handle<reco::TrackCollection> trackHandle_;
0093   edm::Handle<reco::BeamSpot> beamSpotHandle_;
0094   edm::Handle<reco::VertexCollection> vertexHandle_;
0095   edm::Handle<edm::ValueMap<reco::MuonMETCorrectionData> > muonDepValueMapHandle_;
0096   edm::Handle<edm::ValueMap<reco::MuonMETCorrectionData> > tcmetDepValueMapHandle_;
0097 
0098   edm::ESHandle<MagneticField> magneticFieldHandle_;
0099 
0100   edm::EDGetTokenT<reco::MuonCollection> muonToken_;
0101   edm::EDGetTokenT<reco::GsfElectronCollection> electronToken_;
0102   edm::EDGetTokenT<edm::View<reco::MET> > metToken_;
0103   edm::EDGetTokenT<reco::TrackCollection> trackToken_;
0104   edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_;
0105   edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
0106   edm::EDGetTokenT<reco::PFClusterCollection> clustersECALToken_;
0107   edm::EDGetTokenT<reco::PFClusterCollection> clustersHCALToken_;
0108   edm::EDGetTokenT<reco::PFClusterCollection> clustersHFToken_;
0109   edm::EDGetTokenT<edm::ValueMap<reco::MuonMETCorrectionData> > muonDepValueMapToken_;
0110   edm::EDGetTokenT<edm::ValueMap<reco::MuonMETCorrectionData> > tcmetDepValueMapToken_;
0111   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
0112 
0113   bool usePFClusters_;
0114   int nLayers_;
0115   int nLayersTight_;
0116   int vertexNdof_;
0117   double vertexZ_;
0118   double vertexRho_;
0119   double vertexMaxDZ_;
0120   double maxpt_eta25_;
0121   double maxpt_eta20_;
0122   bool vetoDuplicates_;
0123   double dupMinPt_;
0124   double dupDPhi_;
0125   double dupDCotTh_;
0126   std::vector<int> duplicateTracks_;
0127 
0128   double d0cuta_;
0129   double d0cutb_;
0130   double maxd0cut_;
0131   double maxchi2_tight_;
0132   double minhits_tight_;
0133   double maxPtErr_tight_;
0134   int nMinOuterHits_;
0135   std::vector<reco::TrackBase::TrackAlgorithm> trackAlgos_;
0136   double usedeltaRRejection_;
0137   double deltaRShower_;
0138   double minpt_;
0139   double maxpt_;
0140   double maxeta_;
0141   double maxchi2_;
0142   double minhits_;
0143   double maxPtErr_;
0144   double radius_;
0145   double zdist_;
0146   double corner_;
0147   double eVetoDeltaR_;
0148   double eVetoDeltaPhi_;
0149   double eVetoDeltaCotTheta_;
0150   double eVetoMinElectronPt_;
0151   double hOverECut_;
0152   std::vector<int> trkQuality_;
0153   std::vector<reco::TrackBase::TrackAlgorithm> trkAlgos_;
0154 
0155   bool isCosmics_;
0156   bool correctShowerTracks_;
0157   bool electronVetoCone_;
0158   bool usePvtxd0_;
0159   bool checkTrackPropagation_;
0160 
0161   class TH2D* response_function_;
0162   class TH2D* showerRF_;
0163   bool hasValidVertex_;
0164   const reco::VertexCollection* vertexColl_;
0165 
0166   bool isMuon(const reco::TrackRef& trackRef);
0167   bool isElectron(const reco::TrackRef& trackRef);
0168   bool isGoodTrack(const reco::TrackRef trackRef);
0169   bool closeToElectron(const reco::TrackRef);
0170   void correctMETforMuon(const reco::TrackRef, reco::MuonRef& muonRef);
0171   void correctMETforMuon(reco::MuonRef& muonRef);
0172   void correctMETforTrack(const reco::TrackRef, TH2D* rf, const TVector3&);
0173   void correctSumEtForTrack(const reco::TrackRef, TH2D* rf, const TVector3&);
0174   class TVector3 propagateTrackToCalorimeterFace(const reco::TrackRef trackRef);
0175   void findGoodShowerTracks(std::vector<int>& goodShowerTracks);
0176   bool nearGoodShowerTrack(const reco::TrackRef, const std::vector<int>& goodShowerTracks);
0177   int nExpectedInnerHits(const reco::TrackRef);
0178   int nExpectedOuterHits(const reco::TrackRef);
0179   int nLayers(const reco::TrackRef);
0180   bool isValidVertex();
0181   void findDuplicateTracks();
0182   int vetoTrack(int i1, int i2);
0183 };
0184 
0185 //____________________________________________________________________________||
0186 #endif  // TCMETAlgo_h