// Authors: Andres Florez, Alfredo Gurrola, Eduardo Luiggi, Chi Nhan Nguyen, Nitish Dhingra, Nil Valls #ifndef _HiMassTauAnalysis_h #define _HiMassTauAnalysis_h // system include files #include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/PatCandidates/interface/Tau.h" #include "DataFormats/PatCandidates/interface/Muon.h" #include "DataFormats/PatCandidates/interface/Electron.h" #include "DataFormats/PatCandidates/interface/Jet.h" //#include "DataFormats/METReco/interface/PFMET.h" //#include "DataFormats/METReco/interface/PFMETCollection.h" #include "DataFormats/PatCandidates/interface/MET.h" #include "DataFormats/PatCandidates/interface/CompositeCandidate.h" #include "DataFormats/Math/interface/LorentzVector.h" #include "DataFormats/Math/interface/LorentzVectorFwd.h" #include "DataFormats/JetReco/interface/GenJetCollection.h" #include "DataFormats/JetReco/interface/GenJet.h" #include "DataFormats/PatCandidates/interface/Isolation.h" #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Math/interface/normalizedPhi.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/MuonReco/interface/MuonSelectors.h" #include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "FWCore/Common/interface/TriggerNames.h" #include "DataFormats/Common/interface/TriggerResults.h" #include "CLHEP/Random/RandGauss.h" #include "CommonTools/CandUtils/interface/Booster.h" #include #include "DataFormats/HLTReco/interface/TriggerObject.h" #include "DataFormats/HLTReco/interface/TriggerEvent.h" #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "DataFormats/RecoCandidate/interface/IsoDeposit.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/EgammaCandidates/interface/Conversion.h" #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace edm; typedef reco::Candidate::LorentzVector LorentzVector; typedef std::vector LVCollection; //typedef std::vector > > IsoDepositMaps; //typedef std::vector > > IsoDepositVals; class HiMassTauAnalysis : public EDAnalyzer { public: explicit HiMassTauAnalysis(const ParameterSet&); ~HiMassTauAnalysis(); protected: virtual void beginJob() ; virtual void analyze(const Event&, const EventSetup&); virtual void endJob() ; void getCollections(const Event&, const EventSetup&); virtual void fillHistograms(); virtual void bookHistograms(); virtual void fillNtuple(); virtual void setupBranches(); virtual void clearVectors(); virtual void initializeVectors(); void getEventFlags(const Event&); bool passEventSelectionSequence(); //bool passGenTauCuts(const LorentzVector&); bool passRecoTriggerCuts(const Event&); bool passRecoVertexCuts(const reco::Vertex&); bool passRecoTauCuts(const pat::Tau&,int); bool passRecoTau2Cuts(const pat::Tau&,int); bool passRecoMuonCuts(const pat::Muon&,int); bool passRecoElectronCuts(const pat::Electron&,int); bool passRecoJetCuts(const pat::Jet&,int); bool passTopologyCuts(const pat::Tau&, int, const pat::Muon&, int); bool passTopologyCuts(const pat::Tau&, int, const pat::Electron&, int); bool passTopologyCuts(const pat::Electron&, int,const pat::Muon&, int); bool passTopologyCuts(const pat::Muon&, int,const pat::Muon&, int); bool passTopologyCuts(const pat::Tau&, int, const pat::Tau&, int); bool passTopologyCuts(const pat::Electron&, int,const pat::Electron&, int); bool isEMuEvent(); bool passTauProngRequirement(const pat::Tau&, string); bool passProngRequirement(const pat::Tau&, const pat::Tau&); template pair matchToGen(const PatObject&, int); pair matchToGen(const pat::Tau&); const reco::Candidate* getGenMotherCand(const reco::Candidate&); template double CalculatePZeta(const PatObject1&, const PatObject2&, const METObject&); template double CalculatePZetaVis(const PatObject1&, const PatObject2&); template std::pair CalculateThe4Momentum(const PatObject1&, const PatObject2&); template double GetVisMass(const PatObject1&, const PatObject2&); template double GetVisPlusMETMass(const PatObject1&, const PatObject2&, const METObject&); template double GetCollinearApproxMass(const PatObject1&, const PatObject2&, const METObject&); template double CalculateLeptonMetMt(const PatObject&, const METObject&); double CalculateEMFraction(const pat::Tau&, int); double alphaRatio(double); std::pair CalculateTauTrackIsolation(const pat::Tau&); std::pair CalculateTauTrackIsolation(const pat::Tau&, float, float); std::pair CalculateTauEcalIsolation(const pat::Tau&); std::pair CalculateTauEcalIsolation(const pat::Tau&, float, float); int CalculateNumberSignalTauGammas(const pat::Tau&); reco::Candidate::LorentzVector CalculateTauSignalTracksMass(const pat::Tau&); reco::Candidate::LorentzVector CalculateTauSignalTracksAndGammasMass(const pat::Tau&); std::pair CalculateTauSignalTracksAndPiZerosMass(const pat::Tau&); std::pair SmearLightLepton(const pat::Muon&); std::pair SmearLightLepton(const pat::Electron&); std::pair SmearTau(const pat::Tau&); std::pair SmearJet(const pat::Jet&); std::pair > isZee(reco::Candidate::LorentzVector); pair > foundZMuMu(); pair > foundZEE(); void InitializeInfoForPDFSystematicUncertaintites(); void setMapSelectionAlgoIDs(); void initMapSelectionCounters(); void printEfficiency(); bool isInTheCracks(float); template std::pair getMatchedPdgId(const PatObject&); double GetTauTriggerWeight(const pat::Tau&); double GetTauTriggerWeight(const pat::Tau&, const pat::Tau&); std::pair getPATComponents(const reco::CompositeCandidate&); std::pair getDiJetComponents(const reco::CompositeCandidate&); std::pair GetGenCandidate(int theCandPDGId, int theCandParentPDGId, int theCandStatusCode); std::pair GetGenCandidate(int theCandPDGId, int theCandStatusCode); std::pair GetGenHadTau(reco::Candidate* theGenTau); std::pairmatchGsfElectronToGen(const reco::GsfElectron& theGsfElec); bool GetTauDiscriminator(const pat::Tau& thePatTau, const reco::PFTauDiscriminator& theTauDisc); //template std::pairmatchToTrigger(std::string, PatObject&); template bool matchToTrigger(std::string, PatObject&); // ----------member data --------------------------- //unsigned int _nTauWRCounter; //unsigned int _nWRCounter; //unsigned int _nHeavyNuCounter; //unsigned int _nTauHeavyNuCounter; //unsigned int _nTauPairCounter; //unsigned int _nMuonCounter; //unsigned int _nMuons; //unsigned int _nTauPairs; long long eventNum; long long runNum; long long lumiBlock; //-----Generator level Inputs InputTag _GenParticleSource; bool _AnalyzeData; bool _AnalyzeSignal; //-----Inputs to determine which channel to analyze bool _AnalyzeTauForLeg1; bool _AnalyzeMuonForLeg1; bool _AnalyzeElectronForLeg1; bool _AnalyzeTauForLeg2; bool _AnalyzeMuonForLeg2; bool _AnalyzeElectronForLeg2; //-----Reco Tau Inputs InputTag _RecoTauSource; double _RecoTauPtMinCut; double _RecoTauPtMaxCut; double _RecoTauEtaCut; double _RecoTauLeadTrackThreshold; double _RecoTauSigGamThreshold; double _RecoTauIsoDeltaRCone; double _RecoTauTrackIsoTrkThreshold; double _RecoTauGammaIsoGamThreshold; double _RecoTauIsoSumPtMinCutValue; double _RecoTauIsoSumPtMaxCutValue; int _RecoTauNisoMax; double _RecoTauTrackIsoSumPtMinCutValue; double _RecoTauTrackIsoSumPtMaxCutValue; double _RecoTauEcalIsoSumPtMinCutValue; double _RecoTauEcalIsoSumPtMaxCutValue; double _RecoTauEcalIsoRphiForEllipse; double _RecoTauEcalIsoRetaForEllipse; double _RecoTauSignal3ProngAndGammasMassMinCutValue; double _RecoTauSignal3ProngAndGammasMassMaxCutValue; double _RecoTauSignal1ProngAndGammasMassForPionMinCutValue; double _RecoTauSignal1ProngAndGammasMassForPionMaxCutValue; double _RecoTauSignal1ProngAndGammasMassForKaonVetoMinCutValue; double _RecoTauSignal1ProngAndGammasMassForKaonVetoMaxCutValue; int _RecoTauTrackNisoMax; int _RecoTauEcalNisoMax; int _RecoTauLeadTrackMinHits; bool _DoRecoTauDiscrByIsolation; bool _UseRecoTauDiscrByIsolationFlag; bool _UseRecoTauIsoSumPtInsteadOfNiso; bool _UseRecoTauEllipseForEcalIso; bool _DoRecoTauDiscrByLeadTrack; bool _DoRecoTauDiscrByLeadTrackNhits; bool _UseRecoTauDiscrByLeadTrackFlag; bool _DoRecoTauDiscrAgainstElectron; bool _DoRecoTauDiscrAgainstMuon; bool _DoRecoTauDiscrByCrackCut; bool _DoRecoTauDiscrBySignalTracksAndGammasMass; bool _SetTANC; bool _SelectTausThatAreMuons; string _RecoTauDiscrByIsolation; string _RecoTauDiscrByLeadTrack; string _RecoTauDiscrAgainstElectron; string _RecoTauDiscrAgainstMuon; string _RecoTau1ProngRequirement; string _RecoTau2ProngRequirement; bool _DoRecoTauDiscrByH3x3OverP; double _RecoTauH3x3OverP; bool _UseTrackAndGammaCombinedIso; double _RecoTau2EtaCut; double _RecoTau2PtMinCut; double _RecoTau2PtMaxCut; double _RecoTau2H3x3OverP; int _RecoTau2LeadTrackMinHits; int _RecoTau2TrackNisoMax; double _RecoTau2TrackIsoSumPtMinCutValue; double _RecoTau2TrackIsoSumPtMaxCutValue; int _RecoTau2EcalNisoMax; double _RecoTau2EcalIsoSumPtMinCutValue; double _RecoTau2EcalIsoSumPtMaxCutValue; double _RecoTau2LeadTrackThreshold; double _RecoTau2SigGamThreshold; int _RecoTau2NisoMax; double _RecoTau2IsoSumPtMinCutValue; double _RecoTau2IsoSumPtMaxCutValue; bool _MatchTau2ToGen; bool _DoRecoTau2DiscrByLeadTrack; bool _DoRecoTau2DiscrByLeadTrackNhits; bool _DoRecoTau2DiscrByH3x3OverP; bool _DoRecoTau2DiscrByIsolation; string _RecoTau2DiscrByProngType; // bool _DoRecoTau2DiscrBySignalTracksAndGammasMass; bool _DoRecoTau2DiscrAgainstMuon; //-----Reco Muon Inputs InputTag _RecoMuonSource; double _RecoMuonPtMinCut; double _RecoMuonPtMaxCut; double _RecoMuonEtaCut; double _RecoMuonTrackIsoSumPtMinCutValue; double _RecoMuonTrackIsoSumPtMaxCutValue; double _RecoMuonEcalIsoSumPtMinCutValue; double _RecoMuonEcalIsoSumPtMaxCutValue; double _RecoMuonIsoDeltaRCone; double _RecoMuonTrackIsoTrkThreshold; double _RecoMuonEcalIsoRecHitThreshold; double _RecoMuonIpCut; double _RecoMuonCaloCompCoefficient; double _RecoMuonSegmCompCoefficient; double _RecoMuonAntiPionCut; bool _DoRecoMuonDiscrByGlobal; bool _DoRecoMuonDiscrByIsolation; bool _DoRecoMuonDiscrByIp; bool _DoRecoMuonDiscrByPionVeto; //-----Reco Electron Inputs InputTag _RecoElectronSource; InputTag _GsfElectronSource; double _RecoElectronPtMinCut; double _RecoElectronPtMaxCut; double _RecoElectronEtaCut; double _RecoElectronTrackIsoSumPtMaxCutValue; double _RecoElectronTrackIsoSumPtMinCutValue; double _RecoElectronTrackIsoDeltaRCone; double _RecoElectronTrackIsoTrkThreshold; double _RecoElectronEcalIsoSumPtMaxCutValue; double _RecoElectronEcalIsoSumPtMinCutValue; double _RecoElectronEcalIsoDeltaRCone; double _RecoElectronEcalIsoRecHitThreshold; double _RecoElectronIpCut; double _RecoElectronEoverPMax; double _RecoElectronEoverPMin; double _RecoElectronHoverEmCut; bool _UseHeepInfo; bool _DoRecoElectronDiscrByTrackIsolation; bool _DoRecoElectronDiscrByEcalIsolation; bool _DoRecoElectronDiscrByIp; bool _DoRecoElectronDiscrByEoverP; bool _DoRecoElectronDiscrByHoverEm; bool _UseElectronUserIsolation; bool _DoRecoElectronDiscrByEcalDrivenSeed; bool _DoRecoElectronDiscrByTrackerDrivenSeed; bool _DoRecoElectronDiscrBySigmaIEtaIEta; double _RecoElectronSigmaIEtaIEta; bool _DoRecoElectronDiscrByDEtaIn; double _RecoElectronEEDEtaIn; double _RecoElectronEBDEtaIn; bool _DoRecoElectronDiscrByDPhiIn; double _RecoElectronEEDPhiIn; double _RecoElectronEBDPhiIn; bool _DoRecoElectronDiscrBySCE2by5Over5by5; double _RecoElectronEBscE1by5Over5by5; double _RecoElectronEBscE2by5Over5by5; bool _DoRecoElectronDiscrByMissingHits; int _RecoElectronMissingHits; //-----Reco ParticleFlow Inputs InputTag _RecoParticleFlowSource; bool _UsePFlowBasedIsolationInsteadOfStandard; //-----Reco Jet Inputs InputTag _RecoJetSource; double _RecoJetPtCut; double _RecoJetEtaMinCut; double _RecoJetEtaMaxCut; double _JetMuonMatchingDeltaR; double _JetElectronMatchingDeltaR; double _JetTauMatchingDeltaR; double _JetBTaggingTCHEcut; bool _UseCorrectedJet; bool _RemoveJetOverlapWithMuons; bool _RemoveJetOverlapWithElectrons; bool _RemoveJetOverlapWithTaus; bool _ApplyJetBTagging; bool _UseVBFJets; double _VBFJetsDeltaEta; //-----Vertex Inputs InputTag _RecoVertexSource; double _RecoVertexMaxZposition; double _RecoVertexTrackWeight; int _RecoVertexMinTracks; InputTag _PileUpSource; float _trueNumInteractions; int _inTimePUNumInteractions; int _outTimePlusPUNumInteractions; int _outTimeMinusPUNumInteractions; /* // For PF based iso std::vector _MuonPFIsoValSource; std::vector _MuonPFIsoDepSource; */ //-----Trigger Inputs InputTag _RecoTriggerSource; std::vector _TriggerRequirements; //-----Topology Inputs // InputTag _RecoDiTauSource; InputTag _RecoMetSource; double _RecoMetCut; double _DiTauDeltaRCut; double _MuTauDeltaRCut; double _DiTauCosDphiMinCut; double _DiTauCosDphiMaxCut; double _MassMinCut; double _MassMaxCut; double _PZetaCutCoefficient; double _PZetaVisCutCoefficient; double _CDFzeta2DCutValue; double _DiTauDeltaPtDivSumPtMinCutValue; double _DiTauDeltaPtDivSumPtMaxCutValue; double _DiTauDeltaPtMinCutValue; double _DiTauDeltaPtMaxCutValue; double _Leg1MetDphiMinCut; double _Leg1MetDphiMaxCut; double _Leg2MetDphiMinCut; double _Leg2MetDphiMaxCut; bool _DoDiscrByMet; bool _CalculateMetUsingOnlyLeg1AndLeg2; bool _DoDiTauDiscrByDeltaR; bool _UseTauSeedTrackForDiTauDiscrByOSLS; bool _DoDiTauDiscrByCosDphi; bool _DoDiscrByMassReco; bool _UseVectorSumOfVisProductsAndMetMassReco; bool _UseCollinearApproxMassReco; bool _DoDiTauDiscrByCDFzeta2D; bool _DoDiTauDiscrByDeltaPtDivSumPt; bool _DoDiTauDiscrByDeltaPt; bool _DoDiscrByLeg1MetDphi; bool _DoDiscrByLeg2MetDphi; bool _DoTauDiscrByIsZeeCut; string _DiTauDiscrByOSLSType; bool _DoDiscrByLeg1MetMt; double _Leg1MetMtMinCut; double _Leg1MetMtMaxCut; bool _DoDiscrByLeg2MetMt; double _Leg2MetMtMinCut; double _Leg2MetMtMaxCut; //-----do matching to gen? bool _MatchTauToGen; bool _UseTauMotherId; bool _UseTauGrandMotherId; bool _MatchLeptonToGen; bool _UseLeptonMotherId; bool _UseLeptonGrandMotherId; int _TauMotherId; int _TauGrandMotherId; int _LeptonMotherId; int _LeptonGrandMotherId; double _TauToGenMatchingDeltaR; std::vector associatedGenParticles; reco::Candidate::LorentzVector MChadtau; const reco::Candidate * daughterCand; const reco::Candidate * motherCand; const reco::Candidate * grandMotherCand; //-----ntuple Inputs TTree *_HMTTree; std::string _NtupleTreeName; bool _DoProduceNtuple; //-----Fill Histograms? bool _FillRecoVertexHists; bool _FillGenTauHists; bool _FillRecoTauHists; bool _FillRecoMuonHists; bool _FillRecoElectronHists; bool _FillRecoJetHists; bool _FillTopologyHists; //-----histogram that keeps track of the number of analyzed events & the number of //-----events passing the user defined cuts std::map _hEvents; //-----vertex histograms std::map _hVertexZposition; std::map _hVertexNTracks; std::map _hNVertices; //-----generator level histograms std::map _hNGenTau; std::map _hGenTauEnergy; std::map _hGenTauPt; std::map _hGenTauEta; std::map _hGenTauPhi; std::map _hGenTauMotherEnergy; std::map _hGenTauMotherPt; std::map _hGenTauMotherEta; std::map _hGenTauMotherPhi; std::map _hGenTauGrandMotherEnergy; std::map _hGenTauGrandMotherPt; std::map _hGenTauGrandMotherEta; std::map _hGenTauGrandMotherPhi; //-----reconstruction level tau histograms std::map _hNTau; std::map _hTauJetEnergy; std::map _hTauJetPt; std::map _hTauJetEta; std::map _hBestTauJetPt; std::map _hBestTauJetEta; std::map _hTauJetPhi; std::map _hTauJetNumSignalTracks; std::map _hTauJetNumSignalGammas; std::map _hTauJetSeedTrackPt; std::map _hBestTauJetSeedTrackPt; std::map _hTauJetSeedTrackIpSignificance; std::map _hTauJetSeedTrackNhits; std::map _hBestTauJetSeedTrackNhits; std::map _hTauJetSeedTrackChi2; std::map _hTauJetCharge; std::map _hTauJetSignalTracksMass; std::map _hTauJetSignalTracksAndGammasMass; std::map _hTauJetSignalTracksMass1prong; std::map _hTauJetSignalTracksAndGammasMass1prong; std::map _hTauJetSignalTracksAndPiZerosMass1prong; std::map _hTauJetNumSignalPiZeros1prong; std::map _hTauJetSignalTracksMass3prong; std::map _hTauJetSignalTracksAndGammasMass3prong; std::map _hTauJetMass1Prong0Gamma; std::map _hTauJetMass1Prong1Gamma; std::map _hTauJetMass1Prong2orMoreGamma; std::map _hTauJetMass3Prong0Gamma; std::map _hTauJetMass3Prong1Gamma; std::map _hTauJetMass3Prong2orMoreGamma; std::map _hTauJetSignalTracksChargeFraction; std::map _hTauJetNumIsoTracks; std::map _hTauJetNumIsoGammas; std::map _hTauJetNumIsoCands; std::map _hTauJetSumPtIsoTracks; std::map _hTauJetSumPtIsoGammas; std::map _hBestTauJetSumPtIsoTracks; std::map _hBestTauJetSumPtIsoGammas; std::map _hTauJetSumPtIso; std::map _hTauJetGenTauDeltaPhi; std::map _hTauJetGenTauDeltaEta; std::map _hTauJetGenTauDeltaPt; std::map _hTauJetH3x3OverP; std::map _hBestTauJetH3x3OverP; // NV: individual tau quantities std::map _htau1NTau; std::map _htau1TauJetEnergy; std::map _htau1TauJetPt; std::map _htau1TauJetEta; std::map _htau1BestTauJetPt; std::map _htau1BestTauJetEta; std::map _htau1TauJetPhi; std::map _htau1TauJetNumSignalTracks; std::map _htau1TauJetNumSignalGammas; std::map _htau1TauJetSeedTrackPt; std::map _htau1BestTauJetSeedTrackPt; std::map _htau1TauJetSeedTrackIpSignificance; std::map _htau1TauJetSeedTrackNhits; std::map _htau1BestTauJetSeedTrackNhits; std::map _htau1TauJetSeedTrackChi2; std::map _htau1TauJetCharge; std::map _htau1TauJetSignalTracksMass; std::map _htau1TauJetSignalTracksAndGammasMass; std::map _htau1TauJetSignalTracksMass1prong; std::map _htau1TauJetSignalTracksAndGammasMass1prong; std::map _htau1TauJetSignalTracksAndPiZerosMass1prong; std::map _htau1TauJetNumSignalPiZeros1prong; std::map _htau1TauJetSignalTracksMass3prong; std::map _htau1TauJetSignalTracksAndGammasMass3prong; std::map _htau1TauJetMass1Prong0Gamma; std::map _htau1TauJetMass1Prong1Gamma; std::map _htau1TauJetMass1Prong2orMoreGamma; std::map _htau1TauJetMass3Prong0Gamma; std::map _htau1TauJetMass3Prong1Gamma; std::map _htau1TauJetMass3Prong2orMoreGamma; std::map _htau1TauJetSignalTracksChargeFraction; std::map _htau1TauJetNumIsoTracks; std::map _htau1TauJetNumIsoGammas; std::map _htau1TauJetNumIsoCands; std::map _htau1TauJetSumPtIsoTracks; std::map _htau1TauJetSumPtIsoGammas; std::map _htau1BestTauJetSumPtIsoTracks; std::map _htau1BestTauJetSumPtIsoGammas; std::map _htau1TauJetSumPtIso; std::map _htau1TauJetGenTauDeltaPhi; std::map _htau1TauJetGenTauDeltaEta; std::map _htau1TauJetGenTauDeltaPt; std::map _htau1TauJetH3x3OverP; std::map _htau1BestTauJetH3x3OverP; std::map _htau2NTau; std::map _htau2TauJetEnergy; std::map _htau2TauJetPt; std::map _htau2TauJetEta; std::map _htau2BestTauJetPt; std::map _htau2BestTauJetEta; std::map _htau2TauJetPhi; std::map _htau2TauJetNumSignalTracks; std::map _htau2TauJetNumSignalGammas; std::map _htau2TauJetSeedTrackPt; std::map _htau2BestTauJetSeedTrackPt; std::map _htau2TauJetSeedTrackIpSignificance; std::map _htau2TauJetSeedTrackNhits; std::map _htau2BestTauJetSeedTrackNhits; std::map _htau2TauJetSeedTrackChi2; std::map _htau2TauJetCharge; std::map _htau2TauJetSignalTracksMass; std::map _htau2TauJetSignalTracksAndGammasMass; std::map _htau2TauJetSignalTracksMass1prong; std::map _htau2TauJetSignalTracksAndGammasMass1prong; std::map _htau2TauJetSignalTracksAndPiZerosMass1prong; std::map _htau2TauJetNumSignalPiZeros1prong; std::map _htau2TauJetSignalTracksMass3prong; std::map _htau2TauJetSignalTracksAndGammasMass3prong; std::map _htau2TauJetMass1Prong0Gamma; std::map _htau2TauJetMass1Prong1Gamma; std::map _htau2TauJetMass1Prong2orMoreGamma; std::map _htau2TauJetMass3Prong0Gamma; std::map _htau2TauJetMass3Prong1Gamma; std::map _htau2TauJetMass3Prong2orMoreGamma; std::map _htau2TauJetSignalTracksChargeFraction; std::map _htau2TauJetNumIsoTracks; std::map _htau2TauJetNumIsoGammas; std::map _htau2TauJetNumIsoCands; std::map _htau2TauJetSumPtIsoTracks; std::map _htau2TauJetSumPtIsoGammas; std::map _htau2BestTauJetSumPtIsoTracks; std::map _htau2BestTauJetSumPtIsoGammas; std::map _htau2TauJetSumPtIso; std::map _htau2TauJetGenTauDeltaPhi; std::map _htau2TauJetGenTauDeltaEta; std::map _htau2TauJetGenTauDeltaPt; std::map _htau2TauJetH3x3OverP; std::map _htau2BestTauJetH3x3OverP; std::map _htau1TauJetEMFraction; std::map _htau2TauJetEMFraction; std::map _hBestTau1Pt; std::map _hBestTau1Eta; std::map _hBestTau1JetSeedTrackPt; std::map _hBestTau1JetH3x3OverP; std::map _hBestTau1JetSeedTrackNhits; std::map _hBestTau1TrackIso; std::map _hBestTau1EcalIso; std::map _hBestTau2Pt; std::map _hBestTau2Eta; std::map _hBestTau2JetSeedTrackPt; std::map _hBestTau2JetH3x3OverP; std::map _hBestTau2JetSeedTrackNhits; std::map _hBestTau2TrackIso; std::map _hBestTau2EcalIso; //-----reconstruction level muon histograms std::map _hNMuon; std::map _hMuonEnergy; std::map _hMuonPt; std::map _hMuonEta; std::map _hBestMuonPt; std::map _hBestMuonEta; std::map _hMuonPhi; std::map _hMuonTrackIso; std::map _hMuonEcalIso; std::map _hBestMuonTrackIso; std::map _hBestMuonEcalIso; std::map _hMuonIp; std::map _hBestMuonIp; std::map _hMuonIpSignificance; std::map _hMuonIso; std::map _hMuonGenMuonDeltaPhi; std::map _hMuonGenMuonDeltaEta; std::map _hMuonGenMuonDeltaPt; std::map _hMuonCaloCompatibility; std::map _hMuonSegmentCompatibility; std::map _hBestMuonCaloCompatibility; std::map _hBestMuonSegmentCompatibility; std::map _hMuonAntiPion; std::map _hBestMuonAntiPion; std::map _hMuonCaloCompatibilityVsSegmentCompatibility; //-----reconstruction level electron histograms std::map _hNElectron; std::map _hElectronEnergy; std::map _hElectronPt; std::map _hElectronEta; std::map _hBestElectronPt; std::map _hBestElectronEta; std::map _hElectronPhi; std::map _hElectronTrackIso; std::map _hElectronEcalIso; std::map _hBestElectronTrackIso; std::map _hBestElectronEcalIso; std::map _hElectronIp; std::map _hElectronEoverP; std::map _hElectronClassification; std::map _hElectronGenElectronDeltaPhi; std::map _hElectronGenElectronDeltaEta; std::map _hElectronGenElectronDeltaPt; std::map _hElectronEcalDriven; std::map _hElectronTrackerDriven; std::map _hElectronHoverEm; std::map _hElectronEESigmaIEtaIEta; std::map _hElectronEEDEta; std::map _hElectronEEDPhi; std::map _hElectronEBSigmaIEtaIEta; std::map _hElectronEBDEta; std::map _hElectronEBDPhi; std::map _hElectronEB2by5Over5by5; std::map _hElectronEB1by5Over5by5; std::map _hElectronMissingHits; std::map _hBestElectronHoverEm; std::map _hBestElectronEESigmaIEtaIEta; std::map _hBestElectronEEDEta; std::map _hBestElectronEEDPhi; std::map _hBestElectronEBSigmaIEtaIEta; std::map _hBestElectronEBDEta; std::map _hBestElectronEBDPhi; std::map _hBestElectronEB2by5Over5by5; std::map _hBestElectronEB1by5Over5by5; std::map _hBestElectronMissingHits; //-----reconstruction level jet histograms std::map _hNJet; std::map _hJetEnergy; std::map _hJetPt; std::map _hJetEta; std::map _hJetPhi; std::map _hBJetDiscrByTrackCounting; std::map _hBJetDiscrBySimpleSecondaryV; std::map _hBJetDiscrByCombinedSecondaryV; //-----reconstruction level topology histograms std::map _hMuonPtVsTauPt; std::map _hMuonTauDeltaR; std::map _hBestMuonTauDeltaR; std::map _hMuonTauDeltaPtDivSumPt; std::map _hMuonTauDeltaPt; std::map _hMuonTauOSLS; std::map _hBestMuonTauOSLS; std::map _hMuonTauCosDphi; std::map _hBestMuonTauCosDphi; std::map _hMuonMetDeltaPhi; std::map _hTauMetDeltaPhi; std::map _hMuonMetDeltaPhiVsMuonTauCosDphi; std::map _hElectronPtVsTauPt; std::map _hElectronTauDeltaR; std::map _hBestElectronTauDeltaR; std::map _hElectronTauDeltaPtDivSumPt; std::map _hElectronTauDeltaPt; std::map _hElectronTauOSLS; std::map _hBestElectronTauOSLS; std::map _hElectronTauCosDphi; std::map _hBestElectronTauCosDphi; std::map _hElectronMetDeltaPhi; std::map _hElectronMetDeltaPhiVsElectronTauCosDphi; std::map _hElectronPtVsMuonPt; std::map _hElectronMuonDeltaR; std::map _hElectronMuonDeltaPtDivSumPt; std::map _hElectronMuonDeltaPt; std::map _hElectronMuonOSLS; std::map _hElectronMuonCosDphi; std::map _hElectronMetDeltaPhiVsElectronMuonCosDphi; std::map _hTau1PtVsTau2Pt; std::map _hTau1Tau2DeltaR; std::map _hTau1Tau2DeltaPtDivSumPt; std::map _hTau1Tau2DeltaPt; std::map _hTau1MetMt; std::map _hTau2MetMt; std::map _hTau1Tau2OSLS; std::map _hTau1Tau2CosDphi; std::map _hTau1MetDeltaPhi; std::map _hTau2MetDeltaPhi; std::map _hTau1MetDeltaPhiVsTau1Tau2CosDphi; std::map _hMuon1PtVsMuon2Pt; std::map _hMuon1Muon2DeltaR; std::map _hMuon1Muon2DeltaPtDivSumPt; std::map _hMuon1Muon2DeltaPt; std::map _hMuon1MetMt; std::map _hMuon2MetMt; std::map _hMuon1Muon2OSLS; std::map _hMuon1Muon2CosDphi; std::map _hMuon1MetDeltaPhi; std::map _hMuon2MetDeltaPhi; std::map _hMuon1MetDeltaPhiVsMuon1Muon2CosDphi; std::map _hElectron1PtVsElectron2Pt; std::map _hElectron1Electron2DeltaR; std::map _hElectron1Electron2DeltaPtDivSumPt; std::map _hElectron1Electron2DeltaPt; std::map _hElectron1MetMt; std::map _hElectron2MetMt; std::map _hElectron1Electron2OSLS; std::map _hElectron1Electron2CosDphi; std::map _hElectron1MetDeltaPhi; std::map _hElectron2MetDeltaPhi; std::map _hElectron1MetDeltaPhiVsElectron1Electron2CosDphi; std::map _hTauMetMt; std::map _hElectronMetMt; std::map _hBestElectronMetMt; std::map _hMuonMetMt; std::map _hBestMuonMetMt; std::map _hNotReconstructableMass; std::map _hReconstructableMass; std::map _hRecoMassTau1MET; std::map _hRecoMassTau2MET; std::map _hPZeta; std::map _hPZetaTemplate; std::map _hPZetaVis; std::map _hZeta2D; std::map _hZeta1D; std::map _hBestZeta1D; std::map _hMet; std::map _hElectronIsZee; std::map _hBestTau1Tau2DeltaR; std::map _hBestTau1Tau2CosDphi; std::map _hBestTau1Tau2OSLS; std::map _htau1EMFractionVsFullMass; std::map _htau2EMFractionVsFullMass; std::map _hVisMass; /* std::map _hTauJetSumPtIso_JetOS; std::map _hTauJetSumPtIso_JetLS; std::map _hTauJetSumPtIso_SeedOS; std::map _hTauJetSumPtIso_SeedLS; */ //-----Handle to tree collections Handle< reco::GenParticleCollection > _genParticles; Handle< pat::TauCollection > _patTaus; Handle< pat::MuonCollection > _patMuons; Handle< pat::ElectronCollection > _patElectrons; Handle< reco::CompositeCandidateCollection > _patDiTaus; Handle< reco::GsfElectronCollection > _gsfElectrons; Handle< pat::JetCollection > _patJets; Handle< pat::METCollection > _patMETs; Handle< reco::VertexCollection > _primaryEventVertexCollection; Handle< edm::TriggerResults > _triggerResults; Handle< trigger::TriggerEvent > handleTriggerEvent; Handle > _pileUpInfo; Handle _beamSpot; Handle _patDiJets; Handle _looseChargedIsoDisc; Handle _mediumChargedIsoDisc; Handle _tightChargedIsoDisc; // Handle< reco::PFCandidateCollection > _pflow; Handle< reco::PFTauCollection > _hpsTau; Handle > _muonPFChargedHadIsoDep; Handle > _muonPFNeutralHadIsoDep; Handle > _muonPFGammaIsoDep; Handle > _muonPFChargedHadIsoVal03; Handle > _muonPFNeturalHadIsoVal03; Handle > _muonPFGammaIsoVal03; /* Handle< edm::View > _recoMuonsForMetCorrections; Handle< ValueMap > vm_muCorrData_h; Handle< edm::View > _patMuonsForMetCorrections; const edm::View& muonsrecoForMetCorrections; const edm::ValueMap& vm_muCorrData; const edm::View& muonsForMetCorrections; */ //-----Event Sequence inputTags int _RecoTriggersNmin; int _RecoVertexNmin; int _RecoVertexNmax; int _RecoLeg1Nmin; int _RecoLeg1Nmax; int _RecoLeg2Nmin; int _RecoLeg2Nmax; int _RecoJetNmin; int _RecoJetNmax; int _CombinationsNmin; int _CombinationsNmax; vector _EventSelectionSequence; //-----Event flags vector _EventFlag; //-----Event counters int _totalEvents; int _totalEventsPassingCuts; //-----Mapping of cut names and cut id std::map _mapSelectionAlgoID; std::map _mapSelectionCounter; std::map _mapSelectionCounterCumul; //-----Inputs for systematic uncertainties bool _CalculatePdfSystematicUncertanties; bool _CalculateFSRSystematics; bool _CalculateISRGluonSystematics; bool _CalculateISRGammaSystematics; std::vector pdfWeightTags_; InputTag FSRWeightTag_; InputTag ISRWeightTag_; std::vector pdfStart_Denominator_; std::vector weightedEvents_Denominator_; std::vector pdfStart_Numerator_; std::vector weightedEvents_Numerator_; double isrgluon_weight; double isrgamma_weight; double fsr_weight; double pu_weight; double trig_weight; double pdfcentral_weight; bool _SmearTheMuon; double _MuonPtScaleOffset; double _MuonPtSigmaOffset; double _MuonEtaScaleOffset; double _MuonEtaSigmaOffset; double _MuonPhiScaleOffset; double _MuonPhiSigmaOffset; bool _SmearTheElectron; double _ElectronPtScaleOffset; double _ElectronPtSigmaOffset; double _ElectronEtaScaleOffset; double _ElectronEtaSigmaOffset; double _ElectronPhiScaleOffset; double _ElectronPhiSigmaOffset; bool _SmearTheTau; double _TauPtScaleOffset; double _TauPtSigmaOffset; double _TauEtaScaleOffset; double _TauEtaSigmaOffset; double _TauPhiScaleOffset; double _TauPhiSigmaOffset; bool _SmearTheJet; double _JetEnergyScaleOffset; bool _SmearThePt; bool _SmearTheEta; bool _SmearThePhi; bool _CalculatePUSystematics; double _PUConstantWeightFactor; double _PUConstantWeightFactorRMS; double _PUSlopeWeightParameter; double _PUSlopeWeightParameterRMS; bool _ApplyMuonTriggerScaleFactors; bool _ApplyElectronTriggerScaleFactors; bool _ApplyTauTriggerScaleFactors; std::vector smearedMuonMomentumVector; std::vector smearedMuonPtEtaPhiMVector; std::vector smearedElectronMomentumVector; std::vector smearedElectronPtEtaPhiMVector; std::vector smearedTauMomentumVector; std::vector smearedTauPtEtaPhiMVector; std::vector smearedJetMomentumVector; reco::Candidate::LorentzVector maxPtMuonVector; reco::Candidate::LorentzVector maxEtElectronVector; std::vector smearedJetPtEtaPhiMVector; std::vector bosonPtBinEdges_; std::vector ptWeights_; std::vector MuonTrigPtBinEdges_; std::vector MuonTrigptWeights_; std::vector MuonTrigEtaBinEdges_; std::vector MuonTrigetaWeights_; std::vector ElectronTrigPtBinEdges_; std::vector ElectronTrigptWeights_; std::vector ElectronTrigEtaBinEdges_; std::vector ElectronTrigetaWeights_; std::vector TauTrigPtBinEdges_; std::vector TauTrigptWeights_; std::vector TauTrigEtaBinEdges_; std::vector TauTrigetaWeights_; double deltaForMEx; double deltaForMEy; reco::Candidate::LorentzVector theMETVector; //-----For Ntuple vector pdfWeightVector; bool _passedHLTMu5Elec17; bool _passedHLTMu11Elec8; bool _passedHLTMu8Elec17; bool _passedHLTMu17Elec8; bool _passedHLTIsoMu24; bool _passedHLTElec27WP80; // for pf iso computation and electron ID typedef std::vector< edm::Handle< edm::ValueMap > > IsoDepositVals; std::vector _IsoValElecPFDr03VInputTag; std::vector _IsoValElecPFDr04VInputTag; IsoDepositVals _elecIsoValPFIdDr03; IsoDepositVals _elecIsoValPFIdDr04; edm::Handle _elecRhoIso; InputTag _ElecRhoIsoSource; double elecRhoIso; edm::Handle _elecConversions; InputTag _ConversionSource; }; template pair HiMassTauAnalysis::getMatchedPdgId(const PatObject& patObject){ pair theTrackAndMotherPdgId; float minDeltaPt = 1000.; float minDeltaR = 0.2; unsigned int thePdgId = 0; unsigned int theMotherPdgId = 0; for(reco::GenParticleCollection::const_iterator genParticle = _genParticles->begin();genParticle != _genParticles->end();++genParticle){ if(genParticle->status() != 1) continue; // match only to final states... //if(patObject.charge() != genParticle->charge() || genParticle->status() != 1)continue; // match only to final states... //if(reco::deltaR(patObject.eta(), patObject.phi(), genParticle->eta(), genParticle->phi()) > minDeltaR) continue ; float theDeltaR = reco::deltaR(patObject.eta(), patObject.phi(), genParticle->eta(), genParticle->phi()); if(theDeltaR pdgId()); theMotherPdgId = abs(genParticle->mother()->pdgId()); } } theTrackAndMotherPdgId = make_pair(thePdgId, theMotherPdgId); return theTrackAndMotherPdgId; } template double HiMassTauAnalysis::GetVisMass(const PatObject1& patObject1, const PatObject2& patObject2){ reco::Candidate::LorentzVector The_LorentzVect = patObject1.p4() + patObject2.p4(); return The_LorentzVect.M(); } template double HiMassTauAnalysis::GetVisPlusMETMass(const PatObject1& patObject1, const PatObject2& patObject2, const METObject& theMEt){ double px = patObject1.px() + patObject2.px() + theMEt.px(); double py = patObject1.py() + patObject2.py() + theMEt.py(); double pz = patObject1.pz() + patObject2.pz(); double e = patObject1.energy() + patObject2.energy() + TMath::Sqrt((theMEt.px() * theMEt.px()) + (theMEt.py() * theMEt.py())); reco::Candidate::LorentzVector The_LorentzVect(px, py, pz, e); return The_LorentzVect.M(); } template double HiMassTauAnalysis::GetCollinearApproxMass(const PatObject1& patObject1, const PatObject2& patObject2, const METObject& theMEt){ double x1_numerator = (patObject1.px() * patObject2.py()) - (patObject2.px() * patObject1.py()); double x1_denominator = (patObject2.py() * (patObject1.px() + theMEt.px())) - (patObject2.px() * (patObject1.py() + theMEt.py())); double x1 = ( x1_denominator != 0. ) ? x1_numerator/x1_denominator : -1.; double x2_numerator = x1_numerator; double x2_denominator = (patObject1.px() * (patObject2.py() + theMEt.py())) - (patObject1.py() * (patObject2.px() + theMEt.px())); double x2 = ( x2_denominator != 0. ) ? x2_numerator/x2_denominator : -1.; if ( (x1 > 0. && x1 < 1.) && (x2 > 0. && x2 < 1.) ) { reco::Candidate::LorentzVector The_LorentzVect = (patObject1.p4() / x1) + (patObject2.p4() / x2); return The_LorentzVect.M(); } else return -1.; } //-----Calculate lepton+met transverse mass template double HiMassTauAnalysis::CalculateLeptonMetMt(const PatObject& patObject, const METObject& theMET) { double px = patObject.px() + theMET.px(); double py = patObject.py() + theMET.py(); double et = patObject.et() + TMath::Sqrt((theMET.px() * theMET.px()) + (theMET.py() * theMET.py())); double mt2 = et*et - (px*px + py*py); if ( mt2 < 0 ) { return -1.; } else { return sqrt(mt2); } } //-----Calculate zeta variable template double HiMassTauAnalysis::CalculatePZeta(const PatObject1& patObject1, const PatObject2& patObject2, const METObject& theMET) { double zetaX = cos(patObject1.phi()) + cos(patObject2.phi()); double zetaY = sin(patObject1.phi()) + sin(patObject2.phi()); double zetaR = TMath::Sqrt(zetaX*zetaX + zetaY*zetaY); if ( zetaR > 0. ) { zetaX /= zetaR; zetaY /= zetaR; } double visPx = patObject1.px() + patObject2.px(); double visPy = patObject1.py() + patObject2.py(); double px = visPx + theMET.px(); double py = visPy + theMET.py(); double pZeta = px*zetaX + py*zetaY; return pZeta; } //-----Calculate PzetaVis variable template double HiMassTauAnalysis::CalculatePZetaVis(const PatObject1& patObject1, const PatObject2& patObject2) { double zetaX = cos(patObject1.phi()) + cos(patObject2.phi()); double zetaY = sin(patObject1.phi()) + sin(patObject2.phi()); double zetaR = TMath::Sqrt(zetaX*zetaX + zetaY*zetaY); if ( zetaR > 0. ) { zetaX /= zetaR; zetaY /= zetaR; } double visPx = patObject1.px() + patObject2.px(); double visPy = patObject1.py() + patObject2.py(); double pZetaVis = visPx*zetaX + visPy*zetaY; return pZetaVis; } template pair HiMassTauAnalysis::matchToGen(const PatObject& theObject, int thePdgID) { bool isGenMatched = false; reco::Candidate::LorentzVector theGenObject(0,0,0,0); associatedGenParticles = theObject.genParticleRefs(); for(std::vector::const_iterator it = associatedGenParticles.begin(); it != associatedGenParticles.end(); ++it){ if ( it->isNonnull() && it->isAvailable() ) { const reco::GenParticleRef& genParticle = (*it); if (abs(genParticle->pdgId()) == thePdgID) { motherCand = getGenMotherCand(*genParticle); grandMotherCand = getGenMotherCand(*motherCand); if(_UseLeptonMotherId) { if(abs(motherCand->pdgId()) == _LeptonMotherId) { if(_UseLeptonGrandMotherId) { if(abs(grandMotherCand->pdgId()) == _LeptonGrandMotherId) {isGenMatched = true;theGenObject = genParticle->p4();} } else { isGenMatched = true; theGenObject = genParticle->p4(); } } } else { isGenMatched = true; theGenObject = genParticle->p4(); } } } } pair GenMatchedInformation(isGenMatched,theGenObject); return GenMatchedInformation; } template //std::pair HiMassTauAnalysis::matchToTrigger(std::string theTriggerName, PatObject& patObject){ bool HiMassTauAnalysis::matchToTrigger(std::string theTriggerName, PatObject& patObject){ //reco::Candidate::LorentzVector theTriggerObject(0.,0.,0.,0.); bool matchedToTrigger = false; const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects()); for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) { std::string fullname = handleTriggerEvent->filterTag(ia).encode(); std::string name; size_t p = fullname.find_first_of(':'); if ( p != std::string::npos) {name = fullname.substr(0, p);} else {name = fullname;} //std::cout << "name = " << name << std::endl; if ( &toc !=0 ) { const trigger::Keys & k = handleTriggerEvent->filterKeys(ia); for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) { reco::Particle theTriggerParticle = toc[*ki].particle(); if(name.find(theTriggerName) != string::npos){ //if(name == "HLT_Ele27_WP80_v10"){ if((reco::deltaR(patObject.eta(), patObject.phi(),theTriggerParticle.eta(),theTriggerParticle.phi()) <= 0.2)){ matchedToTrigger = true; //theTriggerObject = theTriggerParticle.p4(); } } } } } //std::pair thePair = make_pair(matchedToTrigger,theTriggerObject); //return thePair; return matchedToTrigger; } #endif